Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
skgpu::graphite::Surface Class Referencefinal

#include <Surface_Graphite.h>

Inheritance diagram for skgpu::graphite::Surface:
SkSurface_Base SkSurface SkRefCnt SkRefCntBase

Public Member Functions

 Surface (sk_sp< Device >)
 
 ~Surface () override
 
SkImageInfo imageInfo () const override
 
SkSurface_Base::Type type () const override
 
RecorderonGetRecorder () const override
 
SkCanvasonNewCanvas () override
 
sk_sp< SkSurfaceonNewSurface (const SkImageInfo &) override
 
sk_sp< SkImageonNewImageSnapshot (const SkIRect *subset) override
 
void onWritePixels (const SkPixmap &, int x, int y) override
 
void onAsyncRescaleAndReadPixels (const SkImageInfo &info, SkIRect srcRect, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context) override
 
void onAsyncRescaleAndReadPixelsYUV420 (SkYUVColorSpace yuvColorSpace, bool readAlpha, sk_sp< SkColorSpace > dstColorSpace, SkIRect srcRect, SkISize dstSize, RescaleGamma rescaleGamma, RescaleMode, ReadPixelsCallback callback, ReadPixelsContext context) override
 
bool onCopyOnWrite (ContentChangeMode) override
 
sk_sp< const SkCapabilitiesonCapabilities () override
 
TextureProxyView readSurfaceView () const
 
sk_sp< ImageasImage () const
 
sk_sp< ImagemakeImageCopy (const SkIRect *subset, Mipmapped) const
 
TextureProxybackingTextureProxy () const
 
- Public Member Functions inherited from SkSurface_Base
 SkSurface_Base (int width, int height, const SkSurfaceProps *)
 
 SkSurface_Base (const SkImageInfo &, const SkSurfaceProps *)
 
 ~SkSurface_Base () override
 
bool replaceBackendTexture (const GrBackendTexture &, GrSurfaceOrigin, ContentChangeMode, TextureReleaseProc, ReleaseContext) override
 
bool isRasterBacked () const
 
bool isGaneshBacked () const
 
bool isGraphiteBacked () const
 
virtual GrRecordingContextonGetRecordingContext () const
 
virtual void onDraw (SkCanvas *, SkScalar x, SkScalar y, const SkSamplingOptions &, const SkPaint *)
 
virtual void onDiscard ()
 
virtual void onRestoreBackingMutability ()
 
virtual bool onWait (int numSemaphores, const GrBackendSemaphore *waitSemaphores, bool deleteSemaphoresAfterWait)
 
virtual bool onCharacterize (GrSurfaceCharacterization *) const
 
virtual bool onIsCompatible (const GrSurfaceCharacterization &) const
 
SkCanvasgetCachedCanvas ()
 
sk_sp< SkImagerefCachedImage ()
 
bool hasCachedImage () const
 
uint32_t newGenerationID ()
 
- Public Member Functions inherited from SkSurface
bool isCompatible (const GrSurfaceCharacterization &characterization) const
 
int width () const
 
int height () const
 
uint32_t generationID ()
 
void notifyContentWillChange (ContentChangeMode mode)
 
GrRecordingContextrecordingContext () const
 
skgpu::graphite::Recorderrecorder () const
 
SkCanvasgetCanvas ()
 
sk_sp< const SkCapabilitiescapabilities ()
 
sk_sp< SkSurfacemakeSurface (const SkImageInfo &imageInfo)
 
sk_sp< SkSurfacemakeSurface (int width, int height)
 
sk_sp< SkImagemakeImageSnapshot ()
 
sk_sp< SkImagemakeImageSnapshot (const SkIRect &bounds)
 
void draw (SkCanvas *canvas, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, const SkPaint *paint)
 
void draw (SkCanvas *canvas, SkScalar x, SkScalar y, const SkPaint *paint=nullptr)
 
bool peekPixels (SkPixmap *pixmap)
 
bool readPixels (const SkPixmap &dst, int srcX, int srcY)
 
bool readPixels (const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY)
 
bool readPixels (const SkBitmap &dst, int srcX, int srcY)
 
void asyncRescaleAndReadPixels (const SkImageInfo &info, const SkIRect &srcRect, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context)
 
