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

Unified Diff: cc/layers/picture_layer.cc

Issue 2559413002: [1/5] Pass transformed rasterization policy from Blink (Closed)
Patch Set: rebase Created 3 years, 9 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
« no previous file with comments | « cc/layers/picture_layer.h ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/picture_layer.cc
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc
index c9786e728861f952be68ddfa3810176305842d2c..40742e50ea8b845178c2eeeb20a37e59219a473a 100644
--- a/cc/layers/picture_layer.cc
+++ b/cc/layers/picture_layer.cc
@@ -12,6 +12,7 @@
#include "cc/paint/paint_record.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_impl.h"
+#include "cc/trees/transform_node.h"
#include "ui/gfx/geometry/rect_conversions.h"
namespace cc {
@@ -54,6 +55,8 @@ void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
DropRecordingSourceContentIfInvalid();
layer_impl->SetNearestNeighbor(picture_layer_inputs_.nearest_neighbor);
+ layer_impl->SetUseTransformedRasterization(
+ ShouldUseTransformedRasterization());
// Preserve lcd text settings from the current raster source.
bool can_use_lcd_text = layer_impl->RasterSourceUsesLCDText();
@@ -198,6 +201,14 @@ void PictureLayer::SetNearestNeighbor(bool nearest_neighbor) {
SetNeedsCommit();
}
+void PictureLayer::SetAllowTransformedRasterization(bool allowed) {
+ if (picture_layer_inputs_.allow_transformed_rasterization == allowed)
+ return;
+
+ picture_layer_inputs_.allow_transformed_rasterization = allowed;
+ SetNeedsCommit();
+}
+
bool PictureLayer::HasDrawableContent() const {
return picture_layer_inputs_.client && Layer::HasDrawableContent();
}
@@ -233,6 +244,32 @@ void PictureLayer::DropRecordingSourceContentIfInvalid() {
}
}
+bool PictureLayer::ShouldUseTransformedRasterization() const {
+ if (!picture_layer_inputs_.allow_transformed_rasterization)
+ return false;
+
+ const TransformTree& transform_tree =
+ layer_tree_host()->property_trees()->transform_tree;
+ DCHECK(!transform_tree.needs_update());
+ if (transform_tree.Node(transform_tree_index())
+ ->to_screen_is_potentially_animated)
+ return false;
+
+ const gfx::Transform& to_screen =
+ transform_tree.ToScreen(transform_tree_index());
+ if (!to_screen.IsScaleOrTranslation())
+ return false;
+
+ float origin_x =
+ to_screen.matrix().getFloat(0, 3) + offset_to_transform_parent().x();
+ float origin_y =
+ to_screen.matrix().getFloat(1, 3) + offset_to_transform_parent().y();
+ if (origin_x - floorf(origin_x) == 0.f && origin_y - floorf(origin_y) == 0.f)
+ return false;
+
+ return true;
+}
+
const DisplayItemList* PictureLayer::GetDisplayItemList() {
return picture_layer_inputs_.display_list.get();
}
« no previous file with comments | « cc/layers/picture_layer.h ('k') | cc/layers/picture_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698