Title: [108678] trunk/Source/WebCore
Revision
108678
Author
[email protected]
Date
2012-02-23 15:03:32 -0800 (Thu, 23 Feb 2012)

Log Message

[chromium] Push CCLayerIteratorPosition struct into CCLayerIterator class.
https://bugs.webkit.org/show_bug.cgi?id=75864

Patch by Dana Jansens <[email protected]> on 2012-02-23
Reviewed by James Robinson.

* platform/graphics/chromium/cc/CCLayerIterator.cpp:
(WebCore::CCLayerIteratorActions::BackToFront::begin):
(WebCore::CCLayerIteratorActions::BackToFront::end):
(WebCore::CCLayerIteratorActions::BackToFront::next):
(WebCore::CCLayerIteratorActions::FrontToBack::begin):
(WebCore::CCLayerIteratorActions::FrontToBack::end):
(WebCore::CCLayerIteratorActions::FrontToBack::next):
(WebCore::CCLayerIteratorActions::FrontToBack::goToHighestInSubtree):
* platform/graphics/chromium/cc/CCLayerIterator.h:
(WebCore::CCLayerIterator::CCLayerIterator):
(WebCore::CCLayerIterator::operator++):
(WebCore::CCLayerIterator::operator==):
(WebCore::CCLayerIterator::operator->):
(WebCore::CCLayerIterator::operator*):
(WebCore::CCLayerIterator::representsTargetRenderSurface):
(WebCore::CCLayerIterator::representsContributingRenderSurface):
(WebCore::CCLayerIterator::currentLayer):
(WebCore::CCLayerIterator::currentLayerRepresentsContributingRenderSurface):
(WebCore::CCLayerIterator::currentLayerRepresentsTargetRenderSurface):
(WebCore::CCLayerIterator::targetRenderSurfaceLayer):
(WebCore::CCLayerIterator::targetRenderSurface):
(WebCore::CCLayerIterator::targetRenderSurfaceChildren):
* platform/graphics/chromium/cc/CCLayerIteratorPosition.h: Removed.

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (108677 => 108678)


--- trunk/Source/WebCore/ChangeLog	2012-02-23 22:51:09 UTC (rev 108677)
+++ trunk/Source/WebCore/ChangeLog	2012-02-23 23:03:32 UTC (rev 108678)
@@ -1,3 +1,34 @@
+2012-02-23  Dana Jansens  <[email protected]>
+
+        [chromium] Push CCLayerIteratorPosition struct into CCLayerIterator class.
+        https://bugs.webkit.org/show_bug.cgi?id=75864
+
+        Reviewed by James Robinson.
+
+        * platform/graphics/chromium/cc/CCLayerIterator.cpp:
+        (WebCore::CCLayerIteratorActions::BackToFront::begin):
+        (WebCore::CCLayerIteratorActions::BackToFront::end):
+        (WebCore::CCLayerIteratorActions::BackToFront::next):
+        (WebCore::CCLayerIteratorActions::FrontToBack::begin):
+        (WebCore::CCLayerIteratorActions::FrontToBack::end):
+        (WebCore::CCLayerIteratorActions::FrontToBack::next):
+        (WebCore::CCLayerIteratorActions::FrontToBack::goToHighestInSubtree):
+        * platform/graphics/chromium/cc/CCLayerIterator.h:
+        (WebCore::CCLayerIterator::CCLayerIterator):
+        (WebCore::CCLayerIterator::operator++):
+        (WebCore::CCLayerIterator::operator==):
+        (WebCore::CCLayerIterator::operator->):
+        (WebCore::CCLayerIterator::operator*):
+        (WebCore::CCLayerIterator::representsTargetRenderSurface):
+        (WebCore::CCLayerIterator::representsContributingRenderSurface):
+        (WebCore::CCLayerIterator::currentLayer):
+        (WebCore::CCLayerIterator::currentLayerRepresentsContributingRenderSurface):
+        (WebCore::CCLayerIterator::currentLayerRepresentsTargetRenderSurface):
+        (WebCore::CCLayerIterator::targetRenderSurfaceLayer):
+        (WebCore::CCLayerIterator::targetRenderSurface):
+        (WebCore::CCLayerIterator::targetRenderSurfaceChildren):
+        * platform/graphics/chromium/cc/CCLayerIteratorPosition.h: Removed.
+
 2012-02-23  Daniel Sievers  <[email protected]>
 
         [Chromium] Add video stream texture support

