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

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

Issue 2423483003: cc: Make visible rect computation aware of pixel-moving filters (Closed)
Patch Set: It's 2017 -- update copyright for new files Created 3 years, 11 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/trees/clip_expander.h » ('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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return; 184 return;
185 185
186 surface_property_changed_ = true; 186 surface_property_changed_ = true;
187 draw_properties_.content_rect = content_rect; 187 draw_properties_.content_rect = content_rect;
188 } 188 }
189 189
190 void RenderSurfaceImpl::SetContentRectForTesting(const gfx::Rect& rect) { 190 void RenderSurfaceImpl::SetContentRectForTesting(const gfx::Rect& rect) {
191 SetContentRect(rect); 191 SetContentRect(rect);
192 } 192 }
193 193
194 gfx::Rect RenderSurfaceImpl::CalculateExpandedClipForFilters(
195 const gfx::Transform& target_to_surface) {
196 gfx::Rect clip_in_surface_space =
197 MathUtil::ProjectEnclosingClippedRect(target_to_surface, clip_rect());
198 gfx::Rect expanded_clip_in_surface_space = Filters().MapRectReverse(
199 clip_in_surface_space, FiltersTransform().matrix());
200 gfx::Rect expanded_clip_in_target_space = MathUtil::MapEnclosingClippedRect(
201 draw_transform(), expanded_clip_in_surface_space);
202 return expanded_clip_in_target_space;
203 }
204
194 gfx::Rect RenderSurfaceImpl::CalculateClippedAccumulatedContentRect() { 205 gfx::Rect RenderSurfaceImpl::CalculateClippedAccumulatedContentRect() {
195 if (HasCopyRequest() || !is_clipped()) 206 if (HasCopyRequest() || !is_clipped())
196 return accumulated_content_rect(); 207 return accumulated_content_rect();
197 208
198 if (accumulated_content_rect().IsEmpty()) 209 if (accumulated_content_rect().IsEmpty())
199 return gfx::Rect(); 210 return gfx::Rect();
200 211
201 // Calculate projection from the target surface rect to local 212 // Calculate projection from the target surface rect to local
202 // space. Non-invertible draw transforms means no able to bring clipped rect 213 // space. Non-invertible draw transforms means no able to bring clipped rect
203 // in target space back to local space, early out without clip. 214 // in target space back to local space, early out without clip.
204 gfx::Transform target_to_surface(gfx::Transform::kSkipInitialization); 215 gfx::Transform target_to_surface(gfx::Transform::kSkipInitialization);
205 if (!draw_transform().GetInverse(&target_to_surface)) 216 if (!draw_transform().GetInverse(&target_to_surface))
206 return accumulated_content_rect(); 217 return accumulated_content_rect();
207 218
208 // Clip rect is in target space. Bring accumulated content rect to 219 // Clip rect is in target space. Bring accumulated content rect to
209 // target space in preparation for clipping. 220 // target space in preparation for clipping.
210 gfx::Rect accumulated_rect_in_target_space = 221 gfx::Rect accumulated_rect_in_target_space =
211 MathUtil::MapEnclosingClippedRect(draw_transform(), 222 MathUtil::MapEnclosingClippedRect(draw_transform(),
212 accumulated_content_rect()); 223 accumulated_content_rect());
213 // If accumulated content rect is contained within clip rect, early out 224 // If accumulated content rect is contained within clip rect, early out
214 // without clipping. 225 // without clipping.
215 if (clip_rect().Contains(accumulated_rect_in_target_space)) 226 if (clip_rect().Contains(accumulated_rect_in_target_space))
216 return accumulated_content_rect(); 227 return accumulated_content_rect();
217 228
218 gfx::Rect clipped_accumulated_rect_in_target_space = clip_rect(); 229 gfx::Rect clipped_accumulated_rect_in_target_space;
230 if (Filters().HasFilterThatMovesPixels()) {
231 clipped_accumulated_rect_in_target_space =
232 CalculateExpandedClipForFilters(target_to_surface);
233 } else {
234 clipped_accumulated_rect_in_target_space = clip_rect();
235 }
219 clipped_accumulated_rect_in_target_space.Intersect( 236 clipped_accumulated_rect_in_target_space.Intersect(
220 accumulated_rect_in_target_space); 237 accumulated_rect_in_target_space);
221 238
222 if (clipped_accumulated_rect_in_target_space.IsEmpty()) 239 if (clipped_accumulated_rect_in_target_space.IsEmpty())
223 return gfx::Rect(); 240 return gfx::Rect();
224 241
225 gfx::Rect clipped_accumulated_rect_in_local_space = 242 gfx::Rect clipped_accumulated_rect_in_local_space =
226 MathUtil::ProjectEnclosingClippedRect( 243 MathUtil::ProjectEnclosingClippedRect(
227 target_to_surface, clipped_accumulated_rect_in_target_space); 244 target_to_surface, clipped_accumulated_rect_in_target_space);
228 // Bringing clipped accumulated rect back to local space may result 245 // Bringing clipped accumulated rect back to local space may result
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 413
397 RenderPassDrawQuad* quad = 414 RenderPassDrawQuad* quad =
398 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); 415 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
399 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, 416 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect,
400 GetRenderPassId(), mask_resource_id, mask_uv_scale, 417 GetRenderPassId(), mask_resource_id, mask_uv_scale,
401 mask_texture_size, owning_layer_to_target_scale, 418 mask_texture_size, owning_layer_to_target_scale,
402 FiltersOrigin()); 419 FiltersOrigin());
403 } 420 }
404 421
405 } // namespace cc 422 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/render_surface_impl.h ('k') | cc/trees/clip_expander.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698