Changeset 220392 in webkit
- Timestamp:
- Aug 8, 2017 12:46:42 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r220391 r220392 1 2017-08-08 Zan Dobersek <zdobersek@igalia.com> 2 3 [TexMap] Add TextureMapperContextAttributes 4 https://bugs.webkit.org/show_bug.cgi?id=175311 5 6 Reviewed by Carlos Garcia Campos. 7 8 Add and use TextureMapperContextAttributes, a slim struct that holds 9 information about the type and extensions supported by the OpenGL 10 context that's being used for one specific TextureMapperGL instance. 11 12 This struct is initialized in the TextureMapperGL constructor for the 13 OpenGL context that's been made current on that thread, and that will 14 be used for that TextureMapperGL instance through its lifetime. The 15 struct is then also copied into any BitmapTextureGL objects that have 16 been created through this TextureMapperGL (or its texture pool). 17 18 The struct is initialized with information about GLES2 support (which 19 is at this point done through the USE_OPENGL_ES_2 macro) and about 20 specific OpenGL extensions that are supported. These are then used in 21 TextureMapperGL (NPOT textures) and BitmapTextureGL (BGRA support, 22 sub-image unpacking) to deploy specific optimizations or workarounds. 23 24 This ultimately serves as a replacement for clunky static functions 25 that need to operate on GraphicsContext3D objects to retrieve this 26 information. 27 28 No new tests -- no change in behavior. 29 30 * platform/TextureMapper.cmake: 31 * platform/graphics/texmap/BitmapTextureGL.cpp: 32 (WebCore::BitmapTextureGL::BitmapTextureGL): 33 (WebCore::BitmapTextureGL::updateContentsNoSwizzle): 34 (WebCore::BitmapTextureGL::updateContents): 35 (WebCore::driverSupportsSubImage): Deleted. 36 * platform/graphics/texmap/BitmapTextureGL.h: 37 (WebCore::BitmapTextureGL::create): 38 * platform/graphics/texmap/BitmapTexturePool.cpp: 39 (WebCore::BitmapTexturePool::BitmapTexturePool): 40 (WebCore::BitmapTexturePool::createTexture): 41 * platform/graphics/texmap/BitmapTexturePool.h: 42 * platform/graphics/texmap/TextureMapperContextAttributes.cpp: Added. 43 (WebCore::TextureMapperContextAttributes::initialize): 44 * platform/graphics/texmap/TextureMapperContextAttributes.h: Added. 45 * platform/graphics/texmap/TextureMapperGL.cpp: 46 (WebCore::TextureMapperGL::TextureMapperGL): 47 (WebCore::TextureMapperGL::drawTexture): 48 (WebCore::TextureMapperGL::drawTexturedQuadWithProgram): 49 (WebCore::TextureMapperGL::createTexture): 50 (WebCore::driverSupportsNPOTTextures): Deleted. 51 * platform/graphics/texmap/TextureMapperGL.h: 52 1 53 2017-08-08 Zan Dobersek <zdobersek@igalia.com> 2 54 -
trunk/Source/WebCore/platform/TextureMapper.cmake
r212811 r220392 18 18 platform/graphics/texmap/BitmapTextureGL.cpp 19 19 platform/graphics/texmap/ClipStack.cpp 20 platform/graphics/texmap/TextureMapperContextAttributes.cpp 20 21 platform/graphics/texmap/TextureMapperGL.cpp 21 22 platform/graphics/texmap/TextureMapperShaderProgram.cpp -
trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp
r218170 r220392 58 58 } 59 59 60 BitmapTextureGL::BitmapTextureGL(RefPtr<GraphicsContext3D>&& context3D, const Flags flags, GC3Dint internalFormat) 61 : m_context3D(WTFMove(context3D)) 60 BitmapTextureGL::BitmapTextureGL(const TextureMapperContextAttributes& contextAttributes, RefPtr<GraphicsContext3D>&& context3D, const Flags flags, GC3Dint internalFormat) 61 : m_contextAttributes(contextAttributes) 62 , m_context3D(WTFMove(context3D)) 62 63 { 63 64 if (internalFormat != GraphicsContext3D::DONT_CARE) { … … 73 74 m_internalFormat = GraphicsContext3D::RGBA; 74 75 m_format = GraphicsContext3D::BGRA; 75 if (m_context 3D->isGLES2Compliant()) {76 if (m_context 3D->getExtensions().supports("GL_EXT_texture_format_BGRA8888"))76 if (m_contextAttributes.isGLES2Compliant) { 77 if (m_contextAttributes.supportsBGRA8888) 77 78 m_internalFormat = GraphicsContext3D::BGRA; 78 79 else … … 90 91 p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); 91 92 } 92 }93 94 static bool driverSupportsSubImage(GraphicsContext3D* context)95 {96 if (context->isGLES2Compliant()) {97 static bool supportsSubImage = context->getExtensions().supports("GL_EXT_unpack_subimage");98 return supportsSubImage;99 }100 101 return true;102 93 } 103 94 … … 123 114 void BitmapTextureGL::updateContentsNoSwizzle(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, unsigned bytesPerPixel, Platform3DObject glFormat) 124 115 { 116 // For ES drivers that don't support sub-images. 117 bool contextSupportsUnpackSubimage = m_contextAttributes.supportsUnpackSubimage; 118 125 119 m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id); 126 // For ES drivers that don't support sub-images. 127 if ( driverSupportsSubImage(m_context3D.get())) {120 121 if (contextSupportsUnpackSubimage) { 128 122 // Use the OpenGL sub-image extension, now that we know it's available. 129 123 m_context3D->pixelStorei(GraphicsContext3D::UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel); … … 134 128 m_context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, m_type, srcData); 135 129 136 // For ES drivers that don't support sub-images. 137 if (driverSupportsSubImage(m_context3D.get())) { 130 if (contextSupportsUnpackSubimage) { 138 131 m_context3D->pixelStorei(GraphicsContext3D::UNPACK_ROW_LENGTH, 0); 139 132 m_context3D->pixelStorei(GraphicsContext3D::UNPACK_SKIP_ROWS, 0); … … 152 145 153 146 // Texture upload requires subimage buffer if driver doesn't support subimage and we don't have full image upload. 154 bool requireSubImageBuffer = ! driverSupportsSubImage(m_context3D.get())147 bool requireSubImageBuffer = !m_contextAttributes.supportsUnpackSubimage 155 148 && !(bytesPerLine == static_cast<int>(targetRect.width() * bytesPerPixel) && adjustedSourceOffset == IntPoint::zero()); 156 149 -
trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h
r218170 r220392 29 29 #include "GraphicsContext3D.h" 30 30 #include "IntSize.h" 31 #include "TextureMapperContextAttributes.h" 31 32 #include "TextureMapperGL.h" 32 33 … … 39 40 class BitmapTextureGL : public BitmapTexture { 40 41 public: 41 static Ref<BitmapTexture> create( Ref<GraphicsContext3D>&& context3D, const Flags flags = NoFlag, GC3Dint internalFormat = GraphicsContext3D::DONT_CARE)42 static Ref<BitmapTexture> create(const TextureMapperContextAttributes& contextAttributes, Ref<GraphicsContext3D>&& context3D, const Flags flags = NoFlag, GC3Dint internalFormat = GraphicsContext3D::DONT_CARE) 42 43 { 43 return adoptRef(*new BitmapTextureGL( WTFMove(context3D), flags, internalFormat));44 return adoptRef(*new BitmapTextureGL(contextAttributes, WTFMove(context3D), flags, internalFormat)); 44 45 } 45 46 … … 80 81 81 82 private: 82 BitmapTextureGL( RefPtr<GraphicsContext3D>&&, const Flags, GC3Dint internalFormat);83 BitmapTextureGL(const TextureMapperContextAttributes&, RefPtr<GraphicsContext3D>&&, const Flags, GC3Dint internalFormat); 83 84 84 85 Platform3DObject m_id { 0 }; … … 90 91 bool m_shouldClear { true }; 91 92 ClipStack m_clipStack; 93 TextureMapperContextAttributes m_contextAttributes; 92 94 RefPtr<GraphicsContext3D> m_context3D; 93 95 -
trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp
r217784 r220392 38 38 39 39 #if USE(TEXTURE_MAPPER_GL) 40 BitmapTexturePool::BitmapTexturePool(RefPtr<GraphicsContext3D>&& context3D) 41 : m_context3D(WTFMove(context3D)) 40 BitmapTexturePool::BitmapTexturePool(const TextureMapperContextAttributes& contextAttributes, RefPtr<GraphicsContext3D>&& context3D) 41 : m_contextAttributes(contextAttributes) 42 , m_context3D(WTFMove(context3D)) 42 43 , m_releaseUnusedTexturesTimer(RunLoop::current(), this, &BitmapTexturePool::releaseUnusedTexturesTimerFired) 43 44 { … … 94 95 { 95 96 #if USE(TEXTURE_MAPPER_GL) 96 return BitmapTextureGL::create( *m_context3D, flags);97 return BitmapTextureGL::create(m_contextAttributes, *m_context3D, flags); 97 98 #else 98 99 UNUSED_PARAM(flags); -
trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h
r217213 r220392 29 29 30 30 #include "BitmapTexture.h" 31 #include "TextureMapperContextAttributes.h" 31 32 #include <wtf/CurrentTime.h> 32 33 #include <wtf/RunLoop.h> … … 46 47 public: 47 48 #if USE(TEXTURE_MAPPER_GL) 48 explicit BitmapTexturePool( RefPtr<GraphicsContext3D>&&);49 explicit BitmapTexturePool(const TextureMapperContextAttributes&, RefPtr<GraphicsContext3D>&&); 49 50 #endif 50 51 … … 69 70 70 71 #if USE(TEXTURE_MAPPER_GL) 72 TextureMapperContextAttributes m_contextAttributes; 71 73 RefPtr<GraphicsContext3D> m_context3D; 72 74 #endif -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
r220391 r220392 166 166 : m_enableEdgeDistanceAntialiasing(false) 167 167 { 168 m_contextAttributes.initialize(); 169 168 170 m_context3D = GraphicsContext3D::createForCurrentGLContext(); 169 171 ASSERT(m_context3D); … … 171 173 m_data = new TextureMapperGLData(*m_context3D); 172 174 #if USE(TEXTURE_MAPPER_GL) 173 m_texturePool = std::make_unique<BitmapTexturePool>(m_context 3D.copyRef());175 m_texturePool = std::make_unique<BitmapTexturePool>(m_contextAttributes, m_context3D.copyRef()); 174 176 #endif 175 177 } … … 437 439 } 438 440 439 static bool driverSupportsNPOTTextures(GraphicsContext3D& context)440 {441 if (context.isGLES2Compliant()) {442 static bool supportsNPOTTextures = context.getExtensions().supports("GL_OES_texture_npot");443 return supportsNPOTTextures;444 }445 446 return true;447 }448 449 441 void TextureMapperGL::drawTexture(Platform3DObject texture, Flags flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, unsigned exposedEdges) 450 442 { … … 463 455 flags |= ShouldAntialias; 464 456 } 465 if (wrapMode() == RepeatWrap && ! driverSupportsNPOTTextures(*m_context3D))457 if (wrapMode() == RepeatWrap && !m_contextAttributes.supportsNPOTTextures) 466 458 options |= TextureMapperShaderProgram::ManualRepeat; 467 459 … … 592 584 m_context3D->bindTexture(target, texture); 593 585 m_context3D->uniform1i(program.samplerLocation(), 0); 594 if (wrapMode() == RepeatWrap && driverSupportsNPOTTextures(*m_context3D)) {586 if (wrapMode() == RepeatWrap && m_contextAttributes.supportsNPOTTextures) { 595 587 m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::REPEAT); 596 588 m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::REPEAT); … … 769 761 Ref<BitmapTexture> TextureMapperGL::createTexture(GC3Dint internalFormat) 770 762 { 771 return BitmapTextureGL::create( *m_context3D, internalFormat);763 return BitmapTextureGL::create(m_contextAttributes, *m_context3D, internalFormat); 772 764 } 773 765 -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
r220391 r220392 29 29 #include "IntSize.h" 30 30 #include "TextureMapper.h" 31 #include "TextureMapperContextAttributes.h" 31 32 #include "TransformationMatrix.h" 32 33 … … 91 92 ClipStack& clipStack(); 92 93 inline TextureMapperGLData& data() { return *m_data; } 94 95 TextureMapperContextAttributes m_contextAttributes; 93 96 RefPtr<GraphicsContext3D> m_context3D; 94 97 TextureMapperGLData* m_data;
Note: See TracChangeset
for help on using the changeset viewer.