Modified: trunk/Source/WebCore/WebCore.gypi (108677 => 108678)


--- trunk/Source/WebCore/WebCore.gypi	2012-02-23 22:51:09 UTC (rev 108677)
+++ trunk/Source/WebCore/WebCore.gypi	2012-02-23 23:03:32 UTC (rev 108678)
@@ -3274,7 +3274,6 @@
             'platform/graphics/chromium/cc/CCLayerImpl.h',
             'platform/graphics/chromium/cc/CCLayerIterator.cpp',
             'platform/graphics/chromium/cc/CCLayerIterator.h',
-            'platform/graphics/chromium/cc/CCLayerIteratorPosition.h',
             'platform/graphics/chromium/cc/CCLayerQuad.cpp',
             'platform/graphics/chromium/cc/CCLayerQuad.h',
             'platform/graphics/chromium/cc/CCLayerSorter.cpp',

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerIterator.cpp (108677 => 108678)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerIterator.cpp	2012-02-23 22:51:09 UTC (rev 108677)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerIterator.cpp	2012-02-23 23:03:32 UTC (rev 108678)
@@ -35,73 +35,73 @@
 
 namespace WebCore {
 
-template <typename LayerType, typename RenderSurfaceType>
-void CCLayerIteratorActions::BackToFront::begin(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
+template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
 {
-    pos.targetRenderSurfaceLayerIndex = 0;
-    pos.currentLayerIndex = CCLayerIteratorPositionValue::LayerIndexRepresentingTargetRenderSurface;
+    it.m_targetRenderSurfaceLayerIndex = 0;
+    it.m_currentLayerIndex = CCLayerIteratorValue::LayerIndexRepresentingTargetRenderSurface;
 
     m_highestTargetRenderSurfaceLayer = 0;
 }
 
-template <typename LayerType, typename RenderSurfaceType>
-void CCLayerIteratorActions::BackToFront::end(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
+template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
 {
-    pos.targetRenderSurfaceLayerIndex = CCLayerIteratorPositionValue::InvalidTargetRenderSurfaceLayerIndex;
-    pos.currentLayerIndex = 0;
+    it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
+    it.m_currentLayerIndex = 0;
 }
 
-template <typename LayerType, typename RenderSurfaceType>
-void CCLayerIteratorActions::BackToFront::next(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
+template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
 {
     // If the current layer has a RS, move to its layer list. Otherwise, visit the next layer in the current RS layer list.
-    if (pos.currentLayerRepresentsContributingRenderSurface()) {
+    if (it.currentLayerRepresentsContributingRenderSurface()) {
         // Save our position in the childLayer list for the RenderSurface, then jump to the next RenderSurface. Save where we
         // came from in the next RenderSurface so we can get back to it.
-        pos.targetRenderSurface()->m_currentLayerIndexHistory = pos.currentLayerIndex;
-        int previousTargetRenderSurfaceLayer = pos.targetRenderSurfaceLayerIndex;
+        it.targetRenderSurface()->m_currentLayerIndexHistory = it.m_currentLayerIndex;
+        int previousTargetRenderSurfaceLayer = it.m_targetRenderSurfaceLayerIndex;
 
-        pos.targetRenderSurfaceLayerIndex = ++m_highestTargetRenderSurfaceLayer;
-        pos.currentLayerIndex = CCLayerIteratorPositionValue::LayerIndexRepresentingTargetRenderSurface;
+        it.m_targetRenderSurfaceLayerIndex = ++m_highestTargetRenderSurfaceLayer;
+        it.m_currentLayerIndex = CCLayerIteratorValue::LayerIndexRepresentingTargetRenderSurface;
 
-        pos.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory = previousTargetRenderSurfaceLayer;
+        it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory = previousTargetRenderSurfaceLayer;
     } else {
-        ++pos.currentLayerIndex;
+        ++it.m_currentLayerIndex;
 
-        int targetRenderSurfaceNumChildren = pos.targetRenderSurfaceChildren().size();
-        while (pos.currentLayerIndex == targetRenderSurfaceNumChildren) {
+        int targetRenderSurfaceNumChildren = it.targetRenderSurfaceChildren().size();
+        while (it.m_currentLayerIndex == targetRenderSurfaceNumChildren) {
             // Jump back to the previous RenderSurface, and get back the position where we were in that list, and move to the next position there.
-            if (!pos.targetRenderSurfaceLayerIndex) {
+            if (!it.m_targetRenderSurfaceLayerIndex) {
                 // End of the list
-                pos.targetRenderSurfaceLayerIndex = CCLayerIteratorPositionValue::InvalidTargetRenderSurfaceLayerIndex;
-                pos.currentLayerIndex = 0;
+                it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
+                it.m_currentLayerIndex = 0;
                 return;
             }
-            pos.targetRenderSurfaceLayerIndex = pos.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory;
-            pos.currentLayerIndex = pos.targetRenderSurface()->m_currentLayerIndexHistory + 1;
+            it.m_targetRenderSurfaceLayerIndex = it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory;
+            it.m_currentLayerIndex = it.targetRenderSurface()->m_currentLayerIndexHistory + 1;
 
-            targetRenderSurfaceNumChildren = pos.targetRenderSurfaceChildren().size();
+            targetRenderSurfaceNumChildren = it.targetRenderSurfaceChildren().size();
         }
     }
 }
 
-template <typename LayerType, typename RenderSurfaceType>
-void CCLayerIteratorActions::FrontToBack::begin(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
+template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
 {
-    pos.targetRenderSurfaceLayerIndex = 0;
-    pos.currentLayerIndex = pos.targetRenderSurfaceChildren().size() - 1;
-    goToHighestInSubtree(pos);
+    it.m_targetRenderSurfaceLayerIndex = 0;
+    it.m_currentLayerIndex = it.targetRenderSurfaceChildren().size() - 1;
+    goToHighestInSubtree(it);
 }
 
-template <typename LayerType, typename RenderSurfaceType>
-void CCLayerIteratorActions::FrontToBack::end(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
+template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
 {
-    pos.targetRenderSurfaceLayerIndex = CCLayerIteratorPositionValue::InvalidTargetRenderSurfaceLayerIndex;
-    pos.currentLayerIndex = 0;
+    it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
+    it.m_currentLayerIndex = 0;
 }
 
-template <typename LayerType, typename RenderSurfaceType>
-void CCLayerIteratorActions::FrontToBack::next(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
+template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
 {
     // Moves to the previous layer in the current RS layer list. Then we check if the
     // new current layer has its own RS, in which case there are things in that RS layer list that are higher, so
@@ -109,61 +109,61 @@
     // If we move back past the front of the list, we jump up to the previous RS layer list, picking up again where we
     // had previously recursed into the current RS layer list.
 
-    if (!pos.currentLayerRepresentsTargetRenderSurface()) {
+    if (!it.currentLayerRepresentsTargetRenderSurface()) {
         // Subtracting one here will eventually cause the current layer to become that layer
         // representing the target render surface.
-        --pos.currentLayerIndex;
-        goToHighestInSubtree(pos);
+        --it.m_currentLayerIndex;
+        goToHighestInSubtree(it);
     } else {
-        while (pos.currentLayerRepresentsTargetRenderSurface()) {
-            if (!pos.targetRenderSurfaceLayerIndex) {
+        while (it.currentLayerRepresentsTargetRenderSurface()) {
+            if (!it.m_targetRenderSurfaceLayerIndex) {
                 // End of the list
-                pos.targetRenderSurfaceLayerIndex = CCLayerIteratorPositionValue::InvalidTargetRenderSurfaceLayerIndex;
-                pos.currentLayerIndex = 0;
+                it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
+                it.m_currentLayerIndex = 0;
                 return;
             }
-            pos.targetRenderSurfaceLayerIndex = pos.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory;
-            pos.currentLayerIndex = pos.targetRenderSurface()->m_currentLayerIndexHistory;
+            it.m_targetRenderSurfaceLayerIndex = it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory;
+            it.m_currentLayerIndex = it.targetRenderSurface()->m_currentLayerIndexHistory;
         }
     }
 }
 
-template <typename LayerType, typename RenderSurfaceType>
-void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
+template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
 {
-    if (pos.currentLayerRepresentsTargetRenderSurface())
+    if (it.currentLayerRepresentsTargetRenderSurface())
         return;
-    while (pos.currentLayerRepresentsContributingRenderSurface()) {
+    while (it.currentLayerRepresentsContributingRenderSurface()) {
         // Save where we were in the current target surface, move to the next one, and save the target surface that we
         // came from there so we can go back to it.
-        pos.targetRenderSurface()->m_currentLayerIndexHistory = pos.currentLayerIndex;
-        int previousTargetRenderSurfaceLayer = pos.targetRenderSurfaceLayerIndex;
+        it.targetRenderSurface()->m_currentLayerIndexHistory = it.m_currentLayerIndex;
+        int previousTargetRenderSurfaceLayer = it.m_targetRenderSurfaceLayerIndex;
 
-        for (LayerType* layer = pos.currentLayer(); pos.targetRenderSurfaceLayer() != layer; ++pos.targetRenderSurfaceLayerIndex) { }
-        pos.currentLayerIndex = pos.targetRenderSurfaceChildren().size() - 1;
+        for (LayerType* layer = it.currentLayer(); it.targetRenderSurfaceLayer() != layer; ++it.m_targetRenderSurfaceLayerIndex) { }
+        it.m_currentLayerIndex = it.targetRenderSurfaceChildren().size() - 1;
 
-        pos.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory = previousTargetRenderSurfaceLayer;
+        it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory = previousTargetRenderSurfaceLayer;
     }
 }
 
 // Declare each of the above functions for LayerChromium and CCLayerImpl classes so that they are linked.
-template void CCLayerIteratorActions::BackToFront::begin(CCLayerIteratorPosition<LayerChromium, RenderSurfaceChromium>&);
-template void CCLayerIteratorActions::BackToFront::end(CCLayerIteratorPosition<LayerChromium, RenderSurfaceChromium>&);
-template void CCLayerIteratorActions::BackToFront::next(CCLayerIteratorPosition<LayerChromium, RenderSurfaceChromium>&);
+template void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<LayerChromium, RenderSurfaceChromium, BackToFront> &);
+template void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<LayerChromium, RenderSurfaceChromium, BackToFront>&);
+template void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<LayerChromium, RenderSurfaceChromium, BackToFront>&);
 
-template void CCLayerIteratorActions::BackToFront::begin(CCLayerIteratorPosition<CCLayerImpl, CCRenderSurface>&);
-template void CCLayerIteratorActions::BackToFront::end(CCLayerIteratorPosition<CCLayerImpl, CCRenderSurface>&);
-template void CCLayerIteratorActions::BackToFront::next(CCLayerIteratorPosition<CCLayerImpl, CCRenderSurface>&);
+template void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<CCLayerImpl, CCRenderSurface, BackToFront>&);
+template void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<CCLayerImpl, CCRenderSurface, BackToFront>&);
+template void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<CCLayerImpl, CCRenderSurface, BackToFront>&);
 
-template void CCLayerIteratorActions::FrontToBack::next(CCLayerIteratorPosition<LayerChromium, RenderSurfaceChromium>&);
-template void CCLayerIteratorActions::FrontToBack::end(CCLayerIteratorPosition<LayerChromium, RenderSurfaceChromium>&);
-template void CCLayerIteratorActions::FrontToBack::begin(CCLayerIteratorPosition<LayerChromium, RenderSurfaceChromium>&);
-template void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIteratorPosition<LayerChromium, RenderSurfaceChromium>&);
+template void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<LayerChromium, RenderSurfaceChromium, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<LayerChromium, RenderSurfaceChromium, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<LayerChromium, RenderSurfaceChromium, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<LayerChromium, RenderSurfaceChromium, FrontToBack>&);
 
-template void CCLayerIteratorActions::FrontToBack::next(CCLayerIteratorPosition<CCLayerImpl, CCRenderSurface>&);
-template void CCLayerIteratorActions::FrontToBack::end(CCLayerIteratorPosition<CCLayerImpl, CCRenderSurface>&);
-template void CCLayerIteratorActions::FrontToBack::begin(CCLayerIteratorPosition<CCLayerImpl, CCRenderSurface>&);
-template void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIteratorPosition<CCLayerImpl, CCRenderSurface>&);
+template void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<CCLayerImpl, CCRenderSurface, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<CCLayerImpl, CCRenderSurface, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<CCLayerImpl, CCRenderSurface, FrontToBack>&);
+template void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<CCLayerImpl, CCRenderSurface, FrontToBack>&);
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerIterator.h (108677 => 108678)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerIterator.h	2012-02-23 22:51:09 UTC (rev 108677)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerIterator.h	2012-02-23 23:03:32 UTC (rev 108678)
@@ -25,7 +25,7 @@
 #ifndef CCLayerIterator_h
 #define CCLayerIterator_h
 
-#include "cc/CCLayerIteratorPosition.h"
+#include "cc/CCLayerTreeHostCommon.h"
 
 #include <wtf/PassOwnPtr.h>
 #include <wtf/RefPtr.h>
@@ -82,43 +82,78 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
+// Non-templated constants
+struct CCLayerIteratorValue {
+    static const int InvalidTargetRenderSurfaceLayerIndex = -1;
+    // This must be -1 since the iterator action code assumes that this value can be
+    // reached by subtracting one from the position of the first layer in the current
+    // target surface's child layer list, which is 0.
+    static const int LayerIndexRepresentingTargetRenderSurface = -1;
+};
+
 // An iterator class for walking over layers in the RenderSurface-Layer tree.
 template <typename LayerType, typename RenderSurfaceType, typename IteratorActionType>
 class CCLayerIterator {
     typedef CCLayerIterator<LayerType, RenderSurfaceType, IteratorActionType> CCLayerIteratorType;
 
 public:
-    CCLayerIterator() { }
+    CCLayerIterator() : m_renderSurfaceLayerList(0) { }
 
     static CCLayerIteratorType begin(const Vector<RefPtr<LayerType> >* renderSurfaceLayerList) { return CCLayerIteratorType(renderSurfaceLayerList, true); }
     static CCLayerIteratorType end(const Vector<RefPtr<LayerType> >* renderSurfaceLayerList) { return CCLayerIteratorType(renderSurfaceLayerList, false); }
 
-    CCLayerIteratorType& operator++() { ASSERT(m_actions); m_actions->next(m_position); return *this; }
-    bool operator==(const CCLayerIteratorType& other) const { return m_position == other.m_position; }
+    CCLayerIteratorType& operator++() { m_actions.next(*this); return *this; }
+    bool operator==(const CCLayerIterator& other) const
+    {
+        return m_targetRenderSurfaceLayerIndex == other.m_targetRenderSurfaceLayerIndex
+            && m_currentLayerIndex == other.m_currentLayerIndex;
+    }
     bool operator!=(const CCLayerIteratorType& other) const { return !(*this == other); }
 
-    LayerType* operator->() const { return m_position.currentLayer(); }
-    LayerType* operator*() const { return m_position.currentLayer(); }
+    LayerType* operator->() const { return currentLayer(); }
+    LayerType* operator*() const { return currentLayer(); }
 
-    bool representsTargetRenderSurface() const { return m_position.currentLayerRepresentsTargetRenderSurface(); }
-    bool representsContributingRenderSurface() const { return !representsTargetRenderSurface() && m_position.currentLayerRepresentsContributingRenderSurface(); }
+    bool representsTargetRenderSurface() const { return currentLayerRepresentsTargetRenderSurface(); }
+    bool representsContributingRenderSurface() const { return !representsTargetRenderSurface() && currentLayerRepresentsContributingRenderSurface(); }
     bool representsItself() const { return !representsTargetRenderSurface() && !representsContributingRenderSurface(); }
 
-    LayerType* targetRenderSurfaceLayer() const { return m_position.targetRenderSurfaceLayer(); }
+    LayerType* targetRenderSurfaceLayer() const { return (*m_renderSurfaceLayerList)[m_targetRenderSurfaceLayerIndex].get(); }
 
 private:
     CCLayerIterator(const Vector<RefPtr<LayerType> >* renderSurfaceLayerList, bool start)
-        : m_position(renderSurfaceLayerList)
-        , m_actions(adoptPtr(new IteratorActionType()))
+        : m_renderSurfaceLayerList(renderSurfaceLayerList)
     {
         if (start && !renderSurfaceLayerList->isEmpty())
-            m_actions->begin(m_position);
+            m_actions.begin(*this);
         else
-            m_actions->end(m_position);
+            m_actions.end(*this);
     }
 
-    CCLayerIteratorPosition<LayerType, RenderSurfaceType> m_position;
-    OwnPtr<IteratorActionType> m_actions;
+    inline LayerType* currentLayer() const { return currentLayerRepresentsTargetRenderSurface() ? targetRenderSurfaceLayer() : targetRenderSurfaceChildren()[m_currentLayerIndex].get(); }
+
+    inline bool currentLayerRepresentsContributingRenderSurface() const { return CCLayerTreeHostCommon::renderSurfaceContributesToTarget<LayerType>(currentLayer(), targetRenderSurfaceLayer()->id()); }
+    inline bool currentLayerRepresentsTargetRenderSurface() const { return m_currentLayerIndex == CCLayerIteratorValue::LayerIndexRepresentingTargetRenderSurface; }
+
+    inline RenderSurfaceType* targetRenderSurface() const { return targetRenderSurfaceLayer()->renderSurface(); }
+    inline const Vector<RefPtr<LayerType> >& targetRenderSurfaceChildren() const { return targetRenderSurface()->layerList(); }
+
+    IteratorActionType m_actions;
+    const Vector<RefPtr<LayerType> >* m_renderSurfaceLayerList;
+
+    // The iterator's current position.
+
+    // A position in the renderSurfaceLayerList. This points to a layer which owns the current target surface.
+    // This is a value from 0 to n-1 (n = size of renderSurfaceLayerList = number of surfaces). A value outside of
+    // this range (for example, CCLayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex) is used to
+    // indicate a position outside the bounds of the tree.
+    int m_targetRenderSurfaceLayerIndex;
+    // A position in the list of layers that are children of the current target surface. When pointing to one of
+    // these layers, this is a value from 0 to n-1 (n = number of children). Since the iterator must also stop at
+    // the layers representing the target surface, this is done by setting the currentLayerIndex to a value of
+    // CCLayerIteratorValue::LayerRepresentingTargetRenderSurface.
+    int m_currentLayerIndex;
+
+    friend struct CCLayerIteratorActions;
 };
 
 // Orderings for iterating over the RenderSurface-Layer tree.
@@ -126,14 +161,14 @@
     // Walks layers sorted by z-order from back to front.
     class BackToFront {
     public:
-        template <typename LayerType, typename RenderSurfaceType>
-        void begin(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
+        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+        void begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
 
-        template <typename LayerType, typename RenderSurfaceType>
-        void end(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
+        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+        void end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
 
-        template <typename LayerType, typename RenderSurfaceType>
-        void next(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
+        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+        void next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
 
     private:
         int m_highestTargetRenderSurfaceLayer;
@@ -142,18 +177,18 @@
     // Walks layers sorted by z-order from front to back
     class FrontToBack {
     public:
-        template <typename LayerType, typename RenderSurfaceType>
-        void begin(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
+        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+        void begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
 
-        template <typename LayerType, typename RenderSurfaceType>
-        void end(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
+        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+        void end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
 
-        template <typename LayerType, typename RenderSurfaceType>
-        void next(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
+        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+        void next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
 
     private:
-        template <typename LayerType, typename RenderSurfaceType>
-        void goToHighestInSubtree(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
+        template <typename LayerType, typename RenderSurfaceType, typename ActionType>
+        void goToHighestInSubtree(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
     };
 };
 

Deleted: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerIteratorPosition.h (108677 => 108678)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerIteratorPosition.h	2012-02-23 22:51:09 UTC (rev 108677)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerIteratorPosition.h	2012-02-23 23:03:32 UTC (rev 108678)
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CCLayerIteratorPosition_h
-#define CCLayerIteratorPosition_h
-
-#include "cc/CCLayerTreeHostCommon.h"
-
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-// Non-templated constants
-struct CCLayerIteratorPositionValue {
-    static const int InvalidTargetRenderSurfaceLayerIndex = -1;
-    // This must be -1 since the iterator action code assumes that this value can be
-    // reached by subtracting one from the position of the first layer in the current
-    // target surface's child layer list, which is 0.
-    static const int LayerIndexRepresentingTargetRenderSurface = -1;
-};
-
-// A struct to hold the iterator's current position, which is passed to the various CCLayerIteratorAction functions, for them to
-// read and update. This struct exists so the templated action functions don't need to access the CCLayerIterator class.
-//
-// There is a 1:1 relationship between an instance of the CCLayerIteratorPosition class and a CCLayerIteratorActions::Foo class,
-// so an iterator action class can hold extra position data, if required, in its own class instance.
-//
-// The current position of the iterator is held in two integer variables.
-// - The targetRenderSurfaceLayerIndex is a position in the renderSurfaceLayerList. This points to a layer which owns the current
-// target surface. This is a value from 0 to n-1 (n = size of renderSurfaceLayerList = number of surfaces). A value outside of
-// this range (for example, CCLayerIteratorPositionValue::InvalidTargetRenderSurfaceLayerIndex) is used to indicate a position
-// outside the bounds of the tree.
-// - The currentLayerIndex is a position in the list of layers that are children of the current target surface. When pointing to
-// one of these layers, this is a value from 0 to n-1 (n = number of children). Since the iterator must also stop at the layers
-// representing the target surface, this is done by setting the currentLayerIndex to a value of
-// CCLayerIteratorPositionValue::LayerRepresentingTargetRenderSurface.
-template<typename LayerType, typename RenderSurfaceType>
-struct CCLayerIteratorPosition {
-    CCLayerIteratorPosition() : renderSurfaceLayerList(0) { }
-    explicit CCLayerIteratorPosition(const Vector<RefPtr<LayerType> >* renderSurfaceLayerList) : renderSurfaceLayerList(renderSurfaceLayerList) { }
-
-    inline LayerType* currentLayer() const { return currentLayerRepresentsTargetRenderSurface() ? targetRenderSurfaceLayer() : targetRenderSurfaceChildren()[currentLayerIndex].get(); }
-
-    inline bool currentLayerRepresentsContributingRenderSurface() const { return CCLayerTreeHostCommon::renderSurfaceContributesToTarget<LayerType>(currentLayer(), targetRenderSurfaceLayer()->id()); }
-    inline bool currentLayerRepresentsTargetRenderSurface() const { return currentLayerIndex == CCLayerIteratorPositionValue::LayerIndexRepresentingTargetRenderSurface; }
-
-    inline LayerType* targetRenderSurfaceLayer() const { return (*renderSurfaceLayerList)[targetRenderSurfaceLayerIndex].get(); }
-    inline RenderSurfaceType* targetRenderSurface() const { return targetRenderSurfaceLayer()->renderSurface(); }
-    inline const Vector<RefPtr<LayerType> >& targetRenderSurfaceChildren() const { return targetRenderSurface()->layerList(); }
-
-    inline bool operator==(const CCLayerIteratorPosition& other) const
-    {
-        return targetRenderSurfaceLayerIndex == other.targetRenderSurfaceLayerIndex
-            && currentLayerIndex == other.currentLayerIndex;
-    }
-
-    const Vector<RefPtr<LayerType> >* renderSurfaceLayerList;
-    int targetRenderSurfaceLayerIndex;
-    int currentLayerIndex;
-};
-
-} // namespace WebCore
-
-#endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to