Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(693)

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp

Issue 2745563004: Reduce copying of local data structures in GeometryMapper and PaintLayerClipper. (Closed)
Patch Set: none Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/GeometryMapper.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp b/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp
index c1375c5bf31c7296d1a499fee25528e506d0153d..7c44f7b1c2c3b125fd45a24665f38b68954e5cba 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/GeometryMapperTest.cpp
@@ -53,35 +53,30 @@ class GeometryMapperTest : public ::testing::Test,
return GeometryMapper::lowestCommonAncestor(a, b);
}
- FloatRect sourceToDestinationVisualRectInternal(
- const FloatRect& rect,
+ void sourceToDestinationVisualRectInternal(
const PropertyTreeState& sourceState,
const PropertyTreeState& destinationState,
+ FloatRect& mappingRect,
bool& success) {
- return geometryMapper
- ->localToAncestorVisualRectInternal(rect, sourceState, destinationState,
- success)
- .rect();
+ geometryMapper->localToAncestorVisualRectInternal(
+ sourceState, destinationState, mappingRect, success);
}
- FloatRect localToAncestorVisualRectInternal(
- const FloatRect& rect,
- const PropertyTreeState& localState,
- const PropertyTreeState& ancestorState,
- bool& success) {
- return geometryMapper
- ->localToAncestorVisualRectInternal(rect, localState, ancestorState,
- success)
- .rect();
+ void localToAncestorVisualRectInternal(const PropertyTreeState& localState,
+ const PropertyTreeState& ancestorState,
+ FloatRect& mappingRect,
+ bool& success) {
+ geometryMapper->localToAncestorVisualRectInternal(localState, ancestorState,
+ mappingRect, success);
}
- FloatRect localToAncestorRectInternal(
- const FloatRect& rect,
+ void localToAncestorRectInternal(
const TransformPaintPropertyNode* localTransformNode,
const TransformPaintPropertyNode* ancestorTransformNode,
+ FloatRect& rect,
bool& success) {
- return geometryMapper->localToAncestorRectInternal(
- rect, localTransformNode, ancestorTransformNode, success);
+ geometryMapper->localToAncestorRectInternal(
+ localTransformNode, ancestorTransformNode, rect, success);
}
private:
@@ -123,26 +118,29 @@ const static float kTestEpsilon = 1e-6;
expectedClipInAncestorSpace, localPropertyTreeState, \
ancestorPropertyTreeState, hasRadius) \
do { \
- FloatClipRect clipRect = geometryMapper->localToAncestorVisualRect( \
- inputRect, localPropertyTreeState, ancestorPropertyTreeState); \
- EXPECT_EQ(hasRadius, clipRect.hasRadius()); \
- EXPECT_RECT_EQ(expectedVisualRect, clipRect.rect()); \
- clipRect = geometryMapper->localToAncestorClipRect( \
+ FloatRect floatRect = inputRect; \
+ geometryMapper->localToAncestorVisualRect( \
+ localPropertyTreeState, ancestorPropertyTreeState, floatRect); \
+ EXPECT_RECT_EQ(expectedVisualRect, floatRect); \
+ FloatClipRect floatClipRect; \
+ floatClipRect = geometryMapper->localToAncestorClipRect( \
localPropertyTreeState, ancestorPropertyTreeState); \
- EXPECT_EQ(hasRadius, clipRect.hasRadius()); \
- EXPECT_CLIP_RECT_EQ(expectedClipInAncestorSpace, clipRect); \
- clipRect = geometryMapper->sourceToDestinationVisualRect( \
- inputRect, localPropertyTreeState, ancestorPropertyTreeState); \
- EXPECT_EQ(hasRadius, clipRect.hasRadius()); \
- EXPECT_RECT_EQ(expectedVisualRect, clipRect.rect()); \
- EXPECT_RECT_EQ(expectedTransformedRect, \
- geometryMapper->localToAncestorRect( \
- inputRect, localPropertyTreeState.transform(), \
- ancestorPropertyTreeState.transform())); \
- EXPECT_RECT_EQ(expectedTransformedRect, \
- geometryMapper->sourceToDestinationRect( \
- inputRect, localPropertyTreeState.transform(), \
- ancestorPropertyTreeState.transform())); \
+ EXPECT_EQ(hasRadius, floatClipRect.hasRadius()); \
+ EXPECT_CLIP_RECT_EQ(expectedClipInAncestorSpace, floatClipRect); \
+ floatRect = inputRect; \
+ geometryMapper->sourceToDestinationVisualRect( \
+ localPropertyTreeState, ancestorPropertyTreeState, floatRect); \
+ EXPECT_RECT_EQ(expectedVisualRect, floatRect); \
+ FloatRect testMappedRect = inputRect; \
+ geometryMapper->localToAncestorRect(localPropertyTreeState.transform(), \
+ ancestorPropertyTreeState.transform(), \
+ testMappedRect); \
+ EXPECT_RECT_EQ(expectedTransformedRect, testMappedRect); \
+ testMappedRect = inputRect; \
+ geometryMapper->sourceToDestinationRect( \
+ localPropertyTreeState.transform(), \
+ ancestorPropertyTreeState.transform(), testMappedRect); \
+ EXPECT_RECT_EQ(expectedTransformedRect, testMappedRect); \
if (ancestorPropertyTreeState.transform() != \
localPropertyTreeState.transform()) { \
const TransformationMatrix* transformForTesting = \
@@ -156,8 +154,11 @@ const static float kTestEpsilon = 1e-6;
getClip(localPropertyTreeState.clip(), ancestorPropertyTreeState); \
DCHECK(outputClipForTesting); \
EXPECT_EQ(expectedClipInAncestorSpace, *outputClipForTesting) \
- << expectedClipInAncestorSpace.rect().toString() << " " \
- << outputClipForTesting->rect().toString(); \
+ << "expected: " << expectedClipInAncestorSpace.rect().toString() \
+ << " (hasRadius: " << expectedClipInAncestorSpace.hasRadius() \
+ << ") " \
+ << "actual: " << outputClipForTesting->rect().toString() \
+ << " (hasRadius: " << outputClipForTesting->hasRadius() << ")"; \
} \
} while (false)
@@ -201,9 +202,9 @@ TEST_F(GeometryMapperTest, TranslationTransform) {
CHECK_MAPPINGS(input, output, output, transform->matrix(), FloatClipRect(),
localState, rootPropertyTreeState(), hasRadius);
- EXPECT_RECT_EQ(input, geometryMapper->ancestorToLocalRect(
- output, rootPropertyTreeState().transform(),
- localState.transform()));
+ geometryMapper->ancestorToLocalRect(rootPropertyTreeState().transform(),
+ localState.transform(), output);
+ EXPECT_RECT_EQ(input, output);
}
TEST_F(GeometryMapperTest, RotationAndScaleTransform) {
@@ -420,7 +421,8 @@ TEST_F(GeometryMapperTest, TwoClips) {
ancestorState.setClip(clip1.get());
FloatRect output2(10, 10, 50, 50);
- clipRect.setRect(clip2->clipRect().rect());
+ FloatClipRect clipRect2;
+ clipRect2.setRect(clip2->clipRect().rect());
chrishtr 2017/03/10 01:46:23 Somehow I fixed a bug in this CL - previously it w
hasRadius = false;
CHECK_MAPPINGS(input, // Input
@@ -428,9 +430,8 @@ TEST_F(GeometryMapperTest, TwoClips) {
input, // Transformed rect (not clipped).
TransformPaintPropertyNode::root()
->matrix(), // Transform matrix to ancestor space
- clipRect, // Clip rect in ancestor space
- localState,
- ancestorState, hasRadius);
+ clipRect2, // Clip rect in ancestor space
+ localState, ancestorState, hasRadius);
}
TEST_F(GeometryMapperTest, TwoClipsTransformAbove) {
@@ -629,40 +630,44 @@ TEST_F(GeometryMapperTest, SiblingTransforms) {
bool success;
FloatRect input(0, 0, 100, 100);
- FloatRect result = localToAncestorVisualRectInternal(
- input, transform1State, transform2State, success);
+ FloatRect result = input;
+ localToAncestorVisualRectInternal(transform1State, transform2State, result,
+ success);
// Fails, because the transform2state is not an ancestor of transform1State.
EXPECT_FALSE(success);
EXPECT_RECT_EQ(input, result);
- result = localToAncestorRectInternal(input, transform1.get(),
- transform2.get(), success);
+ result = input;
+ localToAncestorRectInternal(transform1.get(), transform2.get(), result,
+ success);
// Fails, because the transform2state is not an ancestor of transform1State.
EXPECT_FALSE(success);
EXPECT_RECT_EQ(input, result);
- result = localToAncestorVisualRectInternal(input, transform2State,
- transform1State, success);
+ result = input;
+ localToAncestorVisualRectInternal(transform2State, transform1State, result,
+ success);
// Fails, because the transform1state is not an ancestor of transform2State.
EXPECT_FALSE(success);
EXPECT_RECT_EQ(input, result);
- result = localToAncestorRectInternal(input, transform2.get(),
- transform1.get(), success);
+ result = input;
+ localToAncestorRectInternal(transform2.get(), transform1.get(), result,
+ success);
// Fails, because the transform1state is not an ancestor of transform2State.
EXPECT_FALSE(success);
EXPECT_RECT_EQ(input, result);
FloatRect expected =
rotateTransform2.inverse().mapRect(rotateTransform1.mapRect(input));
- result = geometryMapper
- ->sourceToDestinationVisualRect(input, transform1State,
- transform2State)
- .rect();
+ result = input;
+ geometryMapper->sourceToDestinationVisualRect(transform1State,
+ transform2State, result);
EXPECT_RECT_EQ(expected, result);
- result = geometryMapper->sourceToDestinationRect(input, transform1.get(),
- transform2.get());
+ result = input;
+ geometryMapper->sourceToDestinationRect(transform1.get(), transform2.get(),
+ result);
EXPECT_RECT_EQ(expected, result);
}
@@ -700,15 +705,17 @@ TEST_F(GeometryMapperTest, SiblingTransformsWithClip) {
// sourceToDestinationVisualRect ignores clip from the common ancestor to
// destination.
- FloatRect result = sourceToDestinationVisualRectInternal(
- input, transform1State, transform2AndClipState, success);
+ FloatRect result = input;
+ sourceToDestinationVisualRectInternal(transform1State, transform2AndClipState,
+ result, success);
// Fails, because the clip of the destination state is not an ancestor of the
// clip of the source state.
EXPECT_FALSE(success);
// sourceToDestinationRect applies transforms only.
- result = geometryMapper->sourceToDestinationRect(input, transform1.get(),
- transform2.get());
+ result = input;
+ geometryMapper->sourceToDestinationRect(transform1.get(), transform2.get(),
+ result);
EXPECT_RECT_EQ(expected, result);
// Test map from transform2AndClipState to transform1State.
@@ -719,15 +726,15 @@ TEST_F(GeometryMapperTest, SiblingTransformsWithClip) {
// sourceToDestinationVisualRect ignores clip from the common ancestor to
// destination.
- result = geometryMapper
- ->sourceToDestinationVisualRect(input, transform2AndClipState,
- transform1State)
- .rect();
+ result = input;
+ geometryMapper->sourceToDestinationVisualRect(transform2AndClipState,
+ transform1State, result);
EXPECT_RECT_EQ(expectedClipped, result);
// sourceToDestinationRect applies transforms only.
- result = geometryMapper->sourceToDestinationRect(input, transform2.get(),
- transform1.get());
+ result = input;
+ geometryMapper->sourceToDestinationRect(transform2.get(), transform1.get(),
+ result);
EXPECT_RECT_EQ(expectedUnclipped, result);
}
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/GeometryMapper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698