[go: nahoru, domu]

Skip to content

Commit

Permalink
Text snaps to pixel grid, images don't
Browse files Browse the repository at this point in the history
Previously, we tried to use the render tree's paint offset to move the text to
the proper position, but that appears to snap to integer logical pixels,
introducing jitter. Now we use the SkCanvas's matrix to position the text,
removing the jitter.

Fixes flutter/flutter#234
  • Loading branch information
abarth committed Nov 20, 2015
1 parent 43f57d1 commit d12e614
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sky/engine/core/text/Paragraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ double Paragraph::ideographicBaseline()

void Paragraph::layout()
{
FontCachePurgePreventer fontCachePurgePreventer;
FontCachePurgePreventer fontCachePurgePreventer;

LayoutUnit maxWidth = std::max(m_minWidth, m_maxWidth);
LayoutUnit maxHeight = std::max(m_minHeight, m_maxHeight);
Expand All @@ -66,18 +66,19 @@ void Paragraph::paint(Canvas* canvas, const Offset& offset)

// Very simplified painting to allow painting an arbitrary (layer-less) subtree.
RenderBox* box = firstChildBox();
GraphicsContext context(canvas->skCanvas());
SkCanvas* skCanvas = canvas->skCanvas();
skCanvas->translate(offset.sk_size.width(), offset.sk_size.height());

GraphicsContext context(skCanvas);
Vector<RenderBox*> layers;
LayoutPoint paintOffset(offset.sk_size.width(), offset.sk_size.height());
LayoutRect bounds = box->absoluteBoundingBoxRect();
DCHECK(bounds.x() == 0 && bounds.y() == 0);
bounds.setLocation(paintOffset);
PaintInfo paintInfo(&context, enclosingIntRect(bounds), box);
box->paint(paintInfo, paintOffset, layers);

box->paint(paintInfo, LayoutPoint(), layers);
// Note we're ignoring any layers encountered.
// TODO(abarth): Remove the concept of RenderLayers.

skCanvas->translate(-offset.sk_size.width(), -offset.sk_size.height());
}

} // namespace blink

0 comments on commit d12e614

Please sign in to comment.