OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/trees/clip_expander.h" |
| 6 #include "cc/trees/effect_node.h" |
| 7 #include "cc/trees/property_tree.h" |
| 8 #include "ui/gfx/transform.h" |
| 9 |
| 10 namespace cc { |
| 11 |
| 12 ClipExpander::ClipExpander() |
| 13 : expander_type_(ExpanderType::NONE), |
| 14 target_effect_id_(EffectTree::kInvalidNodeId) {} |
| 15 |
| 16 ClipExpander::ClipExpander(ExpanderType type, int filter_effect_id) |
| 17 : expander_type_(type), target_effect_id_(filter_effect_id) { |
| 18 DCHECK(type == ExpanderType::FILTER || |
| 19 filter_effect_id == EffectTree::kInvalidNodeId); |
| 20 } |
| 21 |
| 22 ClipExpander ClipExpander::CreateForFilter(int effect_node_id) { |
| 23 return ClipExpander(ExpanderType::FILTER, effect_node_id); |
| 24 } |
| 25 |
| 26 gfx::Rect ClipExpander::MapRect(const gfx::Rect& rect, |
| 27 const PropertyTrees* property_trees) const { |
| 28 switch (expander_type_) { |
| 29 case ExpanderType::NONE: |
| 30 return rect; |
| 31 case ExpanderType::FILTER: { |
| 32 const EffectNode* effect_node = |
| 33 property_trees->effect_tree.Node(target_effect_id_); |
| 34 gfx::Transform filter_draw_transform; |
| 35 filter_draw_transform.Scale(effect_node->surface_contents_scale.x(), |
| 36 effect_node->surface_contents_scale.y()); |
| 37 return effect_node->filters.MapRect(rect, filter_draw_transform.matrix()); |
| 38 } |
| 39 } |
| 40 NOTREACHED(); |
| 41 return gfx::Rect(); |
| 42 } |
| 43 |
| 44 gfx::Rect ClipExpander::MapRectReverse( |
| 45 const gfx::Rect& rect, |
| 46 const PropertyTrees* property_trees) const { |
| 47 switch (expander_type_) { |
| 48 case ExpanderType::NONE: |
| 49 return rect; |
| 50 case ExpanderType::FILTER: { |
| 51 const EffectNode* effect_node = |
| 52 property_trees->effect_tree.Node(target_effect_id_); |
| 53 gfx::Transform filter_draw_transform; |
| 54 filter_draw_transform.Scale(effect_node->surface_contents_scale.x(), |
| 55 effect_node->surface_contents_scale.y()); |
| 56 return effect_node->filters.MapRectReverse( |
| 57 rect, filter_draw_transform.matrix()); |
| 58 } |
| 59 } |
| 60 NOTREACHED(); |
| 61 return gfx::Rect(); |
| 62 } |
| 63 |
| 64 } // namespace cc |
OLD | NEW |