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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2866733002: Remove owning_id from EffectNode and replace it by an opaque stable_id (Closed)
Patch Set: none Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 3118 matching lines...) Expand 10 before | Expand all | Expand 10 after
3129 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 3129 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
3130 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 3130 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
3131 host_impl_->ActivateSyncTree(); 3131 host_impl_->ActivateSyncTree();
3132 3132
3133 LayerImpl* active_scrollbar_layer = 3133 LayerImpl* active_scrollbar_layer =
3134 host_impl_->active_tree()->LayerById(400); 3134 host_impl_->active_tree()->LayerById(400);
3135 3135
3136 EffectNode* active_tree_node = 3136 EffectNode* active_tree_node =
3137 host_impl_->active_tree()->property_trees()->effect_tree.Node( 3137 host_impl_->active_tree()->property_trees()->effect_tree.Node(
3138 active_scrollbar_layer->effect_tree_index()); 3138 active_scrollbar_layer->effect_tree_index());
3139 EXPECT_FLOAT_EQ(active_scrollbar_layer->Opacity(), 3139 EXPECT_FLOAT_EQ(OpacityForLayer(active_scrollbar_layer),
3140 active_tree_node->opacity); 3140 active_tree_node->opacity);
3141 3141
3142 if (expecting_animations) { 3142 if (expecting_animations) {
3143 host_impl_->ScrollbarAnimationControllerForElementId(scroll->element_id()) 3143 host_impl_->ScrollbarAnimationControllerForElementId(scroll->element_id())
3144 ->DidMouseMove(gfx::PointF(0, 90)); 3144 ->DidMouseMove(gfx::PointF(0, 90));
3145 } else { 3145 } else {
3146 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId( 3146 EXPECT_EQ(nullptr, host_impl_->ScrollbarAnimationControllerForElementId(
3147 scroll->element_id())); 3147 scroll->element_id()));
3148 } 3148 }
3149 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 3149 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
3150 InputHandler::WHEEL); 3150 InputHandler::WHEEL);
3151 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get()); 3151 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 5)).get());
3152 host_impl_->ScrollEnd(EndState().get()); 3152 host_impl_->ScrollEnd(EndState().get());
3153 host_impl_->CreatePendingTree(); 3153 host_impl_->CreatePendingTree();
3154 // To test the case where the effect tree index of scrollbar layer changes, 3154 // To test the case where the effect tree index of scrollbar layer changes,
3155 // we force the container layer to create a render surface. 3155 // we force the container layer to create a render surface.
3156 container = host_impl_->pending_tree()->InnerViewportContainerLayer(); 3156 container = host_impl_->pending_tree()->InnerViewportContainerLayer();
3157 container->test_properties()->force_render_surface = true; 3157 container->test_properties()->force_render_surface = true;
3158 container->SetBounds(gfx::Size(10, 10)); 3158 container->SetBounds(gfx::Size(10, 10));
3159 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); 3159 host_impl_->pending_tree()->BuildPropertyTreesForTesting();
3160 3160
3161 LayerImpl* pending_scrollbar_layer = 3161 LayerImpl* pending_scrollbar_layer =
3162 host_impl_->pending_tree()->LayerById(400); 3162 host_impl_->pending_tree()->LayerById(400);
3163 pending_scrollbar_layer->SetNeedsPushProperties(); 3163 pending_scrollbar_layer->SetNeedsPushProperties();
3164 EffectNode* pending_tree_node = 3164 EffectNode* pending_tree_node =
3165 host_impl_->pending_tree()->property_trees()->effect_tree.Node( 3165 host_impl_->pending_tree()->property_trees()->effect_tree.Node(
3166 pending_scrollbar_layer->effect_tree_index()); 3166 pending_scrollbar_layer->effect_tree_index());
3167 host_impl_->pending_tree() 3167 host_impl_->pending_tree()
3168 ->property_trees() 3168 ->property_trees()
3169 ->always_use_active_tree_opacity_effect_ids.push_back(400); 3169 ->always_use_active_tree_opacity_effect_ids.push_back(
3170 ElementId(500, 0));
3170 if (expecting_animations) { 3171 if (expecting_animations) {
3171 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity); 3172 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity);
3172 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity()); 3173 EXPECT_FLOAT_EQ(1.f, OpacityForLayer(active_scrollbar_layer));
3173 } else { 3174 } else {
3174 EXPECT_FLOAT_EQ(0.f, active_tree_node->opacity); 3175 EXPECT_FLOAT_EQ(0.f, active_tree_node->opacity);
3175 EXPECT_FLOAT_EQ(0.f, active_scrollbar_layer->Opacity()); 3176 EXPECT_FLOAT_EQ(0.f, OpacityForLayer(active_scrollbar_layer));
3176 } 3177 }
3177 EXPECT_FLOAT_EQ(0.f, pending_tree_node->opacity); 3178 EXPECT_FLOAT_EQ(0.f, pending_tree_node->opacity);
3178 host_impl_->ActivateSyncTree(); 3179 host_impl_->ActivateSyncTree();
3179 active_tree_node = 3180 active_tree_node =
3180 host_impl_->active_tree()->property_trees()->effect_tree.Node( 3181 host_impl_->active_tree()->property_trees()->effect_tree.Node(
3181 active_scrollbar_layer->effect_tree_index()); 3182 active_scrollbar_layer->effect_tree_index());
3182 if (expecting_animations) { 3183 if (expecting_animations) {
3183 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity); 3184 EXPECT_FLOAT_EQ(1.f, active_tree_node->opacity);
3184 EXPECT_FLOAT_EQ(1.f, active_scrollbar_layer->Opacity()); 3185 EXPECT_FLOAT_EQ(1.f, OpacityForLayer(active_scrollbar_layer));
3185 } else { 3186 } else {
3186 EXPECT_FLOAT_EQ(0.f, active_tree_node->opacity); 3187 EXPECT_FLOAT_EQ(0.f, active_tree_node->opacity);
3187 EXPECT_FLOAT_EQ(0.f, active_scrollbar_layer->Opacity()); 3188 EXPECT_FLOAT_EQ(0.f, OpacityForLayer(active_scrollbar_layer));
3188 } 3189 }
3189 } 3190 }
3190 }; 3191 };
3191 3192
3192 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Android) { 3193 TEST_F(LayerTreeHostImplTestScrollbarOpacity, Android) {
3193 RunTest(LayerTreeSettings::ANDROID_OVERLAY); 3194 RunTest(LayerTreeSettings::ANDROID_OVERLAY);
3194 } 3195 }
3195 3196
3196 TEST_F(LayerTreeHostImplTestScrollbarOpacity, AuraOverlay) { 3197 TEST_F(LayerTreeHostImplTestScrollbarOpacity, AuraOverlay) {
3197 RunTest(LayerTreeSettings::AURA_OVERLAY); 3198 RunTest(LayerTreeSettings::AURA_OVERLAY);
(...skipping 4044 matching lines...) Expand 10 before | Expand all | Expand 10 after
7242 PopulateSharedQuadState(shared_quad_state); 7243 PopulateSharedQuadState(shared_quad_state);
7243 7244
7244 TileDrawQuad* test_blending_draw_quad = 7245 TileDrawQuad* test_blending_draw_quad =
7245 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); 7246 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>();
7246 test_blending_draw_quad->SetNew(shared_quad_state, quad_rect_, opaque_rect, 7247 test_blending_draw_quad->SetNew(shared_quad_state, quad_rect_, opaque_rect,
7247 visible_quad_rect, resource_id_, 7248 visible_quad_rect, resource_id_,
7248 gfx::RectF(0.f, 0.f, 1.f, 1.f), 7249 gfx::RectF(0.f, 0.f, 1.f, 1.f),
7249 gfx::Size(1, 1), false, false); 7250 gfx::Size(1, 1), false, false);
7250 test_blending_draw_quad->visible_rect = quad_visible_rect_; 7251 test_blending_draw_quad->visible_rect = quad_visible_rect_;
7251 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending()); 7252 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending());
7252 EXPECT_EQ(has_render_surface_, !!GetRenderSurface(this)); 7253 EXPECT_EQ(has_render_surface_,
7254 GetRenderSurface(this) != GetRenderSurface(comparison_layer_));
7253 } 7255 }
7254 7256
7255 void SetExpectation(bool blend, bool has_render_surface) { 7257 void SetExpectation(bool blend,
7258 bool has_render_surface,
7259 LayerImpl* comparison_layer) {
7256 blend_ = blend; 7260 blend_ = blend;
7257 has_render_surface_ = has_render_surface; 7261 has_render_surface_ = has_render_surface;
7262 comparison_layer_ = comparison_layer;
7258 quads_appended_ = false; 7263 quads_appended_ = false;
7259 } 7264 }
7260 7265
7261 bool quads_appended() const { return quads_appended_; } 7266 bool quads_appended() const { return quads_appended_; }
7262 7267
7263 void SetQuadRect(const gfx::Rect& rect) { quad_rect_ = rect; } 7268 void SetQuadRect(const gfx::Rect& rect) { quad_rect_ = rect; }
7264 void SetQuadVisibleRect(const gfx::Rect& rect) { quad_visible_rect_ = rect; } 7269 void SetQuadVisibleRect(const gfx::Rect& rect) { quad_visible_rect_ = rect; }
7265 void SetOpaqueContentRect(const gfx::Rect& rect) { 7270 void SetOpaqueContentRect(const gfx::Rect& rect) {
7266 opaque_content_rect_ = rect; 7271 opaque_content_rect_ = rect;
7267 } 7272 }
7268 7273
7269 private: 7274 private:
7270 BlendStateCheckLayer(LayerTreeImpl* tree_impl, 7275 BlendStateCheckLayer(LayerTreeImpl* tree_impl,
7271 int id, 7276 int id,
7272 ResourceProvider* resource_provider) 7277 ResourceProvider* resource_provider)
7273 : LayerImpl(tree_impl, id), 7278 : LayerImpl(tree_impl, id),
7274 blend_(false), 7279 blend_(false),
7275 has_render_surface_(false), 7280 has_render_surface_(false),
7281 comparison_layer_(nullptr),
7276 quads_appended_(false), 7282 quads_appended_(false),
7277 quad_rect_(5, 5, 5, 5), 7283 quad_rect_(5, 5, 5, 5),
7278 quad_visible_rect_(5, 5, 5, 5), 7284 quad_visible_rect_(5, 5, 5, 5),
7279 resource_id_(resource_provider->CreateResource( 7285 resource_id_(resource_provider->CreateResource(
7280 gfx::Size(1, 1), 7286 gfx::Size(1, 1),
7281 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 7287 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
7282 RGBA_8888, 7288 RGBA_8888,
7283 gfx::ColorSpace())) { 7289 gfx::ColorSpace())) {
7284 resource_provider->AllocateForTesting(resource_id_); 7290 resource_provider->AllocateForTesting(resource_id_);
7285 SetBounds(gfx::Size(10, 10)); 7291 SetBounds(gfx::Size(10, 10));
7286 SetDrawsContent(true); 7292 SetDrawsContent(true);
7287 } 7293 }
7288 7294
7289 bool blend_; 7295 bool blend_;
7290 bool has_render_surface_; 7296 bool has_render_surface_;
7297 LayerImpl* comparison_layer_;
7291 bool quads_appended_; 7298 bool quads_appended_;
7292 gfx::Rect quad_rect_; 7299 gfx::Rect quad_rect_;
7293 gfx::Rect opaque_content_rect_; 7300 gfx::Rect opaque_content_rect_;
7294 gfx::Rect quad_visible_rect_; 7301 gfx::Rect quad_visible_rect_;
7295 ResourceId resource_id_; 7302 ResourceId resource_id_;
7296 }; 7303 };
7297 7304
7298 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { 7305 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
7299 { 7306 {
7300 std::unique_ptr<LayerImpl> root = 7307 std::unique_ptr<LayerImpl> root =
7301 LayerImpl::Create(host_impl_->active_tree(), 1); 7308 LayerImpl::Create(host_impl_->active_tree(), 1);
7302 root->SetBounds(gfx::Size(10, 10)); 7309 root->SetBounds(gfx::Size(10, 10));
7303 root->SetDrawsContent(false); 7310 root->SetDrawsContent(false);
7304 root->test_properties()->force_render_surface = true; 7311 root->test_properties()->force_render_surface = true;
7305 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); 7312 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root));
7306 } 7313 }
7307 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); 7314 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
7308 7315
7309 root->test_properties()->AddChild(BlendStateCheckLayer::Create( 7316 root->test_properties()->AddChild(BlendStateCheckLayer::Create(
7310 host_impl_->active_tree(), 2, host_impl_->resource_provider())); 7317 host_impl_->active_tree(), 2, host_impl_->resource_provider()));
7311 BlendStateCheckLayer* layer1 = 7318 BlendStateCheckLayer* layer1 =
7312 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]); 7319 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]);
7313 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 7320 layer1->SetPosition(gfx::PointF(2.f, 2.f));
7314 7321
7315 TestFrameData frame; 7322 TestFrameData frame;
7316 7323
7317 // Opaque layer, drawn without blending. 7324 // Opaque layer, drawn without blending.
7318 layer1->SetContentsOpaque(true); 7325 layer1->SetContentsOpaque(true);
7319 layer1->SetExpectation(false, false); 7326 layer1->SetExpectation(false, false, root);
7320 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7327 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7321 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7328 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7322 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7329 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7323 host_impl_->DrawLayers(&frame); 7330 host_impl_->DrawLayers(&frame);
7324 EXPECT_TRUE(layer1->quads_appended()); 7331 EXPECT_TRUE(layer1->quads_appended());
7325 host_impl_->DidDrawAllLayers(frame); 7332 host_impl_->DidDrawAllLayers(frame);
7326 7333
7327 // Layer with translucent content and painting, so drawn with blending. 7334 // Layer with translucent content and painting, so drawn with blending.
7328 layer1->SetContentsOpaque(false); 7335 layer1->SetContentsOpaque(false);
7329 layer1->SetExpectation(true, false); 7336 layer1->SetExpectation(true, false, root);
7330 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7337 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7331 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7338 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7332 host_impl_->active_tree()->set_needs_update_draw_properties(); 7339 host_impl_->active_tree()->set_needs_update_draw_properties();
7333 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7340 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7334 host_impl_->DrawLayers(&frame); 7341 host_impl_->DrawLayers(&frame);
7335 EXPECT_TRUE(layer1->quads_appended()); 7342 EXPECT_TRUE(layer1->quads_appended());
7336 host_impl_->DidDrawAllLayers(frame); 7343 host_impl_->DidDrawAllLayers(frame);
7337 7344
7338 // Layer with translucent opacity, drawn with blending. 7345 // Layer with translucent opacity, drawn with blending.
7339 layer1->SetContentsOpaque(true); 7346 layer1->SetContentsOpaque(true);
7340 layer1->test_properties()->opacity = 0.5f; 7347 layer1->test_properties()->opacity = 0.5f;
7341 layer1->NoteLayerPropertyChanged(); 7348 layer1->NoteLayerPropertyChanged();
7342 layer1->SetExpectation(true, false); 7349 layer1->SetExpectation(true, false, root);
7343 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7350 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7344 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7351 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7345 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7352 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7346 host_impl_->DrawLayers(&frame); 7353 host_impl_->DrawLayers(&frame);
7347 EXPECT_TRUE(layer1->quads_appended()); 7354 EXPECT_TRUE(layer1->quads_appended());
7348 host_impl_->DidDrawAllLayers(frame); 7355 host_impl_->DidDrawAllLayers(frame);
7349 7356
7350 // Layer with translucent opacity and painting, drawn with blending. 7357 // Layer with translucent opacity and painting, drawn with blending.
7351 layer1->SetContentsOpaque(true); 7358 layer1->SetContentsOpaque(true);
7352 layer1->test_properties()->opacity = 0.5f; 7359 layer1->test_properties()->opacity = 0.5f;
7353 layer1->NoteLayerPropertyChanged(); 7360 layer1->NoteLayerPropertyChanged();
7354 layer1->SetExpectation(true, false); 7361 layer1->SetExpectation(true, false, root);
7355 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7362 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7356 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7363 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7357 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7364 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7358 host_impl_->DrawLayers(&frame); 7365 host_impl_->DrawLayers(&frame);
7359 EXPECT_TRUE(layer1->quads_appended()); 7366 EXPECT_TRUE(layer1->quads_appended());
7360 host_impl_->DidDrawAllLayers(frame); 7367 host_impl_->DidDrawAllLayers(frame);
7361 7368
7362 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create( 7369 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create(
7363 host_impl_->active_tree(), 3, host_impl_->resource_provider())); 7370 host_impl_->active_tree(), 3, host_impl_->resource_provider()));
7364 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>( 7371 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(
7365 layer1->test_properties()->children[0]); 7372 layer1->test_properties()->children[0]);
7366 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 7373 layer2->SetPosition(gfx::PointF(4.f, 4.f));
7367 7374
7368 // 2 opaque layers, drawn without blending. 7375 // 2 opaque layers, drawn without blending.
7369 layer1->SetContentsOpaque(true); 7376 layer1->SetContentsOpaque(true);
7370 layer1->test_properties()->opacity = 1.f; 7377 layer1->test_properties()->opacity = 1.f;
7371 layer1->NoteLayerPropertyChanged(); 7378 layer1->NoteLayerPropertyChanged();
7372 layer1->SetExpectation(false, false); 7379 layer1->SetExpectation(false, false, root);
7373 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7380 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7374 layer2->SetContentsOpaque(true); 7381 layer2->SetContentsOpaque(true);
7375 layer2->test_properties()->opacity = 1.f; 7382 layer2->test_properties()->opacity = 1.f;
7376 layer2->NoteLayerPropertyChanged(); 7383 layer2->NoteLayerPropertyChanged();
7377 layer2->SetExpectation(false, false); 7384 layer2->SetExpectation(false, false, root);
7378 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7385 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7379 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7386 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7380 host_impl_->active_tree()->set_needs_update_draw_properties(); 7387 host_impl_->active_tree()->set_needs_update_draw_properties();
7381 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7388 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7382 host_impl_->DrawLayers(&frame); 7389 host_impl_->DrawLayers(&frame);
7383 EXPECT_TRUE(layer1->quads_appended()); 7390 EXPECT_TRUE(layer1->quads_appended());
7384 EXPECT_TRUE(layer2->quads_appended()); 7391 EXPECT_TRUE(layer2->quads_appended());
7385 host_impl_->DidDrawAllLayers(frame); 7392 host_impl_->DidDrawAllLayers(frame);
7386 7393
7387 // Parent layer with translucent content, drawn with blending. 7394 // Parent layer with translucent content, drawn with blending.
7388 // Child layer with opaque content, drawn without blending. 7395 // Child layer with opaque content, drawn without blending.
7389 layer1->SetContentsOpaque(false); 7396 layer1->SetContentsOpaque(false);
7390 layer1->SetExpectation(true, false); 7397 layer1->SetExpectation(true, false, root);
7391 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7398 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7392 layer2->SetExpectation(false, false); 7399 layer2->SetExpectation(false, false, root);
7393 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7400 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7394 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7401 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7395 host_impl_->active_tree()->set_needs_update_draw_properties(); 7402 host_impl_->active_tree()->set_needs_update_draw_properties();
7396 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7403 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7397 host_impl_->DrawLayers(&frame); 7404 host_impl_->DrawLayers(&frame);
7398 EXPECT_TRUE(layer1->quads_appended()); 7405 EXPECT_TRUE(layer1->quads_appended());
7399 EXPECT_TRUE(layer2->quads_appended()); 7406 EXPECT_TRUE(layer2->quads_appended());
7400 host_impl_->DidDrawAllLayers(frame); 7407 host_impl_->DidDrawAllLayers(frame);
7401 7408
7402 // Parent layer with translucent content but opaque painting, drawn without 7409 // Parent layer with translucent content but opaque painting, drawn without
7403 // blending. 7410 // blending.
7404 // Child layer with opaque content, drawn without blending. 7411 // Child layer with opaque content, drawn without blending.
7405 layer1->SetContentsOpaque(true); 7412 layer1->SetContentsOpaque(true);
7406 layer1->SetExpectation(false, false); 7413 layer1->SetExpectation(false, false, root);
7407 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7414 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7408 layer2->SetExpectation(false, false); 7415 layer2->SetExpectation(false, false, root);
7409 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7416 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7410 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7417 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7411 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7418 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7412 host_impl_->DrawLayers(&frame); 7419 host_impl_->DrawLayers(&frame);
7413 EXPECT_TRUE(layer1->quads_appended()); 7420 EXPECT_TRUE(layer1->quads_appended());
7414 EXPECT_TRUE(layer2->quads_appended()); 7421 EXPECT_TRUE(layer2->quads_appended());
7415 host_impl_->DidDrawAllLayers(frame); 7422 host_impl_->DidDrawAllLayers(frame);
7416 7423
7417 // Parent layer with translucent opacity and opaque content. Since it has a 7424 // Parent layer with translucent opacity and opaque content. Since it has a
7418 // drawing child, it's drawn to a render surface which carries the opacity, 7425 // drawing child, it's drawn to a render surface which carries the opacity,
7419 // so it's itself drawn without blending. 7426 // so it's itself drawn without blending.
7420 // Child layer with opaque content, drawn without blending (parent surface 7427 // Child layer with opaque content, drawn without blending (parent surface
7421 // carries the inherited opacity). 7428 // carries the inherited opacity).
7422 layer1->SetContentsOpaque(true); 7429 layer1->SetContentsOpaque(true);
7423 layer1->test_properties()->opacity = 0.5f; 7430 layer1->test_properties()->opacity = 0.5f;
7424 layer1->NoteLayerPropertyChanged(); 7431 layer1->NoteLayerPropertyChanged();
7425 layer1->test_properties()->force_render_surface = true; 7432 layer1->test_properties()->force_render_surface = true;
7426 layer1->SetExpectation(false, true); 7433 layer1->SetExpectation(false, true, root);
7427 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7434 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7428 layer2->SetExpectation(false, false); 7435 layer2->SetExpectation(false, false, layer1);
7429 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7436 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7430 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7437 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7431 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7438 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7432 host_impl_->DrawLayers(&frame); 7439 host_impl_->DrawLayers(&frame);
7433 EXPECT_TRUE(layer1->quads_appended()); 7440 EXPECT_TRUE(layer1->quads_appended());
7434 EXPECT_TRUE(layer2->quads_appended()); 7441 EXPECT_TRUE(layer2->quads_appended());
7435 host_impl_->DidDrawAllLayers(frame); 7442 host_impl_->DidDrawAllLayers(frame);
7436 layer1->test_properties()->force_render_surface = false; 7443 layer1->test_properties()->force_render_surface = false;
7437 7444
7438 // Draw again, but with child non-opaque, to make sure 7445 // Draw again, but with child non-opaque, to make sure
7439 // layer1 not culled. 7446 // layer1 not culled.
7440 layer1->SetContentsOpaque(true); 7447 layer1->SetContentsOpaque(true);
7441 layer1->test_properties()->opacity = 1.f; 7448 layer1->test_properties()->opacity = 1.f;
7442 layer1->NoteLayerPropertyChanged(); 7449 layer1->NoteLayerPropertyChanged();
7443 layer1->SetExpectation(false, false); 7450 layer1->SetExpectation(false, false, root);
7444 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7451 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7445 layer2->SetContentsOpaque(true); 7452 layer2->SetContentsOpaque(true);
7446 layer2->test_properties()->opacity = 0.5f; 7453 layer2->test_properties()->opacity = 0.5f;
7447 layer2->NoteLayerPropertyChanged(); 7454 layer2->NoteLayerPropertyChanged();
7448 layer2->SetExpectation(true, false); 7455 layer2->SetExpectation(true, false, layer1);
7449 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7456 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7450 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7457 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7451 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7458 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7452 host_impl_->DrawLayers(&frame); 7459 host_impl_->DrawLayers(&frame);
7453 EXPECT_TRUE(layer1->quads_appended()); 7460 EXPECT_TRUE(layer1->quads_appended());
7454 EXPECT_TRUE(layer2->quads_appended()); 7461 EXPECT_TRUE(layer2->quads_appended());
7455 host_impl_->DidDrawAllLayers(frame); 7462 host_impl_->DidDrawAllLayers(frame);
7456 7463
7457 // A second way of making the child non-opaque. 7464 // A second way of making the child non-opaque.
7458 layer1->SetContentsOpaque(true); 7465 layer1->SetContentsOpaque(true);
7459 layer1->test_properties()->opacity = 1.f; 7466 layer1->test_properties()->opacity = 1.f;
7460 layer1->NoteLayerPropertyChanged(); 7467 layer1->NoteLayerPropertyChanged();
7461 layer1->SetExpectation(false, false); 7468 layer1->SetExpectation(false, false, root);
7462 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7469 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7463 layer2->SetContentsOpaque(false); 7470 layer2->SetContentsOpaque(false);
7464 layer2->test_properties()->opacity = 1.f; 7471 layer2->test_properties()->opacity = 1.f;
7465 layer2->NoteLayerPropertyChanged(); 7472 layer2->NoteLayerPropertyChanged();
7466 layer2->SetExpectation(true, false); 7473 layer2->SetExpectation(true, false, root);
7467 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7474 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7468 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7475 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7469 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7476 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7470 host_impl_->DrawLayers(&frame); 7477 host_impl_->DrawLayers(&frame);
7471 EXPECT_TRUE(layer1->quads_appended()); 7478 EXPECT_TRUE(layer1->quads_appended());
7472 EXPECT_TRUE(layer2->quads_appended()); 7479 EXPECT_TRUE(layer2->quads_appended());
7473 host_impl_->DidDrawAllLayers(frame); 7480 host_impl_->DidDrawAllLayers(frame);
7474 7481
7475 // And when the layer says its not opaque but is painted opaque, it is not 7482 // And when the layer says its not opaque but is painted opaque, it is not
7476 // blended. 7483 // blended.
7477 layer1->SetContentsOpaque(true); 7484 layer1->SetContentsOpaque(true);
7478 layer1->test_properties()->opacity = 1.f; 7485 layer1->test_properties()->opacity = 1.f;
7479 layer1->NoteLayerPropertyChanged(); 7486 layer1->NoteLayerPropertyChanged();
7480 layer1->SetExpectation(false, false); 7487 layer1->SetExpectation(false, false, root);
7481 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7488 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7482 layer2->SetContentsOpaque(true); 7489 layer2->SetContentsOpaque(true);
7483 layer2->test_properties()->opacity = 1.f; 7490 layer2->test_properties()->opacity = 1.f;
7484 layer2->NoteLayerPropertyChanged(); 7491 layer2->NoteLayerPropertyChanged();
7485 layer2->SetExpectation(false, false); 7492 layer2->SetExpectation(false, false, root);
7486 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7493 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7487 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7494 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7488 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7495 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7489 host_impl_->DrawLayers(&frame); 7496 host_impl_->DrawLayers(&frame);
7490 EXPECT_TRUE(layer1->quads_appended()); 7497 EXPECT_TRUE(layer1->quads_appended());
7491 EXPECT_TRUE(layer2->quads_appended()); 7498 EXPECT_TRUE(layer2->quads_appended());
7492 host_impl_->DidDrawAllLayers(frame); 7499 host_impl_->DidDrawAllLayers(frame);
7493 7500
7494 // Layer with partially opaque contents, drawn with blending. 7501 // Layer with partially opaque contents, drawn with blending.
7495 layer1->SetContentsOpaque(false); 7502 layer1->SetContentsOpaque(false);
7496 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 7503 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
7497 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); 7504 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
7498 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 7505 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
7499 layer1->SetExpectation(true, false); 7506 layer1->SetExpectation(true, false, root);
7500 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7507 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7501 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7508 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7502 host_impl_->active_tree()->set_needs_update_draw_properties(); 7509 host_impl_->active_tree()->set_needs_update_draw_properties();
7503 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7510 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7504 host_impl_->DrawLayers(&frame); 7511 host_impl_->DrawLayers(&frame);
7505 EXPECT_TRUE(layer1->quads_appended()); 7512 EXPECT_TRUE(layer1->quads_appended());
7506 host_impl_->DidDrawAllLayers(frame); 7513 host_impl_->DidDrawAllLayers(frame);
7507 7514
7508 // Layer with partially opaque contents partially culled, drawn with blending. 7515 // Layer with partially opaque contents partially culled, drawn with blending.
7509 layer1->SetContentsOpaque(false); 7516 layer1->SetContentsOpaque(false);
7510 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 7517 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
7511 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); 7518 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
7512 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 7519 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
7513 layer1->SetExpectation(true, false); 7520 layer1->SetExpectation(true, false, root);
7514 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7521 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7515 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7522 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7516 host_impl_->active_tree()->set_needs_update_draw_properties(); 7523 host_impl_->active_tree()->set_needs_update_draw_properties();
7517 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7524 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7518 host_impl_->DrawLayers(&frame); 7525 host_impl_->DrawLayers(&frame);
7519 EXPECT_TRUE(layer1->quads_appended()); 7526 EXPECT_TRUE(layer1->quads_appended());
7520 host_impl_->DidDrawAllLayers(frame); 7527 host_impl_->DidDrawAllLayers(frame);
7521 7528
7522 // Layer with partially opaque contents culled, drawn with blending. 7529 // Layer with partially opaque contents culled, drawn with blending.
7523 layer1->SetContentsOpaque(false); 7530 layer1->SetContentsOpaque(false);
7524 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 7531 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
7525 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); 7532 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
7526 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 7533 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
7527 layer1->SetExpectation(true, false); 7534 layer1->SetExpectation(true, false, root);
7528 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7535 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7529 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7536 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7530 host_impl_->active_tree()->set_needs_update_draw_properties(); 7537 host_impl_->active_tree()->set_needs_update_draw_properties();
7531 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7538 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7532 host_impl_->DrawLayers(&frame); 7539 host_impl_->DrawLayers(&frame);
7533 EXPECT_TRUE(layer1->quads_appended()); 7540 EXPECT_TRUE(layer1->quads_appended());
7534 host_impl_->DidDrawAllLayers(frame); 7541 host_impl_->DidDrawAllLayers(frame);
7535 7542
7536 // Layer with partially opaque contents and translucent contents culled, drawn 7543 // Layer with partially opaque contents and translucent contents culled, drawn
7537 // without blending. 7544 // without blending.
7538 layer1->SetContentsOpaque(false); 7545 layer1->SetContentsOpaque(false);
7539 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 7546 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
7540 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); 7547 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
7541 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 7548 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
7542 layer1->SetExpectation(false, false); 7549 layer1->SetExpectation(false, false, root);
7543 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7550 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7544 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7551 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7545 host_impl_->active_tree()->set_needs_update_draw_properties(); 7552 host_impl_->active_tree()->set_needs_update_draw_properties();
7546 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7553 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7547 host_impl_->DrawLayers(&frame); 7554 host_impl_->DrawLayers(&frame);
7548 EXPECT_TRUE(layer1->quads_appended()); 7555 EXPECT_TRUE(layer1->quads_appended());
7549 host_impl_->DidDrawAllLayers(frame); 7556 host_impl_->DidDrawAllLayers(frame);
7550 } 7557 }
7551 7558
7552 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) { 7559 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
7622 ->force_render_surface = true; 7629 ->force_render_surface = true;
7623 host_impl_->active_tree() 7630 host_impl_->active_tree()
7624 ->root_layer_for_testing() 7631 ->root_layer_for_testing()
7625 ->test_properties() 7632 ->test_properties()
7626 ->AddChild(BlendStateCheckLayer::Create( 7633 ->AddChild(BlendStateCheckLayer::Create(
7627 host_impl_->active_tree(), 2, host_impl_->resource_provider())); 7634 host_impl_->active_tree(), 2, host_impl_->resource_provider()));
7628 child_ = static_cast<BlendStateCheckLayer*>(host_impl_->active_tree() 7635 child_ = static_cast<BlendStateCheckLayer*>(host_impl_->active_tree()
7629 ->root_layer_for_testing() 7636 ->root_layer_for_testing()
7630 ->test_properties() 7637 ->test_properties()
7631 ->children[0]); 7638 ->children[0]);
7632 child_->SetExpectation(false, false); 7639 child_->SetExpectation(false, false,
7640 host_impl_->active_tree()->root_layer_for_testing());
7633 child_->SetContentsOpaque(true); 7641 child_->SetContentsOpaque(true);
7634 } 7642 }
7635 7643
7636 // Expect no gutter rects. 7644 // Expect no gutter rects.
7637 void TestLayerCoversFullViewport() { 7645 void TestLayerCoversFullViewport() {
7638 gfx::Rect layer_rect(viewport_size_); 7646 gfx::Rect layer_rect(viewport_size_);
7639 child_->SetPosition(gfx::PointF(layer_rect.origin())); 7647 child_->SetPosition(gfx::PointF(layer_rect.origin()));
7640 child_->SetBounds(layer_rect.size()); 7648 child_->SetBounds(layer_rect.size());
7641 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 7649 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
7642 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 7650 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
(...skipping 4724 matching lines...) Expand 10 before | Expand all | Expand 10 after
12367 else 12375 else
12368 EXPECT_FALSE(tile->HasRasterTask()); 12376 EXPECT_FALSE(tile->HasRasterTask());
12369 } 12377 }
12370 Region expected_invalidation( 12378 Region expected_invalidation(
12371 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12379 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12372 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12380 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12373 } 12381 }
12374 12382
12375 } // namespace 12383 } // namespace
12376 } // namespace cc 12384 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698