#ifndef BackingStore_h
#define BackingStore_h
#include <WebCore/IntSize.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#elif PLATFORM(WIN)
#include <wtf/OwnPtr.h>
#endif
#if PLATFORM(QT)
#include <QtGui/QPainter>
#include <QtGui/QPixmap>
#endif
#if PLATFORM(GTK)
#include <RefPtrCairo.h>
#include <WebCore/GtkWidgetBackingStore.h>
#endif
namespace WebCore {
class IntRect;
}
namespace WebKit {
class ShareableBitmap;
class UpdateInfo;
class WebPageProxy;
class BackingStore {
WTF_MAKE_NONCOPYABLE(BackingStore);
public:
static PassOwnPtr<BackingStore> create(const WebCore::IntSize&, float deviceScaleFactor, WebPageProxy*);
~BackingStore();
const WebCore::IntSize& size() const { return m_size; }
float deviceScaleFactor() const { return m_deviceScaleFactor; }
#if PLATFORM(MAC)
typedef CGContextRef PlatformGraphicsContext;
#elif PLATFORM(WIN)
typedef HDC PlatformGraphicsContext;
#elif PLATFORM(QT)
typedef QPainter* PlatformGraphicsContext;
#elif PLATFORM(GTK)
typedef cairo_t* PlatformGraphicsContext;
#endif
void paint(PlatformGraphicsContext, const WebCore::IntRect&);
void incorporateUpdate(const UpdateInfo&);
private:
BackingStore(const WebCore::IntSize&, float deviceScaleFactor, WebPageProxy*);
void incorporateUpdate(ShareableBitmap*, const UpdateInfo&);
void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
WebCore::IntSize m_size;
float m_deviceScaleFactor;
WebPageProxy* m_webPageProxy;
#if PLATFORM(MAC)
CGContextRef backingStoreContext();
RetainPtr<CGLayerRef> m_cgLayer;
RetainPtr<CGContextRef> m_bitmapContext;
#elif PLATFORM(WIN)
OwnPtr<HBITMAP> m_bitmap;
#elif PLATFORM(QT)
QPixmap m_pixmap;
#elif PLATFORM(GTK)
OwnPtr<WebCore::GtkWidgetBackingStore> m_backingStore;
#endif
};
}
#endif // BackingStore_h