KHTML
Image.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef Image_h
00028 #define Image_h
00029
00030 #include "Color.h"
00031 #include "GraphicsTypes.h"
00032 #include "ImageSource.h"
00033 #include <wtf/RefPtr.h>
00034 #include <wtf/PassRefPtr.h>
00035 #include "SharedBuffer.h"
00036
00037 #if PLATFORM(MAC)
00038 #ifdef __OBJC__
00039 @class NSImage;
00040 #else
00041 class NSImage;
00042 #endif
00043 #endif
00044
00045 #if PLATFORM(CG)
00046 struct CGContext;
00047 #endif
00048
00049 #if PLATFORM(WIN)
00050 typedef struct HBITMAP__ *HBITMAP;
00051 #endif
00052
00053 #if PLATFORM(QT)
00054 #include <QPixmap>
00055 #endif
00056
00057 namespace WebCore {
00058
00059 class AffineTransform;
00060 class FloatPoint;
00061 class FloatRect;
00062 class FloatSize;
00063 class GraphicsContext;
00064 class IntRect;
00065 class IntSize;
00066 class SharedBuffer;
00067
00068
00069
00070 class ImageObserver;
00071
00072 class Image : Noncopyable {
00073 friend class GeneratedImage;
00074 friend class GraphicsContext;
00075 public:
00076 Image(ImageObserver* = 0);
00077 virtual ~Image();
00078
00079 static Image* loadPlatformResource(const char* name);
00080 static bool supportsType(const String&);
00081
00082 bool isNull() const;
00083
00084
00085 virtual void setContainerSize(const IntSize&) { }
00086 virtual bool usesContainerSize() const { return false; }
00087 virtual bool hasRelativeWidth() const { return false; }
00088 virtual bool hasRelativeHeight() const { return false; }
00089
00090 virtual IntSize size() const = 0;
00091 IntRect rect() const;
00092 int width() const;
00093 int height() const;
00094
00095 bool setData(PassRefPtr<SharedBuffer> data, bool allDataReceived);
00096 virtual bool dataChanged(bool allDataReceived) { return false; }
00097
00098
00099
00100 virtual void destroyDecodedData(bool incremental = false) {};
00101 virtual unsigned decodedSize() const { return 0; }
00102
00103 SharedBuffer* data() { return m_data.get(); }
00104
00105
00106
00107
00108 virtual void stopAnimation() {}
00109 virtual void resetAnimation() {}
00110
00111
00112 ImageObserver* imageObserver() const { return m_imageObserver; }
00113
00114 enum TileRule { StretchTile, RoundTile, RepeatTile };
00115
00116 virtual NativeImagePtr nativeImageForCurrentFrame() { return 0; }
00117
00118 #if PLATFORM(MAC)
00119
00120 virtual NSImage* getNSImage() { return 0; }
00121 virtual CFDataRef getTIFFRepresentation() { return 0; }
00122 #endif
00123
00124 #if PLATFORM(CG)
00125 virtual CGImageRef getCGImageRef() { return 0; }
00126 #endif
00127
00128 #if PLATFORM(QT)
00129 virtual QPixmap* getPixmap() const { return 0; }
00130 #endif
00131
00132 #if PLATFORM(WIN)
00133 virtual bool getHBITMAP(HBITMAP) { return false; }
00134 virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE) { return false; }
00135 #endif
00136
00137 protected:
00138 static void fillWithSolidColor(GraphicsContext* ctxt, const FloatRect& dstRect, const Color& color, CompositeOperator op);
00139
00140 protected:
00141 #if PLATFORM(WIN)
00142 virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, CompositeOperator) { }
00143 #endif
00144 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator) = 0;
00145 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, CompositeOperator);
00146 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule, TileRule vRule, CompositeOperator);
00147
00148
00149 virtual bool mayFillWithSolidColor() const { return false; }
00150 virtual Color solidColor() const { return Color(); }
00151
00152 virtual void startAnimation() { }
00153
00154 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
00155 const FloatPoint& phase, CompositeOperator, const FloatRect& destRect);
00156 #if PLATFORM(CG)
00157
00158
00159 static void drawPatternCallback(void* info, CGContext*);
00160 #endif
00161
00162 protected:
00163 RefPtr<SharedBuffer> m_data;
00164 ImageObserver* m_imageObserver;
00165 };
00166
00167 }
00168
00169 #endif