[TexMap] Don't use GraphicsContext3D in ClipStack
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Aug 2017 13:04:40 +0000 (13:04 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Aug 2017 13:04:40 +0000 (13:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174776

Reviewed by Carlos Garcia Campos.

Any GraphicsContext3D object that's passed to ClipStack methods is of the
render-to-current-context nature, meaning there's no internally owned GL
context that has to be properly handled and all calls are simply passed to
OpenGL APIs. We should drop such (non-)usage of GraphicsContext3D in favor
of direct OpenGL API invocations.

This patch covers TextureMapper's ClipStack. Call sites to the apply() and
applyIfNeeded() are modified to not pass a reference to any
GraphicsContext3D object. Internally, OpenGL API entrypoints and constants
are used instead of GraphicsContext3D invocations.

No new tests -- no change in behavior.

* platform/graphics/texmap/BitmapTextureGL.cpp:
(WebCore::BitmapTextureGL::clearIfNeeded):
(WebCore::BitmapTextureGL::bindAsSurface):
* platform/graphics/texmap/ClipStack.cpp:
(WebCore::ClipStack::apply):
(WebCore::ClipStack::applyIfNeeded):
* platform/graphics/texmap/ClipStack.h:
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::bindDefaultSurface):
(WebCore::TextureMapperGL::beginScissorClip):
(WebCore::TextureMapperGL::beginClip):
(WebCore::TextureMapperGL::endClip):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220399 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp
Source/WebCore/platform/graphics/texmap/ClipStack.cpp
Source/WebCore/platform/graphics/texmap/ClipStack.h
Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp

index 72ec0b8176afa4e354f1526f4f40e1e5a9225cdf..2e756b07b7281be1a11b57701b2e239faedc4dca 100644 (file)
@@ -1,3 +1,36 @@
+2017-08-08  Zan Dobersek  <zdobersek@igalia.com>
+
+        [TexMap] Don't use GraphicsContext3D in ClipStack
+        https://bugs.webkit.org/show_bug.cgi?id=174776
+
+        Reviewed by Carlos Garcia Campos.
+
+        Any GraphicsContext3D object that's passed to ClipStack methods is of the
+        render-to-current-context nature, meaning there's no internally owned GL
+        context that has to be properly handled and all calls are simply passed to
+        OpenGL APIs. We should drop such (non-)usage of GraphicsContext3D in favor
+        of direct OpenGL API invocations.
+
+        This patch covers TextureMapper's ClipStack. Call sites to the apply() and
+        applyIfNeeded() are modified to not pass a reference to any
+        GraphicsContext3D object. Internally, OpenGL API entrypoints and constants
+        are used instead of GraphicsContext3D invocations.
+
+        No new tests -- no change in behavior.
+
+        * platform/graphics/texmap/BitmapTextureGL.cpp:
+        (WebCore::BitmapTextureGL::clearIfNeeded):
+        (WebCore::BitmapTextureGL::bindAsSurface):
+        * platform/graphics/texmap/ClipStack.cpp:
+        (WebCore::ClipStack::apply):
+        (WebCore::ClipStack::applyIfNeeded):
+        * platform/graphics/texmap/ClipStack.h:
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGL::bindDefaultSurface):
+        (WebCore::TextureMapperGL::beginScissorClip):
+        (WebCore::TextureMapperGL::beginClip):
+        (WebCore::TextureMapperGL::endClip):
+
 2017-08-08  Javier Fernandez  <jfernandez@igalia.com>
 
         Not possible to remove the 'li' element inside the table cell
index cf56eb27ed8b4fa70c8971a1ff9b3675457492e8..262b9df149a431992a0b0734d7d2ef1f08b7a159 100644 (file)
@@ -288,7 +288,7 @@ void BitmapTextureGL::clearIfNeeded()
         return;
 
     m_clipStack.reset(IntRect(IntPoint::zero(), m_textureSize), ClipStack::YAxisMode::Default);
-    m_clipStack.applyIfNeeded(*m_context3D);
+    m_clipStack.applyIfNeeded();
     m_context3D->clearColor(0, 0, 0, 0);
     m_context3D->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
     m_shouldClear = false;
@@ -312,7 +312,7 @@ void BitmapTextureGL::bindAsSurface(GraphicsContext3D* context3D)
     context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
     context3D->viewport(0, 0, m_textureSize.width(), m_textureSize.height());
     clearIfNeeded();
