diff options
Diffstat (limited to 'WebCore/platform/graphics/ImageBuffer.h')
-rw-r--r-- | WebCore/platform/graphics/ImageBuffer.h | 82 |
1 files changed, 36 insertions, 46 deletions
diff --git a/WebCore/platform/graphics/ImageBuffer.h b/WebCore/platform/graphics/ImageBuffer.h index c815c8d..7c68fc8 100644 --- a/WebCore/platform/graphics/ImageBuffer.h +++ b/WebCore/platform/graphics/ImageBuffer.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,69 +27,59 @@ #ifndef ImageBuffer_h #define ImageBuffer_h +#include "Image.h" #include "IntSize.h" +#include "ImageBufferData.h" #include <wtf/OwnPtr.h> +#include <wtf/PassRefPtr.h> #include <memory> -#if PLATFORM(CG) -typedef struct CGImage* CGImageRef; -#endif - -#if PLATFORM(QT) -#include <QPixmap> -class QPainter; -#endif - -#if PLATFORM(SGL) -#include <memory> -#endif - -#if PLATFORM(CAIRO) -typedef struct _cairo_surface cairo_surface_t; -#endif - namespace WebCore { class GraphicsContext; - class RenderObject; + class ImageData; + class IntPoint; + class IntRect; + class String; class ImageBuffer : Noncopyable { public: - static std::auto_ptr<ImageBuffer> create(const IntSize&, bool grayScale); + // Will return a null pointer on allocation failure. + static std::auto_ptr<ImageBuffer> create(const IntSize& size, bool grayScale) + { + bool success = false; + std::auto_ptr<ImageBuffer> buf(new ImageBuffer(size, grayScale, success)); + if (success) + return buf; + return std::auto_ptr<ImageBuffer>(); + } + ~ImageBuffer(); - IntSize size() const { return m_size; } + const IntSize& size() const { return m_size; } GraphicsContext* context() const; -#if PLATFORM(CG) - CGImageRef cgImage() const; -#elif PLATFORM(QT) - QPixmap* pixmap() const; -#elif PLATFORM(CAIRO) - cairo_surface_t* surface() const; -#endif + Image* image() const; + + void clearImage() { m_image.clear(); } + + PassRefPtr<ImageData> getImageData(const IntRect& rect) const; + void putImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint); + + String toDataURL(const String& mimeType) const; private: - void* m_data; - IntSize m_size; + ImageBufferData m_data; + IntSize m_size; OwnPtr<GraphicsContext> m_context; + mutable RefPtr<Image> m_image; -#if PLATFORM(CG) - ImageBuffer(void* imageData, const IntSize&, std::auto_ptr<GraphicsContext>); - mutable CGImageRef m_cgImage; -#elif PLATFORM(QT) - ImageBuffer(const QPixmap &px); - mutable QPixmap m_pixmap; - mutable QPainter* m_painter; -#elif PLATFORM(CAIRO) - ImageBuffer(cairo_surface_t* surface); - mutable cairo_surface_t* m_surface; -#endif -#if PLATFORM(SGL) - ImageBuffer(const IntSize&, std::auto_ptr<GraphicsContext>); -#endif + // This constructor will place its succes into the given out-variable + // so that create() knows when it should return failure. + ImageBuffer(const IntSize&, bool grayScale, bool& success); }; -} -#endif +} // namespace WebCore + +#endif // ImageBuffer_h |