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
00028 #ifndef Image_h
00029 #define Image_h
00030
00031 #include "Color.h"
00032 #ifdef __OWB__
00033 #include "AffineTransform.h"
00034 namespace BAL { class BIGraphicsContext; }
00035 #define GraphicsContext BIGraphicsContext
00036 namespace WebCore { using ::BAL::BIGraphicsContext; }
00037 #endif
00038 #include "GraphicsTypes.h"
00039 #include "ImageSource.h"
00040 #include <wtf/RefPtr.h>
00041 #include <wtf/PassRefPtr.h>
00042 #include "SharedBuffer.h"
00043
00044 #if PLATFORM(MAC)
00045 #ifdef __OBJC__
00046 @class NSImage;
00047 #else
00048 class NSImage;
00049 #endif
00050 #endif
00051
00052 #if PLATFORM(CG)
00053 struct CGContext;
00054 #endif
00055
00056 #if PLATFORM(WIN)
00057 typedef struct HBITMAP__ *HBITMAP;
00058 #endif
00059
00060 #if PLATFORM(QT)
00061 #include <QPixmap>
00062 #endif
00063
00064 namespace WebCore {
00065
00066 class AffineTransform;
00067 class FloatPoint;
00068 class FloatRect;
00069 class FloatSize;
00070 class GraphicsContext;
00071 class IntRect;
00072 class IntSize;
00073 class SharedBuffer;
00074 class String;
00075
00076
00077 class ImageObserver;
00078
00079 class Image : Noncopyable {
00080 friend class GraphicsContext;
00081 public:
00082 Image(ImageObserver* = 0);
00083 virtual ~Image();
00084
00085 static Image* loadPlatformResource(const char* name);
00086 static bool supportsType(const String&);
00087
00088 bool isNull() const;
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 #if PLATFORM(MAC)
00117
00118 virtual NSImage* getNSImage() { return 0; }
00119 virtual CFDataRef getTIFFRepresentation() { return 0; }
00120 #endif
00121
00122 #if PLATFORM(CG)
00123 virtual CGImageRef getCGImageRef() { return 0; }
00124 #endif
00125
00126 #if PLATFORM(QT)
00127 virtual QPixmap* getPixmap() const { return 0; }
00128 #endif
00129
00130 #if PLATFORM(WIN)
00131 virtual bool getHBITMAP(HBITMAP) { return false; }
00132 virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE) { return false; }
00133 #endif
00134
00135 #ifdef __OWB__
00136 virtual NativeImagePtr nativeImageForCurrentFrame() { return 0; }
00137 virtual void startAnimation() { }
00138 #endif
00139
00140 protected:
00141 static void fillWithSolidColor(GraphicsContext* ctxt, const FloatRect& dstRect, const Color& color, CompositeOperator op);
00142
00143 private:
00144 #if PLATFORM(WIN)
00145 virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, CompositeOperator) { }
00146 #endif
00147
00148 #ifndef __OWB__
00149 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator) = 0;
00150 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, CompositeOperator);
00151 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule, TileRule vRule, CompositeOperator);
00152 #endif //__OWB__
00153
00154
00155 virtual bool mayFillWithSolidColor() const { return false; }
00156 virtual Color solidColor() const { return Color(); }
00157
00158 #ifndef __OWB__
00159 virtual NativeImagePtr nativeImageForCurrentFrame() { return 0; }
00160
00161 virtual void startAnimation() { }
00162
00163
00164 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
00165 const FloatPoint& phase, CompositeOperator, const FloatRect& destRect);
00166 #endif //__OWB__
00167 #if PLATFORM(CG)
00168
00169
00170 static void drawPatternCallback(void* info, CGContext*);
00171 #endif
00172
00173 protected:
00174 RefPtr<SharedBuffer> m_data;
00175 ImageObserver* m_imageObserver;
00176 };
00177
00178 }
00179
00180 #endif