Commit 1ec1e0f6 authored by eric@webkit.org's avatar eric@webkit.org

Reviewed by hyatt.

        Fix leaky ImageBuffer code.

        * platform/graphics/GeneratedImage.cpp:
        (WebCore::GeneratedImage::drawPattern):
        * platform/graphics/ImageBuffer.h:
        * platform/graphics/cg/ImageBufferCG.cpp:
        (WebCore::ImageBuffer::image):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31935 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a6a55b6b
2008-04-16 Eric Seidel <eric@webkit.org>
Reviewed by hyatt.
Fix leaky ImageBuffer code.
* platform/graphics/GeneratedImage.cpp:
(WebCore::GeneratedImage::drawPattern):
* platform/graphics/ImageBuffer.h:
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::image):
2008-04-15 Justin Garcia <justin.garcia@apple.com>
Reviewed by Oliver.
......@@ -59,7 +59,7 @@ void GeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcR
graphicsContext->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
// Grab the final image from the image buffer.
Image* bitmap = imageBuffer->image(true);
Image* bitmap = imageBuffer->image();
// Now just call drawTiled on that image.
bitmap->drawPattern(context, srcRect, patternTransform, phase, compositeOp, destRect);
......
......@@ -70,7 +70,7 @@ namespace WebCore {
GraphicsContext* context() const;
#if PLATFORM(CG)
Image* image(bool createNewImage = false) const;
Image* image() const;
CGImageRef cgImage() const { return image()->getCGImageRef(); }
#elif PLATFORM(QT)
QPixmap* pixmap() const;
......@@ -79,7 +79,7 @@ namespace WebCore {
#endif
#if !PLATFORM(CG)
Image* image(bool createNewImage = false) const { notImplemented(); return 0; }
Image* image() const { notImplemented(); return 0; }
#endif
PassRefPtr<ImageData> getImageData(const IntRect& rect) const;
......
......@@ -94,17 +94,15 @@ GraphicsContext* ImageBuffer::context() const
return m_context.get();
}
Image* ImageBuffer::image(bool createNewImage) const
Image* ImageBuffer::image() const
{
if (!m_image || createNewImage) {
if (!m_image) {
// It's assumed that if image() is called, the actual rendering to the
// GraphicsContext must be done.
ASSERT(context());
CGImageRef cgImage = CGBitmapContextCreateImage(context()->platformContext());
BitmapImage* result = new BitmapImage(cgImage);
if (createNewImage)
return result;
m_image.set(new BitmapImage(cgImage)); // The ref is now held by the BitmapImage.
// BitmapImage will release the passed in CGImage on destruction
m_image.set(new BitmapImage(cgImage));
}
return m_image.get();
}
......
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