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

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

Issue 633773004: cc: Pass Occlusion instead of OcclusionTracker to LayerImpls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 6 years, 2 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/nine_patch_layer_impl.cc ('k') | cc/layers/painted_scrollbar_layer_impl.h » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "base/containers/hash_tables.h" 5 #include "base/containers/hash_tables.h"
6 #include "cc/layers/append_quads_data.h" 6 #include "cc/layers/append_quads_data.h"
7 #include "cc/layers/nine_patch_layer_impl.h" 7 #include "cc/layers/nine_patch_layer_impl.h"
8 #include "cc/quads/texture_draw_quad.h" 8 #include "cc/quads/texture_draw_quad.h"
9 #include "cc/resources/ui_resource_bitmap.h" 9 #include "cc/resources/ui_resource_bitmap.h"
10 #include "cc/resources/ui_resource_client.h" 10 #include "cc/resources/ui_resource_client.h"
(...skipping 17 matching lines...) Expand all
28 gfx::ToRoundedInt(rect_f.width()), 28 gfx::ToRoundedInt(rect_f.width()),
29 gfx::ToRoundedInt(rect_f.height())); 29 gfx::ToRoundedInt(rect_f.height()));
30 } 30 }
31 31
32 void NinePatchLayerLayoutTest(const gfx::Size& bitmap_size, 32 void NinePatchLayerLayoutTest(const gfx::Size& bitmap_size,
33 const gfx::Rect& aperture_rect, 33 const gfx::Rect& aperture_rect,
34 const gfx::Size& layer_size, 34 const gfx::Size& layer_size,
35 const gfx::Rect& border, 35 const gfx::Rect& border,
36 bool fill_center, 36 bool fill_center,
37 size_t expected_quad_size) { 37 size_t expected_quad_size) {
38 MockOcclusionTracker<LayerImpl> occlusion_tracker;
39 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 38 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
40 gfx::Rect visible_content_rect(layer_size); 39 gfx::Rect visible_content_rect(layer_size);
41 gfx::Rect expected_remaining(border.x(), 40 gfx::Rect expected_remaining(border.x(),
42 border.y(), 41 border.y(),
43 layer_size.width() - border.width(), 42 layer_size.width() - border.width(),
44 layer_size.height() - border.height()); 43 layer_size.height() - border.height());
45 44
46 FakeImplProxy proxy; 45 FakeImplProxy proxy;
47 TestSharedBitmapManager shared_bitmap_manager; 46 TestSharedBitmapManager shared_bitmap_manager;
48 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 47 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
49 scoped_ptr<NinePatchLayerImpl> layer = 48 scoped_ptr<NinePatchLayerImpl> layer =
50 NinePatchLayerImpl::Create(host_impl.active_tree(), 1); 49 NinePatchLayerImpl::Create(host_impl.active_tree(), 1);
51 layer->draw_properties().visible_content_rect = visible_content_rect; 50 layer->draw_properties().visible_content_rect = visible_content_rect;
52 layer->SetBounds(layer_size); 51 layer->SetBounds(layer_size);
53 layer->SetContentBounds(layer_size); 52 layer->SetContentBounds(layer_size);
54 layer->CreateRenderSurface(); 53 layer->CreateRenderSurface();
55 layer->draw_properties().render_target = layer.get(); 54 layer->draw_properties().render_target = layer.get();
56 55
57 UIResourceId uid = 1; 56 UIResourceId uid = 1;
58 bool is_opaque = false; 57 bool is_opaque = false;
59 UIResourceBitmap bitmap(bitmap_size, is_opaque); 58 UIResourceBitmap bitmap(bitmap_size, is_opaque);
60 59
61 host_impl.CreateUIResource(uid, bitmap); 60 host_impl.CreateUIResource(uid, bitmap);
62 layer->SetUIResourceId(uid); 61 layer->SetUIResourceId(uid);
63 layer->SetImageBounds(bitmap_size); 62 layer->SetImageBounds(bitmap_size);
64 layer->SetLayout(aperture_rect, border, fill_center); 63 layer->SetLayout(aperture_rect, border, fill_center);
65 AppendQuadsData data; 64 AppendQuadsData data;
66 layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); 65 layer->AppendQuads(render_pass.get(), Occlusion(), &data);
67 66
68 // Verify quad rects 67 // Verify quad rects
69 const QuadList& quads = render_pass->quad_list; 68 const QuadList& quads = render_pass->quad_list;
70 EXPECT_EQ(expected_quad_size, quads.size()); 69 EXPECT_EQ(expected_quad_size, quads.size());
71 70
72 Region remaining(visible_content_rect); 71 Region remaining(visible_content_rect);
73 for (auto iter = quads.cbegin(); iter != quads.cend(); ++iter) { 72 for (auto iter = quads.cbegin(); iter != quads.cend(); ++iter) {
74 gfx::Rect quad_rect = iter->rect; 73 gfx::Rect quad_rect = iter->rect;
75 74
76 EXPECT_TRUE(visible_content_rect.Contains(quad_rect)) << iter.index(); 75 EXPECT_TRUE(visible_content_rect.Contains(quad_rect)) << iter.index();
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 impl.quad_list(), occluded, &partially_occluded_count); 266 impl.quad_list(), occluded, &partially_occluded_count);
268 // The layer outputs nine quads, three of which are partially occluded, and 267 // The layer outputs nine quads, three of which are partially occluded, and
269 // three fully occluded. 268 // three fully occluded.
270 EXPECT_EQ(6u, impl.quad_list().size()); 269 EXPECT_EQ(6u, impl.quad_list().size());
271 EXPECT_EQ(3u, partially_occluded_count); 270 EXPECT_EQ(3u, partially_occluded_count);
272 } 271 }
273 } 272 }
274 273
275 } // namespace 274 } // namespace
276 } // namespace cc 275 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/nine_patch_layer_impl.cc ('k') | cc/layers/painted_scrollbar_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698