Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (194576 => 194577)
--- trunk/Source/WebCore/CMakeLists.txt 2016-01-05 07:37:52 UTC (rev 194576)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-01-05 07:41:39 UTC (rev 194577)
@@ -2243,6 +2243,7 @@
platform/graphics/opentype/OpenTypeMathData.cpp
+ platform/graphics/texmap/ClipStack.cpp
platform/graphics/texmap/TextureMapper.cpp
platform/graphics/texmap/TextureMapperAnimation.cpp
platform/graphics/texmap/TextureMapperBackingStore.cpp
Modified: trunk/Source/WebCore/ChangeLog (194576 => 194577)
--- trunk/Source/WebCore/ChangeLog 2016-01-05 07:37:52 UTC (rev 194576)
+++ trunk/Source/WebCore/ChangeLog 2016-01-05 07:41:39 UTC (rev 194577)
@@ -1,5 +1,67 @@
2016-01-04 Zan Dobersek <[email protected]>
+ [TextureMapper] Move ClipStack into its own file
+ https://bugs.webkit.org/show_bug.cgi?id=152661
+
+ Reviewed by Michael Catanzaro.
+
+ Move TextureMapperGL::ClipStack into its own file and clean it up a bit.
+ Move ClipState under the ClipStack class, and simply name it State.
+
+ Move the ClipState methods into a more sensible order. Remove the inline
+ specifiers, these aren't really needed for the methods defined in the header.
+ apply() and applyIfNeeded() now accept a reference to the GraphicsContext3D
+ object, not a pointer.
+
+ Turn YAxisMode enum into an enum class, update the uses to properly specify
+ the scope of the enum value.
+
+ Reorder the ClipStack member variables into a more efficient order.
+
+ No new tests -- no change in behavior.
+
+ * CMakeLists.txt:
+ * platform/graphics/texmap/BitmapTextureGL.cpp:
+ (WebCore::BitmapTextureGL::clearIfNeeded):
+ (WebCore::BitmapTextureGL::bindAsSurface):
+ * platform/graphics/texmap/BitmapTextureGL.h:
+ (WebCore::BitmapTextureGL::clipStack):
+ * platform/graphics/texmap/ClipStack.cpp: Added.
+ (WebCore::ClipStack::push):
+ (WebCore::ClipStack::pop):
+ (WebCore::ClipStack::reset):
+ (WebCore::ClipStack::intersect):
+ (WebCore::ClipStack::setStencilIndex):
+ (WebCore::ClipStack::apply):
+ (WebCore::ClipStack::applyIfNeeded):
+ * platform/graphics/texmap/ClipStack.h: Added.
+ (WebCore::ClipStack::State::State):
+ (WebCore::ClipStack::current):
+ (WebCore::ClipStack::getStencilIndex):
+ (WebCore::ClipStack::isCurrentScissorBoxEmpty):
+ * platform/graphics/texmap/TextureMapperGL.cpp:
+ (WebCore::TextureMapperGL::clipStack):
+ (WebCore::TextureMapperGL::beginPainting):
+ (WebCore::TextureMapperGL::bindDefaultSurface):
+ (WebCore::TextureMapperGL::beginScissorClip):
+ (WebCore::TextureMapperGL::beginClip):
+ (WebCore::TextureMapperGL::endClip):
+ (WebCore::TextureMapperGL::ClipStack::reset): Deleted.
+ (WebCore::TextureMapperGL::ClipStack::intersect): Deleted.
+ (WebCore::TextureMapperGL::ClipStack::setStencilIndex): Deleted.
+ (WebCore::TextureMapperGL::ClipStack::push): Deleted.
+ (WebCore::TextureMapperGL::ClipStack::pop): Deleted.
+ (WebCore::TextureMapperGL::ClipStack::apply): Deleted.
+ (WebCore::TextureMapperGL::ClipStack::applyIfNeeded): Deleted.
+ * platform/graphics/texmap/TextureMapperGL.h:
+ (WebCore::TextureMapperGL::ClipState::ClipState): Deleted.
+ (WebCore::TextureMapperGL::ClipStack::ClipStack): Deleted.
+ (WebCore::TextureMapperGL::ClipStack::current): Deleted.
+ (WebCore::TextureMapperGL::ClipStack::getStencilIndex): Deleted.
+ (WebCore::TextureMapperGL::ClipStack::isCurrentScissorBoxEmpty): Deleted.
+
+2016-01-04 Zan Dobersek <[email protected]>
+
Shave off a TransformationMatrix copy if RenderLayer's transparencyClipBox()
https://bugs.webkit.org/show_bug.cgi?id=152119
Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp (194576 => 194577)
--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp 2016-01-05 07:37:52 UTC (rev 194576)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp 2016-01-05 07:41:39 UTC (rev 194577)
@@ -296,8 +296,8 @@
if (!m_shouldClear)
return;
- m_clipStack.reset(IntRect(IntPoint::zero(), m_textureSize), TextureMapperGL::ClipStack::DefaultYAxis);
- m_clipStack.applyIfNeeded(m_context3D.get());
+ m_clipStack.reset(IntRect(IntPoint::zero(), m_textureSize), ClipStack::YAxisMode::Default);
+ m_clipStack.applyIfNeeded(*m_context3D);
m_context3D->clearColor(0, 0, 0, 0);
m_context3D->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
m_shouldClear = false;
@@ -321,7 +321,7 @@
context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
context3D->viewport(0, 0, m_textureSize.width(), m_textureSize.height());
clearIfNeeded();
- m_clipStack.apply(m_context3D.get());
+ m_clipStack.apply(*m_context3D);
}
BitmapTextureGL::~BitmapTextureGL()
Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h (194576 => 194577)
--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h 2016-01-05 07:37:52 UTC (rev 194576)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h 2016-01-05 07:41:39 UTC (rev 194577)
@@ -24,6 +24,7 @@
#if USE(TEXTURE_MAPPER_GL)
#include "BitmapTexture.h"
+#include "ClipStack.h"
#include "FilterOperation.h"
#include "GraphicsContext3D.h"
#include "IntSize.h"
@@ -67,7 +68,7 @@
{ }
};
const FilterInfo* filterInfo() const { return &m_filterInfo; }
- TextureMapperGL::ClipStack& clipStack() { return m_clipStack; }
+ ClipStack& clipStack() { return m_clipStack; }
GC3Dint internalFormat() const { return m_internalFormat; }
@@ -80,7 +81,7 @@
Platform3DObject m_rbo;
Platform3DObject m_depthBufferObject;
bool m_shouldClear;
- TextureMapperGL::ClipStack m_clipStack;
+ ClipStack m_clipStack;
RefPtr<GraphicsContext3D> m_context3D;
BitmapTextureGL();
Added: trunk/Source/WebCore/platform/graphics/texmap/ClipStack.cpp (0 => 194577)
--- trunk/Source/WebCore/platform/graphics/texmap/ClipStack.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/ClipStack.cpp 2016-01-05 07:41:39 UTC (rev 194577)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2012 Adobe Systems Incorporated
+ * Copyright (C) 2012, 2016 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "ClipStack.h"
+
+#include "GraphicsContext3D.h"
+
+namespace WebCore {
+
+void ClipStack::push()
+{
+ clipStack.append(clipState);
+ clipStateDirty = true;
+}
+
+void ClipStack::pop()
+{
+ if (clipStack.isEmpty())
+ return;
+ clipState = clipStack.last();
+ clipStack.removeLast();
+ clipStateDirty = true;
+}
+
+void ClipStack::reset(const IntRect& rect, ClipStack::YAxisMode mode)
+{
+ clipStack.clear();
+ size = rect.size();
+ yAxisMode = mode;
+ clipState = State(rect);
+ clipStateDirty = true;
+}
+
+void ClipStack::intersect(const IntRect& rect)
+{
+ clipState.scissorBox.intersect(rect);
+ clipStateDirty = true;
+}
+
+void ClipStack::setStencilIndex(int stencilIndex)
+{
+ clipState.stencilIndex = stencilIndex;
+ clipStateDirty = true;
+}
+
+void ClipStack::apply(GraphicsContext3D& context)
+{
+ if (clipState.scissorBox.isEmpty())
+ return;
+
+ context.scissor(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);
+ if (clipState.stencilIndex == 1)
+ context.disable(GraphicsContext3D::STENCIL_TEST);
+ else
+ context.enable(GraphicsContext3D::STENCIL_TEST);
+}
+
+void ClipStack::applyIfNeeded(GraphicsContext3D& context)
+{
+ if (!clipStateDirty)
+ return;
+
+ clipStateDirty = false;
+ apply(context);
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/platform/graphics/texmap/ClipStack.h (0 => 194577)
--- trunk/Source/WebCore/platform/graphics/texmap/ClipStack.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/ClipStack.h 2016-01-05 07:41:39 UTC (rev 194577)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2015, 2016 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef ClipStack_h
+#define ClipStack_h
+
+#include "IntRect.h"
+#include "IntSize.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class GraphicsContext3D;
+
+class ClipStack {
+public:
+ struct State {
+ State(const IntRect& scissors = IntRect(), int stencil = 1)
+ : scissorBox(scissors)
+ , stencilIndex(stencil)
+ { }
+
+ IntRect scissorBox;
+ int stencilIndex;
+ };
+
+ // Y-axis should be inverted only when painting into the window.
+ enum class YAxisMode {
+ Default,
+ Inverted,
+ };
+
+ void push();
+ void pop();
+ State& current() { return clipState; }
+
+ void reset(const IntRect&, YAxisMode);
+ void intersect(const IntRect&);
+ void setStencilIndex(int);
+ int getStencilIndex() const { return clipState.stencilIndex; }
+
+ void apply(GraphicsContext3D&);
+ void applyIfNeeded(GraphicsContext3D&);
+
+ bool isCurrentScissorBoxEmpty() const { return clipState.scissorBox.isEmpty(); }
+
+private:
+ Vector<State> clipStack;
+ State clipState;
+ IntSize size;
+ bool clipStateDirty { false };
+ YAxisMode yAxisMode { YAxisMode::Default };
+};
+
+} // namespace WebCore
+
+#endif // ClipStack_h
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (194576 => 194577)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2016-01-05 07:37:52 UTC (rev 194576)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2016-01-05 07:41:39 UTC (rev 194577)
@@ -156,67 +156,6 @@
context->deleteBuffer(entry.value);
}
-void TextureMapperGL::ClipStack::reset(const IntRect& rect, TextureMapperGL::ClipStack::YAxisMode mode)
-{
- clipStack.clear();
- size = rect.size();
- yAxisMode = mode;
- clipState = TextureMapperGL::ClipState(rect);
- clipStateDirty = true;
-}
-
-void TextureMapperGL::ClipStack::intersect(const IntRect& rect)
-{
- clipState.scissorBox.intersect(rect);
- clipStateDirty = true;
-}
-
-void TextureMapperGL::ClipStack::setStencilIndex(int stencilIndex)
-{
- clipState.stencilIndex = stencilIndex;
- clipStateDirty = true;
-}
-
-void TextureMapperGL::ClipStack::push()
-{
- clipStack.append(clipState);
- clipStateDirty = true;
-}
-
-void TextureMapperGL::ClipStack::pop()
-{
- if (clipStack.isEmpty())
- return;
- clipState = clipStack.last();
- clipStack.removeLast();
- clipStateDirty = true;
-}
-
-void TextureMapperGL::ClipStack::apply(GraphicsContext3D* context)
-{
- if (clipState.scissorBox.isEmpty())
- return;
-
- context->scissor(clipState.scissorBox.x(),
- (yAxisMode == InvertedYAxis) ? 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);
- if (clipState.stencilIndex == 1)
- context->disable(GraphicsContext3D::STENCIL_TEST);
- else
- context->enable(GraphicsContext3D::STENCIL_TEST);
-}
-
-void TextureMapperGL::ClipStack::applyIfNeeded(GraphicsContext3D* context)
-{
- if (!clipStateDirty)
- return;
-
- clipStateDirty = false;
- apply(context);
-}
-
void TextureMapperGLData::initializeStencil()
{
if (currentSurface) {
@@ -242,7 +181,7 @@
#endif
}
-TextureMapperGL::ClipStack& TextureMapperGL::clipStack()
+ClipStack& TextureMapperGL::clipStack()
{
return data().currentSurface ? toBitmapTextureGL(data().currentSurface.get())->clipStack() : m_clipStack;
}
@@ -258,7 +197,7 @@
m_context3D->depthMask(0);
m_context3D->getIntegerv(GraphicsContext3D::VIEWPORT, data().viewport);
m_context3D->getIntegerv(GraphicsContext3D::SCISSOR_BOX, data().previousScissor);
- m_clipStack.reset(IntRect(0, 0, data().viewport[2], data().viewport[3]), ClipStack::InvertedYAxis);
+ m_clipStack.reset(IntRect(0, 0, data().viewport[2], data().viewport[3]), ClipStack::YAxisMode::Inverted);
m_context3D->getIntegerv(GraphicsContext3D::FRAMEBUFFER_BINDING, &data().targetFrameBuffer);
data().PaintFlags = flags;
bindSurface(0);
@@ -682,7 +621,7 @@
IntSize viewportSize(data().viewport[2], data().viewport[3]);
data().projectionMatrix = createProjectionMatrix(viewportSize, data().PaintFlags & PaintingMirrored);
m_context3D->viewport(data().viewport[0], data().viewport[1], viewportSize.width(), viewportSize.height());
- m_clipStack.apply(m_context3D.get());
+ m_clipStack.apply(*m_context3D);
data().currentSurface = nullptr;
}
@@ -718,7 +657,7 @@
return false;
clipStack().intersect(rect);
- clipStack().applyIfNeeded(m_context3D.get());
+ clipStack().applyIfNeeded(*m_context3D);
return true;
}
@@ -770,13 +709,13 @@
// Increase stencilIndex and apply stencil testing.
clipStack().setStencilIndex(stencilIndex * 2);
- clipStack().applyIfNeeded(m_context3D.get());
+ clipStack().applyIfNeeded(*m_context3D);
}
void TextureMapperGL::endClip()
{
clipStack().pop();
- clipStack().applyIfNeeded(m_context3D.get());
+ clipStack().applyIfNeeded(*m_context3D);
}
IntRect TextureMapperGL::clipBounds()
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h (194576 => 194577)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h 2016-01-05 07:37:52 UTC (rev 194576)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h 2016-01-05 07:41:39 UTC (rev 194577)
@@ -23,6 +23,7 @@
#if USE(TEXTURE_MAPPER_GL)
+#include "ClipStack.h"
#include "FilterOperation.h"
#include "FloatQuad.h"
#include "GraphicsContext3D.h"
@@ -39,52 +40,6 @@
// An OpenGL-ES2 implementation of TextureMapper.
class TextureMapperGL : public TextureMapper {
public:
- struct ClipState {
- IntRect scissorBox;
- int stencilIndex;
- ClipState(const IntRect& scissors = IntRect(), int stencil = 1)
- : scissorBox(scissors)
- , stencilIndex(stencil)
- { }
- };
-
- class ClipStack {
- public:
- ClipStack()
- : clipStateDirty(false)
- { }
-
- // Y-axis should be inverted only when painting into the window.
- enum YAxisMode {
- DefaultYAxis,
- InvertedYAxis
- };
-
- void push();
- void pop();
- void apply(GraphicsContext3D*);
- void applyIfNeeded(GraphicsContext3D*);
- inline ClipState& current() { return clipState; }
- void reset(const IntRect&, YAxisMode);
- void intersect(const IntRect&);
- void setStencilIndex(int);
- inline int getStencilIndex() const
- {
- return clipState.stencilIndex;
- }
- inline bool isCurrentScissorBoxEmpty() const
- {
- return clipState.scissorBox.isEmpty();
- }
-
- private:
- ClipState clipState;
- Vector<ClipState> clipStack;
- bool clipStateDirty;
- IntSize size;
- YAxisMode yAxisMode;
- };
-
TextureMapperGL();
virtual ~TextureMapperGL();