summaryrefslogtreecommitdiffstats
path: root/cc/test
diff options
context:
space:
mode:
authorshawnsingh@chromium.org <shawnsingh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-30 20:45:42 +0000
committershawnsingh@chromium.org <shawnsingh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-30 20:45:42 +0000
commitecc12621a9594424a2ea7347b13e71888fd3c308 (patch)
tree95ce5ab9b1bb67056474b05cb005414749a30ea2 /cc/test
parent45c5a2068dbd71f7e5510ed5a2ca7b89489585cb (diff)
downloadchromium_src-ecc12621a9594424a2ea7347b13e71888fd3c308.zip
chromium_src-ecc12621a9594424a2ea7347b13e71888fd3c308.tar.gz
chromium_src-ecc12621a9594424a2ea7347b13e71888fd3c308.tar.bz2
Remove root layer specialness in calculateDrawTransforms
This patch is step 2 in removing root layer specialness. The previous patch removed root layer specialness from code outside of CCLayerTreeHostCommon, this patch removes it from within CCLayerTreeHostCommon. One subtle semantics change occurs with this patch, that only affects tests and not real-world code: The root renderSurface now re-parents the root layer's drawTransform. In practice, the root layer's drawTransform is always an identity matrix, so it does not matter. BUG=154442 Review URL: https://chromiumcodereview.appspot.com/11276061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165000 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test')
-rw-r--r--cc/test/layer_test_common.cc25
-rw-r--r--cc/test/layer_tree_test_common.cc10
-rw-r--r--cc/test/layer_tree_test_common.h4
3 files changed, 31 insertions, 8 deletions
diff --git a/cc/test/layer_test_common.cc b/cc/test/layer_test_common.cc
index 1a41eec..72546dd 100644
--- a/cc/test/layer_test_common.cc
+++ b/cc/test/layer_test_common.cc
@@ -7,6 +7,7 @@
#include "cc/test/layer_test_common.h"
#include "cc/draw_quad.h"
+#include "cc/math_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace LayerTestCommon {
@@ -14,13 +15,35 @@ namespace LayerTestCommon {
// Align with expected and actual output
const char* quadString = " Quad: ";
+bool floatRectCanBeSafelyRoundedToIntRect(const cc::FloatRect& r)
+{
+ // Ensure that range of float values is not beyond integer range.
+ if (!r.isExpressibleAsIntRect())
+ return false;
+
+ // Ensure that the values are actually integers.
+ if (floorf(r.x()) == r.x()
+ && floorf(r.y()) == r.y()
+ && floorf(r.width()) == r.width()
+ && floorf(r.height()) == r.height())
+ return true;
+
+ return false;
+}
+
void verifyQuadsExactlyCoverRect(const cc::QuadList& quads,
const cc::IntRect& rect) {
cc::Region remaining(rect);
for (size_t i = 0; i < quads.size(); ++i) {
cc::DrawQuad* quad = quads[i];
- cc::IntRect quadRect = cc::IntRect(quad->quadRect());
+ cc::FloatRect floatQuadRect = cc::MathUtil::mapClippedRect(quad->sharedQuadState()->quadTransform, cc::FloatRect(quad->quadRect()));
+
+ // Before testing for exact coverage in the integer world, assert that rounding
+ // will not round the rect incorrectly.
+ ASSERT_TRUE(floatRectCanBeSafelyRoundedToIntRect(floatQuadRect));
+
+ cc::IntRect quadRect = enclosingIntRect(floatQuadRect);
EXPECT_TRUE(rect.contains(quadRect)) << quadString << i;
EXPECT_TRUE(remaining.contains(quadRect)) << quadString << i;
diff --git a/cc/test/layer_tree_test_common.cc b/cc/test/layer_tree_test_common.cc
index 2bb5d41..0d77c67 100644
--- a/cc/test/layer_tree_test_common.cc
+++ b/cc/test/layer_tree_test_common.cc
@@ -350,9 +350,9 @@ void ThreadedTest::postSetNeedsAnimateToMainThread()
m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchSetNeedsAnimate));
}
-void ThreadedTest::postAddAnimationToMainThread()
+void ThreadedTest::postAddAnimationToMainThread(Layer* layerToReceiveAnimation)
{
- m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchAddAnimation));
+ m_mainThreadProxy->postTask(createThreadTask(this, &ThreadedTest::dispatchAddAnimation, layerToReceiveAnimation));
}
void ThreadedTest::postAddInstantAnimationToMainThread()
@@ -456,15 +456,15 @@ void ThreadedTest::dispatchAddInstantAnimation()
addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 0, 0, 0.5, false);
}
-void ThreadedTest::dispatchAddAnimation()
+void ThreadedTest::dispatchAddAnimation(Layer* layerToReceiveAnimation)
{
DCHECK(Proxy::isMainThread());
if (m_finished)
return;
- if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer())
- addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 10, 0, 0.5, true);
+ if (layerToReceiveAnimation)
+ addOpacityTransitionToLayer(*layerToReceiveAnimation, 10, 0, 0.5, true);
}
void ThreadedTest::dispatchSetNeedsAnimateAndCommit()
diff --git a/cc/test/layer_tree_test_common.h b/cc/test/layer_tree_test_common.h
index 10f35ca..c8d1c36 100644
--- a/cc/test/layer_tree_test_common.h
+++ b/cc/test/layer_tree_test_common.h
@@ -77,7 +77,7 @@ public:
void endTestAfterDelay(int delayMilliseconds);
void postSetNeedsAnimateToMainThread();
- void postAddAnimationToMainThread();
+ void postAddAnimationToMainThread(cc::Layer*);
void postAddInstantAnimationToMainThread();
void postSetNeedsCommitToMainThread();
void postAcquireLayerTextures();
@@ -104,7 +104,7 @@ protected:
void dispatchSetNeedsAnimate();
void dispatchAddInstantAnimation();
- void dispatchAddAnimation();
+ void dispatchAddAnimation(cc::Layer*);
void dispatchSetNeedsAnimateAndCommit();
void dispatchSetNeedsCommit();
void dispatchAcquireLayerTextures();