KHTML
ImageSource.h
Go to the documentation of this file.00001 /* 00002 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions 00006 * are met: 00007 * 1. Redistributions of source code must retain the above copyright 00008 * notice, this list of conditions and the following disclaimer. 00009 * 2. Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * 00013 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 00014 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00015 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00016 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 00017 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00018 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00019 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00020 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00021 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00023 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 */ 00025 00026 #ifndef ImageSource_h 00027 #define ImageSource_h 00028 00029 #include <wtf/Noncopyable.h> 00030 #include <wtf/Vector.h> 00031 00032 #if PLATFORM(WX) 00033 class wxBitmap; 00034 #elif PLATFORM(CG) 00035 typedef struct CGImageSource* CGImageSourceRef; 00036 typedef struct CGImage* CGImageRef; 00037 typedef const struct __CFData* CFDataRef; 00038 #elif PLATFORM(QT) 00039 #include <qglobal.h> 00040 QT_BEGIN_NAMESPACE 00041 class QPixmap; 00042 QT_END_NAMESPACE 00043 #elif PLATFORM(CAIRO) 00044 struct _cairo_surface; 00045 typedef struct _cairo_surface cairo_surface_t; 00046 #endif 00047 00048 namespace WebCore { 00049 00050 class IntSize; 00051 class SharedBuffer; 00052 00053 #if PLATFORM(WX) 00054 class ImageDecoder; 00055 typedef ImageDecoder* NativeImageSourcePtr; 00056 typedef const Vector<char>* NativeBytePtr; 00057 typedef wxBitmap* NativeImagePtr; 00058 #elif PLATFORM(CG) 00059 typedef CGImageSourceRef NativeImageSourcePtr; 00060 typedef CGImageRef NativeImagePtr; 00061 #elif PLATFORM(QT) 00062 class ImageDecoderQt; 00063 typedef ImageDecoderQt* NativeImageSourcePtr; 00064 typedef QPixmap* NativeImagePtr; 00065 #else 00066 class ImageDecoder; 00067 typedef ImageDecoder* NativeImageSourcePtr; 00068 typedef cairo_surface_t* NativeImagePtr; 00069 #endif 00070 00071 const int cAnimationLoopOnce = -1; 00072 const int cAnimationNone = -2; 00073 00074 class ImageSource : Noncopyable { 00075 public: 00076 ImageSource(); 00077 ~ImageSource(); 00078 00079 void clear(); 00080 00081 bool initialized() const; 00082 00083 void setData(SharedBuffer* data, bool allDataReceived); 00084 00085 bool isSizeAvailable(); 00086 IntSize size() const; 00087 00088 int repetitionCount(); 00089 00090 size_t frameCount() const; 00091 00092 NativeImagePtr createFrameAtIndex(size_t); 00093 00094 float frameDurationAtIndex(size_t); 00095 bool frameHasAlphaAtIndex(size_t); // Whether or not the frame actually used any alpha. 00096 bool frameIsCompleteAtIndex(size_t); // Whether or not the frame is completely decoded. 00097 00098 private: 00099 NativeImageSourcePtr m_decoder; 00100 }; 00101 00102 } 00103 00104 #endif