ImageBufferCairoGLSurfaceBackend.h [plain text]
#pragma once
#if USE(CAIRO) && ENABLE(ACCELERATED_2D_CANVAS)
#include "ImageBufferCairoSurfaceBackend.h"
#include <wtf/IsoMalloc.h>
#if USE(NICOSIA)
#include "NicosiaContentLayerTextureMapperImpl.h"
#else
#include "PlatformLayer.h"
#endif
namespace WebCore {
class ImageBufferCairoGLSurfaceBackend
#if USE(NICOSIA)
: public Nicosia::ContentLayerTextureMapperImpl::Client
#else
: public PlatformLayer
#endif
, public ImageBufferCairoSurfaceBackend {
WTF_MAKE_ISO_ALLOCATED(ImageBufferCairoGLSurfaceBackend);
WTF_MAKE_NONCOPYABLE(ImageBufferCairoGLSurfaceBackend);
public:
static std::unique_ptr<ImageBufferCairoGLSurfaceBackend> create(const FloatSize&, float resolutionScale, ColorSpace, const HostWindow*);
static std::unique_ptr<ImageBufferCairoGLSurfaceBackend> create(const FloatSize&, const GraphicsContext&);
~ImageBufferCairoGLSurfaceBackend();
PlatformLayer* platformLayer() const override;
bool copyToPlatformTexture(GCGLenum target, PlatformGLObject destinationTexture, GCGLenum internalformat, bool premultiplyAlpha, bool flipY) override;
private:
ImageBufferCairoGLSurfaceBackend(const FloatSize& logicalSize, const IntSize& backendSize, float resolutionScale, ColorSpace, RefPtr<cairo_surface_t>&&);
#if USE(COORDINATED_GRAPHICS)
void createCompositorBuffer();
void swapBuffersIfNeeded() override;
#if !USE(NICOSIA)
RefPtr<TextureMapperPlatformLayerProxy> proxy() const override { return m_platformLayerProxy.copyRef(); }
#endif
#else
void paintToTextureMapper(TextureMapper&, const FloatRect& target, const TransformationMatrix&, float opacity);
#endif
#if USE(COORDINATED_GRAPHICS)
#if USE(NICOSIA)
RefPtr<Nicosia::ContentLayer> m_nicosiaLayer;
#else
RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy;
#endif
uint32_t m_texture;
RefPtr<cairo_surface_t> m_compositorSurface;
RefPtr<cairo_t> m_compositorCr;
uint32_t m_compositorTexture { 0 };
#endif
uint32_t m_texture { 0 };
};
}
#endif // USE(CAIRO) && ENABLE(ACCELERATED_2D_CANVAS)