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

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

Issue 2035863003: cc: Add mask and replica layer ids to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments 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/layers/render_surface_impl.h ('k') | cc/layers/render_surface_impl_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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 gfx::Rect surface_content_rect = content_rect(); 76 gfx::Rect surface_content_rect = content_rect();
77 if (!owning_layer_->filters().IsEmpty()) { 77 if (!owning_layer_->filters().IsEmpty()) {
78 const gfx::Transform& owning_layer_draw_transform = 78 const gfx::Transform& owning_layer_draw_transform =
79 owning_layer_->DrawTransform(); 79 owning_layer_->DrawTransform();
80 DCHECK(owning_layer_draw_transform.IsScale2d()); 80 DCHECK(owning_layer_draw_transform.IsScale2d());
81 surface_content_rect = owning_layer_->filters().MapRect( 81 surface_content_rect = owning_layer_->filters().MapRect(
82 surface_content_rect, owning_layer_draw_transform.matrix()); 82 surface_content_rect, owning_layer_draw_transform.matrix());
83 } 83 }
84 gfx::RectF drawable_content_rect = MathUtil::MapClippedRect( 84 gfx::RectF drawable_content_rect = MathUtil::MapClippedRect(
85 draw_transform(), gfx::RectF(surface_content_rect)); 85 draw_transform(), gfx::RectF(surface_content_rect));
86 if (owning_layer_->has_replica()) { 86 if (HasReplica()) {
87 drawable_content_rect.Union(MathUtil::MapClippedRect( 87 drawable_content_rect.Union(MathUtil::MapClippedRect(
88 replica_draw_transform(), gfx::RectF(surface_content_rect))); 88 replica_draw_transform(), gfx::RectF(surface_content_rect)));
89 } else if (!owning_layer_->filters().IsEmpty() && is_clipped()) { 89 } else if (!owning_layer_->filters().IsEmpty() && is_clipped()) {
90 // Filter could move pixels around, but still need to be clipped. 90 // Filter could move pixels around, but still need to be clipped.
91 drawable_content_rect.Intersect(gfx::RectF(clip_rect())); 91 drawable_content_rect.Intersect(gfx::RectF(clip_rect()));
92 } 92 }
93 93
94 // If the rect has a NaN coordinate, we return empty rect to avoid crashes in 94 // If the rect has a NaN coordinate, we return empty rect to avoid crashes in
95 // functions (for example, gfx::ToEnclosedRect) that are called on this rect. 95 // functions (for example, gfx::ToEnclosedRect) that are called on this rect.
96 if (std::isnan(drawable_content_rect.x()) || 96 if (std::isnan(drawable_content_rect.x()) ||
(...skipping 20 matching lines...) Expand all
117 float RenderSurfaceImpl::GetReplicaDebugBorderWidth() const { 117 float RenderSurfaceImpl::GetReplicaDebugBorderWidth() const {
118 return DebugColors::SurfaceReplicaBorderWidth( 118 return DebugColors::SurfaceReplicaBorderWidth(
119 owning_layer_->layer_tree_impl()); 119 owning_layer_->layer_tree_impl());
120 } 120 }
121 121
122 int RenderSurfaceImpl::OwningLayerId() const { 122 int RenderSurfaceImpl::OwningLayerId() const {
123 return owning_layer_ ? owning_layer_->id() : 0; 123 return owning_layer_ ? owning_layer_->id() : 0;
124 } 124 }
125 125
126 bool RenderSurfaceImpl::HasReplica() const { 126 bool RenderSurfaceImpl::HasReplica() const {
127 return owning_layer_->has_replica(); 127 return OwningEffectNode()->data.replica_layer_id != -1;
128 } 128 }
129 129
130 const LayerImpl* RenderSurfaceImpl::ReplicaLayer() const { 130 const LayerImpl* RenderSurfaceImpl::ReplicaLayer() const {
131 return owning_layer_->replica_layer(); 131 int replica_layer_id = OwningEffectNode()->data.replica_layer_id;
132 return owning_layer_->layer_tree_impl()->LayerById(replica_layer_id);
133 }
134
135 LayerImpl* RenderSurfaceImpl::ReplicaLayer() {
136 int replica_layer_id = OwningEffectNode()->data.replica_layer_id;
137 return owning_layer_->layer_tree_impl()->LayerById(replica_layer_id);
138 }
139
140 LayerImpl* RenderSurfaceImpl::MaskLayer() {
141 int mask_layer_id = OwningEffectNode()->data.mask_layer_id;
142 return owning_layer_->layer_tree_impl()->LayerById(mask_layer_id);
143 }
144
145 bool RenderSurfaceImpl::HasMask() const {
146 return OwningEffectNode()->data.mask_layer_id != -1;
147 }
148
149 LayerImpl* RenderSurfaceImpl::ReplicaMaskLayer() {
150 int replica_mask_layer_id = OwningEffectNode()->data.replica_mask_layer_id;
151 return owning_layer_->layer_tree_impl()->LayerById(replica_mask_layer_id);
152 }
153
154 bool RenderSurfaceImpl::HasReplicaMask() const {
155 return OwningEffectNode()->data.replica_mask_layer_id != -1;
132 } 156 }
133 157
134 bool RenderSurfaceImpl::HasCopyRequest() const { 158 bool RenderSurfaceImpl::HasCopyRequest() const {
135 return owning_layer_->layer_tree_impl() 159 return OwningEffectNode()->data.has_copy_request;
136 ->property_trees()
137 ->effect_tree.Node(EffectTreeIndex())
138 ->data.has_copy_request;
139 } 160 }
140 161
141 int RenderSurfaceImpl::TransformTreeIndex() const { 162 int RenderSurfaceImpl::TransformTreeIndex() const {
142 return owning_layer_->transform_tree_index(); 163 return owning_layer_->transform_tree_index();
143 } 164 }
144 165
145 int RenderSurfaceImpl::ClipTreeIndex() const { 166 int RenderSurfaceImpl::ClipTreeIndex() const {
146 return owning_layer_->clip_tree_index(); 167 return owning_layer_->clip_tree_index();
147 } 168 }
148 169
149 int RenderSurfaceImpl::EffectTreeIndex() const { 170 int RenderSurfaceImpl::EffectTreeIndex() const {
150 return owning_layer_->effect_tree_index(); 171 return owning_layer_->effect_tree_index();
151 } 172 }
152 173
174 const EffectNode* RenderSurfaceImpl::OwningEffectNode() const {
175 return owning_layer_->layer_tree_impl()->property_trees()->effect_tree.Node(
176 EffectTreeIndex());
177 }
178
153 void RenderSurfaceImpl::SetClipRect(const gfx::Rect& clip_rect) { 179 void RenderSurfaceImpl::SetClipRect(const gfx::Rect& clip_rect) {
154 if (clip_rect == draw_properties_.clip_rect) 180 if (clip_rect == draw_properties_.clip_rect)
155 return; 181 return;
156 182
157 surface_property_changed_ = true; 183 surface_property_changed_ = true;
158 draw_properties_.clip_rect = clip_rect; 184 draw_properties_.clip_rect = clip_rect;
159 } 185 }
160 186
161 void RenderSurfaceImpl::SetContentRect(const gfx::Rect& content_rect) { 187 void RenderSurfaceImpl::SetContentRect(const gfx::Rect& content_rect) {
162 if (content_rect == draw_properties_.content_rect) 188 if (content_rect == draw_properties_.content_rect)
163 return; 189 return;
164 190
165 surface_property_changed_ = true; 191 surface_property_changed_ = true;
166 draw_properties_.content_rect = content_rect; 192 draw_properties_.content_rect = content_rect;
167 } 193 }
168 194
169 void RenderSurfaceImpl::SetContentRectForTesting(const gfx::Rect& rect) { 195 void RenderSurfaceImpl::SetContentRectForTesting(const gfx::Rect& rect) {
170 SetContentRect(rect); 196 SetContentRect(rect);
171 } 197 }
172 198
173 gfx::Rect RenderSurfaceImpl::CalculateClippedAccumulatedContentRect() { 199 gfx::Rect RenderSurfaceImpl::CalculateClippedAccumulatedContentRect() {
174 if (owning_layer_->replica_layer() || HasCopyRequest() || !is_clipped()) 200 if (ReplicaLayer() || HasCopyRequest() || !is_clipped())
175 return accumulated_content_rect(); 201 return accumulated_content_rect();
176 202
177 if (accumulated_content_rect().IsEmpty()) 203 if (accumulated_content_rect().IsEmpty())
178 return gfx::Rect(); 204 return gfx::Rect();
179 205
180 // Calculate projection from the target surface rect to local 206 // Calculate projection from the target surface rect to local
181 // space. Non-invertible draw transforms means no able to bring clipped rect 207 // space. Non-invertible draw transforms means no able to bring clipped rect
182 // in target space back to local space, early out without clip. 208 // in target space back to local space, early out without clip.
183 gfx::Transform target_to_surface(gfx::Transform::kSkipInitialization); 209 gfx::Transform target_to_surface(gfx::Transform::kSkipInitialization);
184 if (!draw_transform().GetInverse(&target_to_surface)) 210 if (!draw_transform().GetInverse(&target_to_surface))
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 RenderPassDrawQuad* quad = 389 RenderPassDrawQuad* quad =
364 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); 390 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
365 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, 391 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect,
366 render_pass_id, mask_resource_id, mask_uv_scale, 392 render_pass_id, mask_resource_id, mask_uv_scale,
367 mask_texture_size, owning_layer_->filters(), 393 mask_texture_size, owning_layer_->filters(),
368 owning_layer_to_target_scale, 394 owning_layer_to_target_scale,
369 owning_layer_->background_filters()); 395 owning_layer_->background_filters());
370 } 396 }
371 397
372 } // namespace cc 398 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/render_surface_impl.h ('k') | cc/layers/render_surface_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698