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

Side by Side Diff: cc/surfaces/surface_aggregator.cc

Issue 1883533008: Don't DCHECK on aggregating quads with noninvertible transforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « no previous file | cc/surfaces/surface_aggregator_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/surfaces/surface_aggregator.h" 5 #include "cc/surfaces/surface_aggregator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 10
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 target_transform); 306 target_transform);
307 307
308 ClipData new_clip_rect = CalculateClipRect( 308 ClipData new_clip_rect = CalculateClipRect(
309 clip_rect, ClipData(source_sqs->is_clipped, source_sqs->clip_rect), 309 clip_rect, ClipData(source_sqs->is_clipped, source_sqs->clip_rect),
310 target_transform); 310 target_transform);
311 copy_shared_quad_state->is_clipped = new_clip_rect.is_clipped; 311 copy_shared_quad_state->is_clipped = new_clip_rect.is_clipped;
312 copy_shared_quad_state->clip_rect = new_clip_rect.rect; 312 copy_shared_quad_state->clip_rect = new_clip_rect.rect;
313 return copy_shared_quad_state; 313 return copy_shared_quad_state;
314 } 314 }
315 315
316 static gfx::Rect CalculateQuadSpaceDamageRect( 316 // Returns true if the damage rect is valid.
317 static bool CalculateQuadSpaceDamageRect(
317 const gfx::Transform& quad_to_target_transform, 318 const gfx::Transform& quad_to_target_transform,
318 const gfx::Transform& target_to_root_transform, 319 const gfx::Transform& target_to_root_transform,
319 const gfx::Rect& root_damage_rect) { 320 const gfx::Rect& root_damage_rect,
321 gfx::Rect* quad_space_damage_rect) {
320 gfx::Transform quad_to_root_transform(target_to_root_transform, 322 gfx::Transform quad_to_root_transform(target_to_root_transform,
321 quad_to_target_transform); 323 quad_to_target_transform);
322 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); 324 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization);
323 bool inverse_valid = quad_to_root_transform.GetInverse(&inverse_transform); 325 bool inverse_valid = quad_to_root_transform.GetInverse(&inverse_transform);
324 DCHECK(inverse_valid); 326 if (!inverse_valid)
327 return false;
325 328
326 return MathUtil::ProjectEnclosingClippedRect(inverse_transform, 329 *quad_space_damage_rect = MathUtil::ProjectEnclosingClippedRect(
327 root_damage_rect); 330 inverse_transform, root_damage_rect);
331 return true;
328 } 332 }
329 333
330 void SurfaceAggregator::CopyQuadsToPass( 334 void SurfaceAggregator::CopyQuadsToPass(
331 const QuadList& source_quad_list, 335 const QuadList& source_quad_list,
332 const SharedQuadStateList& source_shared_quad_state_list, 336 const SharedQuadStateList& source_shared_quad_state_list,
333 const ResourceProvider::ResourceIdMap& child_to_parent_map, 337 const ResourceProvider::ResourceIdMap& child_to_parent_map,
334 const gfx::Transform& target_transform, 338 const gfx::Transform& target_transform,
335 const ClipData& clip_rect, 339 const ClipData& clip_rect,
336 RenderPass* dest_pass, 340 RenderPass* dest_pass,
337 SurfaceId surface_id) { 341 SurfaceId surface_id) {
338 const SharedQuadState* last_copied_source_shared_quad_state = nullptr; 342 const SharedQuadState* last_copied_source_shared_quad_state = nullptr;
339 const SharedQuadState* dest_shared_quad_state = nullptr; 343 const SharedQuadState* dest_shared_quad_state = nullptr;
340 // If the current frame has copy requests then aggregate the entire 344 // If the current frame has copy requests then aggregate the entire
341 // thing, as otherwise parts of the copy requests may be ignored. 345 // thing, as otherwise parts of the copy requests may be ignored.
342 const bool ignore_undamaged = aggregate_only_damaged_ && !has_copy_requests_; 346 const bool ignore_undamaged = aggregate_only_damaged_ && !has_copy_requests_;
343 // Damage rect in the quad space of the current shared quad state. 347 // Damage rect in the quad space of the current shared quad state.
344 // TODO(jbauman): This rect may contain unnecessary area if 348 // TODO(jbauman): This rect may contain unnecessary area if
345 // transform isn't axis-aligned. 349 // transform isn't axis-aligned.
346 gfx::Rect damage_rect_in_quad_space; 350 gfx::Rect damage_rect_in_quad_space;
351 bool damage_rect_in_quad_space_valid = false;
347 352
348 #if DCHECK_IS_ON() 353 #if DCHECK_IS_ON()
349 // If quads have come in with SharedQuadState out of order, or when quads have 354 // If quads have come in with SharedQuadState out of order, or when quads have
350 // invalid SharedQuadState pointer, it should DCHECK. 355 // invalid SharedQuadState pointer, it should DCHECK.
351 SharedQuadStateList::ConstIterator sqs_iter = 356 SharedQuadStateList::ConstIterator sqs_iter =
352 source_shared_quad_state_list.begin(); 357 source_shared_quad_state_list.begin();
353 for (const auto& quad : source_quad_list) { 358 for (const auto& quad : source_quad_list) {
354 while (sqs_iter != source_shared_quad_state_list.end() && 359 while (sqs_iter != source_shared_quad_state_list.end() &&
355 quad->shared_quad_state != *sqs_iter) { 360 quad->shared_quad_state != *sqs_iter) {
356 ++sqs_iter; 361 ++sqs_iter;
357 } 362 }
358 DCHECK(sqs_iter != source_shared_quad_state_list.end()); 363 DCHECK(sqs_iter != source_shared_quad_state_list.end());
359 } 364 }
360 #endif 365 #endif
361 366
362 for (const auto& quad : source_quad_list) { 367 for (const auto& quad : source_quad_list) {
363 if (quad->material == DrawQuad::SURFACE_CONTENT) { 368 if (quad->material == DrawQuad::SURFACE_CONTENT) {
364 const SurfaceDrawQuad* surface_quad = SurfaceDrawQuad::MaterialCast(quad); 369 const SurfaceDrawQuad* surface_quad = SurfaceDrawQuad::MaterialCast(quad);
365 // HandleSurfaceQuad may add other shared quad state, so reset the 370 // HandleSurfaceQuad may add other shared quad state, so reset the
366 // current data. 371 // current data.
367 last_copied_source_shared_quad_state = nullptr; 372 last_copied_source_shared_quad_state = nullptr;
368 373
369 if (ignore_undamaged) { 374 if (ignore_undamaged) {
370 gfx::Transform quad_to_target_transform( 375 gfx::Transform quad_to_target_transform(
371 target_transform, 376 target_transform,
372 quad->shared_quad_state->quad_to_target_transform); 377 quad->shared_quad_state->quad_to_target_transform);
373 damage_rect_in_quad_space = CalculateQuadSpaceDamageRect( 378 damage_rect_in_quad_space_valid = CalculateQuadSpaceDamageRect(
374 quad_to_target_transform, dest_pass->transform_to_root_target, 379 quad_to_target_transform, dest_pass->transform_to_root_target,
375 root_damage_rect_); 380 root_damage_rect_, &damage_rect_in_quad_space);
376 if (!damage_rect_in_quad_space.Intersects(quad->visible_rect)) 381 if (damage_rect_in_quad_space_valid &&
danakj 2016/04/13 22:32:46 Do you want to draw quads with non-invertible dama
382 !damage_rect_in_quad_space.Intersects(quad->visible_rect))
377 continue; 383 continue;
378 } 384 }
379 HandleSurfaceQuad(surface_quad, target_transform, clip_rect, dest_pass); 385 HandleSurfaceQuad(surface_quad, target_transform, clip_rect, dest_pass);
380 } else { 386 } else {
381 if (quad->shared_quad_state != last_copied_source_shared_quad_state) { 387 if (quad->shared_quad_state != last_copied_source_shared_quad_state) {
382 dest_shared_quad_state = CopySharedQuadState( 388 dest_shared_quad_state = CopySharedQuadState(
383 quad->shared_quad_state, target_transform, clip_rect, dest_pass); 389 quad->shared_quad_state, target_transform, clip_rect, dest_pass);
384 last_copied_source_shared_quad_state = quad->shared_quad_state; 390 last_copied_source_shared_quad_state = quad->shared_quad_state;
385 if (aggregate_only_damaged_ && !has_copy_requests_) { 391 if (aggregate_only_damaged_ && !has_copy_requests_) {
386 damage_rect_in_quad_space = CalculateQuadSpaceDamageRect( 392 damage_rect_in_quad_space_valid = CalculateQuadSpaceDamageRect(
387 dest_shared_quad_state->quad_to_target_transform, 393 dest_shared_quad_state->quad_to_target_transform,
388 dest_pass->transform_to_root_target, root_damage_rect_); 394 dest_pass->transform_to_root_target, root_damage_rect_,
395 &damage_rect_in_quad_space);
389 } 396 }
390 } 397 }
391 398
392 if (ignore_undamaged) { 399 if (ignore_undamaged) {
393 if (!damage_rect_in_quad_space.Intersects(quad->visible_rect)) 400 if (damage_rect_in_quad_space_valid &&
401 !damage_rect_in_quad_space.Intersects(quad->visible_rect))
394 continue; 402 continue;
395 } 403 }
396 404
397 DrawQuad* dest_quad; 405 DrawQuad* dest_quad;
398 if (quad->material == DrawQuad::RENDER_PASS) { 406 if (quad->material == DrawQuad::RENDER_PASS) {
399 const RenderPassDrawQuad* pass_quad = 407 const RenderPassDrawQuad* pass_quad =
400 RenderPassDrawQuad::MaterialCast(quad); 408 RenderPassDrawQuad::MaterialCast(quad);
401 RenderPassId original_pass_id = pass_quad->render_pass_id; 409 RenderPassId original_pass_id = pass_quad->render_pass_id;
402 RenderPassId remapped_pass_id = 410 RenderPassId remapped_pass_id =
403 RemapPassId(original_pass_id, surface_id); 411 RemapPassId(original_pass_id, surface_id);
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 719
712 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) { 720 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) {
713 auto it = previous_contained_surfaces_.find(surface_id); 721 auto it = previous_contained_surfaces_.find(surface_id);
714 if (it == previous_contained_surfaces_.end()) 722 if (it == previous_contained_surfaces_.end())
715 return; 723 return;
716 // Set the last drawn index as 0 to ensure full damage next time it's drawn. 724 // Set the last drawn index as 0 to ensure full damage next time it's drawn.
717 it->second = 0; 725 it->second = 0;
718 } 726 }
719 727
720 } // namespace cc 728 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/surface_aggregator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698