#pragma once
#include <WebCore/IntRect.h>
#include <wtf/Noncopyable.h>
#if USE(CAIRO)
#include <WebCore/BackingStoreBackendCairo.h>
#elif USE(DIRECT2D)
#include <WebCore/BackingStoreBackendDirect2D.h>
#endif
#if USE(DIRECT2D)
interface ID2D1RenderTarget;
interface ID3D11Device1;
interface ID3D11DeviceContext1;
interface ID3D11Texture2D;
#endif
namespace WebKit {
class ShareableBitmap;
class UpdateInfo;
class WebPageProxy;
class BackingStore {
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(BackingStore);
public:
BackingStore(const WebCore::IntSize&, float deviceScaleFactor, WebPageProxy&);
~BackingStore();
const WebCore::IntSize& size() const { return m_size; }
float deviceScaleFactor() const { return m_deviceScaleFactor; }
#if USE(CAIRO)
typedef cairo_t* PlatformGraphicsContext;
#elif USE(DIRECT2D)
struct DXConnections {
ID3D11DeviceContext1* immediateContext { nullptr };
ID3D11Texture2D* backBuffer { nullptr };
};
typedef DXConnections PlatformGraphicsContext;
#endif
void paint(PlatformGraphicsContext, const WebCore::IntRect&);
void incorporateUpdate(const UpdateInfo&);
private:
void incorporateUpdate(ShareableBitmap*, const UpdateInfo&);
void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
#if USE(CAIRO)
std::unique_ptr<WebCore::BackingStoreBackendCairo> createBackend();
#elif USE(DIRECT2D)
std::unique_ptr<WebCore::BackingStoreBackendDirect2D> createBackend();
#endif
WebCore::IntSize m_size;
float m_deviceScaleFactor;
WebPageProxy& m_webPageProxy;
#if USE(CAIRO)
std::unique_ptr<WebCore::BackingStoreBackendCairo> m_backend;
#elif USE(DIRECT2D)
std::unique_ptr<WebCore::BackingStoreBackendDirect2D> m_backend;
#endif
};
}