OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/picture_image_layer_impl.h" | 5 #include "cc/layers/picture_image_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/draw_quad.h" | 8 #include "cc/quads/draw_quad.h" |
9 #include "cc/resources/tile_priority.h" | 9 #include "cc/resources/tile_priority.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/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
13 #include "cc/test/fake_picture_layer_tiling_client.h" | 13 #include "cc/test/fake_picture_layer_tiling_client.h" |
14 #include "cc/test/impl_side_painting_settings.h" | 14 #include "cc/test/impl_side_painting_settings.h" |
15 #include "cc/test/mock_occlusion_tracker.h" | 15 #include "cc/test/mock_occlusion_tracker.h" |
16 #include "cc/test/test_shared_bitmap_manager.h" | 16 #include "cc/test/test_shared_bitmap_manager.h" |
17 #include "cc/trees/layer_tree_impl.h" | 17 #include "cc/trees/layer_tree_impl.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "ui/gfx/geometry/size_conversions.h" |
19 | 20 |
20 namespace cc { | 21 namespace cc { |
21 namespace { | 22 namespace { |
22 | 23 |
23 class TestablePictureImageLayerImpl : public PictureImageLayerImpl { | 24 class TestablePictureImageLayerImpl : public PictureImageLayerImpl { |
24 public: | 25 public: |
25 TestablePictureImageLayerImpl(LayerTreeImpl* tree_impl, int id) | 26 TestablePictureImageLayerImpl(LayerTreeImpl* tree_impl, int id) |
26 : PictureImageLayerImpl(tree_impl, id) { | 27 : PictureImageLayerImpl(tree_impl, id) { |
27 } | 28 } |
28 using PictureLayerImpl::UpdateIdealScales; | 29 using PictureLayerImpl::UpdateIdealScales; |
(...skipping 28 matching lines...) Expand all Loading... |
57 tree = host_impl_.pending_tree(); | 58 tree = host_impl_.pending_tree(); |
58 break; | 59 break; |
59 case NUM_TREES: | 60 case NUM_TREES: |
60 NOTREACHED(); | 61 NOTREACHED(); |
61 break; | 62 break; |
62 } | 63 } |
63 TestablePictureImageLayerImpl* layer = | 64 TestablePictureImageLayerImpl* layer = |
64 new TestablePictureImageLayerImpl(tree, id); | 65 new TestablePictureImageLayerImpl(tree, id); |
65 layer->SetBounds(gfx::Size(100, 200)); | 66 layer->SetBounds(gfx::Size(100, 200)); |
66 layer->SetContentBounds(gfx::Size(100, 200)); | 67 layer->SetContentBounds(gfx::Size(100, 200)); |
67 layer->tilings_.reset(new PictureLayerTilingSet(&tiling_client_, | 68 layer->tilings_.reset( |
68 layer->bounds())); | 69 new PictureLayerTilingSet(&tiling_client_, |
| 70 gfx::ToCeiledSize(layer->bounds()))); |
69 layer->pile_ = tiling_client_.GetPile(); | 71 layer->pile_ = tiling_client_.GetPile(); |
70 return make_scoped_ptr(layer); | 72 return make_scoped_ptr(layer); |
71 } | 73 } |
72 | 74 |
73 void SetupDrawPropertiesAndUpdateTiles(TestablePictureImageLayerImpl* layer, | 75 void SetupDrawPropertiesAndUpdateTiles(TestablePictureImageLayerImpl* layer, |
74 float ideal_contents_scale, | 76 float ideal_contents_scale, |
75 float device_scale_factor, | 77 float device_scale_factor, |
76 float page_scale_factor, | 78 float page_scale_factor, |
77 float maximum_animation_contents_scale, | 79 float maximum_animation_contents_scale, |
78 bool animating_transform_to_screen) { | 80 bool animating_transform_to_screen) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 animating_transform_to_screen); | 141 animating_transform_to_screen); |
140 EXPECT_EQ(1.f, active_layer->tilings()->tiling_at(0)->contents_scale()); | 142 EXPECT_EQ(1.f, active_layer->tilings()->tiling_at(0)->contents_scale()); |
141 | 143 |
142 // Create tile and resource. | 144 // Create tile and resource. |
143 active_layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 145 active_layer->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
144 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( | 146 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( |
145 active_layer->tilings()->tiling_at(0)->AllTilesForTesting()); | 147 active_layer->tilings()->tiling_at(0)->AllTilesForTesting()); |
146 | 148 |
147 // Draw. | 149 // Draw. |
148 active_layer->draw_properties().visible_content_rect = | 150 active_layer->draw_properties().visible_content_rect = |
149 gfx::Rect(active_layer->bounds()); | 151 gfx::Rect(gfx::ToCeiledSize(active_layer->bounds())); |
150 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 152 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
151 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 153 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
152 AppendQuadsData data; | 154 AppendQuadsData data; |
153 active_layer->WillDraw(DRAW_MODE_SOFTWARE, NULL); | 155 active_layer->WillDraw(DRAW_MODE_SOFTWARE, NULL); |
154 active_layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); | 156 active_layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
155 active_layer->DidDraw(NULL); | 157 active_layer->DidDraw(NULL); |
156 | 158 |
157 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material); | 159 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material); |
158 | 160 |
159 // Tiles are ready at correct scale, so should not set had_incomplete_tile. | 161 // Tiles are ready at correct scale, so should not set had_incomplete_tile. |
160 EXPECT_EQ(0, data.num_incomplete_tiles); | 162 EXPECT_EQ(0, data.num_incomplete_tiles); |
161 } | 163 } |
162 | 164 |
163 } // namespace | 165 } // namespace |
164 } // namespace cc | 166 } // namespace cc |
OLD | NEW |