Commit c05804da authored by vmpstr's avatar vmpstr Committed by Commit bot
Browse files

cc: Change directly composited image raster source scale occasionally.

This patch changes the behavior of directly composited images in the
following way:

- The scale starts at 1.f.
- It is halved if the ideal source scale is less than half of the raster
  scale.
- It is doubled if the ideal source scale is greater than the raster
  scale.

R=enne, chrishtr, danakj
BUG=606287
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review-Url: https://codereview.chromium.org/2100483003
Cr-Commit-Position: refs/heads/master@{#402333}
parent a61f420b
...@@ -874,9 +874,14 @@ void PictureLayerImpl::AddTilingsForRasterScale() { ...@@ -874,9 +874,14 @@ void PictureLayerImpl::AddTilingsForRasterScale() {
} }
bool PictureLayerImpl::ShouldAdjustRasterScale() const { bool PictureLayerImpl::ShouldAdjustRasterScale() const {
// TODO(vmpstr): We might want to adjust the raster scale once in a while. if (is_directly_composited_image_) {
if (is_directly_composited_image_) float max_scale = std::max(1.f, MinimumContentsScale());
if (raster_source_scale_ < std::min(ideal_source_scale_, max_scale))
return true;
if (raster_source_scale_ > 4 * ideal_source_scale_)
return true;
return false; return false;
}
if (was_screen_space_transform_animating_ != if (was_screen_space_transform_animating_ !=
draw_properties().screen_space_transform_is_animating) draw_properties().screen_space_transform_is_animating)
...@@ -956,11 +961,25 @@ void PictureLayerImpl::AddLowResolutionTilingIfNeeded() { ...@@ -956,11 +961,25 @@ void PictureLayerImpl::AddLowResolutionTilingIfNeeded() {
} }
void PictureLayerImpl::RecalculateRasterScales() { void PictureLayerImpl::RecalculateRasterScales() {
// TODO(vmpstr): We might want to adjust these once in a while.
if (is_directly_composited_image_) { if (is_directly_composited_image_) {
if (!raster_source_scale_)
raster_source_scale_ = 1.f;
float min_scale = MinimumContentsScale();
float max_scale = std::max(1.f, MinimumContentsScale());
float clamped_ideal_source_scale_ =
std::max(min_scale, std::min(ideal_source_scale_, max_scale));
while (raster_source_scale_ < clamped_ideal_source_scale_)
raster_source_scale_ *= 2.f;
while (raster_source_scale_ > 4 * clamped_ideal_source_scale_)
raster_source_scale_ /= 2.f;
raster_source_scale_ =
std::max(min_scale, std::min(raster_source_scale_, max_scale));
raster_page_scale_ = 1.f; raster_page_scale_ = 1.f;
raster_device_scale_ = 1.f; raster_device_scale_ = 1.f;
raster_source_scale_ = std::max(1.f, MinimumContentsScale());
raster_contents_scale_ = raster_source_scale_; raster_contents_scale_ = raster_source_scale_;
low_res_raster_contents_scale_ = raster_contents_scale_; low_res_raster_contents_scale_ = raster_contents_scale_;
return; return;
...@@ -1195,15 +1214,6 @@ PictureLayerImpl::CreatePictureLayerTilingSet() { ...@@ -1195,15 +1214,6 @@ PictureLayerImpl::CreatePictureLayerTilingSet() {
} }
void PictureLayerImpl::UpdateIdealScales() { void PictureLayerImpl::UpdateIdealScales() {
// TODO(vmpstr): We might want to adjust these once in a while.
if (is_directly_composited_image_) {
ideal_contents_scale_ = 1.f;
ideal_page_scale_ = 1.f;
ideal_device_scale_ = 1.f;
ideal_source_scale_ = 1.f;
return;
}
DCHECK(CanHaveTilings()); DCHECK(CanHaveTilings());
float min_contents_scale = MinimumContentsScale(); float min_contents_scale = MinimumContentsScale();
......
...@@ -4944,5 +4944,67 @@ TEST_F(PictureLayerImplTest, CompositedImageIgnoreIdealContentsScale) { ...@@ -4944,5 +4944,67 @@ TEST_F(PictureLayerImplTest, CompositedImageIgnoreIdealContentsScale) {
EXPECT_EQ(0, data.num_incomplete_tiles); EXPECT_EQ(0, data.num_incomplete_tiles);
} }
TEST_F(PictureLayerImplTest, CompositedImageRasterScaleChanges) {
gfx::Size layer_bounds(400, 400);
scoped_refptr<FakeRasterSource> pending_raster_source =
FakeRasterSource::CreateFilled(layer_bounds);
host_impl()->CreatePendingTree();
LayerTreeImpl* pending_tree = host_impl()->pending_tree();
std::unique_ptr<FakePictureLayerImpl> pending_layer =
FakePictureLayerImpl::CreateWithRasterSource(pending_tree, layer_id(),
pending_raster_source);
pending_layer->set_is_directly_composited_image(true);
pending_layer->SetDrawsContent(true);
FakePictureLayerImpl* pending_layer_ptr = pending_layer.get();
pending_tree->SetRootLayer(std::move(pending_layer));
pending_tree->BuildLayerListAndPropertyTreesForTesting();
float expected_contents_scale = 0.25f;
for (int i = 1; i < 30; ++i) {
float ideal_contents_scale = 0.1f * i - 1e-6;
switch (i) {
// Scale 0.3.
case 3:
expected_contents_scale = 0.5f;
break;
// Scale 0.6.
case 6:
expected_contents_scale = 1.f;
break;
}
SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale,
1.f, 1.f, 1.f, 1.f, false);
EXPECT_FLOAT_EQ(expected_contents_scale,
pending_layer_ptr->picture_layer_tiling_set()
->FindTilingWithResolution(HIGH_RESOLUTION)
->contents_scale())
<< "ideal_contents_scale: " << ideal_contents_scale;
}
expected_contents_scale = 1.f;
for (int i = 30; i >= 1; --i) {
float ideal_contents_scale = 0.1f * i - 1e-6;
switch (i) {
// Scale 0.2.
case 2:
expected_contents_scale = 0.5f;
break;
// Scale 0.1.
case 1:
expected_contents_scale = 0.25f;
break;
}
SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale,
1.f, 1.f, 1.f, 1.f, false);
EXPECT_FLOAT_EQ(expected_contents_scale,
pending_layer_ptr->picture_layer_tiling_set()
->FindTilingWithResolution(HIGH_RESOLUTION)
->contents_scale())
<< "ideal_contents_scale: " << ideal_contents_scale;
}
}
} // namespace } // namespace
} // namespace cc } // namespace cc
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment