#ifndef CachedImage_h
#define CachedImage_h
#include "CachedResource.h"
#include "ImageObserver.h"
#include "Image.h"
#include "IntRect.h"
#include "Timer.h"
#include <wtf/Vector.h>
namespace WebCore {
class DocLoader;
class Cache;
class CachedImage : public CachedResource, public ImageObserver {
friend class Cache;
public:
CachedImage(const String& url);
CachedImage(Image*);
virtual ~CachedImage();
virtual void load(DocLoader* docLoader);
Image* image() const;
bool canRender(float multiplier) const { return !errorOccurred() && !imageSize(multiplier).isEmpty(); }
void setImageContainerSize(const IntSize&);
bool usesImageContainerSize() const;
bool imageHasRelativeWidth() const;
bool imageHasRelativeHeight() const;
IntSize imageSize(float multiplier) const; IntRect imageRect(float multiplier) const;
virtual void addClient(CachedResourceClient*);
virtual void allClientsRemoved();
virtual void destroyDecodedData();
virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
virtual void error();
virtual bool schedule() const { return true; }
void checkNotify();
virtual bool isImage() const { return true; }
void clear();
bool stillNeedsLoad() const { return !m_errorOccurred && m_status == Unknown && m_loading == false; }
void load();
virtual void decodedSizeChanged(const Image* image, int delta);
virtual void didDraw(const Image*);
virtual bool shouldPauseAnimation(const Image*);
virtual void animationAdvanced(const Image*);
virtual void changedInRect(const Image*, const IntRect&);
virtual bool shouldDecodeFrame(const Image* image, const IntSize& frameSize);
private:
void createImage();
size_t maximumDecodedImageSize();
void notifyObservers(const IntRect* changeRect = 0);
void decodedDataDeletionTimerFired(Timer<CachedImage>*);
RefPtr<Image> m_image;
Timer<CachedImage> m_decodedDataDeletionTimer;
public:
unsigned animatedImageSize();
void stopAnimatedImage();
private:
bool checkOutOfMemory();
};
}
#endif