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

Side by Side Diff: cc/quads/render_pass_unittest.cc

Issue 2873593002: Force use of and cache render surface. (Closed)
Patch Set: Fix test to init has_damage_from_contributing_content_. Created 3 years, 5 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
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 "base/memory/ptr_util.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 gfx::Rect output_rect(45, 22, 120, 13); 72 gfx::Rect output_rect(45, 22, 120, 13);
73 gfx::Transform transform_to_root = 73 gfx::Transform transform_to_root =
74 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 74 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
75 gfx::Rect damage_rect(56, 123, 19, 43); 75 gfx::Rect damage_rect(56, 123, 19, 43);
76 FilterOperations filters; 76 FilterOperations filters;
77 filters.Append(FilterOperation::CreateOpacityFilter(0.5)); 77 filters.Append(FilterOperation::CreateOpacityFilter(0.5));
78 FilterOperations background_filters; 78 FilterOperations background_filters;
79 background_filters.Append(FilterOperation::CreateInvertFilter(1.0)); 79 background_filters.Append(FilterOperation::CreateInvertFilter(1.0));
80 gfx::ColorSpace color_space = gfx::ColorSpace::CreateSRGB(); 80 gfx::ColorSpace color_space = gfx::ColorSpace::CreateSRGB();
81 bool has_transparent_background = true; 81 bool has_transparent_background = true;
82 bool should_cache_render_surface = false;
83 bool has_damage_from_contributing_content = false;
82 84
83 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 85 std::unique_ptr<RenderPass> pass = RenderPass::Create();
84 pass->SetAll(render_pass_id, output_rect, damage_rect, transform_to_root, 86 pass->SetAll(render_pass_id, output_rect, damage_rect, transform_to_root,
85 filters, background_filters, color_space, 87 filters, background_filters, color_space,
86 has_transparent_background); 88 has_transparent_background, should_cache_render_surface,
89 has_damage_from_contributing_content);
87 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); 90 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest());
88 91
89 // Stick a quad in the pass, this should not get copied. 92 // Stick a quad in the pass, this should not get copied.
90 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); 93 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState();
91 shared_state->SetAll(gfx::Transform(), gfx::Rect(), gfx::Rect(), gfx::Rect(), 94 shared_state->SetAll(gfx::Transform(), gfx::Rect(), gfx::Rect(), gfx::Rect(),
92 false, 1, SkBlendMode::kSrcOver, 0); 95 false, 1, SkBlendMode::kSrcOver, 0);
93 96
94 SolidColorDrawQuad* color_quad = 97 SolidColorDrawQuad* color_quad =
95 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 98 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
96 color_quad->SetNew(pass->shared_quad_state_list.back(), gfx::Rect(), 99 color_quad->SetNew(pass->shared_quad_state_list.back(), gfx::Rect(),
(...skipping 25 matching lines...) Expand all
122 gfx::Rect output_rect(45, 22, 120, 13); 125 gfx::Rect output_rect(45, 22, 120, 13);
123 gfx::Transform transform_to_root = 126 gfx::Transform transform_to_root =
124 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 127 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
125 gfx::Rect damage_rect(56, 123, 19, 43); 128 gfx::Rect damage_rect(56, 123, 19, 43);
126 FilterOperations filters; 129 FilterOperations filters;
127 filters.Append(FilterOperation::CreateOpacityFilter(0.5)); 130 filters.Append(FilterOperation::CreateOpacityFilter(0.5));
128 FilterOperations background_filters; 131 FilterOperations background_filters;
129 background_filters.Append(FilterOperation::CreateInvertFilter(1.0)); 132 background_filters.Append(FilterOperation::CreateInvertFilter(1.0));
130 gfx::ColorSpace color_space = gfx::ColorSpace::CreateXYZD50(); 133 gfx::ColorSpace color_space = gfx::ColorSpace::CreateXYZD50();
131 bool has_transparent_background = true; 134 bool has_transparent_background = true;
135 bool should_cache_render_surface = false;
136 bool has_damage_from_contributing_content = false;
132 137
133 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 138 std::unique_ptr<RenderPass> pass = RenderPass::Create();
134 pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, 139 pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters,
135 background_filters, color_space, has_transparent_background); 140 background_filters, color_space, has_transparent_background,
141 should_cache_render_surface,
142 has_damage_from_contributing_content);
136 143
137 // Two quads using one shared state. 144 // Two quads using one shared state.
138 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); 145 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState();
139 shared_state1->SetAll(gfx::Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(), 146 shared_state1->SetAll(gfx::Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(),
140 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0); 147 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0);
141 148
142 SolidColorDrawQuad* color_quad1 = 149 SolidColorDrawQuad* color_quad1 =
143 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 150 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
144 color_quad1->SetNew(pass->shared_quad_state_list.back(), 151 color_quad1->SetNew(pass->shared_quad_state_list.back(),
145 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(), 152 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(),
(...skipping 27 matching lines...) Expand all
173 gfx::Rect contrib_output_rect(10, 15, 12, 17); 180 gfx::Rect contrib_output_rect(10, 15, 12, 17);
174 gfx::Transform contrib_transform_to_root = 181 gfx::Transform contrib_transform_to_root =
175 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 182 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
176 gfx::Rect contrib_damage_rect(11, 16, 10, 15); 183 gfx::Rect contrib_damage_rect(11, 16, 10, 15);
177 FilterOperations contrib_filters; 184 FilterOperations contrib_filters;
178 contrib_filters.Append(FilterOperation::CreateSepiaFilter(0.5)); 185 contrib_filters.Append(FilterOperation::CreateSepiaFilter(0.5));
179 FilterOperations contrib_background_filters; 186 FilterOperations contrib_background_filters;
180 contrib_background_filters.Append(FilterOperation::CreateSaturateFilter(1)); 187 contrib_background_filters.Append(FilterOperation::CreateSaturateFilter(1));
181 gfx::ColorSpace contrib_color_space = gfx::ColorSpace::CreateSCRGBLinear(); 188 gfx::ColorSpace contrib_color_space = gfx::ColorSpace::CreateSCRGBLinear();
182 bool contrib_has_transparent_background = true; 189 bool contrib_has_transparent_background = true;
190 bool contrib_should_cache_render_surface = false;
191 bool contrib_has_damage_from_contributing_content = false;
183 192
184 std::unique_ptr<RenderPass> contrib = RenderPass::Create(); 193 std::unique_ptr<RenderPass> contrib = RenderPass::Create();
185 contrib->SetAll(contrib_id, contrib_output_rect, contrib_damage_rect, 194 contrib->SetAll(contrib_id, contrib_output_rect, contrib_damage_rect,
186 contrib_transform_to_root, contrib_filters, 195 contrib_transform_to_root, contrib_filters,
187 contrib_background_filters, contrib_color_space, 196 contrib_background_filters, contrib_color_space,
188 contrib_has_transparent_background); 197 contrib_has_transparent_background,
198 contrib_should_cache_render_surface,
199 contrib_has_damage_from_contributing_content);
189 200
190 SharedQuadState* contrib_shared_state = 201 SharedQuadState* contrib_shared_state =
191 contrib->CreateAndAppendSharedQuadState(); 202 contrib->CreateAndAppendSharedQuadState();
192 contrib_shared_state->SetAll(gfx::Transform(), gfx::Rect(0, 0, 2, 2), 203 contrib_shared_state->SetAll(gfx::Transform(), gfx::Rect(0, 0, 2, 2),
193 gfx::Rect(), gfx::Rect(), false, 1, 204 gfx::Rect(), gfx::Rect(), false, 1,
194 SkBlendMode::kSrcOver, 0); 205 SkBlendMode::kSrcOver, 0);
195 206
196 SolidColorDrawQuad* contrib_quad = 207 SolidColorDrawQuad* contrib_quad =
197 contrib->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 208 contrib->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
198 contrib_quad->SetNew(contrib->shared_quad_state_list.back(), 209 contrib_quad->SetNew(contrib->shared_quad_state_list.back(),
(...skipping 24 matching lines...) Expand all
223 gfx::Rect output_rect(45, 22, 120, 13); 234 gfx::Rect output_rect(45, 22, 120, 13);
224 gfx::Transform transform_to_root = 235 gfx::Transform transform_to_root =
225 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); 236 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0);
226 gfx::Rect damage_rect(56, 123, 19, 43); 237 gfx::Rect damage_rect(56, 123, 19, 43);
227 FilterOperations filters; 238 FilterOperations filters;
228 filters.Append(FilterOperation::CreateOpacityFilter(0.5)); 239 filters.Append(FilterOperation::CreateOpacityFilter(0.5));
229 FilterOperations background_filters; 240 FilterOperations background_filters;
230 background_filters.Append(FilterOperation::CreateInvertFilter(1.0)); 241 background_filters.Append(FilterOperation::CreateInvertFilter(1.0));
231 gfx::ColorSpace color_space = gfx::ColorSpace::CreateSCRGBLinear(); 242 gfx::ColorSpace color_space = gfx::ColorSpace::CreateSCRGBLinear();
232 bool has_transparent_background = true; 243 bool has_transparent_background = true;
244 bool should_cache_render_surface = false;
245 bool has_damage_from_contributing_content = false;
233 246
234 std::unique_ptr<RenderPass> pass = RenderPass::Create(); 247 std::unique_ptr<RenderPass> pass = RenderPass::Create();
235 pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters, 248 pass->SetAll(id, output_rect, damage_rect, transform_to_root, filters,
236 background_filters, color_space, has_transparent_background); 249 background_filters, color_space, has_transparent_background,
250 should_cache_render_surface,
251 has_damage_from_contributing_content);
237 252
238 // A shared state with a quad. 253 // A shared state with a quad.
239 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); 254 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState();
240 shared_state1->SetAll(gfx::Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(), 255 shared_state1->SetAll(gfx::Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(),
241 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0); 256 gfx::Rect(), false, 1, SkBlendMode::kSrcOver, 0);
242 257
243 SolidColorDrawQuad* color_quad1 = 258 SolidColorDrawQuad* color_quad1 =
244 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 259 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
245 color_quad1->SetNew(pass->shared_quad_state_list.back(), 260 color_quad1->SetNew(pass->shared_quad_state_list.back(),
246 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(), 261 gfx::Rect(1, 1, 1, 1), gfx::Rect(1, 1, 1, 1), SkColor(),
(...skipping 24 matching lines...) Expand all
271 286
272 // Make a copy with CopyAll(). 287 // Make a copy with CopyAll().
273 RenderPassList copy_list; 288 RenderPassList copy_list;
274 RenderPass::CopyAll(pass_list, &copy_list); 289 RenderPass::CopyAll(pass_list, &copy_list);
275 290
276 CompareRenderPassLists(pass_list, copy_list); 291 CompareRenderPassLists(pass_list, copy_list);
277 } 292 }
278 293
279 } // namespace 294 } // namespace
280 } // namespace cc 295 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698