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

Unified Diff: cc/layers/picture_layer.cc

Issue 2175553002: Raster PictureLayerTiling with fractional translation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: combined 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..6cf58ba6bae3dd6a887a390dd6ce34a7f60d69b4 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();
@@ -100,7 +103,13 @@ bool PictureLayer::Update() {
gfx::Size layer_size = paint_properties().bounds;
- recording_source_->SetBackgroundColor(SafeOpaqueBackgroundColor());
+ // When transformed rasterization is used, we try to match the rendering
+ // without a compositing layer, thus we don't over draw background to fill
+ // snapped edges.
+ SkColor background_color = ShouldUseTransformedRasterization()
+ ? SK_ColorTRANSPARENT
+ : SafeOpaqueBackgroundColor();
+ recording_source_->SetBackgroundColor(background_color);
recording_source_->SetRequiresClear(
!contents_opaque() &&
!picture_layer_inputs_.client->FillsBoundsCompletely());
@@ -198,6 +207,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 +250,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