Changeset 107157 in webkit
- Timestamp:
- Feb 8, 2012 5:30:54 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r107149 r107157 1 2012-02-08 Matthew Delaney <mdelaney@apple.com> 2 3 GeneratorGeneratedImage::drawPattern does not factor in its destination context's scale when generating its image tiles 4 5 https://bugs.webkit.org/show_bug.cgi?id=67729 6 <rdar://problem/10087050> 7 8 Reviewed by Beth Dakin. 9 10 No new tests, current pixel tests will cover this. Though some pixel results might improve to become less pixel-y. 11 12 * platform/graphics/GeneratorGeneratedImage.cpp: 13 (WebCore::GeneratorGeneratedImage::draw): Updated context to destContext for consistency. 14 (WebCore::GeneratorGeneratedImage::drawPattern): Taught drawPattern about the destination 15 scale factor to avoid having low-res generated images such as gradients in certain cases. 16 * platform/graphics/GraphicsContext.cpp: 17 (WebCore::GraphicsContext::createCompatibleBuffer): Have the image buffer match the 18 context acceleration setting as well. 19 1 20 2012-02-08 Adam Klein <adamk@chromium.org> 2 21 -
trunk/Source/WebCore/platform/graphics/GeneratorGeneratedImage.cpp
r102893 r107157 34 34 namespace WebCore { 35 35 36 void GeneratorGeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)36 void GeneratorGeneratedImage::draw(GraphicsContext* destContext, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp) 37 37 { 38 GraphicsContextStateSaver stateSaver(* context);39 context->setCompositeOperation(compositeOp);40 context->clip(dstRect);41 context->translate(dstRect.x(), dstRect.y());42 if (d stRect.size() != srcRect.size())43 context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));44 context->translate(-srcRect.x(), -srcRect.y());45 context->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());38 GraphicsContextStateSaver stateSaver(*destContext); 39 destContext->setCompositeOperation(compositeOp); 40 destContext->clip(destRect); 41 destContext->translate(destRect.x(), destRect.y()); 42 if (destRect.size() != srcRect.size()) 43 destContext->scale(FloatSize(destRect.width() / srcRect.width(), destRect.height() / srcRect.height())); 44 destContext->translate(-srcRect.x(), -srcRect.y()); 45 destContext->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get()); 46 46 } 47 47 48 void GeneratorGeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,48 void GeneratorGeneratedImage::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const AffineTransform& patternTransform, 49 49 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect) 50 50 { … … 54 54 m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect); 55 55 56 // Factor in the destination context's scale to generate at the best resolution 57 AffineTransform destContextCTM = destContext->getCTM(); 58 double xScale = fabs(destContextCTM.xScale()); 59 double yScale = fabs(destContextCTM.yScale()); 60 AffineTransform adjustedPatternCTM = patternTransform; 61 adjustedPatternCTM.scale(1.0 / xScale, 1.0 / yScale); 62 adjustedSrcRect.scale(xScale, yScale); 63 56 64 // Create a BitmapImage and call drawPattern on it. 57 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(adjustedSize, ColorSpaceDeviceRGB, context->isAcceleratedContext() ? Accelerated : Unaccelerated);65 OwnPtr<ImageBuffer> imageBuffer = destContext->createCompatibleBuffer(adjustedSize); 58 66 if (!imageBuffer) 59 67 return; … … 64 72 65 73 // Tile the image buffer into the context. 66 imageBuffer->drawPattern( context, adjustedSrcRect, patternTransform, phase, styleColorSpace, compositeOp, destRect);74 imageBuffer->drawPattern(destContext, adjustedSrcRect, adjustedPatternCTM, phase, styleColorSpace, compositeOp, destRect); 67 75 } 68 76 -
trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp
r101556 r107157 755 755 IntSize scaledSize(static_cast<int>(ceil(size.width() * transform.xScale())), static_cast<int>(ceil(size.height() * transform.yScale()))); 756 756 757 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(scaledSize );757 OwnPtr<ImageBuffer> buffer = ImageBuffer::create(scaledSize, ColorSpaceDeviceRGB, isAcceleratedContext() ? Accelerated : Unaccelerated); 758 758 if (!buffer) 759 759 return nullptr;
Note: See TracChangeset
for help on using the changeset viewer.