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

Side by Side Diff: cc/layers/texture_layer_impl_unittest.cc

Issue 1175113010: cc: Rename visible_content_rect and content stuff on quads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename-visible-content-rect: moreandroid Created 5 years, 6 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/layers/texture_layer_impl.cc ('k') | cc/layers/texture_layer_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/layers/texture_layer_impl.h" 5 #include "cc/layers/texture_layer_impl.h"
6 6
7 #include "cc/output/context_provider.h" 7 #include "cc/output/context_provider.h"
8 #include "cc/output/output_surface.h" 8 #include "cc/output/output_surface.h"
9 #include "cc/test/layer_test_common.h" 9 #include "cc/test/layer_test_common.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace cc { 12 namespace cc {
13 namespace { 13 namespace {
14 14
15 void IgnoreCallback(uint32 sync_point, 15 void IgnoreCallback(uint32 sync_point,
16 bool lost, 16 bool lost,
17 BlockingTaskRunner* main_thread_task_runner) { 17 BlockingTaskRunner* main_thread_task_runner) {
18 } 18 }
19 19
20 TEST(TextureLayerImplTest, VisibleOpaqueRegion) {
21 const gfx::Size layer_bounds(100, 100);
22 const gfx::Rect layer_rect(layer_bounds);
23 const Region layer_region(layer_rect);
24
25 LayerTestCommon::LayerImplTest impl;
26
27 TextureLayerImpl* layer = impl.AddChildToRoot<TextureLayerImpl>();
28 layer->SetBounds(layer_bounds);
29 layer->draw_properties().visible_layer_rect = layer_rect;
30 layer->SetBlendBackgroundColor(true);
31
32 // Verify initial conditions.
33 EXPECT_FALSE(layer->contents_opaque());
34 EXPECT_EQ(0u, layer->background_color());
35 EXPECT_EQ(Region().ToString(), layer->VisibleOpaqueRegion().ToString());
36
37 // Opaque background.
38 layer->SetBackgroundColor(SK_ColorWHITE);
39 EXPECT_EQ(layer_region.ToString(), layer->VisibleOpaqueRegion().ToString());
40
41 // Transparent background.
42 layer->SetBackgroundColor(SkColorSetARGB(100, 255, 255, 255));
43 EXPECT_EQ(Region().ToString(), layer->VisibleOpaqueRegion().ToString());
44 }
45
20 TEST(TextureLayerImplTest, Occlusion) { 46 TEST(TextureLayerImplTest, Occlusion) {
21 gfx::Size layer_size(1000, 1000); 47 gfx::Size layer_size(1000, 1000);
22 gfx::Size viewport_size(1000, 1000); 48 gfx::Size viewport_size(1000, 1000);
23 49
24 LayerTestCommon::LayerImplTest impl; 50 LayerTestCommon::LayerImplTest impl;
25 51
26 gpu::Mailbox mailbox; 52 gpu::Mailbox mailbox;
27 impl.output_surface()->context_provider()->ContextGL()->GenMailboxCHROMIUM( 53 impl.output_surface()->context_provider()->ContextGL()->GenMailboxCHROMIUM(
28 mailbox.name); 54 mailbox.name);
29 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, 0); 55 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, 0);
(...skipping 13 matching lines...) Expand all
43 gfx::Rect occluded; 69 gfx::Rect occluded;
44 impl.AppendQuadsWithOcclusion(texture_layer_impl, occluded); 70 impl.AppendQuadsWithOcclusion(texture_layer_impl, occluded);
45 71
46 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), 72 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(),
47 gfx::Rect(layer_size)); 73 gfx::Rect(layer_size));
48 EXPECT_EQ(1u, impl.quad_list().size()); 74 EXPECT_EQ(1u, impl.quad_list().size());
49 } 75 }
50 76
51 { 77 {
52 SCOPED_TRACE("Full occlusion"); 78 SCOPED_TRACE("Full occlusion");
53 gfx::Rect occluded(texture_layer_impl->visible_content_rect()); 79 gfx::Rect occluded(texture_layer_impl->visible_layer_rect());
54 impl.AppendQuadsWithOcclusion(texture_layer_impl, occluded); 80 impl.AppendQuadsWithOcclusion(texture_layer_impl, occluded);
55 81
56 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect()); 82 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect());
57 EXPECT_EQ(impl.quad_list().size(), 0u); 83 EXPECT_EQ(impl.quad_list().size(), 0u);
58 } 84 }
59 85
60 { 86 {
61 SCOPED_TRACE("Partial occlusion"); 87 SCOPED_TRACE("Partial occlusion");
62 gfx::Rect occluded(200, 0, 800, 1000); 88 gfx::Rect occluded(200, 0, 800, 1000);
63 impl.AppendQuadsWithOcclusion(texture_layer_impl, occluded); 89 impl.AppendQuadsWithOcclusion(texture_layer_impl, occluded);
64 90
65 size_t partially_occluded_count = 0; 91 size_t partially_occluded_count = 0;
66 LayerTestCommon::VerifyQuadsAreOccluded( 92 LayerTestCommon::VerifyQuadsAreOccluded(
67 impl.quad_list(), occluded, &partially_occluded_count); 93 impl.quad_list(), occluded, &partially_occluded_count);
68 // The layer outputs one quad, which is partially occluded. 94 // The layer outputs one quad, which is partially occluded.
69 EXPECT_EQ(1u, impl.quad_list().size()); 95 EXPECT_EQ(1u, impl.quad_list().size());
70 EXPECT_EQ(1u, partially_occluded_count); 96 EXPECT_EQ(1u, partially_occluded_count);
71 } 97 }
72 } 98 }
73 99
74 } // namespace 100 } // namespace
75 } // namespace cc 101 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/texture_layer_impl.cc ('k') | cc/layers/texture_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698