| 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(ExpanderType type, int filter_effect_id) |
| 13 : expander_type_(type), target_effect_id_(filter_effect_id) {} |
| 14 |
| 15 ClipExpander::ClipExpander(const ClipExpander& other) = default; |
| 16 |
| 17 bool ClipExpander::operator==(const ClipExpander& other) const { |
| 18 return expander_type_ == other.expander_type_ && |
| 19 target_effect_id_ == other.target_effect_id_; |
| 20 } |
| 21 |
| 22 gfx::Rect ClipExpander::MapRect(const gfx::Rect& rect, |
| 23 const PropertyTrees* property_trees) const { |
| 24 switch (expander_type_) { |
| 25 case ExpanderType::FILTER: { |
| 26 const EffectNode* effect_node = |
| 27 property_trees->effect_tree.Node(target_effect_id_); |
| 28 gfx::Transform filter_draw_transform; |
| 29 filter_draw_transform.Scale(effect_node->surface_contents_scale.x(), |
| 30 effect_node->surface_contents_scale.y()); |
| 31 return effect_node->filters.MapRect(rect, filter_draw_transform.matrix()); |
| 32 } |
| 33 } |
| 34 NOTREACHED(); |
| 35 return gfx::Rect(); |
| 36 } |
| 37 |
| 38 gfx::Rect ClipExpander::MapRectReverse( |
| 39 const gfx::Rect& rect, |
| 40 const PropertyTrees* property_trees) const { |
| 41 switch (expander_type_) { |
| 42 case ExpanderType::FILTER: { |
| 43 const EffectNode* effect_node = |
| 44 property_trees->effect_tree.Node(target_effect_id_); |
| 45 gfx::Transform filter_draw_transform; |
| 46 filter_draw_transform.Scale(effect_node->surface_contents_scale.x(), |
| 47 effect_node->surface_contents_scale.y()); |
| 48 return effect_node->filters.MapRectReverse( |
| 49 rect, filter_draw_transform.matrix()); |
| 50 } |
| 51 } |
| 52 NOTREACHED(); |
| 53 return gfx::Rect(); |
| 54 } |
| 55 |
| 56 } // namespace cc |
| OLD | NEW |