#ifndef BackingStore_h
#define BackingStore_h
#include <WebCore/IntRect.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#endif
#if PLATFORM(QT)
#include <QtGui/QPainter>
#include <QtGui/QPixmap>
#endif
#if USE(CAIRO)
#include <RefPtrCairo.h>
#include <WebCore/WidgetBackingStore.h>
#endif
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(QT)
typedef QPainter* PlatformGraphicsContext;
#elif USE(CAIRO)
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();
void performWithScrolledRectTransform(const WebCore::IntRect&, void (^)(const WebCore::IntRect&, const WebCore::IntSize&));
void resetScrolledRect();
RetainPtr<CGLayerRef> m_cgLayer;
RetainPtr<CGContextRef> m_bitmapContext;
WebCore::IntRect m_scrolledRect;
WebCore::IntSize m_scrolledRectOffset;
#elif PLATFORM(QT)
QPixmap m_pixmap;
#elif USE(CAIRO)
OwnPtr<WebCore::WidgetBackingStore> m_backingStore;
#endif
};
}
#endif // BackingStore_h