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

Side by Side Diff: cc/trees/damage_tracker.cc

Issue 1976413002: cc : Fix damage rect bug caused by deletion of render surface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« cc/trees/damage_tracker.h ('K') | « cc/trees/damage_tracker.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/damage_tracker.h" 5 #include "cc/trees/damage_tracker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 // 273 //
274 // This method is called when we want to consider how a layer contributes to 274 // This method is called when we want to consider how a layer contributes to
275 // its target RenderSurface, even if that layer owns the target RenderSurface 275 // its target RenderSurface, even if that layer owns the target RenderSurface
276 // itself. To consider how a layer's target surface contributes to the 276 // itself. To consider how a layer's target surface contributes to the
277 // ancestor surface, ExtendDamageForRenderSurface() must be called instead. 277 // ancestor surface, ExtendDamageForRenderSurface() must be called instead.
278 278
279 bool layer_is_new = false; 279 bool layer_is_new = false;
280 RectMapData& data = RectDataForLayer(layer->id(), &layer_is_new); 280 RectMapData& data = RectDataForLayer(layer->id(), &layer_is_new);
281 gfx::Rect old_rect_in_target_space = data.rect_; 281 gfx::Rect old_rect_in_target_space = data.rect_;
282 282
283 if (!layer_is_new && data.is_render_surface_) {
284 // This was a render surface in the previous frame. Since the surface is now
285 // removed, we need to add it the damage rect.
286 target_damage_rect->Union(data.rect_);
287 }
283 gfx::Rect rect_in_target_space = layer->GetEnclosingRectInTargetSpace(); 288 gfx::Rect rect_in_target_space = layer->GetEnclosingRectInTargetSpace();
284 data.Update(rect_in_target_space, mailboxId_); 289 data.Update(rect_in_target_space, mailboxId_, false /*is_render_surface*/);
285 290
286 if (layer_is_new || layer->LayerPropertyChanged()) { 291 if (layer_is_new || layer->LayerPropertyChanged()) {
287 // If a layer is new or has changed, then its entire layer rect affects the 292 // If a layer is new or has changed, then its entire layer rect affects the
288 // target surface. 293 // target surface.
289 target_damage_rect->Union(rect_in_target_space); 294 target_damage_rect->Union(rect_in_target_space);
290 295
291 // The layer's old region is now exposed on the target surface, too. 296 // The layer's old region is now exposed on the target surface, too.
292 // Note old_rect_in_target_space is already in target space. 297 // Note old_rect_in_target_space is already in target space.
293 target_damage_rect->Union(old_rect_in_target_space); 298 target_damage_rect->Union(old_rect_in_target_space);
294 return; 299 return;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 331
327 RenderSurfaceImpl* render_surface = layer->render_surface(); 332 RenderSurfaceImpl* render_surface = layer->render_surface();
328 333
329 bool surface_is_new = false; 334 bool surface_is_new = false;
330 RectMapData& data = RectDataForLayer(layer->id(), &surface_is_new); 335 RectMapData& data = RectDataForLayer(layer->id(), &surface_is_new);
331 gfx::Rect old_surface_rect = data.rect_; 336 gfx::Rect old_surface_rect = data.rect_;
332 337
333 // The drawableContextRect() already includes the replica if it exists. 338 // The drawableContextRect() already includes the replica if it exists.
334 gfx::Rect surface_rect_in_target_space = 339 gfx::Rect surface_rect_in_target_space =
335 gfx::ToEnclosingRect(render_surface->DrawableContentRect()); 340 gfx::ToEnclosingRect(render_surface->DrawableContentRect());
336 data.Update(surface_rect_in_target_space, mailboxId_); 341 data.Update(surface_rect_in_target_space, mailboxId_,
342 true /*is_render_surface*/);
337 343
338 if (surface_is_new || render_surface->SurfacePropertyChanged()) { 344 if (surface_is_new || render_surface->SurfacePropertyChanged()) {
339 // The entire surface contributes damage. 345 // The entire surface contributes damage.
340 target_damage_rect->Union(surface_rect_in_target_space); 346 target_damage_rect->Union(surface_rect_in_target_space);
341 347
342 // The surface's old region is now exposed on the target surface, too. 348 // The surface's old region is now exposed on the target surface, too.
343 target_damage_rect->Union(old_surface_rect); 349 target_damage_rect->Union(old_surface_rect);
344 } else { 350 } else {
345 // Only the surface's damage_rect will damage the target surface. 351 // Only the surface's damage_rect will damage the target surface.
346 gfx::Rect damage_rect_in_local_space = 352 gfx::Rect damage_rect_in_local_space =
(...skipping 22 matching lines...) Expand all
369 LayerImpl* replica_mask_layer = layer->replica_layer()->mask_layer(); 375 LayerImpl* replica_mask_layer = layer->replica_layer()->mask_layer();
370 376
371 bool replica_is_new = false; 377 bool replica_is_new = false;
372 RectMapData& data = 378 RectMapData& data =
373 RectDataForLayer(replica_mask_layer->id(), &replica_is_new); 379 RectDataForLayer(replica_mask_layer->id(), &replica_is_new);
374 380
375 const gfx::Transform& replica_draw_transform = 381 const gfx::Transform& replica_draw_transform =
376 render_surface->replica_draw_transform(); 382 render_surface->replica_draw_transform();
377 gfx::Rect replica_mask_layer_rect = MathUtil::MapEnclosingClippedRect( 383 gfx::Rect replica_mask_layer_rect = MathUtil::MapEnclosingClippedRect(
378 replica_draw_transform, gfx::Rect(replica_mask_layer->bounds())); 384 replica_draw_transform, gfx::Rect(replica_mask_layer->bounds()));
379 data.Update(replica_mask_layer_rect, mailboxId_); 385 data.Update(replica_mask_layer_rect, mailboxId_,
386 false /*is_render_surface*/);
380 387
381 // In the current implementation, a change in the replica mask damages the 388 // In the current implementation, a change in the replica mask damages the
382 // entire replica region. 389 // entire replica region.
383 if (replica_is_new || 390 if (replica_is_new ||
384 replica_mask_layer->LayerPropertyChanged() || 391 replica_mask_layer->LayerPropertyChanged() ||
385 !replica_mask_layer->update_rect().IsEmpty()) 392 !replica_mask_layer->update_rect().IsEmpty())
386 target_damage_rect->Union(replica_mask_layer_rect); 393 target_damage_rect->Union(replica_mask_layer_rect);
387 } 394 }
388 395
389 // If the layer has a background filter, this may cause pixels in our surface 396 // If the layer has a background filter, this may cause pixels in our surface
390 // to be expanded, so we will need to expand any damage at or below this 397 // to be expanded, so we will need to expand any damage at or below this
391 // layer. We expand the damage from this layer too, as we need to readback 398 // layer. We expand the damage from this layer too, as we need to readback
392 // those pixels from the surface with only the contents of layers below this 399 // those pixels from the surface with only the contents of layers below this
393 // one in them. This means we need to redraw any pixels in the surface being 400 // one in them. This means we need to redraw any pixels in the surface being
394 // used for the blur in this layer this frame. 401 // used for the blur in this layer this frame.
395 if (layer->background_filters().HasFilterThatMovesPixels()) { 402 if (layer->background_filters().HasFilterThatMovesPixels()) {
396 ExpandDamageRectInsideRectWithFilters(target_damage_rect, 403 ExpandDamageRectInsideRectWithFilters(target_damage_rect,
397 surface_rect_in_target_space, 404 surface_rect_in_target_space,
398 layer->background_filters()); 405 layer->background_filters());
399 } 406 }
400 } 407 }
401 408
402 } // namespace cc 409 } // namespace cc
OLDNEW
« cc/trees/damage_tracker.h ('K') | « cc/trees/damage_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698