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

Side by Side Diff: cc/quads/render_pass_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/quads/render_pass_draw_quad.h ('k') | cc/quads/shared_quad_state.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/quads/render_pass.h" 5 #include "cc/quads/render_pass.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
10 #include "cc/output/copy_output_request.h" 11 #include "cc/output/copy_output_request.h"
11 #include "cc/quads/render_pass_draw_quad.h" 12 #include "cc/quads/render_pass_draw_quad.h"
12 #include "cc/quads/solid_color_draw_quad.h" 13 #include "cc/quads/solid_color_draw_quad.h"
13 #include "cc/test/geometry_test_utils.h" 14 #include "cc/test/geometry_test_utils.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/skia/include/effects/SkBlurImageFilter.h" 16 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
16 #include "ui/gfx/transform.h" 17 #include "ui/gfx/transform.h"
17 18
18 namespace cc { 19 namespace cc {
19 namespace { 20 namespace {
20 21
21 struct RenderPassSize { 22 struct RenderPassSize {
22 // If you add a new field to this class, make sure to add it to the 23 // If you add a new field to this class, make sure to add it to the
23 // Copy() tests. 24 // Copy() tests.
24 RenderPassId id; 25 RenderPassId id;
25 QuadList quad_list; 26 QuadList quad_list;
26 SharedQuadStateList shared_quad_state_list; 27 SharedQuadStateList shared_quad_state_list;
27 gfx::Transform transform_to_root_target; 28 gfx::Transform transform_to_root_target;
28 gfx::Rect output_rect; 29 gfx::Rect output_rect;
29 gfx::Rect damage_rect; 30 gfx::Rect damage_rect;
30 bool has_transparent_background; 31 bool has_transparent_background;
31 std::vector<scoped_ptr<CopyOutputRequest>> copy_callbacks; 32 std::vector<std::unique_ptr<CopyOutputRequest>> copy_callbacks;
32 }; 33 };
33 34
34 static void CompareRenderPassLists(const RenderPassList& expected_list, 35 static void CompareRenderPassLists(const RenderPassList& expected_list,
35 const RenderPassList& actual_list) { 36 const RenderPassList& actual_list) {
36 EXPECT_EQ(expected_list.size(), actual_list.size()); 37 EXPECT_EQ(expected_list.size(), actual_list.size());
37 for (size_t i = 0; i < actual_list.size(); ++i) { 38 for (size_t i = 0; i < actual_list.size(); ++i) {
38 RenderPass* expected = expected_list[i].get(); 39 RenderPass* expected = expected_list[i].get();
39 RenderPass* actual = actual_list[i].get(); 40 RenderPass* actual = actual_list[i].get();
40 41
41 EXPECT_EQ(expected->id, actual->id); 42 EXPECT_EQ(expected->id, actual->id);
(...skipping 20 matching lines...) Expand all
62 } 63 }
63 64
64 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { 65 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) {
65 RenderPassId id(3, 2); 66 RenderPassId id(3, 2);
66 gfx::Rect output_rect(45, 22, 120, 13); 67 gfx::Rect output_rect(45, 22, 120, 13);
67 gfx::Transform transform_to_root = 68 gfx::Transform transform_to_root =
68 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 69 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
69 gfx::Rect damage_rect(56, 123, 19, 43); 70 gfx::Rect damage_rect(56, 123, 19, 43);
70 bool has_transparent_background = true; 71 bool has_transparent_background = true;
71 72
72 scoped_ptr<RenderPass> pass = RenderPass::Create(); 73 std::unique_ptr<RenderPass> pass = RenderPass::Create();
73 pass->SetAll(id, 74 pass->SetAll(id,
74 output_rect, 75 output_rect,
75 damage_rect, 76 damage_rect,
76 transform_to_root, 77 transform_to_root,
77 has_transparent_background); 78 has_transparent_background);
78 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); 79 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest());
79 80
80 // Stick a quad in the pass, this should not get copied. 81 // Stick a quad in the pass, this should not get copied.
81 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); 82 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState();
82 shared_state->SetAll(gfx::Transform(), 83 shared_state->SetAll(gfx::Transform(),
83 gfx::Size(), 84 gfx::Size(),
84 gfx::Rect(), 85 gfx::Rect(),
85 gfx::Rect(), 86 gfx::Rect(),
86 false, 87 false,
87 1, 88 1,
88 SkXfermode::kSrcOver_Mode, 89 SkXfermode::kSrcOver_Mode,
89 0); 90 0);
90 91
91 SolidColorDrawQuad* color_quad = 92 SolidColorDrawQuad* color_quad =
92 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 93 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
93 color_quad->SetNew(pass->shared_quad_state_list.back(), gfx::Rect(), 94 color_quad->SetNew(pass->shared_quad_state_list.back(), gfx::Rect(),
94 gfx::Rect(), SkColor(), false); 95 gfx::Rect(), SkColor(), false);
95 96
96 RenderPassId new_id(63, 4); 97 RenderPassId new_id(63, 4);
97 98
98 scoped_ptr<RenderPass> copy = pass->Copy(new_id); 99 std::unique_ptr<RenderPass> copy = pass->Copy(new_id);
99 EXPECT_EQ(new_id, copy->id); 100 EXPECT_EQ(new_id, copy->id);
100 EXPECT_EQ(pass->output_rect, copy->output_rect); 101 EXPECT_EQ(pass->output_rect, copy->output_rect);
101 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); 102 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target);
102 EXPECT_EQ(pass->damage_rect, copy->damage_rect); 103 EXPECT_EQ(pass->damage_rect, copy->damage_rect);
103 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); 104 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background);
104 EXPECT_EQ(0u, copy->quad_list.size()); 105 EXPECT_EQ(0u, copy->quad_list.size());
105 106
106 // The copy request should not be copied/duplicated. 107 // The copy request should not be copied/duplicated.
107 EXPECT_EQ(1u, pass->copy_requests.size()); 108 EXPECT_EQ(1u, pass->copy_requests.size());
108 EXPECT_EQ(0u, copy->copy_requests.size()); 109 EXPECT_EQ(0u, copy->copy_requests.size());
109 110
110 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); 111 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass));
111 } 112 }
112 113
113 TEST(RenderPassTest, CopyAllShouldBeIdentical) { 114 TEST(RenderPassTest, CopyAllShouldBeIdentical) {
114 RenderPassList pass_list; 115 RenderPassList pass_list;
115 116
116 RenderPassId id(3, 2); 117 RenderPassId id(3, 2);
117 gfx::Rect output_rect(45, 22, 120, 13); 118 gfx::Rect output_rect(45, 22, 120, 13);
118 gfx::Transform transform_to_root = 119 gfx::Transform transform_to_root =
119 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 120 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
120 gfx::Rect damage_rect(56, 123, 19, 43); 121 gfx::Rect damage_rect(56, 123, 19, 43);
121 bool has_transparent_background = true; 122 bool has_transparent_background = true;
122 123
123 scoped_ptr<RenderPass> pass = RenderPass::Create(); 124 std::unique_ptr<RenderPass> pass = RenderPass::Create();
124 pass->SetAll(id, 125 pass->SetAll(id,
125 output_rect, 126 output_rect,
126 damage_rect, 127 damage_rect,
127 transform_to_root, 128 transform_to_root,
128 has_transparent_background); 129 has_transparent_background);
129 130
130 // Two quads using one shared state. 131 // Two quads using one shared state.
131 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); 132 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState();
132 shared_state1->SetAll(gfx::Transform(), 133 shared_state1->SetAll(gfx::Transform(),
133 gfx::Size(1, 1), 134 gfx::Size(1, 1),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 false); 175 false);
175 176
176 // A second render pass with a quad. 177 // A second render pass with a quad.
177 RenderPassId contrib_id(4, 1); 178 RenderPassId contrib_id(4, 1);
178 gfx::Rect contrib_output_rect(10, 15, 12, 17); 179 gfx::Rect contrib_output_rect(10, 15, 12, 17);
179 gfx::Transform contrib_transform_to_root = 180 gfx::Transform contrib_transform_to_root =
180 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 181 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
181 gfx::Rect contrib_damage_rect(11, 16, 10, 15); 182 gfx::Rect contrib_damage_rect(11, 16, 10, 15);
182 bool contrib_has_transparent_background = true; 183 bool contrib_has_transparent_background = true;
183 184
184 scoped_ptr<RenderPass> contrib = RenderPass::Create(); 185 std::unique_ptr<RenderPass> contrib = RenderPass::Create();
185 contrib->SetAll(contrib_id, 186 contrib->SetAll(contrib_id,
186 contrib_output_rect, 187 contrib_output_rect,
187 contrib_damage_rect, 188 contrib_damage_rect,
188 contrib_transform_to_root, 189 contrib_transform_to_root,
189 contrib_has_transparent_background); 190 contrib_has_transparent_background);
190 191
191 SharedQuadState* contrib_shared_state = 192 SharedQuadState* contrib_shared_state =
192 contrib->CreateAndAppendSharedQuadState(); 193 contrib->CreateAndAppendSharedQuadState();
193 contrib_shared_state->SetAll(gfx::Transform(), 194 contrib_shared_state->SetAll(gfx::Transform(),
194 gfx::Size(2, 2), 195 gfx::Size(2, 2),
195 gfx::Rect(), 196 gfx::Rect(),
196 gfx::Rect(), 197 gfx::Rect(),
197 false, 198 false,
198 1, 199 1,
199 SkXfermode::kSrcOver_Mode, 200 SkXfermode::kSrcOver_Mode,
200 0); 201 0);
201 202
202 SolidColorDrawQuad* contrib_quad = 203 SolidColorDrawQuad* contrib_quad =
203 contrib->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 204 contrib->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
204 contrib_quad->SetNew(contrib->shared_quad_state_list.back(), 205 contrib_quad->SetNew(contrib->shared_quad_state_list.back(),
205 gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(), 206 gfx::Rect(3, 3, 3, 3), gfx::Rect(3, 3, 3, 3), SkColor(),
206 false); 207 false);
207 208
208 // And a RenderPassDrawQuad for the contributing pass. 209 // And a RenderPassDrawQuad for the contributing pass.
209 scoped_ptr<RenderPassDrawQuad> pass_quad = 210 std::unique_ptr<RenderPassDrawQuad> pass_quad =
210 make_scoped_ptr(new RenderPassDrawQuad); 211 base::WrapUnique(new RenderPassDrawQuad);
211 pass_quad->SetNew(pass->shared_quad_state_list.back(), 212 pass_quad->SetNew(pass->shared_quad_state_list.back(),
212 contrib_output_rect, 213 contrib_output_rect,
213 contrib_output_rect, 214 contrib_output_rect,
214 contrib_id, 215 contrib_id,
215 0, 216 0,
216 gfx::Vector2dF(), 217 gfx::Vector2dF(),
217 gfx::Size(), 218 gfx::Size(),
218 FilterOperations(), 219 FilterOperations(),
219 gfx::Vector2dF(), 220 gfx::Vector2dF(),
220 FilterOperations()); 221 FilterOperations());
(...skipping 11 matching lines...) Expand all
232 TEST(RenderPassTest, CopyAllWithCulledQuads) { 233 TEST(RenderPassTest, CopyAllWithCulledQuads) {
233 RenderPassList pass_list; 234 RenderPassList pass_list;
234 235
235 RenderPassId id(3, 2); 236 RenderPassId id(3, 2);
236 gfx::Rect output_rect(45, 22, 120, 13); 237 gfx::Rect output_rect(45, 22, 120, 13);
237 gfx::Transform transform_to_root = 238 gfx::Transform transform_to_root =
238 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 239 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
239 gfx::Rect damage_rect(56, 123, 19, 43); 240 gfx::Rect damage_rect(56, 123, 19, 43);
240 bool has_transparent_background = true; 241 bool has_transparent_background = true;
241 242
242 scoped_ptr<RenderPass> pass = RenderPass::Create(); 243 std::unique_ptr<RenderPass> pass = RenderPass::Create();
243 pass->SetAll(id, 244 pass->SetAll(id,
244 output_rect, 245 output_rect,
245 damage_rect, 246 damage_rect,
246 transform_to_root, 247 transform_to_root,
247 has_transparent_background); 248 has_transparent_background);
248 249
249 // A shared state with a quad. 250 // A shared state with a quad.
250 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); 251 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState();
251 shared_state1->SetAll(gfx::Transform(), 252 shared_state1->SetAll(gfx::Transform(),
252 gfx::Size(1, 1), 253 gfx::Size(1, 1),
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 307
307 // Make a copy with CopyAll(). 308 // Make a copy with CopyAll().
308 RenderPassList copy_list; 309 RenderPassList copy_list;
309 RenderPass::CopyAll(pass_list, &copy_list); 310 RenderPass::CopyAll(pass_list, &copy_list);
310 311
311 CompareRenderPassLists(pass_list, copy_list); 312 CompareRenderPassLists(pass_list, copy_list);
312 } 313 }
313 314
314 } // namespace 315 } // namespace
315 } // namespace cc 316 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/render_pass_draw_quad.h ('k') | cc/quads/shared_quad_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698