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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 is_clipped = false; | 69 is_clipped = false; |
70 } | 70 } |
71 | 71 |
72 RenderSurfaceImpl::DrawProperties::~DrawProperties() {} | 72 RenderSurfaceImpl::DrawProperties::~DrawProperties() {} |
73 | 73 |
74 gfx::RectF RenderSurfaceImpl::DrawableContentRect() const { | 74 gfx::RectF RenderSurfaceImpl::DrawableContentRect() const { |
75 if (content_rect().IsEmpty()) | 75 if (content_rect().IsEmpty()) |
76 return gfx::RectF(); | 76 return gfx::RectF(); |
77 | 77 |
78 gfx::Rect surface_content_rect = content_rect(); | 78 gfx::Rect surface_content_rect = content_rect(); |
79 if (!owning_layer_->filters().IsEmpty()) { | 79 const FilterOperations& filters = Filters(); |
| 80 if (!filters.IsEmpty()) { |
80 const gfx::Transform& owning_layer_draw_transform = | 81 const gfx::Transform& owning_layer_draw_transform = |
81 owning_layer_->DrawTransform(); | 82 owning_layer_->DrawTransform(); |
82 DCHECK(owning_layer_draw_transform.IsScale2d()); | 83 DCHECK(owning_layer_draw_transform.IsScale2d()); |
83 surface_content_rect = owning_layer_->filters().MapRect( | 84 surface_content_rect = filters.MapRect( |
84 surface_content_rect, owning_layer_draw_transform.matrix()); | 85 surface_content_rect, owning_layer_draw_transform.matrix()); |
85 } | 86 } |
86 gfx::RectF drawable_content_rect = MathUtil::MapClippedRect( | 87 gfx::RectF drawable_content_rect = MathUtil::MapClippedRect( |
87 draw_transform(), gfx::RectF(surface_content_rect)); | 88 draw_transform(), gfx::RectF(surface_content_rect)); |
88 if (HasReplica()) { | 89 if (HasReplica()) { |
89 drawable_content_rect.Union(MathUtil::MapClippedRect( | 90 drawable_content_rect.Union(MathUtil::MapClippedRect( |
90 replica_draw_transform(), gfx::RectF(surface_content_rect))); | 91 replica_draw_transform(), gfx::RectF(surface_content_rect))); |
91 } else if (!owning_layer_->filters().IsEmpty() && is_clipped()) { | 92 } else if (!filters.IsEmpty() && is_clipped()) { |
92 // Filter could move pixels around, but still need to be clipped. | 93 // Filter could move pixels around, but still need to be clipped. |
93 drawable_content_rect.Intersect(gfx::RectF(clip_rect())); | 94 drawable_content_rect.Intersect(gfx::RectF(clip_rect())); |
94 } | 95 } |
95 | 96 |
96 // If the rect has a NaN coordinate, we return empty rect to avoid crashes in | 97 // If the rect has a NaN coordinate, we return empty rect to avoid crashes in |
97 // functions (for example, gfx::ToEnclosedRect) that are called on this rect. | 98 // functions (for example, gfx::ToEnclosedRect) that are called on this rect. |
98 if (std::isnan(drawable_content_rect.x()) || | 99 if (std::isnan(drawable_content_rect.x()) || |
99 std::isnan(drawable_content_rect.y()) || | 100 std::isnan(drawable_content_rect.y()) || |
100 std::isnan(drawable_content_rect.right()) || | 101 std::isnan(drawable_content_rect.right()) || |
101 std::isnan(drawable_content_rect.bottom())) | 102 std::isnan(drawable_content_rect.bottom())) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 151 |
151 LayerImpl* RenderSurfaceImpl::ReplicaMaskLayer() { | 152 LayerImpl* RenderSurfaceImpl::ReplicaMaskLayer() { |
152 int replica_mask_layer_id = OwningEffectNode()->replica_mask_layer_id; | 153 int replica_mask_layer_id = OwningEffectNode()->replica_mask_layer_id; |
153 return owning_layer_->layer_tree_impl()->LayerById(replica_mask_layer_id); | 154 return owning_layer_->layer_tree_impl()->LayerById(replica_mask_layer_id); |
154 } | 155 } |
155 | 156 |
156 bool RenderSurfaceImpl::HasReplicaMask() const { | 157 bool RenderSurfaceImpl::HasReplicaMask() const { |
157 return OwningEffectNode()->replica_mask_layer_id != -1; | 158 return OwningEffectNode()->replica_mask_layer_id != -1; |
158 } | 159 } |
159 | 160 |
| 161 const FilterOperations& RenderSurfaceImpl::Filters() const { |
| 162 return OwningEffectNode()->filters; |
| 163 } |
| 164 |
160 const FilterOperations& RenderSurfaceImpl::BackgroundFilters() const { | 165 const FilterOperations& RenderSurfaceImpl::BackgroundFilters() const { |
161 return OwningEffectNode()->background_filters; | 166 return OwningEffectNode()->background_filters; |
162 } | 167 } |
163 | 168 |
164 bool RenderSurfaceImpl::HasCopyRequest() const { | 169 bool RenderSurfaceImpl::HasCopyRequest() const { |
165 return OwningEffectNode()->has_copy_request; | 170 return OwningEffectNode()->has_copy_request; |
166 } | 171 } |
167 | 172 |
168 int RenderSurfaceImpl::TransformTreeIndex() const { | 173 int RenderSurfaceImpl::TransformTreeIndex() const { |
169 return owning_layer_->transform_tree_index(); | 174 return owning_layer_->transform_tree_index(); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 } | 394 } |
390 | 395 |
391 DCHECK(owning_layer_draw_transform.IsScale2d()); | 396 DCHECK(owning_layer_draw_transform.IsScale2d()); |
392 gfx::Vector2dF owning_layer_to_target_scale = | 397 gfx::Vector2dF owning_layer_to_target_scale = |
393 owning_layer_draw_transform.Scale2d(); | 398 owning_layer_draw_transform.Scale2d(); |
394 | 399 |
395 RenderPassDrawQuad* quad = | 400 RenderPassDrawQuad* quad = |
396 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 401 render_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
397 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, | 402 quad->SetNew(shared_quad_state, content_rect(), visible_layer_rect, |
398 render_pass_id, mask_resource_id, mask_uv_scale, | 403 render_pass_id, mask_resource_id, mask_uv_scale, |
399 mask_texture_size, owning_layer_->filters(), | 404 mask_texture_size, Filters(), owning_layer_to_target_scale, |
400 owning_layer_to_target_scale, BackgroundFilters()); | 405 BackgroundFilters()); |
401 } | 406 } |
402 | 407 |
403 } // namespace cc | 408 } // namespace cc |
OLD | NEW |