+2012-02-08 Matthew Delaney <mdelaney@apple.com>
+
+ GeneratorGeneratedImage::drawPattern does not factor in its destination context's scale when generating its image tiles
+
+ https://bugs.webkit.org/show_bug.cgi?id=67729
+ <rdar://problem/10087050>
+
+ Reviewed by Beth Dakin.
+
+ No new tests, current pixel tests will cover this. Though some pixel results might improve to become less pixel-y.
+
+ * platform/graphics/GeneratorGeneratedImage.cpp:
+ (WebCore::GeneratorGeneratedImage::draw): Updated context to destContext for consistency.
+ (WebCore::GeneratorGeneratedImage::drawPattern): Taught drawPattern about the destination
+ scale factor to avoid having low-res generated images such as gradients in certain cases.
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::createCompatibleBuffer): Have the image buffer match the
+ context acceleration setting as well.
+
2012-02-08 Adam Klein <adamk@chromium.org>
Simplify and correct mutation delivery timing for JSC
namespace WebCore {
-void GeneratorGeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
+void GeneratorGeneratedImage::draw(GraphicsContext* destContext, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
{
- GraphicsContextStateSaver stateSaver(*context);
- context->setCompositeOperation(compositeOp);
- context->clip(dstRect);
- context->translate(dstRect.x(), dstRect.y());
- if (dstRect.size() != srcRect.size())
- context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
- context->translate(-srcRect.x(), -srcRect.y());
- context->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
+ GraphicsContextStateSaver stateSaver(*destContext);
+ destContext->setCompositeOperation(compositeOp);
+ destContext->clip(destRect);
+ destContext->translate(destRect.x(), destRect.y());
+ if (destRect.size() != srcRect.size())
+ destContext->scale(FloatSize(destRect.width() / srcRect.width(), destRect.height() / srcRect.height()));
+ destContext->translate(-srcRect.x(), -srcRect.y());
+ destContext->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
}
-void GeneratorGeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
+void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect)
{
// Allow the generator to provide visually-equivalent tiling parameters for better performance.
FloatRect adjustedSrcRect = srcRect;
m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
+ // Factor in the destination context's scale to generate at the best resolution
+ AffineTransform destContextCTM = destContext->getCTM();
+ double xScale = fabs(destContextCTM.xScale());
+ double yScale = fabs(destContextCTM.yScale());
+ AffineTransform adjustedPatternCTM = patternTransform;
+ adjustedPatternCTM.scale(1.0 / xScale, 1.0 / yScale);
+ adjustedSrcRect.scale(xScale, yScale);
+
// Create a BitmapImage and call drawPattern on it.
- OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(adjustedSize, ColorSpaceDeviceRGB, context->isAcceleratedContext() ? Accelerated : Unaccelerated);
+ OwnPtr<ImageBuffer> imageBuffer = destContext->createCompatibleBuffer(adjustedSize);
if (!imageBuffer)
return;
graphicsContext->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_generator.get());
// Tile the image buffer into the context.
- imageBuffer->drawPattern(context, adjustedSrcRect, patternTransform, phase, styleColorSpace, compositeOp, destRect);
+ imageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatternCTM, phase, styleColorSpace, compositeOp, destRect);
}
void GeneratedImage::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)