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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/clip_expander.cc
diff --git a/cc/trees/clip_expander.cc b/cc/trees/clip_expander.cc
new file mode 100644
index 0000000000000000000000000000000000000000..43bbb406e3f0fccea84fee644926915dd2b62b60
--- /dev/null
+++ b/cc/trees/clip_expander.cc
@@ -0,0 +1,64 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/trees/clip_expander.h"
+#include "cc/trees/effect_node.h"
+#include "cc/trees/property_tree.h"
+#include "ui/gfx/transform.h"
+
+namespace cc {
+
+ClipExpander::ClipExpander()
+ : expander_type_(ExpanderType::NONE),
+ target_effect_id_(EffectTree::kInvalidNodeId) {}
+
+ClipExpander::ClipExpander(ExpanderType type, int filter_effect_id)
+ : expander_type_(type), target_effect_id_(filter_effect_id) {
+ DCHECK(type == ExpanderType::FILTER ||
+ filter_effect_id == EffectTree::kInvalidNodeId);
+}
+
+ClipExpander ClipExpander::CreateForFilter(int effect_node_id) {
+ return ClipExpander(ExpanderType::FILTER, effect_node_id);
+}
+
+gfx::Rect ClipExpander::MapRect(const gfx::Rect& rect,
+ const PropertyTrees* property_trees) const {
+ switch (expander_type_) {
+ case ExpanderType::NONE:
+ return rect;
+ case ExpanderType::FILTER: {
+ const EffectNode* effect_node =
+ property_trees->effect_tree.Node(target_effect_id_);
+ gfx::Transform filter_draw_transform;
+ filter_draw_transform.Scale(effect_node->surface_contents_scale.x(),
+ effect_node->surface_contents_scale.y());
+ return effect_node->filters.MapRect(rect, filter_draw_transform.matrix());
+ }
+ }
+ NOTREACHED();
+ return gfx::Rect();
+}
+
+gfx::Rect ClipExpander::MapRectReverse(
+ const gfx::Rect& rect,
+ const PropertyTrees* property_trees) const {
+ switch (expander_type_) {
+ case ExpanderType::NONE:
+ return rect;
+ case ExpanderType::FILTER: {
+ const EffectNode* effect_node =
+ property_trees->effect_tree.Node(target_effect_id_);
+ gfx::Transform filter_draw_transform;
+ filter_draw_transform.Scale(effect_node->surface_contents_scale.x(),
+ effect_node->surface_contents_scale.y());
+ return effect_node->filters.MapRectReverse(
+ rect, filter_draw_transform.matrix());
+ }
+ }
+ NOTREACHED();
+ return gfx::Rect();
+}
+
+} // namespace cc
« 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