ShareableSurface.h [plain text]
#ifndef ShareableSurface_h
#define ShareableSurface_h
#include "ShareableBitmap.h"
#include <wtf/ThreadSafeRefCounted.h>
#if USE(GRAPHICS_SURFACE)
#include "GraphicsSurface.h"
#endif
namespace WebCore {
class BitmapTexture;
class Image;
class GraphicsContext;
}
namespace WebKit {
class ShareableSurface : public ThreadSafeRefCounted<ShareableSurface> {
public:
enum Hint {
SupportsGraphicsSurface = 0x01
};
typedef unsigned Hints;
class Handle {
WTF_MAKE_NONCOPYABLE(Handle);
public:
Handle();
bool isNull() const;
void encode(CoreIPC::ArgumentEncoder*) const;
static bool decode(CoreIPC::ArgumentDecoder*, Handle&);
#if USE(GRAPHICS_SURFACE)
uint32_t graphicsSurfaceToken() const { return m_graphicsSurfaceToken; }
#endif
private:
friend class ShareableSurface;
mutable ShareableBitmap::Handle m_bitmapHandle;
#if USE(GRAPHICS_SURFACE)
uint32_t m_graphicsSurfaceToken;
#endif
WebCore::IntSize m_size;
ShareableBitmap::Flags m_flags;
};
static PassRefPtr<ShareableSurface> create(const WebCore::IntSize&, ShareableBitmap::Flags, Hints);
static PassRefPtr<ShareableSurface> create(const Handle&);
ShareableBitmap::Flags flags() const { return m_flags; }
bool createHandle(Handle&);
~ShareableSurface();
const WebCore::IntSize& size() const { return m_size; }
WebCore::IntRect bounds() const { return WebCore::IntRect(WebCore::IntPoint(), size()); }
PassOwnPtr<WebCore::GraphicsContext> createGraphicsContext(const WebCore::IntRect&);
#if USE(TEXTURE_MAPPER)
void copyToTexture(PassRefPtr<WebCore::BitmapTexture>, const WebCore::IntRect& target, const WebCore::IntPoint& sourceOffset);
#endif
private:
ShareableSurface(const WebCore::IntSize&, ShareableBitmap::Flags, PassRefPtr<ShareableBitmap>);
static PassRefPtr<ShareableSurface> create(const WebCore::IntSize&, ShareableBitmap::Flags, PassRefPtr<ShareableBitmap>);
#if USE(GRAPHICS_SURFACE)
ShareableSurface(const WebCore::IntSize&, ShareableBitmap::Flags, PassRefPtr<WebCore::GraphicsSurface>);
static PassRefPtr<ShareableSurface> createWithSurface(const WebCore::IntSize&, ShareableBitmap::Flags);
static PassRefPtr<ShareableSurface> create(const WebCore::IntSize&, ShareableBitmap::Flags, PassRefPtr<WebCore::GraphicsSurface>);
bool isBackedByGraphicsSurface() const { return !!m_graphicsSurface; }
#endif
WebCore::IntSize m_size;
ShareableBitmap::Flags m_flags;
RefPtr<ShareableBitmap> m_bitmap;
#if USE(GRAPHICS_SURFACE)
RefPtr<WebCore::GraphicsSurface> m_graphicsSurface;
#endif
};
}
#endif // ShareableSurface_h