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

Unified Diff: cc/layers/picture_layer_impl.cc

Issue 2175553002: Raster PictureLayerTiling with fractional translation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: alternative: change raster translation if and only if raster scale mutates Created 4 years, 4 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/layers/picture_layer_impl.cc
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 12fe4e679d06f0b50e5137284e2b2273f5e59f9c..98264a7ec5313bc37a4dd024c9b8e40725adfa37 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -830,12 +830,15 @@ void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) {
NoteLayerPropertyChanged();
}
-PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
+PictureLayerTiling* PictureLayerImpl::AddTiling(
+ float contents_scale,
+ const gfx::Vector2dF& contents_translation) {
DCHECK(CanHaveTilings());
DCHECK_GE(contents_scale, MinimumContentsScale());
DCHECK_LE(contents_scale, MaximumContentsScale());
DCHECK(raster_source_->HasRecordings());
- return tilings_->AddTiling(contents_scale, raster_source_);
+ return tilings_->AddTiling(contents_scale, contents_translation,
+ raster_source_);
}
void PictureLayerImpl::RemoveAllTilings() {
@@ -852,8 +855,9 @@ void PictureLayerImpl::AddTilingsForRasterScale() {
PictureLayerTiling* high_res =
tilings_->FindTilingWithScale(raster_contents_scale_);
if (!high_res) {
+ gfx::Vector2dF raster_translation = CalculateRasterTranslation();
// We always need a high res tiling, so create one if it doesn't exist.
- high_res = AddTiling(raster_contents_scale_);
+ high_res = AddTiling(raster_contents_scale_, raster_translation);
} else if (high_res->may_contain_low_resolution_tiles()) {
// If the tiling we find here was LOW_RESOLUTION previously, it may not be
// fully rastered, so destroy the old tiles.
@@ -955,11 +959,34 @@ void PictureLayerImpl::AddLowResolutionTilingIfNeeded() {
bool is_animating = draw_properties().screen_space_transform_is_animating;
if (!is_pinching && !is_animating) {
if (!low_res)
- low_res = AddTiling(low_res_raster_contents_scale_);
+ low_res = AddTiling(low_res_raster_contents_scale_, gfx::Vector2dF());
low_res->set_resolution(LOW_RESOLUTION);
}
}
+gfx::Vector2dF PictureLayerImpl::CalculateRasterTranslation() {
enne (OOO) 2016/08/09 21:02:36 I think this function should use draw transform an
trchen 2016/08/10 01:44:14 Agreed. However ajuma@ mentioned that target trans
ajuma 2016/08/10 13:32:04 More specifically, once we're able to dynamically
enne (OOO) 2016/08/10 18:35:05 I think it is *required* that this approach change
+ if (draw_properties().screen_space_transform_is_animating)
+ return gfx::Vector2dF();
+
+ gfx::Transform screen_space_transform = ScreenSpaceTransform();
+ if (!screen_space_transform.IsScaleOrTranslation())
+ return gfx::Vector2dF();
+
+ // Good match if the maximum alignment error on a layer of size 10000px
+ // does not exceed 0.001px.
+ static constexpr float kErrorThreshold = 0.0000001f;
+ if (std::abs(screen_space_transform.matrix().getFloat(0, 0) -
+ raster_contents_scale_) > kErrorThreshold ||
+ std::abs(screen_space_transform.matrix().getFloat(1, 1) -
+ raster_contents_scale_) > kErrorThreshold)
+ return gfx::Vector2dF();
+
+ float origin_x = screen_space_transform.matrix().getFloat(0, 3);
+ float origin_y = screen_space_transform.matrix().getFloat(1, 3);
+ return gfx::Vector2dF(origin_x - floorf(origin_x),
+ origin_y - floorf(origin_y));
+}
+
void PictureLayerImpl::RecalculateRasterScales() {
if (is_directly_composited_image_) {
if (!raster_source_scale_)

Powered by Google App Engine
This is Rietveld 408576698