summaryrefslogtreecommitdiffstats
path: root/cc/test/layer_test_common.cc
diff options
context:
space:
mode:
authorshawnsingh@chromium.org <shawnsingh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-29 19:57:15 +0000
committershawnsingh@chromium.org <shawnsingh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-29 19:57:15 +0000
commit94eda1ea7cdbf9f38492feae55469abb751bf2aa (patch)
tree1f8773fe3112e738c7861c7b0b47c9a9453e590c /cc/test/layer_test_common.cc
parent4a5aac2a38a17827162ccceb87be77ca3a7b9da9 (diff)
downloadchromium_src-94eda1ea7cdbf9f38492feae55469abb751bf2aa.zip
chromium_src-94eda1ea7cdbf9f38492feae55469abb751bf2aa.tar.gz
chromium_src-94eda1ea7cdbf9f38492feae55469abb751bf2aa.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/11017044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164723 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test/layer_test_common.cc')
-rw-r--r--cc/test/layer_test_common.cc25
1 files changed, 24 insertions, 1 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;