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

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

Issue 2876473005: Get rid of two callsites of effect_tree.FindNodeIndexFromOwningLayerId. (Closed)
Patch Set: 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
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 7234 matching lines...) Expand 10 before | Expand all | Expand 10 after
7245 PopulateSharedQuadState(shared_quad_state); 7245 PopulateSharedQuadState(shared_quad_state);
7246 7246
7247 TileDrawQuad* test_blending_draw_quad = 7247 TileDrawQuad* test_blending_draw_quad =
7248 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); 7248 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>();
7249 test_blending_draw_quad->SetNew(shared_quad_state, quad_rect_, opaque_rect, 7249 test_blending_draw_quad->SetNew(shared_quad_state, quad_rect_, opaque_rect,
7250 visible_quad_rect, resource_id_, 7250 visible_quad_rect, resource_id_,
7251 gfx::RectF(0.f, 0.f, 1.f, 1.f), 7251 gfx::RectF(0.f, 0.f, 1.f, 1.f),
7252 gfx::Size(1, 1), false, false); 7252 gfx::Size(1, 1), false, false);
7253 test_blending_draw_quad->visible_rect = quad_visible_rect_; 7253 test_blending_draw_quad->visible_rect = quad_visible_rect_;
7254 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending()); 7254 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending());
7255 EXPECT_EQ(has_render_surface_, !!GetRenderSurface(this)); 7255 EXPECT_EQ(has_render_surface_,
7256 GetRenderSurface(this) != GetRenderSurface(comparison_layer_));
7256 } 7257 }
7257 7258
7258 void SetExpectation(bool blend, bool has_render_surface) { 7259 void SetExpectation(bool blend,
7260 bool has_render_surface,
7261 LayerImpl* comparison_layer) {
7259 blend_ = blend; 7262 blend_ = blend;
7260 has_render_surface_ = has_render_surface; 7263 has_render_surface_ = has_render_surface;
7264 comparison_layer_ = comparison_layer;
7261 quads_appended_ = false; 7265 quads_appended_ = false;
7262 } 7266 }
7263 7267
7264 bool quads_appended() const { return quads_appended_; } 7268 bool quads_appended() const { return quads_appended_; }
7265 7269
7266 void SetQuadRect(const gfx::Rect& rect) { quad_rect_ = rect; } 7270 void SetQuadRect(const gfx::Rect& rect) { quad_rect_ = rect; }
7267 void SetQuadVisibleRect(const gfx::Rect& rect) { quad_visible_rect_ = rect; } 7271 void SetQuadVisibleRect(const gfx::Rect& rect) { quad_visible_rect_ = rect; }
7268 void SetOpaqueContentRect(const gfx::Rect& rect) { 7272 void SetOpaqueContentRect(const gfx::Rect& rect) {
7269 opaque_content_rect_ = rect; 7273 opaque_content_rect_ = rect;
7270 } 7274 }
7271 7275
7272 private: 7276 private:
7273 BlendStateCheckLayer(LayerTreeImpl* tree_impl, 7277 BlendStateCheckLayer(LayerTreeImpl* tree_impl,
7274 int id, 7278 int id,
7275 ResourceProvider* resource_provider) 7279 ResourceProvider* resource_provider)
7276 : LayerImpl(tree_impl, id), 7280 : LayerImpl(tree_impl, id),
7277 blend_(false), 7281 blend_(false),
7278 has_render_surface_(false), 7282 has_render_surface_(false),
7283 comparison_layer_(nullptr),
7279 quads_appended_(false), 7284 quads_appended_(false),
7280 quad_rect_(5, 5, 5, 5), 7285 quad_rect_(5, 5, 5, 5),
7281 quad_visible_rect_(5, 5, 5, 5), 7286 quad_visible_rect_(5, 5, 5, 5),
7282 resource_id_(resource_provider->CreateResource( 7287 resource_id_(resource_provider->CreateResource(
7283 gfx::Size(1, 1), 7288 gfx::Size(1, 1),
7284 ResourceProvider::TEXTURE_HINT_IMMUTABLE, 7289 ResourceProvider::TEXTURE_HINT_IMMUTABLE,
7285 RGBA_8888, 7290 RGBA_8888,
7286 gfx::ColorSpace())) { 7291 gfx::ColorSpace())) {
7287 resource_provider->AllocateForTesting(resource_id_); 7292 resource_provider->AllocateForTesting(resource_id_);
7288 SetBounds(gfx::Size(10, 10)); 7293 SetBounds(gfx::Size(10, 10));
7289 SetDrawsContent(true); 7294 SetDrawsContent(true);
7290 } 7295 }
7291 7296
7292 bool blend_; 7297 bool blend_;
7293 bool has_render_surface_; 7298 bool has_render_surface_;
7299 LayerImpl* comparison_layer_;
7294 bool quads_appended_; 7300 bool quads_appended_;
7295 gfx::Rect quad_rect_; 7301 gfx::Rect quad_rect_;
7296 gfx::Rect opaque_content_rect_; 7302 gfx::Rect opaque_content_rect_;
7297 gfx::Rect quad_visible_rect_; 7303 gfx::Rect quad_visible_rect_;
7298 ResourceId resource_id_; 7304 ResourceId resource_id_;
7299 }; 7305 };
7300 7306
7301 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { 7307 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
7302 { 7308 {
7303 std::unique_ptr<LayerImpl> root = 7309 std::unique_ptr<LayerImpl> root =
7304 LayerImpl::Create(host_impl_->active_tree(), 1); 7310 LayerImpl::Create(host_impl_->active_tree(), 1);
7305 root->SetBounds(gfx::Size(10, 10)); 7311 root->SetBounds(gfx::Size(10, 10));
7306 root->SetDrawsContent(false); 7312 root->SetDrawsContent(false);
7307 root->test_properties()->force_render_surface = true; 7313 root->test_properties()->force_render_surface = true;
7308 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); 7314 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root));
7309 } 7315 }
7310 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); 7316 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing();
7311 7317
7312 root->test_properties()->AddChild(BlendStateCheckLayer::Create( 7318 root->test_properties()->AddChild(BlendStateCheckLayer::Create(
7313 host_impl_->active_tree(), 2, host_impl_->resource_provider())); 7319 host_impl_->active_tree(), 2, host_impl_->resource_provider()));
7314 BlendStateCheckLayer* layer1 = 7320 BlendStateCheckLayer* layer1 =
7315 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]); 7321 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]);
7316 layer1->SetPosition(gfx::PointF(2.f, 2.f)); 7322 layer1->SetPosition(gfx::PointF(2.f, 2.f));
7317 7323
7318 TestFrameData frame; 7324 TestFrameData frame;
7319 7325
7320 // Opaque layer, drawn without blending. 7326 // Opaque layer, drawn without blending.
7321 layer1->SetContentsOpaque(true); 7327 layer1->SetContentsOpaque(true);
7322 layer1->SetExpectation(false, false); 7328 layer1->SetExpectation(false, false, root);
7323 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7329 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7324 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7330 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7325 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7331 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7326 host_impl_->DrawLayers(&frame); 7332 host_impl_->DrawLayers(&frame);
7327 EXPECT_TRUE(layer1->quads_appended()); 7333 EXPECT_TRUE(layer1->quads_appended());
7328 host_impl_->DidDrawAllLayers(frame); 7334 host_impl_->DidDrawAllLayers(frame);
7329 7335
7330 // Layer with translucent content and painting, so drawn with blending. 7336 // Layer with translucent content and painting, so drawn with blending.
7331 layer1->SetContentsOpaque(false); 7337 layer1->SetContentsOpaque(false);
7332 layer1->SetExpectation(true, false); 7338 layer1->SetExpectation(true, false, root);
7333 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7339 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7334 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7340 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7335 host_impl_->active_tree()->set_needs_update_draw_properties(); 7341 host_impl_->active_tree()->set_needs_update_draw_properties();
7336 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7342 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7337 host_impl_->DrawLayers(&frame); 7343 host_impl_->DrawLayers(&frame);
7338 EXPECT_TRUE(layer1->quads_appended()); 7344 EXPECT_TRUE(layer1->quads_appended());
7339 host_impl_->DidDrawAllLayers(frame); 7345 host_impl_->DidDrawAllLayers(frame);
7340 7346
7341 // Layer with translucent opacity, drawn with blending. 7347 // Layer with translucent opacity, drawn with blending.
7342 layer1->SetContentsOpaque(true); 7348 layer1->SetContentsOpaque(true);
7343 layer1->test_properties()->opacity = 0.5f; 7349 layer1->test_properties()->opacity = 0.5f;
7344 layer1->NoteLayerPropertyChanged(); 7350 layer1->NoteLayerPropertyChanged();
7345 layer1->SetExpectation(true, false); 7351 layer1->SetExpectation(true, false, root);
7346 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7352 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7347 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7353 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7348 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7354 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7349 host_impl_->DrawLayers(&frame); 7355 host_impl_->DrawLayers(&frame);
7350 EXPECT_TRUE(layer1->quads_appended()); 7356 EXPECT_TRUE(layer1->quads_appended());
7351 host_impl_->DidDrawAllLayers(frame); 7357 host_impl_->DidDrawAllLayers(frame);
7352 7358
7353 // Layer with translucent opacity and painting, drawn with blending. 7359 // Layer with translucent opacity and painting, drawn with blending.
7354 layer1->SetContentsOpaque(true); 7360 layer1->SetContentsOpaque(true);
7355 layer1->test_properties()->opacity = 0.5f; 7361 layer1->test_properties()->opacity = 0.5f;
7356 layer1->NoteLayerPropertyChanged(); 7362 layer1->NoteLayerPropertyChanged();
7357 layer1->SetExpectation(true, false); 7363 layer1->SetExpectation(true, false, root);
7358 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7364 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7359 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7365 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7360 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7366 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7361 host_impl_->DrawLayers(&frame); 7367 host_impl_->DrawLayers(&frame);
7362 EXPECT_TRUE(layer1->quads_appended()); 7368 EXPECT_TRUE(layer1->quads_appended());
7363 host_impl_->DidDrawAllLayers(frame); 7369 host_impl_->DidDrawAllLayers(frame);
7364 7370
7365 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create( 7371 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create(
7366 host_impl_->active_tree(), 3, host_impl_->resource_provider())); 7372 host_impl_->active_tree(), 3, host_impl_->resource_provider()));
7367 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>( 7373 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>(
7368 layer1->test_properties()->children[0]); 7374 layer1->test_properties()->children[0]);
7369 layer2->SetPosition(gfx::PointF(4.f, 4.f)); 7375 layer2->SetPosition(gfx::PointF(4.f, 4.f));
7370 7376
7371 // 2 opaque layers, drawn without blending. 7377 // 2 opaque layers, drawn without blending.
7372 layer1->SetContentsOpaque(true); 7378 layer1->SetContentsOpaque(true);
7373 layer1->test_properties()->opacity = 1.f; 7379 layer1->test_properties()->opacity = 1.f;
7374 layer1->NoteLayerPropertyChanged(); 7380 layer1->NoteLayerPropertyChanged();
7375 layer1->SetExpectation(false, false); 7381 layer1->SetExpectation(false, false, root);
7376 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7382 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7377 layer2->SetContentsOpaque(true); 7383 layer2->SetContentsOpaque(true);
7378 layer2->test_properties()->opacity = 1.f; 7384 layer2->test_properties()->opacity = 1.f;
7379 layer2->NoteLayerPropertyChanged(); 7385 layer2->NoteLayerPropertyChanged();
7380 layer2->SetExpectation(false, false); 7386 layer2->SetExpectation(false, false, root);
7381 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7387 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7382 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7388 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7383 host_impl_->active_tree()->set_needs_update_draw_properties(); 7389 host_impl_->active_tree()->set_needs_update_draw_properties();
7384 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7390 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7385 host_impl_->DrawLayers(&frame); 7391 host_impl_->DrawLayers(&frame);
7386 EXPECT_TRUE(layer1->quads_appended()); 7392 EXPECT_TRUE(layer1->quads_appended());
7387 EXPECT_TRUE(layer2->quads_appended()); 7393 EXPECT_TRUE(layer2->quads_appended());
7388 host_impl_->DidDrawAllLayers(frame); 7394 host_impl_->DidDrawAllLayers(frame);
7389 7395
7390 // Parent layer with translucent content, drawn with blending. 7396 // Parent layer with translucent content, drawn with blending.
7391 // Child layer with opaque content, drawn without blending. 7397 // Child layer with opaque content, drawn without blending.
7392 layer1->SetContentsOpaque(false); 7398 layer1->SetContentsOpaque(false);
7393 layer1->SetExpectation(true, false); 7399 layer1->SetExpectation(true, false, root);
7394 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7400 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7395 layer2->SetExpectation(false, false); 7401 layer2->SetExpectation(false, false, root);
7396 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7402 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7397 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7403 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7398 host_impl_->active_tree()->set_needs_update_draw_properties(); 7404 host_impl_->active_tree()->set_needs_update_draw_properties();
7399 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7405 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7400 host_impl_->DrawLayers(&frame); 7406 host_impl_->DrawLayers(&frame);
7401 EXPECT_TRUE(layer1->quads_appended()); 7407 EXPECT_TRUE(layer1->quads_appended());
7402 EXPECT_TRUE(layer2->quads_appended()); 7408 EXPECT_TRUE(layer2->quads_appended());
7403 host_impl_->DidDrawAllLayers(frame); 7409 host_impl_->DidDrawAllLayers(frame);
7404 7410
7405 // Parent layer with translucent content but opaque painting, drawn without 7411 // Parent layer with translucent content but opaque painting, drawn without
7406 // blending. 7412 // blending.
7407 // Child layer with opaque content, drawn without blending. 7413 // Child layer with opaque content, drawn without blending.
7408 layer1->SetContentsOpaque(true); 7414 layer1->SetContentsOpaque(true);
7409 layer1->SetExpectation(false, false); 7415 layer1->SetExpectation(false, false, root);
7410 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7416 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7411 layer2->SetExpectation(false, false); 7417 layer2->SetExpectation(false, false, root);
7412 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7418 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7413 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7419 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7414 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7420 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7415 host_impl_->DrawLayers(&frame); 7421 host_impl_->DrawLayers(&frame);
7416 EXPECT_TRUE(layer1->quads_appended()); 7422 EXPECT_TRUE(layer1->quads_appended());
7417 EXPECT_TRUE(layer2->quads_appended()); 7423 EXPECT_TRUE(layer2->quads_appended());
7418 host_impl_->DidDrawAllLayers(frame); 7424 host_impl_->DidDrawAllLayers(frame);
7419 7425
7420 // Parent layer with translucent opacity and opaque content. Since it has a 7426 // Parent layer with translucent opacity and opaque content. Since it has a
7421 // drawing child, it's drawn to a render surface which carries the opacity, 7427 // drawing child, it's drawn to a render surface which carries the opacity,
7422 // so it's itself drawn without blending. 7428 // so it's itself drawn without blending.
7423 // Child layer with opaque content, drawn without blending (parent surface 7429 // Child layer with opaque content, drawn without blending (parent surface
7424 // carries the inherited opacity). 7430 // carries the inherited opacity).
7425 layer1->SetContentsOpaque(true); 7431 layer1->SetContentsOpaque(true);
7426 layer1->test_properties()->opacity = 0.5f; 7432 layer1->test_properties()->opacity = 0.5f;
7427 layer1->NoteLayerPropertyChanged(); 7433 layer1->NoteLayerPropertyChanged();
7428 layer1->test_properties()->force_render_surface = true; 7434 layer1->test_properties()->force_render_surface = true;
7429 layer1->SetExpectation(false, true); 7435 layer1->SetExpectation(false, true, root);
7430 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7436 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7431 layer2->SetExpectation(false, false); 7437 layer2->SetExpectation(false, false, layer1);
7432 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7438 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7433 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7439 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7434 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7440 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7435 host_impl_->DrawLayers(&frame); 7441 host_impl_->DrawLayers(&frame);
7436 EXPECT_TRUE(layer1->quads_appended()); 7442 EXPECT_TRUE(layer1->quads_appended());
7437 EXPECT_TRUE(layer2->quads_appended()); 7443 EXPECT_TRUE(layer2->quads_appended());
7438 host_impl_->DidDrawAllLayers(frame); 7444 host_impl_->DidDrawAllLayers(frame);
7439 layer1->test_properties()->force_render_surface = false; 7445 layer1->test_properties()->force_render_surface = false;
7440 7446
7441 // Draw again, but with child non-opaque, to make sure 7447 // Draw again, but with child non-opaque, to make sure
7442 // layer1 not culled. 7448 // layer1 not culled.
7443 layer1->SetContentsOpaque(true); 7449 layer1->SetContentsOpaque(true);
7444 layer1->test_properties()->opacity = 1.f; 7450 layer1->test_properties()->opacity = 1.f;
7445 layer1->NoteLayerPropertyChanged(); 7451 layer1->NoteLayerPropertyChanged();
7446 layer1->SetExpectation(false, false); 7452 layer1->SetExpectation(false, false, root);
7447 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7453 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7448 layer2->SetContentsOpaque(true); 7454 layer2->SetContentsOpaque(true);
7449 layer2->test_properties()->opacity = 0.5f; 7455 layer2->test_properties()->opacity = 0.5f;
7450 layer2->NoteLayerPropertyChanged(); 7456 layer2->NoteLayerPropertyChanged();
7451 layer2->SetExpectation(true, false); 7457 layer2->SetExpectation(true, false, layer1);
7452 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7458 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7453 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7459 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7454 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7460 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7455 host_impl_->DrawLayers(&frame); 7461 host_impl_->DrawLayers(&frame);
7456 EXPECT_TRUE(layer1->quads_appended()); 7462 EXPECT_TRUE(layer1->quads_appended());
7457 EXPECT_TRUE(layer2->quads_appended()); 7463 EXPECT_TRUE(layer2->quads_appended());
7458 host_impl_->DidDrawAllLayers(frame); 7464 host_impl_->DidDrawAllLayers(frame);
7459 7465
7460 // A second way of making the child non-opaque. 7466 // A second way of making the child non-opaque.
7461 layer1->SetContentsOpaque(true); 7467 layer1->SetContentsOpaque(true);
7462 layer1->test_properties()->opacity = 1.f; 7468 layer1->test_properties()->opacity = 1.f;
7463 layer1->NoteLayerPropertyChanged(); 7469 layer1->NoteLayerPropertyChanged();
7464 layer1->SetExpectation(false, false); 7470 layer1->SetExpectation(false, false, root);
7465 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7471 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7466 layer2->SetContentsOpaque(false); 7472 layer2->SetContentsOpaque(false);
7467 layer2->test_properties()->opacity = 1.f; 7473 layer2->test_properties()->opacity = 1.f;
7468 layer2->NoteLayerPropertyChanged(); 7474 layer2->NoteLayerPropertyChanged();
7469 layer2->SetExpectation(true, false); 7475 layer2->SetExpectation(true, false, root);
7470 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7476 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7471 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7477 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7472 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7478 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7473 host_impl_->DrawLayers(&frame); 7479 host_impl_->DrawLayers(&frame);
7474 EXPECT_TRUE(layer1->quads_appended()); 7480 EXPECT_TRUE(layer1->quads_appended());
7475 EXPECT_TRUE(layer2->quads_appended()); 7481 EXPECT_TRUE(layer2->quads_appended());
7476 host_impl_->DidDrawAllLayers(frame); 7482 host_impl_->DidDrawAllLayers(frame);
7477 7483
7478 // And when the layer says its not opaque but is painted opaque, it is not 7484 // And when the layer says its not opaque but is painted opaque, it is not
7479 // blended. 7485 // blended.
7480 layer1->SetContentsOpaque(true); 7486 layer1->SetContentsOpaque(true);
7481 layer1->test_properties()->opacity = 1.f; 7487 layer1->test_properties()->opacity = 1.f;
7482 layer1->NoteLayerPropertyChanged(); 7488 layer1->NoteLayerPropertyChanged();
7483 layer1->SetExpectation(false, false); 7489 layer1->SetExpectation(false, false, root);
7484 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7490 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7485 layer2->SetContentsOpaque(true); 7491 layer2->SetContentsOpaque(true);
7486 layer2->test_properties()->opacity = 1.f; 7492 layer2->test_properties()->opacity = 1.f;
7487 layer2->NoteLayerPropertyChanged(); 7493 layer2->NoteLayerPropertyChanged();
7488 layer2->SetExpectation(false, false); 7494 layer2->SetExpectation(false, false, root);
7489 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); 7495 layer2->SetUpdateRect(gfx::Rect(layer1->bounds()));
7490 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7496 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7491 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7497 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7492 host_impl_->DrawLayers(&frame); 7498 host_impl_->DrawLayers(&frame);
7493 EXPECT_TRUE(layer1->quads_appended()); 7499 EXPECT_TRUE(layer1->quads_appended());
7494 EXPECT_TRUE(layer2->quads_appended()); 7500 EXPECT_TRUE(layer2->quads_appended());
7495 host_impl_->DidDrawAllLayers(frame); 7501 host_impl_->DidDrawAllLayers(frame);
7496 7502
7497 // Layer with partially opaque contents, drawn with blending. 7503 // Layer with partially opaque contents, drawn with blending.
7498 layer1->SetContentsOpaque(false); 7504 layer1->SetContentsOpaque(false);
7499 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 7505 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
7500 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); 7506 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5));
7501 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 7507 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
7502 layer1->SetExpectation(true, false); 7508 layer1->SetExpectation(true, false, root);
7503 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7509 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7504 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7510 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7505 host_impl_->active_tree()->set_needs_update_draw_properties(); 7511 host_impl_->active_tree()->set_needs_update_draw_properties();
7506 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7512 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7507 host_impl_->DrawLayers(&frame); 7513 host_impl_->DrawLayers(&frame);
7508 EXPECT_TRUE(layer1->quads_appended()); 7514 EXPECT_TRUE(layer1->quads_appended());
7509 host_impl_->DidDrawAllLayers(frame); 7515 host_impl_->DidDrawAllLayers(frame);
7510 7516
7511 // Layer with partially opaque contents partially culled, drawn with blending. 7517 // Layer with partially opaque contents partially culled, drawn with blending.
7512 layer1->SetContentsOpaque(false); 7518 layer1->SetContentsOpaque(false);
7513 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 7519 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
7514 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); 7520 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2));
7515 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 7521 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
7516 layer1->SetExpectation(true, false); 7522 layer1->SetExpectation(true, false, root);
7517 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7523 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7518 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7524 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7519 host_impl_->active_tree()->set_needs_update_draw_properties(); 7525 host_impl_->active_tree()->set_needs_update_draw_properties();
7520 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7526 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7521 host_impl_->DrawLayers(&frame); 7527 host_impl_->DrawLayers(&frame);
7522 EXPECT_TRUE(layer1->quads_appended()); 7528 EXPECT_TRUE(layer1->quads_appended());
7523 host_impl_->DidDrawAllLayers(frame); 7529 host_impl_->DidDrawAllLayers(frame);
7524 7530
7525 // Layer with partially opaque contents culled, drawn with blending. 7531 // Layer with partially opaque contents culled, drawn with blending.
7526 layer1->SetContentsOpaque(false); 7532 layer1->SetContentsOpaque(false);
7527 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 7533 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
7528 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); 7534 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5));
7529 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 7535 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
7530 layer1->SetExpectation(true, false); 7536 layer1->SetExpectation(true, false, root);
7531 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7537 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7532 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7538 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7533 host_impl_->active_tree()->set_needs_update_draw_properties(); 7539 host_impl_->active_tree()->set_needs_update_draw_properties();
7534 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7540 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7535 host_impl_->DrawLayers(&frame); 7541 host_impl_->DrawLayers(&frame);
7536 EXPECT_TRUE(layer1->quads_appended()); 7542 EXPECT_TRUE(layer1->quads_appended());
7537 host_impl_->DidDrawAllLayers(frame); 7543 host_impl_->DidDrawAllLayers(frame);
7538 7544
7539 // Layer with partially opaque contents and translucent contents culled, drawn 7545 // Layer with partially opaque contents and translucent contents culled, drawn
7540 // without blending. 7546 // without blending.
7541 layer1->SetContentsOpaque(false); 7547 layer1->SetContentsOpaque(false);
7542 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); 7548 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5));
7543 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); 7549 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5));
7544 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); 7550 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
7545 layer1->SetExpectation(false, false); 7551 layer1->SetExpectation(false, false, root);
7546 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 7552 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
7547 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 7553 host_impl_->active_tree()->BuildPropertyTreesForTesting();
7548 host_impl_->active_tree()->set_needs_update_draw_properties(); 7554 host_impl_->active_tree()->set_needs_update_draw_properties();
7549 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 7555 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
7550 host_impl_->DrawLayers(&frame); 7556 host_impl_->DrawLayers(&frame);
7551 EXPECT_TRUE(layer1->quads_appended()); 7557 EXPECT_TRUE(layer1->quads_appended());
7552 host_impl_->DidDrawAllLayers(frame); 7558 host_impl_->DidDrawAllLayers(frame);
7553 } 7559 }
7554 7560
7555 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) { 7561 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
7625 ->force_render_surface = true; 7631 ->force_render_surface = true;
7626 host_impl_->active_tree() 7632 host_impl_->active_tree()
7627 ->root_layer_for_testing() 7633 ->root_layer_for_testing()
7628 ->test_properties() 7634 ->test_properties()
7629 ->AddChild(BlendStateCheckLayer::Create( 7635 ->AddChild(BlendStateCheckLayer::Create(
7630 host_impl_->active_tree(), 2, host_impl_->resource_provider())); 7636 host_impl_->active_tree(), 2, host_impl_->resource_provider()));
7631 child_ = static_cast<BlendStateCheckLayer*>(host_impl_->active_tree() 7637 child_ = static_cast<BlendStateCheckLayer*>(host_impl_->active_tree()
7632 ->root_layer_for_testing() 7638 ->root_layer_for_testing()
7633 ->test_properties() 7639 ->test_properties()
7634 ->children[0]); 7640 ->children[0]);
7635 child_->SetExpectation(false, false); 7641 child_->SetExpectation(false, false,
7642 host_impl_->active_tree()->root_layer_for_testing());
7636 child_->SetContentsOpaque(true); 7643 child_->SetContentsOpaque(true);
7637 } 7644 }
7638 7645
7639 // Expect no gutter rects. 7646 // Expect no gutter rects.
7640 void TestLayerCoversFullViewport() { 7647 void TestLayerCoversFullViewport() {
7641 gfx::Rect layer_rect(viewport_size_); 7648 gfx::Rect layer_rect(viewport_size_);
7642 child_->SetPosition(gfx::PointF(layer_rect.origin())); 7649 child_->SetPosition(gfx::PointF(layer_rect.origin()));
7643 child_->SetBounds(layer_rect.size()); 7650 child_->SetBounds(layer_rect.size());
7644 child_->SetQuadRect(gfx::Rect(layer_rect.size())); 7651 child_->SetQuadRect(gfx::Rect(layer_rect.size()));
7645 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size())); 7652 child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
(...skipping 4724 matching lines...) Expand 10 before | Expand all | Expand 10 after
12370 else 12377 else
12371 EXPECT_FALSE(tile->HasRasterTask()); 12378 EXPECT_FALSE(tile->HasRasterTask());
12372 } 12379 }
12373 Region expected_invalidation( 12380 Region expected_invalidation(
12374 raster_source->GetRectForImage(checkerable_image->uniqueID())); 12381 raster_source->GetRectForImage(checkerable_image->uniqueID()));
12375 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); 12382 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation()));
12376 } 12383 }
12377 12384
12378 } // namespace 12385 } // namespace
12379 } // namespace cc 12386 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698