| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 | 6 |
| 7 #include "cc/content_layer.h" | 7 #include "cc/content_layer.h" |
| 8 #include "cc/content_layer_client.h" | 8 #include "cc/content_layer_client.h" |
| 9 #include "cc/heads_up_display_layer_impl.h" | 9 #include "cc/heads_up_display_layer_impl.h" |
| 10 #include "cc/layer.h" | 10 #include "cc/layer.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "ui/gfx/quad_f.h" | 24 #include "ui/gfx/quad_f.h" |
| 25 #include "ui/gfx/size_conversions.h" | 25 #include "ui/gfx/size_conversions.h" |
| 26 #include "ui/gfx/transform.h" | 26 #include "ui/gfx/transform.h" |
| 27 | 27 |
| 28 namespace cc { | 28 namespace cc { |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 template<typename LayerType> | 31 template<typename LayerType> |
| 32 void setLayerPropertiesForTestingInternal(LayerType* layer, const gfx::Transform
& transform, const gfx::Transform& sublayerTransform, const gfx::PointF& anchor,
const gfx::PointF& position, const gfx::Size& bounds, bool preserves3D) | 32 void setLayerPropertiesForTestingInternal(LayerType* layer, const gfx::Transform
& transform, const gfx::Transform& sublayerTransform, const gfx::PointF& anchor,
const gfx::PointF& position, const gfx::Size& bounds, bool preserves3D) |
| 33 { | 33 { |
| 34 layer->setTransform(transform); | 34 layer->SetTransform(transform); |
| 35 layer->setSublayerTransform(sublayerTransform); | 35 layer->SetSublayerTransform(sublayerTransform); |
| 36 layer->setAnchorPoint(anchor); | 36 layer->SetAnchorPoint(anchor); |
| 37 layer->setPosition(position); | 37 layer->SetPosition(position); |
| 38 layer->setBounds(bounds); | 38 layer->SetBounds(bounds); |
| 39 layer->setPreserves3D(preserves3D); | 39 layer->SetPreserves3d(preserves3D); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void setLayerPropertiesForTesting(Layer* layer, const gfx::Transform& transform,
const gfx::Transform& sublayerTransform, const gfx::PointF& anchor, const gfx::
PointF& position, const gfx::Size& bounds, bool preserves3D) | 42 void setLayerPropertiesForTesting(Layer* layer, const gfx::Transform& transform,
const gfx::Transform& sublayerTransform, const gfx::PointF& anchor, const gfx::
PointF& position, const gfx::Size& bounds, bool preserves3D) |
| 43 { | 43 { |
| 44 setLayerPropertiesForTestingInternal<Layer>(layer, transform, sublayerTransf
orm, anchor, position, bounds, preserves3D); | 44 setLayerPropertiesForTestingInternal<Layer>(layer, transform, sublayerTransf
orm, anchor, position, bounds, preserves3D); |
| 45 layer->setAutomaticallyComputeRasterScale(true); | 45 layer->SetAutomaticallyComputeRasterScale(true); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void setLayerPropertiesForTesting(LayerImpl* layer, const gfx::Transform& transf
orm, const gfx::Transform& sublayerTransform, const gfx::PointF& anchor, const g
fx::PointF& position, const gfx::Size& bounds, bool preserves3D) | 48 void setLayerPropertiesForTesting(LayerImpl* layer, const gfx::Transform& transf
orm, const gfx::Transform& sublayerTransform, const gfx::PointF& anchor, const g
fx::PointF& position, const gfx::Size& bounds, bool preserves3D) |
| 49 { | 49 { |
| 50 setLayerPropertiesForTestingInternal<LayerImpl>(layer, transform, sublayerTr
ansform, anchor, position, bounds, preserves3D); | 50 setLayerPropertiesForTestingInternal<LayerImpl>(layer, transform, sublayerTr
ansform, anchor, position, bounds, preserves3D); |
| 51 layer->setContentBounds(bounds); | 51 layer->SetContentBounds(bounds); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void executeCalculateDrawProperties(Layer* rootLayer, float deviceScaleFactor =
1, float pageScaleFactor = 1, bool canUseLCDText = false) | 54 void executeCalculateDrawProperties(Layer* rootLayer, float deviceScaleFactor =
1, float pageScaleFactor = 1, bool canUseLCDText = false) |
| 55 { | 55 { |
| 56 gfx::Transform identityMatrix; | 56 gfx::Transform identityMatrix; |
| 57 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; | 57 std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList; |
| 58 int dummyMaxTextureSize = 512; | 58 int dummyMaxTextureSize = 512; |
| 59 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); | 59 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); |
| 60 | 60 |
| 61 // We are probably not testing what is intended if the rootLayer bounds are
empty. | 61 // We are probably not testing what is intended if the rootLayer bounds are
empty. |
| 62 DCHECK(!rootLayer->bounds().IsEmpty()); | 62 DCHECK(!rootLayer->bounds().IsEmpty()); |
| 63 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRen
derSurfaceLayerList); | 63 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRen
derSurfaceLayerList); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void executeCalculateDrawProperties(LayerImpl* rootLayer, float deviceScaleFacto
r = 1, float pageScaleFactor = 1, bool canUseLCDText = false) | 66 void executeCalculateDrawProperties(LayerImpl* rootLayer, float deviceScaleFacto
r = 1, float pageScaleFactor = 1, bool canUseLCDText = false) |
| 67 { | 67 { |
| 68 gfx::Transform identityMatrix; | 68 gfx::Transform identityMatrix; |
| 69 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; | 69 std::vector<LayerImpl*> dummyRenderSurfaceLayerList; |
| 70 int dummyMaxTextureSize = 512; | 70 int dummyMaxTextureSize = 512; |
| 71 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); | 71 gfx::Size deviceViewportSize = gfx::Size(rootLayer->bounds().width() * devic
eScaleFactor, rootLayer->bounds().height() * deviceScaleFactor); |
| 72 | 72 |
| 73 // We are probably not testing what is intended if the rootLayer bounds are
empty. | 73 // We are probably not testing what is intended if the rootLayer bounds are
empty. |
| 74 DCHECK(!rootLayer->bounds().IsEmpty()); | 74 DCHECK(!rootLayer->bounds().IsEmpty()); |
| 75 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRen
derSurfaceLayerList, false); | 75 LayerTreeHostCommon::calculateDrawProperties(rootLayer, deviceViewportSize,
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRen
derSurfaceLayerList, false); |
| 76 } | 76 } |
| 77 | 77 |
| 78 scoped_ptr<LayerImpl> createTreeForFixedPositionTests(LayerTreeHostImpl* hostImp
l) | 78 scoped_ptr<LayerImpl> createTreeForFixedPositionTests(LayerTreeHostImpl* hostImp
l) |
| 79 { | 79 { |
| 80 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl->activeTree(), 1); | 80 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl->activeTree(), 1); |
| 81 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl->activeTree(), 2); | 81 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl->activeTree(), 2); |
| 82 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(hostImpl->activeTree(),
3); | 82 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(hostImpl->activeTree(),
3); |
| 83 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::create(hostImpl->activeTr
ee(), 4); | 83 scoped_ptr<LayerImpl> greatGrandChild = LayerImpl::Create(hostImpl->activeTr
ee(), 4); |
| 84 | 84 |
| 85 gfx::Transform IdentityMatrix; | 85 gfx::Transform IdentityMatrix; |
| 86 gfx::PointF anchor(0, 0); | 86 gfx::PointF anchor(0, 0); |
| 87 gfx::PointF position(0, 0); | 87 gfx::PointF position(0, 0); |
| 88 gfx::Size bounds(100, 100); | 88 gfx::Size bounds(100, 100); |
| 89 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc
hor, position, bounds, false); | 89 setLayerPropertiesForTesting(root.get(), IdentityMatrix, IdentityMatrix, anc
hor, position, bounds, false); |
| 90 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an
chor, position, bounds, false); | 90 setLayerPropertiesForTesting(child.get(), IdentityMatrix, IdentityMatrix, an
chor, position, bounds, false); |
| 91 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri
x, anchor, position, bounds, false); | 91 setLayerPropertiesForTesting(grandChild.get(), IdentityMatrix, IdentityMatri
x, anchor, position, bounds, false); |
| 92 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity
Matrix, anchor, position, bounds, false); | 92 setLayerPropertiesForTesting(greatGrandChild.get(), IdentityMatrix, Identity
Matrix, anchor, position, bounds, false); |
| 93 | 93 |
| 94 grandChild->addChild(greatGrandChild.Pass()); | 94 grandChild->AddChild(greatGrandChild.Pass()); |
| 95 child->addChild(grandChild.Pass()); | 95 child->AddChild(grandChild.Pass()); |
| 96 root->addChild(child.Pass()); | 96 root->AddChild(child.Pass()); |
| 97 | 97 |
| 98 return root.Pass(); | 98 return root.Pass(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 class LayerWithForcedDrawsContent : public Layer { | 101 class LayerWithForcedDrawsContent : public Layer { |
| 102 public: | 102 public: |
| 103 LayerWithForcedDrawsContent() | 103 LayerWithForcedDrawsContent() |
| 104 : Layer() | 104 : Layer() |
| 105 { | 105 { |
| 106 } | 106 } |
| 107 | 107 |
| 108 virtual bool drawsContent() const OVERRIDE; | 108 virtual bool DrawsContent() const OVERRIDE; |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 virtual ~LayerWithForcedDrawsContent() | 111 virtual ~LayerWithForcedDrawsContent() |
| 112 { | 112 { |
| 113 } | 113 } |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 class LayerCanClipSelf : public Layer { | 116 class LayerCanClipSelf : public Layer { |
| 117 public: | 117 public: |
| 118 LayerCanClipSelf() | 118 LayerCanClipSelf() |
| 119 : Layer() | 119 : Layer() |
| 120 { | 120 { |
| 121 } | 121 } |
| 122 | 122 |
| 123 virtual bool drawsContent() const OVERRIDE; | 123 virtual bool DrawsContent() const OVERRIDE; |
| 124 virtual bool canClipSelf() const OVERRIDE; | 124 virtual bool CanClipSelf() const OVERRIDE; |
| 125 | 125 |
| 126 private: | 126 private: |
| 127 virtual ~LayerCanClipSelf() | 127 virtual ~LayerCanClipSelf() |
| 128 { | 128 { |
| 129 } | 129 } |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 bool LayerWithForcedDrawsContent::drawsContent() const | 132 bool LayerWithForcedDrawsContent::DrawsContent() const |
| 133 { | 133 { |
| 134 return true; | 134 return true; |
| 135 } | 135 } |
| 136 | 136 |
| 137 bool LayerCanClipSelf::drawsContent() const | 137 bool LayerCanClipSelf::DrawsContent() const |
| 138 { | 138 { |
| 139 return true; | 139 return true; |
| 140 } | 140 } |
| 141 | 141 |
| 142 bool LayerCanClipSelf::canClipSelf() const | 142 bool LayerCanClipSelf::CanClipSelf() const |
| 143 { | 143 { |
| 144 return true; | 144 return true; |
| 145 } | 145 } |
| 146 | 146 |
| 147 class MockContentLayerClient : public ContentLayerClient { | 147 class MockContentLayerClient : public ContentLayerClient { |
| 148 public: | 148 public: |
| 149 MockContentLayerClient() { } | 149 MockContentLayerClient() { } |
| 150 virtual ~MockContentLayerClient() { } | 150 virtual ~MockContentLayerClient() { } |
| 151 virtual void paintContents(SkCanvas*, const gfx::Rect& clip, gfx::RectF& opa
que) OVERRIDE { } | 151 virtual void paintContents(SkCanvas*, const gfx::Rect& clip, gfx::RectF& opa
que) OVERRIDE { } |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 scoped_refptr<ContentLayer> createDrawableContentLayer(ContentLayerClient* deleg
ate) | 154 scoped_refptr<ContentLayer> createDrawableContentLayer(ContentLayerClient* deleg
ate) |
| 155 { | 155 { |
| 156 scoped_refptr<ContentLayer> toReturn = ContentLayer::create(delegate); | 156 scoped_refptr<ContentLayer> toReturn = ContentLayer::Create(delegate); |
| 157 toReturn->setIsDrawable(true); | 157 toReturn->SetIsDrawable(true); |
| 158 return toReturn; | 158 return toReturn; |
| 159 } | 159 } |
| 160 | 160 |
| 161 #define EXPECT_CONTENTS_SCALE_EQ(expected, layer) \ | 161 #define EXPECT_CONTENTS_SCALE_EQ(expected, layer) \ |
| 162 do { \ | 162 do { \ |
| 163 EXPECT_FLOAT_EQ(expected, layer->contentsScaleX()); \ | 163 EXPECT_FLOAT_EQ(expected, layer->contents_scale_x()); \ |
| 164 EXPECT_FLOAT_EQ(expected, layer->contentsScaleY()); \ | 164 EXPECT_FLOAT_EQ(expected, layer->contents_scale_y()); \ |
| 165 } while (false) | 165 } while (false) |
| 166 | 166 |
| 167 TEST(LayerTreeHostCommonTest, verifyTransformsForNoOpLayer) | 167 TEST(LayerTreeHostCommonTest, verifyTransformsForNoOpLayer) |
| 168 { | 168 { |
| 169 // Sanity check: For layers positioned at zero, with zero size, | 169 // Sanity check: For layers positioned at zero, with zero size, |
| 170 // and with identity transforms, then the drawTransform, | 170 // and with identity transforms, then the drawTransform, |
| 171 // screenSpaceTransform, and the hierarchy passed on to children | 171 // screenSpaceTransform, and the hierarchy passed on to children |
| 172 // layers should also be identity transforms. | 172 // layers should also be identity transforms. |
| 173 | 173 |
| 174 scoped_refptr<Layer> parent = Layer::create(); | 174 scoped_refptr<Layer> parent = Layer::Create(); |
| 175 scoped_refptr<Layer> child = Layer::create(); | 175 scoped_refptr<Layer> child = Layer::Create(); |
| 176 scoped_refptr<Layer> grandChild = Layer::create(); | 176 scoped_refptr<Layer> grandChild = Layer::Create(); |
| 177 parent->addChild(child); | 177 parent->AddChild(child); |
| 178 child->addChild(grandChild); | 178 child->AddChild(grandChild); |
| 179 | 179 |
| 180 gfx::Transform identityMatrix; | 180 gfx::Transform identityMatrix; |
| 181 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 181 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 182 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); | 182 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); |
| 183 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); | 183 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); |
| 184 | 184 |
| 185 executeCalculateDrawProperties(parent.get()); | 185 executeCalculateDrawProperties(parent.get()); |
| 186 | 186 |
| 187 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 187 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->draw_transform()); |
| 188 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform(
)); | 188 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screen_space_transfor
m()); |
| 189 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; | 189 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->draw_transform()
); |
| 190 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans
form()); | 190 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screen_space_tra
nsform()); |
| 191 } | 191 } |
| 192 | 192 |
| 193 TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer) | 193 TEST(LayerTreeHostCommonTest, verifyTransformsForSingleLayer) |
| 194 { | 194 { |
| 195 gfx::Transform identityMatrix; | 195 gfx::Transform identityMatrix; |
| 196 scoped_refptr<Layer> layer = Layer::create(); | 196 scoped_refptr<Layer> layer = Layer::Create(); |
| 197 | 197 |
| 198 scoped_refptr<Layer> root = Layer::create(); | 198 scoped_refptr<Layer> root = Layer::Create(); |
| 199 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 199 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 200 root->addChild(layer); | 200 root->AddChild(layer); |
| 201 | 201 |
| 202 // Case 1: setting the sublayer transform should not affect this layer's dra
w transform or screen-space transform. | 202 // Case 1: setting the sublayer transform should not affect this layer's dra
w transform or screen-space transform. |
| 203 gfx::Transform arbitraryTranslation; | 203 gfx::Transform arbitraryTranslation; |
| 204 arbitraryTranslation.Translate(10, 20); | 204 arbitraryTranslation.Translate(10, 20); |
| 205 setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslati
on, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 205 setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslati
on, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 206 executeCalculateDrawProperties(root.get()); | 206 executeCalculateDrawProperties(root.get()); |
| 207 gfx::Transform expectedDrawTransform = identityMatrix; | 207 gfx::Transform expectedDrawTransform = identityMatrix; |
| 208 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, layer->drawTransform(
)); | 208 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, layer->draw_transform
()); |
| 209 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform(
)); | 209 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screen_space_transfor
m()); |
| 210 | 210 |
| 211 // Case 2: Setting the bounds of the layer should not affect either the draw
transform or the screenspace transform. | 211 // Case 2: Setting the bounds of the layer should not affect either the draw
transform or the screenspace transform. |
| 212 gfx::Transform translationToCenter; | 212 gfx::Transform translationToCenter; |
| 213 translationToCenter.Translate(5, 6); | 213 translationToCenter.Translate(5, 6); |
| 214 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 214 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 215 executeCalculateDrawProperties(root.get()); | 215 executeCalculateDrawProperties(root.get()); |
| 216 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform()); | 216 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->draw_transform()); |
| 217 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform(
)); | 217 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screen_space_transfor
m()); |
| 218 | 218 |
| 219 // Case 3: The anchor point by itself (without a layer transform) should hav
e no effect on the transforms. | 219 // Case 3: The anchor point by itself (without a layer transform) should hav
e no effect on the transforms. |
| 220 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 220 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 221 executeCalculateDrawProperties(root.get()); | 221 executeCalculateDrawProperties(root.get()); |
| 222 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform()); | 222 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->draw_transform()); |
| 223 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform(
)); | 223 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screen_space_transfor
m()); |
| 224 | 224 |
| 225 // Case 4: A change in actual position affects both the draw transform and s
creen space transform. | 225 // Case 4: A change in actual position affects both the draw transform and s
creen space transform. |
| 226 gfx::Transform positionTransform; | 226 gfx::Transform positionTransform; |
| 227 positionTransform.Translate(0, 1.2); | 227 positionTransform.Translate(0, 1.2); |
| 228 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); | 228 setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, gf
x::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); |
| 229 executeCalculateDrawProperties(root.get()); | 229 executeCalculateDrawProperties(root.get()); |
| 230 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->drawTransform()); | 230 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->draw_transform()); |
| 231 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->screenSpaceTransfo
rm()); | 231 EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->screen_space_trans
form()); |
| 232 | 232 |
| 233 // Case 5: In the correct sequence of transforms, the layer transform should
pre-multiply the translationToCenter. This is easily tested by | 233 // Case 5: In the correct sequence of transforms, the layer transform should
pre-multiply the translationToCenter. This is easily tested by |
| 234 // using a scale transform, because scale and translation are not co
mmutative. | 234 // using a scale transform, because scale and translation are not co
mmutative. |
| 235 gfx::Transform layerTransform; | 235 gfx::Transform layerTransform; |
| 236 layerTransform.Scale3d(2, 2, 1); | 236 layerTransform.Scale3d(2, 2, 1); |
| 237 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 237 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 238 executeCalculateDrawProperties(root.get()); | 238 executeCalculateDrawProperties(root.get()); |
| 239 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->drawTransform()); | 239 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->draw_transform()); |
| 240 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screenSpaceTransform(
)); | 240 EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screen_space_transfor
m()); |
| 241 | 241 |
| 242 // Case 6: The layer transform should occur with respect to the anchor point
. | 242 // Case 6: The layer transform should occur with respect to the anchor point
. |
| 243 gfx::Transform translationToAnchor; | 243 gfx::Transform translationToAnchor; |
| 244 translationToAnchor.Translate(5, 0); | 244 translationToAnchor.Translate(5, 0); |
| 245 gfx::Transform expectedResult = translationToAnchor * layerTransform * inver
se(translationToAnchor); | 245 gfx::Transform expectedResult = translationToAnchor * layerTransform * inver
se(translationToAnchor); |
| 246 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 246 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 247 executeCalculateDrawProperties(root.get()); | 247 executeCalculateDrawProperties(root.get()); |
| 248 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); | 248 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->draw_transform()); |
| 249 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); | 249 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screen_space_transfor
m()); |
| 250 | 250 |
| 251 // Case 7: Verify that position pre-multiplies the layer transform. | 251 // Case 7: Verify that position pre-multiplies the layer transform. |
| 252 // The current implementation of calculateDrawProperties does this i
mplicitly, but it is | 252 // The current implementation of calculateDrawProperties does this i
mplicitly, but it is |
| 253 // still worth testing to detect accidental regressions. | 253 // still worth testing to detect accidental regressions. |
| 254 expectedResult = positionTransform * translationToAnchor * layerTransform *
inverse(translationToAnchor); | 254 expectedResult = positionTransform * translationToAnchor * layerTransform *
inverse(translationToAnchor); |
| 255 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); | 255 setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, gf
x::PointF(0.5, 0), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); |
| 256 executeCalculateDrawProperties(root.get()); | 256 executeCalculateDrawProperties(root.get()); |
| 257 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform()); | 257 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->draw_transform()); |
| 258 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform(
)); | 258 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screen_space_transfor
m()); |
| 259 } | 259 } |
| 260 | 260 |
| 261 TEST(LayerTreeHostCommonTest, verifyTransformsAboutScrollOffset) | 261 TEST(LayerTreeHostCommonTest, verifyTransformsAboutScrollOffset) |
| 262 { | 262 { |
| 263 const gfx::Vector2d kScrollOffset(50, 100); | 263 const gfx::Vector2d kScrollOffset(50, 100); |
| 264 const gfx::Vector2dF kScrollDelta(2.34f, 5.67f); | 264 const gfx::Vector2dF kScrollDelta(2.34f, 5.67f); |
| 265 const gfx::PointF kScrollLayerPosition(-kScrollOffset.x(), -kScrollOffset.y(
)); | 265 const gfx::PointF kScrollLayerPosition(-kScrollOffset.x(), -kScrollOffset.y(
)); |
| 266 const float kPageScale = 0.888f; | 266 const float kPageScale = 0.888f; |
| 267 const float kDeviceScale = 1.666f; | 267 const float kDeviceScale = 1.666f; |
| 268 | 268 |
| 269 FakeImplProxy proxy; | 269 FakeImplProxy proxy; |
| 270 FakeLayerTreeHostImpl hostImpl(&proxy); | 270 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 271 | 271 |
| 272 gfx::Transform identityMatrix; | 272 gfx::Transform identityMatrix; |
| 273 scoped_ptr<LayerImpl> sublayerScopedPtr(LayerImpl::create(hostImpl.activeTre
e(), 1)); | 273 scoped_ptr<LayerImpl> sublayerScopedPtr(LayerImpl::Create(hostImpl.activeTre
e(), 1)); |
| 274 LayerImpl* sublayer = sublayerScopedPtr.get(); | 274 LayerImpl* sublayer = sublayerScopedPtr.get(); |
| 275 sublayer->setContentsScale(kPageScale * kDeviceScale, kPageScale * kDeviceSc
ale); | 275 sublayer->SetContentsScale(kPageScale * kDeviceScale, kPageScale * kDeviceSc
ale); |
| 276 setLayerPropertiesForTesting(sublayer, identityMatrix, identityMatrix, gfx::
Point(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); | 276 setLayerPropertiesForTesting(sublayer, identityMatrix, identityMatrix, gfx::
Point(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); |
| 277 | 277 |
| 278 scoped_ptr<LayerImpl> scrollLayerScopedPtr(LayerImpl::create(hostImpl.active
Tree(), 2)); | 278 scoped_ptr<LayerImpl> scrollLayerScopedPtr(LayerImpl::Create(hostImpl.active
Tree(), 2)); |
| 279 LayerImpl* scrollLayer = scrollLayerScopedPtr.get(); | 279 LayerImpl* scrollLayer = scrollLayerScopedPtr.get(); |
| 280 setLayerPropertiesForTesting(scrollLayer, identityMatrix, identityMatrix, gf
x::PointF(0, 0), kScrollLayerPosition, gfx::Size(10, 20), false); | 280 setLayerPropertiesForTesting(scrollLayer, identityMatrix, identityMatrix, gf
x::PointF(0, 0), kScrollLayerPosition, gfx::Size(10, 20), false); |
| 281 scrollLayer->setScrollable(true); | 281 scrollLayer->SetScrollable(true); |
| 282 scrollLayer->setScrollOffset(kScrollOffset); | 282 scrollLayer->SetScrollOffset(kScrollOffset); |
| 283 scrollLayer->setScrollDelta(kScrollDelta); | 283 scrollLayer->SetScrollDelta(kScrollDelta); |
| 284 gfx::Transform implTransform; | 284 gfx::Transform implTransform; |
| 285 implTransform.Scale(kPageScale, kPageScale); | 285 implTransform.Scale(kPageScale, kPageScale); |
| 286 scrollLayer->setImplTransform(implTransform); | 286 scrollLayer->SetImplTransform(implTransform); |
| 287 scrollLayer->addChild(sublayerScopedPtr.Pass()); | 287 scrollLayer->AddChild(sublayerScopedPtr.Pass()); |
| 288 | 288 |
| 289 scoped_ptr<LayerImpl> root(LayerImpl::create(hostImpl.activeTree(), 3)); | 289 scoped_ptr<LayerImpl> root(LayerImpl::Create(hostImpl.activeTree(), 3)); |
| 290 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 290 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 291 root->addChild(scrollLayerScopedPtr.Pass()); | 291 root->AddChild(scrollLayerScopedPtr.Pass()); |
| 292 | 292 |
| 293 executeCalculateDrawProperties(root.get(), kDeviceScale, kPageScale); | 293 executeCalculateDrawProperties(root.get(), kDeviceScale, kPageScale); |
| 294 gfx::Transform expectedTransform = identityMatrix; | 294 gfx::Transform expectedTransform = identityMatrix; |
| 295 gfx::PointF subLayerScreenPosition = kScrollLayerPosition - kScrollDelta; | 295 gfx::PointF subLayerScreenPosition = kScrollLayerPosition - kScrollDelta; |
| 296 subLayerScreenPosition.Scale(kPageScale * kDeviceScale); | 296 subLayerScreenPosition.Scale(kPageScale * kDeviceScale); |
| 297 expectedTransform.Translate(MathUtil::Round(subLayerScreenPosition.x()), Mat
hUtil::Round(subLayerScreenPosition.y())); | 297 expectedTransform.Translate(MathUtil::Round(subLayerScreenPosition.x()), Mat
hUtil::Round(subLayerScreenPosition.y())); |
| 298 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->drawTransform()
); | 298 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->draw_transform(
)); |
| 299 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->screenSpaceTran
sform()); | 299 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->screen_space_tr
ansform()); |
| 300 | 300 |
| 301 gfx::Transform arbitraryTranslate; | 301 gfx::Transform arbitraryTranslate; |
| 302 const float kTranslateX = 10.6f; | 302 const float kTranslateX = 10.6f; |
| 303 const float kTranslateY = 20.6f; | 303 const float kTranslateY = 20.6f; |
| 304 arbitraryTranslate.Translate(kTranslateX, kTranslateY); | 304 arbitraryTranslate.Translate(kTranslateX, kTranslateY); |
| 305 setLayerPropertiesForTesting(scrollLayer, arbitraryTranslate, identityMatrix
, gfx::PointF(0, 0), kScrollLayerPosition, gfx::Size(10, 20), false); | 305 setLayerPropertiesForTesting(scrollLayer, arbitraryTranslate, identityMatrix
, gfx::PointF(0, 0), kScrollLayerPosition, gfx::Size(10, 20), false); |
| 306 executeCalculateDrawProperties(root.get(), kDeviceScale, kPageScale); | 306 executeCalculateDrawProperties(root.get(), kDeviceScale, kPageScale); |
| 307 expectedTransform.MakeIdentity(); | 307 expectedTransform.MakeIdentity(); |
| 308 expectedTransform.Translate(MathUtil::Round(kTranslateX * kPageScale * kDevi
ceScale + subLayerScreenPosition.x()), | 308 expectedTransform.Translate(MathUtil::Round(kTranslateX * kPageScale * kDevi
ceScale + subLayerScreenPosition.x()), |
| 309 MathUtil::Round(kTranslateY * kPageScale * kDevi
ceScale + subLayerScreenPosition.y())); | 309 MathUtil::Round(kTranslateY * kPageScale * kDevi
ceScale + subLayerScreenPosition.y())); |
| 310 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->drawTransform()
); | 310 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedTransform, sublayer->draw_transform(
)); |
| 311 } | 311 } |
| 312 | 312 |
| 313 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) | 313 TEST(LayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy) |
| 314 { | 314 { |
| 315 gfx::Transform identityMatrix; | 315 gfx::Transform identityMatrix; |
| 316 scoped_refptr<Layer> root = Layer::create(); | 316 scoped_refptr<Layer> root = Layer::Create(); |
| 317 scoped_refptr<Layer> parent = Layer::create(); | 317 scoped_refptr<Layer> parent = Layer::Create(); |
| 318 scoped_refptr<Layer> child = Layer::create(); | 318 scoped_refptr<Layer> child = Layer::Create(); |
| 319 scoped_refptr<Layer> grandChild = Layer::create(); | 319 scoped_refptr<Layer> grandChild = Layer::Create(); |
| 320 root->addChild(parent); | 320 root->AddChild(parent); |
| 321 parent->addChild(child); | 321 parent->AddChild(child); |
| 322 child->addChild(grandChild); | 322 child->AddChild(grandChild); |
| 323 | 323 |
| 324 // One-time setup of root layer | 324 // One-time setup of root layer |
| 325 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 325 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 326 | 326 |
| 327 // Case 1: parent's anchorPoint should not affect child or grandChild. | 327 // Case 1: parent's anchorPoint should not affect child or grandChild. |
| 328 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 328 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 329 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 329 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 330 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 330 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
| 331 executeCalculateDrawProperties(root.get()); | 331 executeCalculateDrawProperties(root.get()); |
| 332 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 332 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->draw_transform()); |
| 333 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform(
)); | 333 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screen_space_transfor
m()); |
| 334 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; | 334 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->draw_transform()
); |
| 335 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTrans
form()); | 335 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screen_space_tra
nsform()); |
| 336 | 336 |
| 337 // Case 2: parent's position affects child and grandChild. | 337 // Case 2: parent's position affects child and grandChild. |
| 338 gfx::Transform parentPositionTransform; | 338 gfx::Transform parentPositionTransform; |
| 339 parentPositionTransform.Translate(0, 1.2); | 339 parentPositionTransform.Translate(0, 1.2); |
| 340 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); | 340 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0.25, 0.25), gfx::PointF(0, 1.2f), gfx::Size(10, 12), false); |
| 341 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 341 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 342 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 342 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
| 343 executeCalculateDrawProperties(root.get()); | 343 executeCalculateDrawProperties(root.get()); |
| 344 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->drawTransfor
m()); | 344 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->draw_transfo
rm()); |
| 345 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->screenSpaceT
ransform()); | 345 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->screen_space
_transform()); |
| 346 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->drawTra
nsform()); | 346 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->draw_tr
ansform()); |
| 347 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->screenS
paceTransform()); | 347 EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->screen_
space_transform()); |
| 348 | 348 |
| 349 // Case 3: parent's local transform affects child and grandchild | 349 // Case 3: parent's local transform affects child and grandchild |
| 350 gfx::Transform parentLayerTransform; | 350 gfx::Transform parentLayerTransform; |
| 351 parentLayerTransform.Scale3d(2, 2, 1); | 351 parentLayerTransform.Scale3d(2, 2, 1); |
| 352 gfx::Transform parentTranslationToAnchor; | 352 gfx::Transform parentTranslationToAnchor; |
| 353 parentTranslationToAnchor.Translate(2.5, 3); | 353 parentTranslationToAnchor.Translate(2.5, 3); |
| 354 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * inverse(parentTranslationToAnchor); | 354 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * inverse(parentTranslationToAnchor); |
| 355 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMat
rix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); | 355 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, identityMat
rix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false); |
| 356 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 356 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 357 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 357 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
| 358 executeCalculateDrawProperties(root.get()); | 358 executeCalculateDrawProperties(root.get()); |
| 359 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); | 359 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->draw_transf
orm()); |
| 360 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); | 360 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screen_spac
e_transform()); |
| 361 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTr
ansform()); | 361 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->draw_t
ransform()); |
| 362 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen
SpaceTransform()); | 362 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen
_space_transform()); |
| 363 | 363 |
| 364 // Case 4: parent's sublayerMatrix affects child and grandchild | 364 // Case 4: parent's sublayerMatrix affects child and grandchild |
| 365 // scaling is used here again so that the correct sequence of transf
orms is properly tested. | 365 // scaling is used here again so that the correct sequence of transf
orms is properly tested. |
| 366 // Note that preserves3D is false, but the sublayer matrix should re
tain its 3D properties when given to child. | 366 // Note that preserves3D is false, but the sublayer matrix should re
tain its 3D properties when given to child. |
| 367 // But then, the child also does not preserve3D. When it gives its h
ierarchy to the grandChild, it should be flattened to 2D. | 367 // But then, the child also does not preserve3D. When it gives its h
ierarchy to the grandChild, it should be flattened to 2D. |
| 368 gfx::Transform parentSublayerMatrix; | 368 gfx::Transform parentSublayerMatrix; |
| 369 parentSublayerMatrix.Scale3d(10, 10, 3.3); | 369 parentSublayerMatrix.Scale3d(10, 10, 3.3); |
| 370 // Sublayer matrix is applied to the anchor point of the parent layer. | 370 // Sublayer matrix is applied to the anchor point of the parent layer. |
| 371 parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform
* inverse(parentTranslationToAnchor) | 371 parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform
* inverse(parentTranslationToAnchor) |
| 372 * parentTranslationToAnchor * parentSublayerMatrix * inverse(parentT
ranslationToAnchor); | 372 * parentTranslationToAnchor * parentSublayerMatrix * inverse(parentT
ranslationToAnchor); |
| 373 gfx::Transform flattenedCompositeTransform = parentCompositeTransform; | 373 gfx::Transform flattenedCompositeTransform = parentCompositeTransform; |
| 374 flattenedCompositeTransform.FlattenTo2d(); | 374 flattenedCompositeTransform.FlattenTo2d(); |
| 375 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; | 375 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; |
| 376 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 376 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 377 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 377 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
| 378 executeCalculateDrawProperties(root.get()); | 378 executeCalculateDrawProperties(root.get()); |
| 379 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); | 379 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->draw_transf
orm()); |
| 380 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); | 380 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screen_spac
e_transform()); |
| 381 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->dra
wTransform()); | 381 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->dra
w_transform()); |
| 382 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->scr
eenSpaceTransform()); | 382 EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->scr
een_space_transform()); |
| 383 | 383 |
| 384 // Case 5: same as Case 4, except that child does preserve 3D, so the grandC
hild should receive the non-flattened composite transform. | 384 // Case 5: same as Case 4, except that child does preserve 3D, so the grandC
hild should receive the non-flattened composite transform. |
| 385 // | 385 // |
| 386 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; | 386 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; |
| 387 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), true); | 387 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), true); |
| 388 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); | 388 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(76, 78), false); |
| 389 executeCalculateDrawProperties(root.get()); | 389 executeCalculateDrawProperties(root.get()); |
| 390 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransfo
rm()); | 390 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->draw_transf
orm()); |
| 391 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); | 391 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screen_spac
e_transform()); |
| 392 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTr
ansform()); | 392 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->draw_t
ransform()); |
| 393 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen
SpaceTransform()); | 393 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screen
_space_transform()); |
| 394 } | 394 } |
| 395 | 395 |
| 396 TEST(LayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface) | 396 TEST(LayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface) |
| 397 { | 397 { |
| 398 scoped_refptr<Layer> root = Layer::create(); | 398 scoped_refptr<Layer> root = Layer::Create(); |
| 399 scoped_refptr<Layer> parent = Layer::create(); | 399 scoped_refptr<Layer> parent = Layer::Create(); |
| 400 scoped_refptr<Layer> child = Layer::create(); | 400 scoped_refptr<Layer> child = Layer::Create(); |
| 401 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); | 401 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
| 402 root->addChild(parent); | 402 root->AddChild(parent); |
| 403 parent->addChild(child); | 403 parent->AddChild(child); |
| 404 child->addChild(grandChild); | 404 child->AddChild(grandChild); |
| 405 | 405 |
| 406 // One-time setup of root layer | 406 // One-time setup of root layer |
| 407 gfx::Transform identityMatrix; | 407 gfx::Transform identityMatrix; |
| 408 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 408 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 409 | 409 |
| 410 // Child is set up so that a new render surface should be created. | 410 // Child is set up so that a new render surface should be created. |
| 411 child->setOpacity(0.5); | 411 child->SetOpacity(0.5); |
| 412 child->setForceRenderSurface(true); | 412 child->SetForceRenderSurface(true); |
| 413 | 413 |
| 414 gfx::Transform parentLayerTransform; | 414 gfx::Transform parentLayerTransform; |
| 415 parentLayerTransform.Scale3d(1, 0.9, 1); | 415 parentLayerTransform.Scale3d(1, 0.9, 1); |
| 416 gfx::Transform parentTranslationToAnchor; | 416 gfx::Transform parentTranslationToAnchor; |
| 417 parentTranslationToAnchor.Translate(25, 30); | 417 parentTranslationToAnchor.Translate(25, 30); |
| 418 gfx::Transform parentSublayerMatrix; | 418 gfx::Transform parentSublayerMatrix; |
| 419 parentSublayerMatrix.Scale3d(0.9, 1, 3.3); | 419 parentSublayerMatrix.Scale3d(0.9, 1, 3.3); |
| 420 | 420 |
| 421 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * inverse(parentTranslationToAnchor) | 421 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * inverse(parentTranslationToAnchor) |
| 422 * parentTranslationToAnchor * parentSublayerMatrix * inverse(parentT
ranslationToAnchor); | 422 * parentTranslationToAnchor * parentSublayerMatrix * inverse(parentT
ranslationToAnchor); |
| 423 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform, 1.0f); | 423 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform, 1.0f); |
| 424 gfx::Transform surfaceSublayerTransform; | 424 gfx::Transform surfaceSublayerTransform; |
| 425 surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScal
e.y()); | 425 surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScal
e.y()); |
| 426 gfx::Transform surfaceSublayerCompositeTransform = parentCompositeTransform
* inverse(surfaceSublayerTransform); | 426 gfx::Transform surfaceSublayerCompositeTransform = parentCompositeTransform
* inverse(surfaceSublayerTransform); |
| 427 | 427 |
| 428 // Child's render surface should not exist yet. | 428 // Child's render surface should not exist yet. |
| 429 ASSERT_FALSE(child->renderSurface()); | 429 ASSERT_FALSE(child->render_surface()); |
| 430 | 430 |
| 431 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals
e); | 431 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals
e); |
| 432 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 432 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 433 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); | 433 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); |
| 434 executeCalculateDrawProperties(root.get()); | 434 executeCalculateDrawProperties(root.get()); |
| 435 | 435 |
| 436 // Render surface should have been created now. | 436 // Render surface should have been created now. |
| 437 ASSERT_TRUE(child->renderSurface()); | 437 ASSERT_TRUE(child->render_surface()); |
| 438 ASSERT_EQ(child, child->renderTarget()); | 438 ASSERT_EQ(child, child->render_target()); |
| 439 | 439 |
| 440 // The child layer's draw transform should refer to its new render surface. | 440 // The child layer's draw transform should refer to its new render surface. |
| 441 // The screen-space transform, however, should still refer to the root. | 441 // The screen-space transform, however, should still refer to the root. |
| 442 EXPECT_TRANSFORMATION_MATRIX_EQ(surfaceSublayerTransform, child->drawTransfo
rm()); | 442 EXPECT_TRANSFORMATION_MATRIX_EQ(surfaceSublayerTransform, child->draw_transf
orm()); |
| 443 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpace
Transform()); | 443 EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screen_spac
e_transform()); |
| 444 | 444 |
| 445 // Because the grandChild is the only drawable content, the child's renderSu
rface will tighten its bounds to the grandChild. | 445 // Because the grandChild is the only drawable content, the child's renderSu
rface will tighten its bounds to the grandChild. |
| 446 // The scale at which the surface's subtree is drawn must be removed from th
e composite transform. | 446 // The scale at which the surface's subtree is drawn must be removed from th
e composite transform. |
| 447 EXPECT_TRANSFORMATION_MATRIX_EQ(surfaceSublayerCompositeTransform, child->re
nderTarget()->renderSurface()->draw_transform()); | 447 EXPECT_TRANSFORMATION_MATRIX_EQ(surfaceSublayerCompositeTransform, child->re
nder_target()->render_surface()->draw_transform()); |
| 448 | 448 |
| 449 // The screen space is the same as the target since the child surface draws
into the root. | 449 // The screen space is the same as the target since the child surface draws
into the root. |
| 450 EXPECT_TRANSFORMATION_MATRIX_EQ(surfaceSublayerCompositeTransform, child->re
nderTarget()->renderSurface()->screen_space_transform()); | 450 EXPECT_TRANSFORMATION_MATRIX_EQ(surfaceSublayerCompositeTransform, child->re
nder_target()->render_surface()->screen_space_transform()); |
| 451 } | 451 } |
| 452 | 452 |
| 453 TEST(LayerTreeHostCommonTest, verifySublayerTransformWithAnchorPoint) | 453 TEST(LayerTreeHostCommonTest, verifySublayerTransformWithAnchorPoint) |
| 454 { | 454 { |
| 455 // crbug.com/157961 - we were always applying the sublayer transform about | 455 // crbug.com/157961 - we were always applying the sublayer transform about |
| 456 // the center of the layer, rather than the anchor point. | 456 // the center of the layer, rather than the anchor point. |
| 457 | 457 |
| 458 scoped_refptr<Layer> root = Layer::create(); | 458 scoped_refptr<Layer> root = Layer::Create(); |
| 459 scoped_refptr<Layer> parent = Layer::create(); | 459 scoped_refptr<Layer> parent = Layer::Create(); |
| 460 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); | 460 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
| 461 root->addChild(parent); | 461 root->AddChild(parent); |
| 462 parent->addChild(child); | 462 parent->AddChild(child); |
| 463 | 463 |
| 464 gfx::Transform identityMatrix; | 464 gfx::Transform identityMatrix; |
| 465 gfx::Transform parentSublayerMatrix; | 465 gfx::Transform parentSublayerMatrix; |
| 466 parentSublayerMatrix.ApplyPerspectiveDepth(2.0); | 466 parentSublayerMatrix.ApplyPerspectiveDepth(2.0); |
| 467 gfx::PointF parentAnchorPoint(0.2f, 0.8f); | 467 gfx::PointF parentAnchorPoint(0.2f, 0.8f); |
| 468 | 468 |
| 469 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 469 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 470 setLayerPropertiesForTesting(parent.get(), identityMatrix, parentSublayerMat
rix, parentAnchorPoint, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 470 setLayerPropertiesForTesting(parent.get(), identityMatrix, parentSublayerMat
rix, parentAnchorPoint, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 471 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 471 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 472 executeCalculateDrawProperties(root.get()); | 472 executeCalculateDrawProperties(root.get()); |
| 473 | 473 |
| 474 gfx::Transform expectedChildDrawTransform; | 474 gfx::Transform expectedChildDrawTransform; |
| 475 expectedChildDrawTransform.Translate(20, 80); | 475 expectedChildDrawTransform.Translate(20, 80); |
| 476 expectedChildDrawTransform.ApplyPerspectiveDepth(2.0); | 476 expectedChildDrawTransform.ApplyPerspectiveDepth(2.0); |
| 477 expectedChildDrawTransform.Translate(-20, -80); | 477 expectedChildDrawTransform.Translate(-20, -80); |
| 478 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->drawTrans
form()); | 478 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->draw_tran
sform()); |
| 479 } | 479 } |
| 480 | 480 |
| 481 | 481 |
| 482 TEST(LayerTreeHostCommonTest, verifySeparateRenderTargetRequirementWithClipping) | 482 TEST(LayerTreeHostCommonTest, verifySeparateRenderTargetRequirementWithClipping) |
| 483 { | 483 { |
| 484 scoped_refptr<Layer> root = Layer::create(); | 484 scoped_refptr<Layer> root = Layer::Create(); |
| 485 scoped_refptr<Layer> parent = Layer::create(); | 485 scoped_refptr<Layer> parent = Layer::Create(); |
| 486 scoped_refptr<Layer> child = Layer::create(); | 486 scoped_refptr<Layer> child = Layer::Create(); |
| 487 scoped_refptr<Layer> grandChild = make_scoped_refptr(new LayerCanClipSelf())
; | 487 scoped_refptr<Layer> grandChild = make_scoped_refptr(new LayerCanClipSelf())
; |
| 488 root->addChild(parent); | 488 root->AddChild(parent); |
| 489 parent->addChild(child); | 489 parent->AddChild(child); |
| 490 child->addChild(grandChild); | 490 child->AddChild(grandChild); |
| 491 parent->setMasksToBounds(true); | 491 parent->SetMasksToBounds(true); |
| 492 child->setMasksToBounds(true); | 492 child->SetMasksToBounds(true); |
| 493 | 493 |
| 494 gfx::Transform identityMatrix; | 494 gfx::Transform identityMatrix; |
| 495 gfx::Transform parentLayerTransform; | 495 gfx::Transform parentLayerTransform; |
| 496 gfx::Transform parentSublayerMatrix; | 496 gfx::Transform parentSublayerMatrix; |
| 497 gfx::Transform childLayerMatrix; | 497 gfx::Transform childLayerMatrix; |
| 498 | 498 |
| 499 // No render surface should exist yet. | 499 // No render surface should exist yet. |
| 500 EXPECT_FALSE(root->renderSurface()); | 500 EXPECT_FALSE(root->render_surface()); |
| 501 EXPECT_FALSE(parent->renderSurface()); | 501 EXPECT_FALSE(parent->render_surface()); |
| 502 EXPECT_FALSE(child->renderSurface()); | 502 EXPECT_FALSE(child->render_surface()); |
| 503 EXPECT_FALSE(grandChild->renderSurface()); | 503 EXPECT_FALSE(grandChild->render_surface()); |
| 504 | 504 |
| 505 // One-time setup of root layer | 505 // One-time setup of root layer |
| 506 parentLayerTransform.Scale3d(1, 0.9, 1); | 506 parentLayerTransform.Scale3d(1, 0.9, 1); |
| 507 parentSublayerMatrix.Scale3d(0.9, 1, 3.3); | 507 parentSublayerMatrix.Scale3d(0.9, 1, 3.3); |
| 508 childLayerMatrix.Rotate(20); | 508 childLayerMatrix.Rotate(20); |
| 509 | 509 |
| 510 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 510 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 511 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals
e); | 511 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals
e); |
| 512 setLayerPropertiesForTesting(child.get(), childLayerMatrix, identityMatrix,
gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 512 setLayerPropertiesForTesting(child.get(), childLayerMatrix, identityMatrix,
gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 513 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); | 513 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); |
| 514 | 514 |
| 515 executeCalculateDrawProperties(root.get()); | 515 executeCalculateDrawProperties(root.get()); |
| 516 | 516 |
| 517 // Render surfaces should have been created according to clipping rules now
(grandchild can clip self). | 517 // Render surfaces should have been created according to clipping rules now
(grandchild can clip self). |
| 518 EXPECT_TRUE(root->renderSurface()); | 518 EXPECT_TRUE(root->render_surface()); |
| 519 EXPECT_FALSE(parent->renderSurface()); | 519 EXPECT_FALSE(parent->render_surface()); |
| 520 EXPECT_FALSE(child->renderSurface()); | 520 EXPECT_FALSE(child->render_surface()); |
| 521 EXPECT_FALSE(grandChild->renderSurface()); | 521 EXPECT_FALSE(grandChild->render_surface()); |
| 522 } | 522 } |
| 523 | 523 |
| 524 TEST(LayerTreeHostCommonTest, verifySeparateRenderTargetRequirementWithoutClippi
ng) | 524 TEST(LayerTreeHostCommonTest, verifySeparateRenderTargetRequirementWithoutClippi
ng) |
| 525 { | 525 { |
| 526 scoped_refptr<Layer> root = Layer::create(); | 526 scoped_refptr<Layer> root = Layer::Create(); |
| 527 scoped_refptr<Layer> parent = Layer::create(); | 527 scoped_refptr<Layer> parent = Layer::Create(); |
| 528 scoped_refptr<Layer> child = Layer::create(); | 528 scoped_refptr<Layer> child = Layer::Create(); |
| 529 // This layer cannot clip itself, a feature we are testing here. | 529 // This layer cannot clip itself, a feature we are testing here. |
| 530 scoped_refptr<Layer> grandChild = make_scoped_refptr(new LayerWithForcedDraw
sContent()); | 530 scoped_refptr<Layer> grandChild = make_scoped_refptr(new LayerWithForcedDraw
sContent()); |
| 531 root->addChild(parent); | 531 root->AddChild(parent); |
| 532 parent->addChild(child); | 532 parent->AddChild(child); |
| 533 child->addChild(grandChild); | 533 child->AddChild(grandChild); |
| 534 parent->setMasksToBounds(true); | 534 parent->SetMasksToBounds(true); |
| 535 child->setMasksToBounds(true); | 535 child->SetMasksToBounds(true); |
| 536 | 536 |
| 537 gfx::Transform identityMatrix; | 537 gfx::Transform identityMatrix; |
| 538 gfx::Transform parentLayerTransform; | 538 gfx::Transform parentLayerTransform; |
| 539 gfx::Transform parentSublayerMatrix; | 539 gfx::Transform parentSublayerMatrix; |
| 540 gfx::Transform childLayerMatrix; | 540 gfx::Transform childLayerMatrix; |
| 541 | 541 |
| 542 // No render surface should exist yet. | 542 // No render surface should exist yet. |
| 543 EXPECT_FALSE(root->renderSurface()); | 543 EXPECT_FALSE(root->render_surface()); |
| 544 EXPECT_FALSE(parent->renderSurface()); | 544 EXPECT_FALSE(parent->render_surface()); |
| 545 EXPECT_FALSE(child->renderSurface()); | 545 EXPECT_FALSE(child->render_surface()); |
| 546 EXPECT_FALSE(grandChild->renderSurface()); | 546 EXPECT_FALSE(grandChild->render_surface()); |
| 547 | 547 |
| 548 // One-time setup of root layer | 548 // One-time setup of root layer |
| 549 parentLayerTransform.Scale3d(1, 0.9, 1); | 549 parentLayerTransform.Scale3d(1, 0.9, 1); |
| 550 parentSublayerMatrix.Scale3d(0.9, 1, 3.3); | 550 parentSublayerMatrix.Scale3d(0.9, 1, 3.3); |
| 551 childLayerMatrix.Rotate(20); | 551 childLayerMatrix.Rotate(20); |
| 552 | 552 |
| 553 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 553 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 554 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals
e); | 554 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), fals
e); |
| 555 setLayerPropertiesForTesting(child.get(), childLayerMatrix, identityMatrix,
gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 555 setLayerPropertiesForTesting(child.get(), childLayerMatrix, identityMatrix,
gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 556 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); | 556 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(8, 10), false); |
| 557 | 557 |
| 558 executeCalculateDrawProperties(root.get()); | 558 executeCalculateDrawProperties(root.get()); |
| 559 | 559 |
| 560 // Render surfaces should have been created according to clipping rules now
(grandchild can't clip self). | 560 // Render surfaces should have been created according to clipping rules now
(grandchild can't clip self). |
| 561 EXPECT_TRUE(root->renderSurface()); | 561 EXPECT_TRUE(root->render_surface()); |
| 562 EXPECT_FALSE(parent->renderSurface()); | 562 EXPECT_FALSE(parent->render_surface()); |
| 563 EXPECT_TRUE(child->renderSurface()); | 563 EXPECT_TRUE(child->render_surface()); |
| 564 EXPECT_FALSE(grandChild->renderSurface()); | 564 EXPECT_FALSE(grandChild->render_surface()); |
| 565 } | 565 } |
| 566 | 566 |
| 567 TEST(LayerTreeHostCommonTest, verifyTransformsForReplica) | 567 TEST(LayerTreeHostCommonTest, verifyTransformsForReplica) |
| 568 { | 568 { |
| 569 scoped_refptr<Layer> root = Layer::create(); | 569 scoped_refptr<Layer> root = Layer::Create(); |
| 570 scoped_refptr<Layer> parent = Layer::create(); | 570 scoped_refptr<Layer> parent = Layer::Create(); |
| 571 scoped_refptr<Layer> child = Layer::create(); | 571 scoped_refptr<Layer> child = Layer::Create(); |
| 572 scoped_refptr<Layer> childReplica = Layer::create(); | 572 scoped_refptr<Layer> childReplica = Layer::Create(); |
| 573 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); | 573 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
| 574 root->addChild(parent); | 574 root->AddChild(parent); |
| 575 parent->addChild(child); | 575 parent->AddChild(child); |
| 576 child->addChild(grandChild); | 576 child->AddChild(grandChild); |
| 577 child->setReplicaLayer(childReplica.get()); | 577 child->SetReplicaLayer(childReplica.get()); |
| 578 | 578 |
| 579 // One-time setup of root layer | 579 // One-time setup of root layer |
| 580 gfx::Transform identityMatrix; | 580 gfx::Transform identityMatrix; |
| 581 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 581 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 582 | 582 |
| 583 // Child is set up so that a new render surface should be created. | 583 // Child is set up so that a new render surface should be created. |
| 584 child->setOpacity(0.5); | 584 child->SetOpacity(0.5); |
| 585 | 585 |
| 586 gfx::Transform parentLayerTransform; | 586 gfx::Transform parentLayerTransform; |
| 587 parentLayerTransform.Scale3d(2, 2, 1); | 587 parentLayerTransform.Scale3d(2, 2, 1); |
| 588 gfx::Transform parentTranslationToAnchor; | 588 gfx::Transform parentTranslationToAnchor; |
| 589 parentTranslationToAnchor.Translate(2.5, 3); | 589 parentTranslationToAnchor.Translate(2.5, 3); |
| 590 gfx::Transform parentSublayerMatrix; | 590 gfx::Transform parentSublayerMatrix; |
| 591 parentSublayerMatrix.Scale3d(10, 10, 3.3); | 591 parentSublayerMatrix.Scale3d(10, 10, 3.3); |
| 592 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * inverse(parentTranslationToAnchor) | 592 gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parent
LayerTransform * inverse(parentTranslationToAnchor) |
| 593 * parentTranslationToAnchor * parentSublayerMatrix * inverse(parentT
ranslationToAnchor); | 593 * parentTranslationToAnchor * parentSublayerMatrix * inverse(parentT
ranslationToAnchor); |
| 594 gfx::Transform replicaLayerTransform; | 594 gfx::Transform replicaLayerTransform; |
| 595 replicaLayerTransform.Scale3d(3, 3, 1); | 595 replicaLayerTransform.Scale3d(3, 3, 1); |
| 596 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform, 1.f); | 596 gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleCompo
nents(parentCompositeTransform, 1.f); |
| 597 gfx::Transform surfaceSublayerTransform; | 597 gfx::Transform surfaceSublayerTransform; |
| 598 surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScal
e.y()); | 598 surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScal
e.y()); |
| 599 gfx::Transform replicaCompositeTransform = parentCompositeTransform * replic
aLayerTransform * inverse(surfaceSublayerTransform); | 599 gfx::Transform replicaCompositeTransform = parentCompositeTransform * replic
aLayerTransform * inverse(surfaceSublayerTransform); |
| 600 | 600 |
| 601 // Child's render surface should not exist yet. | 601 // Child's render surface should not exist yet. |
| 602 ASSERT_FALSE(child->renderSurface()); | 602 ASSERT_FALSE(child->render_surface()); |
| 603 | 603 |
| 604 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; | 604 setLayerPropertiesForTesting(parent.get(), parentLayerTransform, parentSubla
yerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(10, 12), false)
; |
| 605 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); | 605 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(16, 18), false); |
| 606 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(-0.5, -0.5), gfx::Size(1, 1), false); | 606 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(-0.5, -0.5), gfx::Size(1, 1), false); |
| 607 setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, iden
tityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); | 607 setLayerPropertiesForTesting(childReplica.get(), replicaLayerTransform, iden
tityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(0, 0), false); |
| 608 executeCalculateDrawProperties(root.get()); | 608 executeCalculateDrawProperties(root.get()); |
| 609 | 609 |
| 610 // Render surface should have been created now. | 610 // Render surface should have been created now. |
| 611 ASSERT_TRUE(child->renderSurface()); | 611 ASSERT_TRUE(child->render_surface()); |
| 612 ASSERT_EQ(child, child->renderTarget()); | 612 ASSERT_EQ(child, child->render_target()); |
| 613 | 613 |
| 614 EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->renderTarg
et()->renderSurface()->replica_draw_transform()); | 614 EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->render_tar
get()->render_surface()->replica_draw_transform()); |
| 615 EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->renderTarg
et()->renderSurface()->replica_screen_space_transform()); | 615 EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->render_tar
get()->render_surface()->replica_screen_space_transform()); |
| 616 } | 616 } |
| 617 | 617 |
| 618 TEST(LayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy) | 618 TEST(LayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy) |
| 619 { | 619 { |
| 620 // This test creates a more complex tree and verifies it all at once. This c
overs the following cases: | 620 // This test creates a more complex tree and verifies it all at once. This c
overs the following cases: |
| 621 // - layers that are described w.r.t. a render surface: should have draw t
ransforms described w.r.t. that surface | 621 // - layers that are described w.r.t. a render surface: should have draw t
ransforms described w.r.t. that surface |
| 622 // - A render surface described w.r.t. an ancestor render surface: should
have a draw transform described w.r.t. that ancestor surface | 622 // - A render surface described w.r.t. an ancestor render surface: should
have a draw transform described w.r.t. that ancestor surface |
| 623 // - Replicas of a render surface are described w.r.t. the replica's trans
form around its anchor, along with the surface itself. | 623 // - Replicas of a render surface are described w.r.t. the replica's trans
form around its anchor, along with the surface itself. |
| 624 // - Sanity check on recursion: verify transforms of layers described w.r.
t. a render surface that is described w.r.t. an ancestor render surface. | 624 // - Sanity check on recursion: verify transforms of layers described w.r.
t. a render surface that is described w.r.t. an ancestor render surface. |
| 625 // - verifying that each layer has a reference to the correct renderSurfac
e and renderTarget values. | 625 // - verifying that each layer has a reference to the correct renderSurfac
e and renderTarget values. |
| 626 | 626 |
| 627 scoped_refptr<Layer> root = Layer::create(); | 627 scoped_refptr<Layer> root = Layer::Create(); |
| 628 scoped_refptr<Layer> parent = Layer::create(); | 628 scoped_refptr<Layer> parent = Layer::Create(); |
| 629 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 629 scoped_refptr<Layer> renderSurface1 = Layer::Create(); |
| 630 scoped_refptr<Layer> renderSurface2 = Layer::create(); | 630 scoped_refptr<Layer> renderSurface2 = Layer::Create(); |
| 631 scoped_refptr<Layer> childOfRoot = Layer::create(); | 631 scoped_refptr<Layer> childOfRoot = Layer::Create(); |
| 632 scoped_refptr<Layer> childOfRS1 = Layer::create(); | 632 scoped_refptr<Layer> childOfRS1 = Layer::Create(); |
| 633 scoped_refptr<Layer> childOfRS2 = Layer::create(); | 633 scoped_refptr<Layer> childOfRS2 = Layer::Create(); |
| 634 scoped_refptr<Layer> replicaOfRS1 = Layer::create(); | 634 scoped_refptr<Layer> replicaOfRS1 = Layer::Create(); |
| 635 scoped_refptr<Layer> replicaOfRS2 = Layer::create(); | 635 scoped_refptr<Layer> replicaOfRS2 = Layer::Create(); |
| 636 scoped_refptr<Layer> grandChildOfRoot = Layer::create(); | 636 scoped_refptr<Layer> grandChildOfRoot = Layer::Create(); |
| 637 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS1 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); | 637 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS1 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
| 638 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS2 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); | 638 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS2 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
| 639 root->addChild(parent); | 639 root->AddChild(parent); |
| 640 parent->addChild(renderSurface1); | 640 parent->AddChild(renderSurface1); |
| 641 parent->addChild(childOfRoot); | 641 parent->AddChild(childOfRoot); |
| 642 renderSurface1->addChild(childOfRS1); | 642 renderSurface1->AddChild(childOfRS1); |
| 643 renderSurface1->addChild(renderSurface2); | 643 renderSurface1->AddChild(renderSurface2); |
| 644 renderSurface2->addChild(childOfRS2); | 644 renderSurface2->AddChild(childOfRS2); |
| 645 childOfRoot->addChild(grandChildOfRoot); | 645 childOfRoot->AddChild(grandChildOfRoot); |
| 646 childOfRS1->addChild(grandChildOfRS1); | 646 childOfRS1->AddChild(grandChildOfRS1); |
| 647 childOfRS2->addChild(grandChildOfRS2); | 647 childOfRS2->AddChild(grandChildOfRS2); |
| 648 renderSurface1->setReplicaLayer(replicaOfRS1.get()); | 648 renderSurface1->SetReplicaLayer(replicaOfRS1.get()); |
| 649 renderSurface2->setReplicaLayer(replicaOfRS2.get()); | 649 renderSurface2->SetReplicaLayer(replicaOfRS2.get()); |
| 650 | 650 |
| 651 // In combination with descendantDrawsContent, opacity != 1 forces the layer
to have a new renderSurface. | 651 // In combination with descendantDrawsContent, opacity != 1 forces the layer
to have a new renderSurface. |
| 652 renderSurface1->setOpacity(0.5); | 652 renderSurface1->SetOpacity(0.5); |
| 653 renderSurface2->setOpacity(0.33f); | 653 renderSurface2->SetOpacity(0.33f); |
| 654 | 654 |
| 655 // One-time setup of root layer | 655 // One-time setup of root layer |
| 656 gfx::Transform identityMatrix; | 656 gfx::Transform identityMatrix; |
| 657 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); | 657 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 2), false); |
| 658 | 658 |
| 659 // All layers in the tree are initialized with an anchor at .25 and a size o
f (10,10). | 659 // All layers in the tree are initialized with an anchor at .25 and a size o
f (10,10). |
| 660 // matrix "A" is the composite layer transform used in all layers, centered
about the anchor point | 660 // matrix "A" is the composite layer transform used in all layers, centered
about the anchor point |
| 661 // matrix "B" is the sublayer transform used in all layers, centered about t
he center position of the layer. | 661 // matrix "B" is the sublayer transform used in all layers, centered about t
he center position of the layer. |
| 662 // matrix "R" is the composite replica transform used in all replica layers. | 662 // matrix "R" is the composite replica transform used in all replica layers. |
| 663 // | 663 // |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 701 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 702 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 702 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 703 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 703 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 704 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 704 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 705 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 705 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 706 setLayerPropertiesForTesting(replicaOfRS1.get(), replicaLayerTransform, subl
ayerTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(), false); | 706 setLayerPropertiesForTesting(replicaOfRS1.get(), replicaLayerTransform, subl
ayerTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(), false); |
| 707 setLayerPropertiesForTesting(replicaOfRS2.get(), replicaLayerTransform, subl
ayerTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(), false); | 707 setLayerPropertiesForTesting(replicaOfRS2.get(), replicaLayerTransform, subl
ayerTransform, gfx::PointF(0.25, 0), gfx::PointF(0, 0), gfx::Size(), false); |
| 708 | 708 |
| 709 executeCalculateDrawProperties(root.get()); | 709 executeCalculateDrawProperties(root.get()); |
| 710 | 710 |
| 711 // Only layers that are associated with render surfaces should have an actua
l renderSurface() value. | 711 // Only layers that are associated with render surfaces should have an actua
l RenderSurface() value. |
| 712 // | 712 // |
| 713 ASSERT_TRUE(root->renderSurface()); | 713 ASSERT_TRUE(root->render_surface()); |
| 714 ASSERT_FALSE(childOfRoot->renderSurface()); | 714 ASSERT_FALSE(childOfRoot->render_surface()); |
| 715 ASSERT_FALSE(grandChildOfRoot->renderSurface()); | 715 ASSERT_FALSE(grandChildOfRoot->render_surface()); |
| 716 | 716 |
| 717 ASSERT_TRUE(renderSurface1->renderSurface()); | 717 ASSERT_TRUE(renderSurface1->render_surface()); |
| 718 ASSERT_FALSE(childOfRS1->renderSurface()); | 718 ASSERT_FALSE(childOfRS1->render_surface()); |
| 719 ASSERT_FALSE(grandChildOfRS1->renderSurface()); | 719 ASSERT_FALSE(grandChildOfRS1->render_surface()); |
| 720 | 720 |
| 721 ASSERT_TRUE(renderSurface2->renderSurface()); | 721 ASSERT_TRUE(renderSurface2->render_surface()); |
| 722 ASSERT_FALSE(childOfRS2->renderSurface()); | 722 ASSERT_FALSE(childOfRS2->render_surface()); |
| 723 ASSERT_FALSE(grandChildOfRS2->renderSurface()); | 723 ASSERT_FALSE(grandChildOfRS2->render_surface()); |
| 724 | 724 |
| 725 // Verify all renderTarget accessors | 725 // Verify all renderTarget accessors |
| 726 // | 726 // |
| 727 EXPECT_EQ(root, parent->renderTarget()); | 727 EXPECT_EQ(root, parent->render_target()); |
| 728 EXPECT_EQ(root, childOfRoot->renderTarget()); | 728 EXPECT_EQ(root, childOfRoot->render_target()); |
| 729 EXPECT_EQ(root, grandChildOfRoot->renderTarget()); | 729 EXPECT_EQ(root, grandChildOfRoot->render_target()); |
| 730 | 730 |
| 731 EXPECT_EQ(renderSurface1, renderSurface1->renderTarget()); | 731 EXPECT_EQ(renderSurface1, renderSurface1->render_target()); |
| 732 EXPECT_EQ(renderSurface1, childOfRS1->renderTarget()); | 732 EXPECT_EQ(renderSurface1, childOfRS1->render_target()); |
| 733 EXPECT_EQ(renderSurface1, grandChildOfRS1->renderTarget()); | 733 EXPECT_EQ(renderSurface1, grandChildOfRS1->render_target()); |
| 734 | 734 |
| 735 EXPECT_EQ(renderSurface2, renderSurface2->renderTarget()); | 735 EXPECT_EQ(renderSurface2, renderSurface2->render_target()); |
| 736 EXPECT_EQ(renderSurface2, childOfRS2->renderTarget()); | 736 EXPECT_EQ(renderSurface2, childOfRS2->render_target()); |
| 737 EXPECT_EQ(renderSurface2, grandChildOfRS2->renderTarget()); | 737 EXPECT_EQ(renderSurface2, grandChildOfRS2->render_target()); |
| 738 | 738 |
| 739 // Verify layer draw transforms | 739 // Verify layer draw transforms |
| 740 // note that draw transforms are described with respect to the nearest ance
stor render surface | 740 // note that draw transforms are described with respect to the nearest ance
stor render surface |
| 741 // but screen space transforms are described with respect to the root. | 741 // but screen space transforms are described with respect to the root. |
| 742 // | 742 // |
| 743 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->drawTransform()); | 743 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->draw_transform()); |
| 744 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, childOfRoot->drawTransform()); | 744 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, childOfRoot->draw_transform()); |
| 745 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, grandChildOfRoot->drawTra
nsform()); | 745 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, grandChildOfRoot->draw_tr
ansform()); |
| 746 | 746 |
| 747 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1, renderSurface1->drawTransform()); | 747 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1, renderSurface1->draw_transform()); |
| 748 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A, childOfRS1->drawTransform()); | 748 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A, childOfRS1->draw_transform()); |
| 749 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A * B * A, grandChildOfRS1->drawTr
ansform()); | 749 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A * B * A, grandChildOfRS1->draw_t
ransform()); |
| 750 | 750 |
| 751 EXPECT_TRANSFORMATION_MATRIX_EQ(SS2, renderSurface2->drawTransform()); | 751 EXPECT_TRANSFORMATION_MATRIX_EQ(SS2, renderSurface2->draw_transform()); |
| 752 EXPECT_TRANSFORMATION_MATRIX_EQ(SS2 * B * A, childOfRS2->drawTransform()); | 752 EXPECT_TRANSFORMATION_MATRIX_EQ(SS2 * B * A, childOfRS2->draw_transform()); |
| 753 EXPECT_TRANSFORMATION_MATRIX_EQ(SS2 * B * A * B * A, grandChildOfRS2->drawTr
ansform()); | 753 EXPECT_TRANSFORMATION_MATRIX_EQ(SS2 * B * A * B * A, grandChildOfRS2->draw_t
ransform()); |
| 754 | 754 |
| 755 // Verify layer screen-space transforms | 755 // Verify layer screen-space transforms |
| 756 // | 756 // |
| 757 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->screenSpaceTransform()); | 757 EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->screen_space_transform()); |
| 758 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, childOfRoot->screenSpaceTransform
()); | 758 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, childOfRoot->screen_space_transfo
rm()); |
| 759 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, grandChildOfRoot->screenS
paceTransform()); | 759 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, grandChildOfRoot->screen_
space_transform()); |
| 760 | 760 |
| 761 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, renderSurface1->screenSpaceTransf
orm()); | 761 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, renderSurface1->screen_space_tran
sform()); |
| 762 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, childOfRS1->screenSpaceTr
ansform()); | 762 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, childOfRS1->screen_space_
transform()); |
| 763 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A, grandChildOfRS1->
screenSpaceTransform()); | 763 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A, grandChildOfRS1->
screen_space_transform()); |
| 764 | 764 |
| 765 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, renderSurface2->screenSpa
ceTransform()); | 765 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, renderSurface2->screen_sp
ace_transform()); |
| 766 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A, childOfRS2->scree
nSpaceTransform()); | 766 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A, childOfRS2->scree
n_space_transform()); |
| 767 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A * B * A, grandChil
dOfRS2->screenSpaceTransform()); | 767 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * B * A * B * A, grandChil
dOfRS2->screen_space_transform()); |
| 768 | 768 |
| 769 // Verify render surface transforms. | 769 // Verify render surface transforms. |
| 770 // | 770 // |
| 771 // Draw transform of render surface 1 is described with respect to root. | 771 // Draw transform of render surface 1 is described with respect to root. |
| 772 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * S1, renderSurface1->renderSurfac
e()->draw_transform()); | 772 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * S1, renderSurface1->render_surfa
ce()->draw_transform()); |
| 773 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R * S1, renderSurface1->renderSurfac
e()->replica_draw_transform()); | 773 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R * S1, renderSurface1->render_surfa
ce()->replica_draw_transform()); |
| 774 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * S1, renderSurface1->renderSurfac
e()->screen_space_transform()); | 774 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * S1, renderSurface1->render_surfa
ce()->screen_space_transform()); |
| 775 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R * S1, renderSurface1->renderSurfac
e()->replica_screen_space_transform()); | 775 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * R * S1, renderSurface1->render_surfa
ce()->replica_screen_space_transform()); |
| 776 // Draw transform of render surface 2 is described with respect to render su
rface 1. | 776 // Draw transform of render surface 2 is described with respect to render su
rface 1. |
| 777 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A * S2, renderSurface2->renderSurf
ace()->draw_transform()); | 777 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * A * S2, renderSurface2->render_sur
face()->draw_transform()); |
| 778 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * R * S2, renderSurface2->renderSurf
ace()->replica_draw_transform()); | 778 EXPECT_TRANSFORMATION_MATRIX_EQ(SS1 * B * R * S2, renderSurface2->render_sur
face()->replica_draw_transform()); |
| 779 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * S2, renderSurface2->rend
erSurface()->screen_space_transform()); | 779 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * S2, renderSurface2->rend
er_surface()->screen_space_transform()); |
| 780 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * R * S2, renderSurface2->rend
erSurface()->replica_screen_space_transform()); | 780 EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * R * S2, renderSurface2->rend
er_surface()->replica_screen_space_transform()); |
| 781 | 781 |
| 782 // Sanity check. If these fail there is probably a bug in the test itself. | 782 // Sanity check. If these fail there is probably a bug in the test itself. |
| 783 // It is expected that we correctly set up transforms so that the y-componen
t of the screen-space transform | 783 // It is expected that we correctly set up transforms so that the y-componen
t of the screen-space transform |
| 784 // encodes the "depth" of the layer in the tree. | 784 // encodes the "depth" of the layer in the tree. |
| 785 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().matrix().getDouble(1, 3)); | 785 EXPECT_FLOAT_EQ(1, parent->screen_space_transform().matrix().getDouble(1, 3)
); |
| 786 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().matrix().getDouble(1,
3)); | 786 EXPECT_FLOAT_EQ(2, childOfRoot->screen_space_transform().matrix().getDouble(
1, 3)); |
| 787 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().matrix().getDoub
le(1, 3)); | 787 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screen_space_transform().matrix().getDo
uble(1, 3)); |
| 788 | 788 |
| 789 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().matrix().getDouble
(1, 3)); | 789 EXPECT_FLOAT_EQ(2, renderSurface1->screen_space_transform().matrix().getDoub
le(1, 3)); |
| 790 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().matrix().getDouble(1,
3)); | 790 EXPECT_FLOAT_EQ(3, childOfRS1->screen_space_transform().matrix().getDouble(1
, 3)); |
| 791 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().matrix().getDoubl
e(1, 3)); | 791 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screen_space_transform().matrix().getDou
ble(1, 3)); |
| 792 | 792 |
| 793 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().matrix().getDouble
(1, 3)); | 793 EXPECT_FLOAT_EQ(3, renderSurface2->screen_space_transform().matrix().getDoub
le(1, 3)); |
| 794 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().matrix().getDouble(1,
3)); | 794 EXPECT_FLOAT_EQ(4, childOfRS2->screen_space_transform().matrix().getDouble(1
, 3)); |
| 795 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().matrix().getDoubl
e(1, 3)); | 795 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screen_space_transform().matrix().getDou
ble(1, 3)); |
| 796 } | 796 } |
| 797 | 797 |
| 798 TEST(LayerTreeHostCommonTest, verifyTransformsForFlatteningLayer) | 798 TEST(LayerTreeHostCommonTest, verifyTransformsForFlatteningLayer) |
| 799 { | 799 { |
| 800 // For layers that flatten their subtree, there should be an orthographic pr
ojection | 800 // For layers that flatten their subtree, there should be an orthographic pr
ojection |
| 801 // (for x and y values) in the middle of the transform sequence. Note that t
he way the | 801 // (for x and y values) in the middle of the transform sequence. Note that t
he way the |
| 802 // code is currently implemented, it is not expected to use a canonical orth
ographic | 802 // code is currently implemented, it is not expected to use a canonical orth
ographic |
| 803 // projection. | 803 // projection. |
| 804 | 804 |
| 805 scoped_refptr<Layer> root = Layer::create(); | 805 scoped_refptr<Layer> root = Layer::Create(); |
| 806 scoped_refptr<Layer> child = Layer::create(); | 806 scoped_refptr<Layer> child = Layer::Create(); |
| 807 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); | 807 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
| 808 | 808 |
| 809 gfx::Transform rotationAboutYAxis; | 809 gfx::Transform rotationAboutYAxis; |
| 810 rotationAboutYAxis.RotateAboutYAxis(30); | 810 rotationAboutYAxis.RotateAboutYAxis(30); |
| 811 | 811 |
| 812 const gfx::Transform identityMatrix; | 812 const gfx::Transform identityMatrix; |
| 813 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); | 813 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); |
| 814 setLayerPropertiesForTesting(child.get(), rotationAboutYAxis, identityMatrix
, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 814 setLayerPropertiesForTesting(child.get(), rotationAboutYAxis, identityMatrix
, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 815 setLayerPropertiesForTesting(grandChild.get(), rotationAboutYAxis, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 815 setLayerPropertiesForTesting(grandChild.get(), rotationAboutYAxis, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 816 | 816 |
| 817 root->addChild(child); | 817 root->AddChild(child); |
| 818 child->addChild(grandChild); | 818 child->AddChild(grandChild); |
| 819 child->setForceRenderSurface(true); | 819 child->SetForceRenderSurface(true); |
| 820 | 820 |
| 821 // No layers in this test should preserve 3d. | 821 // No layers in this test should preserve 3d. |
| 822 ASSERT_FALSE(root->preserves3D()); | 822 ASSERT_FALSE(root->preserves_3d()); |
| 823 ASSERT_FALSE(child->preserves3D()); | 823 ASSERT_FALSE(child->preserves_3d()); |
| 824 ASSERT_FALSE(grandChild->preserves3D()); | 824 ASSERT_FALSE(grandChild->preserves_3d()); |
| 825 | 825 |
| 826 gfx::Transform expectedChildDrawTransform = rotationAboutYAxis; | 826 gfx::Transform expectedChildDrawTransform = rotationAboutYAxis; |
| 827 gfx::Transform expectedChildScreenSpaceTransform = rotationAboutYAxis; | 827 gfx::Transform expectedChildScreenSpaceTransform = rotationAboutYAxis; |
| 828 gfx::Transform expectedGrandChildDrawTransform = rotationAboutYAxis; // draw
s onto child's renderSurface | 828 gfx::Transform expectedGrandChildDrawTransform = rotationAboutYAxis; // draw
s onto child's renderSurface |
| 829 gfx::Transform flattenedRotationAboutY = rotationAboutYAxis; | 829 gfx::Transform flattenedRotationAboutY = rotationAboutYAxis; |
| 830 flattenedRotationAboutY.FlattenTo2d(); | 830 flattenedRotationAboutY.FlattenTo2d(); |
| 831 gfx::Transform expectedGrandChildScreenSpaceTransform = flattenedRotationAbo
utY * rotationAboutYAxis; | 831 gfx::Transform expectedGrandChildScreenSpaceTransform = flattenedRotationAbo
utY * rotationAboutYAxis; |
| 832 | 832 |
| 833 executeCalculateDrawProperties(root.get()); | 833 executeCalculateDrawProperties(root.get()); |
| 834 | 834 |
| 835 // The child's drawTransform should have been taken by its surface. | 835 // The child's drawTransform should have been taken by its surface. |
| 836 ASSERT_TRUE(child->renderSurface()); | 836 ASSERT_TRUE(child->render_surface()); |
| 837 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->renderSur
face()->draw_transform()); | 837 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->render_su
rface()->draw_transform()); |
| 838 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->re
nderSurface()->screen_space_transform()); | 838 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->re
nder_surface()->screen_space_transform()); |
| 839 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 839 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->draw_transform()); |
| 840 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->sc
reenSpaceTransform()); | 840 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->sc
reen_space_transform()); |
| 841 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildDrawTransform, grandChild-
>drawTransform()); | 841 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildDrawTransform, grandChild-
>draw_transform()); |
| 842 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildScreenSpaceTransform, gran
dChild->screenSpaceTransform()); | 842 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildScreenSpaceTransform, gran
dChild->screen_space_transform()); |
| 843 } | 843 } |
| 844 | 844 |
| 845 TEST(LayerTreeHostCommonTest, verifyTransformsForDegenerateIntermediateLayer) | 845 TEST(LayerTreeHostCommonTest, verifyTransformsForDegenerateIntermediateLayer) |
| 846 { | 846 { |
| 847 // A layer that is empty in one axis, but not the other, was accidentally sk
ipping a necessary translation. | 847 // A layer that is empty in one axis, but not the other, was accidentally sk
ipping a necessary translation. |
| 848 // Without that translation, the coordinate space of the layer's drawTransfo
rm is incorrect. | 848 // Without that translation, the coordinate space of the layer's drawTransfo
rm is incorrect. |
| 849 // | 849 // |
| 850 // Normally this isn't a problem, because the layer wouldn't be drawn anyway
, but if that layer becomes a renderSurface, then | 850 // Normally this isn't a problem, because the layer wouldn't be drawn anyway
, but if that layer becomes a renderSurface, then |
| 851 // its drawTransform is implicitly inherited by the rest of the subtree, whi
ch then is positioned incorrectly as a result. | 851 // its drawTransform is implicitly inherited by the rest of the subtree, whi
ch then is positioned incorrectly as a result. |
| 852 | 852 |
| 853 scoped_refptr<Layer> root = Layer::create(); | 853 scoped_refptr<Layer> root = Layer::Create(); |
| 854 scoped_refptr<Layer> child = Layer::create(); | 854 scoped_refptr<Layer> child = Layer::Create(); |
| 855 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); | 855 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
| 856 | 856 |
| 857 // The child height is zero, but has non-zero width that should be accounted
for while computing drawTransforms. | 857 // The child height is zero, but has non-zero width that should be accounted
for while computing drawTransforms. |
| 858 const gfx::Transform identityMatrix; | 858 const gfx::Transform identityMatrix; |
| 859 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); | 859 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); |
| 860 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 0), false); | 860 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 0), false); |
| 861 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 861 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 862 | 862 |
| 863 root->addChild(child); | 863 root->AddChild(child); |
| 864 child->addChild(grandChild); | 864 child->AddChild(grandChild); |
| 865 child->setForceRenderSurface(true); | 865 child->SetForceRenderSurface(true); |
| 866 | 866 |
| 867 executeCalculateDrawProperties(root.get()); | 867 executeCalculateDrawProperties(root.get()); |
| 868 | 868 |
| 869 ASSERT_TRUE(child->renderSurface()); | 869 ASSERT_TRUE(child->render_surface()); |
| 870 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->renderSurface()->draw
_transform()); // This is the real test, the rest are sanity checks. | 870 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->render_surface()->dra
w_transform()); // This is the real test, the rest are sanity checks. |
| 871 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 871 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->draw_transform()); |
| 872 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; | 872 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->draw_transform()
); |
| 873 } | 873 } |
| 874 | 874 |
| 875 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipped
Layer) | 875 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipped
Layer) |
| 876 { | 876 { |
| 877 scoped_refptr<Layer> parent = Layer::create(); | 877 scoped_refptr<Layer> parent = Layer::Create(); |
| 878 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 878 scoped_refptr<Layer> renderSurface1 = Layer::Create(); |
| 879 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); | 879 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
| 880 | 880 |
| 881 const gfx::Transform identityMatrix; | 881 const gfx::Transform identityMatrix; |
| 882 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 882 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 883 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 883 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 884 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false); | 884 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(30, 30), gfx::Size(10, 10), false); |
| 885 | 885 |
| 886 parent->addChild(renderSurface1); | 886 parent->AddChild(renderSurface1); |
| 887 parent->setMasksToBounds(true); | 887 parent->SetMasksToBounds(true); |
| 888 renderSurface1->addChild(child); | 888 renderSurface1->AddChild(child); |
| 889 renderSurface1->setForceRenderSurface(true); | 889 renderSurface1->SetForceRenderSurface(true); |
| 890 | 890 |
| 891 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 891 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 892 int dummyMaxTextureSize = 512; | 892 int dummyMaxTextureSize = 512; |
| 893 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 893 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 894 | 894 |
| 895 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate | 895 // The child layer's content is entirely outside the parent's clip rect, so
the intermediate |
| 896 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible | 896 // render surface should not be listed here, even if it was forced to be cre
ated. Render surfaces without children or visible |
| 897 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). | 897 // content are unexpected at draw time (e.g. we might try to create a conten
t texture of size 0). |
| 898 ASSERT_TRUE(parent->renderSurface()); | 898 ASSERT_TRUE(parent->render_surface()); |
| 899 ASSERT_FALSE(renderSurface1->renderSurface()); | 899 ASSERT_FALSE(renderSurface1->render_surface()); |
| 900 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 900 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
| 901 } | 901 } |
| 902 | 902 |
| 903 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) | 903 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild) |
| 904 { | 904 { |
| 905 scoped_refptr<Layer> parent = Layer::create(); | 905 scoped_refptr<Layer> parent = Layer::Create(); |
| 906 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 906 scoped_refptr<Layer> renderSurface1 = Layer::Create(); |
| 907 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); | 907 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
| 908 | 908 |
| 909 const gfx::Transform identityMatrix; | 909 const gfx::Transform identityMatrix; |
| 910 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 910 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 911 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 911 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 912 | 912 |
| 913 parent->addChild(renderSurface1); | 913 parent->AddChild(renderSurface1); |
| 914 renderSurface1->addChild(child); | 914 renderSurface1->AddChild(child); |
| 915 renderSurface1->setForceRenderSurface(true); | 915 renderSurface1->SetForceRenderSurface(true); |
| 916 renderSurface1->setOpacity(0); | 916 renderSurface1->SetOpacity(0); |
| 917 | 917 |
| 918 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 918 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 919 int dummyMaxTextureSize = 512; | 919 int dummyMaxTextureSize = 512; |
| 920 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 920 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 921 | 921 |
| 922 // Since the layer is transparent, renderSurface1->renderSurface() should no
t have gotten added anywhere. | 922 // Since the layer is transparent, renderSurface1->render_surface() should n
ot have gotten added anywhere. |
| 923 // Also, the drawable content rect should not have been extended by the chil
dren. | 923 // Also, the drawable content rect should not have been extended by the chil
dren. |
| 924 ASSERT_TRUE(parent->renderSurface()); | 924 ASSERT_TRUE(parent->render_surface()); |
| 925 EXPECT_EQ(0U, parent->renderSurface()->layer_list().size()); | 925 EXPECT_EQ(0U, parent->render_surface()->layer_list().size()); |
| 926 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 926 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
| 927 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 927 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
| 928 EXPECT_EQ(gfx::Rect(), parent->drawableContentRect()); | 928 EXPECT_EQ(gfx::Rect(), parent->drawable_content_rect()); |
| 929 } | 929 } |
| 930 | 930 |
| 931 TEST(LayerTreeHostCommonTest, verifyForceRenderSurface) | 931 TEST(LayerTreeHostCommonTest, verifyForceRenderSurface) |
| 932 { | 932 { |
| 933 scoped_refptr<Layer> parent = Layer::create(); | 933 scoped_refptr<Layer> parent = Layer::Create(); |
| 934 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 934 scoped_refptr<Layer> renderSurface1 = Layer::Create(); |
| 935 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); | 935 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
| 936 renderSurface1->setForceRenderSurface(true); | 936 renderSurface1->SetForceRenderSurface(true); |
| 937 | 937 |
| 938 const gfx::Transform identityMatrix; | 938 const gfx::Transform identityMatrix; |
| 939 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 939 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 940 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 940 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 941 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 941 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 942 | 942 |
| 943 parent->addChild(renderSurface1); | 943 parent->AddChild(renderSurface1); |
| 944 renderSurface1->addChild(child); | 944 renderSurface1->AddChild(child); |
| 945 | 945 |
| 946 // Sanity check before the actual test | 946 // Sanity check before the actual test |
| 947 EXPECT_FALSE(parent->renderSurface()); | 947 EXPECT_FALSE(parent->render_surface()); |
| 948 EXPECT_FALSE(renderSurface1->renderSurface()); | 948 EXPECT_FALSE(renderSurface1->render_surface()); |
| 949 | 949 |
| 950 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 950 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 951 int dummyMaxTextureSize = 512; | 951 int dummyMaxTextureSize = 512; |
| 952 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 952 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 953 | 953 |
| 954 // The root layer always creates a renderSurface | 954 // The root layer always creates a renderSurface |
| 955 EXPECT_TRUE(parent->renderSurface()); | 955 EXPECT_TRUE(parent->render_surface()); |
| 956 EXPECT_TRUE(renderSurface1->renderSurface()); | 956 EXPECT_TRUE(renderSurface1->render_surface()); |
| 957 EXPECT_EQ(2U, renderSurfaceLayerList.size()); | 957 EXPECT_EQ(2U, renderSurfaceLayerList.size()); |
| 958 | 958 |
| 959 renderSurfaceLayerList.clear(); | 959 renderSurfaceLayerList.clear(); |
| 960 renderSurface1->setForceRenderSurface(false); | 960 renderSurface1->SetForceRenderSurface(false); |
| 961 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 961 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 962 EXPECT_TRUE(parent->renderSurface()); | 962 EXPECT_TRUE(parent->render_surface()); |
| 963 EXPECT_FALSE(renderSurface1->renderSurface()); | 963 EXPECT_FALSE(renderSurface1->render_surface()); |
| 964 EXPECT_EQ(1U, renderSurfaceLayerList.size()); | 964 EXPECT_EQ(1U, renderSurfaceLayerList.size()); |
| 965 } | 965 } |
| 966 | 966 |
| 967 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
irectContainer) | 967 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
irectContainer) |
| 968 { | 968 { |
| 969 // This test checks for correct scroll compensation when the fixed-position
container | 969 // This test checks for correct scroll compensation when the fixed-position
container |
| 970 // is the direct parent of the fixed-position layer. | 970 // is the direct parent of the fixed-position layer. |
| 971 FakeImplProxy proxy; | 971 FakeImplProxy proxy; |
| 972 FakeLayerTreeHostImpl hostImpl(&proxy); | 972 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 973 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); | 973 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); |
| 974 LayerImpl* child = root->children()[0]; | 974 LayerImpl* child = root->children()[0]; |
| 975 LayerImpl* grandChild = child->children()[0]; | 975 LayerImpl* grandChild = child->children()[0]; |
| 976 | 976 |
| 977 child->setIsContainerForFixedPositionLayers(true); | 977 child->SetIsContainerForFixedPositionLayers(true); |
| 978 grandChild->setFixedToContainerLayer(true); | 978 grandChild->SetFixedToContainerLayer(true); |
| 979 | 979 |
| 980 // Case 1: scrollDelta of 0, 0 | 980 // Case 1: scrollDelta of 0, 0 |
| 981 child->setScrollDelta(gfx::Vector2d(0, 0)); | 981 child->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 982 executeCalculateDrawProperties(root.get()); | 982 executeCalculateDrawProperties(root.get()); |
| 983 | 983 |
| 984 gfx::Transform expectedChildTransform; | 984 gfx::Transform expectedChildTransform; |
| 985 gfx::Transform expectedGrandChildTransform = expectedChildTransform; | 985 gfx::Transform expectedGrandChildTransform = expectedChildTransform; |
| 986 | 986 |
| 987 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 987 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 988 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 988 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 989 | 989 |
| 990 // Case 2: scrollDelta of 10, 10 | 990 // Case 2: scrollDelta of 10, 10 |
| 991 child->setScrollDelta(gfx::Vector2d(10, 10)); | 991 child->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 992 executeCalculateDrawProperties(root.get()); | 992 executeCalculateDrawProperties(root.get()); |
| 993 | 993 |
| 994 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. | 994 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. |
| 995 expectedChildTransform.MakeIdentity(); | 995 expectedChildTransform.MakeIdentity(); |
| 996 expectedChildTransform.Translate(-10, -10); | 996 expectedChildTransform.Translate(-10, -10); |
| 997 | 997 |
| 998 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 998 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 999 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 999 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
ransformedDirectContainer) | 1002 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithT
ransformedDirectContainer) |
| 1003 { | 1003 { |
| 1004 // This test checks for correct scroll compensation when the fixed-position
container | 1004 // This test checks for correct scroll compensation when the fixed-position
container |
| 1005 // is the direct parent of the fixed-position layer, but that container is t
ransformed. | 1005 // is the direct parent of the fixed-position layer, but that container is t
ransformed. |
| 1006 // In this case, the fixed position element inherits the container's transfo
rm, | 1006 // In this case, the fixed position element inherits the container's transfo
rm, |
| 1007 // but the scrollDelta that has to be undone should not be affected by that
transform. | 1007 // but the scrollDelta that has to be undone should not be affected by that
transform. |
| 1008 // | 1008 // |
| 1009 // gfx::Transforms are in general non-commutative; using something like a no
n-uniform scale | 1009 // gfx::Transforms are in general non-commutative; using something like a no
n-uniform scale |
| 1010 // helps to verify that translations and non-uniform scales are applied in t
he correct | 1010 // helps to verify that translations and non-uniform scales are applied in t
he correct |
| 1011 // order. | 1011 // order. |
| 1012 FakeImplProxy proxy; | 1012 FakeImplProxy proxy; |
| 1013 FakeLayerTreeHostImpl hostImpl(&proxy); | 1013 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 1014 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); | 1014 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); |
| 1015 LayerImpl* child = root->children()[0]; | 1015 LayerImpl* child = root->children()[0]; |
| 1016 LayerImpl* grandChild = child->children()[0]; | 1016 LayerImpl* grandChild = child->children()[0]; |
| 1017 | 1017 |
| 1018 // This scale will cause child and grandChild to be effectively 200 x 800 wi
th respect to the renderTarget. | 1018 // This scale will cause child and grandChild to be effectively 200 x 800 wi
th respect to the renderTarget. |
| 1019 gfx::Transform nonUniformScale; | 1019 gfx::Transform nonUniformScale; |
| 1020 nonUniformScale.Scale(2, 8); | 1020 nonUniformScale.Scale(2, 8); |
| 1021 child->setTransform(nonUniformScale); | 1021 child->SetTransform(nonUniformScale); |
| 1022 | 1022 |
| 1023 child->setIsContainerForFixedPositionLayers(true); | 1023 child->SetIsContainerForFixedPositionLayers(true); |
| 1024 grandChild->setFixedToContainerLayer(true); | 1024 grandChild->SetFixedToContainerLayer(true); |
| 1025 | 1025 |
| 1026 // Case 1: scrollDelta of 0, 0 | 1026 // Case 1: scrollDelta of 0, 0 |
| 1027 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1027 child->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 1028 executeCalculateDrawProperties(root.get()); | 1028 executeCalculateDrawProperties(root.get()); |
| 1029 | 1029 |
| 1030 gfx::Transform expectedChildTransform; | 1030 gfx::Transform expectedChildTransform; |
| 1031 expectedChildTransform.PreconcatTransform(nonUniformScale); | 1031 expectedChildTransform.PreconcatTransform(nonUniformScale); |
| 1032 | 1032 |
| 1033 gfx::Transform expectedGrandChildTransform = expectedChildTransform; | 1033 gfx::Transform expectedGrandChildTransform = expectedChildTransform; |
| 1034 | 1034 |
| 1035 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1035 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1036 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1036 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1037 | 1037 |
| 1038 // Case 2: scrollDelta of 10, 20 | 1038 // Case 2: scrollDelta of 10, 20 |
| 1039 child->setScrollDelta(gfx::Vector2d(10, 20)); | 1039 child->SetScrollDelta(gfx::Vector2d(10, 20)); |
| 1040 executeCalculateDrawProperties(root.get()); | 1040 executeCalculateDrawProperties(root.get()); |
| 1041 | 1041 |
| 1042 // The child should be affected by scrollDelta, but the fixed position grand
Child should not be affected. | 1042 // The child should be affected by scrollDelta, but the fixed position grand
Child should not be affected. |
| 1043 expectedChildTransform.MakeIdentity(); | 1043 expectedChildTransform.MakeIdentity(); |
| 1044 expectedChildTransform.Translate(-10, -20); // scrollDelta | 1044 expectedChildTransform.Translate(-10, -20); // scrollDelta |
| 1045 expectedChildTransform.PreconcatTransform(nonUniformScale); | 1045 expectedChildTransform.PreconcatTransform(nonUniformScale); |
| 1046 | 1046 |
| 1047 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1047 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1048 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1048 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
istantContainer) | 1051 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
istantContainer) |
| 1052 { | 1052 { |
| 1053 // This test checks for correct scroll compensation when the fixed-position
container | 1053 // This test checks for correct scroll compensation when the fixed-position
container |
| 1054 // is NOT the direct parent of the fixed-position layer. | 1054 // is NOT the direct parent of the fixed-position layer. |
| 1055 FakeImplProxy proxy; | 1055 FakeImplProxy proxy; |
| 1056 FakeLayerTreeHostImpl hostImpl(&proxy); | 1056 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 1057 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); | 1057 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); |
| 1058 LayerImpl* child = root->children()[0]; | 1058 LayerImpl* child = root->children()[0]; |
| 1059 LayerImpl* grandChild = child->children()[0]; | 1059 LayerImpl* grandChild = child->children()[0]; |
| 1060 LayerImpl* greatGrandChild = grandChild->children()[0]; | 1060 LayerImpl* greatGrandChild = grandChild->children()[0]; |
| 1061 | 1061 |
| 1062 child->setIsContainerForFixedPositionLayers(true); | 1062 child->SetIsContainerForFixedPositionLayers(true); |
| 1063 grandChild->setPosition(gfx::PointF(8, 6)); | 1063 grandChild->SetPosition(gfx::PointF(8, 6)); |
| 1064 greatGrandChild->setFixedToContainerLayer(true); | 1064 greatGrandChild->SetFixedToContainerLayer(true); |
| 1065 | 1065 |
| 1066 // Case 1: scrollDelta of 0, 0 | 1066 // Case 1: scrollDelta of 0, 0 |
| 1067 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1067 child->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 1068 executeCalculateDrawProperties(root.get()); | 1068 executeCalculateDrawProperties(root.get()); |
| 1069 | 1069 |
| 1070 gfx::Transform expectedChildTransform; | 1070 gfx::Transform expectedChildTransform; |
| 1071 gfx::Transform expectedGrandChildTransform; | 1071 gfx::Transform expectedGrandChildTransform; |
| 1072 expectedGrandChildTransform.Translate(8, 6); | 1072 expectedGrandChildTransform.Translate(8, 6); |
| 1073 | 1073 |
| 1074 gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransfor
m; | 1074 gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransfor
m; |
| 1075 | 1075 |
| 1076 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1076 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1077 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1077 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1078 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1078 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->draw_transform()); |
| 1079 | 1079 |
| 1080 // Case 2: scrollDelta of 10, 10 | 1080 // Case 2: scrollDelta of 10, 10 |
| 1081 child->setScrollDelta(gfx::Vector2d(10, 10)); | 1081 child->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 1082 executeCalculateDrawProperties(root.get()); | 1082 executeCalculateDrawProperties(root.get()); |
| 1083 | 1083 |
| 1084 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. | 1084 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. |
| 1085 expectedChildTransform.MakeIdentity(); | 1085 expectedChildTransform.MakeIdentity(); |
| 1086 expectedChildTransform.Translate(-10, -10); | 1086 expectedChildTransform.Translate(-10, -10); |
| 1087 expectedGrandChildTransform.MakeIdentity(); | 1087 expectedGrandChildTransform.MakeIdentity(); |
| 1088 expectedGrandChildTransform.Translate(-2, -4); | 1088 expectedGrandChildTransform.Translate(-2, -4); |
| 1089 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1089 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1090 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1090 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1091 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1091 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->draw_transform()); |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
istantContainerAndTransforms) | 1094 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD
istantContainerAndTransforms) |
| 1095 { | 1095 { |
| 1096 // This test checks for correct scroll compensation when the fixed-position
container | 1096 // This test checks for correct scroll compensation when the fixed-position
container |
| 1097 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various | 1097 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various |
| 1098 // transforms that have to be processed in the correct order. | 1098 // transforms that have to be processed in the correct order. |
| 1099 FakeImplProxy proxy; | 1099 FakeImplProxy proxy; |
| 1100 FakeLayerTreeHostImpl hostImpl(&proxy); | 1100 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 1101 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); | 1101 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); |
| 1102 LayerImpl* child = root->children()[0]; | 1102 LayerImpl* child = root->children()[0]; |
| 1103 LayerImpl* grandChild = child->children()[0]; | 1103 LayerImpl* grandChild = child->children()[0]; |
| 1104 LayerImpl* greatGrandChild = grandChild->children()[0]; | 1104 LayerImpl* greatGrandChild = grandChild->children()[0]; |
| 1105 | 1105 |
| 1106 gfx::Transform rotationAboutZ; | 1106 gfx::Transform rotationAboutZ; |
| 1107 rotationAboutZ.RotateAboutZAxis(90); | 1107 rotationAboutZ.RotateAboutZAxis(90); |
| 1108 | 1108 |
| 1109 child->setIsContainerForFixedPositionLayers(true); | 1109 child->SetIsContainerForFixedPositionLayers(true); |
| 1110 child->setTransform(rotationAboutZ); | 1110 child->SetTransform(rotationAboutZ); |
| 1111 grandChild->setPosition(gfx::PointF(8, 6)); | 1111 grandChild->SetPosition(gfx::PointF(8, 6)); |
| 1112 grandChild->setTransform(rotationAboutZ); | 1112 grandChild->SetTransform(rotationAboutZ); |
| 1113 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. | 1113 greatGrandChild->SetFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. |
| 1114 | 1114 |
| 1115 // Case 1: scrollDelta of 0, 0 | 1115 // Case 1: scrollDelta of 0, 0 |
| 1116 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1116 child->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 1117 executeCalculateDrawProperties(root.get()); | 1117 executeCalculateDrawProperties(root.get()); |
| 1118 | 1118 |
| 1119 gfx::Transform expectedChildTransform; | 1119 gfx::Transform expectedChildTransform; |
| 1120 expectedChildTransform.PreconcatTransform(rotationAboutZ); | 1120 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
| 1121 | 1121 |
| 1122 gfx::Transform expectedGrandChildTransform; | 1122 gfx::Transform expectedGrandChildTransform; |
| 1123 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited | 1123 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited |
| 1124 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. | 1124 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. |
| 1125 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform | 1125 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform |
| 1126 | 1126 |
| 1127 gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransfor
m; | 1127 gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransfor
m; |
| 1128 | 1128 |
| 1129 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1129 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1130 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1130 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1131 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1131 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->draw_transform()); |
| 1132 | 1132 |
| 1133 // Case 2: scrollDelta of 10, 20 | 1133 // Case 2: scrollDelta of 10, 20 |
| 1134 child->setScrollDelta(gfx::Vector2d(10, 20)); | 1134 child->SetScrollDelta(gfx::Vector2d(10, 20)); |
| 1135 executeCalculateDrawProperties(root.get()); | 1135 executeCalculateDrawProperties(root.get()); |
| 1136 | 1136 |
| 1137 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. | 1137 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. |
| 1138 expectedChildTransform.MakeIdentity(); | 1138 expectedChildTransform.MakeIdentity(); |
| 1139 expectedChildTransform.Translate(-10, -20); // scrollDelta | 1139 expectedChildTransform.Translate(-10, -20); // scrollDelta |
| 1140 expectedChildTransform.PreconcatTransform(rotationAboutZ); | 1140 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
| 1141 | 1141 |
| 1142 expectedGrandChildTransform.MakeIdentity(); | 1142 expectedGrandChildTransform.MakeIdentity(); |
| 1143 expectedGrandChildTransform.Translate(-10, -20); // child's scrollDelta is i
nherited | 1143 expectedGrandChildTransform.Translate(-10, -20); // child's scrollDelta is i
nherited |
| 1144 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited | 1144 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited |
| 1145 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. | 1145 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. |
| 1146 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform | 1146 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform |
| 1147 | 1147 |
| 1148 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1148 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1149 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1149 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1150 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1150 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->draw_transform()); |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
ultipleScrollDeltas) | 1153 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
ultipleScrollDeltas) |
| 1154 { | 1154 { |
| 1155 // This test checks for correct scroll compensation when the fixed-position
container | 1155 // This test checks for correct scroll compensation when the fixed-position
container |
| 1156 // has multiple ancestors that have nonzero scrollDelta before reaching the
space where the layer is fixed. | 1156 // has multiple ancestors that have nonzero scrollDelta before reaching the
space where the layer is fixed. |
| 1157 // In this test, each scrollDelta occurs in a different space because of eac
h layer's local transform. | 1157 // In this test, each scrollDelta occurs in a different space because of eac
h layer's local transform. |
| 1158 // This test checks for correct scroll compensation when the fixed-position
container | 1158 // This test checks for correct scroll compensation when the fixed-position
container |
| 1159 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various | 1159 // is NOT the direct parent of the fixed-position layer, and the hierarchy h
as various |
| 1160 // transforms that have to be processed in the correct order. | 1160 // transforms that have to be processed in the correct order. |
| 1161 FakeImplProxy proxy; | 1161 FakeImplProxy proxy; |
| 1162 FakeLayerTreeHostImpl hostImpl(&proxy); | 1162 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 1163 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); | 1163 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); |
| 1164 LayerImpl* child = root->children()[0]; | 1164 LayerImpl* child = root->children()[0]; |
| 1165 LayerImpl* grandChild = child->children()[0]; | 1165 LayerImpl* grandChild = child->children()[0]; |
| 1166 LayerImpl* greatGrandChild = grandChild->children()[0]; | 1166 LayerImpl* greatGrandChild = grandChild->children()[0]; |
| 1167 | 1167 |
| 1168 gfx::Transform rotationAboutZ; | 1168 gfx::Transform rotationAboutZ; |
| 1169 rotationAboutZ.RotateAboutZAxis(90); | 1169 rotationAboutZ.RotateAboutZAxis(90); |
| 1170 | 1170 |
| 1171 child->setIsContainerForFixedPositionLayers(true); | 1171 child->SetIsContainerForFixedPositionLayers(true); |
| 1172 child->setTransform(rotationAboutZ); | 1172 child->SetTransform(rotationAboutZ); |
| 1173 grandChild->setPosition(gfx::PointF(8, 6)); | 1173 grandChild->SetPosition(gfx::PointF(8, 6)); |
| 1174 grandChild->setTransform(rotationAboutZ); | 1174 grandChild->SetTransform(rotationAboutZ); |
| 1175 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. | 1175 greatGrandChild->SetFixedToContainerLayer(true); // greatGrandChild is posit
ioned upside-down with respect to the renderTarget. |
| 1176 | 1176 |
| 1177 // Case 1: scrollDelta of 0, 0 | 1177 // Case 1: scrollDelta of 0, 0 |
| 1178 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1178 child->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 1179 executeCalculateDrawProperties(root.get()); | 1179 executeCalculateDrawProperties(root.get()); |
| 1180 | 1180 |
| 1181 gfx::Transform expectedChildTransform; | 1181 gfx::Transform expectedChildTransform; |
| 1182 expectedChildTransform.PreconcatTransform(rotationAboutZ); | 1182 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
| 1183 | 1183 |
| 1184 gfx::Transform expectedGrandChildTransform; | 1184 gfx::Transform expectedGrandChildTransform; |
| 1185 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited | 1185 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited |
| 1186 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. | 1186 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. |
| 1187 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform | 1187 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform |
| 1188 | 1188 |
| 1189 gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransfor
m; | 1189 gfx::Transform expectedGreatGrandChildTransform = expectedGrandChildTransfor
m; |
| 1190 | 1190 |
| 1191 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1191 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1192 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1192 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1193 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1193 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->draw_transform()); |
| 1194 | 1194 |
| 1195 // Case 2: scrollDelta of 10, 20 | 1195 // Case 2: scrollDelta of 10, 20 |
| 1196 child->setScrollDelta(gfx::Vector2d(10, 0)); | 1196 child->SetScrollDelta(gfx::Vector2d(10, 0)); |
| 1197 grandChild->setScrollDelta(gfx::Vector2d(5, 0)); | 1197 grandChild->SetScrollDelta(gfx::Vector2d(5, 0)); |
| 1198 executeCalculateDrawProperties(root.get()); | 1198 executeCalculateDrawProperties(root.get()); |
| 1199 | 1199 |
| 1200 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. | 1200 // Here the child and grandChild are affected by scrollDelta, but the fixed
position greatGrandChild should not be affected. |
| 1201 expectedChildTransform.MakeIdentity(); | 1201 expectedChildTransform.MakeIdentity(); |
| 1202 expectedChildTransform.Translate(-10, 0); // scrollDelta | 1202 expectedChildTransform.Translate(-10, 0); // scrollDelta |
| 1203 expectedChildTransform.PreconcatTransform(rotationAboutZ); | 1203 expectedChildTransform.PreconcatTransform(rotationAboutZ); |
| 1204 | 1204 |
| 1205 expectedGrandChildTransform.MakeIdentity(); | 1205 expectedGrandChildTransform.MakeIdentity(); |
| 1206 expectedGrandChildTransform.Translate(-10, 0); // child's scrollDelta is inh
erited | 1206 expectedGrandChildTransform.Translate(-10, 0); // child's scrollDelta is inh
erited |
| 1207 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited | 1207 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // child's l
ocal transform is inherited |
| 1208 expectedGrandChildTransform.Translate(-5, 0); // grandChild's scrollDelta | 1208 expectedGrandChildTransform.Translate(-5, 0); // grandChild's scrollDelta |
| 1209 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. | 1209 expectedGrandChildTransform.Translate(8, 6); // translation because of posit
ion occurs before layer's local transform. |
| 1210 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform | 1210 expectedGrandChildTransform.PreconcatTransform(rotationAboutZ); // grandChil
d's local transform |
| 1211 | 1211 |
| 1212 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1212 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1213 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1213 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1214 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1214 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->draw_transform()); |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
ntermediateSurfaceAndTransforms) | 1217 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithI
ntermediateSurfaceAndTransforms) |
| 1218 { | 1218 { |
| 1219 // This test checks for correct scroll compensation when the fixed-position
container | 1219 // This test checks for correct scroll compensation when the fixed-position
container |
| 1220 // contributes to a different renderSurface than the fixed-position layer. I
n this | 1220 // contributes to a different renderSurface than the fixed-position layer. I
n this |
| 1221 // case, the surface drawTransforms also have to be accounted for when check
ing the | 1221 // case, the surface drawTransforms also have to be accounted for when check
ing the |
| 1222 // scrollDelta. | 1222 // scrollDelta. |
| 1223 FakeImplProxy proxy; | 1223 FakeImplProxy proxy; |
| 1224 FakeLayerTreeHostImpl hostImpl(&proxy); | 1224 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 1225 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); | 1225 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); |
| 1226 LayerImpl* child = root->children()[0]; | 1226 LayerImpl* child = root->children()[0]; |
| 1227 LayerImpl* grandChild = child->children()[0]; | 1227 LayerImpl* grandChild = child->children()[0]; |
| 1228 LayerImpl* greatGrandChild = grandChild->children()[0]; | 1228 LayerImpl* greatGrandChild = grandChild->children()[0]; |
| 1229 | 1229 |
| 1230 child->setIsContainerForFixedPositionLayers(true); | 1230 child->SetIsContainerForFixedPositionLayers(true); |
| 1231 grandChild->setPosition(gfx::PointF(8, 6)); | 1231 grandChild->SetPosition(gfx::PointF(8, 6)); |
| 1232 grandChild->setForceRenderSurface(true); | 1232 grandChild->SetForceRenderSurface(true); |
| 1233 greatGrandChild->setFixedToContainerLayer(true); | 1233 greatGrandChild->SetFixedToContainerLayer(true); |
| 1234 greatGrandChild->setDrawsContent(true); | 1234 greatGrandChild->SetDrawsContent(true); |
| 1235 | 1235 |
| 1236 gfx::Transform rotationAboutZ; | 1236 gfx::Transform rotationAboutZ; |
| 1237 rotationAboutZ.RotateAboutZAxis(90); | 1237 rotationAboutZ.RotateAboutZAxis(90); |
| 1238 grandChild->setTransform(rotationAboutZ); | 1238 grandChild->SetTransform(rotationAboutZ); |
| 1239 | 1239 |
| 1240 // Case 1: scrollDelta of 0, 0 | 1240 // Case 1: scrollDelta of 0, 0 |
| 1241 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1241 child->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 1242 executeCalculateDrawProperties(root.get()); | 1242 executeCalculateDrawProperties(root.get()); |
| 1243 | 1243 |
| 1244 gfx::Transform expectedChildTransform; | 1244 gfx::Transform expectedChildTransform; |
| 1245 gfx::Transform expectedSurfaceDrawTransform; | 1245 gfx::Transform expectedSurfaceDrawTransform; |
| 1246 expectedSurfaceDrawTransform.Translate(8, 6); | 1246 expectedSurfaceDrawTransform.Translate(8, 6); |
| 1247 expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); | 1247 expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
| 1248 gfx::Transform expectedGrandChildTransform; | 1248 gfx::Transform expectedGrandChildTransform; |
| 1249 gfx::Transform expectedGreatGrandChildTransform; | 1249 gfx::Transform expectedGreatGrandChildTransform; |
| 1250 ASSERT_TRUE(grandChild->renderSurface()); | 1250 ASSERT_TRUE(grandChild->render_surface()); |
| 1251 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1251 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1252 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nderSurface()->draw_transform()); | 1252 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nder_surface()->draw_transform()); |
| 1253 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1253 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1254 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1254 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->draw_transform()); |
| 1255 | 1255 |
| 1256 // Case 2: scrollDelta of 10, 30 | 1256 // Case 2: scrollDelta of 10, 30 |
| 1257 child->setScrollDelta(gfx::Vector2d(10, 30)); | 1257 child->SetScrollDelta(gfx::Vector2d(10, 30)); |
| 1258 executeCalculateDrawProperties(root.get()); | 1258 executeCalculateDrawProperties(root.get()); |
| 1259 | 1259 |
| 1260 // Here the grandChild remains unchanged, because it scrolls along with the | 1260 // Here the grandChild remains unchanged, because it scrolls along with the |
| 1261 // renderSurface, and the translation is actually in the renderSurface. But,
the fixed | 1261 // renderSurface, and the translation is actually in the renderSurface. But,
the fixed |
| 1262 // position greatGrandChild is more awkward: its actually being drawn with r
espect to | 1262 // position greatGrandChild is more awkward: its actually being drawn with r
espect to |
| 1263 // the renderSurface, but it needs to remain fixed with resepct to a contain
er beyond | 1263 // the renderSurface, but it needs to remain fixed with resepct to a contain
er beyond |
| 1264 // that surface. So, the net result is that, unlike previous tests where the
fixed | 1264 // that surface. So, the net result is that, unlike previous tests where the
fixed |
| 1265 // position layer's transform remains unchanged, here the fixed position lay
er's | 1265 // position layer's transform remains unchanged, here the fixed position lay
er's |
| 1266 // transform explicitly contains the translation that cancels out the scroll
. | 1266 // transform explicitly contains the translation that cancels out the scroll
. |
| 1267 expectedChildTransform.MakeIdentity(); | 1267 expectedChildTransform.MakeIdentity(); |
| 1268 expectedChildTransform.Translate(-10, -30); // scrollDelta | 1268 expectedChildTransform.Translate(-10, -30); // scrollDelta |
| 1269 | 1269 |
| 1270 expectedSurfaceDrawTransform.MakeIdentity(); | 1270 expectedSurfaceDrawTransform.MakeIdentity(); |
| 1271 expectedSurfaceDrawTransform.Translate(-10, -30); // scrollDelta | 1271 expectedSurfaceDrawTransform.Translate(-10, -30); // scrollDelta |
| 1272 expectedSurfaceDrawTransform.Translate(8, 6); | 1272 expectedSurfaceDrawTransform.Translate(8, 6); |
| 1273 expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); | 1273 expectedSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
| 1274 | 1274 |
| 1275 // The rotation and its inverse are needed to place the scrollDelta compensa
tion in | 1275 // The rotation and its inverse are needed to place the scrollDelta compensa
tion in |
| 1276 // the correct space. This test will fail if the rotation/inverse are backwa
rds, too, | 1276 // the correct space. This test will fail if the rotation/inverse are backwa
rds, too, |
| 1277 // so it requires perfect order of operations. | 1277 // so it requires perfect order of operations. |
| 1278 expectedGreatGrandChildTransform.MakeIdentity(); | 1278 expectedGreatGrandChildTransform.MakeIdentity(); |
| 1279 expectedGreatGrandChildTransform.PreconcatTransform(inverse(rotationAboutZ))
; | 1279 expectedGreatGrandChildTransform.PreconcatTransform(inverse(rotationAboutZ))
; |
| 1280 expectedGreatGrandChildTransform.Translate(10, 30); // explicit canceling ou
t the scrollDelta that gets embedded in the fixed position layer's surface. | 1280 expectedGreatGrandChildTransform.Translate(10, 30); // explicit canceling ou
t the scrollDelta that gets embedded in the fixed position layer's surface. |
| 1281 expectedGreatGrandChildTransform.PreconcatTransform(rotationAboutZ); | 1281 expectedGreatGrandChildTransform.PreconcatTransform(rotationAboutZ); |
| 1282 | 1282 |
| 1283 ASSERT_TRUE(grandChild->renderSurface()); | 1283 ASSERT_TRUE(grandChild->render_surface()); |
| 1284 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1284 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1285 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nderSurface()->draw_transform()); | 1285 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re
nder_surface()->draw_transform()); |
| 1286 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1286 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1287 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1287 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->draw_transform()); |
| 1288 } | 1288 } |
| 1289 | 1289 |
| 1290 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
ultipleIntermediateSurfaces) | 1290 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithM
ultipleIntermediateSurfaces) |
| 1291 { | 1291 { |
| 1292 // This test checks for correct scroll compensation when the fixed-position
container | 1292 // This test checks for correct scroll compensation when the fixed-position
container |
| 1293 // contributes to a different renderSurface than the fixed-position layer, w
ith | 1293 // contributes to a different renderSurface than the fixed-position layer, w
ith |
| 1294 // additional renderSurfaces in-between. This checks that the conversion to
ancestor | 1294 // additional renderSurfaces in-between. This checks that the conversion to
ancestor |
| 1295 // surfaces is accumulated properly in the final matrix transform. | 1295 // surfaces is accumulated properly in the final matrix transform. |
| 1296 FakeImplProxy proxy; | 1296 FakeImplProxy proxy; |
| 1297 FakeLayerTreeHostImpl hostImpl(&proxy); | 1297 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 1298 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); | 1298 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); |
| 1299 LayerImpl* child = root->children()[0]; | 1299 LayerImpl* child = root->children()[0]; |
| 1300 LayerImpl* grandChild = child->children()[0]; | 1300 LayerImpl* grandChild = child->children()[0]; |
| 1301 LayerImpl* greatGrandChild = grandChild->children()[0]; | 1301 LayerImpl* greatGrandChild = grandChild->children()[0]; |
| 1302 | 1302 |
| 1303 // Add one more layer to the test tree for this scenario. | 1303 // Add one more layer to the test tree for this scenario. |
| 1304 { | 1304 { |
| 1305 gfx::Transform identity; | 1305 gfx::Transform identity; |
| 1306 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::create(hostImpl.ac
tiveTree(), 5); | 1306 scoped_ptr<LayerImpl> fixedPositionChild = LayerImpl::Create(hostImpl.ac
tiveTree(), 5); |
| 1307 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1307 setLayerPropertiesForTesting(fixedPositionChild.get(), identity, identit
y, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1308 greatGrandChild->addChild(fixedPositionChild.Pass()); | 1308 greatGrandChild->AddChild(fixedPositionChild.Pass()); |
| 1309 } | 1309 } |
| 1310 LayerImpl* fixedPositionChild = greatGrandChild->children()[0]; | 1310 LayerImpl* fixedPositionChild = greatGrandChild->children()[0]; |
| 1311 | 1311 |
| 1312 // Actually set up the scenario here. | 1312 // Actually set up the scenario here. |
| 1313 child->setIsContainerForFixedPositionLayers(true); | 1313 child->SetIsContainerForFixedPositionLayers(true); |
| 1314 grandChild->setPosition(gfx::PointF(8, 6)); | 1314 grandChild->SetPosition(gfx::PointF(8, 6)); |
| 1315 grandChild->setForceRenderSurface(true); | 1315 grandChild->SetForceRenderSurface(true); |
| 1316 greatGrandChild->setPosition(gfx::PointF(40, 60)); | 1316 greatGrandChild->SetPosition(gfx::PointF(40, 60)); |
| 1317 greatGrandChild->setForceRenderSurface(true); | 1317 greatGrandChild->SetForceRenderSurface(true); |
| 1318 fixedPositionChild->setFixedToContainerLayer(true); | 1318 fixedPositionChild->SetFixedToContainerLayer(true); |
| 1319 fixedPositionChild->setDrawsContent(true); | 1319 fixedPositionChild->SetDrawsContent(true); |
| 1320 | 1320 |
| 1321 // The additional rotations, which are non-commutative with translations, he
lp to | 1321 // The additional rotations, which are non-commutative with translations, he
lp to |
| 1322 // verify that we have correct order-of-operations in the final scroll compe
nsation. | 1322 // verify that we have correct order-of-operations in the final scroll compe
nsation. |
| 1323 // Note that rotating about the center of the layer ensures we do not accide
ntally | 1323 // Note that rotating about the center of the layer ensures we do not accide
ntally |
| 1324 // clip away layers that we want to test. | 1324 // clip away layers that we want to test. |
| 1325 gfx::Transform rotationAboutZ; | 1325 gfx::Transform rotationAboutZ; |
| 1326 rotationAboutZ.Translate(50, 50); | 1326 rotationAboutZ.Translate(50, 50); |
| 1327 rotationAboutZ.RotateAboutZAxis(90); | 1327 rotationAboutZ.RotateAboutZAxis(90); |
| 1328 rotationAboutZ.Translate(-50, -50); | 1328 rotationAboutZ.Translate(-50, -50); |
| 1329 grandChild->setTransform(rotationAboutZ); | 1329 grandChild->SetTransform(rotationAboutZ); |
| 1330 greatGrandChild->setTransform(rotationAboutZ); | 1330 greatGrandChild->SetTransform(rotationAboutZ); |
| 1331 | 1331 |
| 1332 // Case 1: scrollDelta of 0, 0 | 1332 // Case 1: scrollDelta of 0, 0 |
| 1333 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1333 child->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 1334 executeCalculateDrawProperties(root.get()); | 1334 executeCalculateDrawProperties(root.get()); |
| 1335 | 1335 |
| 1336 gfx::Transform expectedChildTransform; | 1336 gfx::Transform expectedChildTransform; |
| 1337 | 1337 |
| 1338 gfx::Transform expectedGrandChildSurfaceDrawTransform; | 1338 gfx::Transform expectedGrandChildSurfaceDrawTransform; |
| 1339 expectedGrandChildSurfaceDrawTransform.Translate(8, 6); | 1339 expectedGrandChildSurfaceDrawTransform.Translate(8, 6); |
| 1340 expectedGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); | 1340 expectedGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
| 1341 | 1341 |
| 1342 gfx::Transform expectedGrandChildTransform; | 1342 gfx::Transform expectedGrandChildTransform; |
| 1343 | 1343 |
| 1344 gfx::Transform expectedGreatGrandChildSurfaceDrawTransform; | 1344 gfx::Transform expectedGreatGrandChildSurfaceDrawTransform; |
| 1345 expectedGreatGrandChildSurfaceDrawTransform.Translate(40, 60); | 1345 expectedGreatGrandChildSurfaceDrawTransform.Translate(40, 60); |
| 1346 expectedGreatGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAbout
Z); | 1346 expectedGreatGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAbout
Z); |
| 1347 | 1347 |
| 1348 gfx::Transform expectedGreatGrandChildTransform; | 1348 gfx::Transform expectedGreatGrandChildTransform; |
| 1349 | 1349 |
| 1350 gfx::Transform expectedFixedPositionChildTransform; | 1350 gfx::Transform expectedFixedPositionChildTransform; |
| 1351 | 1351 |
| 1352 ASSERT_TRUE(grandChild->renderSurface()); | 1352 ASSERT_TRUE(grandChild->render_surface()); |
| 1353 ASSERT_TRUE(greatGrandChild->renderSurface()); | 1353 ASSERT_TRUE(greatGrandChild->render_surface()); |
| 1354 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1354 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1355 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->renderSurface()->draw_transform()); | 1355 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->render_surface()->draw_transform()); |
| 1356 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1356 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1357 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->renderSurface()->draw_transform()); | 1357 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->render_surface()->draw_transform()); |
| 1358 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1358 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->draw_transform()); |
| 1359 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo
sitionChild->drawTransform()); | 1359 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo
sitionChild->draw_transform()); |
| 1360 | 1360 |
| 1361 // Case 2: scrollDelta of 10, 30 | 1361 // Case 2: scrollDelta of 10, 30 |
| 1362 child->setScrollDelta(gfx::Vector2d(10, 30)); | 1362 child->SetScrollDelta(gfx::Vector2d(10, 30)); |
| 1363 executeCalculateDrawProperties(root.get()); | 1363 executeCalculateDrawProperties(root.get()); |
| 1364 | 1364 |
| 1365 expectedChildTransform.MakeIdentity(); | 1365 expectedChildTransform.MakeIdentity(); |
| 1366 expectedChildTransform.Translate(-10, -30); // scrollDelta | 1366 expectedChildTransform.Translate(-10, -30); // scrollDelta |
| 1367 | 1367 |
| 1368 expectedGrandChildSurfaceDrawTransform.MakeIdentity(); | 1368 expectedGrandChildSurfaceDrawTransform.MakeIdentity(); |
| 1369 expectedGrandChildSurfaceDrawTransform.Translate(-10, -30); // scrollDelta | 1369 expectedGrandChildSurfaceDrawTransform.Translate(-10, -30); // scrollDelta |
| 1370 expectedGrandChildSurfaceDrawTransform.Translate(8, 6); | 1370 expectedGrandChildSurfaceDrawTransform.Translate(8, 6); |
| 1371 expectedGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); | 1371 expectedGrandChildSurfaceDrawTransform.PreconcatTransform(rotationAboutZ); |
| 1372 | 1372 |
| 1373 // grandChild, greatGrandChild, and greatGrandChild's surface are not expect
ed to | 1373 // grandChild, greatGrandChild, and greatGrandChild's surface are not expect
ed to |
| 1374 // change, since they are all not fixed, and they are all drawn with respect
to | 1374 // change, since they are all not fixed, and they are all drawn with respect
to |
| 1375 // grandChild's surface that already has the scrollDelta accounted for. | 1375 // grandChild's surface that already has the scrollDelta accounted for. |
| 1376 | 1376 |
| 1377 // But the great-great grandchild, "fixedPositionChild", should have a trans
form that explicitly cancels out the scrollDelta. | 1377 // But the great-great grandchild, "fixedPositionChild", should have a trans
form that explicitly cancels out the scrollDelta. |
| 1378 // The expected transform is: | 1378 // The expected transform is: |
| 1379 // compoundDrawTransform.inverse() * translate(positive scrollDelta) * com
poundOriginTransform | 1379 // compoundDrawTransform.inverse() * translate(positive scrollDelta) * com
poundOriginTransform |
| 1380 gfx::Transform compoundDrawTransform; // transform from greatGrandChildSurfa
ce's origin to the root surface. | 1380 gfx::Transform compoundDrawTransform; // transform from greatGrandChildSurfa
ce's origin to the root surface. |
| 1381 compoundDrawTransform.Translate(8, 6); // origin translation of grandChild | 1381 compoundDrawTransform.Translate(8, 6); // origin translation of grandChild |
| 1382 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gra
ndChild | 1382 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gra
ndChild |
| 1383 compoundDrawTransform.Translate(40, 60); // origin translation of greatGrand
Child | 1383 compoundDrawTransform.Translate(40, 60); // origin translation of greatGrand
Child |
| 1384 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gre
atGrandChild | 1384 compoundDrawTransform.PreconcatTransform(rotationAboutZ); // rotation of gre
atGrandChild |
| 1385 | 1385 |
| 1386 expectedFixedPositionChildTransform.MakeIdentity(); | 1386 expectedFixedPositionChildTransform.MakeIdentity(); |
| 1387 expectedFixedPositionChildTransform.PreconcatTransform(inverse(compoundDrawT
ransform)); | 1387 expectedFixedPositionChildTransform.PreconcatTransform(inverse(compoundDrawT
ransform)); |
| 1388 expectedFixedPositionChildTransform.Translate(10, 30); // explicit canceling
out the scrollDelta that gets embedded in the fixed position layer's surface. | 1388 expectedFixedPositionChildTransform.Translate(10, 30); // explicit canceling
out the scrollDelta that gets embedded in the fixed position layer's surface. |
| 1389 expectedFixedPositionChildTransform.PreconcatTransform(compoundDrawTransform
); | 1389 expectedFixedPositionChildTransform.PreconcatTransform(compoundDrawTransform
); |
| 1390 | 1390 |
| 1391 ASSERT_TRUE(grandChild->renderSurface()); | 1391 ASSERT_TRUE(grandChild->render_surface()); |
| 1392 ASSERT_TRUE(greatGrandChild->renderSurface()); | 1392 ASSERT_TRUE(greatGrandChild->render_surface()); |
| 1393 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1393 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1394 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->renderSurface()->draw_transform()); | 1394 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran
dChild->render_surface()->draw_transform()); |
| 1395 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1395 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1396 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->renderSurface()->draw_transform()); | 1396 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform,
greatGrandChild->render_surface()->draw_transform()); |
| 1397 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->drawTransform()); | 1397 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand
Child->draw_transform()); |
| 1398 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo
sitionChild->drawTransform()); | 1398 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo
sitionChild->draw_transform()); |
| 1399 } | 1399 } |
| 1400 | 1400 |
| 1401 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC
ontainerLayerThatHasSurface) | 1401 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithC
ontainerLayerThatHasSurface) |
| 1402 { | 1402 { |
| 1403 // This test checks for correct scroll compensation when the fixed-position
container | 1403 // This test checks for correct scroll compensation when the fixed-position
container |
| 1404 // itself has a renderSurface. In this case, the container layer should be t
reated | 1404 // itself has a renderSurface. In this case, the container layer should be t
reated |
| 1405 // like a layer that contributes to a renderTarget, and that renderTarget | 1405 // like a layer that contributes to a renderTarget, and that renderTarget |
| 1406 // is completely irrelevant; it should not affect the scroll compensation. | 1406 // is completely irrelevant; it should not affect the scroll compensation. |
| 1407 FakeImplProxy proxy; | 1407 FakeImplProxy proxy; |
| 1408 FakeLayerTreeHostImpl hostImpl(&proxy); | 1408 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 1409 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); | 1409 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); |
| 1410 LayerImpl* child = root->children()[0]; | 1410 LayerImpl* child = root->children()[0]; |
| 1411 LayerImpl* grandChild = child->children()[0]; | 1411 LayerImpl* grandChild = child->children()[0]; |
| 1412 | 1412 |
| 1413 child->setIsContainerForFixedPositionLayers(true); | 1413 child->SetIsContainerForFixedPositionLayers(true); |
| 1414 child->setForceRenderSurface(true); | 1414 child->SetForceRenderSurface(true); |
| 1415 grandChild->setFixedToContainerLayer(true); | 1415 grandChild->SetFixedToContainerLayer(true); |
| 1416 grandChild->setDrawsContent(true); | 1416 grandChild->SetDrawsContent(true); |
| 1417 | 1417 |
| 1418 // Case 1: scrollDelta of 0, 0 | 1418 // Case 1: scrollDelta of 0, 0 |
| 1419 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1419 child->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 1420 executeCalculateDrawProperties(root.get()); | 1420 executeCalculateDrawProperties(root.get()); |
| 1421 | 1421 |
| 1422 gfx::Transform expectedSurfaceDrawTransform; | 1422 gfx::Transform expectedSurfaceDrawTransform; |
| 1423 expectedSurfaceDrawTransform.Translate(0, 0); | 1423 expectedSurfaceDrawTransform.Translate(0, 0); |
| 1424 gfx::Transform expectedChildTransform; | 1424 gfx::Transform expectedChildTransform; |
| 1425 gfx::Transform expectedGrandChildTransform; | 1425 gfx::Transform expectedGrandChildTransform; |
| 1426 ASSERT_TRUE(child->renderSurface()); | 1426 ASSERT_TRUE(child->render_surface()); |
| 1427 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS
urface()->draw_transform()); | 1427 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->render_
surface()->draw_transform()); |
| 1428 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1428 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1429 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1429 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1430 | 1430 |
| 1431 // Case 2: scrollDelta of 10, 10 | 1431 // Case 2: scrollDelta of 10, 10 |
| 1432 child->setScrollDelta(gfx::Vector2d(10, 10)); | 1432 child->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 1433 executeCalculateDrawProperties(root.get()); | 1433 executeCalculateDrawProperties(root.get()); |
| 1434 | 1434 |
| 1435 // The surface is translated by scrollDelta, the child transform doesn't cha
nge | 1435 // The surface is translated by scrollDelta, the child transform doesn't cha
nge |
| 1436 // because it scrolls along with the surface, but the fixed position grandCh
ild | 1436 // because it scrolls along with the surface, but the fixed position grandCh
ild |
| 1437 // needs to compensate for the scroll translation. | 1437 // needs to compensate for the scroll translation. |
| 1438 expectedSurfaceDrawTransform.MakeIdentity(); | 1438 expectedSurfaceDrawTransform.MakeIdentity(); |
| 1439 expectedSurfaceDrawTransform.Translate(-10, -10); | 1439 expectedSurfaceDrawTransform.Translate(-10, -10); |
| 1440 expectedGrandChildTransform.MakeIdentity(); | 1440 expectedGrandChildTransform.MakeIdentity(); |
| 1441 expectedGrandChildTransform.Translate(10, 10); | 1441 expectedGrandChildTransform.Translate(10, 10); |
| 1442 | 1442 |
| 1443 ASSERT_TRUE(child->renderSurface()); | 1443 ASSERT_TRUE(child->render_surface()); |
| 1444 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS
urface()->draw_transform()); | 1444 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->render_
surface()->draw_transform()); |
| 1445 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1445 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1446 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1446 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1447 } | 1447 } |
| 1448 | 1448 |
| 1449 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
sAlsoFixedPositionContainer) | 1449 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatI
sAlsoFixedPositionContainer) |
| 1450 { | 1450 { |
| 1451 // This test checks the scenario where a fixed-position layer also happens t
o be a | 1451 // This test checks the scenario where a fixed-position layer also happens t
o be a |
| 1452 // container itself for a descendant fixed position layer. In particular, th
e layer | 1452 // container itself for a descendant fixed position layer. In particular, th
e layer |
| 1453 // should not accidentally be fixed to itself. | 1453 // should not accidentally be fixed to itself. |
| 1454 FakeImplProxy proxy; | 1454 FakeImplProxy proxy; |
| 1455 FakeLayerTreeHostImpl hostImpl(&proxy); | 1455 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 1456 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); | 1456 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); |
| 1457 LayerImpl* child = root->children()[0]; | 1457 LayerImpl* child = root->children()[0]; |
| 1458 LayerImpl* grandChild = child->children()[0]; | 1458 LayerImpl* grandChild = child->children()[0]; |
| 1459 | 1459 |
| 1460 child->setIsContainerForFixedPositionLayers(true); | 1460 child->SetIsContainerForFixedPositionLayers(true); |
| 1461 grandChild->setFixedToContainerLayer(true); | 1461 grandChild->SetFixedToContainerLayer(true); |
| 1462 | 1462 |
| 1463 // This should not confuse the grandChild. If correct, the grandChild would
still be considered fixed to its container (i.e. "child"). | 1463 // This should not confuse the grandChild. If correct, the grandChild would
still be considered fixed to its container (i.e. "child"). |
| 1464 grandChild->setIsContainerForFixedPositionLayers(true); | 1464 grandChild->SetIsContainerForFixedPositionLayers(true); |
| 1465 | 1465 |
| 1466 // Case 1: scrollDelta of 0, 0 | 1466 // Case 1: scrollDelta of 0, 0 |
| 1467 child->setScrollDelta(gfx::Vector2d(0, 0)); | 1467 child->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 1468 executeCalculateDrawProperties(root.get()); | 1468 executeCalculateDrawProperties(root.get()); |
| 1469 | 1469 |
| 1470 gfx::Transform expectedChildTransform; | 1470 gfx::Transform expectedChildTransform; |
| 1471 gfx::Transform expectedGrandChildTransform; | 1471 gfx::Transform expectedGrandChildTransform; |
| 1472 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1472 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1473 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1473 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1474 | 1474 |
| 1475 // Case 2: scrollDelta of 10, 10 | 1475 // Case 2: scrollDelta of 10, 10 |
| 1476 child->setScrollDelta(gfx::Vector2d(10, 10)); | 1476 child->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 1477 executeCalculateDrawProperties(root.get()); | 1477 executeCalculateDrawProperties(root.get()); |
| 1478 | 1478 |
| 1479 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. | 1479 // Here the child is affected by scrollDelta, but the fixed position grandCh
ild should not be affected. |
| 1480 expectedChildTransform.MakeIdentity(); | 1480 expectedChildTransform.MakeIdentity(); |
| 1481 expectedChildTransform.Translate(-10, -10); | 1481 expectedChildTransform.Translate(-10, -10); |
| 1482 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 1482 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 1483 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1483 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1484 } | 1484 } |
| 1485 | 1485 |
| 1486 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
asNoContainer) | 1486 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH
asNoContainer) |
| 1487 { | 1487 { |
| 1488 // This test checks scroll compensation when a fixed-position layer does not
find any | 1488 // This test checks scroll compensation when a fixed-position layer does not
find any |
| 1489 // ancestor that is a "containerForFixedPositionLayers". In this situation,
the layer should | 1489 // ancestor that is a "containerForFixedPositionLayers". In this situation,
the layer should |
| 1490 // be fixed to the viewport -- not the rootLayer, which may have transforms
of its own. | 1490 // be fixed to the viewport -- not the rootLayer, which may have transforms
of its own. |
| 1491 FakeImplProxy proxy; | 1491 FakeImplProxy proxy; |
| 1492 FakeLayerTreeHostImpl hostImpl(&proxy); | 1492 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 1493 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); | 1493 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(&hostImpl); |
| 1494 LayerImpl* child = root->children()[0]; | 1494 LayerImpl* child = root->children()[0]; |
| 1495 LayerImpl* grandChild = child->children()[0]; | 1495 LayerImpl* grandChild = child->children()[0]; |
| 1496 | 1496 |
| 1497 gfx::Transform rotationByZ; | 1497 gfx::Transform rotationByZ; |
| 1498 rotationByZ.RotateAboutZAxis(90); | 1498 rotationByZ.RotateAboutZAxis(90); |
| 1499 | 1499 |
| 1500 root->setTransform(rotationByZ); | 1500 root->SetTransform(rotationByZ); |
| 1501 grandChild->setFixedToContainerLayer(true); | 1501 grandChild->SetFixedToContainerLayer(true); |
| 1502 | 1502 |
| 1503 // Case 1: root scrollDelta of 0, 0 | 1503 // Case 1: root scrollDelta of 0, 0 |
| 1504 root->setScrollDelta(gfx::Vector2d(0, 0)); | 1504 root->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 1505 executeCalculateDrawProperties(root.get()); | 1505 executeCalculateDrawProperties(root.get()); |
| 1506 | 1506 |
| 1507 gfx::Transform identityMatrix; | 1507 gfx::Transform identityMatrix; |
| 1508 | 1508 |
| 1509 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 1509 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->draw_transform()); |
| 1510 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform())
; | 1510 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->draw_transform()
); |
| 1511 | 1511 |
| 1512 // Case 2: root scrollDelta of 10, 10 | 1512 // Case 2: root scrollDelta of 10, 10 |
| 1513 root->setScrollDelta(gfx::Vector2d(10, 20)); | 1513 root->SetScrollDelta(gfx::Vector2d(10, 20)); |
| 1514 executeCalculateDrawProperties(root.get()); | 1514 executeCalculateDrawProperties(root.get()); |
| 1515 | 1515 |
| 1516 // The child is affected by scrollDelta, but it is already implcitly account
ed for by | 1516 // The child is affected by scrollDelta, but it is already implcitly account
ed for by |
| 1517 // the child's target surface (i.e. the root renderSurface). The grandChild
is not | 1517 // the child's target surface (i.e. the root renderSurface). The grandChild
is not |
| 1518 // affected by the scrollDelta, so its drawTransform needs to explicitly | 1518 // affected by the scrollDelta, so its drawTransform needs to explicitly |
| 1519 // inverse-compensate for the scroll that's embedded in the target surface. | 1519 // inverse-compensate for the scroll that's embedded in the target surface. |
| 1520 gfx::Transform expectedGrandChildTransform; | 1520 gfx::Transform expectedGrandChildTransform; |
| 1521 expectedGrandChildTransform.PreconcatTransform(inverse(rotationByZ)); | 1521 expectedGrandChildTransform.PreconcatTransform(inverse(rotationByZ)); |
| 1522 expectedGrandChildTransform.Translate(10, 20); // explicit canceling out the
scrollDelta that gets embedded in the fixed position layer's surface. | 1522 expectedGrandChildTransform.Translate(10, 20); // explicit canceling out the
scrollDelta that gets embedded in the fixed position layer's surface. |
| 1523 expectedGrandChildTransform.PreconcatTransform(rotationByZ); | 1523 expectedGrandChildTransform.PreconcatTransform(rotationByZ); |
| 1524 | 1524 |
| 1525 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); | 1525 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->draw_transform()); |
| 1526 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
wTransform()); | 1526 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra
w_transform()); |
| 1527 } | 1527 } |
| 1528 | 1528 |
| 1529 TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) | 1529 TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) |
| 1530 { | 1530 { |
| 1531 // The entire subtree of layers that are outside the clipRect should be cull
ed away, | 1531 // The entire subtree of layers that are outside the clipRect should be cull
ed away, |
| 1532 // and should not affect the renderSurfaceLayerList. | 1532 // and should not affect the renderSurfaceLayerList. |
| 1533 // | 1533 // |
| 1534 // The test tree is set up as follows: | 1534 // The test tree is set up as follows: |
| 1535 // - all layers except the leafNodes are forced to be a new renderSurface t
hat have something to draw. | 1535 // - all layers except the leafNodes are forced to be a new renderSurface t
hat have something to draw. |
| 1536 // - parent is a large container layer. | 1536 // - parent is a large container layer. |
| 1537 // - child has masksToBounds=true to cause clipping. | 1537 // - child has masksToBounds=true to cause clipping. |
| 1538 // - grandChild is positioned outside of the child's bounds | 1538 // - grandChild is positioned outside of the child's bounds |
| 1539 // - greatGrandChild is also kept outside child's bounds. | 1539 // - greatGrandChild is also kept outside child's bounds. |
| 1540 // | 1540 // |
| 1541 // In this configuration, grandChild and greatGrandChild are completely outs
ide the | 1541 // In this configuration, grandChild and greatGrandChild are completely outs
ide the |
| 1542 // clipRect, and they should never get scheduled on the list of renderSurfac
es. | 1542 // clipRect, and they should never get scheduled on the list of renderSurfac
es. |
| 1543 // | 1543 // |
| 1544 | 1544 |
| 1545 const gfx::Transform identityMatrix; | 1545 const gfx::Transform identityMatrix; |
| 1546 scoped_refptr<Layer> parent = Layer::create(); | 1546 scoped_refptr<Layer> parent = Layer::Create(); |
| 1547 scoped_refptr<Layer> child = Layer::create(); | 1547 scoped_refptr<Layer> child = Layer::Create(); |
| 1548 scoped_refptr<Layer> grandChild = Layer::create(); | 1548 scoped_refptr<Layer> grandChild = Layer::Create(); |
| 1549 scoped_refptr<Layer> greatGrandChild = Layer::create(); | 1549 scoped_refptr<Layer> greatGrandChild = Layer::Create(); |
| 1550 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1550 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1551 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1551 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1552 parent->addChild(child); | 1552 parent->AddChild(child); |
| 1553 child->addChild(grandChild); | 1553 child->AddChild(grandChild); |
| 1554 grandChild->addChild(greatGrandChild); | 1554 grandChild->AddChild(greatGrandChild); |
| 1555 | 1555 |
| 1556 // leafNode1 ensures that parent and child are kept on the renderSurfaceLaye
rList, | 1556 // leafNode1 ensures that parent and child are kept on the renderSurfaceLaye
rList, |
| 1557 // even though grandChild and greatGrandChild should be clipped. | 1557 // even though grandChild and greatGrandChild should be clipped. |
| 1558 child->addChild(leafNode1); | 1558 child->AddChild(leafNode1); |
| 1559 greatGrandChild->addChild(leafNode2); | 1559 greatGrandChild->AddChild(leafNode2); |
| 1560 | 1560 |
| 1561 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); | 1561 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); |
| 1562 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1562 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
| 1563 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(45, 45), gfx::Size(10, 10), false); | 1563 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(45, 45), gfx::Size(10, 10), false); |
| 1564 setLayerPropertiesForTesting(greatGrandChild.get(), identityMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1564 setLayerPropertiesForTesting(greatGrandChild.get(), identityMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 1565 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); | 1565 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); |
| 1566 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1566 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
| 1567 | 1567 |
| 1568 child->setMasksToBounds(true); | 1568 child->SetMasksToBounds(true); |
| 1569 child->setOpacity(0.4f); | 1569 child->SetOpacity(0.4f); |
| 1570 child->setForceRenderSurface(true); | 1570 child->SetForceRenderSurface(true); |
| 1571 grandChild->setOpacity(0.5); | 1571 grandChild->SetOpacity(0.5); |
| 1572 greatGrandChild->setOpacity(0.4f); | 1572 greatGrandChild->SetOpacity(0.4f); |
| 1573 | 1573 |
| 1574 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1574 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 1575 int dummyMaxTextureSize = 512; | 1575 int dummyMaxTextureSize = 512; |
| 1576 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1576 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 1577 | 1577 |
| 1578 ASSERT_EQ(2U, renderSurfaceLayerList.size()); | 1578 ASSERT_EQ(2U, renderSurfaceLayerList.size()); |
| 1579 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1579 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
| 1580 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1580 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
| 1581 } | 1581 } |
| 1582 | 1582 |
| 1583 TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) | 1583 TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent) |
| 1584 { | 1584 { |
| 1585 // When a renderSurface has a clipRect, it is used to clip the contentRect | 1585 // When a renderSurface has a clipRect, it is used to clip the contentRect |
| 1586 // of the surface. When the renderSurface is animating its transforms, then | 1586 // of the surface. When the renderSurface is animating its transforms, then |
| 1587 // the contentRect's position in the clipRect is not defined on the main | 1587 // the contentRect's position in the clipRect is not defined on the main |
| 1588 // thread, and its contentRect should not be clipped. | 1588 // thread, and its contentRect should not be clipped. |
| 1589 | 1589 |
| 1590 // The test tree is set up as follows: | 1590 // The test tree is set up as follows: |
| 1591 // - parent is a container layer that masksToBounds=true to cause clipping. | 1591 // - parent is a container layer that masksToBounds=true to cause clipping. |
| 1592 // - child is a renderSurface, which has a clipRect set to the bounds of th
e parent. | 1592 // - child is a renderSurface, which has a clipRect set to the bounds of th
e parent. |
| 1593 // - grandChild is a renderSurface, and the only visible content in child.
It is positioned outside of the clipRect from parent. | 1593 // - grandChild is a renderSurface, and the only visible content in child.
It is positioned outside of the clipRect from parent. |
| 1594 | 1594 |
| 1595 // In this configuration, grandChild should be outside the clipped | 1595 // In this configuration, grandChild should be outside the clipped |
| 1596 // contentRect of the child, making grandChild not appear in the | 1596 // contentRect of the child, making grandChild not appear in the |
| 1597 // renderSurfaceLayerList. However, when we place an animation on the child, | 1597 // renderSurfaceLayerList. However, when we place an animation on the child, |
| 1598 // this clipping should be avoided and we should keep the grandChild | 1598 // this clipping should be avoided and we should keep the grandChild |
| 1599 // in the renderSurfaceLayerList. | 1599 // in the renderSurfaceLayerList. |
| 1600 | 1600 |
| 1601 const gfx::Transform identityMatrix; | 1601 const gfx::Transform identityMatrix; |
| 1602 scoped_refptr<Layer> parent = Layer::create(); | 1602 scoped_refptr<Layer> parent = Layer::Create(); |
| 1603 scoped_refptr<Layer> child = Layer::create(); | 1603 scoped_refptr<Layer> child = Layer::Create(); |
| 1604 scoped_refptr<Layer> grandChild = Layer::create(); | 1604 scoped_refptr<Layer> grandChild = Layer::Create(); |
| 1605 scoped_refptr<LayerWithForcedDrawsContent> leafNode = make_scoped_refptr(new
LayerWithForcedDrawsContent()); | 1605 scoped_refptr<LayerWithForcedDrawsContent> leafNode = make_scoped_refptr(new
LayerWithForcedDrawsContent()); |
| 1606 parent->addChild(child); | 1606 parent->AddChild(child); |
| 1607 child->addChild(grandChild); | 1607 child->AddChild(grandChild); |
| 1608 grandChild->addChild(leafNode); | 1608 grandChild->AddChild(leafNode); |
| 1609 | 1609 |
| 1610 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1610 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1611 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1611 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
| 1612 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(200, 200), gfx::Size(10, 10), false); | 1612 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(200, 200), gfx::Size(10, 10), false); |
| 1613 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1613 setLayerPropertiesForTesting(leafNode.get(), identityMatrix, identityMatrix,
gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 1614 | 1614 |
| 1615 parent->setMasksToBounds(true); | 1615 parent->SetMasksToBounds(true); |
| 1616 child->setOpacity(0.4f); | 1616 child->SetOpacity(0.4f); |
| 1617 child->setForceRenderSurface(true); | 1617 child->SetForceRenderSurface(true); |
| 1618 grandChild->setOpacity(0.4f); | 1618 grandChild->SetOpacity(0.4f); |
| 1619 grandChild->setForceRenderSurface(true); | 1619 grandChild->SetForceRenderSurface(true); |
| 1620 | 1620 |
| 1621 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1621 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 1622 int dummyMaxTextureSize = 512; | 1622 int dummyMaxTextureSize = 512; |
| 1623 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1623 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 1624 | 1624 |
| 1625 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. | 1625 // Without an animation, we should cull child and grandChild from the render
SurfaceLayerList. |
| 1626 ASSERT_EQ(1U, renderSurfaceLayerList.size()); | 1626 ASSERT_EQ(1U, renderSurfaceLayerList.size()); |
| 1627 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1627 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
| 1628 | 1628 |
| 1629 // Now put an animating transform on child. | 1629 // Now put an animating transform on child. |
| 1630 addAnimatedTransformToController(*child->layerAnimationController(), 10, 30,
0); | 1630 addAnimatedTransformToController(*child->layer_animation_controller(), 10, 3
0, 0); |
| 1631 | 1631 |
| 1632 parent->clearRenderSurface(); | 1632 parent->ClearRenderSurface(); |
| 1633 child->clearRenderSurface(); | 1633 child->ClearRenderSurface(); |
| 1634 grandChild->clearRenderSurface(); | 1634 grandChild->ClearRenderSurface(); |
| 1635 renderSurfaceLayerList.clear(); | 1635 renderSurfaceLayerList.clear(); |
| 1636 | 1636 |
| 1637 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1637 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 1638 | 1638 |
| 1639 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. | 1639 // With an animating transform, we should keep child and grandChild in the r
enderSurfaceLayerList. |
| 1640 ASSERT_EQ(3U, renderSurfaceLayerList.size()); | 1640 ASSERT_EQ(3U, renderSurfaceLayerList.size()); |
| 1641 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 1641 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
| 1642 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); | 1642 EXPECT_EQ(child->id(), renderSurfaceLayerList[1]->id()); |
| 1643 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); | 1643 EXPECT_EQ(grandChild->id(), renderSurfaceLayerList[2]->id()); |
| 1644 } | 1644 } |
| 1645 | 1645 |
| 1646 TEST(LayerTreeHostCommonTest, verifyIsClippedIsSetCorrectly) | 1646 TEST(LayerTreeHostCommonTest, verifyIsClippedIsSetCorrectly) |
| 1647 { | 1647 { |
| 1648 // Layer's isClipped() property is set to true when: | 1648 // Layer's IsClipped() property is set to true when: |
| 1649 // - the layer clips its subtree, e.g. masks to bounds, | 1649 // - the layer clips its subtree, e.g. masks to bounds, |
| 1650 // - the layer is clipped by an ancestor that contributes to the same | 1650 // - the layer is clipped by an ancestor that contributes to the same |
| 1651 // renderTarget, | 1651 // renderTarget, |
| 1652 // - a surface is clipped by an ancestor that contributes to the same | 1652 // - a surface is clipped by an ancestor that contributes to the same |
| 1653 // renderTarget. | 1653 // renderTarget. |
| 1654 // | 1654 // |
| 1655 // In particular, for a layer that owns a renderSurface: | 1655 // In particular, for a layer that owns a renderSurface: |
| 1656 // - the renderSurfarce inherits any clip from ancestors, and does NOT | 1656 // - the renderSurfarce inherits any clip from ancestors, and does NOT |
| 1657 // pass that clipped status to the layer itself. | 1657 // pass that clipped status to the layer itself. |
| 1658 // - but if the layer itself masks to bounds, it is considered clipped | 1658 // - but if the layer itself masks to bounds, it is considered clipped |
| 1659 // and propagates the clip to the subtree. | 1659 // and propagates the clip to the subtree. |
| 1660 | 1660 |
| 1661 const gfx::Transform identityMatrix; | 1661 const gfx::Transform identityMatrix; |
| 1662 scoped_refptr<Layer> root = Layer::create(); | 1662 scoped_refptr<Layer> root = Layer::Create(); |
| 1663 scoped_refptr<Layer> parent = Layer::create(); | 1663 scoped_refptr<Layer> parent = Layer::Create(); |
| 1664 scoped_refptr<Layer> child1 = Layer::create(); | 1664 scoped_refptr<Layer> child1 = Layer::Create(); |
| 1665 scoped_refptr<Layer> child2 = Layer::create(); | 1665 scoped_refptr<Layer> child2 = Layer::Create(); |
| 1666 scoped_refptr<Layer> grandChild = Layer::create(); | 1666 scoped_refptr<Layer> grandChild = Layer::Create(); |
| 1667 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1667 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1668 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1668 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1669 root->addChild(parent); | 1669 root->AddChild(parent); |
| 1670 parent->addChild(child1); | 1670 parent->AddChild(child1); |
| 1671 parent->addChild(child2); | 1671 parent->AddChild(child2); |
| 1672 child1->addChild(grandChild); | 1672 child1->AddChild(grandChild); |
| 1673 child2->addChild(leafNode2); | 1673 child2->AddChild(leafNode2); |
| 1674 grandChild->addChild(leafNode1); | 1674 grandChild->AddChild(leafNode1); |
| 1675 | 1675 |
| 1676 child2->setForceRenderSurface(true); | 1676 child2->SetForceRenderSurface(true); |
| 1677 | 1677 |
| 1678 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1678 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1679 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1679 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1680 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1680 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1681 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1681 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1682 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1682 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1683 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1683 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1684 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 1684 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 1685 | 1685 |
| 1686 // Case 1: nothing is clipped except the root renderSurface. | 1686 // Case 1: nothing is clipped except the root renderSurface. |
| 1687 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1687 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 1688 int dummyMaxTextureSize = 512; | 1688 int dummyMaxTextureSize = 512; |
| 1689 LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1689 LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 1690 | 1690 |
| 1691 ASSERT_TRUE(root->renderSurface()); | 1691 ASSERT_TRUE(root->render_surface()); |
| 1692 ASSERT_TRUE(child2->renderSurface()); | 1692 ASSERT_TRUE(child2->render_surface()); |
| 1693 | 1693 |
| 1694 EXPECT_FALSE(root->isClipped()); | 1694 EXPECT_FALSE(root->is_clipped()); |
| 1695 EXPECT_TRUE(root->renderSurface()->is_clipped()); | 1695 EXPECT_TRUE(root->render_surface()->is_clipped()); |
| 1696 EXPECT_FALSE(parent->isClipped()); | 1696 EXPECT_FALSE(parent->is_clipped()); |
| 1697 EXPECT_FALSE(child1->isClipped()); | 1697 EXPECT_FALSE(child1->is_clipped()); |
| 1698 EXPECT_FALSE(child2->isClipped()); | 1698 EXPECT_FALSE(child2->is_clipped()); |
| 1699 EXPECT_FALSE(child2->renderSurface()->is_clipped()); | 1699 EXPECT_FALSE(child2->render_surface()->is_clipped()); |
| 1700 EXPECT_FALSE(grandChild->isClipped()); | 1700 EXPECT_FALSE(grandChild->is_clipped()); |
| 1701 EXPECT_FALSE(leafNode1->isClipped()); | 1701 EXPECT_FALSE(leafNode1->is_clipped()); |
| 1702 EXPECT_FALSE(leafNode2->isClipped()); | 1702 EXPECT_FALSE(leafNode2->is_clipped()); |
| 1703 | 1703 |
| 1704 // Case 2: parent masksToBounds, so the parent, child1, and child2's | 1704 // Case 2: parent masksToBounds, so the parent, child1, and child2's |
| 1705 // surface are clipped. But layers that contribute to child2's surface are | 1705 // surface are clipped. But layers that contribute to child2's surface are |
| 1706 // not clipped explicitly because child2's surface already accounts for | 1706 // not clipped explicitly because child2's surface already accounts for |
| 1707 // that clip. | 1707 // that clip. |
| 1708 renderSurfaceLayerList.clear(); | 1708 renderSurfaceLayerList.clear(); |
| 1709 parent->setMasksToBounds(true); | 1709 parent->SetMasksToBounds(true); |
| 1710 LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1710 LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 1711 | 1711 |
| 1712 ASSERT_TRUE(root->renderSurface()); | 1712 ASSERT_TRUE(root->render_surface()); |
| 1713 ASSERT_TRUE(child2->renderSurface()); | 1713 ASSERT_TRUE(child2->render_surface()); |
| 1714 | 1714 |
| 1715 EXPECT_FALSE(root->isClipped()); | 1715 EXPECT_FALSE(root->is_clipped()); |
| 1716 EXPECT_TRUE(root->renderSurface()->is_clipped()); | 1716 EXPECT_TRUE(root->render_surface()->is_clipped()); |
| 1717 EXPECT_TRUE(parent->isClipped()); | 1717 EXPECT_TRUE(parent->is_clipped()); |
| 1718 EXPECT_TRUE(child1->isClipped()); | 1718 EXPECT_TRUE(child1->is_clipped()); |
| 1719 EXPECT_FALSE(child2->isClipped()); | 1719 EXPECT_FALSE(child2->is_clipped()); |
| 1720 EXPECT_TRUE(child2->renderSurface()->is_clipped()); | 1720 EXPECT_TRUE(child2->render_surface()->is_clipped()); |
| 1721 EXPECT_TRUE(grandChild->isClipped()); | 1721 EXPECT_TRUE(grandChild->is_clipped()); |
| 1722 EXPECT_TRUE(leafNode1->isClipped()); | 1722 EXPECT_TRUE(leafNode1->is_clipped()); |
| 1723 EXPECT_FALSE(leafNode2->isClipped()); | 1723 EXPECT_FALSE(leafNode2->is_clipped()); |
| 1724 | 1724 |
| 1725 // Case 3: child2 masksToBounds. The layer and subtree are clipped, and | 1725 // Case 3: child2 masksToBounds. The layer and subtree are clipped, and |
| 1726 // child2's renderSurface is not clipped. | 1726 // child2's renderSurface is not clipped. |
| 1727 renderSurfaceLayerList.clear(); | 1727 renderSurfaceLayerList.clear(); |
| 1728 parent->setMasksToBounds(false); | 1728 parent->SetMasksToBounds(false); |
| 1729 child2->setMasksToBounds(true); | 1729 child2->SetMasksToBounds(true); |
| 1730 LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1730 LayerTreeHostCommon::calculateDrawProperties(root.get(), parent->bounds(), 1
, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 1731 | 1731 |
| 1732 ASSERT_TRUE(root->renderSurface()); | 1732 ASSERT_TRUE(root->render_surface()); |
| 1733 ASSERT_TRUE(child2->renderSurface()); | 1733 ASSERT_TRUE(child2->render_surface()); |
| 1734 | 1734 |
| 1735 EXPECT_FALSE(root->isClipped()); | 1735 EXPECT_FALSE(root->is_clipped()); |
| 1736 EXPECT_TRUE(root->renderSurface()->is_clipped()); | 1736 EXPECT_TRUE(root->render_surface()->is_clipped()); |
| 1737 EXPECT_FALSE(parent->isClipped()); | 1737 EXPECT_FALSE(parent->is_clipped()); |
| 1738 EXPECT_FALSE(child1->isClipped()); | 1738 EXPECT_FALSE(child1->is_clipped()); |
| 1739 EXPECT_TRUE(child2->isClipped()); | 1739 EXPECT_TRUE(child2->is_clipped()); |
| 1740 EXPECT_FALSE(child2->renderSurface()->is_clipped()); | 1740 EXPECT_FALSE(child2->render_surface()->is_clipped()); |
| 1741 EXPECT_FALSE(grandChild->isClipped()); | 1741 EXPECT_FALSE(grandChild->is_clipped()); |
| 1742 EXPECT_FALSE(leafNode1->isClipped()); | 1742 EXPECT_FALSE(leafNode1->is_clipped()); |
| 1743 EXPECT_TRUE(leafNode2->isClipped()); | 1743 EXPECT_TRUE(leafNode2->is_clipped()); |
| 1744 } | 1744 } |
| 1745 | 1745 |
| 1746 TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers) | 1746 TEST(LayerTreeHostCommonTest, verifydrawable_content_rectForLayers) |
| 1747 { | 1747 { |
| 1748 // Verify that layers get the appropriate drawableContentRect when their par
ent masksToBounds is true. | 1748 // Verify that layers get the appropriate drawableContentRect when their par
ent masksToBounds is true. |
| 1749 // | 1749 // |
| 1750 // grandChild1 - completely inside the region; drawableContentRect should
be the layer rect expressed in target space. | 1750 // grandChild1 - completely inside the region; drawableContentRect should
be the layer rect expressed in target space. |
| 1751 // grandChild2 - partially clipped but NOT masksToBounds; the clipRect wil
l be the intersection of layerBounds and the mask region. | 1751 // grandChild2 - partially clipped but NOT masksToBounds; the clipRect wil
l be the intersection of layerBounds and the mask region. |
| 1752 // grandChild3 - partially clipped and masksToBounds; the drawableContentR
ect will still be the intersection of layerBounds and the mask region. | 1752 // grandChild3 - partially clipped and masksToBounds; the drawableContentR
ect will still be the intersection of layerBounds and the mask region. |
| 1753 // grandChild4 - outside parent's clipRect; the drawableContentRect should
be empty. | 1753 // grandChild4 - outside parent's clipRect; the drawableContentRect should
be empty. |
| 1754 // | 1754 // |
| 1755 | 1755 |
| 1756 const gfx::Transform identityMatrix; | 1756 const gfx::Transform identityMatrix; |
| 1757 scoped_refptr<Layer> parent = Layer::create(); | 1757 scoped_refptr<Layer> parent = Layer::Create(); |
| 1758 scoped_refptr<Layer> child = Layer::create(); | 1758 scoped_refptr<Layer> child = Layer::Create(); |
| 1759 scoped_refptr<Layer> grandChild1 = Layer::create(); | 1759 scoped_refptr<Layer> grandChild1 = Layer::Create(); |
| 1760 scoped_refptr<Layer> grandChild2 = Layer::create(); | 1760 scoped_refptr<Layer> grandChild2 = Layer::Create(); |
| 1761 scoped_refptr<Layer> grandChild3 = Layer::create(); | 1761 scoped_refptr<Layer> grandChild3 = Layer::Create(); |
| 1762 scoped_refptr<Layer> grandChild4 = Layer::create(); | 1762 scoped_refptr<Layer> grandChild4 = Layer::Create(); |
| 1763 | 1763 |
| 1764 parent->addChild(child); | 1764 parent->AddChild(child); |
| 1765 child->addChild(grandChild1); | 1765 child->AddChild(grandChild1); |
| 1766 child->addChild(grandChild2); | 1766 child->AddChild(grandChild2); |
| 1767 child->addChild(grandChild3); | 1767 child->AddChild(grandChild3); |
| 1768 child->addChild(grandChild4); | 1768 child->AddChild(grandChild4); |
| 1769 | 1769 |
| 1770 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); | 1770 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); |
| 1771 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1771 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
| 1772 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(10, 10), false); | 1772 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(10, 10), false); |
| 1773 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(15, 15), gfx::Size(10, 10), false); | 1773 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(15, 15), gfx::Size(10, 10), false); |
| 1774 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(15, 15), gfx::Size(10, 10), false); | 1774 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(15, 15), gfx::Size(10, 10), false); |
| 1775 setLayerPropertiesForTesting(grandChild4.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(45, 45), gfx::Size(10, 10), false); | 1775 setLayerPropertiesForTesting(grandChild4.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(45, 45), gfx::Size(10, 10), false); |
| 1776 | 1776 |
| 1777 child->setMasksToBounds(true); | 1777 child->SetMasksToBounds(true); |
| 1778 grandChild3->setMasksToBounds(true); | 1778 grandChild3->SetMasksToBounds(true); |
| 1779 | 1779 |
| 1780 // Force everyone to be a render surface. | 1780 // Force everyone to be a render surface. |
| 1781 child->setOpacity(0.4f); | 1781 child->SetOpacity(0.4f); |
| 1782 grandChild1->setOpacity(0.5); | 1782 grandChild1->SetOpacity(0.5); |
| 1783 grandChild2->setOpacity(0.5); | 1783 grandChild2->SetOpacity(0.5); |
| 1784 grandChild3->setOpacity(0.5); | 1784 grandChild3->SetOpacity(0.5); |
| 1785 grandChild4->setOpacity(0.5); | 1785 grandChild4->SetOpacity(0.5); |
| 1786 | 1786 |
| 1787 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1787 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 1788 int dummyMaxTextureSize = 512; | 1788 int dummyMaxTextureSize = 512; |
| 1789 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1789 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 1790 | 1790 |
| 1791 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(5, 5), gfx::Size(10, 10)), grandChild1->
drawableContentRect()); | 1791 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(5, 5), gfx::Size(10, 10)), grandChild1->
drawable_content_rect()); |
| 1792 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3->
drawableContentRect()); | 1792 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3->
drawable_content_rect()); |
| 1793 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3->
drawableContentRect()); | 1793 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3->
drawable_content_rect()); |
| 1794 EXPECT_TRUE(grandChild4->drawableContentRect().IsEmpty()); | 1794 EXPECT_TRUE(grandChild4->drawable_content_rect().IsEmpty()); |
| 1795 } | 1795 } |
| 1796 | 1796 |
| 1797 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) | 1797 TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces) |
| 1798 { | 1798 { |
| 1799 // Verify that renderSurfaces (and their layers) get the appropriate clipRec
ts when their parent masksToBounds is true. | 1799 // Verify that renderSurfaces (and their layers) get the appropriate clipRec
ts when their parent masksToBounds is true. |
| 1800 // | 1800 // |
| 1801 // Layers that own renderSurfaces (at least for now) do not inherit any clip
ping; | 1801 // Layers that own renderSurfaces (at least for now) do not inherit any clip
ping; |
| 1802 // instead the surface will enforce the clip for the entire subtree. They ma
y still | 1802 // instead the surface will enforce the clip for the entire subtree. They ma
y still |
| 1803 // have a clipRect of their own layer bounds, however, if masksToBounds was
true. | 1803 // have a clipRect of their own layer bounds, however, if masksToBounds was
true. |
| 1804 // | 1804 // |
| 1805 | 1805 |
| 1806 const gfx::Transform identityMatrix; | 1806 const gfx::Transform identityMatrix; |
| 1807 scoped_refptr<Layer> parent = Layer::create(); | 1807 scoped_refptr<Layer> parent = Layer::Create(); |
| 1808 scoped_refptr<Layer> child = Layer::create(); | 1808 scoped_refptr<Layer> child = Layer::Create(); |
| 1809 scoped_refptr<Layer> grandChild1 = Layer::create(); | 1809 scoped_refptr<Layer> grandChild1 = Layer::Create(); |
| 1810 scoped_refptr<Layer> grandChild2 = Layer::create(); | 1810 scoped_refptr<Layer> grandChild2 = Layer::Create(); |
| 1811 scoped_refptr<Layer> grandChild3 = Layer::create(); | 1811 scoped_refptr<Layer> grandChild3 = Layer::Create(); |
| 1812 scoped_refptr<Layer> grandChild4 = Layer::create(); | 1812 scoped_refptr<Layer> grandChild4 = Layer::Create(); |
| 1813 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1813 scoped_refptr<LayerWithForcedDrawsContent> leafNode1 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1814 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1814 scoped_refptr<LayerWithForcedDrawsContent> leafNode2 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1815 scoped_refptr<LayerWithForcedDrawsContent> leafNode3 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1815 scoped_refptr<LayerWithForcedDrawsContent> leafNode3 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1816 scoped_refptr<LayerWithForcedDrawsContent> leafNode4 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); | 1816 scoped_refptr<LayerWithForcedDrawsContent> leafNode4 = make_scoped_refptr(ne
w LayerWithForcedDrawsContent()); |
| 1817 | 1817 |
| 1818 parent->addChild(child); | 1818 parent->AddChild(child); |
| 1819 child->addChild(grandChild1); | 1819 child->AddChild(grandChild1); |
| 1820 child->addChild(grandChild2); | 1820 child->AddChild(grandChild2); |
| 1821 child->addChild(grandChild3); | 1821 child->AddChild(grandChild3); |
| 1822 child->addChild(grandChild4); | 1822 child->AddChild(grandChild4); |
| 1823 | 1823 |
| 1824 // the leaf nodes ensure that these grandChildren become renderSurfaces for
this test. | 1824 // the leaf nodes ensure that these grandChildren become renderSurfaces for
this test. |
| 1825 grandChild1->addChild(leafNode1); | 1825 grandChild1->AddChild(leafNode1); |
| 1826 grandChild2->addChild(leafNode2); | 1826 grandChild2->AddChild(leafNode2); |
| 1827 grandChild3->addChild(leafNode3); | 1827 grandChild3->AddChild(leafNode3); |
| 1828 grandChild4->addChild(leafNode4); | 1828 grandChild4->AddChild(leafNode4); |
| 1829 | 1829 |
| 1830 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); | 1830 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(500, 500), false); |
| 1831 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); | 1831 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(20, 20), false); |
| 1832 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(10, 10), false); | 1832 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(10, 10), false); |
| 1833 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(15, 15), gfx::Size(10, 10), false); | 1833 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(15, 15), gfx::Size(10, 10), false); |
| 1834 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(15, 15), gfx::Size(10, 10), false); | 1834 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(15, 15), gfx::Size(10, 10), false); |
| 1835 setLayerPropertiesForTesting(grandChild4.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(45, 45), gfx::Size(10, 10), false); | 1835 setLayerPropertiesForTesting(grandChild4.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(45, 45), gfx::Size(10, 10), false); |
| 1836 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1836 setLayerPropertiesForTesting(leafNode1.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 1837 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1837 setLayerPropertiesForTesting(leafNode2.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 1838 setLayerPropertiesForTesting(leafNode3.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1838 setLayerPropertiesForTesting(leafNode3.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 1839 setLayerPropertiesForTesting(leafNode4.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); | 1839 setLayerPropertiesForTesting(leafNode4.get(), identityMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), false); |
| 1840 | 1840 |
| 1841 child->setMasksToBounds(true); | 1841 child->SetMasksToBounds(true); |
| 1842 grandChild3->setMasksToBounds(true); | 1842 grandChild3->SetMasksToBounds(true); |
| 1843 grandChild4->setMasksToBounds(true); | 1843 grandChild4->SetMasksToBounds(true); |
| 1844 | 1844 |
| 1845 // Force everyone to be a render surface. | 1845 // Force everyone to be a render surface. |
| 1846 child->setOpacity(0.4f); | 1846 child->SetOpacity(0.4f); |
| 1847 child->setForceRenderSurface(true); | 1847 child->SetForceRenderSurface(true); |
| 1848 grandChild1->setOpacity(0.5); | 1848 grandChild1->SetOpacity(0.5); |
| 1849 grandChild1->setForceRenderSurface(true); | 1849 grandChild1->SetForceRenderSurface(true); |
| 1850 grandChild2->setOpacity(0.5); | 1850 grandChild2->SetOpacity(0.5); |
| 1851 grandChild2->setForceRenderSurface(true); | 1851 grandChild2->SetForceRenderSurface(true); |
| 1852 grandChild3->setOpacity(0.5); | 1852 grandChild3->SetOpacity(0.5); |
| 1853 grandChild3->setForceRenderSurface(true); | 1853 grandChild3->SetForceRenderSurface(true); |
| 1854 grandChild4->setOpacity(0.5); | 1854 grandChild4->SetOpacity(0.5); |
| 1855 grandChild4->setForceRenderSurface(true); | 1855 grandChild4->SetForceRenderSurface(true); |
| 1856 | 1856 |
| 1857 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 1857 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 1858 int dummyMaxTextureSize = 512; | 1858 int dummyMaxTextureSize = 512; |
| 1859 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 1859 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 1860 | 1860 |
| 1861 ASSERT_TRUE(grandChild1->renderSurface()); | 1861 ASSERT_TRUE(grandChild1->render_surface()); |
| 1862 ASSERT_TRUE(grandChild2->renderSurface()); | 1862 ASSERT_TRUE(grandChild2->render_surface()); |
| 1863 ASSERT_TRUE(grandChild3->renderSurface()); | 1863 ASSERT_TRUE(grandChild3->render_surface()); |
| 1864 EXPECT_FALSE(grandChild4->renderSurface()); // Because grandChild4 is entire
ly clipped, it is expected to not have a renderSurface. | 1864 EXPECT_FALSE(grandChild4->render_surface()); // Because grandChild4 is entir
ely clipped, it is expected to not have a renderSurface. |
| 1865 | 1865 |
| 1866 // Surfaces are clipped by their parent, but un-affected by the owning layer
's masksToBounds. | 1866 // Surfaces are clipped by their parent, but un-affected by the owning layer
's masksToBounds. |
| 1867 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild1->
renderSurface()->clip_rect()); | 1867 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild1->
render_surface()->clip_rect()); |
| 1868 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild2->
renderSurface()->clip_rect()); | 1868 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild2->
render_surface()->clip_rect()); |
| 1869 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild3->
renderSurface()->clip_rect()); | 1869 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(0, 0), gfx::Size(20, 20)), grandChild3->
render_surface()->clip_rect()); |
| 1870 } | 1870 } |
| 1871 | 1871 |
| 1872 TEST(LayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy) | 1872 TEST(LayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy) |
| 1873 { | 1873 { |
| 1874 scoped_refptr<Layer> parent = Layer::create(); | 1874 scoped_refptr<Layer> parent = Layer::Create(); |
| 1875 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 1875 scoped_refptr<Layer> renderSurface1 = Layer::Create(); |
| 1876 scoped_refptr<Layer> renderSurface2 = Layer::create(); | 1876 scoped_refptr<Layer> renderSurface2 = Layer::Create(); |
| 1877 scoped_refptr<Layer> childOfRoot = Layer::create(); | 1877 scoped_refptr<Layer> childOfRoot = Layer::Create(); |
| 1878 scoped_refptr<Layer> childOfRS1 = Layer::create(); | 1878 scoped_refptr<Layer> childOfRS1 = Layer::Create(); |
| 1879 scoped_refptr<Layer> childOfRS2 = Layer::create(); | 1879 scoped_refptr<Layer> childOfRS2 = Layer::Create(); |
| 1880 scoped_refptr<Layer> grandChildOfRoot = Layer::create(); | 1880 scoped_refptr<Layer> grandChildOfRoot = Layer::Create(); |
| 1881 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS1 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); | 1881 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS1 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
| 1882 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS2 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); | 1882 scoped_refptr<LayerWithForcedDrawsContent> grandChildOfRS2 = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
| 1883 parent->addChild(renderSurface1); | 1883 parent->AddChild(renderSurface1); |
| 1884 parent->addChild(childOfRoot); | 1884 parent->AddChild(childOfRoot); |
| 1885 renderSurface1->addChild(childOfRS1); | 1885 renderSurface1->AddChild(childOfRS1); |
| 1886 renderSurface1->addChild(renderSurface2); | 1886 renderSurface1->AddChild(renderSurface2); |
| 1887 renderSurface2->addChild(childOfRS2); | 1887 renderSurface2->AddChild(childOfRS2); |
| 1888 childOfRoot->addChild(grandChildOfRoot); | 1888 childOfRoot->AddChild(grandChildOfRoot); |
| 1889 childOfRS1->addChild(grandChildOfRS1); | 1889 childOfRS1->AddChild(grandChildOfRS1); |
| 1890 childOfRS2->addChild(grandChildOfRS2); | 1890 childOfRS2->AddChild(grandChildOfRS2); |
| 1891 | 1891 |
| 1892 // Make our render surfaces. | 1892 // Make our render surfaces. |
| 1893 renderSurface1->setForceRenderSurface(true); | 1893 renderSurface1->SetForceRenderSurface(true); |
| 1894 renderSurface2->setForceRenderSurface(true); | 1894 renderSurface2->SetForceRenderSurface(true); |
| 1895 | 1895 |
| 1896 gfx::Transform layerTransform; | 1896 gfx::Transform layerTransform; |
| 1897 layerTransform.Translate(1, 1); | 1897 layerTransform.Translate(1, 1); |
| 1898 gfx::Transform sublayerTransform; | 1898 gfx::Transform sublayerTransform; |
| 1899 sublayerTransform.Scale3d(10, 1, 1); | 1899 sublayerTransform.Scale3d(10, 1, 1); |
| 1900 | 1900 |
| 1901 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform
, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1901 setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform
, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
| 1902 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1902 setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
| 1903 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1903 setLayerPropertiesForTesting(renderSurface2.get(), layerTransform, sublayerT
ransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
| 1904 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran
sform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1904 setLayerPropertiesForTesting(childOfRoot.get(), layerTransform, sublayerTran
sform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
| 1905 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1905 setLayerPropertiesForTesting(childOfRS1.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
| 1906 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1906 setLayerPropertiesForTesting(childOfRS2.get(), layerTransform, sublayerTrans
form, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
| 1907 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false)
; | 1907 setLayerPropertiesForTesting(grandChildOfRoot.get(), layerTransform, sublaye
rTransform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false)
; |
| 1908 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1908 setLayerPropertiesForTesting(grandChildOfRS1.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
| 1909 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); | 1909 setLayerPropertiesForTesting(grandChildOfRS2.get(), layerTransform, sublayer
Transform, gfx::PointF(0.25, 0), gfx::PointF(2.5, 0), gfx::Size(10, 10), false); |
| 1910 | 1910 |
| 1911 // Put an animated opacity on the render surface. | 1911 // Put an animated opacity on the render surface. |
| 1912 addOpacityTransitionToController(*renderSurface1->layerAnimationController()
, 10, 1, 0, false); | 1912 addOpacityTransitionToController(*renderSurface1->layer_animation_controller
(), 10, 1, 0, false); |
| 1913 | 1913 |
| 1914 // Also put an animated opacity on a layer without descendants. | 1914 // Also put an animated opacity on a layer without descendants. |
| 1915 addOpacityTransitionToController(*grandChildOfRoot->layerAnimationController
(), 10, 1, 0, false); | 1915 addOpacityTransitionToController(*grandChildOfRoot->layer_animation_controll
er(), 10, 1, 0, false); |
| 1916 | 1916 |
| 1917 // Put a transform animation on the render surface. | 1917 // Put a transform animation on the render surface. |
| 1918 addAnimatedTransformToController(*renderSurface2->layerAnimationController()
, 10, 30, 0); | 1918 addAnimatedTransformToController(*renderSurface2->layer_animation_controller
(), 10, 30, 0); |
| 1919 | 1919 |
| 1920 // Also put transform animations on grandChildOfRoot, and grandChildOfRS2 | 1920 // Also put transform animations on grandChildOfRoot, and grandChildOfRS2 |
| 1921 addAnimatedTransformToController(*grandChildOfRoot->layerAnimationController
(), 10, 30, 0); | 1921 addAnimatedTransformToController(*grandChildOfRoot->layer_animation_controll
er(), 10, 30, 0); |
| 1922 addAnimatedTransformToController(*grandChildOfRS2->layerAnimationController(
), 10, 30, 0); | 1922 addAnimatedTransformToController(*grandChildOfRS2->layer_animation_controlle
r(), 10, 30, 0); |
| 1923 | 1923 |
| 1924 executeCalculateDrawProperties(parent.get()); | 1924 executeCalculateDrawProperties(parent.get()); |
| 1925 | 1925 |
| 1926 // Only layers that are associated with render surfaces should have an actua
l renderSurface() value. | 1926 // Only layers that are associated with render surfaces should have an actua
l RenderSurface() value. |
| 1927 // | 1927 // |
| 1928 ASSERT_TRUE(parent->renderSurface()); | 1928 ASSERT_TRUE(parent->render_surface()); |
| 1929 ASSERT_FALSE(childOfRoot->renderSurface()); | 1929 ASSERT_FALSE(childOfRoot->render_surface()); |
| 1930 ASSERT_FALSE(grandChildOfRoot->renderSurface()); | 1930 ASSERT_FALSE(grandChildOfRoot->render_surface()); |
| 1931 | 1931 |
| 1932 ASSERT_TRUE(renderSurface1->renderSurface()); | 1932 ASSERT_TRUE(renderSurface1->render_surface()); |
| 1933 ASSERT_FALSE(childOfRS1->renderSurface()); | 1933 ASSERT_FALSE(childOfRS1->render_surface()); |
| 1934 ASSERT_FALSE(grandChildOfRS1->renderSurface()); | 1934 ASSERT_FALSE(grandChildOfRS1->render_surface()); |
| 1935 | 1935 |
| 1936 ASSERT_TRUE(renderSurface2->renderSurface()); | 1936 ASSERT_TRUE(renderSurface2->render_surface()); |
| 1937 ASSERT_FALSE(childOfRS2->renderSurface()); | 1937 ASSERT_FALSE(childOfRS2->render_surface()); |
| 1938 ASSERT_FALSE(grandChildOfRS2->renderSurface()); | 1938 ASSERT_FALSE(grandChildOfRS2->render_surface()); |
| 1939 | 1939 |
| 1940 // Verify all renderTarget accessors | 1940 // Verify all renderTarget accessors |
| 1941 // | 1941 // |
| 1942 EXPECT_EQ(parent, parent->renderTarget()); | 1942 EXPECT_EQ(parent, parent->render_target()); |
| 1943 EXPECT_EQ(parent, childOfRoot->renderTarget()); | 1943 EXPECT_EQ(parent, childOfRoot->render_target()); |
| 1944 EXPECT_EQ(parent, grandChildOfRoot->renderTarget()); | 1944 EXPECT_EQ(parent, grandChildOfRoot->render_target()); |
| 1945 | 1945 |
| 1946 EXPECT_EQ(renderSurface1, renderSurface1->renderTarget()); | 1946 EXPECT_EQ(renderSurface1, renderSurface1->render_target()); |
| 1947 EXPECT_EQ(renderSurface1, childOfRS1->renderTarget()); | 1947 EXPECT_EQ(renderSurface1, childOfRS1->render_target()); |
| 1948 EXPECT_EQ(renderSurface1, grandChildOfRS1->renderTarget()); | 1948 EXPECT_EQ(renderSurface1, grandChildOfRS1->render_target()); |
| 1949 | 1949 |
| 1950 EXPECT_EQ(renderSurface2, renderSurface2->renderTarget()); | 1950 EXPECT_EQ(renderSurface2, renderSurface2->render_target()); |
| 1951 EXPECT_EQ(renderSurface2, childOfRS2->renderTarget()); | 1951 EXPECT_EQ(renderSurface2, childOfRS2->render_target()); |
| 1952 EXPECT_EQ(renderSurface2, grandChildOfRS2->renderTarget()); | 1952 EXPECT_EQ(renderSurface2, grandChildOfRS2->render_target()); |
| 1953 | 1953 |
| 1954 // Verify drawOpacityIsAnimating values | 1954 // Verify drawOpacityIsAnimating values |
| 1955 // | 1955 // |
| 1956 EXPECT_FALSE(parent->drawOpacityIsAnimating()); | 1956 EXPECT_FALSE(parent->draw_opacity_is_animating()); |
| 1957 EXPECT_FALSE(childOfRoot->drawOpacityIsAnimating()); | 1957 EXPECT_FALSE(childOfRoot->draw_opacity_is_animating()); |
| 1958 EXPECT_TRUE(grandChildOfRoot->drawOpacityIsAnimating()); | 1958 EXPECT_TRUE(grandChildOfRoot->draw_opacity_is_animating()); |
| 1959 EXPECT_FALSE(renderSurface1->drawOpacityIsAnimating()); | 1959 EXPECT_FALSE(renderSurface1->draw_opacity_is_animating()); |
| 1960 EXPECT_TRUE(renderSurface1->renderSurface()->draw_opacity_is_animating()); | 1960 EXPECT_TRUE(renderSurface1->render_surface()->draw_opacity_is_animating()); |
| 1961 EXPECT_FALSE(childOfRS1->drawOpacityIsAnimating()); | 1961 EXPECT_FALSE(childOfRS1->draw_opacity_is_animating()); |
| 1962 EXPECT_FALSE(grandChildOfRS1->drawOpacityIsAnimating()); | 1962 EXPECT_FALSE(grandChildOfRS1->draw_opacity_is_animating()); |
| 1963 EXPECT_FALSE(renderSurface2->drawOpacityIsAnimating()); | 1963 EXPECT_FALSE(renderSurface2->draw_opacity_is_animating()); |
| 1964 EXPECT_FALSE(renderSurface2->renderSurface()->draw_opacity_is_animating()); | 1964 EXPECT_FALSE(renderSurface2->render_surface()->draw_opacity_is_animating()); |
| 1965 EXPECT_FALSE(childOfRS2->drawOpacityIsAnimating()); | 1965 EXPECT_FALSE(childOfRS2->draw_opacity_is_animating()); |
| 1966 EXPECT_FALSE(grandChildOfRS2->drawOpacityIsAnimating()); | 1966 EXPECT_FALSE(grandChildOfRS2->draw_opacity_is_animating()); |
| 1967 | 1967 |
| 1968 // Verify drawTransformsAnimatingInTarget values | 1968 // Verify drawTransformsAnimatingInTarget values |
| 1969 // | 1969 // |
| 1970 EXPECT_FALSE(parent->drawTransformIsAnimating()); | 1970 EXPECT_FALSE(parent->draw_transform_is_animating()); |
| 1971 EXPECT_FALSE(childOfRoot->drawTransformIsAnimating()); | 1971 EXPECT_FALSE(childOfRoot->draw_transform_is_animating()); |
| 1972 EXPECT_TRUE(grandChildOfRoot->drawTransformIsAnimating()); | 1972 EXPECT_TRUE(grandChildOfRoot->draw_transform_is_animating()); |
| 1973 EXPECT_FALSE(renderSurface1->drawTransformIsAnimating()); | 1973 EXPECT_FALSE(renderSurface1->draw_transform_is_animating()); |
| 1974 EXPECT_FALSE(renderSurface1->renderSurface()->target_surface_transforms_are_
animating()); | 1974 EXPECT_FALSE(renderSurface1->render_surface()->target_surface_transforms_are
_animating()); |
| 1975 EXPECT_FALSE(childOfRS1->drawTransformIsAnimating()); | 1975 EXPECT_FALSE(childOfRS1->draw_transform_is_animating()); |
| 1976 EXPECT_FALSE(grandChildOfRS1->drawTransformIsAnimating()); | 1976 EXPECT_FALSE(grandChildOfRS1->draw_transform_is_animating()); |
| 1977 EXPECT_FALSE(renderSurface2->drawTransformIsAnimating()); | 1977 EXPECT_FALSE(renderSurface2->draw_transform_is_animating()); |
| 1978 EXPECT_TRUE(renderSurface2->renderSurface()->target_surface_transforms_are_a
nimating()); | 1978 EXPECT_TRUE(renderSurface2->render_surface()->target_surface_transforms_are_
animating()); |
| 1979 EXPECT_FALSE(childOfRS2->drawTransformIsAnimating()); | 1979 EXPECT_FALSE(childOfRS2->draw_transform_is_animating()); |
| 1980 EXPECT_TRUE(grandChildOfRS2->drawTransformIsAnimating()); | 1980 EXPECT_TRUE(grandChildOfRS2->draw_transform_is_animating()); |
| 1981 | 1981 |
| 1982 // Verify drawTransformsAnimatingInScreen values | 1982 // Verify drawTransformsAnimatingInScreen values |
| 1983 // | 1983 // |
| 1984 EXPECT_FALSE(parent->screenSpaceTransformIsAnimating()); | 1984 EXPECT_FALSE(parent->screen_space_transform_is_animating()); |
| 1985 EXPECT_FALSE(childOfRoot->screenSpaceTransformIsAnimating()); | 1985 EXPECT_FALSE(childOfRoot->screen_space_transform_is_animating()); |
| 1986 EXPECT_TRUE(grandChildOfRoot->screenSpaceTransformIsAnimating()); | 1986 EXPECT_TRUE(grandChildOfRoot->screen_space_transform_is_animating()); |
| 1987 EXPECT_FALSE(renderSurface1->screenSpaceTransformIsAnimating()); | 1987 EXPECT_FALSE(renderSurface1->screen_space_transform_is_animating()); |
| 1988 EXPECT_FALSE(renderSurface1->renderSurface()->screen_space_transforms_are_an
imating()); | 1988 EXPECT_FALSE(renderSurface1->render_surface()->screen_space_transforms_are_a
nimating()); |
| 1989 EXPECT_FALSE(childOfRS1->screenSpaceTransformIsAnimating()); | 1989 EXPECT_FALSE(childOfRS1->screen_space_transform_is_animating()); |
| 1990 EXPECT_FALSE(grandChildOfRS1->screenSpaceTransformIsAnimating()); | 1990 EXPECT_FALSE(grandChildOfRS1->screen_space_transform_is_animating()); |
| 1991 EXPECT_TRUE(renderSurface2->screenSpaceTransformIsAnimating()); | 1991 EXPECT_TRUE(renderSurface2->screen_space_transform_is_animating()); |
| 1992 EXPECT_TRUE(renderSurface2->renderSurface()->screen_space_transforms_are_ani
mating()); | 1992 EXPECT_TRUE(renderSurface2->render_surface()->screen_space_transforms_are_an
imating()); |
| 1993 EXPECT_TRUE(childOfRS2->screenSpaceTransformIsAnimating()); | 1993 EXPECT_TRUE(childOfRS2->screen_space_transform_is_animating()); |
| 1994 EXPECT_TRUE(grandChildOfRS2->screenSpaceTransformIsAnimating()); | 1994 EXPECT_TRUE(grandChildOfRS2->screen_space_transform_is_animating()); |
| 1995 | 1995 |
| 1996 | 1996 |
| 1997 // Sanity check. If these fail there is probably a bug in the test itself. | 1997 // Sanity check. If these fail there is probably a bug in the test itself. |
| 1998 // It is expected that we correctly set up transforms so that the y-componen
t of the screen-space transform | 1998 // It is expected that we correctly set up transforms so that the y-componen
t of the screen-space transform |
| 1999 // encodes the "depth" of the layer in the tree. | 1999 // encodes the "depth" of the layer in the tree. |
| 2000 EXPECT_FLOAT_EQ(1, parent->screenSpaceTransform().matrix().getDouble(1, 3)); | 2000 EXPECT_FLOAT_EQ(1, parent->screen_space_transform().matrix().getDouble(1, 3)
); |
| 2001 EXPECT_FLOAT_EQ(2, childOfRoot->screenSpaceTransform().matrix().getDouble(1,
3)); | 2001 EXPECT_FLOAT_EQ(2, childOfRoot->screen_space_transform().matrix().getDouble(
1, 3)); |
| 2002 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screenSpaceTransform().matrix().getDoub
le(1, 3)); | 2002 EXPECT_FLOAT_EQ(3, grandChildOfRoot->screen_space_transform().matrix().getDo
uble(1, 3)); |
| 2003 | 2003 |
| 2004 EXPECT_FLOAT_EQ(2, renderSurface1->screenSpaceTransform().matrix().getDouble
(1, 3)); | 2004 EXPECT_FLOAT_EQ(2, renderSurface1->screen_space_transform().matrix().getDoub
le(1, 3)); |
| 2005 EXPECT_FLOAT_EQ(3, childOfRS1->screenSpaceTransform().matrix().getDouble(1,
3)); | 2005 EXPECT_FLOAT_EQ(3, childOfRS1->screen_space_transform().matrix().getDouble(1
, 3)); |
| 2006 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screenSpaceTransform().matrix().getDoubl
e(1, 3)); | 2006 EXPECT_FLOAT_EQ(4, grandChildOfRS1->screen_space_transform().matrix().getDou
ble(1, 3)); |
| 2007 | 2007 |
| 2008 EXPECT_FLOAT_EQ(3, renderSurface2->screenSpaceTransform().matrix().getDouble
(1, 3)); | 2008 EXPECT_FLOAT_EQ(3, renderSurface2->screen_space_transform().matrix().getDoub
le(1, 3)); |
| 2009 EXPECT_FLOAT_EQ(4, childOfRS2->screenSpaceTransform().matrix().getDouble(1,
3)); | 2009 EXPECT_FLOAT_EQ(4, childOfRS2->screen_space_transform().matrix().getDouble(1
, 3)); |
| 2010 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screenSpaceTransform().matrix().getDoubl
e(1, 3)); | 2010 EXPECT_FLOAT_EQ(5, grandChildOfRS2->screen_space_transform().matrix().getDou
ble(1, 3)); |
| 2011 } | 2011 } |
| 2012 | 2012 |
| 2013 TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) | 2013 TEST(LayerTreeHostCommonTest, verifyVisibleRectForIdentityTransform) |
| 2014 { | 2014 { |
| 2015 // Test the calculateVisibleRect() function works correctly for identity tra
nsforms. | 2015 // Test the calculateVisibleRect() function works correctly for identity tra
nsforms. |
| 2016 | 2016 |
| 2017 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); | 2017 gfx::Rect targetSurfaceRect = gfx::Rect(gfx::Point(0, 0), gfx::Size(100, 100
)); |
| 2018 gfx::Transform layerToSurfaceTransform; | 2018 gfx::Transform layerToSurfaceTransform; |
| 2019 | 2019 |
| 2020 // Case 1: Layer is contained within the surface. | 2020 // Case 1: Layer is contained within the surface. |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2263 // Only the corner of the layer is not visible on the surface because of bei
ng | 2263 // Only the corner of the layer is not visible on the surface because of bei
ng |
| 2264 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is | 2264 // clipped. But, the net result of rounding visible region to an axis-aligne
d rect is |
| 2265 // that the entire layer should still be considered visible. | 2265 // that the entire layer should still be considered visible. |
| 2266 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); | 2266 gfx::Rect expected = gfx::Rect(gfx::Point(-10, -10), gfx::Size(20, 20)); |
| 2267 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); | 2267 gfx::Rect actual = LayerTreeHostCommon::calculateVisibleRect(targetSurfaceRe
ct, layerContentRect, layerToSurfaceTransform); |
| 2268 EXPECT_RECT_EQ(expected, actual); | 2268 EXPECT_RECT_EQ(expected, actual); |
| 2269 } | 2269 } |
| 2270 | 2270 |
| 2271 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLayer
s) | 2271 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSimpleLayer
s) |
| 2272 { | 2272 { |
| 2273 scoped_refptr<Layer> root = Layer::create(); | 2273 scoped_refptr<Layer> root = Layer::Create(); |
| 2274 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2274 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2275 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2275 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2276 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2276 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2277 root->addChild(child1); | 2277 root->AddChild(child1); |
| 2278 root->addChild(child2); | 2278 root->AddChild(child2); |
| 2279 root->addChild(child3); | 2279 root->AddChild(child3); |
| 2280 | 2280 |
| 2281 gfx::Transform identityMatrix; | 2281 gfx::Transform identityMatrix; |
| 2282 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2282 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2283 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); | 2283 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); |
| 2284 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2284 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2285 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2285 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2286 | 2286 |
| 2287 executeCalculateDrawProperties(root.get()); | 2287 executeCalculateDrawProperties(root.get()); |
| 2288 | 2288 |
| 2289 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->DrawableCon
tentRect()); | 2289 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->render_surface()->DrawableCo
ntentRect()); |
| 2290 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawableContentRect()); | 2290 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); |
| 2291 | 2291 |
| 2292 // Layers that do not draw content should have empty visibleContentRects. | 2292 // Layers that do not draw content should have empty visible_content_rects. |
| 2293 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visibleContentRect()); | 2293 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); |
| 2294 | 2294 |
| 2295 // layer visibleContentRects are clipped by their targetSurface | 2295 // layer visible_content_rects are clipped by their target surface. |
| 2296 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visibleContentRect()); | 2296 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); |
| 2297 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visibleContentRect()); | 2297 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_content_rect()); |
| 2298 EXPECT_TRUE(child3->visibleContentRect().IsEmpty()); | 2298 EXPECT_TRUE(child3->visible_content_rect().IsEmpty()); |
| 2299 | 2299 |
| 2300 // layer drawableContentRects are not clipped. | 2300 // layer drawable_content_rects are not clipped. |
| 2301 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->drawableContentRect()); | 2301 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->drawable_content_rect()); |
| 2302 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawableContentRect()); | 2302 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); |
| 2303 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawableContentRect()); | 2303 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect())
; |
| 2304 } | 2304 } |
| 2305 | 2305 |
| 2306 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersClipp
edByLayer) | 2306 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersClipp
edByLayer) |
| 2307 { | 2307 { |
| 2308 scoped_refptr<Layer> root = Layer::create(); | 2308 scoped_refptr<Layer> root = Layer::Create(); |
| 2309 scoped_refptr<Layer> child = Layer::create(); | 2309 scoped_refptr<Layer> child = Layer::Create(); |
| 2310 scoped_refptr<LayerWithForcedDrawsContent> grandChild1 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); | 2310 scoped_refptr<LayerWithForcedDrawsContent> grandChild1 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); |
| 2311 scoped_refptr<LayerWithForcedDrawsContent> grandChild2 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); | 2311 scoped_refptr<LayerWithForcedDrawsContent> grandChild2 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); |
| 2312 scoped_refptr<LayerWithForcedDrawsContent> grandChild3 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); | 2312 scoped_refptr<LayerWithForcedDrawsContent> grandChild3 = make_scoped_refptr(
new LayerWithForcedDrawsContent()); |
| 2313 root->addChild(child); | 2313 root->AddChild(child); |
| 2314 child->addChild(grandChild1); | 2314 child->AddChild(grandChild1); |
| 2315 child->addChild(grandChild2); | 2315 child->AddChild(grandChild2); |
| 2316 child->addChild(grandChild3); | 2316 child->AddChild(grandChild3); |
| 2317 | 2317 |
| 2318 gfx::Transform identityMatrix; | 2318 gfx::Transform identityMatrix; |
| 2319 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2319 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2320 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2320 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2321 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2321 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
| 2322 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2322 setLayerPropertiesForTesting(grandChild2.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2323 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2323 setLayerPropertiesForTesting(grandChild3.get(), identityMatrix, identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2324 | 2324 |
| 2325 child->setMasksToBounds(true); | 2325 child->SetMasksToBounds(true); |
| 2326 executeCalculateDrawProperties(root.get()); | 2326 executeCalculateDrawProperties(root.get()); |
| 2327 | 2327 |
| 2328 ASSERT_FALSE(child->renderSurface()); | 2328 ASSERT_FALSE(child->render_surface()); |
| 2329 | 2329 |
| 2330 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->DrawableCon
tentRect()); | 2330 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->render_surface()->DrawableCo
ntentRect()); |
| 2331 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawableContentRect()); | 2331 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); |
| 2332 | 2332 |
| 2333 // Layers that do not draw content should have empty visibleContentRects. | 2333 // Layers that do not draw content should have empty visibleContentRects. |
| 2334 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visibleContentRect()); | 2334 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); |
| 2335 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), child->visibleContentRect()); | 2335 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), child->visible_content_rect()); |
| 2336 | 2336 |
| 2337 // All grandchild visibleContentRects should be clipped by child. | 2337 // All grandchild visibleContentRects should be clipped by child. |
| 2338 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), grandChild1->visibleContentRect()); | 2338 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), grandChild1->visible_content_rect())
; |
| 2339 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), grandChild2->visibleContentRect()); | 2339 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), grandChild2->visible_content_rect())
; |
| 2340 EXPECT_TRUE(grandChild3->visibleContentRect().IsEmpty()); | 2340 EXPECT_TRUE(grandChild3->visible_content_rect().IsEmpty()); |
| 2341 | 2341 |
| 2342 // All grandchild drawableContentRects should also be clipped by child. | 2342 // All grandchild drawableContentRects should also be clipped by child. |
| 2343 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), grandChild1->drawableContentRect()); | 2343 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), grandChild1->drawable_content_rect()
); |
| 2344 EXPECT_RECT_EQ(gfx::Rect(75, 75, 25, 25), grandChild2->drawableContentRect()
); | 2344 EXPECT_RECT_EQ(gfx::Rect(75, 75, 25, 25), grandChild2->drawable_content_rect
()); |
| 2345 EXPECT_TRUE(grandChild3->drawableContentRect().IsEmpty()); | 2345 EXPECT_TRUE(grandChild3->drawable_content_rect().IsEmpty()); |
| 2346 } | 2346 } |
| 2347 | 2347 |
| 2348 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInUnc
lippedRenderSurface) | 2348 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInUnc
lippedRenderSurface) |
| 2349 { | 2349 { |
| 2350 scoped_refptr<Layer> root = Layer::create(); | 2350 scoped_refptr<Layer> root = Layer::Create(); |
| 2351 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2351 scoped_refptr<Layer> renderSurface1 = Layer::Create(); |
| 2352 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2352 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2353 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2353 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2354 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2354 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2355 root->addChild(renderSurface1); | 2355 root->AddChild(renderSurface1); |
| 2356 renderSurface1->addChild(child1); | 2356 renderSurface1->AddChild(child1); |
| 2357 renderSurface1->addChild(child2); | 2357 renderSurface1->AddChild(child2); |
| 2358 renderSurface1->addChild(child3); | 2358 renderSurface1->AddChild(child3); |
| 2359 | 2359 |
| 2360 gfx::Transform identityMatrix; | 2360 gfx::Transform identityMatrix; |
| 2361 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2361 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2362 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2362 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 2363 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2363 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
| 2364 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2364 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2365 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2365 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2366 | 2366 |
| 2367 renderSurface1->setForceRenderSurface(true); | 2367 renderSurface1->SetForceRenderSurface(true); |
| 2368 executeCalculateDrawProperties(root.get()); | 2368 executeCalculateDrawProperties(root.get()); |
| 2369 | 2369 |
| 2370 ASSERT_TRUE(renderSurface1->renderSurface()); | 2370 ASSERT_TRUE(renderSurface1->render_surface()); |
| 2371 | 2371 |
| 2372 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->DrawableCon
tentRect()); | 2372 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->render_surface()->DrawableCo
ntentRect()); |
| 2373 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawableContentRect()); | 2373 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); |
| 2374 | 2374 |
| 2375 // Layers that do not draw content should have empty visibleContentRects. | 2375 // Layers that do not draw content should have empty visibleContentRects. |
| 2376 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visibleContentRect()); | 2376 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); |
| 2377 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), renderSurface1->visibleContentRect()); | 2377 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), renderSurface1->visible_content_rect()
); |
| 2378 | 2378 |
| 2379 // An unclipped surface grows its drawableContentRect to include all drawabl
e regions of the subtree. | 2379 // An unclipped surface grows its drawableContentRect to include all drawabl
e regions of the subtree. |
| 2380 EXPECT_RECT_EQ(gfx::Rect(5, 5, 170, 170), renderSurface1->renderSurface()->D
rawableContentRect()); | 2380 EXPECT_RECT_EQ(gfx::Rect(5, 5, 170, 170), renderSurface1->render_surface()->
DrawableContentRect()); |
| 2381 | 2381 |
| 2382 // All layers that draw content into the unclipped surface are also unclippe
d. | 2382 // All layers that draw content into the unclipped surface are also unclippe
d. |
| 2383 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visibleContentRect()); | 2383 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); |
| 2384 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visibleContentRect()); | 2384 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect()); |
| 2385 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visibleContentRect()); | 2385 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); |
| 2386 | 2386 |
| 2387 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawableContentRect()); | 2387 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); |
| 2388 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawableContentRect()); | 2388 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); |
| 2389 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawableContentRect()); | 2389 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect())
; |
| 2390 } | 2390 } |
| 2391 | 2391 |
| 2392 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInCli
ppedRenderSurface) | 2392 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForLayersInCli
ppedRenderSurface) |
| 2393 { | 2393 { |
| 2394 scoped_refptr<Layer> root = Layer::create(); | 2394 scoped_refptr<Layer> root = Layer::Create(); |
| 2395 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2395 scoped_refptr<Layer> renderSurface1 = Layer::Create(); |
| 2396 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2396 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2397 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2397 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2398 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2398 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2399 root->addChild(renderSurface1); | 2399 root->AddChild(renderSurface1); |
| 2400 renderSurface1->addChild(child1); | 2400 renderSurface1->AddChild(child1); |
| 2401 renderSurface1->addChild(child2); | 2401 renderSurface1->AddChild(child2); |
| 2402 renderSurface1->addChild(child3); | 2402 renderSurface1->AddChild(child3); |
| 2403 | 2403 |
| 2404 gfx::Transform identityMatrix; | 2404 gfx::Transform identityMatrix; |
| 2405 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2405 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2406 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2406 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 2407 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2407 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
| 2408 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2408 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2409 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2409 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2410 | 2410 |
| 2411 root->setMasksToBounds(true); | 2411 root->SetMasksToBounds(true); |
| 2412 renderSurface1->setForceRenderSurface(true); | 2412 renderSurface1->SetForceRenderSurface(true); |
| 2413 executeCalculateDrawProperties(root.get()); | 2413 executeCalculateDrawProperties(root.get()); |
| 2414 | 2414 |
| 2415 ASSERT_TRUE(renderSurface1->renderSurface()); | 2415 ASSERT_TRUE(renderSurface1->render_surface()); |
| 2416 | 2416 |
| 2417 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->DrawableCon
tentRect()); | 2417 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->render_surface()->DrawableCo
ntentRect()); |
| 2418 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawableContentRect()); | 2418 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); |
| 2419 | 2419 |
| 2420 // Layers that do not draw content should have empty visibleContentRects. | 2420 // Layers that do not draw content should have empty visibleContentRects. |
| 2421 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visibleContentRect()); | 2421 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); |
| 2422 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), renderSurface1->visibleContentRect()); | 2422 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), renderSurface1->visible_content_rect()
); |
| 2423 | 2423 |
| 2424 // A clipped surface grows its drawableContentRect to include all drawable r
egions of the subtree, | 2424 // A clipped surface grows its drawableContentRect to include all drawable r
egions of the subtree, |
| 2425 // but also gets clamped by the ancestor's clip. | 2425 // but also gets clamped by the ancestor's clip. |
| 2426 EXPECT_RECT_EQ(gfx::Rect(5, 5, 95, 95), renderSurface1->renderSurface()->Dra
wableContentRect()); | 2426 EXPECT_RECT_EQ(gfx::Rect(5, 5, 95, 95), renderSurface1->render_surface()->Dr
awableContentRect()); |
| 2427 | 2427 |
| 2428 // All layers that draw content into the surface have their visibleContentRe
ct clipped by the surface clipRect. | 2428 // All layers that draw content into the surface have their visibleContentRe
ct clipped by the surface clipRect. |
| 2429 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visibleContentRect()); | 2429 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); |
| 2430 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visibleContentRect()); | 2430 EXPECT_RECT_EQ(gfx::Rect(0, 0, 25, 25), child2->visible_content_rect()); |
| 2431 EXPECT_TRUE(child3->visibleContentRect().IsEmpty()); | 2431 EXPECT_TRUE(child3->visible_content_rect().IsEmpty()); |
| 2432 | 2432 |
| 2433 // But the drawableContentRects are unclipped. | 2433 // But the drawableContentRects are unclipped. |
| 2434 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawableContentRect()); | 2434 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); |
| 2435 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawableContentRect()); | 2435 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); |
| 2436 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawableContentRect()); | 2436 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect())
; |
| 2437 } | 2437 } |
| 2438 | 2438 |
| 2439 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSurfaceHier
archy) | 2439 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsForSurfaceHier
archy) |
| 2440 { | 2440 { |
| 2441 // Check that clipping does not propagate down surfaces. | 2441 // Check that clipping does not propagate down surfaces. |
| 2442 scoped_refptr<Layer> root = Layer::create(); | 2442 scoped_refptr<Layer> root = Layer::Create(); |
| 2443 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2443 scoped_refptr<Layer> renderSurface1 = Layer::Create(); |
| 2444 scoped_refptr<Layer> renderSurface2 = Layer::create(); | 2444 scoped_refptr<Layer> renderSurface2 = Layer::Create(); |
| 2445 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2445 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2446 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2446 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2447 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2447 scoped_refptr<LayerWithForcedDrawsContent> child3 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2448 root->addChild(renderSurface1); | 2448 root->AddChild(renderSurface1); |
| 2449 renderSurface1->addChild(renderSurface2); | 2449 renderSurface1->AddChild(renderSurface2); |
| 2450 renderSurface2->addChild(child1); | 2450 renderSurface2->AddChild(child1); |
| 2451 renderSurface2->addChild(child2); | 2451 renderSurface2->AddChild(child2); |
| 2452 renderSurface2->addChild(child3); | 2452 renderSurface2->AddChild(child3); |
| 2453 | 2453 |
| 2454 gfx::Transform identityMatrix; | 2454 gfx::Transform identityMatrix; |
| 2455 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2455 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2456 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2456 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 2457 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(7, 13), false); | 2457 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(7, 13), false); |
| 2458 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2458 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
| 2459 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2459 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2460 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2460 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2461 | 2461 |
| 2462 root->setMasksToBounds(true); | 2462 root->SetMasksToBounds(true); |
| 2463 renderSurface1->setForceRenderSurface(true); | 2463 renderSurface1->SetForceRenderSurface(true); |
| 2464 renderSurface2->setForceRenderSurface(true); | 2464 renderSurface2->SetForceRenderSurface(true); |
| 2465 executeCalculateDrawProperties(root.get()); | 2465 executeCalculateDrawProperties(root.get()); |
| 2466 | 2466 |
| 2467 ASSERT_TRUE(renderSurface1->renderSurface()); | 2467 ASSERT_TRUE(renderSurface1->render_surface()); |
| 2468 ASSERT_TRUE(renderSurface2->renderSurface()); | 2468 ASSERT_TRUE(renderSurface2->render_surface()); |
| 2469 | 2469 |
| 2470 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->DrawableCon
tentRect()); | 2470 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->render_surface()->DrawableCo
ntentRect()); |
| 2471 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawableContentRect()); | 2471 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); |
| 2472 | 2472 |
| 2473 // Layers that do not draw content should have empty visibleContentRects. | 2473 // Layers that do not draw content should have empty visibleContentRects. |
| 2474 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visibleContentRect()); | 2474 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); |
| 2475 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), renderSurface1->visibleContentRect()); | 2475 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), renderSurface1->visible_content_rect()
); |
| 2476 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), renderSurface2->visibleContentRect()); | 2476 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), renderSurface2->visible_content_rect()
); |
| 2477 | 2477 |
| 2478 // A clipped surface grows its drawableContentRect to include all drawable r
egions of the subtree, | 2478 // A clipped surface grows its drawableContentRect to include all drawable r
egions of the subtree, |
| 2479 // but also gets clamped by the ancestor's clip. | 2479 // but also gets clamped by the ancestor's clip. |
| 2480 EXPECT_RECT_EQ(gfx::Rect(5, 5, 95, 95), renderSurface1->renderSurface()->Dra
wableContentRect()); | 2480 EXPECT_RECT_EQ(gfx::Rect(5, 5, 95, 95), renderSurface1->render_surface()->Dr
awableContentRect()); |
| 2481 | 2481 |
| 2482 // renderSurface1 lives in the "unclipped universe" of renderSurface1, and i
s only | 2482 // renderSurface1 lives in the "unclipped universe" of renderSurface1, and i
s only |
| 2483 // implicitly clipped by renderSurface1's contentRect. So, renderSurface2 gr
ows to | 2483 // implicitly clipped by renderSurface1's contentRect. So, renderSurface2 gr
ows to |
| 2484 // enclose all drawable content of its subtree. | 2484 // enclose all drawable content of its subtree. |
| 2485 EXPECT_RECT_EQ(gfx::Rect(5, 5, 170, 170), renderSurface2->renderSurface()->D
rawableContentRect()); | 2485 EXPECT_RECT_EQ(gfx::Rect(5, 5, 170, 170), renderSurface2->render_surface()->
DrawableContentRect()); |
| 2486 | 2486 |
| 2487 // All layers that draw content into renderSurface2 think they are unclipped
. | 2487 // All layers that draw content into renderSurface2 think they are unclipped
. |
| 2488 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visibleContentRect()); | 2488 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); |
| 2489 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visibleContentRect()); | 2489 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect()); |
| 2490 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visibleContentRect()); | 2490 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); |
| 2491 | 2491 |
| 2492 // drawableContentRects are also unclipped. | 2492 // drawableContentRects are also unclipped. |
| 2493 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawableContentRect()); | 2493 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); |
| 2494 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawableContentRect()); | 2494 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); |
| 2495 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawableContentRect()); | 2495 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect())
; |
| 2496 } | 2496 } |
| 2497 | 2497 |
| 2498 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransformO
nUnclippedSurface) | 2498 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransformO
nUnclippedSurface) |
| 2499 { | 2499 { |
| 2500 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, | 2500 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, |
| 2501 // axis-aligned drawableContentRect and visibleContentRect. | 2501 // axis-aligned drawableContentRect and visibleContentRect. |
| 2502 | 2502 |
| 2503 scoped_refptr<Layer> root = Layer::create(); | 2503 scoped_refptr<Layer> root = Layer::Create(); |
| 2504 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2504 scoped_refptr<Layer> renderSurface1 = Layer::Create(); |
| 2505 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2505 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2506 root->addChild(renderSurface1); | 2506 root->AddChild(renderSurface1); |
| 2507 renderSurface1->addChild(child1); | 2507 renderSurface1->AddChild(child1); |
| 2508 | 2508 |
| 2509 gfx::Transform identityMatrix; | 2509 gfx::Transform identityMatrix; |
| 2510 gfx::Transform childRotation; | 2510 gfx::Transform childRotation; |
| 2511 childRotation.Rotate(45); | 2511 childRotation.Rotate(45); |
| 2512 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2512 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2513 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2513 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 2514 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf
x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); | 2514 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf
x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); |
| 2515 | 2515 |
| 2516 renderSurface1->setForceRenderSurface(true); | 2516 renderSurface1->SetForceRenderSurface(true); |
| 2517 executeCalculateDrawProperties(root.get()); | 2517 executeCalculateDrawProperties(root.get()); |
| 2518 | 2518 |
| 2519 ASSERT_TRUE(renderSurface1->renderSurface()); | 2519 ASSERT_TRUE(renderSurface1->render_surface()); |
| 2520 | 2520 |
| 2521 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->renderSurface()->DrawableCon
tentRect()); | 2521 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->render_surface()->DrawableCo
ntentRect()); |
| 2522 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawableContentRect()); | 2522 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect()); |
| 2523 | 2523 |
| 2524 // Layers that do not draw content should have empty visibleContentRects. | 2524 // Layers that do not draw content should have empty visibleContentRects. |
| 2525 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visibleContentRect()); | 2525 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); |
| 2526 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), renderSurface1->visibleContentRect()); | 2526 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), renderSurface1->visible_content_rect()
); |
| 2527 | 2527 |
| 2528 // The unclipped surface grows its drawableContentRect to include all drawab
le regions of the subtree. | 2528 // The unclipped surface grows its drawableContentRect to include all drawab
le regions of the subtree. |
| 2529 int diagonalRadius = ceil(sqrt(2.0) * 25); | 2529 int diagonalRadius = ceil(sqrt(2.0) * 25); |
| 2530 gfx::Rect expectedSurfaceDrawableContent = gfx::Rect(50 - diagonalRadius, 50
- diagonalRadius, diagonalRadius * 2, diagonalRadius * 2); | 2530 gfx::Rect expectedSurfaceDrawableContent = gfx::Rect(50 - diagonalRadius, 50
- diagonalRadius, diagonalRadius * 2, diagonalRadius * 2); |
| 2531 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, renderSurface1->renderSurface
()->DrawableContentRect()); | 2531 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, renderSurface1->render_surfac
e()->DrawableContentRect()); |
| 2532 | 2532 |
| 2533 // All layers that draw content into the unclipped surface are also unclippe
d. | 2533 // All layers that draw content into the unclipped surface are also unclippe
d. |
| 2534 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visibleContentRect()); | 2534 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); |
| 2535 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, child1->drawableContentRect()
); | 2535 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, child1->drawable_content_rect
()); |
| 2536 } | 2536 } |
| 2537 | 2537 |
| 2538 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransformO
nClippedSurface) | 2538 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsWithTransformO
nClippedSurface) |
| 2539 { | 2539 { |
| 2540 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, | 2540 // Layers that have non-axis aligned bounds (due to transforms) have an expa
nded, |
| 2541 // axis-aligned drawableContentRect and visibleContentRect. | 2541 // axis-aligned drawableContentRect and visibleContentRect. |
| 2542 | 2542 |
| 2543 scoped_refptr<Layer> root = Layer::create(); | 2543 scoped_refptr<Layer> root = Layer::Create(); |
| 2544 scoped_refptr<Layer> renderSurface1 = Layer::create(); | 2544 scoped_refptr<Layer> renderSurface1 = Layer::Create(); |
| 2545 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2545 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2546 root->addChild(renderSurface1); | 2546 root->AddChild(renderSurface1); |
| 2547 renderSurface1->addChild(child1); | 2547 renderSurface1->AddChild(child1); |
| 2548 | 2548 |
| 2549 gfx::Transform identityMatrix; | 2549 gfx::Transform identityMatrix; |
| 2550 gfx::Transform childRotation; | 2550 gfx::Transform childRotation; |
| 2551 childRotation.Rotate(45); | 2551 childRotation.Rotate(45); |
| 2552 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); | 2552 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(50, 50), false); |
| 2553 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); | 2553 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(3, 4), false); |
| 2554 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf
x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); | 2554 setLayerPropertiesForTesting(child1.get(), childRotation, identityMatrix, gf
x::PointF(0.5, 0.5), gfx::PointF(25, 25), gfx::Size(50, 50), false); |
| 2555 | 2555 |
| 2556 root->setMasksToBounds(true); | 2556 root->SetMasksToBounds(true); |
| 2557 renderSurface1->setForceRenderSurface(true); | 2557 renderSurface1->SetForceRenderSurface(true); |
| 2558 executeCalculateDrawProperties(root.get()); | 2558 executeCalculateDrawProperties(root.get()); |
| 2559 | 2559 |
| 2560 ASSERT_TRUE(renderSurface1->renderSurface()); | 2560 ASSERT_TRUE(renderSurface1->render_surface()); |
| 2561 | 2561 |
| 2562 // The clipped surface clamps the drawableContentRect that encloses the rota
ted layer. | 2562 // The clipped surface clamps the drawableContentRect that encloses the rota
ted layer. |
| 2563 int diagonalRadius = ceil(sqrt(2.0) * 25); | 2563 int diagonalRadius = ceil(sqrt(2.0) * 25); |
| 2564 gfx::Rect unclippedSurfaceContent = gfx::Rect(50 - diagonalRadius, 50 - diag
onalRadius, diagonalRadius * 2, diagonalRadius * 2); | 2564 gfx::Rect unclippedSurfaceContent = gfx::Rect(50 - diagonalRadius, 50 - diag
onalRadius, diagonalRadius * 2, diagonalRadius * 2); |
| 2565 gfx::Rect expectedSurfaceDrawableContent = gfx::IntersectRects(unclippedSurf
aceContent, gfx::Rect(0, 0, 50, 50)); | 2565 gfx::Rect expectedSurfaceDrawableContent = gfx::IntersectRects(unclippedSurf
aceContent, gfx::Rect(0, 0, 50, 50)); |
| 2566 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, renderSurface1->renderSurface
()->DrawableContentRect()); | 2566 EXPECT_RECT_EQ(expectedSurfaceDrawableContent, renderSurface1->render_surfac
e()->DrawableContentRect()); |
| 2567 | 2567 |
| 2568 // On the clipped surface, only a quarter of the child1 is visible, but whe
n rotating | 2568 // On the clipped surface, only a quarter of the child1 is visible, but whe
n rotating |
| 2569 // it back to child1's content space, the actual enclosing rect ends up cov
ering the | 2569 // it back to child1's content space, the actual enclosing rect ends up cov
ering the |
| 2570 // full left half of child1. | 2570 // full left half of child1. |
| 2571 EXPECT_RECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visibleContentRect()); | 2571 EXPECT_RECT_EQ(gfx::Rect(0, 0, 26, 50), child1->visible_content_rect()); |
| 2572 | 2572 |
| 2573 // The child's drawableContentRect is unclipped. | 2573 // The child's drawableContentRect is unclipped. |
| 2574 EXPECT_RECT_EQ(unclippedSurfaceContent, child1->drawableContentRect()); | 2574 EXPECT_RECT_EQ(unclippedSurfaceContent, child1->drawable_content_rect()); |
| 2575 } | 2575 } |
| 2576 | 2576 |
| 2577 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsInHighDPI) | 2577 TEST(LayerTreeHostCommonTest, verifyDrawableAndVisibleContentRectsInHighDPI) |
| 2578 { | 2578 { |
| 2579 MockContentLayerClient client; | 2579 MockContentLayerClient client; |
| 2580 | 2580 |
| 2581 scoped_refptr<Layer> root = Layer::create(); | 2581 scoped_refptr<Layer> root = Layer::Create(); |
| 2582 scoped_refptr<ContentLayer> renderSurface1 = createDrawableContentLayer(&cli
ent); | 2582 scoped_refptr<ContentLayer> renderSurface1 = createDrawableContentLayer(&cli
ent); |
| 2583 scoped_refptr<ContentLayer> renderSurface2 = createDrawableContentLayer(&cli
ent); | 2583 scoped_refptr<ContentLayer> renderSurface2 = createDrawableContentLayer(&cli
ent); |
| 2584 scoped_refptr<ContentLayer> child1 = createDrawableContentLayer(&client); | 2584 scoped_refptr<ContentLayer> child1 = createDrawableContentLayer(&client); |
| 2585 scoped_refptr<ContentLayer> child2 = createDrawableContentLayer(&client); | 2585 scoped_refptr<ContentLayer> child2 = createDrawableContentLayer(&client); |
| 2586 scoped_refptr<ContentLayer> child3 = createDrawableContentLayer(&client); | 2586 scoped_refptr<ContentLayer> child3 = createDrawableContentLayer(&client); |
| 2587 root->addChild(renderSurface1); | 2587 root->AddChild(renderSurface1); |
| 2588 renderSurface1->addChild(renderSurface2); | 2588 renderSurface1->AddChild(renderSurface2); |
| 2589 renderSurface2->addChild(child1); | 2589 renderSurface2->AddChild(child1); |
| 2590 renderSurface2->addChild(child2); | 2590 renderSurface2->AddChild(child2); |
| 2591 renderSurface2->addChild(child3); | 2591 renderSurface2->AddChild(child3); |
| 2592 | 2592 |
| 2593 gfx::Transform identityMatrix; | 2593 gfx::Transform identityMatrix; |
| 2594 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2594 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2595 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(3, 4), false); | 2595 setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(3, 4), false); |
| 2596 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(7, 13), false); | 2596 setLayerPropertiesForTesting(renderSurface2.get(), identityMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(7, 13), false); |
| 2597 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); | 2597 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(5, 5), gfx::Size(50, 50), false); |
| 2598 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); | 2598 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(75, 75), gfx::Size(50, 50), false); |
| 2599 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); | 2599 setLayerPropertiesForTesting(child3.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(125, 125), gfx::Size(50, 50), false); |
| 2600 | 2600 |
| 2601 const double deviceScaleFactor = 2; | 2601 const double deviceScaleFactor = 2; |
| 2602 | 2602 |
| 2603 root->setMasksToBounds(true); | 2603 root->SetMasksToBounds(true); |
| 2604 renderSurface1->setForceRenderSurface(true); | 2604 renderSurface1->SetForceRenderSurface(true); |
| 2605 renderSurface2->setForceRenderSurface(true); | 2605 renderSurface2->SetForceRenderSurface(true); |
| 2606 executeCalculateDrawProperties(root.get(), deviceScaleFactor); | 2606 executeCalculateDrawProperties(root.get(), deviceScaleFactor); |
| 2607 | 2607 |
| 2608 ASSERT_TRUE(renderSurface1->renderSurface()); | 2608 ASSERT_TRUE(renderSurface1->render_surface()); |
| 2609 ASSERT_TRUE(renderSurface2->renderSurface()); | 2609 ASSERT_TRUE(renderSurface2->render_surface()); |
| 2610 | 2610 |
| 2611 // DrawableContentRects for all layers and surfaces are scaled by deviceScal
eFactor. | 2611 // drawable_content_rects for all layers and surfaces are scaled by deviceSc
aleFactor. |
| 2612 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 200), root->renderSurface()->DrawableCon
tentRect()); | 2612 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 200), root->render_surface()->DrawableCo
ntentRect()); |
| 2613 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 200), root->drawableContentRect()); | 2613 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 200), root->drawable_content_rect()); |
| 2614 EXPECT_RECT_EQ(gfx::Rect(10, 10, 190, 190), renderSurface1->renderSurface()-
>DrawableContentRect()); | 2614 EXPECT_RECT_EQ(gfx::Rect(10, 10, 190, 190), renderSurface1->render_surface()
->DrawableContentRect()); |
| 2615 | 2615 |
| 2616 // renderSurface2 lives in the "unclipped universe" of renderSurface1, and | 2616 // renderSurface2 lives in the "unclipped universe" of renderSurface1, and |
| 2617 // is only implicitly clipped by renderSurface1. | 2617 // is only implicitly clipped by renderSurface1. |
| 2618 EXPECT_RECT_EQ(gfx::Rect(10, 10, 350, 350), renderSurface2->renderSurface()-
>DrawableContentRect()); | 2618 EXPECT_RECT_EQ(gfx::Rect(10, 10, 350, 350), renderSurface2->render_surface()
->DrawableContentRect()); |
| 2619 | 2619 |
| 2620 EXPECT_RECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawableContentRect()); | 2620 EXPECT_RECT_EQ(gfx::Rect(10, 10, 100, 100), child1->drawable_content_rect())
; |
| 2621 EXPECT_RECT_EQ(gfx::Rect(150, 150, 100, 100), child2->drawableContentRect())
; | 2621 EXPECT_RECT_EQ(gfx::Rect(150, 150, 100, 100), child2->drawable_content_rect(
)); |
| 2622 EXPECT_RECT_EQ(gfx::Rect(250, 250, 100, 100), child3->drawableContentRect())
; | 2622 EXPECT_RECT_EQ(gfx::Rect(250, 250, 100, 100), child3->drawable_content_rect(
)); |
| 2623 | 2623 |
| 2624 // The root layer does not actually draw content of its own. | 2624 // The root layer does not actually draw content of its own. |
| 2625 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visibleContentRect()); | 2625 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_content_rect()); |
| 2626 | 2626 |
| 2627 // All layer visibleContentRects are expressed in content space of each | 2627 // All layer visibleContentRects are expressed in content space of each |
| 2628 // layer, so they are also scaled by the deviceScaleFactor. | 2628 // layer, so they are also scaled by the deviceScaleFactor. |
| 2629 EXPECT_RECT_EQ(gfx::Rect(0, 0, 6, 8), renderSurface1->visibleContentRect()); | 2629 EXPECT_RECT_EQ(gfx::Rect(0, 0, 6, 8), renderSurface1->visible_content_rect()
); |
| 2630 EXPECT_RECT_EQ(gfx::Rect(0, 0, 14, 26), renderSurface2->visibleContentRect()
); | 2630 EXPECT_RECT_EQ(gfx::Rect(0, 0, 14, 26), renderSurface2->visible_content_rect
()); |
| 2631 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child1->visibleContentRect()); | 2631 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child1->visible_content_rect()); |
| 2632 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child2->visibleContentRect()); | 2632 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child2->visible_content_rect()); |
| 2633 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child3->visibleContentRect()); | 2633 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), child3->visible_content_rect()); |
| 2634 } | 2634 } |
| 2635 | 2635 |
| 2636 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d) | 2636 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d) |
| 2637 { | 2637 { |
| 2638 // Verify the behavior of back-face culling when there are no preserve-3d la
yers. Note | 2638 // Verify the behavior of back-face culling when there are no preserve-3d la
yers. Note |
| 2639 // that 3d transforms still apply in this case, but they are "flattened" to
each | 2639 // that 3d transforms still apply in this case, but they are "flattened" to
each |
| 2640 // parent layer according to current W3C spec. | 2640 // parent layer according to current W3C spec. |
| 2641 | 2641 |
| 2642 const gfx::Transform identityMatrix; | 2642 const gfx::Transform identityMatrix; |
| 2643 scoped_refptr<Layer> parent = Layer::create(); | 2643 scoped_refptr<Layer> parent = Layer::Create(); |
| 2644 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); | 2644 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); |
| 2645 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); | 2645 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
| 2646 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); | 2646 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
| 2647 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); | 2647 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); |
| 2648 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf
ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2648 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf
ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2649 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2649 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2650 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2650 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2651 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac
e = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2651 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac
e = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2652 | 2652 |
| 2653 parent->addChild(frontFacingChild); | 2653 parent->AddChild(frontFacingChild); |
| 2654 parent->addChild(backFacingChild); | 2654 parent->AddChild(backFacingChild); |
| 2655 parent->addChild(frontFacingSurface); | 2655 parent->AddChild(frontFacingSurface); |
| 2656 parent->addChild(backFacingSurface); | 2656 parent->AddChild(backFacingSurface); |
| 2657 frontFacingSurface->addChild(frontFacingChildOfFrontFacingSurface); | 2657 frontFacingSurface->AddChild(frontFacingChildOfFrontFacingSurface); |
| 2658 frontFacingSurface->addChild(backFacingChildOfFrontFacingSurface); | 2658 frontFacingSurface->AddChild(backFacingChildOfFrontFacingSurface); |
| 2659 backFacingSurface->addChild(frontFacingChildOfBackFacingSurface); | 2659 backFacingSurface->AddChild(frontFacingChildOfBackFacingSurface); |
| 2660 backFacingSurface->addChild(backFacingChildOfBackFacingSurface); | 2660 backFacingSurface->AddChild(backFacingChildOfBackFacingSurface); |
| 2661 | 2661 |
| 2662 // Nothing is double-sided | 2662 // Nothing is double-sided |
| 2663 frontFacingChild->setDoubleSided(false); | 2663 frontFacingChild->SetDoubleSided(false); |
| 2664 backFacingChild->setDoubleSided(false); | 2664 backFacingChild->SetDoubleSided(false); |
| 2665 frontFacingSurface->setDoubleSided(false); | 2665 frontFacingSurface->SetDoubleSided(false); |
| 2666 backFacingSurface->setDoubleSided(false); | 2666 backFacingSurface->SetDoubleSided(false); |
| 2667 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2667 frontFacingChildOfFrontFacingSurface->SetDoubleSided(false); |
| 2668 backFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2668 backFacingChildOfFrontFacingSurface->SetDoubleSided(false); |
| 2669 frontFacingChildOfBackFacingSurface->setDoubleSided(false); | 2669 frontFacingChildOfBackFacingSurface->SetDoubleSided(false); |
| 2670 backFacingChildOfBackFacingSurface->setDoubleSided(false); | 2670 backFacingChildOfBackFacingSurface->SetDoubleSided(false); |
| 2671 | 2671 |
| 2672 gfx::Transform backfaceMatrix; | 2672 gfx::Transform backfaceMatrix; |
| 2673 backfaceMatrix.Translate(50, 50); | 2673 backfaceMatrix.Translate(50, 50); |
| 2674 backfaceMatrix.RotateAboutYAxis(180); | 2674 backfaceMatrix.RotateAboutYAxis(180); |
| 2675 backfaceMatrix.Translate(-50, -50); | 2675 backfaceMatrix.Translate(-50, -50); |
| 2676 | 2676 |
| 2677 // Having a descendant and opacity will force these to have render surfaces. | 2677 // Having a descendant and opacity will force these to have render surfaces. |
| 2678 frontFacingSurface->setOpacity(0.5); | 2678 frontFacingSurface->SetOpacity(0.5); |
| 2679 backFacingSurface->setOpacity(0.5); | 2679 backFacingSurface->SetOpacity(0.5); |
| 2680 | 2680 |
| 2681 // Nothing preserves 3d. According to current W3C CSS gfx::Transforms spec,
these layers | 2681 // Nothing preserves 3d. According to current W3C CSS gfx::Transforms spec,
these layers |
| 2682 // should blindly use their own local transforms to determine back-face cull
ing. | 2682 // should blindly use their own local transforms to determine back-face cull
ing. |
| 2683 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2683 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2684 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2684 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2685 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2685 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2686 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2686 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2687 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2687 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2688 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); | 2688 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); |
| 2689 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2689 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
| 2690 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2690 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
| 2691 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2691 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
| 2692 | 2692 |
| 2693 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2693 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 2694 int dummyMaxTextureSize = 512; | 2694 int dummyMaxTextureSize = 512; |
| 2695 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 2695 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 2696 | 2696 |
| 2697 // Verify which renderSurfaces were created. | 2697 // Verify which renderSurfaces were created. |
| 2698 EXPECT_FALSE(frontFacingChild->renderSurface()); | 2698 EXPECT_FALSE(frontFacingChild->render_surface()); |
| 2699 EXPECT_FALSE(backFacingChild->renderSurface()); | 2699 EXPECT_FALSE(backFacingChild->render_surface()); |
| 2700 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2700 EXPECT_TRUE(frontFacingSurface->render_surface()); |
| 2701 EXPECT_TRUE(backFacingSurface->renderSurface()); | 2701 EXPECT_TRUE(backFacingSurface->render_surface()); |
| 2702 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); | 2702 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->render_surface()); |
| 2703 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); | 2703 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->render_surface()); |
| 2704 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); | 2704 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->render_surface()); |
| 2705 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); | 2705 EXPECT_FALSE(backFacingChildOfBackFacingSurface->render_surface()); |
| 2706 | 2706 |
| 2707 // Verify the renderSurfaceLayerList. | 2707 // Verify the renderSurfaceLayerList. |
| 2708 ASSERT_EQ(3u, renderSurfaceLayerList.size()); | 2708 ASSERT_EQ(3u, renderSurfaceLayerList.size()); |
| 2709 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2709 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
| 2710 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); | 2710 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); |
| 2711 // Even though the back facing surface LAYER gets culled, the other descenda
nts should still be added, so the SURFACE should not be culled. | 2711 // Even though the back facing surface LAYER gets culled, the other descenda
nts should still be added, so the SURFACE should not be culled. |
| 2712 EXPECT_EQ(backFacingSurface->id(), renderSurfaceLayerList[2]->id()); | 2712 EXPECT_EQ(backFacingSurface->id(), renderSurfaceLayerList[2]->id()); |
| 2713 | 2713 |
| 2714 // Verify root surface's layerList. | 2714 // Verify root surface's layerList. |
| 2715 ASSERT_EQ(3u, renderSurfaceLayerList[0]->renderSurface()->layer_list().size(
)); | 2715 ASSERT_EQ(3u, renderSurfaceLayerList[0]->render_surface()->layer_list().size
()); |
| 2716 EXPECT_EQ(frontFacingChild->id(), renderSurfaceLayerList[0]->renderSurface()
->layer_list()[0]->id()); | 2716 EXPECT_EQ(frontFacingChild->id(), renderSurfaceLayerList[0]->render_surface(
)->layer_list()[0]->id()); |
| 2717 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->renderSurface
()->layer_list()[1]->id()); | 2717 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->render_surfac
e()->layer_list()[1]->id()); |
| 2718 EXPECT_EQ(backFacingSurface->id(), renderSurfaceLayerList[0]->renderSurface(
)->layer_list()[2]->id()); | 2718 EXPECT_EQ(backFacingSurface->id(), renderSurfaceLayerList[0]->render_surface
()->layer_list()[2]->id()); |
| 2719 | 2719 |
| 2720 // Verify frontFacingSurface's layerList. | 2720 // Verify frontFacingSurface's layerList. |
| 2721 ASSERT_EQ(2u, renderSurfaceLayerList[1]->renderSurface()->layer_list().size(
)); | 2721 ASSERT_EQ(2u, renderSurfaceLayerList[1]->render_surface()->layer_list().size
()); |
| 2722 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->renderSurface
()->layer_list()[0]->id()); | 2722 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->render_surfac
e()->layer_list()[0]->id()); |
| 2723 EXPECT_EQ(frontFacingChildOfFrontFacingSurface->id(), renderSurfaceLayerList
[1]->renderSurface()->layer_list()[1]->id()); | 2723 EXPECT_EQ(frontFacingChildOfFrontFacingSurface->id(), renderSurfaceLayerList
[1]->render_surface()->layer_list()[1]->id()); |
| 2724 | 2724 |
| 2725 // Verify backFacingSurface's layerList; its own layer should be culled from
the surface list. | 2725 // Verify backFacingSurface's layerList; its own layer should be culled from
the surface list. |
| 2726 ASSERT_EQ(1u, renderSurfaceLayerList[2]->renderSurface()->layer_list().size(
)); | 2726 ASSERT_EQ(1u, renderSurfaceLayerList[2]->render_surface()->layer_list().size
()); |
| 2727 EXPECT_EQ(frontFacingChildOfBackFacingSurface->id(), renderSurfaceLayerList[
2]->renderSurface()->layer_list()[0]->id()); | 2727 EXPECT_EQ(frontFacingChildOfBackFacingSurface->id(), renderSurfaceLayerList[
2]->render_surface()->layer_list()[0]->id()); |
| 2728 } | 2728 } |
| 2729 | 2729 |
| 2730 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d) | 2730 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d) |
| 2731 { | 2731 { |
| 2732 // Verify the behavior of back-face culling when preserves-3d transform styl
e is used. | 2732 // Verify the behavior of back-face culling when preserves-3d transform styl
e is used. |
| 2733 | 2733 |
| 2734 const gfx::Transform identityMatrix; | 2734 const gfx::Transform identityMatrix; |
| 2735 scoped_refptr<Layer> parent = Layer::create(); | 2735 scoped_refptr<Layer> parent = Layer::Create(); |
| 2736 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); | 2736 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChild = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); |
| 2737 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); | 2737 scoped_refptr<LayerWithForcedDrawsContent> backFacingChild = make_scoped_ref
ptr(new LayerWithForcedDrawsContent()); |
| 2738 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); | 2738 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
| 2739 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); | 2739 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); |
| 2740 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf
ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2740 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfFrontFacingSurf
ace = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2741 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2741 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfFrontFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2742 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2742 scoped_refptr<LayerWithForcedDrawsContent> frontFacingChildOfBackFacingSurfa
ce = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2743 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac
e = make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2743 scoped_refptr<LayerWithForcedDrawsContent> backFacingChildOfBackFacingSurfac
e = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2744 scoped_refptr<LayerWithForcedDrawsContent> dummyReplicaLayer1 = make_scoped_
refptr(new LayerWithForcedDrawsContent()); | 2744 scoped_refptr<LayerWithForcedDrawsContent> dummyReplicaLayer1 = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
| 2745 scoped_refptr<LayerWithForcedDrawsContent> dummyReplicaLayer2 = make_scoped_
refptr(new LayerWithForcedDrawsContent()); | 2745 scoped_refptr<LayerWithForcedDrawsContent> dummyReplicaLayer2 = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
| 2746 | 2746 |
| 2747 parent->addChild(frontFacingChild); | 2747 parent->AddChild(frontFacingChild); |
| 2748 parent->addChild(backFacingChild); | 2748 parent->AddChild(backFacingChild); |
| 2749 parent->addChild(frontFacingSurface); | 2749 parent->AddChild(frontFacingSurface); |
| 2750 parent->addChild(backFacingSurface); | 2750 parent->AddChild(backFacingSurface); |
| 2751 frontFacingSurface->addChild(frontFacingChildOfFrontFacingSurface); | 2751 frontFacingSurface->AddChild(frontFacingChildOfFrontFacingSurface); |
| 2752 frontFacingSurface->addChild(backFacingChildOfFrontFacingSurface); | 2752 frontFacingSurface->AddChild(backFacingChildOfFrontFacingSurface); |
| 2753 backFacingSurface->addChild(frontFacingChildOfBackFacingSurface); | 2753 backFacingSurface->AddChild(frontFacingChildOfBackFacingSurface); |
| 2754 backFacingSurface->addChild(backFacingChildOfBackFacingSurface); | 2754 backFacingSurface->AddChild(backFacingChildOfBackFacingSurface); |
| 2755 | 2755 |
| 2756 // Nothing is double-sided | 2756 // Nothing is double-sided |
| 2757 frontFacingChild->setDoubleSided(false); | 2757 frontFacingChild->SetDoubleSided(false); |
| 2758 backFacingChild->setDoubleSided(false); | 2758 backFacingChild->SetDoubleSided(false); |
| 2759 frontFacingSurface->setDoubleSided(false); | 2759 frontFacingSurface->SetDoubleSided(false); |
| 2760 backFacingSurface->setDoubleSided(false); | 2760 backFacingSurface->SetDoubleSided(false); |
| 2761 frontFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2761 frontFacingChildOfFrontFacingSurface->SetDoubleSided(false); |
| 2762 backFacingChildOfFrontFacingSurface->setDoubleSided(false); | 2762 backFacingChildOfFrontFacingSurface->SetDoubleSided(false); |
| 2763 frontFacingChildOfBackFacingSurface->setDoubleSided(false); | 2763 frontFacingChildOfBackFacingSurface->SetDoubleSided(false); |
| 2764 backFacingChildOfBackFacingSurface->setDoubleSided(false); | 2764 backFacingChildOfBackFacingSurface->SetDoubleSided(false); |
| 2765 | 2765 |
| 2766 gfx::Transform backfaceMatrix; | 2766 gfx::Transform backfaceMatrix; |
| 2767 backfaceMatrix.Translate(50, 50); | 2767 backfaceMatrix.Translate(50, 50); |
| 2768 backfaceMatrix.RotateAboutYAxis(180); | 2768 backfaceMatrix.RotateAboutYAxis(180); |
| 2769 backfaceMatrix.Translate(-50, -50); | 2769 backfaceMatrix.Translate(-50, -50); |
| 2770 | 2770 |
| 2771 // Opacity will not force creation of renderSurfaces in this case because of
the | 2771 // Opacity will not force creation of renderSurfaces in this case because of
the |
| 2772 // preserve-3d transform style. Instead, an example of when a surface would
be | 2772 // preserve-3d transform style. Instead, an example of when a surface would
be |
| 2773 // created with preserve-3d is when there is a replica layer. | 2773 // created with preserve-3d is when there is a replica layer. |
| 2774 frontFacingSurface->setReplicaLayer(dummyReplicaLayer1.get()); | 2774 frontFacingSurface->SetReplicaLayer(dummyReplicaLayer1.get()); |
| 2775 backFacingSurface->setReplicaLayer(dummyReplicaLayer2.get()); | 2775 backFacingSurface->SetReplicaLayer(dummyReplicaLayer2.get()); |
| 2776 | 2776 |
| 2777 // Each surface creates its own new 3d rendering context (as defined by W3C
spec). | 2777 // Each surface creates its own new 3d rendering context (as defined by W3C
spec). |
| 2778 // According to current W3C CSS gfx::Transforms spec, layers in a 3d renderi
ng context | 2778 // According to current W3C CSS gfx::Transforms spec, layers in a 3d renderi
ng context |
| 2779 // should use the transform with respect to that context. This 3d rendering
context | 2779 // should use the transform with respect to that context. This 3d rendering
context |
| 2780 // occurs when (a) parent's transform style is flat and (b) the layer's tran
sform | 2780 // occurs when (a) parent's transform style is flat and (b) the layer's tran
sform |
| 2781 // style is preserve-3d. | 2781 // style is preserve-3d. |
| 2782 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // parent tran
sform style is flat. | 2782 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); // parent tran
sform style is flat. |
| 2783 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2783 setLayerPropertiesForTesting(frontFacingChild.get(), identityMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2784 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2784 setLayerPropertiesForTesting(backFacingChild.get(), backfaceMatrix, identity
Matrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2785 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); //
surface transform style is preserve-3d. | 2785 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); //
surface transform style is preserve-3d. |
| 2786 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // s
urface transform style is preserve-3d. | 2786 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, identi
tyMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // s
urface transform style is preserve-3d. |
| 2787 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); | 2787 setLayerPropertiesForTesting(frontFacingChildOfFrontFacingSurface.get(), ide
ntityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100
, 100), false); |
| 2788 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2788 setLayerPropertiesForTesting(backFacingChildOfFrontFacingSurface.get(), back
faceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
| 2789 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2789 setLayerPropertiesForTesting(frontFacingChildOfBackFacingSurface.get(), iden
tityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
| 2790 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); | 2790 setLayerPropertiesForTesting(backFacingChildOfBackFacingSurface.get(), backf
aceMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100,
100), false); |
| 2791 | 2791 |
| 2792 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2792 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 2793 int dummyMaxTextureSize = 512; | 2793 int dummyMaxTextureSize = 512; |
| 2794 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 2794 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 2795 | 2795 |
| 2796 // Verify which renderSurfaces were created. | 2796 // Verify which renderSurfaces were created. |
| 2797 EXPECT_FALSE(frontFacingChild->renderSurface()); | 2797 EXPECT_FALSE(frontFacingChild->render_surface()); |
| 2798 EXPECT_FALSE(backFacingChild->renderSurface()); | 2798 EXPECT_FALSE(backFacingChild->render_surface()); |
| 2799 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2799 EXPECT_TRUE(frontFacingSurface->render_surface()); |
| 2800 EXPECT_FALSE(backFacingSurface->renderSurface()); | 2800 EXPECT_FALSE(backFacingSurface->render_surface()); |
| 2801 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->renderSurface()); | 2801 EXPECT_FALSE(frontFacingChildOfFrontFacingSurface->render_surface()); |
| 2802 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->renderSurface()); | 2802 EXPECT_FALSE(backFacingChildOfFrontFacingSurface->render_surface()); |
| 2803 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->renderSurface()); | 2803 EXPECT_FALSE(frontFacingChildOfBackFacingSurface->render_surface()); |
| 2804 EXPECT_FALSE(backFacingChildOfBackFacingSurface->renderSurface()); | 2804 EXPECT_FALSE(backFacingChildOfBackFacingSurface->render_surface()); |
| 2805 | 2805 |
| 2806 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. | 2806 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. |
| 2807 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2807 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
| 2808 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2808 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
| 2809 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); | 2809 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); |
| 2810 | 2810 |
| 2811 // Verify root surface's layerList. | 2811 // Verify root surface's layerList. |
| 2812 ASSERT_EQ(2u, renderSurfaceLayerList[0]->renderSurface()->layer_list().size(
)); | 2812 ASSERT_EQ(2u, renderSurfaceLayerList[0]->render_surface()->layer_list().size
()); |
| 2813 EXPECT_EQ(frontFacingChild->id(), renderSurfaceLayerList[0]->renderSurface()
->layer_list()[0]->id()); | 2813 EXPECT_EQ(frontFacingChild->id(), renderSurfaceLayerList[0]->render_surface(
)->layer_list()[0]->id()); |
| 2814 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->renderSurface
()->layer_list()[1]->id()); | 2814 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->render_surfac
e()->layer_list()[1]->id()); |
| 2815 | 2815 |
| 2816 // Verify frontFacingSurface's layerList. | 2816 // Verify frontFacingSurface's layerList. |
| 2817 ASSERT_EQ(2u, renderSurfaceLayerList[1]->renderSurface()->layer_list().size(
)); | 2817 ASSERT_EQ(2u, renderSurfaceLayerList[1]->render_surface()->layer_list().size
()); |
| 2818 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->renderSurface
()->layer_list()[0]->id()); | 2818 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->render_surfac
e()->layer_list()[0]->id()); |
| 2819 EXPECT_EQ(frontFacingChildOfFrontFacingSurface->id(), renderSurfaceLayerList
[1]->renderSurface()->layer_list()[1]->id()); | 2819 EXPECT_EQ(frontFacingChildOfFrontFacingSurface->id(), renderSurfaceLayerList
[1]->render_surface()->layer_list()[1]->id()); |
| 2820 } | 2820 } |
| 2821 | 2821 |
| 2822 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms) | 2822 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms) |
| 2823 { | 2823 { |
| 2824 // Verify that layers are appropriately culled when their back face is showi
ng and | 2824 // Verify that layers are appropriately culled when their back face is showi
ng and |
| 2825 // they are not double sided, while animations are going on. | 2825 // they are not double sided, while animations are going on. |
| 2826 // | 2826 // |
| 2827 // Layers that are animating do not get culled on the main thread, as their
transforms should be | 2827 // Layers that are animating do not get culled on the main thread, as their
transforms should be |
| 2828 // treated as "unknown" so we can not be sure that their back face is really
showing. | 2828 // treated as "unknown" so we can not be sure that their back face is really
showing. |
| 2829 // | 2829 // |
| 2830 | 2830 |
| 2831 const gfx::Transform identityMatrix; | 2831 const gfx::Transform identityMatrix; |
| 2832 scoped_refptr<Layer> parent = Layer::create(); | 2832 scoped_refptr<Layer> parent = Layer::Create(); |
| 2833 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); | 2833 scoped_refptr<LayerWithForcedDrawsContent> child = make_scoped_refptr(new La
yerWithForcedDrawsContent()); |
| 2834 scoped_refptr<LayerWithForcedDrawsContent> animatingSurface = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); | 2834 scoped_refptr<LayerWithForcedDrawsContent> animatingSurface = make_scoped_re
fptr(new LayerWithForcedDrawsContent()); |
| 2835 scoped_refptr<LayerWithForcedDrawsContent> childOfAnimatingSurface = make_sc
oped_refptr(new LayerWithForcedDrawsContent()); | 2835 scoped_refptr<LayerWithForcedDrawsContent> childOfAnimatingSurface = make_sc
oped_refptr(new LayerWithForcedDrawsContent()); |
| 2836 scoped_refptr<LayerWithForcedDrawsContent> animatingChild = make_scoped_refp
tr(new LayerWithForcedDrawsContent()); | 2836 scoped_refptr<LayerWithForcedDrawsContent> animatingChild = make_scoped_refp
tr(new LayerWithForcedDrawsContent()); |
| 2837 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2837 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2838 | 2838 |
| 2839 parent->addChild(child); | 2839 parent->AddChild(child); |
| 2840 parent->addChild(animatingSurface); | 2840 parent->AddChild(animatingSurface); |
| 2841 animatingSurface->addChild(childOfAnimatingSurface); | 2841 animatingSurface->AddChild(childOfAnimatingSurface); |
| 2842 parent->addChild(animatingChild); | 2842 parent->AddChild(animatingChild); |
| 2843 parent->addChild(child2); | 2843 parent->AddChild(child2); |
| 2844 | 2844 |
| 2845 // Nothing is double-sided | 2845 // Nothing is double-sided |
| 2846 child->setDoubleSided(false); | 2846 child->SetDoubleSided(false); |
| 2847 child2->setDoubleSided(false); | 2847 child2->SetDoubleSided(false); |
| 2848 animatingSurface->setDoubleSided(false); | 2848 animatingSurface->SetDoubleSided(false); |
| 2849 childOfAnimatingSurface->setDoubleSided(false); | 2849 childOfAnimatingSurface->SetDoubleSided(false); |
| 2850 animatingChild->setDoubleSided(false); | 2850 animatingChild->SetDoubleSided(false); |
| 2851 | 2851 |
| 2852 gfx::Transform backfaceMatrix; | 2852 gfx::Transform backfaceMatrix; |
| 2853 backfaceMatrix.Translate(50, 50); | 2853 backfaceMatrix.Translate(50, 50); |
| 2854 backfaceMatrix.RotateAboutYAxis(180); | 2854 backfaceMatrix.RotateAboutYAxis(180); |
| 2855 backfaceMatrix.Translate(-50, -50); | 2855 backfaceMatrix.Translate(-50, -50); |
| 2856 | 2856 |
| 2857 // Make our render surface. | 2857 // Make our render surface. |
| 2858 animatingSurface->setForceRenderSurface(true); | 2858 animatingSurface->SetForceRenderSurface(true); |
| 2859 | 2859 |
| 2860 // Animate the transform on the render surface. | 2860 // Animate the transform on the render surface. |
| 2861 addAnimatedTransformToController(*animatingSurface->layerAnimationController
(), 10, 30, 0); | 2861 addAnimatedTransformToController(*animatingSurface->layer_animation_controll
er(), 10, 30, 0); |
| 2862 // This is just an animating layer, not a surface. | 2862 // This is just an animating layer, not a surface. |
| 2863 addAnimatedTransformToController(*animatingChild->layerAnimationController()
, 10, 30, 0); | 2863 addAnimatedTransformToController(*animatingChild->layer_animation_controller
(), 10, 30, 0); |
| 2864 | 2864 |
| 2865 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2865 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2866 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2866 setLayerPropertiesForTesting(child.get(), backfaceMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2867 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2867 setLayerPropertiesForTesting(animatingSurface.get(), backfaceMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2868 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false
); | 2868 setLayerPropertiesForTesting(childOfAnimatingSurface.get(), backfaceMatrix,
identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false
); |
| 2869 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2869 setLayerPropertiesForTesting(animatingChild.get(), backfaceMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2870 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2870 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2871 | 2871 |
| 2872 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2872 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 2873 int dummyMaxTextureSize = 512; | 2873 int dummyMaxTextureSize = 512; |
| 2874 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 2874 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 2875 | 2875 |
| 2876 EXPECT_FALSE(child->renderSurface()); | 2876 EXPECT_FALSE(child->render_surface()); |
| 2877 EXPECT_TRUE(animatingSurface->renderSurface()); | 2877 EXPECT_TRUE(animatingSurface->render_surface()); |
| 2878 EXPECT_FALSE(childOfAnimatingSurface->renderSurface()); | 2878 EXPECT_FALSE(childOfAnimatingSurface->render_surface()); |
| 2879 EXPECT_FALSE(animatingChild->renderSurface()); | 2879 EXPECT_FALSE(animatingChild->render_surface()); |
| 2880 EXPECT_FALSE(child2->renderSurface()); | 2880 EXPECT_FALSE(child2->render_surface()); |
| 2881 | 2881 |
| 2882 // Verify that the animatingChild and childOfAnimatingSurface were not culle
d, but that child was. | 2882 // Verify that the animatingChild and childOfAnimatingSurface were not culle
d, but that child was. |
| 2883 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2883 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
| 2884 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2884 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
| 2885 EXPECT_EQ(animatingSurface->id(), renderSurfaceLayerList[1]->id()); | 2885 EXPECT_EQ(animatingSurface->id(), renderSurfaceLayerList[1]->id()); |
| 2886 | 2886 |
| 2887 // The non-animating child be culled from the layer list for the parent rend
er surface. | 2887 // The non-animating child be culled from the layer list for the parent rend
er surface. |
| 2888 ASSERT_EQ(3u, renderSurfaceLayerList[0]->renderSurface()->layer_list().size(
)); | 2888 ASSERT_EQ(3u, renderSurfaceLayerList[0]->render_surface()->layer_list().size
()); |
| 2889 EXPECT_EQ(animatingSurface->id(), renderSurfaceLayerList[0]->renderSurface()
->layer_list()[0]->id()); | 2889 EXPECT_EQ(animatingSurface->id(), renderSurfaceLayerList[0]->render_surface(
)->layer_list()[0]->id()); |
| 2890 EXPECT_EQ(animatingChild->id(), renderSurfaceLayerList[0]->renderSurface()->
layer_list()[1]->id()); | 2890 EXPECT_EQ(animatingChild->id(), renderSurfaceLayerList[0]->render_surface()-
>layer_list()[1]->id()); |
| 2891 EXPECT_EQ(child2->id(), renderSurfaceLayerList[0]->renderSurface()->layer_li
st()[2]->id()); | 2891 EXPECT_EQ(child2->id(), renderSurfaceLayerList[0]->render_surface()->layer_l
ist()[2]->id()); |
| 2892 | 2892 |
| 2893 ASSERT_EQ(2u, renderSurfaceLayerList[1]->renderSurface()->layer_list().size(
)); | 2893 ASSERT_EQ(2u, renderSurfaceLayerList[1]->render_surface()->layer_list().size
()); |
| 2894 EXPECT_EQ(animatingSurface->id(), renderSurfaceLayerList[1]->renderSurface()
->layer_list()[0]->id()); | 2894 EXPECT_EQ(animatingSurface->id(), renderSurfaceLayerList[1]->render_surface(
)->layer_list()[0]->id()); |
| 2895 EXPECT_EQ(childOfAnimatingSurface->id(), renderSurfaceLayerList[1]->renderSu
rface()->layer_list()[1]->id()); | 2895 EXPECT_EQ(childOfAnimatingSurface->id(), renderSurfaceLayerList[1]->render_s
urface()->layer_list()[1]->id()); |
| 2896 | 2896 |
| 2897 EXPECT_FALSE(child2->visibleContentRect().IsEmpty()); | 2897 EXPECT_FALSE(child2->visible_content_rect().IsEmpty()); |
| 2898 | 2898 |
| 2899 // The animating layers should have a visibleContentRect that represents the
area of the front face that is within the viewport. | 2899 // The animating layers should have a visibleContentRect that represents the
area of the front face that is within the viewport. |
| 2900 EXPECT_EQ(animatingChild->visibleContentRect(), gfx::Rect(gfx::Point(), anim
atingChild->contentBounds())); | 2900 EXPECT_EQ(animatingChild->visible_content_rect(), gfx::Rect(gfx::Point(), an
imatingChild->content_bounds())); |
| 2901 EXPECT_EQ(animatingSurface->visibleContentRect(), gfx::Rect(gfx::Point(), an
imatingSurface->contentBounds())); | 2901 EXPECT_EQ(animatingSurface->visible_content_rect(), gfx::Rect(gfx::Point(),
animatingSurface->content_bounds())); |
| 2902 // And layers in the subtree of the animating layer should have valid visibl
eContentRects also. | 2902 // And layers in the subtree of the animating layer should have valid visibl
eContentRects also. |
| 2903 EXPECT_EQ(childOfAnimatingSurface->visibleContentRect(), gfx::Rect(gfx::Poin
t(), childOfAnimatingSurface->contentBounds())); | 2903 EXPECT_EQ(childOfAnimatingSurface->visible_content_rect(), gfx::Rect(gfx::Po
int(), childOfAnimatingSurface->content_bounds())); |
| 2904 } | 2904 } |
| 2905 | 2905 |
| 2906 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS
urface) | 2906 TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS
urface) |
| 2907 { | 2907 { |
| 2908 // Verify the behavior of back-face culling for a renderSurface that is crea
ted | 2908 // Verify the behavior of back-face culling for a renderSurface that is crea
ted |
| 2909 // when it flattens its subtree, and its parent has preserves-3d. | 2909 // when it flattens its subtree, and its parent has preserves-3d. |
| 2910 | 2910 |
| 2911 const gfx::Transform identityMatrix; | 2911 const gfx::Transform identityMatrix; |
| 2912 scoped_refptr<Layer> parent = Layer::create(); | 2912 scoped_refptr<Layer> parent = Layer::Create(); |
| 2913 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); | 2913 scoped_refptr<LayerWithForcedDrawsContent> frontFacingSurface = make_scoped_
refptr(new LayerWithForcedDrawsContent()); |
| 2914 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); | 2914 scoped_refptr<LayerWithForcedDrawsContent> backFacingSurface = make_scoped_r
efptr(new LayerWithForcedDrawsContent()); |
| 2915 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2915 scoped_refptr<LayerWithForcedDrawsContent> child1 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2916 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); | 2916 scoped_refptr<LayerWithForcedDrawsContent> child2 = make_scoped_refptr(new L
ayerWithForcedDrawsContent()); |
| 2917 | 2917 |
| 2918 parent->addChild(frontFacingSurface); | 2918 parent->AddChild(frontFacingSurface); |
| 2919 parent->addChild(backFacingSurface); | 2919 parent->AddChild(backFacingSurface); |
| 2920 frontFacingSurface->addChild(child1); | 2920 frontFacingSurface->AddChild(child1); |
| 2921 backFacingSurface->addChild(child2); | 2921 backFacingSurface->AddChild(child2); |
| 2922 | 2922 |
| 2923 // RenderSurfaces are not double-sided | 2923 // RenderSurfaces are not double-sided |
| 2924 frontFacingSurface->setDoubleSided(false); | 2924 frontFacingSurface->SetDoubleSided(false); |
| 2925 backFacingSurface->setDoubleSided(false); | 2925 backFacingSurface->SetDoubleSided(false); |
| 2926 | 2926 |
| 2927 gfx::Transform backfaceMatrix; | 2927 gfx::Transform backfaceMatrix; |
| 2928 backfaceMatrix.Translate(50, 50); | 2928 backfaceMatrix.Translate(50, 50); |
| 2929 backfaceMatrix.RotateAboutYAxis(180); | 2929 backfaceMatrix.RotateAboutYAxis(180); |
| 2930 backfaceMatrix.Translate(-50, -50); | 2930 backfaceMatrix.Translate(-50, -50); |
| 2931 | 2931 |
| 2932 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans
form style is preserve3d. | 2932 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); // parent trans
form style is preserve3d. |
| 2933 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. | 2933 setLayerPropertiesForTesting(frontFacingSurface.get(), identityMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. |
| 2934 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. | 2934 setLayerPropertiesForTesting(backFacingSurface.get(), backfaceMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); //
surface transform style is flat. |
| 2935 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2935 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2936 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); | 2936 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 2937 | 2937 |
| 2938 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 2938 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 2939 int dummyMaxTextureSize = 512; | 2939 int dummyMaxTextureSize = 512; |
| 2940 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 2940 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 2941 | 2941 |
| 2942 // Verify which renderSurfaces were created. | 2942 // Verify which renderSurfaces were created. |
| 2943 EXPECT_TRUE(frontFacingSurface->renderSurface()); | 2943 EXPECT_TRUE(frontFacingSurface->render_surface()); |
| 2944 EXPECT_FALSE(backFacingSurface->renderSurface()); // because it should be cu
lled | 2944 EXPECT_FALSE(backFacingSurface->render_surface()); // because it should be c
ulled |
| 2945 EXPECT_FALSE(child1->renderSurface()); | 2945 EXPECT_FALSE(child1->render_surface()); |
| 2946 EXPECT_FALSE(child2->renderSurface()); | 2946 EXPECT_FALSE(child2->render_surface()); |
| 2947 | 2947 |
| 2948 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. | 2948 // Verify the renderSurfaceLayerList. The back-facing surface should be cull
ed. |
| 2949 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 2949 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
| 2950 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); | 2950 EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id()); |
| 2951 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); | 2951 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->id()); |
| 2952 | 2952 |
| 2953 // Verify root surface's layerList. | 2953 // Verify root surface's layerList. |
| 2954 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layer_list().size(
)); | 2954 ASSERT_EQ(1u, renderSurfaceLayerList[0]->render_surface()->layer_list().size
()); |
| 2955 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->renderSurface
()->layer_list()[0]->id()); | 2955 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[0]->render_surfac
e()->layer_list()[0]->id()); |
| 2956 | 2956 |
| 2957 // Verify frontFacingSurface's layerList. | 2957 // Verify frontFacingSurface's layerList. |
| 2958 ASSERT_EQ(2u, renderSurfaceLayerList[1]->renderSurface()->layer_list().size(
)); | 2958 ASSERT_EQ(2u, renderSurfaceLayerList[1]->render_surface()->layer_list().size
()); |
| 2959 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->renderSurface
()->layer_list()[0]->id()); | 2959 EXPECT_EQ(frontFacingSurface->id(), renderSurfaceLayerList[1]->render_surfac
e()->layer_list()[0]->id()); |
| 2960 EXPECT_EQ(child1->id(), renderSurfaceLayerList[1]->renderSurface()->layer_li
st()[1]->id()); | 2960 EXPECT_EQ(child1->id(), renderSurfaceLayerList[1]->render_surface()->layer_l
ist()[1]->id()); |
| 2961 } | 2961 } |
| 2962 | 2962 |
| 2963 TEST(LayerTreeHostCommonTest, verifyHitTestingForEmptyLayerList) | 2963 TEST(LayerTreeHostCommonTest, verifyHitTestingForEmptyLayerList) |
| 2964 { | 2964 { |
| 2965 // Hit testing on an empty renderSurfaceLayerList should return a null point
er. | 2965 // Hit testing on an empty renderSurfaceLayerList should return a null point
er. |
| 2966 std::vector<LayerImpl*> renderSurfaceLayerList; | 2966 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 2967 | 2967 |
| 2968 gfx::Point testPoint(0, 0); | 2968 gfx::Point testPoint(0, 0); |
| 2969 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 2969 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 2970 EXPECT_FALSE(resultLayer); | 2970 EXPECT_FALSE(resultLayer); |
| 2971 | 2971 |
| 2972 testPoint = gfx::Point(10, 20); | 2972 testPoint = gfx::Point(10, 20); |
| 2973 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 2973 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 2974 EXPECT_FALSE(resultLayer); | 2974 EXPECT_FALSE(resultLayer); |
| 2975 } | 2975 } |
| 2976 | 2976 |
| 2977 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) | 2977 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer) |
| 2978 { | 2978 { |
| 2979 FakeImplProxy proxy; | 2979 FakeImplProxy proxy; |
| 2980 FakeLayerTreeHostImpl hostImpl(&proxy); | 2980 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 2981 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; | 2981 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; |
| 2982 | 2982 |
| 2983 gfx::Transform identityMatrix; | 2983 gfx::Transform identityMatrix; |
| 2984 gfx::PointF anchor(0, 0); | 2984 gfx::PointF anchor(0, 0); |
| 2985 gfx::PointF position(0, 0); | 2985 gfx::PointF position(0, 0); |
| 2986 gfx::Size bounds(100, 100); | 2986 gfx::Size bounds(100, 100); |
| 2987 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 2987 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 2988 root->setDrawsContent(true); | 2988 root->SetDrawsContent(true); |
| 2989 | 2989 |
| 2990 std::vector<LayerImpl*> renderSurfaceLayerList; | 2990 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 2991 int dummyMaxTextureSize = 512; | 2991 int dummyMaxTextureSize = 512; |
| 2992 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 2992 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 2993 | 2993 |
| 2994 // Sanity check the scenario we just created. | 2994 // Sanity check the scenario we just created. |
| 2995 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 2995 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 2996 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 2996 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 2997 | 2997 |
| 2998 // Hit testing for a point outside the layer should return a null pointer. | 2998 // Hit testing for a point outside the layer should return a null pointer. |
| 2999 gfx::Point testPoint(101, 101); | 2999 gfx::Point testPoint(101, 101); |
| 3000 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3000 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3001 EXPECT_FALSE(resultLayer); | 3001 EXPECT_FALSE(resultLayer); |
| 3002 | 3002 |
| 3003 testPoint = gfx::Point(-1, -1); | 3003 testPoint = gfx::Point(-1, -1); |
| 3004 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3004 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3005 EXPECT_FALSE(resultLayer); | 3005 EXPECT_FALSE(resultLayer); |
| 3006 | 3006 |
| 3007 // Hit testing for a point inside should return the root layer. | 3007 // Hit testing for a point inside should return the root layer. |
| 3008 testPoint = gfx::Point(1, 1); | 3008 testPoint = gfx::Point(1, 1); |
| 3009 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3009 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3010 ASSERT_TRUE(resultLayer); | 3010 ASSERT_TRUE(resultLayer); |
| 3011 EXPECT_EQ(12345, resultLayer->id()); | 3011 EXPECT_EQ(12345, resultLayer->id()); |
| 3012 | 3012 |
| 3013 testPoint = gfx::Point(99, 99); | 3013 testPoint = gfx::Point(99, 99); |
| 3014 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3014 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3015 ASSERT_TRUE(resultLayer); | 3015 ASSERT_TRUE(resultLayer); |
| 3016 EXPECT_EQ(12345, resultLayer->id()); | 3016 EXPECT_EQ(12345, resultLayer->id()); |
| 3017 } | 3017 } |
| 3018 | 3018 |
| 3019 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerAndHud) | 3019 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerAndHud) |
| 3020 { | 3020 { |
| 3021 FakeImplProxy proxy; | 3021 FakeImplProxy proxy; |
| 3022 FakeLayerTreeHostImpl hostImpl(&proxy); | 3022 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3023 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; | 3023 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; |
| 3024 scoped_ptr<HeadsUpDisplayLayerImpl> hud = HeadsUpDisplayLayerImpl::create(ho
stImpl.activeTree(), 11111); | 3024 scoped_ptr<HeadsUpDisplayLayerImpl> hud = HeadsUpDisplayLayerImpl::Create(ho
stImpl.activeTree(), 11111); |
| 3025 | 3025 |
| 3026 gfx::Transform identityMatrix; | 3026 gfx::Transform identityMatrix; |
| 3027 gfx::PointF anchor(0.f, 0.f); | 3027 gfx::PointF anchor(0.f, 0.f); |
| 3028 gfx::PointF position(0.f, 0.f); | 3028 gfx::PointF position(0.f, 0.f); |
| 3029 gfx::Size bounds(100, 100); | 3029 gfx::Size bounds(100, 100); |
| 3030 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3030 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3031 root->setDrawsContent(true); | 3031 root->SetDrawsContent(true); |
| 3032 | 3032 |
| 3033 // Create hud and add it as a child of root. | 3033 // Create hud and add it as a child of root. |
| 3034 gfx::Size hudBounds(200, 200); | 3034 gfx::Size hudBounds(200, 200); |
| 3035 setLayerPropertiesForTesting(hud.get(), identityMatrix, identityMatrix, anch
or, position, hudBounds, false); | 3035 setLayerPropertiesForTesting(hud.get(), identityMatrix, identityMatrix, anch
or, position, hudBounds, false); |
| 3036 hud->setDrawsContent(true); | 3036 hud->SetDrawsContent(true); |
| 3037 | 3037 |
| 3038 hostImpl.activeTree()->set_hud_layer(hud.get()); | 3038 hostImpl.activeTree()->set_hud_layer(hud.get()); |
| 3039 root->addChild(hud.PassAs<LayerImpl>()); | 3039 root->AddChild(hud.PassAs<LayerImpl>()); |
| 3040 | 3040 |
| 3041 std::vector<LayerImpl*> renderSurfaceLayerList; | 3041 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3042 int dummyMaxTextureSize = 512; | 3042 int dummyMaxTextureSize = 512; |
| 3043 LayerTreeHostCommon::calculateDrawProperties(root.get(), hudBounds, 1, 1, du
mmyMaxTextureSize, false, renderSurfaceLayerList, false); | 3043 LayerTreeHostCommon::calculateDrawProperties(root.get(), hudBounds, 1, 1, du
mmyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3044 | 3044 |
| 3045 // Sanity check the scenario we just created. | 3045 // Sanity check the scenario we just created. |
| 3046 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3046 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3047 ASSERT_EQ(2u, root->renderSurface()->layer_list().size()); | 3047 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 3048 | 3048 |
| 3049 // Hit testing for a point inside HUD, but outside root should return null | 3049 // Hit testing for a point inside HUD, but outside root should return null |
| 3050 gfx::Point testPoint(101, 101); | 3050 gfx::Point testPoint(101, 101); |
| 3051 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3051 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3052 EXPECT_FALSE(resultLayer); | 3052 EXPECT_FALSE(resultLayer); |
| 3053 | 3053 |
| 3054 testPoint = gfx::Point(-1, -1); | 3054 testPoint = gfx::Point(-1, -1); |
| 3055 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3055 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3056 EXPECT_FALSE(resultLayer); | 3056 EXPECT_FALSE(resultLayer); |
| 3057 | 3057 |
| 3058 // Hit testing for a point inside should return the root layer, never the HU
D layer. | 3058 // Hit testing for a point inside should return the root layer, never the HU
D layer. |
| 3059 testPoint = gfx::Point(1, 1); | 3059 testPoint = gfx::Point(1, 1); |
| 3060 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3060 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3061 ASSERT_TRUE(resultLayer); | 3061 ASSERT_TRUE(resultLayer); |
| 3062 EXPECT_EQ(12345, resultLayer->id()); | 3062 EXPECT_EQ(12345, resultLayer->id()); |
| 3063 | 3063 |
| 3064 testPoint = gfx::Point(99, 99); | 3064 testPoint = gfx::Point(99, 99); |
| 3065 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3065 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3066 ASSERT_TRUE(resultLayer); | 3066 ASSERT_TRUE(resultLayer); |
| 3067 EXPECT_EQ(12345, resultLayer->id()); | 3067 EXPECT_EQ(12345, resultLayer->id()); |
| 3068 } | 3068 } |
| 3069 | 3069 |
| 3070 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) | 3070 TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform) |
| 3071 { | 3071 { |
| 3072 FakeImplProxy proxy; | 3072 FakeImplProxy proxy; |
| 3073 FakeLayerTreeHostImpl hostImpl(&proxy); | 3073 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3074 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; | 3074 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; |
| 3075 | 3075 |
| 3076 gfx::Transform uninvertibleTransform; | 3076 gfx::Transform uninvertibleTransform; |
| 3077 uninvertibleTransform.matrix().setDouble(0, 0, 0); | 3077 uninvertibleTransform.matrix().setDouble(0, 0, 0); |
| 3078 uninvertibleTransform.matrix().setDouble(1, 1, 0); | 3078 uninvertibleTransform.matrix().setDouble(1, 1, 0); |
| 3079 uninvertibleTransform.matrix().setDouble(2, 2, 0); | 3079 uninvertibleTransform.matrix().setDouble(2, 2, 0); |
| 3080 uninvertibleTransform.matrix().setDouble(3, 3, 0); | 3080 uninvertibleTransform.matrix().setDouble(3, 3, 0); |
| 3081 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); | 3081 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); |
| 3082 | 3082 |
| 3083 gfx::Transform identityMatrix; | 3083 gfx::Transform identityMatrix; |
| 3084 gfx::PointF anchor(0, 0); | 3084 gfx::PointF anchor(0, 0); |
| 3085 gfx::PointF position(0, 0); | 3085 gfx::PointF position(0, 0); |
| 3086 gfx::Size bounds(100, 100); | 3086 gfx::Size bounds(100, 100); |
| 3087 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); | 3087 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); |
| 3088 root->setDrawsContent(true); | 3088 root->SetDrawsContent(true); |
| 3089 | 3089 |
| 3090 std::vector<LayerImpl*> renderSurfaceLayerList; | 3090 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3091 int dummyMaxTextureSize = 512; | 3091 int dummyMaxTextureSize = 512; |
| 3092 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3092 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3093 | 3093 |
| 3094 // Sanity check the scenario we just created. | 3094 // Sanity check the scenario we just created. |
| 3095 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3095 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3096 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 3096 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 3097 ASSERT_FALSE(root->screenSpaceTransform().IsInvertible()); | 3097 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); |
| 3098 | 3098 |
| 3099 // Hit testing any point should not hit the layer. If the invertible matrix
is | 3099 // Hit testing any point should not hit the layer. If the invertible matrix
is |
| 3100 // accidentally ignored and treated like an identity, then the hit testing w
ill | 3100 // accidentally ignored and treated like an identity, then the hit testing w
ill |
| 3101 // incorrectly hit the layer when it shouldn't. | 3101 // incorrectly hit the layer when it shouldn't. |
| 3102 gfx::Point testPoint(1, 1); | 3102 gfx::Point testPoint(1, 1); |
| 3103 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3103 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3104 EXPECT_FALSE(resultLayer); | 3104 EXPECT_FALSE(resultLayer); |
| 3105 | 3105 |
| 3106 testPoint = gfx::Point(10, 10); | 3106 testPoint = gfx::Point(10, 10); |
| 3107 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3107 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3125 | 3125 |
| 3126 testPoint = gfx::Point(-1, -1); | 3126 testPoint = gfx::Point(-1, -1); |
| 3127 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3127 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3128 EXPECT_FALSE(resultLayer); | 3128 EXPECT_FALSE(resultLayer); |
| 3129 } | 3129 } |
| 3130 | 3130 |
| 3131 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) | 3131 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer) |
| 3132 { | 3132 { |
| 3133 FakeImplProxy proxy; | 3133 FakeImplProxy proxy; |
| 3134 FakeLayerTreeHostImpl hostImpl(&proxy); | 3134 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3135 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; | 3135 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; |
| 3136 | 3136 |
| 3137 gfx::Transform identityMatrix; | 3137 gfx::Transform identityMatrix; |
| 3138 gfx::PointF anchor(0, 0); | 3138 gfx::PointF anchor(0, 0); |
| 3139 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. | 3139 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. |
| 3140 gfx::Size bounds(100, 100); | 3140 gfx::Size bounds(100, 100); |
| 3141 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3141 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3142 root->setDrawsContent(true); | 3142 root->SetDrawsContent(true); |
| 3143 | 3143 |
| 3144 std::vector<LayerImpl*> renderSurfaceLayerList; | 3144 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3145 int dummyMaxTextureSize = 512; | 3145 int dummyMaxTextureSize = 512; |
| 3146 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3146 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3147 | 3147 |
| 3148 // Sanity check the scenario we just created. | 3148 // Sanity check the scenario we just created. |
| 3149 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3149 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3150 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 3150 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 3151 | 3151 |
| 3152 // Hit testing for a point outside the layer should return a null pointer. | 3152 // Hit testing for a point outside the layer should return a null pointer. |
| 3153 gfx::Point testPoint(49, 49); | 3153 gfx::Point testPoint(49, 49); |
| 3154 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3154 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3155 EXPECT_FALSE(resultLayer); | 3155 EXPECT_FALSE(resultLayer); |
| 3156 | 3156 |
| 3157 // Even though the layer exists at (101, 101), it should not be visible ther
e since the root renderSurface would clamp it. | 3157 // Even though the layer exists at (101, 101), it should not be visible ther
e since the root renderSurface would clamp it. |
| 3158 testPoint = gfx::Point(101, 101); | 3158 testPoint = gfx::Point(101, 101); |
| 3159 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3159 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3160 EXPECT_FALSE(resultLayer); | 3160 EXPECT_FALSE(resultLayer); |
| 3161 | 3161 |
| 3162 // Hit testing for a point inside should return the root layer. | 3162 // Hit testing for a point inside should return the root layer. |
| 3163 testPoint = gfx::Point(51, 51); | 3163 testPoint = gfx::Point(51, 51); |
| 3164 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3164 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3165 ASSERT_TRUE(resultLayer); | 3165 ASSERT_TRUE(resultLayer); |
| 3166 EXPECT_EQ(12345, resultLayer->id()); | 3166 EXPECT_EQ(12345, resultLayer->id()); |
| 3167 | 3167 |
| 3168 testPoint = gfx::Point(99, 99); | 3168 testPoint = gfx::Point(99, 99); |
| 3169 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3169 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3170 ASSERT_TRUE(resultLayer); | 3170 ASSERT_TRUE(resultLayer); |
| 3171 EXPECT_EQ(12345, resultLayer->id()); | 3171 EXPECT_EQ(12345, resultLayer->id()); |
| 3172 } | 3172 } |
| 3173 | 3173 |
| 3174 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) | 3174 TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer) |
| 3175 { | 3175 { |
| 3176 FakeImplProxy proxy; | 3176 FakeImplProxy proxy; |
| 3177 FakeLayerTreeHostImpl hostImpl(&proxy); | 3177 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3178 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; | 3178 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; |
| 3179 | 3179 |
| 3180 gfx::Transform identityMatrix; | 3180 gfx::Transform identityMatrix; |
| 3181 gfx::Transform rotation45DegreesAboutCenter; | 3181 gfx::Transform rotation45DegreesAboutCenter; |
| 3182 rotation45DegreesAboutCenter.Translate(50, 50); | 3182 rotation45DegreesAboutCenter.Translate(50, 50); |
| 3183 rotation45DegreesAboutCenter.RotateAboutZAxis(45); | 3183 rotation45DegreesAboutCenter.RotateAboutZAxis(45); |
| 3184 rotation45DegreesAboutCenter.Translate(-50, -50); | 3184 rotation45DegreesAboutCenter.Translate(-50, -50); |
| 3185 gfx::PointF anchor(0, 0); | 3185 gfx::PointF anchor(0, 0); |
| 3186 gfx::PointF position(0, 0); | 3186 gfx::PointF position(0, 0); |
| 3187 gfx::Size bounds(100, 100); | 3187 gfx::Size bounds(100, 100); |
| 3188 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); | 3188 setLayerPropertiesForTesting(root.get(), rotation45DegreesAboutCenter, ident
ityMatrix, anchor, position, bounds, false); |
| 3189 root->setDrawsContent(true); | 3189 root->SetDrawsContent(true); |
| 3190 | 3190 |
| 3191 std::vector<LayerImpl*> renderSurfaceLayerList; | 3191 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3192 int dummyMaxTextureSize = 512; | 3192 int dummyMaxTextureSize = 512; |
| 3193 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3193 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3194 | 3194 |
| 3195 // Sanity check the scenario we just created. | 3195 // Sanity check the scenario we just created. |
| 3196 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3196 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3197 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 3197 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 3198 | 3198 |
| 3199 // Hit testing for points outside the layer. | 3199 // Hit testing for points outside the layer. |
| 3200 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. | 3200 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. |
| 3201 gfx::Point testPoint(99, 99); | 3201 gfx::Point testPoint(99, 99); |
| 3202 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3202 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3203 EXPECT_FALSE(resultLayer); | 3203 EXPECT_FALSE(resultLayer); |
| 3204 | 3204 |
| 3205 testPoint = gfx::Point(1, 1); | 3205 testPoint = gfx::Point(1, 1); |
| 3206 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3206 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3207 EXPECT_FALSE(resultLayer); | 3207 EXPECT_FALSE(resultLayer); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3219 | 3219 |
| 3220 testPoint = gfx::Point(-1, 50); | 3220 testPoint = gfx::Point(-1, 50); |
| 3221 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3221 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3222 ASSERT_FALSE(resultLayer); | 3222 ASSERT_FALSE(resultLayer); |
| 3223 } | 3223 } |
| 3224 | 3224 |
| 3225 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) | 3225 TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer) |
| 3226 { | 3226 { |
| 3227 FakeImplProxy proxy; | 3227 FakeImplProxy proxy; |
| 3228 FakeLayerTreeHostImpl hostImpl(&proxy); | 3228 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3229 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; | 3229 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; |
| 3230 | 3230 |
| 3231 gfx::Transform identityMatrix; | 3231 gfx::Transform identityMatrix; |
| 3232 | 3232 |
| 3233 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). | 3233 // perspectiveProjectionAboutCenter * translationByZ is designed so that the
100 x 100 layer becomes 50 x 50, and remains centered at (50, 50). |
| 3234 gfx::Transform perspectiveProjectionAboutCenter; | 3234 gfx::Transform perspectiveProjectionAboutCenter; |
| 3235 perspectiveProjectionAboutCenter.Translate(50, 50); | 3235 perspectiveProjectionAboutCenter.Translate(50, 50); |
| 3236 perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1); | 3236 perspectiveProjectionAboutCenter.ApplyPerspectiveDepth(1); |
| 3237 perspectiveProjectionAboutCenter.Translate(-50, -50); | 3237 perspectiveProjectionAboutCenter.Translate(-50, -50); |
| 3238 gfx::Transform translationByZ; | 3238 gfx::Transform translationByZ; |
| 3239 translationByZ.Translate3d(0, 0, -1); | 3239 translationByZ.Translate3d(0, 0, -1); |
| 3240 | 3240 |
| 3241 gfx::PointF anchor(0, 0); | 3241 gfx::PointF anchor(0, 0); |
| 3242 gfx::PointF position(0, 0); | 3242 gfx::PointF position(0, 0); |
| 3243 gfx::Size bounds(100, 100); | 3243 gfx::Size bounds(100, 100); |
| 3244 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); | 3244 setLayerPropertiesForTesting(root.get(), perspectiveProjectionAboutCenter *
translationByZ, identityMatrix, anchor, position, bounds, false); |
| 3245 root->setDrawsContent(true); | 3245 root->SetDrawsContent(true); |
| 3246 | 3246 |
| 3247 std::vector<LayerImpl*> renderSurfaceLayerList; | 3247 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3248 int dummyMaxTextureSize = 512; | 3248 int dummyMaxTextureSize = 512; |
| 3249 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3249 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3250 | 3250 |
| 3251 // Sanity check the scenario we just created. | 3251 // Sanity check the scenario we just created. |
| 3252 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3252 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3253 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 3253 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 3254 | 3254 |
| 3255 // Hit testing for points outside the layer. | 3255 // Hit testing for points outside the layer. |
| 3256 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. | 3256 // These corners would have been inside the un-transformed layer, but they s
hould not hit the correctly transformed layer. |
| 3257 gfx::Point testPoint(24, 24); | 3257 gfx::Point testPoint(24, 24); |
| 3258 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3258 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3259 EXPECT_FALSE(resultLayer); | 3259 EXPECT_FALSE(resultLayer); |
| 3260 | 3260 |
| 3261 testPoint = gfx::Point(76, 76); | 3261 testPoint = gfx::Point(76, 76); |
| 3262 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3262 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3263 EXPECT_FALSE(resultLayer); | 3263 EXPECT_FALSE(resultLayer); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3281 // test makes sure that hit testing works correctly accounts for the content
s scale. | 3281 // test makes sure that hit testing works correctly accounts for the content
s scale. |
| 3282 // A contentsScale that is not 1 effectively forces a non-identity transform
between | 3282 // A contentsScale that is not 1 effectively forces a non-identity transform
between |
| 3283 // layer's content space and layer's origin space. The hit testing code must
take this into account. | 3283 // layer's content space and layer's origin space. The hit testing code must
take this into account. |
| 3284 // | 3284 // |
| 3285 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If | 3285 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If |
| 3286 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect | 3286 // contentsScale is ignored, then hit testing will mis-interpret the visible
ContentRect |
| 3287 // as being larger than the actual bounds of the layer. | 3287 // as being larger than the actual bounds of the layer. |
| 3288 // | 3288 // |
| 3289 FakeImplProxy proxy; | 3289 FakeImplProxy proxy; |
| 3290 FakeLayerTreeHostImpl hostImpl(&proxy); | 3290 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3291 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1); | 3291 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); |
| 3292 | 3292 |
| 3293 gfx::Transform identityMatrix; | 3293 gfx::Transform identityMatrix; |
| 3294 gfx::PointF anchor(0, 0); | 3294 gfx::PointF anchor(0, 0); |
| 3295 | 3295 |
| 3296 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3296 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3297 | 3297 |
| 3298 { | 3298 { |
| 3299 gfx::PointF position(25, 25); | 3299 gfx::PointF position(25, 25); |
| 3300 gfx::Size bounds(50, 50); | 3300 gfx::Size bounds(50, 50); |
| 3301 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(hostImpl.activeTree(
), 12345); | 3301 scoped_ptr<LayerImpl> testLayer = LayerImpl::Create(hostImpl.activeTree(
), 12345); |
| 3302 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 3302 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
| 3303 | 3303 |
| 3304 // override contentBounds and contentsScale | 3304 // override contentBounds and contentsScale |
| 3305 testLayer->setContentBounds(gfx::Size(100, 100)); | 3305 testLayer->SetContentBounds(gfx::Size(100, 100)); |
| 3306 testLayer->setContentsScale(2, 2); | 3306 testLayer->SetContentsScale(2, 2); |
| 3307 | 3307 |
| 3308 testLayer->setDrawsContent(true); | 3308 testLayer->SetDrawsContent(true); |
| 3309 root->addChild(testLayer.Pass()); | 3309 root->AddChild(testLayer.Pass()); |
| 3310 } | 3310 } |
| 3311 | 3311 |
| 3312 std::vector<LayerImpl*> renderSurfaceLayerList; | 3312 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3313 int dummyMaxTextureSize = 512; | 3313 int dummyMaxTextureSize = 512; |
| 3314 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3314 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3315 | 3315 |
| 3316 // Sanity check the scenario we just created. | 3316 // Sanity check the scenario we just created. |
| 3317 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 3317 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
| 3318 LayerImpl* testLayer = root->children()[0]; | 3318 LayerImpl* testLayer = root->children()[0]; |
| 3319 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi
bleContentRect()); | 3319 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi
ble_content_rect()); |
| 3320 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3320 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3321 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 3321 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 3322 | 3322 |
| 3323 // Hit testing for a point outside the layer should return a null pointer (t
he root layer does not draw content, so it will not be hit tested either). | 3323 // Hit testing for a point outside the layer should return a null pointer (t
he root layer does not draw content, so it will not be hit tested either). |
| 3324 gfx::Point testPoint(101, 101); | 3324 gfx::Point testPoint(101, 101); |
| 3325 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3325 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3326 EXPECT_FALSE(resultLayer); | 3326 EXPECT_FALSE(resultLayer); |
| 3327 | 3327 |
| 3328 testPoint = gfx::Point(24, 24); | 3328 testPoint = gfx::Point(24, 24); |
| 3329 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3329 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3330 EXPECT_FALSE(resultLayer); | 3330 EXPECT_FALSE(resultLayer); |
| 3331 | 3331 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3347 | 3347 |
| 3348 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) | 3348 TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer) |
| 3349 { | 3349 { |
| 3350 // Test that hit-testing will only work for the visible portion of a layer,
and not | 3350 // Test that hit-testing will only work for the visible portion of a layer,
and not |
| 3351 // the entire layer bounds. Here we just test the simple axis-aligned case. | 3351 // the entire layer bounds. Here we just test the simple axis-aligned case. |
| 3352 gfx::Transform identityMatrix; | 3352 gfx::Transform identityMatrix; |
| 3353 gfx::PointF anchor(0, 0); | 3353 gfx::PointF anchor(0, 0); |
| 3354 | 3354 |
| 3355 FakeImplProxy proxy; | 3355 FakeImplProxy proxy; |
| 3356 FakeLayerTreeHostImpl hostImpl(&proxy); | 3356 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3357 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1); | 3357 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); |
| 3358 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3358 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3359 | 3359 |
| 3360 { | 3360 { |
| 3361 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(hostImpl.activeT
ree(), 123); | 3361 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::Create(hostImpl.activeT
ree(), 123); |
| 3362 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. | 3362 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. |
| 3363 gfx::Size bounds(50, 50); | 3363 gfx::Size bounds(50, 50); |
| 3364 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); | 3364 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); |
| 3365 clippingLayer->setMasksToBounds(true); | 3365 clippingLayer->SetMasksToBounds(true); |
| 3366 | 3366 |
| 3367 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl.activeTree(), 4
56); | 3367 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.activeTree(), 4
56); |
| 3368 position = gfx::PointF(-50, -50); | 3368 position = gfx::PointF(-50, -50); |
| 3369 bounds = gfx::Size(300, 300); | 3369 bounds = gfx::Size(300, 300); |
| 3370 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3370 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 3371 child->setDrawsContent(true); | 3371 child->SetDrawsContent(true); |
| 3372 clippingLayer->addChild(child.Pass()); | 3372 clippingLayer->AddChild(child.Pass()); |
| 3373 root->addChild(clippingLayer.Pass()); | 3373 root->AddChild(clippingLayer.Pass()); |
| 3374 } | 3374 } |
| 3375 | 3375 |
| 3376 std::vector<LayerImpl*> renderSurfaceLayerList; | 3376 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3377 int dummyMaxTextureSize = 512; | 3377 int dummyMaxTextureSize = 512; |
| 3378 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3378 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3379 | 3379 |
| 3380 // Sanity check the scenario we just created. | 3380 // Sanity check the scenario we just created. |
| 3381 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3381 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3382 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 3382 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 3383 ASSERT_EQ(456, root->renderSurface()->layer_list()[0]->id()); | 3383 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); |
| 3384 | 3384 |
| 3385 // Hit testing for a point outside the layer should return a null pointer. | 3385 // Hit testing for a point outside the layer should return a null pointer. |
| 3386 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. | 3386 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. |
| 3387 gfx::Point testPoint(24, 24); | 3387 gfx::Point testPoint(24, 24); |
| 3388 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3388 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3389 EXPECT_FALSE(resultLayer); | 3389 EXPECT_FALSE(resultLayer); |
| 3390 | 3390 |
| 3391 // Even though the layer exists at (101, 101), it should not be visible ther
e since the clippingLayer would clamp it. | 3391 // Even though the layer exists at (101, 101), it should not be visible ther
e since the clippingLayer would clamp it. |
| 3392 testPoint = gfx::Point(76, 76); | 3392 testPoint = gfx::Point(76, 76); |
| 3393 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3393 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3412 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and | 3412 // algorithm needs to recognize that multiple parent layers may clip the lay
er, and |
| 3413 // should not actually hit those clipped areas. | 3413 // should not actually hit those clipped areas. |
| 3414 // | 3414 // |
| 3415 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The | 3415 // The child and grandChild layers are both initialized to clip the rotatedL
eaf. The |
| 3416 // child layer is rotated about the top-left corner, so that the root + chil
d clips | 3416 // child layer is rotated about the top-left corner, so that the root + chil
d clips |
| 3417 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps | 3417 // combined create a triangle. The rotatedLeaf will only be visible where it
overlaps |
| 3418 // this triangle. | 3418 // this triangle. |
| 3419 // | 3419 // |
| 3420 FakeImplProxy proxy; | 3420 FakeImplProxy proxy; |
| 3421 FakeLayerTreeHostImpl hostImpl(&proxy); | 3421 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3422 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 123); | 3422 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 123); |
| 3423 | 3423 |
| 3424 gfx::Transform identityMatrix; | 3424 gfx::Transform identityMatrix; |
| 3425 gfx::PointF anchor(0, 0); | 3425 gfx::PointF anchor(0, 0); |
| 3426 gfx::PointF position(0, 0); | 3426 gfx::PointF position(0, 0); |
| 3427 gfx::Size bounds(100, 100); | 3427 gfx::Size bounds(100, 100); |
| 3428 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3428 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3429 root->setMasksToBounds(true); | 3429 root->SetMasksToBounds(true); |
| 3430 | 3430 |
| 3431 { | 3431 { |
| 3432 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl.activeTree(), 4
56); | 3432 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.activeTree(), 4
56); |
| 3433 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(hostImpl.activeTree
(), 789); | 3433 scoped_ptr<LayerImpl> grandChild = LayerImpl::Create(hostImpl.activeTree
(), 789); |
| 3434 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::create(hostImpl.activeTre
e(), 2468); | 3434 scoped_ptr<LayerImpl> rotatedLeaf = LayerImpl::Create(hostImpl.activeTre
e(), 2468); |
| 3435 | 3435 |
| 3436 position = gfx::PointF(10, 10); | 3436 position = gfx::PointF(10, 10); |
| 3437 bounds = gfx::Size(80, 80); | 3437 bounds = gfx::Size(80, 80); |
| 3438 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3438 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 3439 child->setMasksToBounds(true); | 3439 child->SetMasksToBounds(true); |
| 3440 | 3440 |
| 3441 gfx::Transform rotation45DegreesAboutCorner; | 3441 gfx::Transform rotation45DegreesAboutCorner; |
| 3442 rotation45DegreesAboutCorner.RotateAboutZAxis(45); | 3442 rotation45DegreesAboutCorner.RotateAboutZAxis(45); |
| 3443 | 3443 |
| 3444 position = gfx::PointF(0, 0); // remember, positioned with respect to it
s parent which is already at 10, 10 | 3444 position = gfx::PointF(0, 0); // remember, positioned with respect to it
s parent which is already at 10, 10 |
| 3445 bounds = gfx::Size(200, 200); // to ensure it covers at least sqrt(2) *
100. | 3445 bounds = gfx::Size(200, 200); // to ensure it covers at least sqrt(2) *
100. |
| 3446 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor
ner, identityMatrix, anchor, position, bounds, false); | 3446 setLayerPropertiesForTesting(grandChild.get(), rotation45DegreesAboutCor
ner, identityMatrix, anchor, position, bounds, false); |
| 3447 grandChild->setMasksToBounds(true); | 3447 grandChild->SetMasksToBounds(true); |
| 3448 | 3448 |
| 3449 // Rotates about the center of the layer | 3449 // Rotates about the center of the layer |
| 3450 gfx::Transform rotatedLeafTransform; | 3450 gfx::Transform rotatedLeafTransform; |
| 3451 rotatedLeafTransform.Translate(-10, -10); // cancel out the grandParent'
s position | 3451 rotatedLeafTransform.Translate(-10, -10); // cancel out the grandParent'
s position |
| 3452 rotatedLeafTransform.RotateAboutZAxis(-45); // cancel out the corner 45-
degree rotation of the parent. | 3452 rotatedLeafTransform.RotateAboutZAxis(-45); // cancel out the corner 45-
degree rotation of the parent. |
| 3453 rotatedLeafTransform.Translate(50, 50); | 3453 rotatedLeafTransform.Translate(50, 50); |
| 3454 rotatedLeafTransform.RotateAboutZAxis(45); | 3454 rotatedLeafTransform.RotateAboutZAxis(45); |
| 3455 rotatedLeafTransform.Translate(-50, -50); | 3455 rotatedLeafTransform.Translate(-50, -50); |
| 3456 position = gfx::PointF(0, 0); | 3456 position = gfx::PointF(0, 0); |
| 3457 bounds = gfx::Size(100, 100); | 3457 bounds = gfx::Size(100, 100); |
| 3458 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); | 3458 setLayerPropertiesForTesting(rotatedLeaf.get(), rotatedLeafTransform, id
entityMatrix, anchor, position, bounds, false); |
| 3459 rotatedLeaf->setDrawsContent(true); | 3459 rotatedLeaf->SetDrawsContent(true); |
| 3460 | 3460 |
| 3461 grandChild->addChild(rotatedLeaf.Pass()); | 3461 grandChild->AddChild(rotatedLeaf.Pass()); |
| 3462 child->addChild(grandChild.Pass()); | 3462 child->AddChild(grandChild.Pass()); |
| 3463 root->addChild(child.Pass()); | 3463 root->AddChild(child.Pass()); |
| 3464 } | 3464 } |
| 3465 | 3465 |
| 3466 std::vector<LayerImpl*> renderSurfaceLayerList; | 3466 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3467 int dummyMaxTextureSize = 512; | 3467 int dummyMaxTextureSize = 512; |
| 3468 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3468 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3469 | 3469 |
| 3470 // Sanity check the scenario we just created. | 3470 // Sanity check the scenario we just created. |
| 3471 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. | 3471 // The grandChild is expected to create a renderSurface because it masksToBo
unds and is not axis aligned. |
| 3472 ASSERT_EQ(2u, renderSurfaceLayerList.size()); | 3472 ASSERT_EQ(2u, renderSurfaceLayerList.size()); |
| 3473 ASSERT_EQ(1u, renderSurfaceLayerList[0]->renderSurface()->layer_list().size(
)); | 3473 ASSERT_EQ(1u, renderSurfaceLayerList[0]->render_surface()->layer_list().size
()); |
| 3474 ASSERT_EQ(789, renderSurfaceLayerList[0]->renderSurface()->layer_list()[0]->
id()); // grandChild's surface. | 3474 ASSERT_EQ(789, renderSurfaceLayerList[0]->render_surface()->layer_list()[0]-
>id()); // grandChild's surface. |
| 3475 ASSERT_EQ(1u, renderSurfaceLayerList[1]->renderSurface()->layer_list().size(
)); | 3475 ASSERT_EQ(1u, renderSurfaceLayerList[1]->render_surface()->layer_list().size
()); |
| 3476 ASSERT_EQ(2468, renderSurfaceLayerList[1]->renderSurface()->layer_list()[0]-
>id()); | 3476 ASSERT_EQ(2468, renderSurfaceLayerList[1]->render_surface()->layer_list()[0]
->id()); |
| 3477 | 3477 |
| 3478 // (11, 89) is close to the the bottom left corner within the clip, but it i
s not inside the layer. | 3478 // (11, 89) is close to the the bottom left corner within the clip, but it i
s not inside the layer. |
| 3479 gfx::Point testPoint(11, 89); | 3479 gfx::Point testPoint(11, 89); |
| 3480 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3480 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3481 EXPECT_FALSE(resultLayer); | 3481 EXPECT_FALSE(resultLayer); |
| 3482 | 3482 |
| 3483 // Closer inwards from the bottom left will overlap the layer. | 3483 // Closer inwards from the bottom left will overlap the layer. |
| 3484 testPoint = gfx::Point(25, 75); | 3484 testPoint = gfx::Point(25, 75); |
| 3485 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3485 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3486 ASSERT_TRUE(resultLayer); | 3486 ASSERT_TRUE(resultLayer); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3515 | 3515 |
| 3516 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) | 3516 TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer) |
| 3517 { | 3517 { |
| 3518 // This test checks that hit testing code does not accidentally clip to laye
r | 3518 // This test checks that hit testing code does not accidentally clip to laye
r |
| 3519 // bounds for a layer that actually does not clip. | 3519 // bounds for a layer that actually does not clip. |
| 3520 gfx::Transform identityMatrix; | 3520 gfx::Transform identityMatrix; |
| 3521 gfx::PointF anchor(0, 0); | 3521 gfx::PointF anchor(0, 0); |
| 3522 | 3522 |
| 3523 FakeImplProxy proxy; | 3523 FakeImplProxy proxy; |
| 3524 FakeLayerTreeHostImpl hostImpl(&proxy); | 3524 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3525 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1); | 3525 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); |
| 3526 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3526 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3527 | 3527 |
| 3528 { | 3528 { |
| 3529 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::create(hostImpl.act
iveTree(), 123); | 3529 scoped_ptr<LayerImpl> intermediateLayer = LayerImpl::Create(hostImpl.act
iveTree(), 123); |
| 3530 gfx::PointF position(10, 10); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. | 3530 gfx::PointF position(10, 10); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. |
| 3531 gfx::Size bounds(50, 50); | 3531 gfx::Size bounds(50, 50); |
| 3532 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); | 3532 setLayerPropertiesForTesting(intermediateLayer.get(), identityMatrix, id
entityMatrix, anchor, position, bounds, false); |
| 3533 // Sanity check the intermediate layer should not clip. | 3533 // Sanity check the intermediate layer should not clip. |
| 3534 ASSERT_FALSE(intermediateLayer->masksToBounds()); | 3534 ASSERT_FALSE(intermediateLayer->masks_to_bounds()); |
| 3535 ASSERT_FALSE(intermediateLayer->maskLayer()); | 3535 ASSERT_FALSE(intermediateLayer->mask_layer()); |
| 3536 | 3536 |
| 3537 // The child of the intermediateLayer is translated so that it does not
overlap intermediateLayer at all. | 3537 // The child of the intermediateLayer is translated so that it does not
overlap intermediateLayer at all. |
| 3538 // If child is incorrectly clipped, we would not be able to hit it succe
ssfully. | 3538 // If child is incorrectly clipped, we would not be able to hit it succe
ssfully. |
| 3539 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl.activeTree(), 4
56); | 3539 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.activeTree(), 4
56); |
| 3540 position = gfx::PointF(60, 60); // 70, 70 in screen space | 3540 position = gfx::PointF(60, 60); // 70, 70 in screen space |
| 3541 bounds = gfx::Size(20, 20); | 3541 bounds = gfx::Size(20, 20); |
| 3542 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 3542 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 3543 child->setDrawsContent(true); | 3543 child->SetDrawsContent(true); |
| 3544 intermediateLayer->addChild(child.Pass()); | 3544 intermediateLayer->AddChild(child.Pass()); |
| 3545 root->addChild(intermediateLayer.Pass()); | 3545 root->AddChild(intermediateLayer.Pass()); |
| 3546 } | 3546 } |
| 3547 | 3547 |
| 3548 std::vector<LayerImpl*> renderSurfaceLayerList; | 3548 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3549 int dummyMaxTextureSize = 512; | 3549 int dummyMaxTextureSize = 512; |
| 3550 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3550 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3551 | 3551 |
| 3552 // Sanity check the scenario we just created. | 3552 // Sanity check the scenario we just created. |
| 3553 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3553 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3554 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 3554 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 3555 ASSERT_EQ(456, root->renderSurface()->layer_list()[0]->id()); | 3555 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); |
| 3556 | 3556 |
| 3557 // Hit testing for a point outside the layer should return a null pointer. | 3557 // Hit testing for a point outside the layer should return a null pointer. |
| 3558 gfx::Point testPoint(69, 69); | 3558 gfx::Point testPoint(69, 69); |
| 3559 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3559 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3560 EXPECT_FALSE(resultLayer); | 3560 EXPECT_FALSE(resultLayer); |
| 3561 | 3561 |
| 3562 testPoint = gfx::Point(91, 91); | 3562 testPoint = gfx::Point(91, 91); |
| 3563 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3563 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3564 EXPECT_FALSE(resultLayer); | 3564 EXPECT_FALSE(resultLayer); |
| 3565 | 3565 |
| 3566 // Hit testing for a point inside should return the child layer. | 3566 // Hit testing for a point inside should return the child layer. |
| 3567 testPoint = gfx::Point(71, 71); | 3567 testPoint = gfx::Point(71, 71); |
| 3568 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3568 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3569 ASSERT_TRUE(resultLayer); | 3569 ASSERT_TRUE(resultLayer); |
| 3570 EXPECT_EQ(456, resultLayer->id()); | 3570 EXPECT_EQ(456, resultLayer->id()); |
| 3571 | 3571 |
| 3572 testPoint = gfx::Point(89, 89); | 3572 testPoint = gfx::Point(89, 89); |
| 3573 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3573 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| 3574 ASSERT_TRUE(resultLayer); | 3574 ASSERT_TRUE(resultLayer); |
| 3575 EXPECT_EQ(456, resultLayer->id()); | 3575 EXPECT_EQ(456, resultLayer->id()); |
| 3576 } | 3576 } |
| 3577 | 3577 |
| 3578 | 3578 |
| 3579 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) | 3579 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers) |
| 3580 { | 3580 { |
| 3581 FakeImplProxy proxy; | 3581 FakeImplProxy proxy; |
| 3582 FakeLayerTreeHostImpl hostImpl(&proxy); | 3582 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3583 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1); | 3583 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); |
| 3584 | 3584 |
| 3585 gfx::Transform identityMatrix; | 3585 gfx::Transform identityMatrix; |
| 3586 gfx::PointF anchor(0, 0); | 3586 gfx::PointF anchor(0, 0); |
| 3587 gfx::PointF position(0, 0); | 3587 gfx::PointF position(0, 0); |
| 3588 gfx::Size bounds(100, 100); | 3588 gfx::Size bounds(100, 100); |
| 3589 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3589 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3590 root->setDrawsContent(true); | 3590 root->SetDrawsContent(true); |
| 3591 | 3591 |
| 3592 { | 3592 { |
| 3593 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3593 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 3594 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3594 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
| 3595 // The expected stacking order is: | 3595 // The expected stacking order is: |
| 3596 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. | 3596 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. |
| 3597 | 3597 |
| 3598 scoped_ptr<LayerImpl> child1 = LayerImpl::create(hostImpl.activeTree(),
2); | 3598 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(hostImpl.activeTree(),
2); |
| 3599 scoped_ptr<LayerImpl> child2 = LayerImpl::create(hostImpl.activeTree(),
3); | 3599 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(hostImpl.activeTree(),
3); |
| 3600 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(hostImpl.activeTre
e(), 4); | 3600 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::Create(hostImpl.activeTre
e(), 4); |
| 3601 | 3601 |
| 3602 position = gfx::PointF(10, 10); | 3602 position = gfx::PointF(10, 10); |
| 3603 bounds = gfx::Size(50, 50); | 3603 bounds = gfx::Size(50, 50); |
| 3604 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3604 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| 3605 child1->setDrawsContent(true); | 3605 child1->SetDrawsContent(true); |
| 3606 | 3606 |
| 3607 position = gfx::PointF(50, 10); | 3607 position = gfx::PointF(50, 10); |
| 3608 bounds = gfx::Size(50, 50); | 3608 bounds = gfx::Size(50, 50); |
| 3609 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3609 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| 3610 child2->setDrawsContent(true); | 3610 child2->SetDrawsContent(true); |
| 3611 | 3611 |
| 3612 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). | 3612 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). |
| 3613 // In screen space, the intended position is (10, 50), with size 100 x 5
0. | 3613 // In screen space, the intended position is (10, 50), with size 100 x 5
0. |
| 3614 position = gfx::PointF(0, 40); | 3614 position = gfx::PointF(0, 40); |
| 3615 bounds = gfx::Size(100, 50); | 3615 bounds = gfx::Size(100, 50); |
| 3616 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); | 3616 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); |
| 3617 grandChild1->setDrawsContent(true); | 3617 grandChild1->SetDrawsContent(true); |
| 3618 | 3618 |
| 3619 child1->addChild(grandChild1.Pass()); | 3619 child1->AddChild(grandChild1.Pass()); |
| 3620 root->addChild(child1.Pass()); | 3620 root->AddChild(child1.Pass()); |
| 3621 root->addChild(child2.Pass()); | 3621 root->AddChild(child2.Pass()); |
| 3622 } | 3622 } |
| 3623 | 3623 |
| 3624 LayerImpl* child1 = root->children()[0]; | 3624 LayerImpl* child1 = root->children()[0]; |
| 3625 LayerImpl* child2 = root->children()[1]; | 3625 LayerImpl* child2 = root->children()[1]; |
| 3626 LayerImpl* grandChild1 = child1->children()[0]; | 3626 LayerImpl* grandChild1 = child1->children()[0]; |
| 3627 | 3627 |
| 3628 std::vector<LayerImpl*> renderSurfaceLayerList; | 3628 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3629 int dummyMaxTextureSize = 512; | 3629 int dummyMaxTextureSize = 512; |
| 3630 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3630 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3631 | 3631 |
| 3632 // Sanity check the scenario we just created. | 3632 // Sanity check the scenario we just created. |
| 3633 ASSERT_TRUE(child1); | 3633 ASSERT_TRUE(child1); |
| 3634 ASSERT_TRUE(child2); | 3634 ASSERT_TRUE(child2); |
| 3635 ASSERT_TRUE(grandChild1); | 3635 ASSERT_TRUE(grandChild1); |
| 3636 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3636 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3637 ASSERT_EQ(4u, root->renderSurface()->layer_list().size()); | 3637 ASSERT_EQ(4u, root->render_surface()->layer_list().size()); |
| 3638 ASSERT_EQ(1, root->renderSurface()->layer_list()[0]->id()); // root layer | 3638 ASSERT_EQ(1, root->render_surface()->layer_list()[0]->id()); // root layer |
| 3639 ASSERT_EQ(2, root->renderSurface()->layer_list()[1]->id()); // child1 | 3639 ASSERT_EQ(2, root->render_surface()->layer_list()[1]->id()); // child1 |
| 3640 ASSERT_EQ(4, root->renderSurface()->layer_list()[2]->id()); // grandChild1 | 3640 ASSERT_EQ(4, root->render_surface()->layer_list()[2]->id()); // grandChild1 |
| 3641 ASSERT_EQ(3, root->renderSurface()->layer_list()[3]->id()); // child2 | 3641 ASSERT_EQ(3, root->render_surface()->layer_list()[3]->id()); // child2 |
| 3642 | 3642 |
| 3643 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. | 3643 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. |
| 3644 gfx::Point testPoint = gfx::Point(1, 1); | 3644 gfx::Point testPoint = gfx::Point(1, 1); |
| 3645 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3645 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3646 ASSERT_TRUE(resultLayer); | 3646 ASSERT_TRUE(resultLayer); |
| 3647 EXPECT_EQ(1, resultLayer->id()); | 3647 EXPECT_EQ(1, resultLayer->id()); |
| 3648 | 3648 |
| 3649 // At (15, 15), child1 and root are the only layers. child1 is expected to b
e on top. | 3649 // At (15, 15), child1 and root are the only layers. child1 is expected to b
e on top. |
| 3650 testPoint = gfx::Point(15, 15); | 3650 testPoint = gfx::Point(15, 15); |
| 3651 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); | 3651 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(testPoint, rend
erSurfaceLayerList); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3678 } | 3678 } |
| 3679 | 3679 |
| 3680 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) | 3680 TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists) |
| 3681 { | 3681 { |
| 3682 // | 3682 // |
| 3683 // The geometry is set up similarly to the previous case, but | 3683 // The geometry is set up similarly to the previous case, but |
| 3684 // all layers are forced to be renderSurfaces now. | 3684 // all layers are forced to be renderSurfaces now. |
| 3685 // | 3685 // |
| 3686 FakeImplProxy proxy; | 3686 FakeImplProxy proxy; |
| 3687 FakeLayerTreeHostImpl hostImpl(&proxy); | 3687 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3688 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1); | 3688 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); |
| 3689 | 3689 |
| 3690 gfx::Transform identityMatrix; | 3690 gfx::Transform identityMatrix; |
| 3691 gfx::PointF anchor(0, 0); | 3691 gfx::PointF anchor(0, 0); |
| 3692 gfx::PointF position(0, 0); | 3692 gfx::PointF position(0, 0); |
| 3693 gfx::Size bounds(100, 100); | 3693 gfx::Size bounds(100, 100); |
| 3694 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3694 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3695 root->setDrawsContent(true); | 3695 root->SetDrawsContent(true); |
| 3696 | 3696 |
| 3697 { | 3697 { |
| 3698 // child 1 and child2 are initialized to overlap between x=50 and x=60. | 3698 // child 1 and child2 are initialized to overlap between x=50 and x=60. |
| 3699 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. | 3699 // grandChild is set to overlap both child1 and child2 between y=50 and
y=60. |
| 3700 // The expected stacking order is: | 3700 // The expected stacking order is: |
| 3701 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. | 3701 // (front) child2, (second) grandChild, (third) child1, and (back) the
root layer behind all other layers. |
| 3702 | 3702 |
| 3703 scoped_ptr<LayerImpl> child1 = LayerImpl::create(hostImpl.activeTree(),
2); | 3703 scoped_ptr<LayerImpl> child1 = LayerImpl::Create(hostImpl.activeTree(),
2); |
| 3704 scoped_ptr<LayerImpl> child2 = LayerImpl::create(hostImpl.activeTree(),
3); | 3704 scoped_ptr<LayerImpl> child2 = LayerImpl::Create(hostImpl.activeTree(),
3); |
| 3705 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::create(hostImpl.activeTre
e(), 4); | 3705 scoped_ptr<LayerImpl> grandChild1 = LayerImpl::Create(hostImpl.activeTre
e(), 4); |
| 3706 | 3706 |
| 3707 position = gfx::PointF(10, 10); | 3707 position = gfx::PointF(10, 10); |
| 3708 bounds = gfx::Size(50, 50); | 3708 bounds = gfx::Size(50, 50); |
| 3709 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3709 setLayerPropertiesForTesting(child1.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| 3710 child1->setDrawsContent(true); | 3710 child1->SetDrawsContent(true); |
| 3711 child1->setForceRenderSurface(true); | 3711 child1->SetForceRenderSurface(true); |
| 3712 | 3712 |
| 3713 position = gfx::PointF(50, 10); | 3713 position = gfx::PointF(50, 10); |
| 3714 bounds = gfx::Size(50, 50); | 3714 bounds = gfx::Size(50, 50); |
| 3715 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); | 3715 setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatri
x, anchor, position, bounds, false); |
| 3716 child2->setDrawsContent(true); | 3716 child2->SetDrawsContent(true); |
| 3717 child2->setForceRenderSurface(true); | 3717 child2->SetForceRenderSurface(true); |
| 3718 | 3718 |
| 3719 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). | 3719 // Remember that grandChild is positioned with respect to its parent (i.
e. child1). |
| 3720 // In screen space, the intended position is (10, 50), with size 100 x 5
0. | 3720 // In screen space, the intended position is (10, 50), with size 100 x 5
0. |
| 3721 position = gfx::PointF(0, 40); | 3721 position = gfx::PointF(0, 40); |
| 3722 bounds = gfx::Size(100, 50); | 3722 bounds = gfx::Size(100, 50); |
| 3723 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); | 3723 setLayerPropertiesForTesting(grandChild1.get(), identityMatrix, identity
Matrix, anchor, position, bounds, false); |
| 3724 grandChild1->setDrawsContent(true); | 3724 grandChild1->SetDrawsContent(true); |
| 3725 grandChild1->setForceRenderSurface(true); | 3725 grandChild1->SetForceRenderSurface(true); |
| 3726 | 3726 |
| 3727 child1->addChild(grandChild1.Pass()); | 3727 child1->AddChild(grandChild1.Pass()); |
| 3728 root->addChild(child1.Pass()); | 3728 root->AddChild(child1.Pass()); |
| 3729 root->addChild(child2.Pass()); | 3729 root->AddChild(child2.Pass()); |
| 3730 } | 3730 } |
| 3731 | 3731 |
| 3732 LayerImpl* child1 = root->children()[0]; | 3732 LayerImpl* child1 = root->children()[0]; |
| 3733 LayerImpl* child2 = root->children()[1]; | 3733 LayerImpl* child2 = root->children()[1]; |
| 3734 LayerImpl* grandChild1 = child1->children()[0]; | 3734 LayerImpl* grandChild1 = child1->children()[0]; |
| 3735 | 3735 |
| 3736 std::vector<LayerImpl*> renderSurfaceLayerList; | 3736 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3737 int dummyMaxTextureSize = 512; | 3737 int dummyMaxTextureSize = 512; |
| 3738 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3738 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3739 | 3739 |
| 3740 // Sanity check the scenario we just created. | 3740 // Sanity check the scenario we just created. |
| 3741 ASSERT_TRUE(child1); | 3741 ASSERT_TRUE(child1); |
| 3742 ASSERT_TRUE(child2); | 3742 ASSERT_TRUE(child2); |
| 3743 ASSERT_TRUE(grandChild1); | 3743 ASSERT_TRUE(grandChild1); |
| 3744 ASSERT_TRUE(child1->renderSurface()); | 3744 ASSERT_TRUE(child1->render_surface()); |
| 3745 ASSERT_TRUE(child2->renderSurface()); | 3745 ASSERT_TRUE(child2->render_surface()); |
| 3746 ASSERT_TRUE(grandChild1->renderSurface()); | 3746 ASSERT_TRUE(grandChild1->render_surface()); |
| 3747 ASSERT_EQ(4u, renderSurfaceLayerList.size()); | 3747 ASSERT_EQ(4u, renderSurfaceLayerList.size()); |
| 3748 ASSERT_EQ(3u, root->renderSurface()->layer_list().size()); // The root surfa
ce has the root layer, and child1's and child2's renderSurfaces. | 3748 ASSERT_EQ(3u, root->render_surface()->layer_list().size()); // The root surf
ace has the root layer, and child1's and child2's renderSurfaces. |
| 3749 ASSERT_EQ(2u, child1->renderSurface()->layer_list().size()); // The child1 s
urface has the child1 layer and grandChild1's renderSurface. | 3749 ASSERT_EQ(2u, child1->render_surface()->layer_list().size()); // The child1
surface has the child1 layer and grandChild1's renderSurface. |
| 3750 ASSERT_EQ(1u, child2->renderSurface()->layer_list().size()); | 3750 ASSERT_EQ(1u, child2->render_surface()->layer_list().size()); |
| 3751 ASSERT_EQ(1u, grandChild1->renderSurface()->layer_list().size()); | 3751 ASSERT_EQ(1u, grandChild1->render_surface()->layer_list().size()); |
| 3752 ASSERT_EQ(1, renderSurfaceLayerList[0]->id()); // root layer | 3752 ASSERT_EQ(1, renderSurfaceLayerList[0]->id()); // root layer |
| 3753 ASSERT_EQ(2, renderSurfaceLayerList[1]->id()); // child1 | 3753 ASSERT_EQ(2, renderSurfaceLayerList[1]->id()); // child1 |
| 3754 ASSERT_EQ(4, renderSurfaceLayerList[2]->id()); // grandChild1 | 3754 ASSERT_EQ(4, renderSurfaceLayerList[2]->id()); // grandChild1 |
| 3755 ASSERT_EQ(3, renderSurfaceLayerList[3]->id()); // child2 | 3755 ASSERT_EQ(3, renderSurfaceLayerList[3]->id()); // child2 |
| 3756 | 3756 |
| 3757 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. | 3757 // Nothing overlaps the rootLayer at (1, 1), so hit testing there should fin
d the root layer. |
| 3758 gfx::Point testPoint = gfx::Point(1, 1); | 3758 gfx::Point testPoint = gfx::Point(1, 1); |
| 3759 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); | 3759 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPoint(test
Point, renderSurfaceLayerList); |
| 3760 ASSERT_TRUE(resultLayer); | 3760 ASSERT_TRUE(resultLayer); |
| 3761 EXPECT_EQ(1, resultLayer->id()); | 3761 EXPECT_EQ(1, resultLayer->id()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3802 | 3802 |
| 3803 testPoint = gfx::Point(10, 20); | 3803 testPoint = gfx::Point(10, 20); |
| 3804 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3804 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3805 EXPECT_FALSE(resultLayer); | 3805 EXPECT_FALSE(resultLayer); |
| 3806 } | 3806 } |
| 3807 | 3807 |
| 3808 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
) | 3808 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
) |
| 3809 { | 3809 { |
| 3810 FakeImplProxy proxy; | 3810 FakeImplProxy proxy; |
| 3811 FakeLayerTreeHostImpl hostImpl(&proxy); | 3811 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3812 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; | 3812 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; |
| 3813 | 3813 |
| 3814 gfx::Transform identityMatrix; | 3814 gfx::Transform identityMatrix; |
| 3815 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3815 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
| 3816 gfx::PointF anchor(0, 0); | 3816 gfx::PointF anchor(0, 0); |
| 3817 gfx::PointF position(0, 0); | 3817 gfx::PointF position(0, 0); |
| 3818 gfx::Size bounds(100, 100); | 3818 gfx::Size bounds(100, 100); |
| 3819 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3819 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3820 root->setDrawsContent(true); | 3820 root->SetDrawsContent(true); |
| 3821 | 3821 |
| 3822 std::vector<LayerImpl*> renderSurfaceLayerList; | 3822 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3823 int dummyMaxTextureSize = 512; | 3823 int dummyMaxTextureSize = 512; |
| 3824 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3824 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3825 | 3825 |
| 3826 // Sanity check the scenario we just created. | 3826 // Sanity check the scenario we just created. |
| 3827 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3827 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3828 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 3828 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 3829 | 3829 |
| 3830 // Hit checking for any point should return a null pointer for a layer witho
ut any touch event handler regions. | 3830 // Hit checking for any point should return a null pointer for a layer witho
ut any touch event handler regions. |
| 3831 gfx::Point testPoint(11, 11); | 3831 gfx::Point testPoint(11, 11); |
| 3832 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 3832 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
| 3833 EXPECT_FALSE(resultLayer); | 3833 EXPECT_FALSE(resultLayer); |
| 3834 | 3834 |
| 3835 root->setTouchEventHandlerRegion(touchHandlerRegion); | 3835 root->SetTouchEventHandlerRegion(touchHandlerRegion); |
| 3836 // Hit checking for a point outside the layer should return a null pointer. | 3836 // Hit checking for a point outside the layer should return a null pointer. |
| 3837 testPoint = gfx::Point(101, 101); | 3837 testPoint = gfx::Point(101, 101); |
| 3838 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3838 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3839 EXPECT_FALSE(resultLayer); | 3839 EXPECT_FALSE(resultLayer); |
| 3840 | 3840 |
| 3841 testPoint = gfx::Point(-1, -1); | 3841 testPoint = gfx::Point(-1, -1); |
| 3842 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3842 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3843 EXPECT_FALSE(resultLayer); | 3843 EXPECT_FALSE(resultLayer); |
| 3844 | 3844 |
| 3845 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. | 3845 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3860 testPoint = gfx::Point(59, 59); | 3860 testPoint = gfx::Point(59, 59); |
| 3861 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3861 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3862 ASSERT_TRUE(resultLayer); | 3862 ASSERT_TRUE(resultLayer); |
| 3863 EXPECT_EQ(12345, resultLayer->id()); | 3863 EXPECT_EQ(12345, resultLayer->id()); |
| 3864 } | 3864 } |
| 3865 | 3865 |
| 3866 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl
eTransform) | 3866 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForUninvertibl
eTransform) |
| 3867 { | 3867 { |
| 3868 FakeImplProxy proxy; | 3868 FakeImplProxy proxy; |
| 3869 FakeLayerTreeHostImpl hostImpl(&proxy); | 3869 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3870 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; | 3870 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; |
| 3871 | 3871 |
| 3872 gfx::Transform uninvertibleTransform; | 3872 gfx::Transform uninvertibleTransform; |
| 3873 uninvertibleTransform.matrix().setDouble(0, 0, 0); | 3873 uninvertibleTransform.matrix().setDouble(0, 0, 0); |
| 3874 uninvertibleTransform.matrix().setDouble(1, 1, 0); | 3874 uninvertibleTransform.matrix().setDouble(1, 1, 0); |
| 3875 uninvertibleTransform.matrix().setDouble(2, 2, 0); | 3875 uninvertibleTransform.matrix().setDouble(2, 2, 0); |
| 3876 uninvertibleTransform.matrix().setDouble(3, 3, 0); | 3876 uninvertibleTransform.matrix().setDouble(3, 3, 0); |
| 3877 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); | 3877 ASSERT_FALSE(uninvertibleTransform.IsInvertible()); |
| 3878 | 3878 |
| 3879 gfx::Transform identityMatrix; | 3879 gfx::Transform identityMatrix; |
| 3880 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3880 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
| 3881 gfx::PointF anchor(0, 0); | 3881 gfx::PointF anchor(0, 0); |
| 3882 gfx::PointF position(0, 0); | 3882 gfx::PointF position(0, 0); |
| 3883 gfx::Size bounds(100, 100); | 3883 gfx::Size bounds(100, 100); |
| 3884 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); | 3884 setLayerPropertiesForTesting(root.get(), uninvertibleTransform, identityMatr
ix, anchor, position, bounds, false); |
| 3885 root->setDrawsContent(true); | 3885 root->SetDrawsContent(true); |
| 3886 root->setTouchEventHandlerRegion(touchHandlerRegion); | 3886 root->SetTouchEventHandlerRegion(touchHandlerRegion); |
| 3887 | 3887 |
| 3888 std::vector<LayerImpl*> renderSurfaceLayerList; | 3888 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3889 int dummyMaxTextureSize = 512; | 3889 int dummyMaxTextureSize = 512; |
| 3890 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3890 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3891 | 3891 |
| 3892 // Sanity check the scenario we just created. | 3892 // Sanity check the scenario we just created. |
| 3893 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3893 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3894 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 3894 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 3895 ASSERT_FALSE(root->screenSpaceTransform().IsInvertible()); | 3895 ASSERT_FALSE(root->screen_space_transform().IsInvertible()); |
| 3896 | 3896 |
| 3897 // Hit checking any point should not hit the touch handler region on the lay
er. If the invertible matrix is | 3897 // Hit checking any point should not hit the touch handler region on the lay
er. If the invertible matrix is |
| 3898 // accidentally ignored and treated like an identity, then the hit testing w
ill | 3898 // accidentally ignored and treated like an identity, then the hit testing w
ill |
| 3899 // incorrectly hit the layer when it shouldn't. | 3899 // incorrectly hit the layer when it shouldn't. |
| 3900 gfx::Point testPoint(1, 1); | 3900 gfx::Point testPoint(1, 1); |
| 3901 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 3901 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
| 3902 EXPECT_FALSE(resultLayer); | 3902 EXPECT_FALSE(resultLayer); |
| 3903 | 3903 |
| 3904 testPoint = gfx::Point(10, 10); | 3904 testPoint = gfx::Point(10, 10); |
| 3905 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3905 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3923 | 3923 |
| 3924 testPoint = gfx::Point(-1, -1); | 3924 testPoint = gfx::Point(-1, -1); |
| 3925 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3925 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3926 EXPECT_FALSE(resultLayer); | 3926 EXPECT_FALSE(resultLayer); |
| 3927 } | 3927 } |
| 3928 | 3928 |
| 3929 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit
ionedLayer) | 3929 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSinglePosit
ionedLayer) |
| 3930 { | 3930 { |
| 3931 FakeImplProxy proxy; | 3931 FakeImplProxy proxy; |
| 3932 FakeLayerTreeHostImpl hostImpl(&proxy); | 3932 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3933 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 12345)
; | 3933 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 12345)
; |
| 3934 | 3934 |
| 3935 gfx::Transform identityMatrix; | 3935 gfx::Transform identityMatrix; |
| 3936 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 3936 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
| 3937 gfx::PointF anchor(0, 0); | 3937 gfx::PointF anchor(0, 0); |
| 3938 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. | 3938 gfx::PointF position(50, 50); // this layer is positioned, and hit testing s
hould correctly know where the layer is located. |
| 3939 gfx::Size bounds(100, 100); | 3939 gfx::Size bounds(100, 100); |
| 3940 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); | 3940 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, position, bounds, false); |
| 3941 root->setDrawsContent(true); | 3941 root->SetDrawsContent(true); |
| 3942 root->setTouchEventHandlerRegion(touchHandlerRegion); | 3942 root->SetTouchEventHandlerRegion(touchHandlerRegion); |
| 3943 | 3943 |
| 3944 std::vector<LayerImpl*> renderSurfaceLayerList; | 3944 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 3945 int dummyMaxTextureSize = 512; | 3945 int dummyMaxTextureSize = 512; |
| 3946 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 3946 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 3947 | 3947 |
| 3948 // Sanity check the scenario we just created. | 3948 // Sanity check the scenario we just created. |
| 3949 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 3949 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 3950 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 3950 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 3951 | 3951 |
| 3952 // Hit checking for a point outside the layer should return a null pointer. | 3952 // Hit checking for a point outside the layer should return a null pointer. |
| 3953 gfx::Point testPoint(49, 49); | 3953 gfx::Point testPoint(49, 49); |
| 3954 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 3954 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
| 3955 EXPECT_FALSE(resultLayer); | 3955 EXPECT_FALSE(resultLayer); |
| 3956 | 3956 |
| 3957 // Even though the layer has a touch handler region containing (101, 101), i
t should not be visible there since the root renderSurface would clamp it. | 3957 // Even though the layer has a touch handler region containing (101, 101), i
t should not be visible there since the root renderSurface would clamp it. |
| 3958 testPoint = gfx::Point(101, 101); | 3958 testPoint = gfx::Point(101, 101); |
| 3959 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 3959 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 3960 EXPECT_FALSE(resultLayer); | 3960 EXPECT_FALSE(resultLayer); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3983 // test makes sure that hit testing works correctly accounts for the content
s scale. | 3983 // test makes sure that hit testing works correctly accounts for the content
s scale. |
| 3984 // A contentsScale that is not 1 effectively forces a non-identity transform
between | 3984 // A contentsScale that is not 1 effectively forces a non-identity transform
between |
| 3985 // layer's content space and layer's origin space. The hit testing code must
take this into account. | 3985 // layer's content space and layer's origin space. The hit testing code must
take this into account. |
| 3986 // | 3986 // |
| 3987 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If | 3987 // To test this, the layer is positioned at (25, 25), and is size (50, 50).
If |
| 3988 // contentsScale is ignored, then hit checking will mis-interpret the visibl
eContentRect | 3988 // contentsScale is ignored, then hit checking will mis-interpret the visibl
eContentRect |
| 3989 // as being larger than the actual bounds of the layer. | 3989 // as being larger than the actual bounds of the layer. |
| 3990 // | 3990 // |
| 3991 FakeImplProxy proxy; | 3991 FakeImplProxy proxy; |
| 3992 FakeLayerTreeHostImpl hostImpl(&proxy); | 3992 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 3993 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1); | 3993 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); |
| 3994 | 3994 |
| 3995 gfx::Transform identityMatrix; | 3995 gfx::Transform identityMatrix; |
| 3996 gfx::PointF anchor(0, 0); | 3996 gfx::PointF anchor(0, 0); |
| 3997 | 3997 |
| 3998 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 3998 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 3999 | 3999 |
| 4000 { | 4000 { |
| 4001 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); | 4001 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); |
| 4002 gfx::PointF position(25, 25); | 4002 gfx::PointF position(25, 25); |
| 4003 gfx::Size bounds(50, 50); | 4003 gfx::Size bounds(50, 50); |
| 4004 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(hostImpl.activeTree(
), 12345); | 4004 scoped_ptr<LayerImpl> testLayer = LayerImpl::Create(hostImpl.activeTree(
), 12345); |
| 4005 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 4005 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
| 4006 | 4006 |
| 4007 // override contentBounds and contentsScale | 4007 // override contentBounds and contentsScale |
| 4008 testLayer->setContentBounds(gfx::Size(100, 100)); | 4008 testLayer->SetContentBounds(gfx::Size(100, 100)); |
| 4009 testLayer->setContentsScale(2, 2); | 4009 testLayer->SetContentsScale(2, 2); |
| 4010 | 4010 |
| 4011 testLayer->setDrawsContent(true); | 4011 testLayer->SetDrawsContent(true); |
| 4012 testLayer->setTouchEventHandlerRegion(touchHandlerRegion); | 4012 testLayer->SetTouchEventHandlerRegion(touchHandlerRegion); |
| 4013 root->addChild(testLayer.Pass()); | 4013 root->AddChild(testLayer.Pass()); |
| 4014 } | 4014 } |
| 4015 | 4015 |
| 4016 std::vector<LayerImpl*> renderSurfaceLayerList; | 4016 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 4017 int dummyMaxTextureSize = 512; | 4017 int dummyMaxTextureSize = 512; |
| 4018 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 4018 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 4019 | 4019 |
| 4020 // Sanity check the scenario we just created. | 4020 // Sanity check the scenario we just created. |
| 4021 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 4021 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
| 4022 LayerImpl* testLayer = root->children()[0]; | 4022 LayerImpl* testLayer = root->children()[0]; |
| 4023 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi
bleContentRect()); | 4023 EXPECT_RECT_EQ(gfx::Rect(gfx::Point(), gfx::Size(100, 100)), testLayer->visi
ble_content_rect()); |
| 4024 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 4024 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 4025 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 4025 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4026 | 4026 |
| 4027 // Hit checking for a point outside the layer should return a null pointer (
the root layer does not draw content, so it will not be tested either). | 4027 // Hit checking for a point outside the layer should return a null pointer (
the root layer does not draw content, so it will not be tested either). |
| 4028 gfx::Point testPoint(76, 76); | 4028 gfx::Point testPoint(76, 76); |
| 4029 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 4029 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
| 4030 EXPECT_FALSE(resultLayer); | 4030 EXPECT_FALSE(resultLayer); |
| 4031 | 4031 |
| 4032 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. | 4032 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. |
| 4033 testPoint = gfx::Point(26, 26); | 4033 testPoint = gfx::Point(26, 26); |
| 4034 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4034 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 4035 EXPECT_FALSE(resultLayer); | 4035 EXPECT_FALSE(resultLayer); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4057 ASSERT_TRUE(resultLayer); | 4057 ASSERT_TRUE(resultLayer); |
| 4058 EXPECT_EQ(12345, resultLayer->id()); | 4058 EXPECT_EQ(12345, resultLayer->id()); |
| 4059 } | 4059 } |
| 4060 | 4060 |
| 4061 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
WithDeviceScale) | 4061 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSingleLayer
WithDeviceScale) |
| 4062 { | 4062 { |
| 4063 // The layer's deviceScalefactor and pageScaleFactor should scale the conten
tRect and we should | 4063 // The layer's deviceScalefactor and pageScaleFactor should scale the conten
tRect and we should |
| 4064 // be able to hit the touch handler region by scaling the points accordingly
. | 4064 // be able to hit the touch handler region by scaling the points accordingly
. |
| 4065 FakeImplProxy proxy; | 4065 FakeImplProxy proxy; |
| 4066 FakeLayerTreeHostImpl hostImpl(&proxy); | 4066 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 4067 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1); | 4067 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); |
| 4068 | 4068 |
| 4069 gfx::Transform identityMatrix; | 4069 gfx::Transform identityMatrix; |
| 4070 gfx::PointF anchor(0, 0); | 4070 gfx::PointF anchor(0, 0); |
| 4071 // Set the bounds of the root layer big enough to fit the child when scaled. | 4071 // Set the bounds of the root layer big enough to fit the child when scaled. |
| 4072 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 4072 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 4073 | 4073 |
| 4074 { | 4074 { |
| 4075 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); | 4075 Region touchHandlerRegion(gfx::Rect(10, 10, 30, 30)); |
| 4076 gfx::PointF position(25, 25); | 4076 gfx::PointF position(25, 25); |
| 4077 gfx::Size bounds(50, 50); | 4077 gfx::Size bounds(50, 50); |
| 4078 scoped_ptr<LayerImpl> testLayer = LayerImpl::create(hostImpl.activeTree(
), 12345); | 4078 scoped_ptr<LayerImpl> testLayer = LayerImpl::Create(hostImpl.activeTree(
), 12345); |
| 4079 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); | 4079 setLayerPropertiesForTesting(testLayer.get(), identityMatrix, identityMa
trix, anchor, position, bounds, false); |
| 4080 | 4080 |
| 4081 testLayer->setDrawsContent(true); | 4081 testLayer->SetDrawsContent(true); |
| 4082 testLayer->setTouchEventHandlerRegion(touchHandlerRegion); | 4082 testLayer->SetTouchEventHandlerRegion(touchHandlerRegion); |
| 4083 root->addChild(testLayer.Pass()); | 4083 root->AddChild(testLayer.Pass()); |
| 4084 } | 4084 } |
| 4085 | 4085 |
| 4086 std::vector<LayerImpl*> renderSurfaceLayerList; | 4086 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 4087 int dummyMaxTextureSize = 512; | 4087 int dummyMaxTextureSize = 512; |
| 4088 float deviceScaleFactor = 3.0f; | 4088 float deviceScaleFactor = 3.0f; |
| 4089 float pageScaleFactor = 5.0f; | 4089 float pageScaleFactor = 5.0f; |
| 4090 gfx::Transform pageScaleTransform; | 4090 gfx::Transform pageScaleTransform; |
| 4091 pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor); | 4091 pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor); |
| 4092 root->setImplTransform(pageScaleTransform); // Applying the pageScaleFactor
through implTransform. | 4092 root->SetImplTransform(pageScaleTransform); // Applying the pageScaleFactor
through implTransform. |
| 4093 gfx::Size scaledBoundsForRoot = gfx::ToCeiledSize(gfx::ScaleSize(root->bound
s(), deviceScaleFactor * pageScaleFactor)); | 4093 gfx::Size scaledBoundsForRoot = gfx::ToCeiledSize(gfx::ScaleSize(root->bound
s(), deviceScaleFactor * pageScaleFactor)); |
| 4094 LayerTreeHostCommon::calculateDrawProperties(root.get(), scaledBoundsForRoot
, deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, fals
e); | 4094 LayerTreeHostCommon::calculateDrawProperties(root.get(), scaledBoundsForRoot
, deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList, fals
e); |
| 4095 | 4095 |
| 4096 // Sanity check the scenario we just created. | 4096 // Sanity check the scenario we just created. |
| 4097 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. | 4097 // The visibleContentRect for testLayer is actually 100x100, even though its
layout size is 50x50, positioned at 25x25. |
| 4098 LayerImpl* testLayer = root->children()[0]; | 4098 LayerImpl* testLayer = root->children()[0]; |
| 4099 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 4099 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 4100 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 4100 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4101 | 4101 |
| 4102 // Check whether the child layer fits into the root after scaled. | 4102 // Check whether the child layer fits into the root after scaled. |
| 4103 EXPECT_RECT_EQ(gfx::Rect(testLayer->contentBounds()), testLayer->visibleCont
entRect());; | 4103 EXPECT_RECT_EQ(gfx::Rect(testLayer->content_bounds()), testLayer->visible_co
ntent_rect());; |
| 4104 | 4104 |
| 4105 // Hit checking for a point outside the layer should return a null pointer (
the root layer does not draw content, so it will not be tested either). | 4105 // Hit checking for a point outside the layer should return a null pointer (
the root layer does not draw content, so it will not be tested either). |
| 4106 gfx::PointF testPoint(76, 76); | 4106 gfx::PointF testPoint(76, 76); |
| 4107 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); | 4107 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); |
| 4108 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 4108 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
| 4109 EXPECT_FALSE(resultLayer); | 4109 EXPECT_FALSE(resultLayer); |
| 4110 | 4110 |
| 4111 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. | 4111 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. |
| 4112 testPoint = gfx::Point(26, 26); | 4112 testPoint = gfx::Point(26, 26); |
| 4113 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); | 4113 testPoint = gfx::ScalePoint(testPoint, deviceScaleFactor * pageScaleFactor); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4145 | 4145 |
| 4146 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp
edLayer) | 4146 TEST(LayerTreeHostCommonTest, verifyHitCheckingTouchHandlerRegionsForSimpleClipp
edLayer) |
| 4147 { | 4147 { |
| 4148 // Test that hit-checking will only work for the visible portion of a layer,
and not | 4148 // Test that hit-checking will only work for the visible portion of a layer,
and not |
| 4149 // the entire layer bounds. Here we just test the simple axis-aligned case. | 4149 // the entire layer bounds. Here we just test the simple axis-aligned case. |
| 4150 gfx::Transform identityMatrix; | 4150 gfx::Transform identityMatrix; |
| 4151 gfx::PointF anchor(0, 0); | 4151 gfx::PointF anchor(0, 0); |
| 4152 | 4152 |
| 4153 FakeImplProxy proxy; | 4153 FakeImplProxy proxy; |
| 4154 FakeLayerTreeHostImpl hostImpl(&proxy); | 4154 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 4155 scoped_ptr<LayerImpl> root = LayerImpl::create(hostImpl.activeTree(), 1); | 4155 scoped_ptr<LayerImpl> root = LayerImpl::Create(hostImpl.activeTree(), 1); |
| 4156 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); | 4156 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, anc
hor, gfx::PointF(0, 0), gfx::Size(100, 100), false); |
| 4157 | 4157 |
| 4158 { | 4158 { |
| 4159 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::create(hostImpl.activeT
ree(), 123); | 4159 scoped_ptr<LayerImpl> clippingLayer = LayerImpl::Create(hostImpl.activeT
ree(), 123); |
| 4160 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. | 4160 gfx::PointF position(25, 25); // this layer is positioned, and hit testi
ng should correctly know where the layer is located. |
| 4161 gfx::Size bounds(50, 50); | 4161 gfx::Size bounds(50, 50); |
| 4162 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); | 4162 setLayerPropertiesForTesting(clippingLayer.get(), identityMatrix, identi
tyMatrix, anchor, position, bounds, false); |
| 4163 clippingLayer->setMasksToBounds(true); | 4163 clippingLayer->SetMasksToBounds(true); |
| 4164 | 4164 |
| 4165 scoped_ptr<LayerImpl> child = LayerImpl::create(hostImpl.activeTree(), 4
56); | 4165 scoped_ptr<LayerImpl> child = LayerImpl::Create(hostImpl.activeTree(), 4
56); |
| 4166 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); | 4166 Region touchHandlerRegion(gfx::Rect(10, 10, 50, 50)); |
| 4167 position = gfx::PointF(-50, -50); | 4167 position = gfx::PointF(-50, -50); |
| 4168 bounds = gfx::Size(300, 300); | 4168 bounds = gfx::Size(300, 300); |
| 4169 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); | 4169 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix
, anchor, position, bounds, false); |
| 4170 child->setDrawsContent(true); | 4170 child->SetDrawsContent(true); |
| 4171 child->setTouchEventHandlerRegion(touchHandlerRegion); | 4171 child->SetTouchEventHandlerRegion(touchHandlerRegion); |
| 4172 clippingLayer->addChild(child.Pass()); | 4172 clippingLayer->AddChild(child.Pass()); |
| 4173 root->addChild(clippingLayer.Pass()); | 4173 root->AddChild(clippingLayer.Pass()); |
| 4174 } | 4174 } |
| 4175 | 4175 |
| 4176 std::vector<LayerImpl*> renderSurfaceLayerList; | 4176 std::vector<LayerImpl*> renderSurfaceLayerList; |
| 4177 int dummyMaxTextureSize = 512; | 4177 int dummyMaxTextureSize = 512; |
| 4178 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); | 4178 LayerTreeHostCommon::calculateDrawProperties(root.get(), root->bounds(), 1,
1, dummyMaxTextureSize, false, renderSurfaceLayerList, false); |
| 4179 | 4179 |
| 4180 // Sanity check the scenario we just created. | 4180 // Sanity check the scenario we just created. |
| 4181 ASSERT_EQ(1u, renderSurfaceLayerList.size()); | 4181 ASSERT_EQ(1u, renderSurfaceLayerList.size()); |
| 4182 ASSERT_EQ(1u, root->renderSurface()->layer_list().size()); | 4182 ASSERT_EQ(1u, root->render_surface()->layer_list().size()); |
| 4183 ASSERT_EQ(456, root->renderSurface()->layer_list()[0]->id()); | 4183 ASSERT_EQ(456, root->render_surface()->layer_list()[0]->id()); |
| 4184 | 4184 |
| 4185 // Hit checking for a point outside the layer should return a null pointer. | 4185 // Hit checking for a point outside the layer should return a null pointer. |
| 4186 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. | 4186 // Despite the child layer being very large, it should be clipped to the roo
t layer's bounds. |
| 4187 gfx::Point testPoint(24, 24); | 4187 gfx::Point testPoint(24, 24); |
| 4188 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); | 4188 LayerImpl* resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTou
chHandlerRegion(testPoint, renderSurfaceLayerList); |
| 4189 EXPECT_FALSE(resultLayer); | 4189 EXPECT_FALSE(resultLayer); |
| 4190 | 4190 |
| 4191 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. | 4191 // Hit checking for a point inside the layer, but outside the touch handler
region should return a null pointer. |
| 4192 testPoint = gfx::Point(35, 35); | 4192 testPoint = gfx::Point(35, 35); |
| 4193 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4193 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4205 | 4205 |
| 4206 testPoint = gfx::Point(34, 34); | 4206 testPoint = gfx::Point(34, 34); |
| 4207 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); | 4207 resultLayer = LayerTreeHostCommon::findLayerThatIsHitByPointInTouchHandlerRe
gion(testPoint, renderSurfaceLayerList); |
| 4208 ASSERT_TRUE(resultLayer); | 4208 ASSERT_TRUE(resultLayer); |
| 4209 EXPECT_EQ(456, resultLayer->id()); | 4209 EXPECT_EQ(456, resultLayer->id()); |
| 4210 } | 4210 } |
| 4211 | 4211 |
| 4212 class NoScaleContentLayer : public ContentLayer | 4212 class NoScaleContentLayer : public ContentLayer |
| 4213 { | 4213 { |
| 4214 public: | 4214 public: |
| 4215 static scoped_refptr<NoScaleContentLayer> create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } | 4215 static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client)
{ return make_scoped_refptr(new NoScaleContentLayer(client)); } |
| 4216 | 4216 |
| 4217 virtual void calculateContentsScale( | 4217 virtual void CalculateContentsScale( |
| 4218 float idealContentsScale, | 4218 float ideal_contents_scale, |
| 4219 bool animatingTransformToScreen, | 4219 bool animating_transform_to_screen, |
| 4220 float* contentsScaleX, | 4220 float* contents_scale_x, |
| 4221 float* contentsScaleY, | 4221 float* contents_scale_y, |
| 4222 gfx::Size* contentBounds) OVERRIDE | 4222 gfx::Size* contentBounds) OVERRIDE |
| 4223 { | 4223 { |
| 4224 // Skip over the ContentLayer to the base Layer class. | 4224 // Skip over the ContentLayer to the base Layer class. |
| 4225 Layer::calculateContentsScale( | 4225 Layer::CalculateContentsScale( |
| 4226 idealContentsScale, | 4226 ideal_contents_scale, |
| 4227 animatingTransformToScreen, | 4227 animating_transform_to_screen, |
| 4228 contentsScaleX, | 4228 contents_scale_x, |
| 4229 contentsScaleY, | 4229 contents_scale_y, |
| 4230 contentBounds); | 4230 contentBounds); |
| 4231 } | 4231 } |
| 4232 | 4232 |
| 4233 protected: | 4233 protected: |
| 4234 explicit NoScaleContentLayer(ContentLayerClient* client) : ContentLayer(clie
nt) { } | 4234 explicit NoScaleContentLayer(ContentLayerClient* client) : ContentLayer(clie
nt) { } |
| 4235 virtual ~NoScaleContentLayer() { } | 4235 virtual ~NoScaleContentLayer() { } |
| 4236 }; | 4236 }; |
| 4237 | 4237 |
| 4238 scoped_refptr<NoScaleContentLayer> createNoScaleDrawableContentLayer(ContentLaye
rClient* delegate) | 4238 scoped_refptr<NoScaleContentLayer> createNoScaleDrawableContentLayer(ContentLaye
rClient* delegate) |
| 4239 { | 4239 { |
| 4240 scoped_refptr<NoScaleContentLayer> toReturn = NoScaleContentLayer::create(de
legate); | 4240 scoped_refptr<NoScaleContentLayer> toReturn = NoScaleContentLayer::Create(de
legate); |
| 4241 toReturn->setIsDrawable(true); | 4241 toReturn->SetIsDrawable(true); |
| 4242 return toReturn; | 4242 return toReturn; |
| 4243 } | 4243 } |
| 4244 | 4244 |
| 4245 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) | 4245 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI) |
| 4246 { | 4246 { |
| 4247 // Verify draw and screen space transforms of layers not in a surface. | 4247 // Verify draw and screen space transforms of layers not in a surface. |
| 4248 MockContentLayerClient delegate; | 4248 MockContentLayerClient delegate; |
| 4249 gfx::Transform identityMatrix; | 4249 gfx::Transform identityMatrix; |
| 4250 | 4250 |
| 4251 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4251 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4252 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4252 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
| 4253 | 4253 |
| 4254 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); | 4254 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
| 4255 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4255 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4256 | 4256 |
| 4257 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat
e); | 4257 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat
e); |
| 4258 setLayerPropertiesForTesting(childEmpty.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(0, 0), true); | 4258 setLayerPropertiesForTesting(childEmpty.get(), identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(0, 0), true); |
| 4259 | 4259 |
| 4260 scoped_refptr<NoScaleContentLayer> childNoScale = createNoScaleDrawableConte
ntLayer(&delegate); | 4260 scoped_refptr<NoScaleContentLayer> childNoScale = createNoScaleDrawableConte
ntLayer(&delegate); |
| 4261 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4261 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4262 | 4262 |
| 4263 parent->addChild(child); | 4263 parent->AddChild(child); |
| 4264 parent->addChild(childEmpty); | 4264 parent->AddChild(childEmpty); |
| 4265 parent->addChild(childNoScale); | 4265 parent->AddChild(childNoScale); |
| 4266 | 4266 |
| 4267 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4267 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4268 int dummyMaxTextureSize = 512; | 4268 int dummyMaxTextureSize = 512; |
| 4269 | 4269 |
| 4270 const double deviceScaleFactor = 2.5; | 4270 const double deviceScaleFactor = 2.5; |
| 4271 const double pageScaleFactor = 1; | 4271 const double pageScaleFactor = 1; |
| 4272 | 4272 |
| 4273 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4273 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); |
| 4274 | 4274 |
| 4275 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 4275 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
| 4276 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); | 4276 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); |
| 4277 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); | 4277 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); |
| 4278 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4278 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
| 4279 | 4279 |
| 4280 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 4280 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
| 4281 | 4281 |
| 4282 // Verify parent transforms | 4282 // Verify parent transforms |
| 4283 gfx::Transform expectedParentTransform; | 4283 gfx::Transform expectedParentTransform; |
| 4284 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 4284 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screen_spac
e_transform()); |
| 4285 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 4285 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->draw_transf
orm()); |
| 4286 | 4286 |
| 4287 // Verify results of transformed parent rects | 4287 // Verify results of transformed parent rects |
| 4288 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->contentBoun
ds())); | 4288 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->content_bou
nds())); |
| 4289 | 4289 |
| 4290 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->drawTransform()
, parentContentBounds); | 4290 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->draw_transform(
), parentContentBounds); |
| 4291 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screenSp
aceTransform(), parentContentBounds); | 4291 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screen_s
pace_transform(), parentContentBounds); |
| 4292 | 4292 |
| 4293 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); | 4293 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); |
| 4294 expectedParentDrawRect.Scale(deviceScaleFactor); | 4294 expectedParentDrawRect.Scale(deviceScaleFactor); |
| 4295 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); | 4295 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); |
| 4296 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); | 4296 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); |
| 4297 | 4297 |
| 4298 // Verify child and childEmpty transforms. They should match. | 4298 // Verify child and childEmpty transforms. They should match. |
| 4299 gfx::Transform expectedChildTransform; | 4299 gfx::Transform expectedChildTransform; |
| 4300 expectedChildTransform.Translate(deviceScaleFactor * child->position().x(),
deviceScaleFactor * child->position().y()); | 4300 expectedChildTransform.Translate(deviceScaleFactor * child->position().x(),
deviceScaleFactor * child->position().y()); |
| 4301 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 4301 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 4302 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr
ansform()); | 4302 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screen_space_
transform()); |
| 4303 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->drawTran
sform()); | 4303 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->draw_tra
nsform()); |
| 4304 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->screenSp
aceTransform()); | 4304 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, childEmpty->screen_s
pace_transform()); |
| 4305 | 4305 |
| 4306 // Verify results of transformed child and childEmpty rects. They should mat
ch. | 4306 // Verify results of transformed child and childEmpty rects. They should mat
ch. |
| 4307 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->contentBounds
())); | 4307 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->content_bound
s())); |
| 4308 | 4308 |
| 4309 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->drawTransform(),
childContentBounds); | 4309 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->draw_transform(),
childContentBounds); |
| 4310 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screenSpac
eTransform(), childContentBounds); | 4310 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screen_spa
ce_transform(), childContentBounds); |
| 4311 | 4311 |
| 4312 gfx::RectF childEmptyDrawRect = MathUtil::mapClippedRect(childEmpty->drawTra
nsform(), childContentBounds); | 4312 gfx::RectF childEmptyDrawRect = MathUtil::mapClippedRect(childEmpty->draw_tr
ansform(), childContentBounds); |
| 4313 gfx::RectF childEmptyScreenSpaceRect = MathUtil::mapClippedRect(childEmpty->
screenSpaceTransform(), childContentBounds); | 4313 gfx::RectF childEmptyScreenSpaceRect = MathUtil::mapClippedRect(childEmpty->
screen_space_transform(), childContentBounds); |
| 4314 | 4314 |
| 4315 gfx::RectF expectedChildDrawRect(child->position(), child->bounds()); | 4315 gfx::RectF expectedChildDrawRect(child->position(), child->bounds()); |
| 4316 expectedChildDrawRect.Scale(deviceScaleFactor); | 4316 expectedChildDrawRect.Scale(deviceScaleFactor); |
| 4317 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); | 4317 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); |
| 4318 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); | 4318 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); |
| 4319 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyDrawRect); | 4319 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyDrawRect); |
| 4320 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyScreenSpaceRect); | 4320 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childEmptyScreenSpaceRect); |
| 4321 | 4321 |
| 4322 // Verify childNoScale transforms | 4322 // Verify childNoScale transforms |
| 4323 gfx::Transform expectedChildNoScaleTransform = child->drawTransform(); | 4323 gfx::Transform expectedChildNoScaleTransform = child->draw_transform(); |
| 4324 // All transforms operate on content rects. The child's content rect | 4324 // All transforms operate on content rects. The child's content rect |
| 4325 // incorporates device scale, but the childNoScale does not; add it here. | 4325 // incorporates device scale, but the childNoScale does not; add it here. |
| 4326 expectedChildNoScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); | 4326 expectedChildNoScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); |
| 4327 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); | 4327 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>draw_transform()); |
| 4328 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); | 4328 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screen_space_transform()); |
| 4329 } | 4329 } |
| 4330 | 4330 |
| 4331 TEST(LayerTreeHostCommonTest, verifySurfaceLayerTransformsInHighDPI) | 4331 TEST(LayerTreeHostCommonTest, verifySurfaceLayerTransformsInHighDPI) |
| 4332 { | 4332 { |
| 4333 // Verify draw and screen space transforms of layers in a surface. | 4333 // Verify draw and screen space transforms of layers in a surface. |
| 4334 MockContentLayerClient delegate; | 4334 MockContentLayerClient delegate; |
| 4335 gfx::Transform identityMatrix; | 4335 gfx::Transform identityMatrix; |
| 4336 | 4336 |
| 4337 gfx::Transform perspectiveMatrix; | 4337 gfx::Transform perspectiveMatrix; |
| 4338 perspectiveMatrix.ApplyPerspectiveDepth(2); | 4338 perspectiveMatrix.ApplyPerspectiveDepth(2); |
| 4339 | 4339 |
| 4340 gfx::Transform scaleSmallMatrix; | 4340 gfx::Transform scaleSmallMatrix; |
| 4341 scaleSmallMatrix.Scale(1.0 / 10.0, 1.0 / 12.0); | 4341 scaleSmallMatrix.Scale(1.0 / 10.0, 1.0 / 12.0); |
| 4342 | 4342 |
| 4343 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4343 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4344 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4344 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
| 4345 | 4345 |
| 4346 scoped_refptr<ContentLayer> perspectiveSurface = createDrawableContentLayer(
&delegate); | 4346 scoped_refptr<ContentLayer> perspectiveSurface = createDrawableContentLayer(
&delegate); |
| 4347 setLayerPropertiesForTesting(perspectiveSurface.get(), perspectiveMatrix * s
caleSmallMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size
(10, 10), true); | 4347 setLayerPropertiesForTesting(perspectiveSurface.get(), perspectiveMatrix * s
caleSmallMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size
(10, 10), true); |
| 4348 | 4348 |
| 4349 scoped_refptr<ContentLayer> scaleSurface = createDrawableContentLayer(&deleg
ate); | 4349 scoped_refptr<ContentLayer> scaleSurface = createDrawableContentLayer(&deleg
ate); |
| 4350 setLayerPropertiesForTesting(scaleSurface.get(), scaleSmallMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4350 setLayerPropertiesForTesting(scaleSurface.get(), scaleSmallMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4351 | 4351 |
| 4352 perspectiveSurface->setForceRenderSurface(true); | 4352 perspectiveSurface->SetForceRenderSurface(true); |
| 4353 scaleSurface->setForceRenderSurface(true); | 4353 scaleSurface->SetForceRenderSurface(true); |
| 4354 | 4354 |
| 4355 parent->addChild(perspectiveSurface); | 4355 parent->AddChild(perspectiveSurface); |
| 4356 parent->addChild(scaleSurface); | 4356 parent->AddChild(scaleSurface); |
| 4357 | 4357 |
| 4358 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4358 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4359 int dummyMaxTextureSize = 512; | 4359 int dummyMaxTextureSize = 512; |
| 4360 | 4360 |
| 4361 const double deviceScaleFactor = 2.5; | 4361 const double deviceScaleFactor = 2.5; |
| 4362 const double pageScaleFactor = 3; | 4362 const double pageScaleFactor = 3; |
| 4363 | 4363 |
| 4364 gfx::Transform pageScaleTransform; | 4364 gfx::Transform pageScaleTransform; |
| 4365 pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor); | 4365 pageScaleTransform.Scale(pageScaleFactor, pageScaleFactor); |
| 4366 parent->setImplTransform(pageScaleTransform); | 4366 parent->SetImplTransform(pageScaleTransform); |
| 4367 | 4367 |
| 4368 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4368 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); |
| 4369 | 4369 |
| 4370 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 4370 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
| 4371 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, perspectiveSur
face); | 4371 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, perspectiveSur
face); |
| 4372 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, scaleSurface); | 4372 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, scaleSurface); |
| 4373 | 4373 |
| 4374 EXPECT_EQ(3u, renderSurfaceLayerList.size()); | 4374 EXPECT_EQ(3u, renderSurfaceLayerList.size()); |
| 4375 | 4375 |
| 4376 gfx::Transform expectedParentDrawTransform; | 4376 gfx::Transform expectedParentDrawTransform; |
| 4377 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentDrawTransform, parent->drawTra
nsform()); | 4377 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentDrawTransform, parent->draw_tr
ansform()); |
| 4378 | 4378 |
| 4379 // The scaled surface is rendered at its appropriate scale, and drawn 1:1 | 4379 // The scaled surface is rendered at its appropriate scale, and drawn 1:1 |
| 4380 // into its target. | 4380 // into its target. |
| 4381 gfx::Transform expectedScaleSurfaceDrawTransform; | 4381 gfx::Transform expectedScaleSurfaceDrawTransform; |
| 4382 expectedScaleSurfaceDrawTransform.Translate( | 4382 expectedScaleSurfaceDrawTransform.Translate( |
| 4383 deviceScaleFactor * pageScaleFactor * scaleSurface->position().x(), | 4383 deviceScaleFactor * pageScaleFactor * scaleSurface->position().x(), |
| 4384 deviceScaleFactor * pageScaleFactor * scaleSurface->position().y()); | 4384 deviceScaleFactor * pageScaleFactor * scaleSurface->position().y()); |
| 4385 gfx::Transform expectedScaleSurfaceLayerDrawTransform; | 4385 gfx::Transform expectedScaleSurfaceLayerDrawTransform; |
| 4386 expectedScaleSurfaceLayerDrawTransform.PreconcatTransform(scaleSmallMatrix); | 4386 expectedScaleSurfaceLayerDrawTransform.PreconcatTransform(scaleSmallMatrix); |
| 4387 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScaleSurfaceDrawTransform, scaleSurf
ace->renderSurface()->draw_transform()); | 4387 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScaleSurfaceDrawTransform, scaleSurf
ace->render_surface()->draw_transform()); |
| 4388 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScaleSurfaceLayerDrawTransform, scal
eSurface->drawTransform()); | 4388 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScaleSurfaceLayerDrawTransform, scal
eSurface->draw_transform()); |
| 4389 | 4389 |
| 4390 // The scale for the perspective surface is not known, so it is rendered 1:1 | 4390 // The scale for the perspective surface is not known, so it is rendered 1:1 |
| 4391 // with the screen, and then scaled during drawing. | 4391 // with the screen, and then scaled during drawing. |
| 4392 gfx::Transform expectedPerspectiveSurfaceDrawTransform; | 4392 gfx::Transform expectedPerspectiveSurfaceDrawTransform; |
| 4393 expectedPerspectiveSurfaceDrawTransform.Translate( | 4393 expectedPerspectiveSurfaceDrawTransform.Translate( |
| 4394 deviceScaleFactor * pageScaleFactor * perspectiveSurface->position().x()
, | 4394 deviceScaleFactor * pageScaleFactor * perspectiveSurface->position().x()
, |
| 4395 deviceScaleFactor * pageScaleFactor * perspectiveSurface->position().y()
); | 4395 deviceScaleFactor * pageScaleFactor * perspectiveSurface->position().y()
); |
| 4396 expectedPerspectiveSurfaceDrawTransform.PreconcatTransform(perspectiveMatrix
); | 4396 expectedPerspectiveSurfaceDrawTransform.PreconcatTransform(perspectiveMatrix
); |
| 4397 expectedPerspectiveSurfaceDrawTransform.PreconcatTransform(scaleSmallMatrix)
; | 4397 expectedPerspectiveSurfaceDrawTransform.PreconcatTransform(scaleSmallMatrix)
; |
| 4398 gfx::Transform expectedPerspectiveSurfaceLayerDrawTransform; | 4398 gfx::Transform expectedPerspectiveSurfaceLayerDrawTransform; |
| 4399 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedPerspectiveSurfaceDrawTransform, per
spectiveSurface->renderSurface()->draw_transform()); | 4399 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedPerspectiveSurfaceDrawTransform, per
spectiveSurface->render_surface()->draw_transform()); |
| 4400 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedPerspectiveSurfaceLayerDrawTransform
, perspectiveSurface->drawTransform()); | 4400 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedPerspectiveSurfaceLayerDrawTransform
, perspectiveSurface->draw_transform()); |
| 4401 } | 4401 } |
| 4402 | 4402 |
| 4403 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi
ldPosition) | 4403 TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi
ldPosition) |
| 4404 { | 4404 { |
| 4405 // Verify draw and screen space transforms of layers not in a surface. | 4405 // Verify draw and screen space transforms of layers not in a surface. |
| 4406 MockContentLayerClient delegate; | 4406 MockContentLayerClient delegate; |
| 4407 gfx::Transform identityMatrix; | 4407 gfx::Transform identityMatrix; |
| 4408 | 4408 |
| 4409 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4409 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4410 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(133, 133), true); | 4410 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(133, 133), true); |
| 4411 | 4411 |
| 4412 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); | 4412 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
| 4413 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); | 4413 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); |
| 4414 | 4414 |
| 4415 scoped_refptr<NoScaleContentLayer> childNoScale = createNoScaleDrawableConte
ntLayer(&delegate); | 4415 scoped_refptr<NoScaleContentLayer> childNoScale = createNoScaleDrawableConte
ntLayer(&delegate); |
| 4416 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); | 4416 setLayerPropertiesForTesting(childNoScale.get(), identityMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 13), true); |
| 4417 | 4417 |
| 4418 parent->addChild(child); | 4418 parent->AddChild(child); |
| 4419 parent->addChild(childNoScale); | 4419 parent->AddChild(childNoScale); |
| 4420 | 4420 |
| 4421 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4421 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4422 int dummyMaxTextureSize = 512; | 4422 int dummyMaxTextureSize = 512; |
| 4423 | 4423 |
| 4424 const float deviceScaleFactor = 1.7f; | 4424 const float deviceScaleFactor = 1.7f; |
| 4425 const float pageScaleFactor = 1; | 4425 const float pageScaleFactor = 1; |
| 4426 | 4426 |
| 4427 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4427 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); |
| 4428 | 4428 |
| 4429 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); | 4429 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent); |
| 4430 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); | 4430 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child); |
| 4431 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4431 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
| 4432 | 4432 |
| 4433 EXPECT_EQ(1u, renderSurfaceLayerList.size()); | 4433 EXPECT_EQ(1u, renderSurfaceLayerList.size()); |
| 4434 | 4434 |
| 4435 // Verify parent transforms | 4435 // Verify parent transforms |
| 4436 gfx::Transform expectedParentTransform; | 4436 gfx::Transform expectedParentTransform; |
| 4437 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 4437 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screen_spac
e_transform()); |
| 4438 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 4438 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->draw_transf
orm()); |
| 4439 | 4439 |
| 4440 // Verify results of transformed parent rects | 4440 // Verify results of transformed parent rects |
| 4441 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->contentBoun
ds())); | 4441 gfx::RectF parentContentBounds(gfx::PointF(), gfx::SizeF(parent->content_bou
nds())); |
| 4442 | 4442 |
| 4443 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->drawTransform()
, parentContentBounds); | 4443 gfx::RectF parentDrawRect = MathUtil::mapClippedRect(parent->draw_transform(
), parentContentBounds); |
| 4444 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screenSp
aceTransform(), parentContentBounds); | 4444 gfx::RectF parentScreenSpaceRect = MathUtil::mapClippedRect(parent->screen_s
pace_transform(), parentContentBounds); |
| 4445 | 4445 |
| 4446 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); | 4446 gfx::RectF expectedParentDrawRect(gfx::PointF(), parent->bounds()); |
| 4447 expectedParentDrawRect.Scale(deviceScaleFactor); | 4447 expectedParentDrawRect.Scale(deviceScaleFactor); |
| 4448 expectedParentDrawRect.set_width(ceil(expectedParentDrawRect.width())); | 4448 expectedParentDrawRect.set_width(ceil(expectedParentDrawRect.width())); |
| 4449 expectedParentDrawRect.set_height(ceil(expectedParentDrawRect.height())); | 4449 expectedParentDrawRect.set_height(ceil(expectedParentDrawRect.height())); |
| 4450 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); | 4450 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentDrawRect); |
| 4451 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); | 4451 EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect); |
| 4452 | 4452 |
| 4453 // Verify child transforms | 4453 // Verify child transforms |
| 4454 gfx::Transform expectedChildTransform; | 4454 gfx::Transform expectedChildTransform; |
| 4455 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform
()); | 4455 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->draw_transfor
m()); |
| 4456 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTr
ansform()); | 4456 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screen_space_
transform()); |
| 4457 | 4457 |
| 4458 // Verify results of transformed child rects | 4458 // Verify results of transformed child rects |
| 4459 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->contentBounds
())); | 4459 gfx::RectF childContentBounds(gfx::PointF(), gfx::SizeF(child->content_bound
s())); |
| 4460 | 4460 |
| 4461 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->drawTransform(),
childContentBounds); | 4461 gfx::RectF childDrawRect = MathUtil::mapClippedRect(child->draw_transform(),
childContentBounds); |
| 4462 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screenSpac
eTransform(), childContentBounds); | 4462 gfx::RectF childScreenSpaceRect = MathUtil::mapClippedRect(child->screen_spa
ce_transform(), childContentBounds); |
| 4463 | 4463 |
| 4464 gfx::RectF expectedChildDrawRect(gfx::PointF(), child->bounds()); | 4464 gfx::RectF expectedChildDrawRect(gfx::PointF(), child->bounds()); |
| 4465 expectedChildDrawRect.Scale(deviceScaleFactor); | 4465 expectedChildDrawRect.Scale(deviceScaleFactor); |
| 4466 expectedChildDrawRect.set_width(ceil(expectedChildDrawRect.width())); | 4466 expectedChildDrawRect.set_width(ceil(expectedChildDrawRect.width())); |
| 4467 expectedChildDrawRect.set_height(ceil(expectedChildDrawRect.height())); | 4467 expectedChildDrawRect.set_height(ceil(expectedChildDrawRect.height())); |
| 4468 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); | 4468 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childDrawRect); |
| 4469 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); | 4469 EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect); |
| 4470 | 4470 |
| 4471 // Verify childNoScale transforms | 4471 // Verify childNoScale transforms |
| 4472 gfx::Transform expectedChildNoScaleTransform = child->drawTransform(); | 4472 gfx::Transform expectedChildNoScaleTransform = child->draw_transform(); |
| 4473 // All transforms operate on content rects. The child's content rect | 4473 // All transforms operate on content rects. The child's content rect |
| 4474 // incorporates device scale, but the childNoScale does not; add it here. | 4474 // incorporates device scale, but the childNoScale does not; add it here. |
| 4475 expectedChildNoScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); | 4475 expectedChildNoScaleTransform.Scale(deviceScaleFactor, deviceScaleFactor); |
| 4476 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>drawTransform()); | 4476 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>draw_transform()); |
| 4477 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screenSpaceTransform()); | 4477 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale-
>screen_space_transform()); |
| 4478 } | 4478 } |
| 4479 | 4479 |
| 4480 TEST(LayerTreeHostCommonTest, verifyContentsScale) | 4480 TEST(LayerTreeHostCommonTest, verifyContentsScale) |
| 4481 { | 4481 { |
| 4482 MockContentLayerClient delegate; | 4482 MockContentLayerClient delegate; |
| 4483 gfx::Transform identityMatrix; | 4483 gfx::Transform identityMatrix; |
| 4484 | 4484 |
| 4485 gfx::Transform parentScaleMatrix; | 4485 gfx::Transform parentScaleMatrix; |
| 4486 const double initialParentScale = 1.75; | 4486 const double initialParentScale = 1.75; |
| 4487 parentScaleMatrix.Scale(initialParentScale, initialParentScale); | 4487 parentScaleMatrix.Scale(initialParentScale, initialParentScale); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4499 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4499 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4500 | 4500 |
| 4501 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat
e); | 4501 scoped_refptr<ContentLayer> childEmpty = createDrawableContentLayer(&delegat
e); |
| 4502 setLayerPropertiesForTesting(childEmpty.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(0, 0), true); | 4502 setLayerPropertiesForTesting(childEmpty.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(0, 0), true); |
| 4503 | 4503 |
| 4504 scoped_refptr<NoScaleContentLayer> childNoScale = createNoScaleDrawableConte
ntLayer(&delegate); | 4504 scoped_refptr<NoScaleContentLayer> childNoScale = createNoScaleDrawableConte
ntLayer(&delegate); |
| 4505 setLayerPropertiesForTesting(childNoScale.get(), childScaleMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(12, 12), gfx::Size(10, 10), true); | 4505 setLayerPropertiesForTesting(childNoScale.get(), childScaleMatrix, identityM
atrix, gfx::PointF(0, 0), gfx::PointF(12, 12), gfx::Size(10, 10), true); |
| 4506 | 4506 |
| 4507 scoped_refptr<ContentLayer> childNoAutoScale = createDrawableContentLayer(&d
elegate); | 4507 scoped_refptr<ContentLayer> childNoAutoScale = createDrawableContentLayer(&d
elegate); |
| 4508 setLayerPropertiesForTesting(childNoAutoScale.get(), childScaleMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(22, 22), gfx::Size(10, 10), true); | 4508 setLayerPropertiesForTesting(childNoAutoScale.get(), childScaleMatrix, ident
ityMatrix, gfx::PointF(0, 0), gfx::PointF(22, 22), gfx::Size(10, 10), true); |
| 4509 childNoAutoScale->setAutomaticallyComputeRasterScale(false); | 4509 childNoAutoScale->SetAutomaticallyComputeRasterScale(false); |
| 4510 childNoAutoScale->setRasterScale(fixedRasterScale); | 4510 childNoAutoScale->SetRasterScale(fixedRasterScale); |
| 4511 | 4511 |
| 4512 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4512 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4513 // Page scale should not apply to the parent. | 4513 // Page scale should not apply to the parent. |
| 4514 parent->setBoundsContainPageScale(true); | 4514 parent->SetBoundsContainPageScale(true); |
| 4515 | 4515 |
| 4516 parent->addChild(childScale); | 4516 parent->AddChild(childScale); |
| 4517 parent->addChild(childEmpty); | 4517 parent->AddChild(childEmpty); |
| 4518 parent->addChild(childNoScale); | 4518 parent->AddChild(childNoScale); |
| 4519 parent->addChild(childNoAutoScale); | 4519 parent->AddChild(childNoAutoScale); |
| 4520 | 4520 |
| 4521 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4521 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4522 int dummyMaxTextureSize = 512; | 4522 int dummyMaxTextureSize = 512; |
| 4523 | 4523 |
| 4524 double deviceScaleFactor = 2.5; | 4524 double deviceScaleFactor = 2.5; |
| 4525 double pageScaleFactor = 1.5; | 4525 double pageScaleFactor = 1.5; |
| 4526 | 4526 |
| 4527 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4527 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4528 gfx::Transform pageScaleMatrix; | 4528 gfx::Transform pageScaleMatrix; |
| 4529 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); | 4529 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
| 4530 parent->setSublayerTransform(pageScaleMatrix); | 4530 parent->SetSublayerTransform(pageScaleMatrix); |
| 4531 | 4531 |
| 4532 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4532 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); |
| 4533 | 4533 |
| 4534 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4534 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4535 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); | 4535 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); |
| 4536 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); | 4536 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); |
| 4537 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4537 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
| 4538 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); | 4538 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); |
| 4539 | 4539 |
| 4540 // The parent is scaled up and shouldn't need to scale during draw. The chil
d that can scale its contents should | 4540 // The parent is scaled up and shouldn't need to scale during draw. The chil
d that can scale its contents should |
| 4541 // also not need to scale during draw. This shouldn't change if the child ha
s empty bounds. The other children should. | 4541 // also not need to scale during draw. This shouldn't change if the child ha
s empty bounds. The other children should. |
| 4542 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(0, 0)); | 4542 EXPECT_FLOAT_EQ(1, parent->draw_transform().matrix().getDouble(0, 0)); |
| 4543 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(1, 1)); | 4543 EXPECT_FLOAT_EQ(1, parent->draw_transform().matrix().getDouble(1, 1)); |
| 4544 EXPECT_FLOAT_EQ(1, childScale->drawTransform().matrix().getDouble(0, 0)); | 4544 EXPECT_FLOAT_EQ(1, childScale->draw_transform().matrix().getDouble(0, 0)); |
| 4545 EXPECT_FLOAT_EQ(1, childScale->drawTransform().matrix().getDouble(1, 1)); | 4545 EXPECT_FLOAT_EQ(1, childScale->draw_transform().matrix().getDouble(1, 1)); |
| 4546 EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().matrix().getDouble(0, 0)); | 4546 EXPECT_FLOAT_EQ(1, childEmpty->draw_transform().matrix().getDouble(0, 0)); |
| 4547 EXPECT_FLOAT_EQ(1, childEmpty->drawTransform().matrix().getDouble(1, 1)); | 4547 EXPECT_FLOAT_EQ(1, childEmpty->draw_transform().matrix().getDouble(1, 1)); |
| 4548 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->drawTransform().matrix().getDouble(0, 0)); | 4548 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->draw_transform().matrix().getDouble(0, 0)); |
| 4549 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->drawTransform().matrix().getDouble(1, 1)); | 4549 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, childNoScale->draw_transform().matrix().getDouble(1, 1)); |
| 4550 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c
hildNoAutoScale->drawTransform().matrix().getDouble(0, 0)); | 4550 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c
hildNoAutoScale->draw_transform().matrix().getDouble(0, 0)); |
| 4551 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c
hildNoAutoScale->drawTransform().matrix().getDouble(1, 1)); | 4551 EXPECT_FLOAT_EQ(initialParentScale * initialChildScale / fixedRasterScale, c
hildNoAutoScale->draw_transform().matrix().getDouble(1, 1)); |
| 4552 | 4552 |
| 4553 // If the deviceScaleFactor or pageScaleFactor changes, then it should be up
dated using the initial transform as the rasterScale. | 4553 // If the deviceScaleFactor or pageScaleFactor changes, then it should be up
dated using the initial transform as the rasterScale. |
| 4554 deviceScaleFactor = 2.25; | 4554 deviceScaleFactor = 2.25; |
| 4555 pageScaleFactor = 1.25; | 4555 pageScaleFactor = 1.25; |
| 4556 | 4556 |
| 4557 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4557 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4558 pageScaleMatrix = identityMatrix; | 4558 pageScaleMatrix = identityMatrix; |
| 4559 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); | 4559 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
| 4560 parent->setSublayerTransform(pageScaleMatrix); | 4560 parent->SetSublayerTransform(pageScaleMatrix); |
| 4561 | 4561 |
| 4562 renderSurfaceLayerList.clear(); | 4562 renderSurfaceLayerList.clear(); |
| 4563 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4563 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); |
| 4564 | 4564 |
| 4565 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4565 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4566 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); | 4566 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); |
| 4567 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); | 4567 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childEmpty); |
| 4568 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4568 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
| 4569 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); | 4569 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); |
| 4570 | 4570 |
| 4571 // If the transform changes, we expect the rasterScale to be reset to 1.0. | 4571 // If the transform changes, we expect the rasterScale to be reset to 1.0. |
| 4572 const double secondChildScale = 1.75; | 4572 const double secondChildScale = 1.75; |
| 4573 childScaleMatrix.Scale(secondChildScale / initialChildScale, secondChildScal
e / initialChildScale); | 4573 childScaleMatrix.Scale(secondChildScale / initialChildScale, secondChildScal
e / initialChildScale); |
| 4574 childScale->setTransform(childScaleMatrix); | 4574 childScale->SetTransform(childScaleMatrix); |
| 4575 childEmpty->setTransform(childScaleMatrix); | 4575 childEmpty->SetTransform(childScaleMatrix); |
| 4576 | 4576 |
| 4577 renderSurfaceLayerList.clear(); | 4577 renderSurfaceLayerList.clear(); |
| 4578 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4578 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); |
| 4579 | 4579 |
| 4580 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4580 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4581 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childScale); | 4581 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childScale); |
| 4582 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); | 4582 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); |
| 4583 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4583 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
| 4584 | 4584 |
| 4585 // If the deviceScaleFactor or pageScaleFactor changes, then it should be up
dated, but still using 1.0 as the rasterScale. | 4585 // If the deviceScaleFactor or pageScaleFactor changes, then it should be up
dated, but still using 1.0 as the rasterScale. |
| 4586 deviceScaleFactor = 2.75; | 4586 deviceScaleFactor = 2.75; |
| 4587 pageScaleFactor = 1.75; | 4587 pageScaleFactor = 1.75; |
| 4588 | 4588 |
| 4589 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4589 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4590 pageScaleMatrix = identityMatrix; | 4590 pageScaleMatrix = identityMatrix; |
| 4591 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); | 4591 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
| 4592 parent->setSublayerTransform(pageScaleMatrix); | 4592 parent->SetSublayerTransform(pageScaleMatrix); |
| 4593 | 4593 |
| 4594 renderSurfaceLayerList.clear(); | 4594 renderSurfaceLayerList.clear(); |
| 4595 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4595 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); |
| 4596 | 4596 |
| 4597 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4597 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4598 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childScale); | 4598 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childScale); |
| 4599 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); | 4599 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, childEmpty); |
| 4600 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 4600 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
| 4601 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); | 4601 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); |
| 4602 } | 4602 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4615 childScaleMatrix.Scale(initialChildScale, initialChildScale); | 4615 childScaleMatrix.Scale(initialChildScale, initialChildScale); |
| 4616 | 4616 |
| 4617 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4617 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4618 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4618 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
| 4619 | 4619 |
| 4620 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); | 4620 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); |
| 4621 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4621 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4622 | 4622 |
| 4623 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4623 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4624 // Page scale should not apply to the parent. | 4624 // Page scale should not apply to the parent. |
| 4625 parent->setBoundsContainPageScale(true); | 4625 parent->SetBoundsContainPageScale(true); |
| 4626 | 4626 |
| 4627 parent->addChild(childScale); | 4627 parent->AddChild(childScale); |
| 4628 | 4628 |
| 4629 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4629 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4630 int dummyMaxTextureSize = 512; | 4630 int dummyMaxTextureSize = 512; |
| 4631 | 4631 |
| 4632 double deviceScaleFactor = 2.5; | 4632 double deviceScaleFactor = 2.5; |
| 4633 double pageScaleFactor = 0.01; | 4633 double pageScaleFactor = 0.01; |
| 4634 | 4634 |
| 4635 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4635 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4636 gfx::Transform pageScaleMatrix; | 4636 gfx::Transform pageScaleMatrix; |
| 4637 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); | 4637 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
| 4638 parent->setSublayerTransform(pageScaleMatrix); | 4638 parent->SetSublayerTransform(pageScaleMatrix); |
| 4639 | 4639 |
| 4640 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4640 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); |
| 4641 | 4641 |
| 4642 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4642 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4643 // The child's scale is < 1, so we should not save and use that scale factor
. | 4643 // The child's scale is < 1, so we should not save and use that scale factor
. |
| 4644 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale
); | 4644 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale
); |
| 4645 | 4645 |
| 4646 // When chilld's total scale becomes >= 1, we should save and use that scale
factor. | 4646 // When chilld's total scale becomes >= 1, we should save and use that scale
factor. |
| 4647 childScaleMatrix.MakeIdentity(); | 4647 childScaleMatrix.MakeIdentity(); |
| 4648 const double finalChildScale = 0.75; | 4648 const double finalChildScale = 0.75; |
| 4649 childScaleMatrix.Scale(finalChildScale, finalChildScale); | 4649 childScaleMatrix.Scale(finalChildScale, finalChildScale); |
| 4650 childScale->setTransform(childScaleMatrix); | 4650 childScale->SetTransform(childScaleMatrix); |
| 4651 | 4651 |
| 4652 renderSurfaceLayerList.clear(); | 4652 renderSurfaceLayerList.clear(); |
| 4653 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4653 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); |
| 4654 | 4654 |
| 4655 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4655 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4656 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * finalChildScale, childScale); | 4656 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * finalChildScale, childScale); |
| 4657 } | 4657 } |
| 4658 | 4658 |
| 4659 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) | 4659 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) |
| 4660 { | 4660 { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4687 setLayerPropertiesForTesting(surfaceNoScale.get(), childScaleMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(12, 12), gfx::Size(10, 10), true); | 4687 setLayerPropertiesForTesting(surfaceNoScale.get(), childScaleMatrix, identit
yMatrix, gfx::PointF(0, 0), gfx::PointF(12, 12), gfx::Size(10, 10), true); |
| 4688 | 4688 |
| 4689 scoped_refptr<ContentLayer> surfaceNoScaleChildScale = createDrawableContent
Layer(&delegate); | 4689 scoped_refptr<ContentLayer> surfaceNoScaleChildScale = createDrawableContent
Layer(&delegate); |
| 4690 setLayerPropertiesForTesting(surfaceNoScaleChildScale.get(), childScaleMatri
x, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true
); | 4690 setLayerPropertiesForTesting(surfaceNoScaleChildScale.get(), childScaleMatri
x, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true
); |
| 4691 | 4691 |
| 4692 scoped_refptr<NoScaleContentLayer> surfaceNoScaleChildNoScale = createNoScal
eDrawableContentLayer(&delegate); | 4692 scoped_refptr<NoScaleContentLayer> surfaceNoScaleChildNoScale = createNoScal
eDrawableContentLayer(&delegate); |
| 4693 setLayerPropertiesForTesting(surfaceNoScaleChildNoScale.get(), childScaleMat
rix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), tr
ue); | 4693 setLayerPropertiesForTesting(surfaceNoScaleChildNoScale.get(), childScaleMat
rix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), tr
ue); |
| 4694 | 4694 |
| 4695 scoped_refptr<ContentLayer> surfaceNoAutoScale = createDrawableContentLayer(
&delegate); | 4695 scoped_refptr<ContentLayer> surfaceNoAutoScale = createDrawableContentLayer(
&delegate); |
| 4696 setLayerPropertiesForTesting(surfaceNoAutoScale.get(), childScaleMatrix, ide
ntityMatrix, gfx::PointF(0, 0), gfx::PointF(22, 22), gfx::Size(10, 10), true); | 4696 setLayerPropertiesForTesting(surfaceNoAutoScale.get(), childScaleMatrix, ide
ntityMatrix, gfx::PointF(0, 0), gfx::PointF(22, 22), gfx::Size(10, 10), true); |
| 4697 surfaceNoAutoScale->setAutomaticallyComputeRasterScale(false); | 4697 surfaceNoAutoScale->SetAutomaticallyComputeRasterScale(false); |
| 4698 surfaceNoAutoScale->setRasterScale(fixedRasterScale); | 4698 surfaceNoAutoScale->SetRasterScale(fixedRasterScale); |
| 4699 | 4699 |
| 4700 scoped_refptr<ContentLayer> surfaceNoAutoScaleChildScale = createDrawableCon
tentLayer(&delegate); | 4700 scoped_refptr<ContentLayer> surfaceNoAutoScaleChildScale = createDrawableCon
tentLayer(&delegate); |
| 4701 setLayerPropertiesForTesting(surfaceNoAutoScaleChildScale.get(), childScaleM
atrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10),
true); | 4701 setLayerPropertiesForTesting(surfaceNoAutoScaleChildScale.get(), childScaleM
atrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10),
true); |
| 4702 | 4702 |
| 4703 scoped_refptr<NoScaleContentLayer> surfaceNoAutoScaleChildNoScale = createNo
ScaleDrawableContentLayer(&delegate); | 4703 scoped_refptr<NoScaleContentLayer> surfaceNoAutoScaleChildNoScale = createNo
ScaleDrawableContentLayer(&delegate); |
| 4704 setLayerPropertiesForTesting(surfaceNoAutoScaleChildNoScale.get(), childScal
eMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10)
, true); | 4704 setLayerPropertiesForTesting(surfaceNoAutoScaleChildNoScale.get(), childScal
eMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10)
, true); |
| 4705 | 4705 |
| 4706 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4706 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4707 // Page scale should not apply to the parent. | 4707 // Page scale should not apply to the parent. |
| 4708 parent->setBoundsContainPageScale(true); | 4708 parent->SetBoundsContainPageScale(true); |
| 4709 | 4709 |
| 4710 parent->addChild(surfaceScale); | 4710 parent->AddChild(surfaceScale); |
| 4711 parent->addChild(surfaceNoScale); | 4711 parent->AddChild(surfaceNoScale); |
| 4712 parent->addChild(surfaceNoAutoScale); | 4712 parent->AddChild(surfaceNoAutoScale); |
| 4713 | 4713 |
| 4714 surfaceScale->setForceRenderSurface(true); | 4714 surfaceScale->SetForceRenderSurface(true); |
| 4715 surfaceScale->addChild(surfaceScaleChildScale); | 4715 surfaceScale->AddChild(surfaceScaleChildScale); |
| 4716 surfaceScale->addChild(surfaceScaleChildNoScale); | 4716 surfaceScale->AddChild(surfaceScaleChildNoScale); |
| 4717 | 4717 |
| 4718 surfaceNoScale->setForceRenderSurface(true); | 4718 surfaceNoScale->SetForceRenderSurface(true); |
| 4719 surfaceNoScale->addChild(surfaceNoScaleChildScale); | 4719 surfaceNoScale->AddChild(surfaceNoScaleChildScale); |
| 4720 surfaceNoScale->addChild(surfaceNoScaleChildNoScale); | 4720 surfaceNoScale->AddChild(surfaceNoScaleChildNoScale); |
| 4721 | 4721 |
| 4722 surfaceNoAutoScale->setForceRenderSurface(true); | 4722 surfaceNoAutoScale->SetForceRenderSurface(true); |
| 4723 surfaceNoAutoScale->addChild(surfaceNoAutoScaleChildScale); | 4723 surfaceNoAutoScale->AddChild(surfaceNoAutoScaleChildScale); |
| 4724 surfaceNoAutoScale->addChild(surfaceNoAutoScaleChildNoScale); | 4724 surfaceNoAutoScale->AddChild(surfaceNoAutoScaleChildNoScale); |
| 4725 | 4725 |
| 4726 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4726 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4727 int dummyMaxTextureSize = 512; | 4727 int dummyMaxTextureSize = 512; |
| 4728 | 4728 |
| 4729 double deviceScaleFactor = 5; | 4729 double deviceScaleFactor = 5; |
| 4730 double pageScaleFactor = 7; | 4730 double pageScaleFactor = 7; |
| 4731 | 4731 |
| 4732 // FIXME: Remove this when pageScaleFactor is applied in the compositor. | 4732 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 4733 gfx::Transform pageScaleMatrix; | 4733 gfx::Transform pageScaleMatrix; |
| 4734 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); | 4734 pageScaleMatrix.Scale(pageScaleFactor, pageScaleFactor); |
| 4735 parent->setSublayerTransform(pageScaleMatrix); | 4735 parent->SetSublayerTransform(pageScaleMatrix); |
| 4736 | 4736 |
| 4737 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); | 4737 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLa
yerList); |
| 4738 | 4738 |
| 4739 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 4739 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 4740 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, surfaceScale); | 4740 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, surfaceScale); |
| 4741 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale); | 4741 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScale); |
| 4742 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, surfaceNoAutoScale); | 4742 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, surfaceNoAutoScale); |
| 4743 | 4743 |
| 4744 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceScaleChildScale); | 4744 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceScaleChildScale); |
| 4745 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale); | 4745 EXPECT_CONTENTS_SCALE_EQ(1, surfaceScaleChildNoScale); |
| 4746 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale); | 4746 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceNoScaleChildScale); |
| 4747 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale); | 4747 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoScaleChildNoScale); |
| 4748 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceNoAutoScaleChildScale); | 4748 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale * initialChildScale, surfaceNoAutoScaleChildScale); |
| 4749 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoAutoScaleChildNoScale); | 4749 EXPECT_CONTENTS_SCALE_EQ(1, surfaceNoAutoScaleChildNoScale); |
| 4750 | 4750 |
| 4751 // The parent is scaled up and shouldn't need to scale during draw. | 4751 // The parent is scaled up and shouldn't need to scale during draw. |
| 4752 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(0, 0)); | 4752 EXPECT_FLOAT_EQ(1, parent->draw_transform().matrix().getDouble(0, 0)); |
| 4753 EXPECT_FLOAT_EQ(1, parent->drawTransform().matrix().getDouble(1, 1)); | 4753 EXPECT_FLOAT_EQ(1, parent->draw_transform().matrix().getDouble(1, 1)); |
| 4754 | 4754 |
| 4755 // RenderSurfaces should always be 1:1 with their target. | 4755 // RenderSurfaces should always be 1:1 with their target. |
| 4756 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->draw_transform().matrix().
getDouble(0, 0)); | 4756 EXPECT_FLOAT_EQ(1, surfaceScale->render_surface()->draw_transform().matrix()
.getDouble(0, 0)); |
| 4757 EXPECT_FLOAT_EQ(1, surfaceScale->renderSurface()->draw_transform().matrix().
getDouble(1, 1)); | 4757 EXPECT_FLOAT_EQ(1, surfaceScale->render_surface()->draw_transform().matrix()
.getDouble(1, 1)); |
| 4758 | 4758 |
| 4759 // The surfaceScale can apply contents scale so the layer shouldn't need to
scale during draw. | 4759 // The surfaceScale can apply contents scale so the layer shouldn't need to
scale during draw. |
| 4760 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().matrix().getDouble(0, 0)); | 4760 EXPECT_FLOAT_EQ(1, surfaceScale->draw_transform().matrix().getDouble(0, 0)); |
| 4761 EXPECT_FLOAT_EQ(1, surfaceScale->drawTransform().matrix().getDouble(1, 1)); | 4761 EXPECT_FLOAT_EQ(1, surfaceScale->draw_transform().matrix().getDouble(1, 1)); |
| 4762 | 4762 |
| 4763 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. | 4763 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. |
| 4764 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().matrix().getDoubl
e(0, 0)); | 4764 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->draw_transform().matrix().getDoub
le(0, 0)); |
| 4765 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->drawTransform().matrix().getDoubl
e(1, 1)); | 4765 EXPECT_FLOAT_EQ(1, surfaceScaleChildScale->draw_transform().matrix().getDoub
le(1, 1)); |
| 4766 | 4766 |
| 4767 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. | 4767 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. |
| 4768 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().
matrix().getDouble(0, 0)); | 4768 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->draw_transform()
.matrix().getDouble(0, 0)); |
| 4769 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->drawTransform().
matrix().getDouble(1, 1)); | 4769 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceScaleChildNoScale->draw_transform()
.matrix().getDouble(1, 1)); |
| 4770 | 4770 |
| 4771 // RenderSurfaces should always be 1:1 with their target. | 4771 // RenderSurfaces should always be 1:1 with their target. |
| 4772 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->draw_transform().matrix(
).getDouble(0, 0)); | 4772 EXPECT_FLOAT_EQ(1, surfaceNoScale->render_surface()->draw_transform().matrix
().getDouble(0, 0)); |
| 4773 EXPECT_FLOAT_EQ(1, surfaceNoScale->renderSurface()->draw_transform().matrix(
).getDouble(1, 1)); | 4773 EXPECT_FLOAT_EQ(1, surfaceNoScale->render_surface()->draw_transform().matrix
().getDouble(1, 1)); |
| 4774 | 4774 |
| 4775 // The surfaceNoScale layer can not apply contents scale, so it needs to be
scaled during draw. | 4775 // The surfaceNoScale layer can not apply contents scale, so it needs to be
scaled during draw. |
| 4776 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->drawTransform().matrix().getDouble(0, 0)); | 4776 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->draw_transform().matrix().getDouble(0, 0)); |
| 4777 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->drawTransform().matrix().getDouble(1, 1)); | 4777 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale, surfaceNoScale->draw_transform().matrix().getDouble(1, 1)); |
| 4778 | 4778 |
| 4779 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. | 4779 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. |
| 4780 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().matrix().getDou
ble(0, 0)); | 4780 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->draw_transform().matrix().getDo
uble(0, 0)); |
| 4781 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->drawTransform().matrix().getDou
ble(1, 1)); | 4781 EXPECT_FLOAT_EQ(1, surfaceNoScaleChildScale->draw_transform().matrix().getDo
uble(1, 1)); |
| 4782 | 4782 |
| 4783 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. | 4783 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. |
| 4784 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform(
).matrix().getDouble(0, 0)); | 4784 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->draw_transform
().matrix().getDouble(0, 0)); |
| 4785 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->drawTransform(
).matrix().getDouble(1, 1)); | 4785 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoScaleChildNoScale->draw_transform
().matrix().getDouble(1, 1)); |
| 4786 | 4786 |
| 4787 // RenderSurfaces should always be 1:1 with their target. | 4787 // RenderSurfaces should always be 1:1 with their target. |
| 4788 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->draw_transform().mat
rix().getDouble(0, 0)); | 4788 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->render_surface()->draw_transform().ma
trix().getDouble(0, 0)); |
| 4789 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->renderSurface()->draw_transform().mat
rix().getDouble(1, 1)); | 4789 EXPECT_FLOAT_EQ(1, surfaceNoAutoScale->render_surface()->draw_transform().ma
trix().getDouble(1, 1)); |
| 4790 | 4790 |
| 4791 // The surfaceNoAutoScale layer has a fixed contents scale, so it needs to b
e scaled during draw. | 4791 // The surfaceNoAutoScale layer has a fixed contents scale, so it needs to b
e scaled during draw. |
| 4792 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur
faceNoAutoScale->drawTransform().matrix().getDouble(0, 0)); | 4792 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur
faceNoAutoScale->draw_transform().matrix().getDouble(0, 0)); |
| 4793 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur
faceNoAutoScale->drawTransform().matrix().getDouble(1, 1)); | 4793 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale / (deviceScaleFactor * pageScaleFactor * fixedRasterScale), sur
faceNoAutoScale->draw_transform().matrix().getDouble(1, 1)); |
| 4794 | 4794 |
| 4795 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. | 4795 // The surfaceScaleChildScale can apply contents scale so it shouldn't need
to scale during draw. |
| 4796 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().matrix().ge
tDouble(0, 0)); | 4796 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->draw_transform().matrix().g
etDouble(0, 0)); |
| 4797 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->drawTransform().matrix().ge
tDouble(1, 1)); | 4797 EXPECT_FLOAT_EQ(1, surfaceNoAutoScaleChildScale->draw_transform().matrix().g
etDouble(1, 1)); |
| 4798 | 4798 |
| 4799 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. | 4799 // The surfaceScaleChildNoScale can not apply contents scale, so it needs to
be scaled during draw. |
| 4800 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf
orm().matrix().getDouble(0, 0)); | 4800 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->draw_trans
form().matrix().getDouble(0, 0)); |
| 4801 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->drawTransf
orm().matrix().getDouble(1, 1)); | 4801 EXPECT_FLOAT_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * i
nitialChildScale * initialChildScale, surfaceNoAutoScaleChildNoScale->draw_trans
form().matrix().getDouble(1, 1)); |
| 4802 } | 4802 } |
| 4803 | 4803 |
| 4804 TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer) | 4804 TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer) |
| 4805 { | 4805 { |
| 4806 MockContentLayerClient delegate; | 4806 MockContentLayerClient delegate; |
| 4807 gfx::Transform identityMatrix; | 4807 gfx::Transform identityMatrix; |
| 4808 | 4808 |
| 4809 gfx::Transform parentScaleMatrix; | 4809 gfx::Transform parentScaleMatrix; |
| 4810 const double initialParentScale = 1.75; | 4810 const double initialParentScale = 1.75; |
| 4811 parentScaleMatrix.Scale(initialParentScale, initialParentScale); | 4811 parentScaleMatrix.Scale(initialParentScale, initialParentScale); |
| 4812 | 4812 |
| 4813 gfx::Transform childScaleMatrix; | 4813 gfx::Transform childScaleMatrix; |
| 4814 const double initialChildScale = 1.25; | 4814 const double initialChildScale = 1.25; |
| 4815 childScaleMatrix.Scale(initialChildScale, initialChildScale); | 4815 childScaleMatrix.Scale(initialChildScale, initialChildScale); |
| 4816 | 4816 |
| 4817 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4817 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4818 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); | 4818 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
| 4819 | 4819 |
| 4820 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); | 4820 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); |
| 4821 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4821 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4822 | 4822 |
| 4823 parent->addChild(childScale); | 4823 parent->AddChild(childScale); |
| 4824 | 4824 |
| 4825 // Now put an animating transform on child. | 4825 // Now put an animating transform on child. |
| 4826 int animationId = addAnimatedTransformToController(*childScale->layerAnimati
onController(), 10, 30, 0); | 4826 int animationId = addAnimatedTransformToController(*childScale->layer_animat
ion_controller(), 10, 30, 0); |
| 4827 | 4827 |
| 4828 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4828 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4829 int dummyMaxTextureSize = 512; | 4829 int dummyMaxTextureSize = 512; |
| 4830 | 4830 |
| 4831 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 4831 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 4832 | 4832 |
| 4833 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); | 4833 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); |
| 4834 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. | 4834 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. |
| 4835 EXPECT_CONTENTS_SCALE_EQ(1, childScale); | 4835 EXPECT_CONTENTS_SCALE_EQ(1, childScale); |
| 4836 | 4836 |
| 4837 // Remove the animation, now it can save a raster scale. | 4837 // Remove the animation, now it can save a raster scale. |
| 4838 childScale->layerAnimationController()->RemoveAnimation(animationId); | 4838 childScale->layer_animation_controller()->RemoveAnimation(animationId); |
| 4839 | 4839 |
| 4840 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 4840 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 4841 | 4841 |
| 4842 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); | 4842 EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent); |
| 4843 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. | 4843 // The layers with animating transforms should not compute a contentsScale o
ther than 1 until they finish animating. |
| 4844 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale)
; | 4844 EXPECT_CONTENTS_SCALE_EQ(initialParentScale * initialChildScale, childScale)
; |
| 4845 } | 4845 } |
| 4846 | 4846 |
| 4847 | 4847 |
| 4848 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) | 4848 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4859 gfx::Transform replicaTransform; | 4859 gfx::Transform replicaTransform; |
| 4860 replicaTransform.Scale(1, -1); | 4860 replicaTransform.Scale(1, -1); |
| 4861 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); | 4861 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); |
| 4862 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); | 4862 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 4863 | 4863 |
| 4864 // This layer should end up in the same surface as child, with the same draw | 4864 // This layer should end up in the same surface as child, with the same draw |
| 4865 // and screen space transforms. | 4865 // and screen space transforms. |
| 4866 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa
yer(&delegate); | 4866 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa
yer(&delegate); |
| 4867 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true); | 4867 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 10), true); |
| 4868 | 4868 |
| 4869 parent->addChild(child); | 4869 parent->AddChild(child); |
| 4870 child->addChild(duplicateChildNonOwner); | 4870 child->AddChild(duplicateChildNonOwner); |
| 4871 child->setReplicaLayer(replica.get()); | 4871 child->SetReplicaLayer(replica.get()); |
| 4872 | 4872 |
| 4873 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4873 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4874 int dummyMaxTextureSize = 512; | 4874 int dummyMaxTextureSize = 512; |
| 4875 | 4875 |
| 4876 const double deviceScaleFactor = 1.5; | 4876 const double deviceScaleFactor = 1.5; |
| 4877 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 4877 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 4878 | 4878 |
| 4879 // We should have two render surfaces. The root's render surface and child's | 4879 // We should have two render surfaces. The root's render surface and child's |
| 4880 // render surface (it needs one because it has a replica layer). | 4880 // render surface (it needs one because it has a replica layer). |
| 4881 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4881 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
| 4882 | 4882 |
| 4883 gfx::Transform expectedParentTransform; | 4883 gfx::Transform expectedParentTransform; |
| 4884 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpace
Transform()); | 4884 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screen_spac
e_transform()); |
| 4885 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransfo
rm()); | 4885 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->draw_transf
orm()); |
| 4886 | 4886 |
| 4887 gfx::Transform expectedDrawTransform; | 4887 gfx::Transform expectedDrawTransform; |
| 4888 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->drawTransform(
)); | 4888 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->draw_transform
()); |
| 4889 | 4889 |
| 4890 gfx::Transform expectedScreenSpaceTransform; | 4890 gfx::Transform expectedScreenSpaceTransform; |
| 4891 expectedScreenSpaceTransform.Translate(deviceScaleFactor * child->position()
.x(), deviceScaleFactor * child->position().y()); | 4891 expectedScreenSpaceTransform.Translate(deviceScaleFactor * child->position()
.x(), deviceScaleFactor * child->position().y()); |
| 4892 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->screenS
paceTransform()); | 4892 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->screen_
space_transform()); |
| 4893 | 4893 |
| 4894 gfx::Transform expectedDuplicateChildDrawTransform = child->drawTransform(); | 4894 gfx::Transform expectedDuplicateChildDrawTransform = child->draw_transform()
; |
| 4895 EXPECT_TRANSFORMATION_MATRIX_EQ(child->drawTransform(), duplicateChildNonOwn
er->drawTransform()); | 4895 EXPECT_TRANSFORMATION_MATRIX_EQ(child->draw_transform(), duplicateChildNonOw
ner->draw_transform()); |
| 4896 EXPECT_TRANSFORMATION_MATRIX_EQ(child->screenSpaceTransform(), duplicateChil
dNonOwner->screenSpaceTransform()); | 4896 EXPECT_TRANSFORMATION_MATRIX_EQ(child->screen_space_transform(), duplicateCh
ildNonOwner->screen_space_transform()); |
| 4897 EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawabl
eContentRect()); | 4897 EXPECT_RECT_EQ(child->drawable_content_rect(), duplicateChildNonOwner->drawa
ble_content_rect()); |
| 4898 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds()); | 4898 EXPECT_EQ(child->content_bounds(), duplicateChildNonOwner->content_bounds())
; |
| 4899 | 4899 |
| 4900 gfx::Transform expectedRenderSurfaceDrawTransform; | 4900 gfx::Transform expectedRenderSurfaceDrawTransform; |
| 4901 expectedRenderSurfaceDrawTransform.Translate(deviceScaleFactor * child->posi
tion().x(), deviceScaleFactor * child->position().y()); | 4901 expectedRenderSurfaceDrawTransform.Translate(deviceScaleFactor * child->posi
tion().x(), deviceScaleFactor * child->position().y()); |
| 4902 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedRenderSurfaceDrawTransform, child->r
enderSurface()->draw_transform()); | 4902 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedRenderSurfaceDrawTransform, child->r
ender_surface()->draw_transform()); |
| 4903 | 4903 |
| 4904 gfx::Transform expectedSurfaceDrawTransform; | 4904 gfx::Transform expectedSurfaceDrawTransform; |
| 4905 expectedSurfaceDrawTransform.Translate(deviceScaleFactor * 2, deviceScaleFac
tor * 2); | 4905 expectedSurfaceDrawTransform.Translate(deviceScaleFactor * 2, deviceScaleFac
tor * 2); |
| 4906 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS
urface()->draw_transform()); | 4906 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->render_
surface()->draw_transform()); |
| 4907 | 4907 |
| 4908 gfx::Transform expectedSurfaceScreenSpaceTransform; | 4908 gfx::Transform expectedSurfaceScreenSpaceTransform; |
| 4909 expectedSurfaceScreenSpaceTransform.Translate(deviceScaleFactor * 2, deviceS
caleFactor * 2); | 4909 expectedSurfaceScreenSpaceTransform.Translate(deviceScaleFactor * 2, deviceS
caleFactor * 2); |
| 4910 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceScreenSpaceTransform, child->
renderSurface()->screen_space_transform()); | 4910 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceScreenSpaceTransform, child->
render_surface()->screen_space_transform()); |
| 4911 | 4911 |
| 4912 gfx::Transform expectedReplicaDrawTransform; | 4912 gfx::Transform expectedReplicaDrawTransform; |
| 4913 expectedReplicaDrawTransform.matrix().setDouble(1, 1, -1); | 4913 expectedReplicaDrawTransform.matrix().setDouble(1, 1, -1); |
| 4914 expectedReplicaDrawTransform.matrix().setDouble(0, 3, 6); | 4914 expectedReplicaDrawTransform.matrix().setDouble(0, 3, 6); |
| 4915 expectedReplicaDrawTransform.matrix().setDouble(1, 3, 6); | 4915 expectedReplicaDrawTransform.matrix().setDouble(1, 3, 6); |
| 4916 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS
urface()->replica_draw_transform()); | 4916 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->render_
surface()->replica_draw_transform()); |
| 4917 | 4917 |
| 4918 gfx::Transform expectedReplicaScreenSpaceTransform; | 4918 gfx::Transform expectedReplicaScreenSpaceTransform; |
| 4919 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 1, -1); | 4919 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 1, -1); |
| 4920 expectedReplicaScreenSpaceTransform.matrix().setDouble(0, 3, 6); | 4920 expectedReplicaScreenSpaceTransform.matrix().setDouble(0, 3, 6); |
| 4921 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 3, 6); | 4921 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 3, 6); |
| 4922 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
renderSurface()->replica_screen_space_transform()); | 4922 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
render_surface()->replica_screen_space_transform()); |
| 4923 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
renderSurface()->replica_screen_space_transform()); | 4923 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
render_surface()->replica_screen_space_transform()); |
| 4924 } | 4924 } |
| 4925 | 4925 |
| 4926 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScal
eZeroPosition) | 4926 TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScal
eZeroPosition) |
| 4927 { | 4927 { |
| 4928 MockContentLayerClient delegate; | 4928 MockContentLayerClient delegate; |
| 4929 gfx::Transform identityMatrix; | 4929 gfx::Transform identityMatrix; |
| 4930 | 4930 |
| 4931 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); | 4931 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 4932 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(33, 31), true); | 4932 setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, g
fx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(33, 31), true); |
| 4933 | 4933 |
| 4934 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); | 4934 scoped_refptr<ContentLayer> child = createDrawableContentLayer(&delegate); |
| 4935 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); | 4935 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
| 4936 | 4936 |
| 4937 gfx::Transform replicaTransform; | 4937 gfx::Transform replicaTransform; |
| 4938 replicaTransform.Scale(1, -1); | 4938 replicaTransform.Scale(1, -1); |
| 4939 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); | 4939 scoped_refptr<ContentLayer> replica = createDrawableContentLayer(&delegate); |
| 4940 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); | 4940 setLayerPropertiesForTesting(replica.get(), replicaTransform, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
| 4941 | 4941 |
| 4942 // This layer should end up in the same surface as child, with the same draw | 4942 // This layer should end up in the same surface as child, with the same draw |
| 4943 // and screen space transforms. | 4943 // and screen space transforms. |
| 4944 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa
yer(&delegate); | 4944 scoped_refptr<ContentLayer> duplicateChildNonOwner = createDrawableContentLa
yer(&delegate); |
| 4945 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); | 4945 setLayerPropertiesForTesting(duplicateChildNonOwner.get(), identityMatrix, i
dentityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(13, 11), true); |
| 4946 | 4946 |
| 4947 parent->addChild(child); | 4947 parent->AddChild(child); |
| 4948 child->addChild(duplicateChildNonOwner); | 4948 child->AddChild(duplicateChildNonOwner); |
| 4949 child->setReplicaLayer(replica.get()); | 4949 child->SetReplicaLayer(replica.get()); |
| 4950 | 4950 |
| 4951 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; | 4951 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 4952 int dummyMaxTextureSize = 512; | 4952 int dummyMaxTextureSize = 512; |
| 4953 | 4953 |
| 4954 const float deviceScaleFactor = 1.7f; | 4954 const float deviceScaleFactor = 1.7f; |
| 4955 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); | 4955 LayerTreeHostCommon::calculateDrawProperties(parent.get(), parent->bounds(),
deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList); |
| 4956 | 4956 |
| 4957 // We should have two render surfaces. The root's render surface and child's | 4957 // We should have two render surfaces. The root's render surface and child's |
| 4958 // render surface (it needs one because it has a replica layer). | 4958 // render surface (it needs one because it has a replica layer). |
| 4959 EXPECT_EQ(2u, renderSurfaceLayerList.size()); | 4959 EXPECT_EQ(2u, renderSurfaceLayerList.size()); |
| 4960 | 4960 |
| 4961 gfx::Transform identityTransform; | 4961 gfx::Transform identityTransform; |
| 4962 | 4962 |
| 4963 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screenSpaceTransf
orm()); | 4963 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->screen_space_tran
sform()); |
| 4964 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->drawTransform()); | 4964 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, parent->draw_transform())
; |
| 4965 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->drawTransform()); | 4965 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->draw_transform()); |
| 4966 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->screenSpaceTransfo
rm()); | 4966 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->screen_space_trans
form()); |
| 4967 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->d
rawTransform()); | 4967 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->d
raw_transform()); |
| 4968 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->s
creenSpaceTransform()); | 4968 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, duplicateChildNonOwner->s
creen_space_transform()); |
| 4969 EXPECT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawabl
eContentRect()); | 4969 EXPECT_RECT_EQ(child->drawable_content_rect(), duplicateChildNonOwner->drawa
ble_content_rect()); |
| 4970 EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds()); | 4970 EXPECT_EQ(child->content_bounds(), duplicateChildNonOwner->content_bounds())
; |
| 4971 | 4971 |
| 4972 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->d
raw_transform()); | 4972 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->render_surface()->
draw_transform()); |
| 4973 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->d
raw_transform()); | 4973 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->render_surface()->
draw_transform()); |
| 4974 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->renderSurface()->s
creen_space_transform()); | 4974 EXPECT_TRANSFORMATION_MATRIX_EQ(identityTransform, child->render_surface()->
screen_space_transform()); |
| 4975 | 4975 |
| 4976 gfx::Transform expectedReplicaDrawTransform; | 4976 gfx::Transform expectedReplicaDrawTransform; |
| 4977 expectedReplicaDrawTransform.matrix().setDouble(1, 1, -1); | 4977 expectedReplicaDrawTransform.matrix().setDouble(1, 1, -1); |
| 4978 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderS
urface()->replica_draw_transform()); | 4978 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->render_
surface()->replica_draw_transform()); |
| 4979 | 4979 |
| 4980 gfx::Transform expectedReplicaScreenSpaceTransform; | 4980 gfx::Transform expectedReplicaScreenSpaceTransform; |
| 4981 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 1, -1); | 4981 expectedReplicaScreenSpaceTransform.matrix().setDouble(1, 1, -1); |
| 4982 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
renderSurface()->replica_screen_space_transform()); | 4982 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaScreenSpaceTransform, child->
render_surface()->replica_screen_space_transform()); |
| 4983 } | 4983 } |
| 4984 | 4984 |
| 4985 TEST(LayerTreeHostCommonTest, verifySubtreeSearch) | 4985 TEST(LayerTreeHostCommonTest, verifySubtreeSearch) |
| 4986 { | 4986 { |
| 4987 scoped_refptr<Layer> root = Layer::create(); | 4987 scoped_refptr<Layer> root = Layer::Create(); |
| 4988 scoped_refptr<Layer> child = Layer::create(); | 4988 scoped_refptr<Layer> child = Layer::Create(); |
| 4989 scoped_refptr<Layer> grandChild = Layer::create(); | 4989 scoped_refptr<Layer> grandChild = Layer::Create(); |
| 4990 scoped_refptr<Layer> maskLayer = Layer::create(); | 4990 scoped_refptr<Layer> maskLayer = Layer::Create(); |
| 4991 scoped_refptr<Layer> replicaLayer = Layer::create(); | 4991 scoped_refptr<Layer> replicaLayer = Layer::Create(); |
| 4992 | 4992 |
| 4993 grandChild->setReplicaLayer(replicaLayer.get()); | 4993 grandChild->SetReplicaLayer(replicaLayer.get()); |
| 4994 child->addChild(grandChild.get()); | 4994 child->AddChild(grandChild.get()); |
| 4995 child->setMaskLayer(maskLayer.get()); | 4995 child->SetMaskLayer(maskLayer.get()); |
| 4996 root->addChild(child.get()); | 4996 root->AddChild(child.get()); |
| 4997 | 4997 |
| 4998 int nonexistentId = -1; | 4998 int nonexistentId = -1; |
| 4999 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); | 4999 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); |
| 5000 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); | 5000 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); |
| 5001 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); | 5001 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); |
| 5002 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); | 5002 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); |
| 5003 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); | 5003 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); |
| 5004 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); | 5004 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); |
| 5005 } | 5005 } |
| 5006 | 5006 |
| 5007 TEST(LayerTreeHostCommonTest, verifyTransparentChildRenderSurfaceCreation) | 5007 TEST(LayerTreeHostCommonTest, verifyTransparentChildRenderSurfaceCreation) |
| 5008 { | 5008 { |
| 5009 scoped_refptr<Layer> root = Layer::create(); | 5009 scoped_refptr<Layer> root = Layer::Create(); |
| 5010 scoped_refptr<Layer> child = Layer::create(); | 5010 scoped_refptr<Layer> child = Layer::Create(); |
| 5011 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); | 5011 scoped_refptr<LayerWithForcedDrawsContent> grandChild = make_scoped_refptr(n
ew LayerWithForcedDrawsContent()); |
| 5012 | 5012 |
| 5013 const gfx::Transform identityMatrix; | 5013 const gfx::Transform identityMatrix; |
| 5014 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); | 5014 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx
::PointF(), gfx::PointF(), gfx::Size(100, 100), false); |
| 5015 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 5015 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf
x::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 5016 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); | 5016 setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatri
x, gfx::PointF(), gfx::PointF(), gfx::Size(10, 10), false); |
| 5017 | 5017 |
| 5018 root->addChild(child); | 5018 root->AddChild(child); |
| 5019 child->addChild(grandChild); | 5019 child->AddChild(grandChild); |
| 5020 child->setOpacity(0.5f); | 5020 child->SetOpacity(0.5f); |
| 5021 | 5021 |
| 5022 executeCalculateDrawProperties(root.get()); | 5022 executeCalculateDrawProperties(root.get()); |
| 5023 | 5023 |
| 5024 EXPECT_FALSE(child->renderSurface()); | 5024 EXPECT_FALSE(child->render_surface()); |
| 5025 } | 5025 } |
| 5026 | 5026 |
| 5027 typedef std::tr1::tuple<bool, bool> LCDTextTestParam; | 5027 typedef std::tr1::tuple<bool, bool> LCDTextTestParam; |
| 5028 class LCDTextTest : public testing::TestWithParam<LCDTextTestParam> { | 5028 class LCDTextTest : public testing::TestWithParam<LCDTextTestParam> { |
| 5029 protected: | 5029 protected: |
| 5030 virtual void SetUp() | 5030 virtual void SetUp() |
| 5031 { | 5031 { |
| 5032 m_canUseLCDText = std::tr1::get<0>(GetParam()); | 5032 m_canUseLCDText = std::tr1::get<0>(GetParam()); |
| 5033 | 5033 |
| 5034 m_root = Layer::create(); | 5034 m_root = Layer::Create(); |
| 5035 m_child = Layer::create(); | 5035 m_child = Layer::Create(); |
| 5036 m_grandChild = Layer::create(); | 5036 m_grandChild = Layer::Create(); |
| 5037 m_child->addChild(m_grandChild.get()); | 5037 m_child->AddChild(m_grandChild.get()); |
| 5038 m_root->addChild(m_child.get()); | 5038 m_root->AddChild(m_child.get()); |
| 5039 | 5039 |
| 5040 gfx::Transform identityMatrix; | 5040 gfx::Transform identityMatrix; |
| 5041 setLayerPropertiesForTesting(m_root, identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); | 5041 setLayerPropertiesForTesting(m_root, identityMatrix, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); |
| 5042 setLayerPropertiesForTesting(m_child, identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); | 5042 setLayerPropertiesForTesting(m_child, identityMatrix, identityMatrix, gf
x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); |
| 5043 setLayerPropertiesForTesting(m_grandChild, identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); | 5043 setLayerPropertiesForTesting(m_grandChild, identityMatrix, identityMatri
x, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); |
| 5044 | 5044 |
| 5045 m_child->setForceRenderSurface(std::tr1::get<1>(GetParam())); | 5045 m_child->SetForceRenderSurface(std::tr1::get<1>(GetParam())); |
| 5046 } | 5046 } |
| 5047 | 5047 |
| 5048 bool m_canUseLCDText; | 5048 bool m_canUseLCDText; |
| 5049 scoped_refptr<Layer> m_root; | 5049 scoped_refptr<Layer> m_root; |
| 5050 scoped_refptr<Layer> m_child; | 5050 scoped_refptr<Layer> m_child; |
| 5051 scoped_refptr<Layer> m_grandChild; | 5051 scoped_refptr<Layer> m_grandChild; |
| 5052 }; | 5052 }; |
| 5053 | 5053 |
| 5054 TEST_P(LCDTextTest, verifyCanUseLCDText) | 5054 TEST_P(LCDTextTest, verifyCanUseLCDText) |
| 5055 { | 5055 { |
| 5056 // Case 1: Identity transform. | 5056 // Case 1: Identity transform. |
| 5057 gfx::Transform identityMatrix; | 5057 gfx::Transform identityMatrix; |
| 5058 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5058 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
| 5059 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText()); | 5059 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
| 5060 EXPECT_EQ(m_canUseLCDText, m_child->canUseLCDText()); | 5060 EXPECT_EQ(m_canUseLCDText, m_child->can_use_lcd_text()); |
| 5061 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); | 5061 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); |
| 5062 | 5062 |
| 5063 // Case 2: Integral translation. | 5063 // Case 2: Integral translation. |
| 5064 gfx::Transform integralTranslation; | 5064 gfx::Transform integralTranslation; |
| 5065 integralTranslation.Translate(1, 2); | 5065 integralTranslation.Translate(1, 2); |
| 5066 m_child->setTransform(integralTranslation); | 5066 m_child->SetTransform(integralTranslation); |
| 5067 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5067 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
| 5068 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText()); | 5068 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
| 5069 EXPECT_EQ(m_canUseLCDText, m_child->canUseLCDText()); | 5069 EXPECT_EQ(m_canUseLCDText, m_child->can_use_lcd_text()); |
| 5070 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); | 5070 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); |
| 5071 | 5071 |
| 5072 // Case 3: Non-integral translation. | 5072 // Case 3: Non-integral translation. |
| 5073 gfx::Transform nonIntegralTranslation; | 5073 gfx::Transform nonIntegralTranslation; |
| 5074 nonIntegralTranslation.Translate(1.5, 2.5); | 5074 nonIntegralTranslation.Translate(1.5, 2.5); |
| 5075 m_child->setTransform(nonIntegralTranslation); | 5075 m_child->SetTransform(nonIntegralTranslation); |
| 5076 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5076 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
| 5077 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText()); | 5077 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
| 5078 EXPECT_FALSE(m_child->canUseLCDText()); | 5078 EXPECT_FALSE(m_child->can_use_lcd_text()); |
| 5079 EXPECT_FALSE(m_grandChild->canUseLCDText()); | 5079 EXPECT_FALSE(m_grandChild->can_use_lcd_text()); |
| 5080 | 5080 |
| 5081 // Case 4: Rotation. | 5081 // Case 4: Rotation. |
| 5082 gfx::Transform rotation; | 5082 gfx::Transform rotation; |
| 5083 rotation.Rotate(10); | 5083 rotation.Rotate(10); |
| 5084 m_child->setTransform(rotation); | 5084 m_child->SetTransform(rotation); |
| 5085 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5085 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
| 5086 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText()); | 5086 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
| 5087 EXPECT_FALSE(m_child->canUseLCDText()); | 5087 EXPECT_FALSE(m_child->can_use_lcd_text()); |
| 5088 EXPECT_FALSE(m_grandChild->canUseLCDText()); | 5088 EXPECT_FALSE(m_grandChild->can_use_lcd_text()); |
| 5089 | 5089 |
| 5090 // Case 5: Scale. | 5090 // Case 5: Scale. |
| 5091 gfx::Transform scale; | 5091 gfx::Transform scale; |
| 5092 scale.Scale(2, 2); | 5092 scale.Scale(2, 2); |
| 5093 m_child->setTransform(scale); | 5093 m_child->SetTransform(scale); |
| 5094 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5094 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
| 5095 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText()); | 5095 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
| 5096 EXPECT_FALSE(m_child->canUseLCDText()); | 5096 EXPECT_FALSE(m_child->can_use_lcd_text()); |
| 5097 EXPECT_FALSE(m_grandChild->canUseLCDText()); | 5097 EXPECT_FALSE(m_grandChild->can_use_lcd_text()); |
| 5098 | 5098 |
| 5099 // Case 6: Skew. | 5099 // Case 6: Skew. |
| 5100 gfx::Transform skew; | 5100 gfx::Transform skew; |
| 5101 skew.SkewX(10); | 5101 skew.SkewX(10); |
| 5102 m_child->setTransform(skew); | 5102 m_child->SetTransform(skew); |
| 5103 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5103 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
| 5104 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText()); | 5104 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
| 5105 EXPECT_FALSE(m_child->canUseLCDText()); | 5105 EXPECT_FALSE(m_child->can_use_lcd_text()); |
| 5106 EXPECT_FALSE(m_grandChild->canUseLCDText()); | 5106 EXPECT_FALSE(m_grandChild->can_use_lcd_text()); |
| 5107 | 5107 |
| 5108 // Case 7: Translucent. | 5108 // Case 7: Translucent. |
| 5109 m_child->setTransform(identityMatrix); | 5109 m_child->SetTransform(identityMatrix); |
| 5110 m_child->setOpacity(0.5); | 5110 m_child->SetOpacity(0.5); |
| 5111 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5111 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
| 5112 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText()); | 5112 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
| 5113 EXPECT_FALSE(m_child->canUseLCDText()); | 5113 EXPECT_FALSE(m_child->can_use_lcd_text()); |
| 5114 EXPECT_FALSE(m_grandChild->canUseLCDText()); | 5114 EXPECT_FALSE(m_grandChild->can_use_lcd_text()); |
| 5115 | 5115 |
| 5116 // Case 8: Sanity check: restore transform and opacity. | 5116 // Case 8: Sanity check: restore transform and opacity. |
| 5117 m_child->setTransform(identityMatrix); | 5117 m_child->SetTransform(identityMatrix); |
| 5118 m_child->setOpacity(1); | 5118 m_child->SetOpacity(1); |
| 5119 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5119 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
| 5120 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText()); | 5120 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
| 5121 EXPECT_EQ(m_canUseLCDText, m_child->canUseLCDText()); | 5121 EXPECT_EQ(m_canUseLCDText, m_child->can_use_lcd_text()); |
| 5122 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); | 5122 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); |
| 5123 } | 5123 } |
| 5124 | 5124 |
| 5125 TEST_P(LCDTextTest, verifyCanUseLCDTextWithAnimation) | 5125 TEST_P(LCDTextTest, verifycan_use_lcd_textWithAnimation) |
| 5126 { | 5126 { |
| 5127 // Sanity check: Make sure m_canUseLCDText is set on each node. | 5127 // Sanity check: Make sure m_canUseLCDText is set on each node. |
| 5128 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5128 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
| 5129 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText()); | 5129 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
| 5130 EXPECT_EQ(m_canUseLCDText, m_child->canUseLCDText()); | 5130 EXPECT_EQ(m_canUseLCDText, m_child->can_use_lcd_text()); |
| 5131 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); | 5131 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); |
| 5132 | 5132 |
| 5133 // Add opacity animation. | 5133 // Add opacity animation. |
| 5134 m_child->setOpacity(0.9f); | 5134 m_child->SetOpacity(0.9f); |
| 5135 addOpacityTransitionToController(*(m_child->layerAnimationController()), 10,
0.9f, 0.1f, false); | 5135 addOpacityTransitionToController(*(m_child->layer_animation_controller()), 1
0, 0.9f, 0.1f, false); |
| 5136 | 5136 |
| 5137 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); | 5137 executeCalculateDrawProperties(m_root, 1, 1, m_canUseLCDText); |
| 5138 // Text AA should not be adjusted while animation is active. | 5138 // Text AA should not be adjusted while animation is active. |
| 5139 // Make sure LCD text AA setting remains unchanged. | 5139 // Make sure LCD text AA setting remains unchanged. |
| 5140 EXPECT_EQ(m_canUseLCDText, m_root->canUseLCDText()); | 5140 EXPECT_EQ(m_canUseLCDText, m_root->can_use_lcd_text()); |
| 5141 EXPECT_EQ(m_canUseLCDText, m_child->canUseLCDText()); | 5141 EXPECT_EQ(m_canUseLCDText, m_child->can_use_lcd_text()); |
| 5142 EXPECT_EQ(m_canUseLCDText, m_grandChild->canUseLCDText()); | 5142 EXPECT_EQ(m_canUseLCDText, m_grandChild->can_use_lcd_text()); |
| 5143 } | 5143 } |
| 5144 | 5144 |
| 5145 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, | 5145 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, |
| 5146 LCDTextTest, | 5146 LCDTextTest, |
| 5147 testing::Combine(testing::Bool(), | 5147 testing::Combine(testing::Bool(), |
| 5148 testing::Bool())); | 5148 testing::Bool())); |
| 5149 | 5149 |
| 5150 } // namespace | 5150 } // namespace |
| 5151 } // namespace cc | 5151 } // namespace cc |
| OLD | NEW |