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

Unified Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp

Issue 2112753002: Snap paint offset paint property to pixel boundaries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
index 2823cc71fc0a171897078a01fb939785dc88bc5e..c3078720eaaccfff1c396c766f1b791c8c23baa0 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
@@ -77,11 +77,17 @@ void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject&
if (context.paintOffset == LayoutPoint())
return;
+ // We pixel align transformed content to reduce aliasing by pixel snapping the paint offset
+ // transform. Any residual paint offset continues through to children. See the equivalent spv1
+ // code in PaintLayerPainter::paintFragmentByApplyingTransform.
+ IntPoint roundedPaintOffset = roundedIntPoint(context.paintOffset);
+ LayoutPoint subpixelPaintOffset = LayoutPoint(context.paintOffset - roundedPaintOffset);
+
RefPtr<TransformPaintPropertyNode> paintOffsetTranslation = TransformPaintPropertyNode::create(
- TransformationMatrix().translate(context.paintOffset.x(), context.paintOffset.y()),
+ TransformationMatrix().translate(roundedPaintOffset.x(), roundedPaintOffset.y()),
FloatPoint3D(), context.currentTransform);
context.currentTransform = paintOffsetTranslation.get();
- context.paintOffset = LayoutPoint();
+ context.paintOffset = subpixelPaintOffset;
object.getMutableForPainting().ensureObjectPaintProperties().setPaintOffsetTranslation(paintOffsetTranslation.release());
}
@@ -98,10 +104,6 @@ static FloatPoint3D transformOrigin(const LayoutBox& box)
void PaintPropertyTreeBuilder::updateTransform(const LayoutObject& object, PaintPropertyTreeBuilderContext& context)
{
if (object.isSVG() && !object.isSVGRoot()) {
- // SVG does not use paint offset internally and the root should have already accounted for
- // any paint offset in the root's svgLocalToBorderBox transform.
- DCHECK(context.paintOffset == LayoutPoint());
-
// FIXME(pdr): Check for the presence of a transform instead of the value. Checking for an
// identity matrix will cause the property tree structure to change during animations if
// the animation passes through the identity matrix.
@@ -121,7 +123,6 @@ void PaintPropertyTreeBuilder::updateTransform(const LayoutObject& object, Paint
const ComputedStyle& style = object.styleRef();
if (!object.isBox() || !style.hasTransform())
return;
- ASSERT(context.paintOffset == LayoutPoint());
TransformationMatrix matrix;
style.applyTransform(matrix, toLayoutBox(object).size(), ComputedStyle::ExcludeTransformOrigin,

Powered by Google App Engine
This is Rietveld 408576698