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 | |
204 gfx::Rect RenderSurfaceImpl::CalculateClippedAccumulatedContentRect() { | 193 gfx::Rect RenderSurfaceImpl::CalculateClippedAccumulatedContentRect() { |
205 if (HasCopyRequest() || !is_clipped()) | 194 if (HasCopyRequest() || !is_clipped()) |
206 return accumulated_content_rect(); | 195 return accumulated_content_rect(); |
207 | 196 |
208 if (accumulated_content_rect().IsEmpty()) | 197 if (accumulated_content_rect().IsEmpty()) |
209 return gfx::Rect(); | 198 return gfx::Rect(); |
210 | 199 |
211 // Calculate projection from the target surface rect to local | 200 // Calculate projection from the target surface rect to local |
212 // space. Non-invertible draw transforms means no able to bring clipped rect | 201 // space. Non-invertible draw transforms means no able to bring clipped rect |
213 // in target space back to local space, early out without clip. | 202 // in target space back to local space, early out without clip. |
214 gfx::Transform target_to_surface(gfx::Transform::kSkipInitialization); | 203 gfx::Transform target_to_surface(gfx::Transform::kSkipInitialization); |
215 if (!draw_transform().GetInverse(&target_to_surface)) | 204 if (!draw_transform().GetInverse(&target_to_surface)) |
216 return accumulated_content_rect(); | 205 return accumulated_content_rect(); |
217 | 206 |
218 // Clip rect is in target space. Bring accumulated content rect to | 207 // Clip rect is in target space. Bring accumulated content rect to |
219 // target space in preparation for clipping. | 208 // target space in preparation for clipping. |
220 gfx::Rect accumulated_rect_in_target_space = | 209 gfx::Rect accumulated_rect_in_target_space = |
221 MathUtil::MapEnclosingClippedRect(draw_transform(), | 210 MathUtil::MapEnclosingClippedRect(draw_transform(), |
222 accumulated_content_rect()); | 211 accumulated_content_rect()); |
223 // If accumulated content rect is contained within clip rect, early out | 212 // If accumulated content rect is contained within clip rect, early out |
224 // without clipping. | 213 // without clipping. |
225 if (clip_rect().Contains(accumulated_rect_in_target_space)) | 214 if (clip_rect().Contains(accumulated_rect_in_target_space)) |
226 return accumulated_content_rect(); | 215 return accumulated_content_rect(); |
227 | 216 |
228 gfx::Rect clipped_accumulated_rect_in_target_space; | 217 gfx::Rect clipped_accumulated_rect_in_target_space = clip_rect(); |
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 } | |
235 clipped_accumulated_rect_in_target_space.Intersect( | 218 clipped_accumulated_rect_in_target_space.Intersect( |
236 accumulated_rect_in_target_space); | 219 accumulated_rect_in_target_space); |
237 | 220 |
238 if (clipped_accumulated_rect_in_target_space.IsEmpty()) | 221 if (clipped_accumulated_rect_in_target_space.IsEmpty()) |
239 return gfx::Rect(); | 222 return gfx::Rect(); |
240 | 223 |
241 gfx::Rect clipped_accumulated_rect_in_local_space = | 224 gfx::Rect clipped_accumulated_rect_in_local_space = |
242 MathUtil::ProjectEnclosingClippedRect( | 225 MathUtil::ProjectEnclosingClippedRect( |
243 target_to_surface, clipped_accumulated_rect_in_target_space); | 226 target_to_surface, clipped_accumulated_rect_in_target_space); |
244 // Bringing clipped accumulated rect back to local space may result | 227 // Bringing clipped accumulated rect back to local space may result |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 | 404 |
422 RenderPassDrawQuad* quad = | 405 RenderPassDrawQuad* quad = |
423 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 406 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
424 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, | 407 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, |
425 render_pass_id, mask_resource_id, mask_uv_scale, | 408 render_pass_id, mask_resource_id, mask_uv_scale, |
426 mask_texture_size, Filters(), owning_layer_to_target_scale, | 409 mask_texture_size, Filters(), owning_layer_to_target_scale, |
427 FiltersOrigin(), BackgroundFilters()); | 410 FiltersOrigin(), BackgroundFilters()); |
428 } | 411 } |
429 | 412 |
430 } // namespace cc | 413 } // namespace cc |
OLD | NEW |