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

Side by Side Diff: webkit/compositor_bindings/web_layer_impl_fixed_bounds_unittest.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer_tree_host_common.h" 5 #include "cc/layer_tree_host_common.h"
6 #include "cc/picture_image_layer.h" 6 #include "cc/picture_image_layer.h"
7 #include "cc/test/geometry_test_utils.h" 7 #include "cc/test/geometry_test_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 gfx::Point3F scaled_point( 48 gfx::Point3F scaled_point(
49 original_point.x() * bounds.width / fixed_bounds.width(), 49 original_point.x() * bounds.width / fixed_bounds.width(),
50 original_point.y() * bounds.height / fixed_bounds.height(), 50 original_point.y() * bounds.height / fixed_bounds.height(),
51 original_point.z()); 51 original_point.z());
52 // Test if the bounds scale is correctly applied in transform and 52 // Test if the bounds scale is correctly applied in transform and
53 // sublayerTransform. 53 // sublayerTransform.
54 EXPECT_POINT3F_EQ(scaled_point, 54 EXPECT_POINT3F_EQ(scaled_point,
55 TransformPoint(layer->layer()->transform(), 55 TransformPoint(layer->layer()->transform(),
56 original_point)); 56 original_point));
57 EXPECT_POINT3F_EQ(original_point, 57 EXPECT_POINT3F_EQ(original_point,
58 TransformPoint(layer->layer()->sublayerTransform(), 58 TransformPoint(layer->layer()->sublayer_transform(),
59 scaled_point)); 59 scaled_point));
60 } 60 }
61 61
62 TEST(WebLayerImplFixedBoundsTest, BoundsScaleSimple) { 62 TEST(WebLayerImplFixedBoundsTest, BoundsScaleSimple) {
63 scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds()); 63 scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds());
64 layer->setAnchorPoint(WebFloatPoint(0, 0)); 64 layer->setAnchorPoint(WebFloatPoint(0, 0));
65 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(150, 250)); 65 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(150, 250));
66 // Change fixed_bounds. 66 // Change fixed_bounds.
67 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(75, 100)); 67 CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(75, 100));
68 // Change bounds. 68 // Change bounds.
69 CheckBoundsScaleSimple(layer.get(), WebSize(300, 100), gfx::Size(75, 100)); 69 CheckBoundsScaleSimple(layer.get(), WebSize(300, 100), gfx::Size(75, 100));
70 } 70 }
71 71
72 void ExpectEqualLayerRectsInTarget(cc::Layer* layer1, cc::Layer* layer2) { 72 void ExpectEqualLayerRectsInTarget(cc::Layer* layer1, cc::Layer* layer2) {
73 gfx::RectF layer1_rect_in_target(layer1->contentBounds()); 73 gfx::RectF layer1_rect_in_target(layer1->content_bounds());
74 layer1->drawTransform().TransformRect(&layer1_rect_in_target); 74 layer1->draw_transform().TransformRect(&layer1_rect_in_target);
75 75
76 gfx::RectF layer2_rect_in_target(layer2->contentBounds()); 76 gfx::RectF layer2_rect_in_target(layer2->content_bounds());
77 layer2->drawTransform().TransformRect(&layer2_rect_in_target); 77 layer2->draw_transform().TransformRect(&layer2_rect_in_target);
78 78
79 EXPECT_FLOAT_RECT_EQ(layer1_rect_in_target, layer2_rect_in_target); 79 EXPECT_FLOAT_RECT_EQ(layer1_rect_in_target, layer2_rect_in_target);
80 } 80 }
81 81
82 void CompareFixedBoundsLayerAndNormalLayer( 82 void CompareFixedBoundsLayerAndNormalLayer(
83 const WebFloatPoint& anchor_point, 83 const WebFloatPoint& anchor_point,
84 const gfx::Transform& transform, 84 const gfx::Transform& transform,
85 const gfx::Transform& sublayer_transform) { 85 const gfx::Transform& sublayer_transform) {
86 const gfx::Size kDeviceViewportSize(800, 600); 86 const gfx::Size kDeviceViewportSize(800, 600);
87 const float kDeviceScaleFactor = 2.f; 87 const float kDeviceScaleFactor = 2.f;
88 const float kPageScaleFactor = 1.5f; 88 const float kPageScaleFactor = 1.5f;
89 const int kMaxTextureSize = 512; 89 const int kMaxTextureSize = 512;
90 90
91 WebSize bounds(150, 200); 91 WebSize bounds(150, 200);
92 WebFloatPoint position(20, 30); 92 WebFloatPoint position(20, 30);
93 WebSize sublayer_bounds(88, 99); 93 WebSize sublayer_bounds(88, 99);
94 WebFloatPoint sublayer_position(50, 60); 94 WebFloatPoint sublayer_position(50, 60);
95 gfx::Size fixed_bounds(160, 70); 95 gfx::Size fixed_bounds(160, 70);
96 96
97 scoped_ptr<WebLayerImplFixedBounds> root_layer(new WebLayerImplFixedBounds()); 97 scoped_ptr<WebLayerImplFixedBounds> root_layer(new WebLayerImplFixedBounds());
98 98
99 WebLayerImplFixedBounds* fixed_bounds_layer = 99 WebLayerImplFixedBounds* fixed_bounds_layer =
100 new WebLayerImplFixedBounds(cc::PictureImageLayer::create()); 100 new WebLayerImplFixedBounds(cc::PictureImageLayer::Create());
101 WebLayerImpl* sublayer_under_fixed_bounds_layer = new WebLayerImpl(); 101 WebLayerImpl* sublayer_under_fixed_bounds_layer = new WebLayerImpl();
102 sublayer_under_fixed_bounds_layer->setBounds(sublayer_bounds); 102 sublayer_under_fixed_bounds_layer->setBounds(sublayer_bounds);
103 sublayer_under_fixed_bounds_layer->setPosition(sublayer_position); 103 sublayer_under_fixed_bounds_layer->setPosition(sublayer_position);
104 fixed_bounds_layer->addChild(sublayer_under_fixed_bounds_layer); 104 fixed_bounds_layer->addChild(sublayer_under_fixed_bounds_layer);
105 fixed_bounds_layer->setBounds(bounds); 105 fixed_bounds_layer->setBounds(bounds);
106 fixed_bounds_layer->SetFixedBounds(fixed_bounds); 106 fixed_bounds_layer->SetFixedBounds(fixed_bounds);
107 fixed_bounds_layer->setAnchorPoint(anchor_point); 107 fixed_bounds_layer->setAnchorPoint(anchor_point);
108 fixed_bounds_layer->setTransform(transform.matrix()); 108 fixed_bounds_layer->setTransform(transform.matrix());
109 fixed_bounds_layer->setSublayerTransform(sublayer_transform.matrix()); 109 fixed_bounds_layer->setSublayerTransform(sublayer_transform.matrix());
110 fixed_bounds_layer->setPosition(position); 110 fixed_bounds_layer->setPosition(position);
111 root_layer->addChild(fixed_bounds_layer); 111 root_layer->addChild(fixed_bounds_layer);
112 112
113 WebLayerImpl* normal_layer(new WebLayerImpl(cc::PictureImageLayer::create())); 113 WebLayerImpl* normal_layer(new WebLayerImpl(cc::PictureImageLayer::Create()));
114 WebLayerImpl* sublayer_under_normal_layer = new WebLayerImpl(); 114 WebLayerImpl* sublayer_under_normal_layer = new WebLayerImpl();
115 sublayer_under_normal_layer->setBounds(sublayer_bounds); 115 sublayer_under_normal_layer->setBounds(sublayer_bounds);
116 sublayer_under_normal_layer->setPosition(sublayer_position); 116 sublayer_under_normal_layer->setPosition(sublayer_position);
117 117
118 normal_layer->addChild(sublayer_under_normal_layer); 118 normal_layer->addChild(sublayer_under_normal_layer);
119 normal_layer->setBounds(bounds); 119 normal_layer->setBounds(bounds);
120 normal_layer->setAnchorPoint(anchor_point); 120 normal_layer->setAnchorPoint(anchor_point);
121 normal_layer->setTransform(transform.matrix()); 121 normal_layer->setTransform(transform.matrix());
122 normal_layer->setSublayerTransform(sublayer_transform.matrix()); 122 normal_layer->setSublayerTransform(sublayer_transform.matrix());
123 normal_layer->setPosition(position); 123 normal_layer->setPosition(position);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0), 181 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0),
182 transform, 182 transform,
183 sublayer_transform); 183 sublayer_transform);
184 184
185 // With non-zero anchor point, WebLayerImplFixedBounds will fall back to 185 // With non-zero anchor point, WebLayerImplFixedBounds will fall back to
186 // WebLayerImpl. 186 // WebLayerImpl.
187 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0.4f, 0.6f), 187 CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0.4f, 0.6f),
188 transform, 188 transform,
189 sublayer_transform); 189 sublayer_transform);
190 } 190 }
OLDNEW
« no previous file with comments | « webkit/compositor_bindings/web_layer_impl_fixed_bounds.cc ('k') | webkit/compositor_bindings/web_nine_patch_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698