#include "cc/CCQuadCuller.h"
+#include "cc/CCOcclusionTracker.h"
+#include "cc/CCSingleThreadProxy.h"
+#include "cc/CCTiledLayerImpl.h"
#include "cc/CCTileDrawQuad.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
namespace {
-class CCQuadCullerTest : public testing::Test {
+class TestCCOcclusionTrackerImpl : public CCOcclusionTrackerImpl {
+public:
+ TestCCOcclusionTrackerImpl(const IntRect& scissorRectInScreen)
+ : CCOcclusionTrackerImpl(scissorRectInScreen)
+ , m_scissorRectInScreen(scissorRectInScreen)
+ {
+ // Pretend we have visited a render surface.
+ m_stack.append(StackObject());
+ }
+
+protected:
+ virtual IntRect layerScissorRectInTargetSurface(const CCLayerImpl* layer) const { return m_scissorRectInScreen; }
+
+private:
+ IntRect m_scissorRectInScreen;
};
-static PassOwnPtr<CCDrawQuad> MakeTileQuad(CCSharedQuadState* state, const IntRect& rect, const IntRect& opaqueRect = IntRect())
+static PassOwnPtr<CCTiledLayerImpl> makeLayer(const TransformationMatrix& drawTransform, const IntRect& layerRect, float opacity, bool opaque, const IntRect& layerOpaqueRect)
{
- return CCTileDrawQuad::create(state, rect, intersection(rect, opaqueRect), 1, IntPoint(1, 1), IntSize(100, 100), 0, false, false, false, false, false);
+ OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(0);
+ OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100, 100), CCLayerTilingData::NoBorderTexels);
+ tiler->setBounds(layerRect.size());
+ layer->setTilingData(*tiler);
+ layer->setSkipsDraw(false);
+ layer->setDrawTransform(drawTransform);
+ layer->setScreenSpaceTransform(drawTransform);
+ layer->setVisibleLayerRect(layerRect);
+ layer->setDrawOpacity(opacity);
+ layer->setOpaque(opaque);
+
+ int textureId = 1;
+ for (int i = 0; i < tiler->numTilesX(); ++i)
+ for (int j = 0; j < tiler->numTilesY(); ++j) {
+ IntRect tileOpaqueRect = opaque ? tiler->tileBounds(i, j) : intersection(tiler->tileBounds(i, j), layerOpaqueRect);
+ layer->pushTileProperties(i, j, static_cast<Platform3DObject>(textureId++), tileOpaqueRect);
+ }
+
+ return layer.release();
}
-void setQuads(CCSharedQuadState* rootState, CCSharedQuadState* childState, CCQuadList& quadList, const IntRect& opaqueRect = IntRect())
+static void appendQuads(CCQuadList& quadList, CCTiledLayerImpl* layer, CCOcclusionTrackerImpl& occlusionTracker, CCOverdrawCounts& overdraw)
{
- quadList.clear();
-
- quadList.append(MakeTileQuad(rootState, IntRect(IntPoint(), IntSize(100, 100)), opaqueRect));
- quadList.append(MakeTileQuad(rootState, IntRect(IntPoint(100, 0), IntSize(100, 100)), opaqueRect));
- quadList.append(MakeTileQuad(rootState, IntRect(IntPoint(200, 0), IntSize(100, 100)), opaqueRect));
- quadList.append(MakeTileQuad(rootState, IntRect(IntPoint(0, 100), IntSize(100, 100)), opaqueRect));
- quadList.append(MakeTileQuad(rootState, IntRect(IntPoint(100, 100), IntSize(100, 100)), opaqueRect));
- quadList.append(MakeTileQuad(rootState, IntRect(IntPoint(200, 100), IntSize(100, 100)), opaqueRect));
- quadList.append(MakeTileQuad(rootState, IntRect(IntPoint(0, 200), IntSize(100, 100)), opaqueRect));
- quadList.append(MakeTileQuad(rootState, IntRect(IntPoint(100, 200), IntSize(100, 100)), opaqueRect));
- quadList.append(MakeTileQuad(rootState, IntRect(IntPoint(200, 200), IntSize(100, 100)), opaqueRect));
-
- quadList.append(MakeTileQuad(childState, IntRect(IntPoint(), IntSize(100, 100)), opaqueRect));
- quadList.append(MakeTileQuad(childState, IntRect(IntPoint(100, 0), IntSize(100, 100)), opaqueRect));
- quadList.append(MakeTileQuad(childState, IntRect(IntPoint(0, 100), IntSize(100, 100)), opaqueRect));
- quadList.append(MakeTileQuad(childState, IntRect(IntPoint(100, 100), IntSize(100, 100)), opaqueRect));
+ CCQuadCuller quadCuller(quadList, layer, &occlusionTracker, &overdraw);
+ OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState();
+ layer->appendQuads(quadCuller, sharedQuadState.get());
}
#define DECLARE_AND_INITIALIZE_TEST_QUADS \
+ DebugScopedSetImplThread impl; \
CCQuadList quadList; \
- CCOverdrawCounts overdraw; \
+ CCOverdrawCounts overdraw; \
TransformationMatrix childTransform; \
IntSize rootSize = IntSize(300, 300); \
IntRect rootRect = IntRect(IntPoint(), rootSize); \
IntSize childSize = IntSize(200, 200); \
IntRect childRect = IntRect(IntPoint(), childSize);
-TEST(CCQuadCullerTest, verifyCullChildLinesUpTopLeft)
+TEST(CCQuadCullerTest, verifyNoCulling)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- setQuads(rootState.get(), childState.get(), quadList);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 130000, 1);
+ EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1);
+ EXPECT_NEAR(overdraw.m_pixelsCulled, 0, 1);
+}
+
+TEST(CCQuadCullerTest, verifyCullChildLinesUpTopLeft)
+{
+ DECLARE_AND_INITIALIZE_TEST_QUADS
+
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
+
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 9u);
EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1);
EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1);
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 0.9, true);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 0.9, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- setQuads(rootState.get(), childState.get(), quadList);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 13u);
EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1);
EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 40000, 1);
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, false);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, false, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- setQuads(rootState.get(), childState.get(), quadList);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 13u);
EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1);
EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 40000, 1);
childTransform.translate(50, 50);
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- setQuads(rootState.get(), childState.get(), quadList);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 12u);
- IntRect quadVisibleRect1 = quadList[1].get()->quadVisibleRect();
+ IntRect quadVisibleRect1 = quadList[5].get()->quadVisibleRect();
EXPECT_EQ(quadVisibleRect1.height(), 50);
- IntRect quadVisibleRect3 = quadList[3].get()->quadVisibleRect();
+ IntRect quadVisibleRect3 = quadList[7].get()->quadVisibleRect();
EXPECT_EQ(quadVisibleRect3.width(), 50);
- // Next index is 4, not 5, since centre quad culled.
- IntRect quadVisibleRect4 = quadList[4].get()->quadVisibleRect();
+ // Next index is 8, not 9, since centre quad culled.
+ IntRect quadVisibleRect4 = quadList[8].get()->quadVisibleRect();
EXPECT_EQ(quadVisibleRect4.width(), 50);
EXPECT_EQ(quadVisibleRect4.x(), 250);
- IntRect quadVisibleRect6 = quadList[6].get()->quadVisibleRect();
+ IntRect quadVisibleRect6 = quadList[10].get()->quadVisibleRect();
EXPECT_EQ(quadVisibleRect6.height(), 50);
EXPECT_EQ(quadVisibleRect6.y(), 250);
childTransform.translate(100, 100);
- // Create root layer tile with extent (99.1, 99.1) -> (200.9, 200.9) to make
+ // Make the root layer's quad have extent (99.1, 99.1) -> (200.9, 200.9) to make
// sure it doesn't get culled due to transform rounding.
TransformationMatrix rootTransform;
rootTransform.translate(99.1, 99.1);
rootTransform.scale(1.018);
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(rootTransform, TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+ rootRect = childRect = IntRect(0, 0, 100, 100);
- quadList.append(MakeTileQuad(rootState.get(), IntRect(IntPoint(), IntSize(100, 100))));
- quadList.append(MakeTileQuad(childState.get(), IntRect(IntPoint(), IntSize(100, 100))));
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(rootTransform, rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- EXPECT_EQ(quadList.size(), 2u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 2u);
EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 20363, 1);
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- // Make the child quad slightly smaller than, and centred over, the root layer tile.
+ // Make the child's quad slightly smaller than, and centred over, the root layer tile.
// Verify the child does not cause the quad below to be culled due to rounding.
childTransform.translate(100.1, 100.1);
childTransform.scale(0.982);
TransformationMatrix rootTransform;
rootTransform.translate(100, 100);
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(rootTransform, TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+ rootRect = childRect = IntRect(0, 0, 100, 100);
- quadList.append(MakeTileQuad(rootState.get(), IntRect(IntPoint(), IntSize(100, 100))));
- quadList.append(MakeTileQuad(childState.get(), IntRect(IntPoint(), IntSize(100, 100))));
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(rootTransform, rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- EXPECT_EQ(quadList.size(), 2u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 2u);
EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 19643, 1);
childTransform.translate(100, 100);
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- setQuads(rootState.get(), childState.get(), quadList);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 9u);
EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1);
EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1);
childTransform.translate(50, 50);
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, false);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2);
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, false, childOpaqueRect);
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 12u);
EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1);
EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 30000, 1);
childTransform.translate(50, 10);
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, false);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() * 3 / 4);
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, false, childOpaqueRect);
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 12u);
EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1);
EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 25000, 1);
childTransform.translate(50, 49);
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, false);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2);
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, false, childOpaqueRect);
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 13u);
+ EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 90000, 1);
+ EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 30000, 1);
+ EXPECT_NEAR(overdraw.m_pixelsCulled, 10000, 1);
}
TEST(CCQuadCullerTest, verifyNonAxisAlignedQuadsDontOcclude)
// Use a small rotation so as to not disturb the geometry significantly.
childTransform.rotate(1);
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- setQuads(rootState.get(), childState.get(), quadList);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 13u);
EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 130000, 1);
EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1);
TransformationMatrix parentTransform;
parentTransform.rotate(1);
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(parentTransform, TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), childRect, IntRect(), 1.0, true);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(parentTransform, rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000));
- setQuads(rootState.get(), childState.get(), quadList);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, false, IntRect(), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 12u);
- EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 120000, 1);
+ EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 100600, 1);
EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1);
- EXPECT_NEAR(overdraw.m_pixelsCulled, 10000, 1);
+ EXPECT_NEAR(overdraw.m_pixelsCulled, 29400, 1);
}
TEST(CCQuadCullerTest, verifyCullOutsideScissorOverTile)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(200, 100, 100, 100));
- setQuads(rootState.get(), childState.get(), quadList);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(200, 100, 100, 100), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 1u);
EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 10000, 1);
EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1);
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(100, 100, 100, 100));
- setQuads(rootState.get(), childState.get(), quadList);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(100, 100, 100, 100), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 1u);
+ EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 10000, 1);
+ EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1);
+ EXPECT_NEAR(overdraw.m_pixelsCulled, 120000, 1);
}
TEST(CCQuadCullerTest, verifyCullOutsideScissorOverPartialTiles)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(50, 50, 200, 200));
- setQuads(rootState.get(), childState.get(), quadList);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(50, 50, 200, 200), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 9u);
+ EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 40000, 1);
+ EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1);
+ EXPECT_NEAR(overdraw.m_pixelsCulled, 90000, 1);
}
TEST(CCQuadCullerTest, verifyCullOutsideScissorOverNoTiles)
{
DECLARE_AND_INITIALIZE_TEST_QUADS
- OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true);
- OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true);
+ OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect());
+ OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect());
+ TestCCOcclusionTrackerImpl occlusionTracker(IntRect(500, 500, 100, 100));
- setQuads(rootState.get(), childState.get(), quadList);
- EXPECT_EQ(quadList.size(), 13u);
- CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(500, 500, 100, 100), &overdraw);
+ appendQuads(quadList, childLayer.get(), occlusionTracker, overdraw);
+ occlusionTracker.markOccludedBehindLayer(childLayer.get());
+ appendQuads(quadList, rootLayer.get(), occlusionTracker, overdraw);
EXPECT_EQ(quadList.size(), 0u);
EXPECT_NEAR(overdraw.m_pixelsDrawnOpaque, 0, 1);
EXPECT_NEAR(overdraw.m_pixelsDrawnTransparent, 0, 1);
EXPECT_NEAR(overdraw.m_pixelsCulled, 130000, 1);
}
-
} // namespace