Chromium Code Reviews| 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 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 surface_property_changed_(false), | 33 surface_property_changed_(false), |
| 34 contributes_to_drawn_surface_(false), | 34 contributes_to_drawn_surface_(false), |
| 35 nearest_occlusion_immune_ancestor_(nullptr), | 35 nearest_occlusion_immune_ancestor_(nullptr), |
| 36 target_render_surface_layer_index_history_(0), | 36 target_render_surface_layer_index_history_(0), |
| 37 current_layer_index_history_(0) { | 37 current_layer_index_history_(0) { |
| 38 damage_tracker_ = DamageTracker::Create(); | 38 damage_tracker_ = DamageTracker::Create(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 RenderSurfaceImpl::~RenderSurfaceImpl() {} | 41 RenderSurfaceImpl::~RenderSurfaceImpl() {} |
| 42 | 42 |
| 43 RenderSurfaceImpl* RenderSurfaceImpl::render_target() { | |
| 44 EffectTree& effect_tree = | |
| 45 owning_layer_->layer_tree_impl()->property_trees()->effect_tree; | |
| 46 EffectNode* node = effect_tree.Node(EffectTreeIndex()); | |
| 47 EffectNode* target_node = effect_tree.Node(node->data.target_id); | |
| 48 if (target_node->id != 0) | |
| 49 return target_node->data.render_surface; | |
| 50 else | |
| 51 return this; | |
| 52 } | |
| 53 | |
| 54 const RenderSurfaceImpl* RenderSurfaceImpl::render_target() const { | |
| 55 const EffectTree& effect_tree = | |
| 56 owning_layer_->layer_tree_impl()->property_trees()->effect_tree; | |
| 57 const EffectNode* node = effect_tree.Node(EffectTreeIndex()); | |
| 58 const EffectNode* target_node = effect_tree.Node(node->data.target_id); | |
| 59 if (target_node->id != 0) | |
| 60 return target_node->data.render_surface; | |
| 61 else | |
| 62 return this; | |
| 63 } | |
| 64 | |
| 43 RenderSurfaceImpl::DrawProperties::DrawProperties() { | 65 RenderSurfaceImpl::DrawProperties::DrawProperties() { |
| 44 draw_opacity = 1.f; | 66 draw_opacity = 1.f; |
| 45 is_clipped = false; | 67 is_clipped = false; |
| 46 } | 68 } |
| 47 | 69 |
| 48 RenderSurfaceImpl::DrawProperties::~DrawProperties() {} | 70 RenderSurfaceImpl::DrawProperties::~DrawProperties() {} |
| 49 | 71 |
| 50 gfx::RectF RenderSurfaceImpl::DrawableContentRect() const { | 72 gfx::RectF RenderSurfaceImpl::DrawableContentRect() const { |
| 51 gfx::RectF drawable_content_rect = | 73 gfx::RectF drawable_content_rect = |
| 52 MathUtil::MapClippedRect(draw_transform(), gfx::RectF(content_rect())); | 74 MathUtil::MapClippedRect(draw_transform(), gfx::RectF(content_rect())); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 } | 143 } |
| 122 | 144 |
| 123 void RenderSurfaceImpl::SetContentRect(const gfx::Rect& content_rect) { | 145 void RenderSurfaceImpl::SetContentRect(const gfx::Rect& content_rect) { |
| 124 if (content_rect == draw_properties_.content_rect) | 146 if (content_rect == draw_properties_.content_rect) |
| 125 return; | 147 return; |
| 126 | 148 |
| 127 surface_property_changed_ = true; | 149 surface_property_changed_ = true; |
| 128 draw_properties_.content_rect = content_rect; | 150 draw_properties_.content_rect = content_rect; |
| 129 } | 151 } |
| 130 | 152 |
| 131 void RenderSurfaceImpl::SetAccumulatedContentRect( | 153 void RenderSurfaceImpl::ClearAccumulatedContentRect() { |
| 132 const gfx::Rect& content_rect) { | 154 accumulated_content_rect_ = gfx::Rect(); |
| 133 accumulated_content_rect_ = content_rect; | 155 } |
| 156 | |
| 157 void RenderSurfaceImpl::AccumulateContentRectFromContributingLayer( | |
| 158 LayerImpl* layer) { | |
| 159 DCHECK(layer->DrawsContent()); | |
| 160 DCHECK_EQ(this, layer->render_target()); | |
| 161 | |
| 162 accumulated_content_rect_.Union(layer->drawable_content_rect()); | |
| 163 } | |
| 164 | |
| 165 void RenderSurfaceImpl::AccumulateContentRectFromContributingRenderSurface( | |
| 166 RenderSurfaceImpl* contributing_surface) { | |
| 167 DCHECK_NE(this, contributing_surface); | |
| 168 DCHECK_EQ(this, contributing_surface->render_target()); | |
| 169 | |
| 170 // The content rect of contributing surface is in its own space. Instead, we | |
| 171 // will use contributing surface's DrawableContentRect which is in target | |
| 172 // space (local space for this render surface) as required. We also need to | |
| 173 // clip it with this render surface's clip if the target is clipped. | |
| 174 accumulated_content_rect_.Union( | |
| 175 gfx::ToEnclosedRect(contributing_surface->DrawableContentRect())); | |
| 176 if (is_clipped()) | |
| 177 accumulated_content_rect_.Intersect(clip_rect()); | |
|
ajuma
2016/04/07 21:59:55
This clipping seems like something that can be rem
ajuma
2016/04/07 23:57:37
Thinking about this some more:
In the old code, th
| |
| 134 } | 178 } |
| 135 | 179 |
| 136 bool RenderSurfaceImpl::SurfacePropertyChanged() const { | 180 bool RenderSurfaceImpl::SurfacePropertyChanged() const { |
| 137 // Surface property changes are tracked as follows: | 181 // Surface property changes are tracked as follows: |
| 138 // | 182 // |
| 139 // - surface_property_changed_ is flagged when the clip_rect or content_rect | 183 // - surface_property_changed_ is flagged when the clip_rect or content_rect |
| 140 // change. As of now, these are the only two properties that can be affected | 184 // change. As of now, these are the only two properties that can be affected |
| 141 // by descendant layers. | 185 // by descendant layers. |
| 142 // | 186 // |
| 143 // - all other property changes come from the owning layer (or some ancestor | 187 // - all other property changes come from the owning layer (or some ancestor |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 RenderPassDrawQuad* quad = | 268 RenderPassDrawQuad* quad = |
| 225 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 269 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 226 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, | 270 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, |
| 227 render_pass_id, mask_resource_id, mask_uv_scale, | 271 render_pass_id, mask_resource_id, mask_uv_scale, |
| 228 mask_texture_size, owning_layer_->filters(), | 272 mask_texture_size, owning_layer_->filters(), |
| 229 owning_layer_to_target_scale, | 273 owning_layer_to_target_scale, |
| 230 owning_layer_->background_filters()); | 274 owning_layer_->background_filters()); |
| 231 } | 275 } |
| 232 | 276 |
| 233 } // namespace cc | 277 } // namespace cc |
| OLD | NEW |