Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: cc/trees/clip_expander.cc

Issue 2423483003: cc: Make visible rect computation aware of pixel-moving filters (Closed)
Patch Set: Rebaseline Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW
« no previous file with comments | « cc/trees/clip_expander.h ('k') | cc/trees/clip_node.h » ('j') | cc/trees/clip_node.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698