| OLD | NEW |
| 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/layers/render_surface_impl.h" | 5 #include "cc/layers/render_surface_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "cc/base/math_util.h" | 13 #include "cc/base/math_util.h" |
| 14 #include "cc/debug/debug_colors.h" | 14 #include "cc/debug/debug_colors.h" |
| 15 #include "cc/layers/layer_impl.h" | 15 #include "cc/layers/layer_impl.h" |
| 16 #include "cc/layers/render_pass_sink.h" | 16 #include "cc/layers/render_pass_sink.h" |
| 17 #include "cc/output/filter_operations.h" | 17 #include "cc/output/filter_operations.h" |
| 18 #include "cc/quads/debug_border_draw_quad.h" | 18 #include "cc/quads/debug_border_draw_quad.h" |
| 19 #include "cc/quads/render_pass.h" | 19 #include "cc/quads/render_pass.h" |
| 20 #include "cc/quads/render_pass_draw_quad.h" | 20 #include "cc/quads/render_pass_draw_quad.h" |
| 21 #include "cc/quads/shared_quad_state.h" | 21 #include "cc/quads/shared_quad_state.h" |
| 22 #include "cc/trees/damage_tracker.h" | 22 #include "cc/trees/damage_tracker.h" |
| 23 #include "cc/trees/draw_property_utils.h" | 23 #include "cc/trees/draw_property_utils.h" |
| 24 #include "cc/trees/effect_node.h" | 24 #include "cc/trees/effect_node.h" |
| 25 #include "cc/trees/layer_tree_impl.h" | 25 #include "cc/trees/layer_tree_impl.h" |
| 26 #include "cc/trees/occlusion.h" | 26 #include "cc/trees/occlusion.h" |
| 27 #include "cc/trees/transform_node.h" |
| 27 #include "third_party/skia/include/core/SkImageFilter.h" | 28 #include "third_party/skia/include/core/SkImageFilter.h" |
| 28 #include "ui/gfx/geometry/rect_conversions.h" | 29 #include "ui/gfx/geometry/rect_conversions.h" |
| 29 #include "ui/gfx/transform.h" | 30 #include "ui/gfx/transform.h" |
| 30 | 31 |
| 31 namespace cc { | 32 namespace cc { |
| 32 | 33 |
| 33 RenderSurfaceImpl::RenderSurfaceImpl(LayerImpl* owning_layer) | 34 RenderSurfaceImpl::RenderSurfaceImpl(LayerImpl* owning_layer) |
| 34 : owning_layer_(owning_layer), | 35 : owning_layer_(owning_layer), |
| 35 surface_property_changed_(false), | 36 surface_property_changed_(false), |
| 37 ancestor_property_changed_(false), |
| 36 contributes_to_drawn_surface_(false), | 38 contributes_to_drawn_surface_(false), |
| 37 nearest_occlusion_immune_ancestor_(nullptr), | 39 nearest_occlusion_immune_ancestor_(nullptr), |
| 38 target_render_surface_layer_index_history_(0), | 40 target_render_surface_layer_index_history_(0), |
| 39 current_layer_index_history_(0) { | 41 current_layer_index_history_(0) { |
| 40 damage_tracker_ = DamageTracker::Create(); | 42 damage_tracker_ = DamageTracker::Create(); |
| 41 } | 43 } |
| 42 | 44 |
| 43 RenderSurfaceImpl::~RenderSurfaceImpl() {} | 45 RenderSurfaceImpl::~RenderSurfaceImpl() {} |
| 44 | 46 |
| 45 RenderSurfaceImpl* RenderSurfaceImpl::render_target() { | 47 RenderSurfaceImpl* RenderSurfaceImpl::render_target() { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 gfx::ToEnclosedRect(contributing_surface->DrawableContentRect())); | 328 gfx::ToEnclosedRect(contributing_surface->DrawableContentRect())); |
| 327 } | 329 } |
| 328 | 330 |
| 329 bool RenderSurfaceImpl::SurfacePropertyChanged() const { | 331 bool RenderSurfaceImpl::SurfacePropertyChanged() const { |
| 330 // Surface property changes are tracked as follows: | 332 // Surface property changes are tracked as follows: |
| 331 // | 333 // |
| 332 // - surface_property_changed_ is flagged when the clip_rect or content_rect | 334 // - surface_property_changed_ is flagged when the clip_rect or content_rect |
| 333 // change. As of now, these are the only two properties that can be affected | 335 // change. As of now, these are the only two properties that can be affected |
| 334 // by descendant layers. | 336 // by descendant layers. |
| 335 // | 337 // |
| 336 // - all other property changes come from the owning layer (or some ancestor | 338 // - all other property changes come from the surface's property tree nodes |
| 337 // layer that propagates its change to the owning layer). | 339 // (or some ancestor node that propagates its change to one of these nodes). |
| 338 // | 340 // |
| 339 DCHECK(owning_layer_); | 341 DCHECK(owning_layer_); |
| 340 return surface_property_changed_ || owning_layer_->LayerPropertyChanged(); | 342 return surface_property_changed_ || AncestorPropertyChanged(); |
| 341 } | 343 } |
| 342 | 344 |
| 343 bool RenderSurfaceImpl::SurfacePropertyChangedOnlyFromDescendant() const { | 345 bool RenderSurfaceImpl::SurfacePropertyChangedOnlyFromDescendant() const { |
| 344 return surface_property_changed_ && !owning_layer_->LayerPropertyChanged(); | 346 return surface_property_changed_ && !AncestorPropertyChanged(); |
| 347 } |
| 348 |
| 349 bool RenderSurfaceImpl::AncestorPropertyChanged() const { |
| 350 const PropertyTrees* property_trees = |
| 351 owning_layer_->layer_tree_impl()->property_trees(); |
| 352 return ancestor_property_changed_ || property_trees->full_tree_damaged || |
| 353 property_trees->transform_tree.Node(TransformTreeIndex()) |
| 354 ->transform_changed || |
| 355 property_trees->effect_tree.Node(EffectTreeIndex())->effect_changed; |
| 356 } |
| 357 |
| 358 void RenderSurfaceImpl::NoteAncestorPropertyChanged() { |
| 359 ancestor_property_changed_ = true; |
| 360 } |
| 361 |
| 362 void RenderSurfaceImpl::ResetPropertyChangedFlags() { |
| 363 surface_property_changed_ = false; |
| 364 ancestor_property_changed_ = false; |
| 345 } | 365 } |
| 346 | 366 |
| 347 void RenderSurfaceImpl::ClearLayerLists() { | 367 void RenderSurfaceImpl::ClearLayerLists() { |
| 348 layer_list_.clear(); | 368 layer_list_.clear(); |
| 349 } | 369 } |
| 350 | 370 |
| 351 RenderPassId RenderSurfaceImpl::GetRenderPassId() { | 371 RenderPassId RenderSurfaceImpl::GetRenderPassId() { |
| 352 int layer_id = owning_layer_->id(); | 372 int layer_id = owning_layer_->id(); |
| 353 int sub_id = 0; | 373 int sub_id = 0; |
| 354 DCHECK_GT(layer_id, 0); | 374 DCHECK_GT(layer_id, 0); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 | 436 |
| 417 RenderPassDrawQuad* quad = | 437 RenderPassDrawQuad* quad = |
| 418 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 438 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 419 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, | 439 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, |
| 420 render_pass_id, mask_resource_id, mask_uv_scale, | 440 render_pass_id, mask_resource_id, mask_uv_scale, |
| 421 mask_texture_size, Filters(), owning_layer_to_target_scale, | 441 mask_texture_size, Filters(), owning_layer_to_target_scale, |
| 422 FiltersOrigin(), BackgroundFilters()); | 442 FiltersOrigin(), BackgroundFilters()); |
| 423 } | 443 } |
| 424 | 444 |
| 425 } // namespace cc | 445 } // namespace cc |
| OLD | NEW |