Commit 7cc71e21 authored by danakj's avatar danakj Committed by Commit Bot

cc: Document and explain Layer::IsSnapped{ToPixelGridInTarget}().

Since property tree builder makes assumptions about scrolling things
being snapped elsewhere, just have it snap scrollable things itself.
Use the Layer only to snap TextureLayers.

R=enne@chromium.org

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ia47bcaa252c6bdf58b276a7ff0bcde8de0af594e
Reviewed-on: https://chromium-review.googlesource.com/1100005Reviewed-by: default avatarenne <enne@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567406}
parent 089bc8ad
...@@ -1162,8 +1162,8 @@ void Layer::SetLayerClient(base::WeakPtr<LayerClient> client) { ...@@ -1162,8 +1162,8 @@ void Layer::SetLayerClient(base::WeakPtr<LayerClient> client) {
inputs_.debug_info = nullptr; inputs_.debug_info = nullptr;
} }
bool Layer::IsSnapped() { bool Layer::IsSnappedToPixelGridInTarget() {
return scrollable(); return false;
} }
void Layer::PushPropertiesTo(LayerImpl* layer) { void Layer::PushPropertiesTo(LayerImpl* layer) {
......
...@@ -509,8 +509,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> { ...@@ -509,8 +509,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
void SetLayerClient(base::WeakPtr<LayerClient> client); void SetLayerClient(base::WeakPtr<LayerClient> client);
LayerClient* GetLayerClientForTesting() const { return inputs_.client.get(); } LayerClient* GetLayerClientForTesting() const { return inputs_.client.get(); }
virtual bool IsSnapped();
virtual sk_sp<SkPicture> GetPicture() const; virtual sk_sp<SkPicture> GetPicture() const;
// Mark the layer as needing to push its properties to the LayerImpl during // Mark the layer as needing to push its properties to the LayerImpl during
...@@ -613,6 +611,13 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> { ...@@ -613,6 +611,13 @@ class CC_EXPORT Layer : public base::RefCounted<Layer> {
// in other ways may leave it as the default. // in other ways may leave it as the default.
virtual bool HasNonAAPaint() const; virtual bool HasNonAAPaint() const;
// Internal to property tree construction. This allows a layer to request that
// its transform should be snapped such that the layer aligns with the pixel
// grid in its rendering target. This ensures that the layer is not fuzzy
// (unless it is being scaled). Layers may override this to return true, by
// default layers are not snapped.
virtual bool IsSnappedToPixelGridInTarget();
// Internal to property tree construction. A generation number for the // Internal to property tree construction. A generation number for the
// property trees, to verify the layer's indices are pointers into the trees // property trees, to verify the layer's indices are pointers into the trees
// currently held by the LayerTreeHost. The number is updated when property // currently held by the LayerTreeHost. The number is updated when property
......
...@@ -294,8 +294,8 @@ std::unique_ptr<LayerImpl> LayerImpl::CreateLayerImpl( ...@@ -294,8 +294,8 @@ std::unique_ptr<LayerImpl> LayerImpl::CreateLayerImpl(
return LayerImpl::Create(tree_impl, layer_id_); return LayerImpl::Create(tree_impl, layer_id_);
} }
bool LayerImpl::IsSnapped() { bool LayerImpl::IsSnappedToPixelGridInTarget() {
return scrollable(); return false;
} }
void LayerImpl::PushPropertiesTo(LayerImpl* layer) { void LayerImpl::PushPropertiesTo(LayerImpl* layer) {
......
...@@ -374,9 +374,13 @@ class CC_EXPORT LayerImpl { ...@@ -374,9 +374,13 @@ class CC_EXPORT LayerImpl {
virtual void RecreateTileResources(); virtual void RecreateTileResources();
virtual std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); virtual std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
virtual bool IsSnapped();
virtual void PushPropertiesTo(LayerImpl* layer); virtual void PushPropertiesTo(LayerImpl* layer);
// Internal to property tree construction (which only happens in tests on a
// LayerImpl tree. See Layer::IsSnappedToPixelGridInTarget() for explanation,
// as this mirrors that method.
virtual bool IsSnappedToPixelGridInTarget();
virtual void GetAllPrioritizedTilesForTracing( virtual void GetAllPrioritizedTilesForTracing(
std::vector<PrioritizedTile>* prioritized_tiles) const; std::vector<PrioritizedTile>* prioritized_tiles) const;
virtual void AsValueInto(base::trace_event::TracedValue* dict) const; virtual void AsValueInto(base::trace_event::TracedValue* dict) const;
......
...@@ -192,7 +192,12 @@ bool TextureLayer::Update() { ...@@ -192,7 +192,12 @@ bool TextureLayer::Update() {
return updated || !update_rect().IsEmpty(); return updated || !update_rect().IsEmpty();
} }
bool TextureLayer::IsSnapped() { bool TextureLayer::IsSnappedToPixelGridInTarget() {
// Often layers are positioned with CSS to "50%", which can often leave them
// with a fractional (N + 0.5) pixel position. This would leave them looking
// fuzzy, so we request that TextureLayers are snapped to the pixel grid,
// since their content is generated externally and we can not adjust for it
// inside the content (unlike for PictureLayers).
return true; return true;
} }
......
...@@ -153,7 +153,7 @@ class CC_EXPORT TextureLayer : public Layer, SharedBitmapIdRegistrar { ...@@ -153,7 +153,7 @@ class CC_EXPORT TextureLayer : public Layer, SharedBitmapIdRegistrar {
void SetLayerTreeHost(LayerTreeHost* layer_tree_host) override; void SetLayerTreeHost(LayerTreeHost* layer_tree_host) override;
bool Update() override; bool Update() override;
bool IsSnapped() override; bool IsSnappedToPixelGridInTarget() override;
void PushPropertiesTo(LayerImpl* layer) override; void PushPropertiesTo(LayerImpl* layer) override;
// Request a mapping from SharedBitmapId to SharedMemory be registered via the // Request a mapping from SharedBitmapId to SharedMemory be registered via the
......
...@@ -42,7 +42,8 @@ std::unique_ptr<LayerImpl> TextureLayerImpl::CreateLayerImpl( ...@@ -42,7 +42,8 @@ std::unique_ptr<LayerImpl> TextureLayerImpl::CreateLayerImpl(
return TextureLayerImpl::Create(tree_impl, id()); return TextureLayerImpl::Create(tree_impl, id());
} }
bool TextureLayerImpl::IsSnapped() { bool TextureLayerImpl::IsSnappedToPixelGridInTarget() {
// See TextureLayer::IsSnappedToPixelGridInTarget() for explanation of |true|.
return true; return true;
} }
......
...@@ -32,7 +32,7 @@ class CC_EXPORT TextureLayerImpl : public LayerImpl { ...@@ -32,7 +32,7 @@ class CC_EXPORT TextureLayerImpl : public LayerImpl {
std::unique_ptr<LayerImpl> CreateLayerImpl( std::unique_ptr<LayerImpl> CreateLayerImpl(
LayerTreeImpl* layer_tree_impl) override; LayerTreeImpl* layer_tree_impl) override;
bool IsSnapped() override; bool IsSnappedToPixelGridInTarget() override;
void PushPropertiesTo(LayerImpl* layer) override; void PushPropertiesTo(LayerImpl* layer) override;
bool WillDraw(DrawMode draw_mode, bool WillDraw(DrawMode draw_mode,
......
...@@ -394,7 +394,11 @@ bool PropertyTreeBuilderContext<LayerType>::AddTransformNodeIfNeeded( ...@@ -394,7 +394,11 @@ bool PropertyTreeBuilderContext<LayerType>::AddTransformNodeIfNeeded(
const bool is_scrollable = layer->scrollable(); const bool is_scrollable = layer->scrollable();
const bool is_fixed = PositionConstraint(layer).is_fixed_position(); const bool is_fixed = PositionConstraint(layer).is_fixed_position();
const bool is_sticky = StickyPositionConstraint(layer).is_sticky; const bool is_sticky = StickyPositionConstraint(layer).is_sticky;
const bool is_snapped = layer->IsSnapped(); // Scrolling a layer should not move it from being pixel-aligned to moving off
// the pixel grid and becoming fuzzy. So always snap scrollable things to the
// pixel grid. Layers may also request to be snapped as such.
const bool is_snapped =
is_scrollable || layer->IsSnappedToPixelGridInTarget();
const bool has_significant_transform = const bool has_significant_transform =
!Transform(layer).IsIdentityOr2DTranslation(); !Transform(layer).IsIdentityOr2DTranslation();
......
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