void asyncRescaleAndReadPixelsYUV420 (SkYUVColorSpace yuvColorSpace, sk_sp< SkColorSpace > dstColorSpace, const SkIRect &srcRect, const SkISize &dstSize, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context)
 
void asyncRescaleAndReadPixelsYUVA420 (SkYUVColorSpace yuvColorSpace, sk_sp< SkColorSpace > dstColorSpace, const SkIRect &srcRect, const SkISize &dstSize, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context)
 
void writePixels (const SkPixmap &src, int dstX, int dstY)
 
void writePixels (const SkBitmap &src, int dstX, int dstY)
 
const SkSurfacePropsprops () const
 
bool wait (int numSemaphores, const GrBackendSemaphore *waitSemaphores, bool deleteSemaphoresAfterWait=true)
 
bool characterize (GrSurfaceCharacterization *characterization) const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< SurfaceMake (Recorder *recorder, const SkImageInfo &info, Budgeted budgeted, Mipmapped mipmapped=Mipmapped::kNo, SkBackingFit backingFit=SkBackingFit::kExact, const SkSurfaceProps *props=nullptr)
 
static sk_sp< SurfaceMakeScratch (Recorder *recorder, const SkImageInfo &info, Budgeted budgeted=Budgeted::kYes, Mipmapped mipmapped=Mipmapped::kNo, SkBackingFit backingFit=SkBackingFit::kApprox)
 

Friends

void Flush (SkSurface *)
 

Additional Inherited Members

- Public Types inherited from SkSurface_Base
enum class  Type { kNull , kGanesh , kGraphite , kRaster }
 
- Public Types inherited from SkSurface
enum  ContentChangeMode { kDiscard_ContentChangeMode , kRetain_ContentChangeMode }
 
enum class  BackendHandleAccess {
  kFlushRead , kFlushWrite , kDiscardWrite , kFlushRead_BackendHandleAccess = kFlushRead ,
  kFlushWrite_BackendHandleAccess = kFlushWrite , kDiscardWrite_BackendHandleAccess = kDiscardWrite
}
 
using ReleaseContext = void *
 
using TextureReleaseProc = void(*)(ReleaseContext)
 
using AsyncReadResult = SkImage::AsyncReadResult
 
using ReadPixelsContext = void *
 
using ReadPixelsCallback = void(ReadPixelsContext, std::unique_ptr< const AsyncReadResult >)
 
using RescaleGamma = SkImage::RescaleGamma
 
using RescaleMode = SkImage::RescaleMode
 
- Static Public Attributes inherited from SkSurface
static constexpr BackendHandleAccess kFlushRead_BackendHandleAccess
 
static constexpr BackendHandleAccess kFlushWrite_BackendHandleAccess
 
static constexpr BackendHandleAccess kDiscardWrite_BackendHandleAccess
 
- Protected Member Functions inherited from SkSurface
 SkSurface (int width, int height, const SkSurfaceProps *surfaceProps)
 
 SkSurface (const SkImageInfo &imageInfo, const SkSurfaceProps *surfaceProps)
 
void dirtyGenerationID ()
 

Detailed Description

Definition at line 26 of file Surface_Graphite.h.

Constructor & Destructor Documentation

◆ Surface()

Surface::Surface ( sk_sp< Device device)

Definition at line 28 of file Surface_Graphite.cpp.

29 : SkSurface_Base(device->width(), device->height(), &device->surfaceProps())
30 , fDevice(std::move(device))
31 , fImageView(Image::WrapDevice(fDevice)) {}
static sk_sp< Image > WrapDevice(sk_sp< Device > device)
VkDevice device
Definition main.cc:53

◆ ~Surface()

Surface::~Surface ( )
override

Definition at line 33 of file Surface_Graphite.cpp.

33 {
34 // Mark the device immutable when the Surface is destroyed to flush any pending work to the
35 // recorder and to flag the device so that any linked image views can detach from the Device
36 // when they are next drawn.
37 fDevice->setImmutable();
38}

Member Function Documentation

◆ asImage()

sk_sp< Image > Surface::asImage ( ) const

Definition at line 65 of file Surface_Graphite.cpp.

65 {
66 if (this->hasCachedImage()) {
67 SKGPU_LOG_W("Intermingling makeImageSnapshot and asImage calls may produce "
68 "unexpected results. Please use either the old _or_ new API.");
69 }
70 return fImageView;
71}
#define SKGPU_LOG_W(fmt,...)
Definition Log.h:40
bool hasCachedImage() const

