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

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

Issue 2099743002: cc: Move background filters to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ' Created 4 years, 6 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/trees/damage_tracker.h ('k') | cc/trees/damage_tracker_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 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // Visit layers in back-to-front order. 189 // Visit layers in back-to-front order.
190 LayerImpl* layer = layer_list[layer_index]; 190 LayerImpl* layer = layer_list[layer_index];
191 191
192 // We skip damage from the HUD layer because (a) the HUD layer damages the 192 // We skip damage from the HUD layer because (a) the HUD layer damages the
193 // whole frame and (b) we don't want HUD layer damage to be shown by the 193 // whole frame and (b) we don't want HUD layer damage to be shown by the
194 // HUD damage rect visualization. 194 // HUD damage rect visualization.
195 if (layer == layer->layer_tree_impl()->hud_layer()) 195 if (layer == layer->layer_tree_impl()->hud_layer())
196 continue; 196 continue;
197 197
198 if (layer->render_surface() && layer->render_surface() != target_surface) 198 if (layer->render_surface() && layer->render_surface() != target_surface)
199 ExtendDamageForRenderSurface(layer, &damage_rect); 199 ExtendDamageForRenderSurface(layer->render_surface(), &damage_rect);
200 else 200 else
201 ExtendDamageForLayer(layer, &damage_rect); 201 ExtendDamageForLayer(layer, &damage_rect);
202 } 202 }
203 203
204 return damage_rect; 204 return damage_rect;
205 } 205 }
206 206
207 gfx::Rect DamageTracker::TrackDamageFromSurfaceMask( 207 gfx::Rect DamageTracker::TrackDamageFromSurfaceMask(
208 LayerImpl* target_surface_mask_layer) { 208 LayerImpl* target_surface_mask_layer) {
209 gfx::Rect damage_rect; 209 gfx::Rect damage_rect;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 gfx::UnionRects(layer->update_rect(), layer->damage_rect()); 336 gfx::UnionRects(layer->update_rect(), layer->damage_rect());
337 damage_rect.Intersect(gfx::Rect(layer->bounds())); 337 damage_rect.Intersect(gfx::Rect(layer->bounds()));
338 if (!damage_rect.IsEmpty()) { 338 if (!damage_rect.IsEmpty()) {
339 gfx::Rect damage_rect_in_target_space = 339 gfx::Rect damage_rect_in_target_space =
340 MathUtil::MapEnclosingClippedRect(layer->DrawTransform(), damage_rect); 340 MathUtil::MapEnclosingClippedRect(layer->DrawTransform(), damage_rect);
341 target_damage_rect->Union(damage_rect_in_target_space); 341 target_damage_rect->Union(damage_rect_in_target_space);
342 } 342 }
343 } 343 }
344 344
345 void DamageTracker::ExtendDamageForRenderSurface( 345 void DamageTracker::ExtendDamageForRenderSurface(
346 LayerImpl* layer, 346 RenderSurfaceImpl* render_surface,
347 gfx::Rect* target_damage_rect) { 347 gfx::Rect* target_damage_rect) {
348 // There are two ways a "descendant surface" can damage regions of the "target 348 // There are two ways a "descendant surface" can damage regions of the "target
349 // surface": 349 // surface":
350 // 1. Property change: 350 // 1. Property change:
351 // - a surface's geometry can change because of 351 // - a surface's geometry can change because of
352 // - changes to descendants (i.e. the subtree) that affect the 352 // - changes to descendants (i.e. the subtree) that affect the
353 // surface's content rect 353 // surface's content rect
354 // - changes to ancestor layers that propagate their property 354 // - changes to ancestor layers that propagate their property
355 // changes to their entire subtree. 355 // changes to their entire subtree.
356 // - just like layers, both the old surface rect and new surface rect 356 // - just like layers, both the old surface rect and new surface rect
357 // will damage the target surface in this case. 357 // will damage the target surface in this case.
358 // 358 //
359 // 2. Damage rect: This surface may have been damaged by its own layer_list 359 // 2. Damage rect: This surface may have been damaged by its own layer_list
360 // as well, and that damage should propagate to the target surface. 360 // as well, and that damage should propagate to the target surface.
361 // 361 //
362 362
363 RenderSurfaceImpl* render_surface = layer->render_surface();
364
365 bool surface_is_new = false; 363 bool surface_is_new = false;
366 SurfaceRectMapData& data = RectDataForSurface(layer->id(), &surface_is_new); 364 SurfaceRectMapData& data =
365 RectDataForSurface(render_surface->OwningLayerId(), &surface_is_new);
367 gfx::Rect old_surface_rect = data.rect_; 366 gfx::Rect old_surface_rect = data.rect_;
368 367
369 // The drawableContextRect() already includes the replica if it exists. 368 // The drawableContextRect() already includes the replica if it exists.
370 gfx::Rect surface_rect_in_target_space = 369 gfx::Rect surface_rect_in_target_space =
371 gfx::ToEnclosingRect(render_surface->DrawableContentRect()); 370 gfx::ToEnclosingRect(render_surface->DrawableContentRect());
372 data.Update(surface_rect_in_target_space, mailboxId_); 371 data.Update(surface_rect_in_target_space, mailboxId_);
373 372
374 if (surface_is_new || render_surface->SurfacePropertyChanged()) { 373 if (surface_is_new || render_surface->SurfacePropertyChanged()) {
375 // The entire surface contributes damage. 374 // The entire surface contributes damage.
376 target_damage_rect->Union(surface_rect_in_target_space); 375 target_damage_rect->Union(surface_rect_in_target_space);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 !replica_mask_layer->update_rect().IsEmpty()) 420 !replica_mask_layer->update_rect().IsEmpty())
422 target_damage_rect->Union(replica_mask_layer_rect); 421 target_damage_rect->Union(replica_mask_layer_rect);
423 } 422 }
424 423
425 // If the layer has a background filter, this may cause pixels in our surface 424 // If the layer has a background filter, this may cause pixels in our surface
426 // to be expanded, so we will need to expand any damage at or below this 425 // to be expanded, so we will need to expand any damage at or below this
427 // layer. We expand the damage from this layer too, as we need to readback 426 // layer. We expand the damage from this layer too, as we need to readback
428 // those pixels from the surface with only the contents of layers below this 427 // those pixels from the surface with only the contents of layers below this
429 // one in them. This means we need to redraw any pixels in the surface being 428 // one in them. This means we need to redraw any pixels in the surface being
430 // used for the blur in this layer this frame. 429 // used for the blur in this layer this frame.
431 if (layer->background_filters().HasFilterThatMovesPixels()) { 430 const FilterOperations& background_filters =
432 ExpandDamageRectInsideRectWithFilters(target_damage_rect, 431 render_surface->BackgroundFilters();
433 surface_rect_in_target_space, 432 if (background_filters.HasFilterThatMovesPixels()) {
434 layer->background_filters()); 433 ExpandDamageRectInsideRectWithFilters(
434 target_damage_rect, surface_rect_in_target_space, background_filters);
435 } 435 }
436 } 436 }
437 437
438 } // namespace cc 438 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/damage_tracker.h ('k') | cc/trees/damage_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698