0

Reland "Enable transformed rasterization for most layers"

This reverts commit 5fd12ebf05.

Reason for revert: No obvious change for crbug.com/1121730.

Original change's description:
> Revert "Enable transformed rasterization for most layers"
>
> This reverts commit b179b125df.
>
> Reason for revert: for debugging crbug.com/1121730
>
> Original change's description:
> > Enable transformed rasterization for most layers
> > 
> > Background: transformed rasterization is used to render sharp text in a
> > composited layer with fractional transform. It snaps the composited
> > transform of the layer to whole pixels, then applies the fraction
> > during rasterization.
> > 
> > Previously we disallowed transformed rasterization in blink for directly
> > composited layers (excluding backface-visibility:hidden and trivial 3d
> > transforms such as translateZ(0)), especially for will-change:transform
> > because change of fractional transform would cause re-rasterization
> > which would defeat the purpose of will-change:transform.
> > 
> > Now for a layer that was not eligible for transformed rasterization,
> > calculate the initial raster translation which achieves sharp text
> > rendering with the initial transform. When the transform of the layer
> > changes, keep its original raster translation to avoid invalidation
> > of tilings, to ensure animation performance. The rendered result will
> > be blurry during animation but the initial rendering result is sharp.
> > 
> > Remove blink-side transformed rasterization conditions and let cc
> > decide it based on screen and draw transforms of the layers.
> > 
> > Bug: 1111195
> > Change-Id: If0455be2f29e69cd7152c951626e6e8cc143b5bd
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2351164
> > Reviewed-by: Philip Rogers <pdr@chromium.org>
> > Reviewed-by: vmpstr <vmpstr@chromium.org>
> > Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#798268}
>
> TBR=wangxianzhu@chromium.org,vmpstr@chromium.org,pdr@chromium.org
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: 1111195, 1121730
> Change-Id: Ibab42e963cab263cab062377ffa2aad38291c5a9
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427125
> Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
> Reviewed-by: Philip Rogers <pdr@chromium.org>
> Reviewed-by: vmpstr <vmpstr@chromium.org>
> Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#810026}

TBR=wangxianzhu@chromium.org,vmpstr@chromium.org,pdr@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1111195
Bug: 1121730
Change-Id: Ie61adb5086d7424346ec3ca006555e31e936be43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2435803
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: vmpstr <vmpstr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811471}
This commit is contained in:
Xianzhu Wang
2020-09-29 00:48:37 +00:00
committed by Commit Bot
parent db3378c8fc
commit f0aa1b1cf5
14 changed files with 176 additions and 338 deletions

