+2012-02-22 Adrienne Walker <enne@google.com>
+
+ Unreviewed, rolling out r108518.
+ http://trac.webkit.org/changeset/108518
+ https://bugs.webkit.org/show_bug.cgi?id=75864
+
+ Breaks surfaceOcclusionWithOverlappingSiblingSurfaces unit test.
+
+ * WebCore.gypi:
+ * platform/graphics/chromium/cc/CCLayerIterator.cpp:
+ (WebCore):
+ (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):
+ (WebCore::CCLayerIterator::CCLayerIterator):
+ (WebCore::CCLayerIterator::operator++):
+ (WebCore::CCLayerIterator::operator==):
+ (WebCore::CCLayerIterator::operator->):
+ (WebCore::CCLayerIterator::operator*):
+ (WebCore::CCLayerIterator::representsTargetRenderSurface):
+ (WebCore::CCLayerIterator::representsContributingRenderSurface):
+ (WebCore::CCLayerIterator::targetRenderSurfaceLayer):
+ (CCLayerIterator):
+ (BackToFront):
+ (FrontToBack):
+ * platform/graphics/chromium/cc/CCLayerIteratorPosition.h: Added.
+ (WebCore):
+ (CCLayerIteratorPositionValue):
+ (WebCore::CCLayerIteratorPosition::CCLayerIteratorPosition):
+ (CCLayerIteratorPosition):
+ (WebCore::CCLayerIteratorPosition::currentLayer):
+ (WebCore::CCLayerIteratorPosition::currentLayerRepresentsContributingRenderSurface):
+ (WebCore::CCLayerIteratorPosition::currentLayerRepresentsTargetRenderSurface):
+ (WebCore::CCLayerIteratorPosition::targetRenderSurfaceLayer):
+ (WebCore::CCLayerIteratorPosition::targetRenderSurface):
+ (WebCore::CCLayerIteratorPosition::targetRenderSurfaceChildren):
+ (WebCore::CCLayerIteratorPosition::operator==):
+
2012-02-22 Dan Bernstein <mitz@apple.com>
REGRESSION (r62632): page-break-inside: avoid is ignored
'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',
namespace WebCore {
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::BackToFront::begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename RenderSurfaceType>
+void CCLayerIteratorActions::BackToFront::begin(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
{
- it.m_targetRenderSurfaceLayerIndex = 0;
- it.m_currentLayerIndex = CCLayerIteratorValue::LayerIndexRepresentingTargetRenderSurface;
+ pos.targetRenderSurfaceLayerIndex = 0;
+ pos.currentLayerIndex = CCLayerIteratorPositionValue::LayerIndexRepresentingTargetRenderSurface;
m_highestTargetRenderSurfaceLayer = 0;
}
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::BackToFront::end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename RenderSurfaceType>
+void CCLayerIteratorActions::BackToFront::end(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
{
- it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
- it.m_currentLayerIndex = 0;
+ pos.targetRenderSurfaceLayerIndex = CCLayerIteratorPositionValue::InvalidTargetRenderSurfaceLayerIndex;
+ pos.currentLayerIndex = 0;
}
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::BackToFront::next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename RenderSurfaceType>
+void CCLayerIteratorActions::BackToFront::next(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
{
// If the current layer has a RS, move to its layer list. Otherwise, visit the next layer in the current RS layer list.
- if (it.currentLayerRepresentsContributingRenderSurface()) {
+ if (pos.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.
- it.targetRenderSurface()->m_currentLayerIndexHistory = it.m_currentLayerIndex;
- int previousTargetRenderSurfaceLayer = it.m_targetRenderSurfaceLayerIndex;
+ pos.targetRenderSurface()->m_currentLayerIndexHistory = pos.currentLayerIndex;
+ int previousTargetRenderSurfaceLayer = pos.targetRenderSurfaceLayerIndex;
- it.m_targetRenderSurfaceLayerIndex = ++m_highestTargetRenderSurfaceLayer;
- it.m_currentLayerIndex = CCLayerIteratorValue::LayerIndexRepresentingTargetRenderSurface;
+ pos.targetRenderSurfaceLayerIndex = ++m_highestTargetRenderSurfaceLayer;
+ pos.currentLayerIndex = CCLayerIteratorPositionValue::LayerIndexRepresentingTargetRenderSurface;
- it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory = previousTargetRenderSurfaceLayer;
+ pos.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory = previousTargetRenderSurfaceLayer;
} else {
- ++it.m_currentLayerIndex;
+ ++pos.currentLayerIndex;
- int targetRenderSurfaceNumChildren = it.targetRenderSurfaceChildren().size();
- while (it.m_currentLayerIndex == targetRenderSurfaceNumChildren) {
+ int targetRenderSurfaceNumChildren = pos.targetRenderSurfaceChildren().size();
+ while (pos.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 (!it.m_targetRenderSurfaceLayerIndex) {
+ if (!pos.targetRenderSurfaceLayerIndex) {
// End of the list
- it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
- it.m_currentLayerIndex = 0;
+ pos.targetRenderSurfaceLayerIndex = CCLayerIteratorPositionValue::InvalidTargetRenderSurfaceLayerIndex;
+ pos.currentLayerIndex = 0;
return;
}
- it.m_targetRenderSurfaceLayerIndex = it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory;
- it.m_currentLayerIndex = it.targetRenderSurface()->m_currentLayerIndexHistory + 1;
+ pos.targetRenderSurfaceLayerIndex = pos.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory;
+ pos.currentLayerIndex = pos.targetRenderSurface()->m_currentLayerIndexHistory + 1;
- targetRenderSurfaceNumChildren = it.targetRenderSurfaceChildren().size();
+ targetRenderSurfaceNumChildren = pos.targetRenderSurfaceChildren().size();
}
}
}
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::FrontToBack::begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename RenderSurfaceType>
+void CCLayerIteratorActions::FrontToBack::begin(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
{
- it.m_targetRenderSurfaceLayerIndex = 0;
- it.m_currentLayerIndex = it.targetRenderSurfaceChildren().size() - 1;
- goToHighestInSubtree(it);
+ pos.targetRenderSurfaceLayerIndex = 0;
+ pos.currentLayerIndex = pos.targetRenderSurfaceChildren().size() - 1;
+ goToHighestInSubtree(pos);
}
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::FrontToBack::end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename RenderSurfaceType>
+void CCLayerIteratorActions::FrontToBack::end(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
{
- it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
- it.m_currentLayerIndex = 0;
+ pos.targetRenderSurfaceLayerIndex = CCLayerIteratorPositionValue::InvalidTargetRenderSurfaceLayerIndex;
+ pos.currentLayerIndex = 0;
}
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::FrontToBack::next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename RenderSurfaceType>
+void CCLayerIteratorActions::FrontToBack::next(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
{
// 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
// 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 (!it.currentLayerRepresentsTargetRenderSurface()) {
+ if (!pos.currentLayerRepresentsTargetRenderSurface()) {
// Subtracting one here will eventually cause the current layer to become that layer
// representing the target render surface.
- --it.m_currentLayerIndex;
- goToHighestInSubtree(it);
+ --pos.currentLayerIndex;
+ goToHighestInSubtree(pos);
} else {
- while (it.currentLayerRepresentsTargetRenderSurface()) {
- if (!it.m_targetRenderSurfaceLayerIndex) {
+ while (pos.currentLayerRepresentsTargetRenderSurface()) {
+ if (!pos.targetRenderSurfaceLayerIndex) {
// End of the list
- it.m_targetRenderSurfaceLayerIndex = CCLayerIteratorValue::InvalidTargetRenderSurfaceLayerIndex;
- it.m_currentLayerIndex = 0;
+ pos.targetRenderSurfaceLayerIndex = CCLayerIteratorPositionValue::InvalidTargetRenderSurfaceLayerIndex;
+ pos.currentLayerIndex = 0;
return;
}
- it.m_targetRenderSurfaceLayerIndex = it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory;
- it.m_currentLayerIndex = it.targetRenderSurface()->m_currentLayerIndexHistory;
+ pos.targetRenderSurfaceLayerIndex = pos.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory;
+ pos.currentLayerIndex = pos.targetRenderSurface()->m_currentLayerIndexHistory;
}
}
}
-template <typename LayerType, typename RenderSurfaceType, typename ActionType>
-void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>& it)
+template <typename LayerType, typename RenderSurfaceType>
+void CCLayerIteratorActions::FrontToBack::goToHighestInSubtree(CCLayerIteratorPosition<LayerType, RenderSurfaceType>& pos)
{
- if (it.currentLayerRepresentsTargetRenderSurface())
+ if (pos.currentLayerRepresentsTargetRenderSurface())
return;
- while (it.currentLayerRepresentsContributingRenderSurface()) {
+ while (pos.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.
- it.targetRenderSurface()->m_currentLayerIndexHistory = it.m_currentLayerIndex;
- int previousTargetRenderSurfaceLayer = it.m_targetRenderSurfaceLayerIndex;
+ pos.targetRenderSurface()->m_currentLayerIndexHistory = pos.currentLayerIndex;
+ int previousTargetRenderSurfaceLayer = pos.targetRenderSurfaceLayerIndex;
- for (LayerType* layer = it.currentLayer(); it.targetRenderSurfaceLayer() != layer; ++it.m_targetRenderSurfaceLayerIndex) { }
- it.m_currentLayerIndex = it.targetRenderSurfaceChildren().size() - 1;
+ for (LayerType* layer = pos.currentLayer(); pos.targetRenderSurfaceLayer() != layer; ++pos.targetRenderSurfaceLayerIndex) { }
+ pos.currentLayerIndex = pos.targetRenderSurfaceChildren().size() - 1;
- it.targetRenderSurface()->m_targetRenderSurfaceLayerIndexHistory = previousTargetRenderSurfaceLayer;
+ pos.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(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(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(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(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>&);
+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(CCLayerIteratorPosition<CCLayerImpl, CCRenderSurface>&);
+template void CCLayerIteratorActions::BackToFront::end(CCLayerIteratorPosition<CCLayerImpl, CCRenderSurface>&);
+template void CCLayerIteratorActions::BackToFront::next(CCLayerIteratorPosition<CCLayerImpl, CCRenderSurface>&);
+
+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(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>&);
} // namespace WebCore
#ifndef CCLayerIterator_h
#define CCLayerIterator_h
-#include "cc/CCLayerTreeHostCommon.h"
+#include "cc/CCLayerIteratorPosition.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/RefPtr.h>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// 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() : m_renderSurfaceLayerList(0) { }
+ CCLayerIterator() { }
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++() { m_actions.next(*this); return *this; }
- bool operator==(const CCLayerIterator& other) const
- {
- return m_targetRenderSurfaceLayerIndex == other.m_targetRenderSurfaceLayerIndex
- && m_currentLayerIndex == other.m_currentLayerIndex;
- }
+ CCLayerIteratorType& operator++() { ASSERT(m_actions); m_actions->next(m_position); return *this; }
+ bool operator==(const CCLayerIteratorType& other) const { return m_position == other.m_position; }
bool operator!=(const CCLayerIteratorType& other) const { return !(*this == other); }
- LayerType* operator->() const { return currentLayer(); }
- LayerType* operator*() const { return currentLayer(); }
+ LayerType* operator->() const { return m_position.currentLayer(); }
+ LayerType* operator*() const { return m_position.currentLayer(); }
- bool representsTargetRenderSurface() const { return currentLayerRepresentsTargetRenderSurface(); }
- bool representsContributingRenderSurface() const { return !representsTargetRenderSurface() && currentLayerRepresentsContributingRenderSurface(); }
+ bool representsTargetRenderSurface() const { return m_position.currentLayerRepresentsTargetRenderSurface(); }
+ bool representsContributingRenderSurface() const { return !representsTargetRenderSurface() && m_position.currentLayerRepresentsContributingRenderSurface(); }
bool representsItself() const { return !representsTargetRenderSurface() && !representsContributingRenderSurface(); }
- LayerType* targetRenderSurfaceLayer() const { return (*m_renderSurfaceLayerList)[m_targetRenderSurfaceLayerIndex].get(); }
+ LayerType* targetRenderSurfaceLayer() const { return m_position.targetRenderSurfaceLayer(); }
private:
CCLayerIterator(const Vector<RefPtr<LayerType> >* renderSurfaceLayerList, bool start)
- : m_renderSurfaceLayerList(renderSurfaceLayerList)
+ : m_position(renderSurfaceLayerList)
+ , m_actions(adoptPtr(new IteratorActionType()))
{
if (start && !renderSurfaceLayerList->isEmpty())
- m_actions.begin(*this);
+ m_actions->begin(m_position);
else
- m_actions.end(*this);
+ m_actions->end(m_position);
}
- 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;
+ CCLayerIteratorPosition<LayerType, RenderSurfaceType> m_position;
+ OwnPtr<IteratorActionType> m_actions;
};
// Orderings for iterating over the RenderSurface-Layer tree.
// Walks layers sorted by z-order from back to front.
class BackToFront {
public:
- template <typename LayerType, typename RenderSurfaceType, typename ActionType>
- void begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+ template <typename LayerType, typename RenderSurfaceType>
+ void begin(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
- template <typename LayerType, typename RenderSurfaceType, typename ActionType>
- void end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+ template <typename LayerType, typename RenderSurfaceType>
+ void end(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
- template <typename LayerType, typename RenderSurfaceType, typename ActionType>
- void next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+ template <typename LayerType, typename RenderSurfaceType>
+ void next(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
private:
int m_highestTargetRenderSurfaceLayer;
// Walks layers sorted by z-order from front to back
class FrontToBack {
public:
- template <typename LayerType, typename RenderSurfaceType, typename ActionType>
- void begin(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+ template <typename LayerType, typename RenderSurfaceType>
+ void begin(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
- template <typename LayerType, typename RenderSurfaceType, typename ActionType>
- void end(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+ template <typename LayerType, typename RenderSurfaceType>
+ void end(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
- template <typename LayerType, typename RenderSurfaceType, typename ActionType>
- void next(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+ template <typename LayerType, typename RenderSurfaceType>
+ void next(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
private:
- template <typename LayerType, typename RenderSurfaceType, typename ActionType>
- void goToHighestInSubtree(CCLayerIterator<LayerType, RenderSurfaceType, ActionType>&);
+ template <typename LayerType, typename RenderSurfaceType>
+ void goToHighestInSubtree(CCLayerIteratorPosition<LayerType, RenderSurfaceType>&);
};
};
--- /dev/null
+/*
+ * 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