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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 return; | 183 return; |
184 | 184 |
185 surface_property_changed_ = true; | 185 surface_property_changed_ = true; |
186 draw_properties_.content_rect = content_rect; | 186 draw_properties_.content_rect = content_rect; |
187 } | 187 } |
188 | 188 |
189 void RenderSurfaceImpl::SetContentRectForTesting(const gfx::Rect& rect) { | 189 void RenderSurfaceImpl::SetContentRectForTesting(const gfx::Rect& rect) { |
190 SetContentRect(rect); | 190 SetContentRect(rect); |
191 } | 191 } |
192 | 192 |
| 193 gfx::Rect RenderSurfaceImpl::CalculateExpandedClipForFilters( |
| 194 const gfx::Transform& target_to_surface) { |
| 195 gfx::Rect clip_in_surface_space = |
| 196 MathUtil::ProjectEnclosingClippedRect(target_to_surface, clip_rect()); |
| 197 gfx::Rect expanded_clip_in_surface_space = Filters().MapRectReverse( |
| 198 clip_in_surface_space, FiltersTransform().matrix()); |
| 199 gfx::Rect expanded_clip_in_target_space = MathUtil::MapEnclosingClippedRect( |
| 200 draw_transform(), expanded_clip_in_surface_space); |
| 201 return expanded_clip_in_target_space; |
| 202 } |
| 203 |
193 gfx::Rect RenderSurfaceImpl::CalculateClippedAccumulatedContentRect() { | 204 gfx::Rect RenderSurfaceImpl::CalculateClippedAccumulatedContentRect() { |
194 if (HasCopyRequest() || !is_clipped()) | 205 if (HasCopyRequest() || !is_clipped()) |
195 return accumulated_content_rect(); | 206 return accumulated_content_rect(); |
196 | 207 |
197 if (accumulated_content_rect().IsEmpty()) | 208 if (accumulated_content_rect().IsEmpty()) |
198 return gfx::Rect(); | 209 return gfx::Rect(); |
199 | 210 |
200 // Calculate projection from the target surface rect to local | 211 // Calculate projection from the target surface rect to local |
201 // space. Non-invertible draw transforms means no able to bring clipped rect | 212 // space. Non-invertible draw transforms means no able to bring clipped rect |
202 // in target space back to local space, early out without clip. | 213 // in target space back to local space, early out without clip. |
203 gfx::Transform target_to_surface(gfx::Transform::kSkipInitialization); | 214 gfx::Transform target_to_surface(gfx::Transform::kSkipInitialization); |
204 if (!draw_transform().GetInverse(&target_to_surface)) | 215 if (!draw_transform().GetInverse(&target_to_surface)) |
205 return accumulated_content_rect(); | 216 return accumulated_content_rect(); |
206 | 217 |
207 // Clip rect is in target space. Bring accumulated content rect to | 218 // Clip rect is in target space. Bring accumulated content rect to |
208 // target space in preparation for clipping. | 219 // target space in preparation for clipping. |
209 gfx::Rect accumulated_rect_in_target_space = | 220 gfx::Rect accumulated_rect_in_target_space = |
210 MathUtil::MapEnclosingClippedRect(draw_transform(), | 221 MathUtil::MapEnclosingClippedRect(draw_transform(), |
211 accumulated_content_rect()); | 222 accumulated_content_rect()); |
212 // If accumulated content rect is contained within clip rect, early out | 223 // If accumulated content rect is contained within clip rect, early out |
213 // without clipping. | 224 // without clipping. |
214 if (clip_rect().Contains(accumulated_rect_in_target_space)) | 225 if (clip_rect().Contains(accumulated_rect_in_target_space)) |
215 return accumulated_content_rect(); | 226 return accumulated_content_rect(); |
216 | 227 |
217 gfx::Rect clipped_accumulated_rect_in_target_space = clip_rect(); | 228 gfx::Rect clipped_accumulated_rect_in_target_space; |
| 229 if (Filters().HasFilterThatMovesPixels()) { |
| 230 clipped_accumulated_rect_in_target_space = |
| 231 CalculateExpandedClipForFilters(target_to_surface); |
| 232 } else { |
| 233 clipped_accumulated_rect_in_target_space = clip_rect(); |
| 234 } |
218 clipped_accumulated_rect_in_target_space.Intersect( | 235 clipped_accumulated_rect_in_target_space.Intersect( |
219 accumulated_rect_in_target_space); | 236 accumulated_rect_in_target_space); |
220 | 237 |
221 if (clipped_accumulated_rect_in_target_space.IsEmpty()) | 238 if (clipped_accumulated_rect_in_target_space.IsEmpty()) |
222 return gfx::Rect(); | 239 return gfx::Rect(); |
223 | 240 |
224 gfx::Rect clipped_accumulated_rect_in_local_space = | 241 gfx::Rect clipped_accumulated_rect_in_local_space = |
225 MathUtil::ProjectEnclosingClippedRect( | 242 MathUtil::ProjectEnclosingClippedRect( |
226 target_to_surface, clipped_accumulated_rect_in_target_space); | 243 target_to_surface, clipped_accumulated_rect_in_target_space); |
227 // Bringing clipped accumulated rect back to local space may result | 244 // Bringing clipped accumulated rect back to local space may result |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 417 |
401 RenderPassDrawQuad* quad = | 418 RenderPassDrawQuad* quad = |
402 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 419 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
403 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, | 420 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, |
404 render_pass_id, mask_resource_id, mask_uv_scale, | 421 render_pass_id, mask_resource_id, mask_uv_scale, |
405 mask_texture_size, Filters(), owning_layer_to_target_scale, | 422 mask_texture_size, Filters(), owning_layer_to_target_scale, |
406 FiltersOrigin(), BackgroundFilters()); | 423 FiltersOrigin(), BackgroundFilters()); |
407 } | 424 } |
408 | 425 |
409 } // namespace cc | 426 } // namespace cc |
OLD | NEW |