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

Side by Side Diff: cc/layers/render_surface_impl.cc

Issue 1868003002: cc: Move RenderTarget Information to Effect Tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 | « cc/layers/render_surface_impl.h ('k') | cc/layers/render_surface_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/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
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
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 // Root render surface doesn't accumulate content rect, it always uses
163 // viewport for content rect.
164 if (render_target() == this)
165 return;
166
167 accumulated_content_rect_.Union(layer->drawable_content_rect());
168 }
169
170 void RenderSurfaceImpl::AccumulateContentRectFromContributingRenderSurface(
171 RenderSurfaceImpl* contributing_surface) {
172 DCHECK_NE(this, contributing_surface);
173 DCHECK_EQ(this, contributing_surface->render_target());
174
175 // Root render surface doesn't accumulate content rect, it always uses
176 // viewport for content rect.
177 if (render_target() == this)
178 return;
179
180 // The content rect of contributing surface is in its own space. Instead, we
181 // will use contributing surface's DrawableContentRect which is in target
182 // space (local space for this render surface) as required.
183 accumulated_content_rect_.Union(
184 gfx::ToEnclosedRect(contributing_surface->DrawableContentRect()));
134 } 185 }
135 186
136 bool RenderSurfaceImpl::SurfacePropertyChanged() const { 187 bool RenderSurfaceImpl::SurfacePropertyChanged() const {
137 // Surface property changes are tracked as follows: 188 // Surface property changes are tracked as follows:
138 // 189 //
139 // - surface_property_changed_ is flagged when the clip_rect or content_rect 190 // - 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 191 // change. As of now, these are the only two properties that can be affected
141 // by descendant layers. 192 // by descendant layers.
142 // 193 //
143 // - all other property changes come from the owning layer (or some ancestor 194 // - all other property changes come from the owning layer (or some ancestor
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 RenderPassDrawQuad* quad = 275 RenderPassDrawQuad* quad =
225 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); 276 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
226 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, 277 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect,
227 render_pass_id, mask_resource_id, mask_uv_scale, 278 render_pass_id, mask_resource_id, mask_uv_scale,
228 mask_texture_size, owning_layer_->filters(), 279 mask_texture_size, owning_layer_->filters(),
229 owning_layer_to_target_scale, 280 owning_layer_to_target_scale,
230 owning_layer_->background_filters()); 281 owning_layer_->background_filters());
231 } 282 }
232 283
233 } // namespace cc 284 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/render_surface_impl.h ('k') | cc/layers/render_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698