◆ backingTextureProxy()

TextureProxy * Surface::backingTextureProxy ( ) const

Definition at line 117 of file Surface_Graphite.cpp.

117{ return fDevice->target(); }

◆ imageInfo()

SkImageInfo Surface::imageInfo ( ) const
overridevirtual

Returns an ImageInfo describing the surface.

Reimplemented from SkSurface.

Definition at line 40 of file Surface_Graphite.cpp.

40 {
41 return fDevice->imageInfo();
42}

◆ Make()

static sk_sp< Surface > skgpu::graphite::Surface::Make ( Recorder recorder,
const SkImageInfo info,
Budgeted  budgeted,
Mipmapped  mipmapped = Mipmapped::kNo,
SkBackingFit  backingFit = SkBackingFit::kExact,
const SkSurfaceProps props = nullptr 
)
inlinestatic

Definition at line 29 of file Surface_Graphite.h.

34 {
35 return Make(recorder, info, budgeted, mipmapped, backingFit, props,
36 LoadOp::kClear, /*registerWithRecorder=*/true);
37 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
const SkSurfaceProps & props() const
Definition SkSurface.h:604
skgpu::graphite::Recorder * recorder() const
static sk_sp< Surface > Make(Recorder *recorder, const SkImageInfo &info, Budgeted budgeted, Mipmapped mipmapped=Mipmapped::kNo, SkBackingFit backingFit=SkBackingFit::kExact, const SkSurfaceProps *props=nullptr)

◆ makeImageCopy()

sk_sp< Image > Surface::makeImageCopy ( const SkIRect subset,
Mipmapped  mipmapped 
) const

Definition at line 73 of file Surface_Graphite.cpp.

73 {
74 if (this->hasCachedImage()) {
75 SKGPU_LOG_W("Intermingling makeImageSnapshot and asImage calls may produce "
76 "unexpected results. Please use either the old _or_ new API.");
77 }
78
79 SkIRect srcRect = subset ? *subset : SkIRect::MakeSize(this->imageInfo().dimensions());
80 // NOTE: Must copy through fDevice and not fImageView if the surface's texture is not sampleable
81 return fDevice->makeImageCopy(srcRect, Budgeted::kNo, mipmapped, SkBackingFit::kExact);
82}
SkImageInfo imageInfo() const override
static constexpr SkIRect MakeSize(const SkISize &size)
Definition SkRect.h:66

◆ MakeScratch()

static sk_sp< Surface > skgpu::graphite::Surface::MakeScratch ( Recorder recorder,
const SkImageInfo info,
Budgeted  budgeted = Budgeted::kYes,
Mipmapped  mipmapped = Mipmapped::kNo,
SkBackingFit  backingFit = SkBackingFit::kApprox 
)
inlinestatic

Definition at line 42 of file Surface_Graphite.h.

46 {
47 return Make(recorder, info, budgeted, mipmapped, backingFit,
48 /*props=*/nullptr, LoadOp::kDiscard, /*registerWithRecorder=*/false);
49 }

◆ onAsyncRescaleAndReadPixels()

void Surface::onAsyncRescaleAndReadPixels ( const SkImageInfo info,
SkIRect  srcRect,
RescaleGamma  rescaleGamma,
RescaleMode  rescaleMode,
ReadPixelsCallback  callback,
ReadPixelsContext  context 
)
overridevirtual

Default implementation does a rescale/read and then calls the callback.

Reimplemented from SkSurface_Base.

Definition at line 90 of file Surface_Graphite.cpp.

95 {
96 // Not supported for Graphite. Use Context::asyncRescaleAndReadPixels instead.
97 callback(context, nullptr);
98}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ onAsyncRescaleAndReadPixelsYUV420()

void Surface::onAsyncRescaleAndReadPixelsYUV420 ( SkYUVColorSpace  yuvColorSpace,
bool  readAlpha,
sk_sp< SkColorSpace dstColorSpace,
SkIRect  srcRect,
SkISize  dstSize,
RescaleGamma  rescaleGamma,
RescaleMode  ,
ReadPixelsCallback  callback,
ReadPixelsContext  context 
)
overridevirtual

Default implementation does a rescale/read/yuv conversion and then calls the callback.

Reimplemented from SkSurface_Base.

Definition at line 100 of file Surface_Graphite.cpp.

108 {
109 // Not supported for Graphite. Use Context::asyncRescaleAndReadPixelsYUV420 instead.
110 callback(context, nullptr);
111}

◆ onCapabilities()

sk_sp< const SkCapabilities > Surface::onCapabilities ( )
overridevirtual

Reimplemented from SkSurface_Base.

Definition at line 113 of file Surface_Graphite.cpp.

113 {
114 return fDevice->recorder()->priv().caps()->capabilities();
115}

◆ onCopyOnWrite()

bool Surface::onCopyOnWrite ( ContentChangeMode  )
overridevirtual

If the surface is about to change, we call this so that our subclass can optionally fork their backend (copy-on-write) in case it was being shared with the cachedImage.

Returns false if the backing cannot be un-shared.

Implements SkSurface_Base.

Definition at line 88 of file Surface_Graphite.cpp.

88{ return true; }

◆ onGetRecorder()

Recorder * Surface::onGetRecorder ( ) const
overridevirtual

Reimplemented from SkSurface_Base.

Definition at line 44 of file Surface_Graphite.cpp.

44{ return fDevice->recorder(); }

◆ onNewCanvas()

SkCanvas * Surface::onNewCanvas ( )
overridevirtual

Allocate a canvas that will draw into this surface. We will cache this canvas, to return the same object to the caller multiple times. We take ownership, and will call unref() on the canvas when we go out of scope.

Implements SkSurface_Base.

Definition at line 50 of file Surface_Graphite.cpp.

50{ return new SkCanvas(fDevice); }
friend class SkCanvas

◆ onNewImageSnapshot()

sk_sp< SkImage > Surface::onNewImageSnapshot ( const SkIRect subset)
overridevirtual

Allocate an SkImage that represents the current contents of the surface. This needs to be able to outlive the surface itself (if need be), and must faithfully represent the current contents, even if the surface is changed after this called (e.g. it is drawn to via its canvas).

If a subset is specified, the the impl must make a copy, rather than try to wait on copy-on-write.

Reimplemented from SkSurface_Base.

Definition at line 56 of file Surface_Graphite.cpp.

56 {
57 TextureProxyView srcView = fDevice->readSurfaceView();
58 if (!srcView) {
59 return nullptr;
60 }
61
62 return this->makeImageCopy(subset, srcView.mipmapped());
63}
sk_sp< Image > makeImageCopy(const SkIRect *subset, Mipmapped) const
skgpu::Mipmapped mipmapped() const

◆ onNewSurface()

sk_sp< SkSurface > Surface::onNewSurface ( const SkImageInfo ii)
overridevirtual

Implements SkSurface_Base.

Definition at line 52 of file Surface_Graphite.cpp.

52 {
53 return SkSurfaces::RenderTarget(fDevice->recorder(), ii, Mipmapped::kNo, &this->props());
54}
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)

◆ onWritePixels()

void Surface::onWritePixels ( const SkPixmap pixmap,
int  x,
int  y 
)
overridevirtual

Implements SkSurface_Base.

Definition at line 84 of file Surface_Graphite.cpp.

84 {
85 fDevice->writePixels(pixmap, x, y);
86}
double y
double x

◆ readSurfaceView()

TextureProxyView Surface::readSurfaceView ( ) const

Definition at line 46 of file Surface_Graphite.cpp.

46 {
47 return fDevice->readSurfaceView();
48}

◆ type()

SkSurface_Base::Type skgpu::graphite::Surface::type ( ) const
inlineoverridevirtual

Reimplemented from SkSurface_Base.

Definition at line 58 of file Surface_Graphite.h.

Friends And Related Symbol Documentation

◆ Flush

void Flush ( SkSurface )
friend

Definition at line 25 of file GpuTools.h.

25 {
26#if defined(SK_GANESH)
28#endif
29#if defined(SK_GRAPHITE)
31#endif
32}
VkSurfaceKHR surface
Definition main.cc:49
SK_API GrSemaphoresSubmitted Flush(sk_sp< SkSurface >)
void Flush(sk_sp< SkSurface > surface)

The documentation for this class was generated from the following files: