Changeset 106524 in webkit
- Timestamp:
- Feb 1, 2012 6:42:14 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106523 r106524 1 2012-02-01 No'am Rosenthal <noam.rosenthal@nokia.com> 2 3 [Texmap] Use glScissors for clipping in TextureMapperGL when possible 4 https://bugs.webkit.org/show_bug.cgi?id=77575 5 6 Reviewed by Martin Robinson. 7 8 Maintain a clipping stack, that helps us use stencils in conjunction with scissors. 9 We apply scissors when the clip region is rectalinear, and stencil when it's not. 10 11 No behavior changes so no new tests. 12 13 * platform/graphics/opengl/TextureMapperGL.cpp: 14 (SharedGLData): 15 (WebCore::TextureMapperGLData::SharedGLData::SharedGLData): 16 (WebCore::TextureMapperGL::drawTexture): 17 (WebCore::TextureMapperGL::bindSurface): 18 (WebCore): 19 (WebCore::scissorClip): 20 (WebCore::TextureMapperGL::beginScissorClip): 21 (WebCore::TextureMapperGL::endScissorClip): 22 (WebCore::TextureMapperGL::beginClip): 23 (WebCore::TextureMapperGL::endClip): 24 * platform/graphics/opengl/TextureMapperGL.h: 25 (TextureMapperGL): 26 1 27 2012-02-01 Anders Carlsson <andersca@apple.com> 2 28 -
trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp
r105737 r106524 239 239 240 240 int stencilIndex; 241 242 SharedGLData(GLContext glContext) : stencilIndex(1) 241 Vector<IntRect> clipStack; 242 243 SharedGLData(GLContext glContext) 244 : stencilIndex(1) 243 245 { 244 246 glContextDataMap().add(glContext, this); … … 322 324 TextureMapperGLData() 323 325 : currentProgram(SharedGLData::NoProgram) 326 , previousProgram(0) 327 , previousScissorState(0) 324 328 , m_sharedGLData(TextureMapperGLData::SharedGLData::currentSharedGLData()) 325 329 { } … … 327 331 TransformationMatrix projectionMatrix; 328 332 int currentProgram; 329 int previousProgram; 333 GLint previousProgram; 334 GLint previousScissorState; 330 335 RefPtr<SharedGLData> m_sharedGLData; 331 336 }; … … 521 526 void TextureMapperGL::beginPainting() 522 527 { 528 // Make sure that no GL error code stays from previous operations. 529 glGetError(); 530 531 if (!initializeOpenGLShims()) 532 return; 533 534 glGetIntegerv(GL_CURRENT_PROGRAM, &data().previousProgram); 535 data().previousScissorState = glIsEnabled(GL_SCISSOR_TEST); 536 537 glEnable(GL_SCISSOR_TEST); 523 538 #if PLATFORM(QT) 524 if (!initializeOpenGLShims())525 return;526 527 glGetIntegerv(GL_CURRENT_PROGRAM, &m_data->previousProgram);528 539 if (m_context) { 529 540 QPainter* painter = m_context->platformContext(); … … 531 542 painter->beginNativePainting(); 532 543 } 544 #endif 533 545 glClearStencil(0); 534 546 glClear(GL_STENCIL_BUFFER_BIT); 535 547 bindSurface(0); 536 #endif537 548 } 538 549 539 550 void TextureMapperGL::endPainting() 540 551 { 541 #if PLATFORM(QT)542 552 glClearStencil(1); 543 553 glClear(GL_STENCIL_BUFFER_BIT); 544 glUseProgram(m_data->previousProgram); 554 glUseProgram(data().previousProgram); 555 556 if (data().previousScissorState) 557 glEnable(GL_SCISSOR_TEST); 558 else 559 glDisable(GL_SCISSOR_TEST); 560 561 #if PLATFORM(QT) 545 562 if (!m_context) 546 563 return; … … 621 638 622 639 GL_CMD(glDisable(GL_DEPTH_TEST)) 640 623 641 GL_CMD(glDrawArrays(GL_TRIANGLE_FAN, 0, 4)) 624 642 GL_CMD(glDisableVertexAttribArray(programInfo.vertexAttrib)) … … 816 834 GL_CMD(glViewport(0, 0, size().width(), size().height())) 817 835 m_textureMapper->data().projectionMatrix = createProjectionMatrix(size(), false); 818 glDisable(GL_SCISSOR_TEST);819 836 } 820 837 … … 861 878 GL_CMD(glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP)) 862 879 GL_CMD(glViewport(0, 0, viewportSize().width(), viewportSize().height())) 880 data().sharedGLData().clipStack.append(IntRect(IntPoint::zero(), viewportSize())); 863 881 return; 864 882 } … … 867 885 } 868 886 887 static void scissorClip(const IntRect& rect) 888 { 889 GLint viewport[4]; 890 glGetIntegerv(GL_VIEWPORT, viewport); 891 glScissor(rect.x(), viewport[3] - rect.maxY(), rect.width(), rect.height()); 892 } 893 894 bool TextureMapperGL::beginScissorClip(const TransformationMatrix& modelViewMatrix, const FloatRect& targetRect) 895 { 896 FloatQuad quad = modelViewMatrix.projectQuad(targetRect); 897 IntRect rect = quad.enclosingBoundingBox(); 898 899 // Only use scissors on rectilinear clips. 900 if (!quad.isRectilinear() || rect.isEmpty()) { 901 data().sharedGLData().clipStack.append(IntRect()); 902 return false; 903 } 904 905 // Intersect with previous clip. 906 if (!data().sharedGLData().clipStack.isEmpty()) 907 rect.intersect(data().sharedGLData().clipStack.last()); 908 909 scissorClip(rect); 910 data().sharedGLData().clipStack.append(rect); 911 912 return true; 913 } 914 915 bool TextureMapperGL::endScissorClip() 916 { 917 data().sharedGLData().clipStack.removeLast(); 918 ASSERT(!data().sharedGLData().clipStack.isEmpty()); 919 920 IntRect rect = data().sharedGLData().clipStack.last(); 921 if (rect.isEmpty()) 922 return false; 923 924 scissorClip(rect); 925 return true; 926 } 927 869 928 void TextureMapperGL::beginClip(const TransformationMatrix& modelViewMatrix, const FloatRect& targetRect) 870 929 { 930 if (beginScissorClip(modelViewMatrix, targetRect)) 931 return; 871 932 TextureMapperGLData::SharedGLData::ShaderProgramIndex program = TextureMapperGLData::SharedGLData::ClipProgram; 872 933 const TextureMapperGLData::SharedGLData::ProgramInfo& programInfo = data().sharedGLData().programs[program]; … … 906 967 void TextureMapperGL::endClip() 907 968 { 969 if (endScissorClip()) 970 return; 971 908 972 data().sharedGLData().stencilIndex >>= 1; 909 glStencilFunc(data().sharedGLData().stencilIndex > 1 ? GL_EQUAL : GL_ALWAYS, data().sharedGLData().stencilIndex - 1, data().sharedGLData().stencilIndex - 1); 973 glStencilFunc(data().sharedGLData().stencilIndex > 1 ? GL_EQUAL : GL_ALWAYS, data().sharedGLData().stencilIndex - 1, data().sharedGLData().stencilIndex - 1); 974 975 // After we've cleared the last non-rectalinear clip, we disable the stencil test. 976 if (data().sharedGLData().stencilIndex == 1) 977 GL_CMD(glDisable(GL_STENCIL_TEST)) 978 910 979 } 911 980 -
trunk/Source/WebCore/platform/graphics/opengl/TextureMapperGL.h
r104651 r106524 56 56 57 57 private: 58 bool beginScissorClip(const TransformationMatrix&, const FloatRect&); 59 bool endScissorClip(); 58 60 inline TextureMapperGLData& data() { return *m_data; } 59 61 TextureMapperGLData* m_data; -
trunk/Source/WebKit2/ChangeLog
r106511 r106524 1 2012-02-01 No'am Rosenthal <noam.rosenthal@nokia.com> 2 3 [Texmap] Use glScissors for clipping in TextureMapperGL when possible 4 https://bugs.webkit.org/show_bug.cgi?id=77575 5 6 Reviewed by Martin Robinson. 7 8 Instead of applying the scissor clip in QQuickWebPage, we trickle it down to 9 TextureMapperGL, and apply it there as part of beginClip(). All direct GL operations are 10 now cleaned out of QQuickWebPage. 11 12 * UIProcess/API/qt/qquickwebpage.cpp: 13 (QQuickWebPagePrivate::paintToCurrentGLContext): 14 * UIProcess/DrawingAreaProxy.h: 15 (WebKit::DrawingAreaProxy::paintToCurrentGLContext): 16 * UIProcess/DrawingAreaProxyImpl.cpp: 17 (WebKit::DrawingAreaProxyImpl::paintToCurrentGLContext): 18 * UIProcess/DrawingAreaProxyImpl.h: 19 (DrawingAreaProxyImpl): 20 * UIProcess/LayerTreeHostProxy.h: 21 (LayerTreeHostProxy): 22 * UIProcess/qt/LayerTreeHostProxyQt.cpp: 23 (WebKit::LayerTreeHostProxy::paintToCurrentGLContext): 24 1 25 2012-02-01 Dan Bernstein <mitz@apple.com> 2 26 -
trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
r106250 r106524 125 125 return; 126 126 127 // Make sure that no GL error code stays from previous QT operations. 128 glGetError(); 129 130 glEnable(GL_SCISSOR_TEST); 131 ASSERT(!glGetError()); 132 const int left = clipRect.left(); 133 const int width = clipRect.width(); 134 const int bottom = q->canvas()->height() - (clipRect.bottom() + 1); 135 const int height = clipRect.height(); 136 137 glScissor(left, bottom, width, height); 138 ASSERT(!glGetError()); 139 140 drawingArea->paintToCurrentGLContext(transform, opacity); 141 142 glDisable(GL_SCISSOR_TEST); 143 ASSERT(!glGetError()); 127 drawingArea->paintToCurrentGLContext(transform, opacity, clipRect); 144 128 } 145 129 -
trunk/Source/WebKit2/UIProcess/DrawingAreaProxy.h
r106250 r106524 89 89 virtual WebCore::IntRect contentsRect() const; 90 90 virtual bool isBackingStoreReady() const { return true; } 91 virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity) { }91 virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&) { } 92 92 virtual void paintLayerTree(BackingStore::PlatformGraphicsContext) { } 93 93 LayerTreeHostProxy* layerTreeHostProxy() const { return m_layerTreeHostProxy.get(); } -
trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
r106250 r106524 367 367 } 368 368 369 void DrawingAreaProxyImpl::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity )369 void DrawingAreaProxyImpl::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect) 370 370 { 371 371 if (m_layerTreeHostProxy) 372 m_layerTreeHostProxy->paintToCurrentGLContext(matrix, opacity );372 m_layerTreeHostProxy->paintToCurrentGLContext(matrix, opacity, clipRect); 373 373 } 374 374 #endif -
trunk/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
r106250 r106524 81 81 virtual void setVisibleContentsRectAndScale(const WebCore::IntRect& visibleContentsRect, float scale); 82 82 virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&); 83 virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity );83 virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity, const WebCore::FloatRect&); 84 84 virtual void paintLayerTree(BackingStore::PlatformGraphicsContext); 85 85 void didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); -
trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.h
r106250 r106524 53 53 void setRootCompositingLayer(WebLayerID); 54 54 void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); 55 void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float );55 void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&); 56 56 void paintToGraphicsContext(BackingStore::PlatformGraphicsContext); 57 57 void purgeGLResources(); -
trunk/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp
r106250 r106524 169 169 170 170 // This function needs to be reentrant. 171 void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity )171 void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect) 172 172 { 173 173 if (!m_textureMapper) … … 191 191 m_textureMapper->beginPainting(); 192 192 m_textureMapper->bindSurface(0); 193 m_textureMapper->beginClip(TransformationMatrix(), clipRect); 193 194 194 195 if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) { … … 199 200 200 201 node->paint(); 202 m_textureMapper->endClip(); 201 203 m_textureMapper->endPainting(); 202 204
Note: See TracChangeset
for help on using the changeset viewer.