<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[194577] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/194577">194577</a></dd>
<dt>Author</dt> <dd>zandobersek@gmail.com</dd>
<dt>Date</dt> <dd>2016-01-04 23:41:39 -0800 (Mon, 04 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapBitmapTextureGLcpp">trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapBitmapTextureGLh">trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapTextureMapperGLcpp">trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapTextureMapperGLh">trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapClipStackcpp">trunk/Source/WebCore/platform/graphics/texmap/ClipStack.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapClipStackh">trunk/Source/WebCore/platform/graphics/texmap/ClipStack.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (194576 => 194577)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -2243,6 +2243,7 @@
</span><span class="cx"> 
</span><span class="cx">     platform/graphics/opentype/OpenTypeMathData.cpp
</span><span class="cx"> 
</span><ins>+    platform/graphics/texmap/ClipStack.cpp
</ins><span class="cx">     platform/graphics/texmap/TextureMapper.cpp
</span><span class="cx">     platform/graphics/texmap/TextureMapperAnimation.cpp
</span><span class="cx">     platform/graphics/texmap/TextureMapperBackingStore.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194576 => 194577)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,5 +1,67 @@
</span><span class="cx"> 2016-01-04  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
</span><span class="cx"> 
</span><ins>+        [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  &lt;zdobersek@igalia.com&gt;
+
</ins><span class="cx">         Shave off a TransformationMatrix copy if RenderLayer's transparencyClipBox()
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=152119
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapBitmapTextureGLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp (194576 => 194577)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -296,8 +296,8 @@
</span><span class="cx">     if (!m_shouldClear)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_clipStack.reset(IntRect(IntPoint::zero(), m_textureSize), TextureMapperGL::ClipStack::DefaultYAxis);
-    m_clipStack.applyIfNeeded(m_context3D.get());
</del><ins>+    m_clipStack.reset(IntRect(IntPoint::zero(), m_textureSize), ClipStack::YAxisMode::Default);
+    m_clipStack.applyIfNeeded(*m_context3D);
</ins><span class="cx">     m_context3D-&gt;clearColor(0, 0, 0, 0);
</span><span class="cx">     m_context3D-&gt;clear(GraphicsContext3D::COLOR_BUFFER_BIT);
</span><span class="cx">     m_shouldClear = false;
</span><span class="lines">@@ -321,7 +321,7 @@
</span><span class="cx">     context3D-&gt;bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
</span><span class="cx">     context3D-&gt;viewport(0, 0, m_textureSize.width(), m_textureSize.height());
</span><span class="cx">     clearIfNeeded();
</span><del>-    m_clipStack.apply(m_context3D.get());
</del><ins>+    m_clipStack.apply(*m_context3D);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> BitmapTextureGL::~BitmapTextureGL()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapBitmapTextureGLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h (194576 => 194577)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;BitmapTexture.h&quot;
</span><ins>+#include &quot;ClipStack.h&quot;
</ins><span class="cx"> #include &quot;FilterOperation.h&quot;
</span><span class="cx"> #include &quot;GraphicsContext3D.h&quot;
</span><span class="cx"> #include &quot;IntSize.h&quot;
</span><span class="lines">@@ -67,7 +68,7 @@
</span><span class="cx">             { }
</span><span class="cx">     };
</span><span class="cx">     const FilterInfo* filterInfo() const { return &amp;m_filterInfo; }
</span><del>-    TextureMapperGL::ClipStack&amp; clipStack() { return m_clipStack; }
</del><ins>+    ClipStack&amp; clipStack() { return m_clipStack; }
</ins><span class="cx"> 
</span><span class="cx">     GC3Dint internalFormat() const { return m_internalFormat; }
</span><span class="cx"> 
</span><span class="lines">@@ -80,7 +81,7 @@
</span><span class="cx">     Platform3DObject m_rbo;
</span><span class="cx">     Platform3DObject m_depthBufferObject;
</span><span class="cx">     bool m_shouldClear;
</span><del>-    TextureMapperGL::ClipStack m_clipStack;
</del><ins>+    ClipStack m_clipStack;
</ins><span class="cx">     RefPtr&lt;GraphicsContext3D&gt; m_context3D;
</span><span class="cx"> 
</span><span class="cx">     BitmapTextureGL();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapClipStackcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/texmap/ClipStack.cpp (0 => 194577)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,90 @@
</span><ins>+/*
+ * 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 &quot;config.h&quot;
+#include &quot;ClipStack.h&quot;
+
+#include &quot;GraphicsContext3D.h&quot;
+
+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&amp; rect, ClipStack::YAxisMode mode)
+{
+    clipStack.clear();
+    size = rect.size();
+    yAxisMode = mode;
+    clipState = State(rect);
+    clipStateDirty = true;
+}
+
+void ClipStack::intersect(const IntRect&amp; rect)
+{
+    clipState.scissorBox.intersect(rect);
+    clipStateDirty = true;
+}
+
+void ClipStack::setStencilIndex(int stencilIndex)
+{
+    clipState.stencilIndex = stencilIndex;
+    clipStateDirty = true;
+}
+
+void ClipStack::apply(GraphicsContext3D&amp; 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&amp; context)
+{
+    if (!clipStateDirty)
+        return;
+
+    clipStateDirty = false;
+    apply(context);
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapClipStackh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/texmap/ClipStack.h (0 => 194577)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+/*
+ * 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 &quot;IntRect.h&quot;
+#include &quot;IntSize.h&quot;
+#include &lt;wtf/Vector.h&gt;
+
+namespace WebCore {
+
+class GraphicsContext3D;
+
+class ClipStack {
+public:
+    struct State {
+        State(const IntRect&amp; 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&amp; current() { return clipState; }
+
+    void reset(const IntRect&amp;, YAxisMode);
+    void intersect(const IntRect&amp;);
+    void setStencilIndex(int);
+    int getStencilIndex() const { return clipState.stencilIndex; }
+
+    void apply(GraphicsContext3D&amp;);
+    void applyIfNeeded(GraphicsContext3D&amp;);
+
+    bool isCurrentScissorBoxEmpty() const { return clipState.scissorBox.isEmpty(); }
+
+private:
+    Vector&lt;State&gt; clipStack;
+    State clipState;
+    IntSize size;
+    bool clipStateDirty { false };
+    YAxisMode yAxisMode { YAxisMode::Default };
+};
+
+} // namespace WebCore
+
+#endif // ClipStack_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapTextureMapperGLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (194576 => 194577)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -156,67 +156,6 @@
</span><span class="cx">         context-&gt;deleteBuffer(entry.value);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureMapperGL::ClipStack::reset(const IntRect&amp; rect, TextureMapperGL::ClipStack::YAxisMode mode)
-{
-    clipStack.clear();
-    size = rect.size();
-    yAxisMode = mode;
-    clipState = TextureMapperGL::ClipState(rect);
-    clipStateDirty = true;
-}
-
-void TextureMapperGL::ClipStack::intersect(const IntRect&amp; 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-&gt;scissor(clipState.scissorBox.x(),
-        (yAxisMode == InvertedYAxis) ? size.height() - clipState.scissorBox.maxY() : clipState.scissorBox.y(),
-        clipState.scissorBox.width(), clipState.scissorBox.height());
-    context-&gt;stencilOp(GraphicsContext3D::KEEP, GraphicsContext3D::KEEP, GraphicsContext3D::KEEP);
-    context-&gt;stencilFunc(GraphicsContext3D::EQUAL, clipState.stencilIndex - 1, clipState.stencilIndex - 1);
-    if (clipState.stencilIndex == 1)
-        context-&gt;disable(GraphicsContext3D::STENCIL_TEST);
-    else
-        context-&gt;enable(GraphicsContext3D::STENCIL_TEST);
-}
-
-void TextureMapperGL::ClipStack::applyIfNeeded(GraphicsContext3D* context)
-{
-    if (!clipStateDirty)
-        return;
-
-    clipStateDirty = false;
-    apply(context);
-}
-
</del><span class="cx"> void TextureMapperGLData::initializeStencil()
</span><span class="cx"> {
</span><span class="cx">     if (currentSurface) {
</span><span class="lines">@@ -242,7 +181,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureMapperGL::ClipStack&amp; TextureMapperGL::clipStack()
</del><ins>+ClipStack&amp; TextureMapperGL::clipStack()
</ins><span class="cx"> {
</span><span class="cx">     return data().currentSurface ? toBitmapTextureGL(data().currentSurface.get())-&gt;clipStack() : m_clipStack;
</span><span class="cx"> }
</span><span class="lines">@@ -258,7 +197,7 @@
</span><span class="cx">     m_context3D-&gt;depthMask(0);
</span><span class="cx">     m_context3D-&gt;getIntegerv(GraphicsContext3D::VIEWPORT, data().viewport);
</span><span class="cx">     m_context3D-&gt;getIntegerv(GraphicsContext3D::SCISSOR_BOX, data().previousScissor);
</span><del>-    m_clipStack.reset(IntRect(0, 0, data().viewport[2], data().viewport[3]), ClipStack::InvertedYAxis);
</del><ins>+    m_clipStack.reset(IntRect(0, 0, data().viewport[2], data().viewport[3]), ClipStack::YAxisMode::Inverted);
</ins><span class="cx">     m_context3D-&gt;getIntegerv(GraphicsContext3D::FRAMEBUFFER_BINDING, &amp;data().targetFrameBuffer);
</span><span class="cx">     data().PaintFlags = flags;
</span><span class="cx">     bindSurface(0);
</span><span class="lines">@@ -682,7 +621,7 @@
</span><span class="cx">     IntSize viewportSize(data().viewport[2], data().viewport[3]);
</span><span class="cx">     data().projectionMatrix = createProjectionMatrix(viewportSize, data().PaintFlags &amp; PaintingMirrored);
</span><span class="cx">     m_context3D-&gt;viewport(data().viewport[0], data().viewport[1], viewportSize.width(), viewportSize.height());
</span><del>-    m_clipStack.apply(m_context3D.get());
</del><ins>+    m_clipStack.apply(*m_context3D);
</ins><span class="cx">     data().currentSurface = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -718,7 +657,7 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     clipStack().intersect(rect);
</span><del>-    clipStack().applyIfNeeded(m_context3D.get());
</del><ins>+    clipStack().applyIfNeeded(*m_context3D);
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -770,13 +709,13 @@
</span><span class="cx"> 
</span><span class="cx">     // Increase stencilIndex and apply stencil testing.
</span><span class="cx">     clipStack().setStencilIndex(stencilIndex * 2);
</span><del>-    clipStack().applyIfNeeded(m_context3D.get());
</del><ins>+    clipStack().applyIfNeeded(*m_context3D);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperGL::endClip()
</span><span class="cx"> {
</span><span class="cx">     clipStack().pop();
</span><del>-    clipStack().applyIfNeeded(m_context3D.get());
</del><ins>+    clipStack().applyIfNeeded(*m_context3D);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntRect TextureMapperGL::clipBounds()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapTextureMapperGLh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h (194576 => 194577)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -23,6 +23,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(TEXTURE_MAPPER_GL)
</span><span class="cx"> 
</span><ins>+#include &quot;ClipStack.h&quot;
</ins><span class="cx"> #include &quot;FilterOperation.h&quot;
</span><span class="cx"> #include &quot;FloatQuad.h&quot;
</span><span class="cx"> #include &quot;GraphicsContext3D.h&quot;
</span><span class="lines">@@ -39,52 +40,6 @@
</span><span class="cx"> // An OpenGL-ES2 implementation of TextureMapper.
</span><span class="cx"> class TextureMapperGL : public TextureMapper {
</span><span class="cx"> public:
</span><del>-    struct ClipState {
-        IntRect scissorBox;
-        int stencilIndex;
-        ClipState(const IntRect&amp; 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&amp; current() { return clipState; }
-        void reset(const IntRect&amp;, YAxisMode);
-        void intersect(const IntRect&amp;);
-        void setStencilIndex(int);
-        inline int getStencilIndex() const
-        {
-            return clipState.stencilIndex;
-        }
-        inline bool isCurrentScissorBoxEmpty() const
-        {
-            return clipState.scissorBox.isEmpty();
-        }
-
-    private:
-        ClipState clipState;
-        Vector&lt;ClipState&gt; clipStack;
-        bool clipStateDirty;
-        IntSize size;
-        YAxisMode yAxisMode;
-    };
-
</del><span class="cx">     TextureMapperGL();
</span><span class="cx">     virtual ~TextureMapperGL();
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>