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

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

Issue 145313006: [#7] Pass gfx structs by const ref (gfx::Size) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 10 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/tiled_layer.cc ('k') | cc/layers/ui_resource_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 "cc/layers/tiled_layer_impl.h" 5 #include "cc/layers/tiled_layer_impl.h"
6 6
7 #include "cc/layers/append_quads_data.h" 7 #include "cc/layers/append_quads_data.h"
8 #include "cc/quads/tile_draw_quad.h" 8 #include "cc/quads/tile_draw_quad.h"
9 #include "cc/resources/layer_tiling_data.h" 9 #include "cc/resources/layer_tiling_data.h"
10 #include "cc/test/fake_impl_proxy.h" 10 #include "cc/test/fake_impl_proxy.h"
11 #include "cc/test/fake_layer_tree_host_impl.h" 11 #include "cc/test/fake_layer_tree_host_impl.h"
12 #include "cc/test/layer_test_common.h" 12 #include "cc/test/layer_test_common.h"
13 #include "cc/test/mock_quad_culler.h" 13 #include "cc/test/mock_quad_culler.h"
14 #include "cc/trees/single_thread_proxy.h" 14 #include "cc/trees/single_thread_proxy.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace cc { 18 namespace cc {
19 namespace { 19 namespace {
20 20
21 class TiledLayerImplTest : public testing::Test { 21 class TiledLayerImplTest : public testing::Test {
22 public: 22 public:
23 TiledLayerImplTest() : host_impl_(&proxy_) {} 23 TiledLayerImplTest() : host_impl_(&proxy_) {}
24 24
25 scoped_ptr<TiledLayerImpl> CreateLayerNoTiles( 25 scoped_ptr<TiledLayerImpl> CreateLayerNoTiles(
26 gfx::Size tile_size, 26 const gfx::Size& tile_size,
27 gfx::Size layer_size, 27 const gfx::Size& layer_size,
28 LayerTilingData::BorderTexelOption border_texels) { 28 LayerTilingData::BorderTexelOption border_texels) {
29 scoped_ptr<TiledLayerImpl> layer = 29 scoped_ptr<TiledLayerImpl> layer =
30 TiledLayerImpl::Create(host_impl_.active_tree(), 1); 30 TiledLayerImpl::Create(host_impl_.active_tree(), 1);
31 scoped_ptr<LayerTilingData> tiler = 31 scoped_ptr<LayerTilingData> tiler =
32 LayerTilingData::Create(tile_size, border_texels); 32 LayerTilingData::Create(tile_size, border_texels);
33 tiler->SetBounds(layer_size); 33 tiler->SetBounds(layer_size);
34 layer->SetTilingData(*tiler); 34 layer->SetTilingData(*tiler);
35 layer->set_skips_draw(false); 35 layer->set_skips_draw(false);
36 layer->draw_properties().visible_content_rect = 36 layer->draw_properties().visible_content_rect =
37 gfx::Rect(layer_size); 37 gfx::Rect(layer_size);
38 layer->draw_properties().opacity = 1; 38 layer->draw_properties().opacity = 1;
39 layer->SetBounds(layer_size); 39 layer->SetBounds(layer_size);
40 layer->SetContentBounds(layer_size); 40 layer->SetContentBounds(layer_size);
41 layer->CreateRenderSurface(); 41 layer->CreateRenderSurface();
42 layer->draw_properties().render_target = layer.get(); 42 layer->draw_properties().render_target = layer.get();
43 return layer.Pass(); 43 return layer.Pass();
44 } 44 }
45 45
46 // Create a default tiled layer with textures for all tiles and a default 46 // Create a default tiled layer with textures for all tiles and a default
47 // visibility of the entire layer size. 47 // visibility of the entire layer size.
48 scoped_ptr<TiledLayerImpl> CreateLayer( 48 scoped_ptr<TiledLayerImpl> CreateLayer(
49 gfx::Size tile_size, 49 const gfx::Size& tile_size,
50 gfx::Size layer_size, 50 const gfx::Size& layer_size,
51 LayerTilingData::BorderTexelOption border_texels) { 51 LayerTilingData::BorderTexelOption border_texels) {
52 scoped_ptr<TiledLayerImpl> layer = 52 scoped_ptr<TiledLayerImpl> layer =
53 CreateLayerNoTiles(tile_size, layer_size, border_texels); 53 CreateLayerNoTiles(tile_size, layer_size, border_texels);
54 54
55 layer->SetDrawsContent(true); 55 layer->SetDrawsContent(true);
56 56
57 ResourceProvider::ResourceId resource_id = 1; 57 ResourceProvider::ResourceId resource_id = 1;
58 for (int i = 0; i < layer->TilingForTesting()->num_tiles_x(); ++i) { 58 for (int i = 0; i < layer->TilingForTesting()->num_tiles_x(); ++i) {
59 for (int j = 0; j < layer->TilingForTesting()->num_tiles_y(); ++j) { 59 for (int j = 0; j < layer->TilingForTesting()->num_tiles_y(); ++j) {
60 gfx::Rect opaque_rect( 60 gfx::Rect opaque_rect(
61 layer->TilingForTesting()->tile_bounds(i, j).origin(), 61 layer->TilingForTesting()->tile_bounds(i, j).origin(),
62 gfx::Size(1, 1)); 62 gfx::Size(1, 1));
63 layer->PushTileProperties(i, j, resource_id++, opaque_rect, false); 63 layer->PushTileProperties(i, j, resource_id++, opaque_rect, false);
64 } 64 }
65 } 65 }
66 66
67 return layer.Pass(); 67 return layer.Pass();
68 } 68 }
69 69
70 void GetQuads(QuadList* quads, 70 void GetQuads(QuadList* quads,
71 SharedQuadStateList* shared_states, 71 SharedQuadStateList* shared_states,
72 gfx::Size tile_size, 72 const gfx::Size& tile_size,
73 gfx::Size layer_size, 73 const gfx::Size& layer_size,
74 LayerTilingData::BorderTexelOption border_texel_option, 74 LayerTilingData::BorderTexelOption border_texel_option,
75 const gfx::Rect& visible_content_rect) { 75 const gfx::Rect& visible_content_rect) {
76 scoped_ptr<TiledLayerImpl> layer = 76 scoped_ptr<TiledLayerImpl> layer =
77 CreateLayer(tile_size, layer_size, border_texel_option); 77 CreateLayer(tile_size, layer_size, border_texel_option);
78 layer->draw_properties().visible_content_rect = visible_content_rect; 78 layer->draw_properties().visible_content_rect = visible_content_rect;
79 layer->SetBounds(layer_size); 79 layer->SetBounds(layer_size);
80 80
81 MockQuadCuller quad_culler(quads, shared_states); 81 MockQuadCuller quad_culler(quads, shared_states);
82 AppendQuadsData data; 82 AppendQuadsData data;
83 layer->AppendQuads(&quad_culler, &data); 83 layer->AppendQuads(&quad_culler, &data);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 scoped_ptr<TiledLayerImpl> layer = 310 scoped_ptr<TiledLayerImpl> layer =
311 CreateLayer(tile_size, layer_size, LayerTilingData::NO_BORDER_TEXELS); 311 CreateLayer(tile_size, layer_size, LayerTilingData::NO_BORDER_TEXELS);
312 312
313 EXPECT_EQ(0u, layer->ContentsResourceId()); 313 EXPECT_EQ(0u, layer->ContentsResourceId());
314 EXPECT_EQ(0, layer->TilingForTesting()->num_tiles_x()); 314 EXPECT_EQ(0, layer->TilingForTesting()->num_tiles_x());
315 EXPECT_EQ(0, layer->TilingForTesting()->num_tiles_y()); 315 EXPECT_EQ(0, layer->TilingForTesting()->num_tiles_y());
316 } 316 }
317 317
318 } // namespace 318 } // namespace
319 } // namespace cc 319 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/tiled_layer.cc ('k') | cc/layers/ui_resource_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698