Changeset 193723 in webkit
- Timestamp:
- Dec 8, 2015 12:36:02 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r193688 r193723 1 2015-12-08 Gwang Yoon Hwang <yoon@igalia.com> 2 3 [ThreadedCompositor] Support WebGL for OpenGL. 4 https://bugs.webkit.org/show_bug.cgi?id=143300 5 6 Reviewed by Žan Doberšek. 7 8 To remove pixel transfer operation, this patch adds m_compositorFBO which uses same depth and stencil 9 buffer with m_fbo but uses m_compositorTexture as a color attachment in GraphicsContext3D. 10 Because switching target framebuffer is cheaper than pixel transfer operation and switching color 11 attachment of m_fbo. In Threaded Compositor, when WebGL renders a scene, prepareTexture swaps 12 m_fbo with m_compositorFBO and send the color attachment to the compositor thread. 13 This patch only supports WebGL for OpenGL. OpenGLES will be covered in following-up patches. 14 15 No new tests needed. 16 17 * platform/graphics/GraphicsContext3D.h: 18 * platform/graphics/GraphicsContext3DPrivate.cpp: 19 (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): 20 (WebCore::GraphicsContext3DPrivate::proxy): 21 (WebCore::GraphicsContext3DPrivate::swapBuffersIfNeeded): 22 Implement interfaces to pass a rendered texture to the compositing 23 thread. 24 * platform/graphics/GraphicsContext3DPrivate.h: 25 * platform/graphics/cairo/GraphicsContext3DCairo.cpp: 26 (WebCore::GraphicsContext3D::GraphicsContext3D): 27 (WebCore::GraphicsContext3D::~GraphicsContext3D): 28 Create additional compositing texture and FBO to swaping buffers for 29 threaded compositor. 30 * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: 31 (WebCore::GraphicsContext3D::reshapeFBOs): 32 (WebCore::GraphicsContext3D::attachDepthAndStencilBufferIfNeeded): 33 Split attaching depth and stencil buffer codes from reshapeFBOs 34 to make complete framebuffer with not only m_fbo but m_compositorFBO also. 35 * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp: 36 (WebCore::GraphicsContext3D::prepareTexture): 37 If we are in the threaded compositor, we will swap m_fbo with 38 m_compositorFBO instead of copying it. 39 1 40 2015-12-07 Zalan Bujtas <zalan@apple.com> 2 41 -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h
r189144 r193723 1294 1294 bool reshapeFBOs(const IntSize&); 1295 1295 void resolveMultisamplingIfNecessary(const IntRect& = IntRect()); 1296 void attachDepthAndStencilBufferIfNeeded(GLuint internalDepthStencilFormat, int width, int height); 1296 1297 #if PLATFORM(EFL) && USE(GRAPHICS_SURFACE) 1297 1298 void createGraphicsSurfaces(const IntSize&); … … 1418 1419 GC3Duint m_compositorTexture; 1419 1420 GC3Duint m_fbo; 1421 #if USE(COORDINATED_GRAPHICS_THREADED) 1422 GC3Duint m_compositorFBO; 1423 #endif 1420 1424 1421 1425 GC3Duint m_depthBuffer; -
trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.cpp
r193630 r193723 42 42 #endif 43 43 44 #if USE(COORDINATED_GRAPHICS_THREADED) 45 #include "TextureMapperPlatformLayerBuffer.h" 46 #endif 47 44 48 using namespace std; 45 49 … … 60 64 break; 61 65 } 66 67 #if USE(COORDINATED_GRAPHICS_THREADED) 68 if (m_renderStyle == GraphicsContext3D::RenderOffscreen) 69 m_platformLayerProxy = adoptRef(new TextureMapperPlatformLayerProxy()); 70 #endif 62 71 } 63 72 … … 83 92 RefPtr<TextureMapperPlatformLayerProxy> GraphicsContext3DPrivate::proxy() const 84 93 { 85 notImplemented(); 86 return nullptr; 94 return m_platformLayerProxy.copyRef(); 87 95 } 88 #elif USE(TEXTURE_MAPPER) 96 97 void GraphicsContext3DPrivate::swapBuffersIfNeeded() 98 { 99 ASSERT(m_renderStyle == GraphicsContext3D::RenderOffscreen); 100 if (m_context->layerComposited()) 101 return; 102 103 m_context->prepareTexture(); 104 IntSize textureSize(m_context->m_currentWidth, m_context->m_currentHeight); 105 TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context->m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0); 106 107 { 108 LockHolder holder(m_platformLayerProxy->lock()); 109 m_platformLayerProxy->pushNextBuffer(std::make_unique<TextureMapperPlatformLayerBuffer>(m_context->m_compositorTexture, textureSize, flags)); 110 } 111 112 m_context->markLayerComposited(); 113 } 114 #elif USE(TEXTURE_MAPPER) && !USE(COORDINATED_GRAPHICS_THREADED) 89 115 void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity) 90 116 { -
trunk/Source/WebCore/platform/graphics/GraphicsContext3DPrivate.h
r193630 r193723 25 25 26 26 #if USE(COORDINATED_GRAPHICS_THREADED) 27 #include "BitmapTextureGL.h" 27 28 #include "TextureMapperPlatformLayerProxy.h" 28 29 #elif USE(TEXTURE_MAPPER) … … 49 50 #if USE(COORDINATED_GRAPHICS_THREADED) 50 51 virtual RefPtr<TextureMapperPlatformLayerProxy> proxy() const override; 51 virtual void swapBuffersIfNeeded() override { };52 virtual void swapBuffersIfNeeded() override; 52 53 #elif USE(TEXTURE_MAPPER) 53 54 virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity); … … 58 59 std::unique_ptr<GLContext> m_glContext; 59 60 GraphicsContext3D::RenderStyle m_renderStyle; 61 62 #if USE(COORDINATED_GRAPHICS_THREADED) 63 RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy; 64 RefPtr<BitmapTextureGL> m_compositorTexture; 65 #endif 60 66 }; 61 67 -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
r183432 r193723 86 86 , m_compositorTexture(0) 87 87 , m_fbo(0) 88 #if USE(COORDINATED_GRAPHICS_THREADED) 89 , m_compositorFBO(0) 90 #endif 88 91 , m_depthStencilBuffer(0) 92 , m_layerComposited(false) 89 93 , m_multisampleFBO(0) 90 94 , m_multisampleDepthStencilBuffer(0) … … 110 114 ::glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); 111 115 116 #if USE(COORDINATED_GRAPHICS_THREADED) 117 ::glGenFramebuffers(1, &m_compositorFBO); 118 ::glGenTextures(1, &m_compositorTexture); 119 ::glBindTexture(GL_TEXTURE_2D, m_compositorTexture); 120 ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 121 ::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 122 ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 123 ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 124 ::glBindTexture(GL_TEXTURE_2D, 0); 125 #endif 126 112 127 m_state.boundFBO = m_fbo; 113 128 if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) … … 175 190 } 176 191 ::glDeleteFramebuffers(1, &m_fbo); 192 #if USE(COORDINATED_GRAPHICS_THREADED) 193 ::glDeleteFramebuffers(1, &m_compositorFBO); 194 #endif 177 195 } 178 196 -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
r183432 r193723 173 173 ::glTexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); 174 174 ::glBindTexture(GL_TEXTURE_2D, 0); 175 } 176 #endif 177 175 #if USE(COORDINATED_GRAPHICS_THREADED) 176 ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_compositorFBO); 177 ::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_compositorTexture, 0); 178 attachDepthAndStencilBufferIfNeeded(internalDepthStencilFormat, width, height); 179 ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); 180 #endif 181 } 182 #endif 183 184 attachDepthAndStencilBufferIfNeeded(internalDepthStencilFormat, width, height); 185 186 bool mustRestoreFBO = true; 187 if (m_attrs.antialias) { 188 ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO); 189 if (m_state.boundFBO == m_multisampleFBO) 190 mustRestoreFBO = false; 191 } else { 192 if (m_state.boundFBO == m_fbo) 193 mustRestoreFBO = false; 194 } 195 196 return mustRestoreFBO; 197 } 198 199 void GraphicsContext3D::attachDepthAndStencilBufferIfNeeded(GLuint internalDepthStencilFormat, int width, int height) 200 { 178 201 if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) { 179 202 ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthStencilBuffer); … … 190 213 notImplemented(); 191 214 } 192 193 bool mustRestoreFBO = true;194 if (m_attrs.antialias) {195 ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);196 if (m_state.boundFBO == m_multisampleFBO)197 mustRestoreFBO = false;198 } else {199 if (m_state.boundFBO == m_fbo)200 mustRestoreFBO = false;201 }202 203 return mustRestoreFBO;204 215 } 205 216 -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
r190382 r193723 224 224 makeContextCurrent(); 225 225 226 #if !USE(COORDINATED_GRAPHICS_THREADED) 226 227 TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE); 227 228 TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE); 228 229 #endif 230 229 231 if (m_attrs.antialias) 230 232 resolveMultisamplingIfNecessary(); 233 234 #if USE(COORDINATED_GRAPHICS_THREADED) 235 std::swap(m_fbo, m_compositorFBO); 236 std::swap(m_texture, m_compositorTexture); 237 238 if (m_state.boundFBO != m_compositorFBO) 239 ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO); 240 else 241 ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo); 242 return; 243 #endif 231 244 232 245 ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo); -
trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
r193630 r193723 387 387 if (m_platformLayer) 388 388 m_pendingPlatformLayerOperation |= SyncPlatformLayer; 389 #elif USE(COORDINATED_GRAPHICS_THREADED) 390 if (m_platformLayer) 391 m_shouldSyncPlatformLayer = true; 389 392 #endif 390 393
Note: See TracChangeset
for help on using the changeset viewer.