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

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

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 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/picture_image_layer_impl.cc ('k') | cc/layers/picture_image_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 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 "base/memory/ptr_util.h"
7 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
8 #include "cc/layers/append_quads_data.h" 9 #include "cc/layers/append_quads_data.h"
9 #include "cc/quads/draw_quad.h" 10 #include "cc/quads/draw_quad.h"
10 #include "cc/test/fake_impl_task_runner_provider.h" 11 #include "cc/test/fake_impl_task_runner_provider.h"
11 #include "cc/test/fake_layer_tree_host_impl.h" 12 #include "cc/test/fake_layer_tree_host_impl.h"
12 #include "cc/test/fake_output_surface.h" 13 #include "cc/test/fake_output_surface.h"
13 #include "cc/test/fake_raster_source.h" 14 #include "cc/test/fake_raster_source.h"
14 #include "cc/test/test_shared_bitmap_manager.h" 15 #include "cc/test/test_shared_bitmap_manager.h"
15 #include "cc/test/test_task_graph_runner.h" 16 #include "cc/test/test_task_graph_runner.h"
16 #include "cc/tiles/tile_priority.h" 17 #include "cc/tiles/tile_priority.h"
17 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.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, false) {} 27 : PictureImageLayerImpl(tree_impl, id, false) {}
27 28
28 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override { 29 std::unique_ptr<LayerImpl> CreateLayerImpl(
29 return make_scoped_ptr(new TestablePictureImageLayerImpl(tree_impl, id())); 30 LayerTreeImpl* tree_impl) override {
31 return base::WrapUnique(new TestablePictureImageLayerImpl(tree_impl, id()));
30 } 32 }
31 33
32 using PictureLayerImpl::UpdateIdealScales; 34 using PictureLayerImpl::UpdateIdealScales;
33 using PictureLayerImpl::MaximumTilingContentsScale; 35 using PictureLayerImpl::MaximumTilingContentsScale;
34 36
35 PictureLayerTilingSet* tilings() { return tilings_.get(); } 37 PictureLayerTilingSet* tilings() { return tilings_.get(); }
36 38
37 friend class PictureImageLayerImplTest; 39 friend class PictureImageLayerImplTest;
38 }; 40 };
39 41
(...skipping 11 matching lines...) Expand all
51 output_surface_(FakeOutputSurface::Create3d()), 53 output_surface_(FakeOutputSurface::Create3d()),
52 host_impl_(PictureLayerImplImageTestSettings(), 54 host_impl_(PictureLayerImplImageTestSettings(),
53 &task_runner_provider_, 55 &task_runner_provider_,
54 &shared_bitmap_manager_, 56 &shared_bitmap_manager_,
55 &task_graph_runner_) { 57 &task_graph_runner_) {
56 host_impl_.CreatePendingTree(); 58 host_impl_.CreatePendingTree();
57 host_impl_.SetVisible(true); 59 host_impl_.SetVisible(true);
58 host_impl_.InitializeRenderer(output_surface_.get()); 60 host_impl_.InitializeRenderer(output_surface_.get());
59 } 61 }
60 62
61 scoped_ptr<TestablePictureImageLayerImpl> CreateLayer(int id, 63 std::unique_ptr<TestablePictureImageLayerImpl> CreateLayer(
62 WhichTree which_tree) { 64 int id,
65 WhichTree which_tree) {
63 LayerTreeImpl* tree = nullptr; 66 LayerTreeImpl* tree = nullptr;
64 switch (which_tree) { 67 switch (which_tree) {
65 case ACTIVE_TREE: 68 case ACTIVE_TREE:
66 tree = host_impl_.active_tree(); 69 tree = host_impl_.active_tree();
67 break; 70 break;
68 case PENDING_TREE: 71 case PENDING_TREE:
69 tree = host_impl_.pending_tree(); 72 tree = host_impl_.pending_tree();
70 break; 73 break;
71 } 74 }
72 TestablePictureImageLayerImpl* layer = 75 TestablePictureImageLayerImpl* layer =
73 new TestablePictureImageLayerImpl(tree, id); 76 new TestablePictureImageLayerImpl(tree, id);
74 layer->raster_source_ = FakeRasterSource::CreateInfiniteFilled(); 77 layer->raster_source_ = FakeRasterSource::CreateInfiniteFilled();
75 layer->SetBounds(layer->raster_source_->GetSize()); 78 layer->SetBounds(layer->raster_source_->GetSize());
76 return make_scoped_ptr(layer); 79 return base::WrapUnique(layer);
77 } 80 }
78 81
79 void SetupDrawPropertiesAndUpdateTiles(TestablePictureImageLayerImpl* layer, 82 void SetupDrawPropertiesAndUpdateTiles(TestablePictureImageLayerImpl* layer,
80 float ideal_contents_scale, 83 float ideal_contents_scale,
81 float device_scale_factor, 84 float device_scale_factor,
82 float page_scale_factor, 85 float page_scale_factor,
83 float maximum_animation_contents_scale, 86 float maximum_animation_contents_scale,
84 bool animating_transform_to_screen, 87 bool animating_transform_to_screen,
85 gfx::Rect viewport_rect) { 88 gfx::Rect viewport_rect) {
86 gfx::Transform scale_transform; 89 gfx::Transform scale_transform;
87 scale_transform.Scale(ideal_contents_scale, ideal_contents_scale); 90 scale_transform.Scale(ideal_contents_scale, ideal_contents_scale);
88 layer->draw_properties().target_space_transform = scale_transform; 91 layer->draw_properties().target_space_transform = scale_transform;
89 DCHECK_EQ(layer->GetIdealContentsScale(), ideal_contents_scale); 92 DCHECK_EQ(layer->GetIdealContentsScale(), ideal_contents_scale);
90 layer->draw_properties().maximum_animation_contents_scale = 93 layer->draw_properties().maximum_animation_contents_scale =
91 maximum_animation_contents_scale; 94 maximum_animation_contents_scale;
92 layer->draw_properties().screen_space_transform_is_animating = 95 layer->draw_properties().screen_space_transform_is_animating =
93 animating_transform_to_screen; 96 animating_transform_to_screen;
94 layer->draw_properties().visible_layer_rect = viewport_rect; 97 layer->draw_properties().visible_layer_rect = viewport_rect;
95 layer->UpdateTiles(); 98 layer->UpdateTiles();
96 } 99 }
97 100
98 protected: 101 protected:
99 FakeImplTaskRunnerProvider task_runner_provider_; 102 FakeImplTaskRunnerProvider task_runner_provider_;
100 TestSharedBitmapManager shared_bitmap_manager_; 103 TestSharedBitmapManager shared_bitmap_manager_;
101 TestTaskGraphRunner task_graph_runner_; 104 TestTaskGraphRunner task_graph_runner_;
102 scoped_ptr<OutputSurface> output_surface_; 105 std::unique_ptr<OutputSurface> output_surface_;
103 FakeLayerTreeHostImpl host_impl_; 106 FakeLayerTreeHostImpl host_impl_;
104 }; 107 };
105 108
106 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { 109 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) {
107 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); 110 std::unique_ptr<TestablePictureImageLayerImpl> layer(
111 CreateLayer(1, PENDING_TREE));
108 layer->SetDrawsContent(true); 112 layer->SetDrawsContent(true);
109 113
110 TestablePictureImageLayerImpl* layer_ptr = layer.get(); 114 TestablePictureImageLayerImpl* layer_ptr = layer.get();
111 host_impl_.pending_tree()->SetRootLayer(std::move(layer)); 115 host_impl_.pending_tree()->SetRootLayer(std::move(layer));
112 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); 116 host_impl_.pending_tree()->BuildPropertyTreesForTesting();
113 117
114 gfx::Rect viewport(100, 200); 118 gfx::Rect viewport(100, 200);
115 SetupDrawPropertiesAndUpdateTiles(layer_ptr, 2.f, 3.f, 4.f, 1.f, false, 119 SetupDrawPropertiesAndUpdateTiles(layer_ptr, 2.f, 3.f, 4.f, 1.f, false,
116 viewport); 120 viewport);
117 EXPECT_FLOAT_EQ(1.f, layer_ptr->MaximumTilingContentsScale()); 121 EXPECT_FLOAT_EQ(1.f, layer_ptr->MaximumTilingContentsScale());
118 } 122 }
119 123
120 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { 124 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) {
121 scoped_ptr<TestablePictureImageLayerImpl> pending_layer( 125 std::unique_ptr<TestablePictureImageLayerImpl> pending_layer(
122 CreateLayer(1, PENDING_TREE)); 126 CreateLayer(1, PENDING_TREE));
123 pending_layer->SetDrawsContent(true); 127 pending_layer->SetDrawsContent(true);
124 128
125 gfx::Rect viewport(100, 200); 129 gfx::Rect viewport(100, 200);
126 130
127 TestablePictureImageLayerImpl* pending_layer_ptr = pending_layer.get(); 131 TestablePictureImageLayerImpl* pending_layer_ptr = pending_layer.get();
128 host_impl_.pending_tree()->SetRootLayer(std::move(pending_layer)); 132 host_impl_.pending_tree()->SetRootLayer(std::move(pending_layer));
129 host_impl_.pending_tree()->BuildPropertyTreesForTesting(); 133 host_impl_.pending_tree()->BuildPropertyTreesForTesting();
130 134
131 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal 135 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal
(...skipping 22 matching lines...) Expand all
154 maximum_animation_contents_scale, 158 maximum_animation_contents_scale,
155 animating_transform_to_screen, 159 animating_transform_to_screen,
156 viewport); 160 viewport);
157 EXPECT_EQ(1.f, active_layer->tilings()->tiling_at(0)->contents_scale()); 161 EXPECT_EQ(1.f, active_layer->tilings()->tiling_at(0)->contents_scale());
158 162
159 // Create resources for the tiles. 163 // Create resources for the tiles.
160 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting( 164 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(
161 active_layer->tilings()->tiling_at(0)->AllTilesForTesting()); 165 active_layer->tilings()->tiling_at(0)->AllTilesForTesting());
162 166
163 // Draw. 167 // Draw.
164 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 168 std::unique_ptr<RenderPass> render_pass = RenderPass::Create();
165 AppendQuadsData data; 169 AppendQuadsData data;
166 active_layer->WillDraw(DRAW_MODE_SOFTWARE, nullptr); 170 active_layer->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
167 active_layer->AppendQuads(render_pass.get(), &data); 171 active_layer->AppendQuads(render_pass.get(), &data);
168 active_layer->DidDraw(nullptr); 172 active_layer->DidDraw(nullptr);
169 173
170 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material); 174 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material);
171 175
172 // Tiles are ready at correct scale, so should not set had_incomplete_tile. 176 // Tiles are ready at correct scale, so should not set had_incomplete_tile.
173 EXPECT_EQ(0, data.num_incomplete_tiles); 177 EXPECT_EQ(0, data.num_incomplete_tiles);
174 } 178 }
175 179
176 } // namespace 180 } // namespace
177 } // namespace cc 181 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_image_layer_impl.cc ('k') | cc/layers/picture_image_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698