-    m_clipStack.apply(*m_context3D);
+    m_clipStack.apply();
 }
 
 BitmapTextureGL::~BitmapTextureGL()
index 11a00bc8a3b954844e81fc1f4ebbdaa956894e1d..da840bf4f7e2129b123c8d17e928b0056bacd973 100644 (file)
@@ -22,7 +22,7 @@
 #include "config.h"
 #include "ClipStack.h"
 
-#include "GraphicsContext3D.h"
+#include "TextureMapperGLHeaders.h"
 
 namespace WebCore {
 
@@ -62,29 +62,29 @@ void ClipStack::setStencilIndex(int stencilIndex)
     clipStateDirty = true;
 }
 
-void ClipStack::apply(GraphicsContext3D& context)
+void ClipStack::apply()
 {
     if (clipState.scissorBox.isEmpty())
         return;
 
-    context.scissor(clipState.scissorBox.x(),
+    glScissor(clipState.scissorBox.x(),
         (yAxisMode == YAxisMode::Inverted) ? size.height() - clipState.scissorBox.maxY() : clipState.scissorBox.y(),
         clipState.scissorBox.width(), clipState.scissorBox.height());
-    context.stencilOp(GraphicsContext3D::KEEP, GraphicsContext3D::KEEP, GraphicsContext3D::KEEP);
-    context.stencilFunc(GraphicsContext3D::EQUAL, clipState.stencilIndex - 1, clipState.stencilIndex - 1);
+    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+    glStencilFunc(GL_EQUAL, clipState.stencilIndex - 1, clipState.stencilIndex - 1);
     if (clipState.stencilIndex == 1)
-        context.disable(GraphicsContext3D::STENCIL_TEST);
+        glDisable(GL_STENCIL_TEST);
     else
-        context.enable(GraphicsContext3D::STENCIL_TEST);
+        glEnable(GL_STENCIL_TEST);
 }
 
-void ClipStack::applyIfNeeded(GraphicsContext3D& context)
+void ClipStack::applyIfNeeded()
 {
     if (!clipStateDirty)
         return;
 
     clipStateDirty = false;
-    apply(context);
+    apply();
 }
 
 } // namespace WebCore
index 2fc40475b1c5174d125907101a8babf9a616ebbb..267ce4096012fb17e768e91c25fa0990d4e099e9 100644 (file)
@@ -27,8 +27,6 @@
 
 namespace WebCore {
 
-class GraphicsContext3D;
-
 class ClipStack {
 public:
     struct State {
@@ -56,8 +54,8 @@ public:
     void setStencilIndex(int);
     int getStencilIndex() const { return clipState.stencilIndex; }
 
-    void apply(GraphicsContext3D&);
-    void applyIfNeeded(GraphicsContext3D&);
+    void apply();
+    void applyIfNeeded();
 
     bool isCurrentScissorBoxEmpty() const { return clipState.scissorBox.isEmpty(); }
 
index 39a747b5abca6e79926eb38813ac2bf75ec27672..1ece45728d400b5b8dd593604e5053333308b740 100644 (file)
@@ -653,7 +653,7 @@ void TextureMapperGL::bindDefaultSurface()
     auto& viewport = data().viewport;
     data().projectionMatrix = createProjectionMatrix(IntSize(viewport[2], viewport[3]), data().PaintFlags & PaintingMirrored);
     m_context3D->viewport(viewport[0], viewport[1], viewport[2], viewport[3]);
-    m_clipStack.apply(*m_context3D);
+    m_clipStack.apply();
     data().currentSurface = nullptr;
 }
 
@@ -689,7 +689,7 @@ bool TextureMapperGL::beginScissorClip(const TransformationMatrix& modelViewMatr
         return false;
 
     clipStack().intersect(rect);
-    clipStack().applyIfNeeded(*m_context3D);
+    clipStack().applyIfNeeded();
     return true;
 }
 
@@ -744,13 +744,13 @@ void TextureMapperGL::beginClip(const TransformationMatrix& modelViewMatrix, con
 
     // Increase stencilIndex and apply stencil testing.
     clipStack().setStencilIndex(stencilIndex * 2);
-    clipStack().applyIfNeeded(*m_context3D);
+    clipStack().applyIfNeeded();
 }
 
 void TextureMapperGL::endClip()
 {
     clipStack().pop();
-    clipStack().applyIfNeeded(*m_context3D);
+    clipStack().applyIfNeeded();
 }
 
 IntRect TextureMapperGL::clipBounds()