ImageBufferIOSurfaceBackend.h [plain text]
#pragma once
#if HAVE(IOSURFACE)
#include "ImageBufferCGBackend.h"
#include "IOSurface.h"
#include <wtf/IsoMalloc.h>
namespace WebCore {
class WEBCORE_EXPORT ImageBufferIOSurfaceBackend : public ImageBufferCGBackend {
WTF_MAKE_ISO_ALLOCATED(ImageBufferIOSurfaceBackend);
WTF_MAKE_NONCOPYABLE(ImageBufferIOSurfaceBackend);
public:
static IntSize calculateBackendSize(const FloatSize& logicalSize, float resolutionScale);
static std::unique_ptr<ImageBufferIOSurfaceBackend> create(const FloatSize&, float resolutionScale, ColorSpace, CGColorSpaceRef, const HostWindow*);
static std::unique_ptr<ImageBufferIOSurfaceBackend> create(const FloatSize&, float resolutionScale, ColorSpace, const HostWindow*);
static std::unique_ptr<ImageBufferIOSurfaceBackend> create(const FloatSize&, const GraphicsContext&);
ImageBufferIOSurfaceBackend(const FloatSize& logicalSize, const IntSize& physicalSize, float resolutionScale, ColorSpace, std::unique_ptr<IOSurface>&&);
GraphicsContext& context() const override;
void flushContext() override;
size_t memoryCost() const override;
size_t externalMemoryCost() const override;
NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const override;
NativeImagePtr sinkIntoNativeImage() override;
void drawConsuming(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions&) override;
RetainPtr<CFDataRef> toCFData(const String& mimeType, Optional<double> quality, PreserveResolution) const override;
Vector<uint8_t> toBGRAData() const override;
RefPtr<ImageData> getImageData(AlphaPremultiplication outputFormat, const IntRect&) const override;
void putImageData(AlphaPremultiplication inputFormat, const ImageData&, const IntRect& srcRect, const IntPoint& destPoint, AlphaPremultiplication destFormat) override;
IOSurface* surface();
bool isAccelerated() const override;
protected:
static RetainPtr<CGColorSpaceRef> contextColorSpace(const GraphicsContext&);
unsigned bytesPerRow() const override;
ColorFormat backendColorFormat() const override;
std::unique_ptr<IOSurface> m_surface;
mutable bool m_requiresDrawAfterPutImageData { false };
};
}
#endif // HAVE(IOSURFACE)