#ifndef DrawingBuffer_h
#define DrawingBuffer_h
#include "GraphicsContext3D.h"
#include "GraphicsLayer.h"
#include "IntSize.h"
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#endif
#if USE(SKIA)
class GrContext;
struct GrPlatformSurfaceDesc;
#endif
namespace WebCore {
#if PLATFORM(CHROMIUM)
struct DrawingBufferInternal;
#endif
class DrawingBuffer : public RefCounted<DrawingBuffer> {
public:
friend class GraphicsContext3D;
~DrawingBuffer();
void clearFramebuffer();
bool reset(const IntSize&);
void bind();
IntSize size() const { return m_size; }
Platform3DObject colorBuffer() const { return m_colorBuffer; }
void clear();
void createSecondaryBuffers();
void resizeDepthStencil(int sampleCount);
void commit(long x = 0, long y = 0, long width = -1, long height = -1);
bool multisample() const { return m_context && m_context->getContextAttributes().antialias && m_multisampleExtensionSupported; }
Platform3DObject platformColorBuffer() const;
#if USE(ACCELERATED_COMPOSITING)
PlatformLayer* platformLayer();
void publishToPlatformLayer();
#endif
#if PLATFORM(CHROMIUM)
class WillPublishCallback {
WTF_MAKE_NONCOPYABLE(WillPublishCallback);
public:
WillPublishCallback() { }
virtual ~WillPublishCallback() { }
virtual void willPublish() = 0;
};
void setWillPublishCallback(PassOwnPtr<WillPublishCallback> callback) { m_callback = callback; }
#endif
#if USE(SKIA)
void setGrContext(GrContext* ctx);
void getGrPlatformSurfaceDesc(GrPlatformSurfaceDesc*);
#endif
PassRefPtr<GraphicsContext3D> graphicsContext3D() const { return m_context; }
private:
static PassRefPtr<DrawingBuffer> create(GraphicsContext3D*, const IntSize&);
DrawingBuffer(GraphicsContext3D*, const IntSize&, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported);
void didReset();
RefPtr<GraphicsContext3D> m_context;
IntSize m_size;
bool m_multisampleExtensionSupported;
bool m_packedDepthStencilExtensionSupported;
Platform3DObject m_fbo;
Platform3DObject m_colorBuffer;
Platform3DObject m_depthStencilBuffer;
Platform3DObject m_depthBuffer;
Platform3DObject m_stencilBuffer;
Platform3DObject m_multisampleFBO;
Platform3DObject m_multisampleColorBuffer;
#if PLATFORM(CHROMIUM)
OwnPtr<WillPublishCallback> m_callback;
OwnPtr<DrawingBufferInternal> m_internal;
#endif
#if PLATFORM(MAC)
RetainPtr<WebGLLayer> m_platformLayer;
#endif
#if USE(SKIA)
GrContext* m_grContext;
#endif
};
}
#endif // DrawingBuffer_h