@ -61,8 +61,6 @@ void PictureLayer::PushPropertiesTo(LayerImpl* base_layer) {
DropRecordingSourceContentIfInvalid();
layer_impl->SetNearestNeighbor(picture_layer_inputs_.nearest_neighbor);
layer_impl->SetUseTransformedRasterization(
ShouldUseTransformedRasterization());
layer_impl->set_gpu_raster_max_texture_size(
layer_tree_host()->device_viewport_rect().size());
layer_impl->SetIsBackdropFilterMask(is_backdrop_filter_mask());
@ -215,14 +213,6 @@ void PictureLayer::SetNearestNeighbor(bool nearest_neighbor) {
SetNeedsCommit();
}
void PictureLayer::SetTransformedRasterizationAllowed(bool allowed) {
if (picture_layer_inputs_.transformed_rasterization_allowed == allowed)
return;
picture_layer_inputs_.transformed_rasterization_allowed = allowed;
SetNeedsCommit();
}
bool PictureLayer::HasDrawableContent() const {
return picture_layer_inputs_.client && Layer::HasDrawableContent();
}
@ -305,38 +295,6 @@ void PictureLayer::DropRecordingSourceContentIfInvalid() {
}
}
bool PictureLayer::ShouldUseTransformedRasterization() const {
if (!picture_layer_inputs_.transformed_rasterization_allowed)
return false;
const TransformTree& transform_tree =
layer_tree_host()->property_trees()->transform_tree;
DCHECK(!transform_tree.needs_update());
auto* transform_node = transform_tree.Node(transform_tree_index());
DCHECK(transform_node);
// TODO(pdr): This is a workaround for https://crbug.com/708951 to avoid
// crashing when there's no transform node. This workaround should be removed.
if (!transform_node)
return false;
if (transform_node->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();
}

@ -33,11 +33,6 @@ class CC_EXPORT PictureLayer : public Layer {
return picture_layer_inputs_.nearest_neighbor;
}
void SetTransformedRasterizationAllowed(bool allowed);
bool transformed_rasterization_allowed() const {
return picture_layer_inputs_.transformed_rasterization_allowed;
}
void SetIsBackdropFilterMask(bool is_backdrop_filter_mask);
bool is_backdrop_filter_mask() const {
return picture_layer_inputs_.is_backdrop_filter_mask;
@ -70,7 +65,6 @@ class CC_EXPORT PictureLayer : public Layer {
ContentLayerClient* client = nullptr;
bool nearest_neighbor = false;
bool transformed_rasterization_allowed = false;
bool is_backdrop_filter_mask = false;
scoped_refptr<DisplayItemList> display_list;
base::Optional<gfx::Size> directly_composited_image_size = base::nullopt;
@ -92,8 +86,6 @@ class CC_EXPORT PictureLayer : public Layer {
void DropRecordingSourceContentIfInvalid();
bool ShouldUseTransformedRasterization() const;
std::unique_ptr<RecordingSource> recording_source_;
devtools_instrumentation::
ScopedLayerObjectTracker instrumentation_object_tracker_;

@ -100,7 +100,6 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id)
was_screen_space_transform_animating_(false),
only_used_low_res_last_append_quads_(false),
nearest_neighbor_(false),
use_transformed_rasterization_(false),
lcd_text_disallowed_reason_(LCDTextDisallowedReason::kNone),
directly_composited_image_size_(base::nullopt),
directly_composited_image_initial_raster_scale_(0.f),
@ -156,7 +155,6 @@ void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) {
layer_impl->twin_layer_ = this;
layer_impl->SetNearestNeighbor(nearest_neighbor_);
layer_impl->SetUseTransformedRasterization(use_transformed_rasterization_);
layer_impl->SetDirectlyCompositedImageSize(directly_composited_image_size_);
layer_impl->SetIsBackdropFilterMask(is_backdrop_filter_mask_);
@ -814,22 +812,15 @@ void PictureLayerImpl::UpdateRasterSource(
}
}
bool PictureLayerImpl::UpdateCanUseLCDText() {
void PictureLayerImpl::UpdateCanUseLCDText(
bool raster_translation_aligns_pixels) {
// If we have pending/active trees, the active tree doesn't update lcd text
// status but copies it from the pending tree.
if (!layer_tree_impl()->IsSyncTree())
return false;
return;
// Once we disable lcd text, we don't re-enable it.
if (!can_use_lcd_text())
return false;
auto new_lcd_text_disallowed_reason = ComputeLCDTextDisallowedReason();
if (lcd_text_disallowed_reason_ == new_lcd_text_disallowed_reason)
return false;
lcd_text_disallowed_reason_ = new_lcd_text_disallowed_reason;
return true;
lcd_text_disallowed_reason_ =
ComputeLCDTextDisallowedReason(raster_translation_aligns_pixels);
}
bool PictureLayerImpl::HasWillChangeTransformHint() const {
@ -838,8 +829,8 @@ bool PictureLayerImpl::HasWillChangeTransformHint() const {
return transform_node && transform_node->will_change_transform;
}
LCDTextDisallowedReason PictureLayerImpl::ComputeLCDTextDisallowedReason()
const {
LCDTextDisallowedReason PictureLayerImpl::ComputeLCDTextDisallowedReason(
bool raster_translation_aligns_pixels) const {
// No need to use LCD text if there is no text.
if (!raster_source_ || !raster_source_->GetDisplayItemList() ||
!raster_source_->GetDisplayItemList()->has_draw_text_ops()) {
@ -856,17 +847,16 @@ LCDTextDisallowedReason PictureLayerImpl::ComputeLCDTextDisallowedReason()
return LCDTextDisallowedReason::kContentsNotOpaque;
}
if (!use_transformed_rasterization_) {
if (!GetTransformTree()
.Node(transform_tree_index())
->node_and_ancestors_have_only_integer_translation)
return LCDTextDisallowedReason::kNonIntegralTranslation;
// If raster translation aligns pixels, we can ignore fractional layer offset
// and transform for LCD text.
if (!raster_translation_aligns_pixels) {
if (static_cast<int>(offset_to_transform_parent().x()) !=
offset_to_transform_parent().x())
return LCDTextDisallowedReason::kNonIntegralXOffset;
if (static_cast<int>(offset_to_transform_parent().y()) !=
offset_to_transform_parent().y())
return LCDTextDisallowedReason::kNonIntegralYOffset;
return LCDTextDisallowedReason::kNonIntegralTranslation;
}
TransformNode* transform_node =
@ -874,6 +864,9 @@ LCDTextDisallowedReason PictureLayerImpl::ComputeLCDTextDisallowedReason()
if (transform_node->node_or_ancestors_will_change_transform)
return LCDTextDisallowedReason::kWillChangeTransform;
if (screen_space_transform_is_animating())
return LCDTextDisallowedReason::kTransformAnimation;
EffectNode* effect_node = GetEffectTree().Node(effect_tree_index());
if (effect_node->node_or_ancestor_has_filters ||
effect_node->affected_by_backdrop_filter)
@ -882,6 +875,13 @@ LCDTextDisallowedReason PictureLayerImpl::ComputeLCDTextDisallowedReason()
return LCDTextDisallowedReason::kNone;
}
LCDTextDisallowedReason
PictureLayerImpl::ComputeLCDTextDisallowedReasonForTesting() const {
gfx::Vector2dF raster_translation;
return ComputeLCDTextDisallowedReason(
CalculateRasterTranslation(raster_translation));
}
void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) {
if (layer_tree_impl()->IsActiveTree())
damage_rect_.Union(tile->enclosing_layer_rect());
@ -1091,14 +1091,6 @@ void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) {
NoteLayerPropertyChanged();
}
void PictureLayerImpl::SetUseTransformedRasterization(bool use) {
if (use_transformed_rasterization_ == use)
return;
use_transformed_rasterization_ = use;
NoteLayerPropertyChanged();
}
void PictureLayerImpl::SetDirectlyCompositedImageSize(
base::Optional<gfx::Size> size) {
if (directly_composited_image_size_ == size)
@ -1212,22 +1204,26 @@ bool PictureLayerImpl::CanRecreateHighResTilingForLCDTextAndRasterTranslation(
}
void PictureLayerImpl::UpdateTilingsForRasterScaleAndTranslation(
bool adjusted_raster_scale) {
bool has_adjusted_raster_scale) {
PictureLayerTiling* high_res =
tilings_->FindTilingWithScaleKey(raster_contents_scale_);
gfx::Vector2dF raster_translation =
CalculateRasterTranslation(raster_contents_scale_);
bool can_use_lcd_text_changed = UpdateCanUseLCDText();
gfx::Vector2dF raster_translation;
bool raster_translation_aligns_pixels =
CalculateRasterTranslation(raster_translation);
UpdateCanUseLCDText(raster_translation_aligns_pixels);
if (high_res) {
if (layer_tree_impl()->IsSyncTree() &&
(high_res->raster_transform().translation() != raster_translation ||
can_use_lcd_text_changed)) {
// We should recreate the high res tiling with the new raster translation
// and lcd text, which is for the sync tree only to avoid flickering.
bool raster_translation_is_not_ideal =
high_res->raster_transform().translation() != raster_translation;
bool can_use_lcd_text_changed =
high_res->can_use_lcd_text() != can_use_lcd_text();
bool should_recreate_high_res =
(raster_translation_is_not_ideal || can_use_lcd_text_changed) &&
CanRecreateHighResTilingForLCDTextAndRasterTranslation(*high_res);
if (should_recreate_high_res) {
tilings_->Remove(high_res);
high_res = nullptr;
} else if (!adjusted_raster_scale) {
} else if (!has_adjusted_raster_scale) {
// Nothing changed, no need to update tilings.
DCHECK_EQ(HIGH_RESOLUTION, high_res->resolution());
SanityCheckTilingState();
@ -1576,41 +1572,64 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer(
SanityCheckTilingState();
}
gfx::Vector2dF PictureLayerImpl::CalculateRasterTranslation(
float raster_scale) {
if (!use_transformed_rasterization_)
return gfx::Vector2dF();
bool PictureLayerImpl::CalculateRasterTranslation(
gfx::Vector2dF& raster_translation) const {
// If this setting is set, the client (e.g. the Chromium UI) is sure that it
// can almost always align raster pixels to physical pixels, and doesn't care
// about temporary misalignment, so don't bother raster translation.
if (layer_tree_impl()->settings().layers_always_allowed_lcd_text)
return true;
// No need to use raster translation if there is no text.
if (!raster_source_ || !raster_source_->GetDisplayItemList() ||
!raster_source_->GetDisplayItemList()->has_draw_text_ops()) {
return false;
}
const gfx::Transform& screen_transform = ScreenSpaceTransform();
gfx::Transform draw_transform = DrawTransform();
// TODO(enne): for performance reasons, we should only have a raster
// translation when the screen space transform is not animating. We try to
// avoid this elsewhere but it still happens: http://crbug.com/778440
// TODO(enne): Also, we shouldn't ever get here if the draw transform is not
// just a scale + translation, but we do sometimes: http://crbug.com/740113
if (draw_properties().screen_space_transform_is_animating ||
if (!screen_transform.IsScaleOrTranslation() ||
!draw_transform.IsScaleOrTranslation()) {
// For now, while these problems are not well understood, avoid changing
// the raster scale in these cases.
return gfx::Vector2dF();
return false;
}
// It is only useful to align the content space to the target space if their
// relative pixel ratio is some small rational number. Currently we only
// align if the relative pixel ratio is 1:1.
// 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(draw_transform.matrix().getFloat(0, 0) - raster_scale) >
kErrorThreshold ||
std::abs(draw_transform.matrix().getFloat(1, 1) - raster_scale) >
kErrorThreshold)
return gfx::Vector2dF();
// align if the relative pixel ratio is 1:1 (i.e. the scale components of
// both the screen transform and the draw transform are approximately the same
// as |raster_contents_scale_|). Good match if the maximum alignment error on
// a layer of size 10000px does not exceed 0.001px.
static constexpr float kPixelErrorThreshold = 0.001f;
static constexpr float kScaleErrorThreshold = kPixelErrorThreshold / 10000;
auto is_raster_scale = [this](float scale) -> bool {
return std::abs(scale - raster_contents_scale_) <= kScaleErrorThreshold;
};
if (!is_raster_scale(screen_transform.matrix().getFloat(0, 0)) ||
!is_raster_scale(screen_transform.matrix().getFloat(1, 1)) ||
!is_raster_scale(draw_transform.matrix().getFloat(0, 0)) ||
!is_raster_scale(draw_transform.matrix().getFloat(1, 1))) {
return false;
}
// Extract the fractional part of layer origin in the target space.
float origin_x = draw_transform.matrix().getFloat(0, 3);
float origin_y = draw_transform.matrix().getFloat(1, 3);
return gfx::Vector2dF(origin_x - floorf(origin_x),
origin_y - floorf(origin_y));
// Extract the fractional part of layer origin in the screen space and in the
// target space.
auto fraction = [](float f) -> float { return f - floorf(f); };
float screen_x_fraction = fraction(screen_transform.matrix().getFloat(0, 3));
float screen_y_fraction = fraction(screen_transform.matrix().getFloat(1, 3));
float target_x_fraction = fraction(draw_transform.matrix().getFloat(0, 3));
float target_y_fraction = fraction(draw_transform.matrix().getFloat(1, 3));
// If the origin is different in the screen space and in the target space,
// it means the render target is not aligned to physical pixels, and the
// text content will be blurry regardless of raster translation.
if (std::abs(screen_x_fraction - target_x_fraction) > kPixelErrorThreshold ||
std::abs(screen_y_fraction - target_y_fraction) > kPixelErrorThreshold) {
return false;
}
raster_translation = gfx::Vector2dF(target_x_fraction, target_y_fraction);
return true;
}
float PictureLayerImpl::MinimumContentsScale() const {

@ -104,8 +104,6 @@ class CC_EXPORT PictureLayerImpl
void SetNearestNeighbor(bool nearest_neighbor);
void SetUseTransformedRasterization(bool use);
void SetDirectlyCompositedImageSize(base::Optional<gfx::Size>);
size_t GPUMemoryUsageInBytes() const override;
@ -143,9 +141,7 @@ class CC_EXPORT PictureLayerImpl
LCDTextDisallowedReason lcd_text_disallowed_reason() const {
return lcd_text_disallowed_reason_;
}
LCDTextDisallowedReason ComputeLCDTextDisallowedReasonForTesting() const {
return ComputeLCDTextDisallowedReason();
}
LCDTextDisallowedReason ComputeLCDTextDisallowedReasonForTesting() const;
const Region& InvalidationForTesting() const { return invalidation_; }
@ -181,7 +177,8 @@ class CC_EXPORT PictureLayerImpl
void AddLowResolutionTilingIfNeeded();
bool ShouldAdjustRasterScale() const;
void RecalculateRasterScales();
gfx::Vector2dF CalculateRasterTranslation(float raster_scale);
// Returns false if raster translation is not applicable.
bool CalculateRasterTranslation(gfx::Vector2dF& raster_translation) const;
void CleanUpTilingsOnActiveLayer(
const std::vector<PictureLayerTiling*>& used_tilings);
float MinimumContentsScale() const;
@ -223,9 +220,9 @@ class CC_EXPORT PictureLayerImpl
const std::vector<DiscardableImageMap::PaintWorkletInputWithImageId>&
inputs);
LCDTextDisallowedReason ComputeLCDTextDisallowedReason() const;
// Returns true if the LCD state changed.
bool UpdateCanUseLCDText();
LCDTextDisallowedReason ComputeLCDTextDisallowedReason(
bool raster_translation_aligns_pixels) const;
void UpdateCanUseLCDText(bool raster_translation_aligns_pixels);
// TODO(crbug.com/1114504): For now this checks the immediate transform node
// only. The callers may actually want to know if this layer or ancestor has
@ -264,7 +261,6 @@ class CC_EXPORT PictureLayerImpl
bool only_used_low_res_last_append_quads_ : 1;
bool nearest_neighbor_ : 1;
bool use_transformed_rasterization_ : 1;
LCDTextDisallowedReason lcd_text_disallowed_reason_;

@ -5066,13 +5066,24 @@ TEST_F(LegacySWPictureLayerImplTest, UpdateLCDTextInvalidatesPendingTree) {
for (Tile* tile : pending_layer()->HighResTiling()->AllTilesForTesting())
EXPECT_FALSE(tile->can_use_lcd_text());
// Change of the specific LCD text disallowed reason should not invalidate
// tilings.
pending_layer()->SetContentsOpaque(true);
pending_layer()->UpdateTiles();
// Once we disable lcd text, we don't re-enable it.
FilterOperations blur_filter;
blur_filter.Append(FilterOperation::CreateBlurFilter(4.0f));
SetFilter(pending_layer(), blur_filter);
UpdateDrawProperties(host_impl()->pending_tree());
EXPECT_FALSE(pending_layer()->can_use_lcd_text());
EXPECT_TRUE(pending_layer()->HighResTiling()->has_tiles());
for (Tile* tile : pending_layer()->HighResTiling()->AllTilesForTesting())
EXPECT_FALSE(tile->can_use_lcd_text());
SetFilter(pending_layer(), FilterOperations());
UpdateDrawProperties(host_impl()->pending_tree());
EXPECT_TRUE(pending_layer()->can_use_lcd_text());
EXPECT_TRUE(pending_layer()->HighResTiling()->has_tiles());
for (Tile* tile : pending_layer()->HighResTiling()->AllTilesForTesting())
EXPECT_TRUE(tile->can_use_lcd_text());
}
TEST_F(LegacySWPictureLayerImplTest, UpdateLCDTextPushToActiveTree) {
@ -5644,8 +5655,9 @@ TEST_F(LegacySWPictureLayerImplTest,
ChangeRasterTranslationNukePendingLayerTiles) {
gfx::Size layer_bounds(200, 200);
gfx::Size tile_size(256, 256);
SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region());
pending_layer()->SetUseTransformedRasterization(true);
auto raster_source = FakeRasterSource::CreateFilledWithText(layer_bounds);
SetupTreesWithFixedTileSize(raster_source, raster_source, tile_size,
Region());
// Start with scale & translation of * 2.25 + (0.25, 0.5).
SetupDrawProperties(pending_layer(), 2.25f, 1.5f, 1.f, 2.25f, 2.25f, false);
@ -5709,9 +5721,9 @@ TEST_F(LegacySWPictureLayerImplTest,
ChangeRasterTranslationNukeActiveLayerTiles) {
gfx::Size layer_bounds(200, 200);
gfx::Size tile_size(256, 256);
SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region());
active_layer()->SetUseTransformedRasterization(true);
pending_layer()->SetUseTransformedRasterization(true);
auto raster_source = FakeRasterSource::CreateFilledWithText(layer_bounds);
SetupTreesWithFixedTileSize(raster_source, raster_source, tile_size,
Region());
// Start with scale & translation of * 2.25 + (0.25, 0.5) on the active layer.
SetupDrawProperties(active_layer(), 2.25f, 1.5f, 1.f, 2.25f, 2.25f, false);
@ -5918,22 +5930,67 @@ TEST_F(LegacySWPictureLayerImplTest,
UpdateDrawProperties(host_impl()->pending_tree());
EXPECT_TRUE(pending_layer()->contents_opaque());
EXPECT_TRUE(pending_layer()->contents_opaque_for_text());
EXPECT_EQ(LCDTextDisallowedReason::kNonIntegralXOffset,
EXPECT_EQ(LCDTextDisallowedReason::kNone,
pending_layer()->ComputeLCDTextDisallowedReasonForTesting());
ASSERT_TRUE(pending_layer()->HighResTiling());
EXPECT_EQ(gfx::Vector2dF(0.2, 0.3),
pending_layer()->HighResTiling()->raster_transform().translation());
pending_layer()->SetUseTransformedRasterization(true);
// Adding will-change:transform will keep the current raster translation.
SetWillChangeTransform(pending_layer(), true);
host_impl()->pending_tree()->set_needs_update_draw_properties();
UpdateDrawProperties(host_impl()->pending_tree());
EXPECT_TRUE(pending_layer()->contents_opaque());
EXPECT_TRUE(pending_layer()->contents_opaque_for_text());
EXPECT_EQ(LCDTextDisallowedReason::kWillChangeTransform,
pending_layer()->ComputeLCDTextDisallowedReasonForTesting());
ASSERT_TRUE(pending_layer()->HighResTiling());
EXPECT_EQ(gfx::Vector2dF(0.2, 0.3),
pending_layer()->HighResTiling()->raster_transform().translation());
// We should not update raster translation when there is
// will-change:transform.
pending_layer()->SetOffsetToTransformParent(gfx::Vector2dF(0.4, 0.5));
host_impl()->pending_tree()->set_needs_update_draw_properties();
UpdateDrawProperties(host_impl()->pending_tree());
EXPECT_TRUE(pending_layer()->contents_opaque());
EXPECT_TRUE(pending_layer()->contents_opaque_for_text());
EXPECT_EQ(LCDTextDisallowedReason::kWillChangeTransform,
pending_layer()->ComputeLCDTextDisallowedReasonForTesting());
ASSERT_TRUE(pending_layer()->HighResTiling());
EXPECT_EQ(gfx::Vector2dF(0.2, 0.3),
pending_layer()->HighResTiling()->raster_transform().translation());
// Removing will-change:transform will update raster translation.
SetWillChangeTransform(pending_layer(), false);
host_impl()->pending_tree()->set_needs_update_draw_properties();
UpdateDrawProperties(host_impl()->pending_tree());
EXPECT_TRUE(pending_layer()->contents_opaque());
EXPECT_TRUE(pending_layer()->contents_opaque_for_text());
EXPECT_EQ(LCDTextDisallowedReason::kNone,
pending_layer()->ComputeLCDTextDisallowedReasonForTesting());
ASSERT_TRUE(pending_layer()->HighResTiling());
EXPECT_EQ(gfx::Vector2dF(0.4, 0.5),
pending_layer()->HighResTiling()->raster_transform().translation());
}
// Simulate another push from main-thread with the same values.
TEST_F(LegacySWPictureLayerImplTest,
TransformedRasterizationAndLCDTextWithoutText) {
auto raster_source = FakeRasterSource::CreateFilled(gfx::Size(200, 200));
SetupTreesWithInvalidation(raster_source, raster_source, Region());
pending_layer()->SetBackgroundColor(SK_ColorWHITE);
pending_layer()->SetContentsOpaque(true);
pending_layer()->SetUseTransformedRasterization(true);
pending_layer()->SetOffsetToTransformParent(gfx::Vector2dF(0.2, 0.3));
host_impl()->pending_tree()->set_needs_update_draw_properties();
UpdateDrawProperties(host_impl()->pending_tree());
EXPECT_TRUE(pending_layer()->contents_opaque());
EXPECT_TRUE(pending_layer()->contents_opaque_for_text());
EXPECT_EQ(LCDTextDisallowedReason::kNone,
EXPECT_EQ(LCDTextDisallowedReason::kNoText,
pending_layer()->ComputeLCDTextDisallowedReasonForTesting());
ASSERT_TRUE(pending_layer()->HighResTiling());
EXPECT_EQ(gfx::Vector2dF(),
pending_layer()->HighResTiling()->raster_transform().translation());
}
enum {
@ -6035,7 +6092,9 @@ TEST_P(LCDTextTest, NonIntegralTranslation) {
gfx::Transform non_integral_translation;
non_integral_translation.Translate(1.5, 2.5);
SetTransform(layer_, non_integral_translation);
CheckCanUseLCDText(LCDTextDisallowedReason::kNonIntegralTranslation,
// We can use LCD-text as raster translation can align the text to physical
// pixels for fragtional transform in the render target.
CheckCanUseLCDText(LCDTextDisallowedReason::kNone,
"non-integeral translation");
SetTransform(layer_, gfx::Transform());
@ -6064,12 +6123,11 @@ TEST_P(LCDTextTest, NonTranslation) {
CheckCanUseLCDText(LCDTextDisallowedReason::kNonIntegralTranslation,
"Rotation transform");
// Scale.
// Scale. LCD text is allowed.
gfx::Transform scale;
scale.Scale(2.0, 2.0);
SetTransform(layer_, scale);
CheckCanUseLCDText(LCDTextDisallowedReason::kNonIntegralTranslation,
"Scale transform");
CheckCanUseLCDText(LCDTextDisallowedReason::kNone, "Scale transform");
// Skew.
gfx::Transform skew;
@ -6227,5 +6285,16 @@ TEST_P(LCDTextTest, ContentsOpaqueForText) {
"contents not opaque for text", layer_);
}
TEST_P(LCDTextTest, TransformAnimation) {
GetTransformNode(layer_)->has_potential_animation = true;
SetLocalTransformChanged(layer_);
CheckCanUseLCDText(LCDTextDisallowedReason::kTransformAnimation,
"transform animation");
GetTransformNode(layer_)->has_potential_animation = false;
SetLocalTransformChanged(layer_);
CheckCanUseLCDText(LCDTextDisallowedReason::kNone, "no transform animation");
}
} // namespace
} // namespace cc

@ -181,7 +181,6 @@ void TransformTree::UpdateTransforms(int id) {
UpdateScreenSpaceTransform(node, parent_node);
UpdateAnimationProperties(node, parent_node);
UpdateSnapping(node);
UpdateNodeAndAncestorsHaveIntegerTranslations(node, parent_node);
UpdateTransformChanged(node, parent_node);
UpdateNodeAndAncestorsAreAnimatedOrInvertible(node, parent_node);
UpdateNodeOrAncestorsWillChangeTransform(node, parent_node);
@ -1145,15 +1144,6 @@ bool EffectTree::HitTestMayBeAffectedByMask(int effect_id) const {
return false;
}
void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations(
TransformNode* node,
TransformNode* parent_node) {
DCHECK(parent_node);
node->node_and_ancestors_have_only_integer_translation =
node->to_parent.IsIdentityOrIntegerTranslation() &&
parent_node->node_and_ancestors_have_only_integer_translation;
}
void ClipTree::SetViewportClip(gfx::RectF viewport_rect) {
if (size() < 2)
return;

@ -421,45 +421,6 @@ TEST(PropertyTreeTest, ScreenSpaceOpacityUpdateTest) {
EXPECT_EQ(tree.Node(child)->screen_space_opacity, 0.25f);
}
TEST(PropertyTreeTest, NonIntegerTranslationTest) {
// This tests that when a node has non-integer translation, the information
// is propagated to the subtree.
PropertyTrees property_trees;
TransformTree& tree = property_trees.transform_tree;
int parent = tree.Insert(TransformNode(), 0);
tree.Node(parent)->local.Translate(1.5f, 1.5f);
int child = tree.Insert(TransformNode(), parent);
tree.Node(child)->local.Translate(1, 1);
tree.set_needs_update(true);
draw_property_utils::ComputeTransforms(&tree);
EXPECT_FALSE(
tree.Node(parent)->node_and_ancestors_have_only_integer_translation);
EXPECT_FALSE(
tree.Node(child)->node_and_ancestors_have_only_integer_translation);
tree.Node(parent)->local.Translate(0.5f, 0.5f);
tree.Node(child)->local.Translate(0.5f, 0.5f);
tree.Node(parent)->needs_local_transform_update = true;
tree.Node(child)->needs_local_transform_update = true;
tree.set_needs_update(true);
draw_property_utils::ComputeTransforms(&tree);
EXPECT_TRUE(
tree.Node(parent)->node_and_ancestors_have_only_integer_translation);
EXPECT_FALSE(
tree.Node(child)->node_and_ancestors_have_only_integer_translation);
tree.Node(child)->local.Translate(0.5f, 0.5f);
tree.Node(child)->needs_local_transform_update = true;
tree.set_needs_update(true);
draw_property_utils::ComputeTransforms(&tree);
EXPECT_TRUE(
tree.Node(parent)->node_and_ancestors_have_only_integer_translation);
EXPECT_TRUE(
tree.Node(child)->node_and_ancestors_have_only_integer_translation);
}
TEST(PropertyTreeTest, SingularTransformSnapTest) {
// This tests that to_target transform is not snapped when it has a singular
// transform.

@ -27,7 +27,6 @@ TransformNode::TransformNode()
to_screen_is_potentially_animated(false),
flattens_inherited_transform(true),
node_and_ancestors_are_flat(true),
node_and_ancestors_have_only_integer_translation(true),
scrolls(false),
should_be_snapped(false),
moved_by_outer_viewport_bounds_delta_y(false),
@ -60,8 +59,6 @@ bool TransformNode::operator==(const TransformNode& other) const {
other.to_screen_is_potentially_animated &&
flattens_inherited_transform == other.flattens_inherited_transform &&
node_and_ancestors_are_flat == other.node_and_ancestors_are_flat &&
node_and_ancestors_have_only_integer_translation ==
other.node_and_ancestors_have_only_integer_translation &&
scrolls == other.scrolls &&
should_be_snapped == other.should_be_snapped &&
moved_by_outer_viewport_bounds_delta_y ==

@ -87,9 +87,6 @@ struct CC_EXPORT TransformNode {
// root is flat.
bool node_and_ancestors_are_flat : 1;
// This is needed to know if a layer can use lcd text.
bool node_and_ancestors_have_only_integer_translation : 1;
bool scrolls : 1;
bool should_be_snapped : 1;

@ -337,18 +337,6 @@ void CompositedLayerMapping::UpdateContentsOpaque() {
}
}
void CompositedLayerMapping::UpdateRasterizationPolicy() {
bool transformed_rasterization_allowed =
!(owning_layer_.GetCompositingReasons() &
CompositingReason::kComboTransformedRasterizationDisallowedReasons);
graphics_layer_->CcLayer().SetTransformedRasterizationAllowed(
transformed_rasterization_allowed);
if (non_scrolling_squashing_layer_) {
non_scrolling_squashing_layer_->CcLayer()
.SetTransformedRasterizationAllowed(true);
}
}
void CompositedLayerMapping::UpdateCompositedBounds() {
DCHECK_EQ(owning_layer_.Compositor()->Lifecycle().GetState(),
DocumentLifecycle::kInCompositingAssignmentsUpdate);
@ -716,7 +704,6 @@ void CompositedLayerMapping::UpdateGraphicsLayerGeometry(
UpdateDrawsContentAndPaintsHitTest();
UpdateElementId();
UpdateContentsOpaque();
UpdateRasterizationPolicy();
UpdateCompositingReasons();
}

@ -104,8 +104,6 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
// Update whether layer needs blending.
void UpdateContentsOpaque();
void UpdateRasterizationPolicy();
GraphicsLayer* MainGraphicsLayer() const { return graphics_layer_.get(); }
GraphicsLayer* ForegroundLayer() const { return foreground_layer_.get(); }

@ -1326,116 +1326,6 @@ TEST_F(CompositedLayerMappingTest,
EXPECT_FLOAT_EQ(8, sticky_position_relative_to_root.Y());
}
TEST_F(CompositedLayerMappingTest,
TransformedRasterizationDisallowedForDirectReasons) {
// This test verifies layers with direct compositing reasons won't have
// transformed rasterization, i.e. should raster in local space.
SetBodyInnerHTML(R"HTML(
<div id='target1' style='will-change: transform;'>foo</div>
<div id='target2' style='will-change: opacity;'>bar</div>
)HTML");
{
LayoutObject* target = GetLayoutObjectByElementId("target1");
ASSERT_TRUE(target && target->IsBox());
PaintLayer* target_layer = ToLayoutBox(target)->Layer();
GraphicsLayer* target_graphics_layer =
target_layer ? target_layer->GraphicsLayerBacking() : nullptr;
ASSERT_TRUE(target_graphics_layer);
EXPECT_FALSE(
target_graphics_layer->CcLayer().transformed_rasterization_allowed());
}
{
LayoutObject* target = GetLayoutObjectByElementId("target2");
ASSERT_TRUE(target && target->IsBox());
PaintLayer* target_layer = ToLayoutBox(target)->Layer();
GraphicsLayer* target_graphics_layer =
target_layer ? target_layer->GraphicsLayerBacking() : nullptr;
ASSERT_TRUE(target_graphics_layer);
EXPECT_FALSE(
target_graphics_layer->CcLayer().transformed_rasterization_allowed());
}
}
TEST_F(CompositedLayerMappingTest, TransformedRasterizationForInlineTransform) {
// This test verifies we allow layers that are indirectly composited due to
// an inline transform (but no direct reason otherwise) to raster in the
// device space for higher quality.
SetBodyInnerHTML(R"HTML(
<div style='will-change:transform; width:500px;
height:20px;'>composited</div>
<div id='target' style='transform:translate(1.5px,-10.5px);
width:500px; height:20px;'>indirectly composited due to inline
transform</div>
)HTML");
LayoutObject* target = GetLayoutObjectByElementId("target");
ASSERT_TRUE(target && target->IsBox());
PaintLayer* target_layer = ToLayoutBox(target)->Layer();
GraphicsLayer* target_graphics_layer =
target_layer ? target_layer->GraphicsLayerBacking() : nullptr;
ASSERT_TRUE(target_graphics_layer);
EXPECT_TRUE(
target_graphics_layer->CcLayer().transformed_rasterization_allowed());
}
TEST_F(CompositedLayerMappingTest,
TransformedRasterizationForScrollDependentPosition) {
SetBodyInnerHTML(R"HTML(
<div id="target"
style="transform: translateX(0.3px);
position: fixed; top: 20px; left: 30px;">
FIXED
</div>
<div style="height: 4000px; width: 4000px;
background: silver;">
</div>
)HTML");
LayoutObject* target = GetLayoutObjectByElementId("target");
ASSERT_TRUE(target && target->IsBox());
PaintLayer* target_layer = ToLayoutBox(target)->Layer();
GraphicsLayer* target_graphics_layer =
target_layer ? target_layer->GraphicsLayerBacking() : nullptr;
ASSERT_TRUE(target_graphics_layer);
EXPECT_TRUE(
target_graphics_layer->CcLayer().transformed_rasterization_allowed());
}
TEST_F(CompositedLayerMappingTest,
TransformedRasterizationForTrivial3DTransform) {
SetBodyInnerHTML(R"HTML(
<div id="target" style="transform: translate3d(0.3px, 0px, 0px);">
Trivial 3D Transform
</div>
)HTML");
LayoutObject* target = GetLayoutObjectByElementId("target");
ASSERT_TRUE(target && target->IsBox());
PaintLayer* target_layer = ToLayoutBox(target)->Layer();
GraphicsLayer* target_graphics_layer =
target_layer ? target_layer->GraphicsLayerBacking() : nullptr;
ASSERT_TRUE(target_graphics_layer);
EXPECT_TRUE(
target_graphics_layer->CcLayer().transformed_rasterization_allowed());
}
TEST_F(CompositedLayerMappingTest,
TransformedRasterizationForBackfaceVisibilityHidden) {
SetBodyInnerHTML(R"HTML(
<div id="target" style="backface-visibility: hidden;">EXAMPLE</div>
)HTML");
LayoutObject* target = GetLayoutObjectByElementId("target");
ASSERT_TRUE(target && target->IsBox());
PaintLayer* target_layer = ToLayoutBox(target)->Layer();
GraphicsLayer* target_graphics_layer =
target_layer ? target_layer->GraphicsLayerBacking() : nullptr;
ASSERT_TRUE(target_graphics_layer);
EXPECT_TRUE(
target_graphics_layer->CcLayer().transformed_rasterization_allowed());
}
TEST_F(CompositedLayerMappingTest, ScrollingContainerBoundsChange) {
GetDocument().GetFrame()->GetSettings()->SetPreferCompositingToLCDTextEnabled(
true);

@ -134,10 +134,6 @@ class PLATFORM_EXPORT CompositingReason {
kComboAllDirectReasons = kComboAllDirectStyleDeterminedReasons |
kComboAllDirectNonStyleDeterminedReasons,
kComboTransformedRasterizationDisallowedReasons =
kComboAllDirectReasons & ~kScrollDependentPosition &
~kTrivial3DTransform & ~kBackfaceVisibilityHidden,
kComboAllCompositedScrollingDeterminedReasons =
kScrollDependentPosition | kOverflowScrolling,

@ -150,18 +150,6 @@ virtual/composite-after-paint/paint/frames/* [ Pass ]
virtual/composite-after-paint/scrollingcoordinator/* [ Pass ]
# --- End CompositeAfterPaint Tests --
# TODO(crbug.com/1121630): These tests are temporarily disabled during
# investigation of the performance regression.
crbug.com/1121630 compositing/composited-text-subpixel-translation.html [ Failure ]
crbug.com/1121630 fast/overflow/overflow-of-video-outline.html [ Failure ]
crbug.com/1121630 http/tests/media/video-buffered-range-contains-currentTime.html [ Failure ]
crbug.com/1121630 media/controls-layout-direction.html [ Failure ]
crbug.com/1121630 media/media-controls-clone.html [ Failure ]
crbug.com/1121630 media/media-controls-grey-scrubber.html [ Failure ]
crbug.com/1121630 paint/frames/frameset-with-stacking-context-and-not-stacking-context-children.html [ Failure ]
crbug.com/1121630 virtual/composite-after-paint/paint/frames/frameset-with-stacking-context-and-not-stacking-context-children.html [ Failure ]
crbug.com/1121630 virtual/dark-color-scheme/media/audio-controls-rendering.html [ Failure ]
# Sheriff on 2020-09-03
crbug.com/1124352 media/picture-in-picture/clear-after-request.html [ Crash Pass ]
crbug.com/1124352 media/picture-in-picture/controls/picture-in-picture-button.html [ Crash Pass ]