Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
SkImage_Ganesh Class Referencefinal

#include <SkImage_Ganesh.h>

Inheritance diagram for SkImage_Ganesh:
SkImage_GaneshBase SkImage_Base SkImage SkRefCnt SkRefCntBase

Public Member Functions

 SkImage_Ganesh (sk_sp< GrImageContext > context, uint32_t uniqueID, GrSurfaceProxyView view, SkColorInfo info)
 
 ~SkImage_Ganesh () override
 
size_t textureSize () const override
 
SkImage_Base::Type type () const override
 
bool onHasMipmaps () const override
 
bool onIsProtected () const override
 
sk_sp< SkImageonMakeColorTypeAndColorSpace (SkColorType, sk_sp< SkColorSpace >, GrDirectContext *) const final
 
sk_sp< SkImageonReinterpretColorSpace (sk_sp< SkColorSpace >) const final
 
void onAsyncRescaleAndReadPixels (const SkImageInfo &, SkIRect srcRect, RescaleGamma, RescaleMode, ReadPixelsCallback, ReadPixelsContext) const override
 
void onAsyncRescaleAndReadPixelsYUV420 (SkYUVColorSpace, bool readAlpha, sk_sp< SkColorSpace >, SkIRect srcRect, SkISize dstSize, RescaleGamma, RescaleMode, ReadPixelsCallback, ReadPixelsContext) const override
 
void generatingSurfaceIsDeleted () override
 
GrSemaphoresSubmitted flush (GrDirectContext *, const GrFlushInfo &) const override
 
std::tuple< GrSurfaceProxyView, GrColorTypeasView (GrRecordingContext *, skgpu::Mipmapped, GrImageTexGenPolicy) const override
 
std::unique_ptr< GrFragmentProcessorasFragmentProcessor (GrRecordingContext *, SkSamplingOptions, const SkTileMode[2], const SkMatrix &, const SkRect *, const SkRect *) const override
 
bool surfaceMustCopyOnWrite (GrSurfaceProxy *surfaceProxy) const
 
bool getExistingBackendTexture (GrBackendTexture *outTexture, bool flushPendingGrContextIO, GrSurfaceOrigin *origin) const
 
GrSurfaceOrigin origin () const override
 
- Public Member Functions inherited from SkImage_GaneshBase
bool isValid (GrRecordingContext *) const final
 
sk_sp< SkImagemakeColorTypeAndColorSpace (GrDirectContext *dContext, SkColorType targetColorType, sk_sp< SkColorSpace > targetCS) const final
 
sk_sp< SkImagemakeSubset (GrDirectContext *direct, const SkIRect &subset) const final
 
GrImageContextcontext () const final
 
GrDirectContextdirectContext () const final
 
bool getROPixels (GrDirectContext *, SkBitmap *, CachingHint) const final
 
sk_sp< SkImageonMakeSubset (GrDirectContext *, const SkIRect &subset) const final
 
bool onReadPixels (GrDirectContext *dContext, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRB, int srcX, int srcY, CachingHint) const override
 
virtual GrSemaphoresSubmitted flush (GrDirectContext *, const GrFlushInfo &) const =0
 
virtual std::tuple< GrSurfaceProxyView, GrColorTypeasView (GrRecordingContext *, skgpu::Mipmapped, GrImageTexGenPolicy) const =0
 
virtual std::unique_ptr< GrFragmentProcessorasFragmentProcessor (GrRecordingContext *, SkSamplingOptions, const SkTileMode[2], const SkMatrix &, const SkRect *, const SkRect *) const =0
 
virtual GrSurfaceOrigin origin () const =0
 
- Public Member Functions inherited from SkImage_Base
 ~SkImage_Base () override
 
sk_sp< SkImagemakeColorSpace (GrDirectContext *, sk_sp< SkColorSpace >) const override
 
sk_sp< SkImagemakeColorSpace (skgpu::graphite::Recorder *, sk_sp< SkColorSpace >, RequiredProperties) const override
 
sk_sp< SkImagemakeColorTypeAndColorSpace (GrDirectContext *dContext, SkColorType targetColorType, sk_sp< SkColorSpace > targetCS) const override
 
sk_sp< SkImagemakeColorTypeAndColorSpace (skgpu::graphite::Recorder *, SkColorType, sk_sp< SkColorSpace >, RequiredProperties) const override
 
sk_sp< SkImagemakeSubset (GrDirectContext *direct, const SkIRect &subset) const override
 
sk_sp< SkImagemakeSubset (skgpu::graphite::Recorder *, const SkIRect &, RequiredProperties) const override
 
size_t textureSize () const override
 
virtual bool onPeekPixels (SkPixmap *) const
 
virtual const SkBitmaponPeekBitmap () const
 
virtual bool onReadPixels (GrDirectContext *, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint) const =0
 
virtual bool onHasMipmaps () const =0
 
virtual bool onIsProtected () const =0
 
virtual SkMipmaponPeekMips () const
 
sk_sp< SkMipmaprefMips () const
 
virtual void onAsyncRescaleAndReadPixels (const SkImageInfo &, SkIRect srcRect, RescaleGamma, RescaleMode, ReadPixelsCallback, ReadPixelsContext) const
 
virtual void onAsyncRescaleAndReadPixelsYUV420 (SkYUVColorSpace, bool readAlpha, sk_sp< SkColorSpace > dstColorSpace, SkIRect srcRect, SkISize dstSize, RescaleGamma, RescaleMode, ReadPixelsCallback, ReadPixelsContext) const
 
virtual GrImageContextcontext () const
 
virtual GrDirectContextdirectContext () const
 
virtual void generatingSurfaceIsDeleted ()
 
virtual bool getROPixels (GrDirectContext *, SkBitmap *, CachingHint=kAllow_CachingHint) const =0
 
virtual sk_sp< SkImageonMakeSubset (GrDirectContext *, const SkIRect &) const =0
 
virtual sk_sp< SkDataonRefEncoded () const
 
virtual bool onAsLegacyBitmap (GrDirectContext *, SkBitmap *) const
 
virtual Type type () const =0
 
bool isLazyGenerated () const override
 
bool isRasterBacked () const
 
bool isGaneshBacked () const
 
bool isGraphiteBacked () const
 
bool isYUVA () const
 
bool isTextureBacked () const override
 
virtual void notifyAddedToRasterCache () const
 
virtual sk_sp< SkImageonMakeColorTypeAndColorSpace (SkColorType, sk_sp< SkColorSpace >, GrDirectContext *) const =0
 
virtual sk_sp< SkImageonReinterpretColorSpace (sk_sp< SkColorSpace >) const =0
 
virtual sk_sp< SkImageonMakeWithMipmaps (sk_sp< SkMipmap >) const
 
virtual sk_sp< SkImageonMakeSubset (skgpu::graphite::Recorder *, const SkIRect &, RequiredProperties) const =0
 
- Public Member Functions inherited from SkImage
const SkImageInfoimageInfo () const
 
int width () const
 
int height () const
 
SkISize dimensions () const
 
SkIRect bounds () const
 
uint32_t uniqueID () const
 
SkAlphaType alphaType () const
 
SkColorType colorType () const
 
SkColorSpacecolorSpace () const
 
sk_sp< SkColorSpacerefColorSpace () const
 
bool isAlphaOnly () const
 
bool isOpaque () const
 
sk_sp< SkShadermakeShader (SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
 
sk_sp< SkShadermakeShader (SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &sampling, const SkMatrix &lm) const
 
sk_sp< SkShadermakeShader (const SkSamplingOptions &sampling, const SkMatrix &lm) const
 
sk_sp< SkShadermakeShader (const SkSamplingOptions &sampling, const SkMatrix *lm=nullptr) const
 
sk_sp< SkShadermakeRawShader (SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
 
sk_sp< SkShadermakeRawShader (SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &sampling, const SkMatrix &lm) const
 
sk_sp< SkShadermakeRawShader (const SkSamplingOptions &sampling, const SkMatrix &lm) const
 
sk_sp< SkShadermakeRawShader (const SkSamplingOptions &sampling, const SkMatrix *lm=nullptr) const
 
bool peekPixels (SkPixmap *pixmap) const
 
virtual bool isTextureBacked () const =0
 
virtual size_t textureSize () const =0
 
virtual bool isValid (GrRecordingContext *context) const =0
 
bool readPixels (GrDirectContext *context, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
 
bool readPixels (GrDirectContext *context, const SkPixmap &dst, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
 
bool readPixels (const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
 
bool readPixels (const SkPixmap &dst, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
 
void asyncRescaleAndReadPixels (const SkImageInfo &info, const SkIRect &srcRect, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context) const
 
void asyncRescaleAndReadPixelsYUV420 (SkYUVColorSpace yuvColorSpace, sk_sp< SkColorSpace > dstColorSpace, const SkIRect &srcRect, const SkISize &dstSize, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context) const
 
void asyncRescaleAndReadPixelsYUVA420 (SkYUVColorSpace yuvColorSpace, sk_sp< SkColorSpace > dstColorSpace, const SkIRect &srcRect, const SkISize &dstSize, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context) const
 
bool scalePixels (const SkPixmap &dst, const SkSamplingOptions &, CachingHint cachingHint=kAllow_CachingHint) const
 
sk_sp< SkDatarefEncodedData () const
 
virtual sk_sp< SkImagemakeSubset (GrDirectContext *direct, const SkIRect &subset) const =0
 
virtual sk_sp< SkImagemakeSubset (skgpu::graphite::Recorder *, const SkIRect &subset, RequiredProperties) const =0
 
bool hasMipmaps () const
 
bool isProtected () const
 
sk_sp< SkImagewithDefaultMipmaps () const
 
sk_sp< SkImagemakeNonTextureImage (GrDirectContext *=nullptr) const
 
sk_sp< SkImagemakeRasterImage (GrDirectContext *, CachingHint cachingHint=kDisallow_CachingHint) const
 
sk_sp< SkImagemakeRasterImage (CachingHint cachingHint=kDisallow_CachingHint) const
 
bool asLegacyBitmap (SkBitmap *bitmap, LegacyBitmapMode legacyBitmapMode=kRO_LegacyBitmapMode) const
 
virtual bool isLazyGenerated () const =0
 
virtual sk_sp< SkImagemakeColorSpace (GrDirectContext *direct, sk_sp< SkColorSpace > target) const =0
 
virtual sk_sp< SkImagemakeColorSpace (skgpu::graphite::Recorder *, sk_sp< SkColorSpace > targetColorSpace, RequiredProperties) const =0
 
virtual sk_sp< SkImagemakeColorTypeAndColorSpace (GrDirectContext *direct, SkColorType targetColorType, sk_sp< SkColorSpace > targetCS) const =0
 
virtual sk_sp< SkImagemakeColorTypeAndColorSpace (skgpu::graphite::Recorder *, SkColorType targetColorType, sk_sp< SkColorSpace > targetColorSpace, RequiredProperties) const =0
 
sk_sp< SkImagereinterpretColorSpace (sk_sp< SkColorSpace > newColorSpace) 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< SkImageMakeWithVolatileSrc (sk_sp< GrRecordingContext > rContext, GrSurfaceProxyView volatileSrc, SkColorInfo colorInfo)
 
- Static Public Member Functions inherited from SkImage_GaneshBase
static bool ValidateBackendTexture (const GrCaps *, const GrBackendTexture &tex, GrColorType grCT, SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs)
 
static bool ValidateCompressedBackendTexture (const GrCaps *, const GrBackendTexture &tex, SkAlphaType)
 
static sk_sp< GrTextureProxyMakePromiseImageLazyProxy (GrContextThreadSafeProxy *, SkISize dimensions, const GrBackendFormat &, skgpu::Mipmapped, SkImages::PromiseImageTextureFulfillProc, sk_sp< skgpu::RefCntedCallback > releaseHelper)
 

Additional Inherited Members

- Public Types inherited from SkImage_Base
enum class  Type {
  kRaster , kRasterPinnable , kLazy , kLazyPicture ,
  kGanesh , kGaneshYUVA , kGraphite , kGraphiteYUVA
}
 
- Public Types inherited from SkImage
enum  CachingHint { kAllow_CachingHint , kDisallow_CachingHint }
 
enum class  RescaleGamma : bool { kSrc , kLinear }
 
enum class  RescaleMode { kNearest , kLinear , kRepeatedLinear , kRepeatedCubic }
 
enum  LegacyBitmapMode { kRO_LegacyBitmapMode }
 
using ReadPixelsContext = void *
 
using ReadPixelsCallback = void(ReadPixelsContext, std::unique_ptr< const AsyncReadResult >)
 
- Protected Member Functions inherited from SkImage_GaneshBase
 SkImage_GaneshBase (sk_sp< GrImageContext >, SkImageInfo, uint32_t uniqueID)
 
sk_sp< SkImageonMakeSubset (skgpu::graphite::Recorder *, const SkIRect &subset, RequiredProperties) const final
 
sk_sp< SkImagemakeColorTypeAndColorSpace (skgpu::graphite::Recorder *, SkColorType, sk_sp< SkColorSpace >, RequiredProperties) const final
 
virtual sk_sp< SkImageonMakeColorTypeAndColorSpace (SkColorType, sk_sp< SkColorSpace >, GrDirectContext *) const=0
 
- Protected Member Functions inherited from SkImage_Base
 SkImage_Base (const SkImageInfo &info, uint32_t uniqueID)
 
- Protected Attributes inherited from SkImage_GaneshBase
sk_sp< GrImageContextfContext
 

Detailed Description

Definition at line 56 of file SkImage_Ganesh.h.

Constructor & Destructor Documentation

◆ SkImage_Ganesh()

SkImage_Ganesh::SkImage_Ganesh ( sk_sp< GrImageContext context,
uint32_t  uniqueID,
GrSurfaceProxyView  view,
SkColorInfo  info 
)

Definition at line 157 of file SkImage_Ganesh.cpp.

161 : INHERITED(std::move(context),
162 SkImageInfo::Make(view.proxy()->backingStoreDimensions(), std::move(info)),
163 uniqueID)
164 , fChooser(view.detachProxy())
165 , fSwizzle(view.swizzle())
166 , fOrigin(view.origin()) {
167#ifdef SK_DEBUG
168 const GrBackendFormat& format = fChooser.backendFormat();
169 const GrCaps* caps = this->context()->priv().caps();
173#endif
174}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
GrColorType
Definition: GrTypesPriv.h:540
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
Definition: GrTypesPriv.h:629
#define SkASSERT(cond)
Definition: SkAssert.h:116
const GrCaps * caps() const
Definition: GrCaps.h:57
bool areColorTypeAndFormatCompatible(GrColorType grCT, const GrBackendFormat &format) const
Definition: GrCaps.cpp:428
bool isFormatCompressed(const GrBackendFormat &format) const
Definition: GrCaps.cpp:457
GrImageContextPriv priv()
skgpu::Swizzle swizzle() const
sk_sp< GrSurfaceProxy > detachProxy()
GrSurfaceOrigin origin() const
GrSurfaceProxy * proxy() const
SkISize backingStoreDimensions() const
GrImageContext * context() const final
uint32_t uniqueID() const
Definition: SkImage.h:311
SkColorType colorType() const
Definition: SkImage.cpp:152
uint32_t uint32_t * format
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ ~SkImage_Ganesh()

SkImage_Ganesh::~SkImage_Ganesh ( )
overridedefault

Member Function Documentation

◆ asFragmentProcessor()

std::unique_ptr< GrFragmentProcessor > SkImage_Ganesh::asFragmentProcessor ( GrRecordingContext rContext,
SkSamplingOptions  sampling,
const SkTileMode  tileModes[2],
const SkMatrix m,
const SkRect subset,
const SkRect domain 
) const
overridevirtual

Implements SkImage_GaneshBase.

Definition at line 431 of file SkImage_Ganesh.cpp.

437 {
438 if (!fContext->priv().matches(rContext)) {
439 return {};
440 }
441 auto mm =
444 rContext,
445 std::get<0>(skgpu::ganesh::AsView(rContext, this, mm)),
446 this->alphaType(),
447 sampling,
448 tileModes,
449 m,
450 subset,
451 domain);
452}
bool matches(GrContext_Base *candidate) const
sk_sp< GrImageContext > fContext
SkAlphaType alphaType() const
Definition: SkImage.cpp:154
SkSamplingOptions sampling
Definition: SkRecords.h:337
const myers::Point & get< 0 >(const myers::Segment &s)
Definition: Myers.h:80
std::tuple< GrSurfaceProxyView, GrColorType > AsView(GrRecordingContext *rContext, const SkImage *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)
std::unique_ptr< GrFragmentProcessor > MakeFragmentProcessorFromView(GrRecordingContext *rContext, GrSurfaceProxyView view, SkAlphaType at, SkSamplingOptions sampling, const SkTileMode tileModes[2], const SkMatrix &m, const SkRect *subset, const SkRect *domain)
const SkMipmapMode mipmap

◆ asView()

std::tuple< GrSurfaceProxyView, GrColorType > SkImage_Ganesh::asView ( GrRecordingContext recordingContext,
skgpu::Mipmapped  mipmapped,
GrImageTexGenPolicy  policy 
) const
overridevirtual

Implements SkImage_GaneshBase.

Definition at line 407 of file SkImage_Ganesh.cpp.

410 {
411 if (!fContext->priv().matches(recordingContext)) {
412 return {};
413 }
415 return {skgpu::ganesh::CopyView(recordingContext,
416 this->makeView(recordingContext),
417 mipmapped,
418 policy,
419 /*label=*/"SkImageGpu_AsView"),
421 }
422 GrSurfaceProxyView view = this->makeView(recordingContext);
424 if (mipmapped == skgpu::Mipmapped::kYes) {
425 view = skgpu::ganesh::FindOrMakeCachedMipmappedView(recordingContext, std::move(view),
426 this->uniqueID());
427 }
428 return {std::move(view), ct};
429}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network policy
Definition: switches.h:248
GrSurfaceProxyView FindOrMakeCachedMipmappedView(GrRecordingContext *rContext, GrSurfaceProxyView view, uint32_t imageUniqueID)
GrSurfaceProxyView CopyView(GrRecordingContext *context, GrSurfaceProxyView src, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy, std::string_view label)

◆ flush()

GrSemaphoresSubmitted SkImage_Ganesh::flush ( GrDirectContext dContext,
const GrFlushInfo info 
) const
overridevirtual

Implements SkImage_GaneshBase.

Definition at line 249 of file SkImage_Ganesh.cpp.

250 {
251 if (!fContext->priv().matches(dContext) || dContext->abandoned()) {
252 if (info.fSubmittedProc) {
253 info.fSubmittedProc(info.fSubmittedContext, false);
254 }
255 if (info.fFinishedProc) {
256 info.fFinishedProc(info.fFinishedContext);
257 }
259 }
260
261 sk_sp<GrSurfaceProxy> proxy = fChooser.chooseProxy(dContext);
262 return dContext->priv().flushSurface(
264}
GrSemaphoresSubmitted flushSurface(GrSurfaceProxy *proxy, SkSurfaces::BackendSurfaceAccess access=SkSurfaces::BackendSurfaceAccess::kNoAccess, const GrFlushInfo &info={}, const skgpu::MutableTextureState *newState=nullptr)
bool abandoned() override
GrDirectContextPriv priv()
T * get() const
Definition: SkRefCnt.h:303
@ kNoAccess
back-end surface will not be used by client

◆ generatingSurfaceIsDeleted()

void SkImage_Ganesh::generatingSurfaceIsDeleted ( )
overridevirtual

Reimplemented from SkImage_Base.

Definition at line 405 of file SkImage_Ganesh.cpp.

405{ fChooser.makeVolatileProxyStable(); }

◆ getExistingBackendTexture()

bool SkImage_Ganesh::getExistingBackendTexture ( GrBackendTexture outTexture,
bool  flushPendingGrContextIO,
GrSurfaceOrigin origin 
) const

Definition at line 266 of file SkImage_Ganesh.cpp.

268 {
269 auto direct = fContext->asDirectContext();
270 if (!direct) {
271 // This image was created with a DDL context and cannot be instantiated.
272 return false;
273 }
274 if (direct->abandoned()) {
275 return false;
276 }
277
278 // We don't know how client's use of the texture will be ordered WRT Skia's. Ensure the
279 // texture seen by the client won't be mutated by a SkSurface.
280 sk_sp<GrSurfaceProxy> proxy = fChooser.switchToStableProxy();
281
282 if (!proxy->isInstantiated()) {
283 auto resourceProvider = direct->priv().resourceProvider();
284
285 if (!proxy->instantiate(resourceProvider)) {
286 return false;
287 }
288 }
289
290 GrTexture* texture = proxy->peekTexture();
291 if (!texture) {
292 return false;
293 }
294 if (flushPendingGrContextIO) {
295 direct->priv().flushSurface(proxy.get());
296 }
297 if (origin) {
298 *origin = fOrigin;
299 }
300 if (outTexture) {
301 *outTexture = texture->getBackendTexture();
302 }
303 return true;
304}
virtual GrDirectContext * asDirectContext()
virtual bool instantiate(GrResourceProvider *)=0
GrTexture * peekTexture() const
bool isInstantiated() const
GrSurfaceOrigin origin() const override
FlTexture * texture

◆ MakeWithVolatileSrc()

sk_sp< SkImage > SkImage_Ganesh::MakeWithVolatileSrc ( sk_sp< GrRecordingContext rContext,
GrSurfaceProxyView  volatileSrc,
SkColorInfo  colorInfo 
)
static

Definition at line 201 of file SkImage_Ganesh.cpp.

203 {
204 SkASSERT(rContext);
205 SkASSERT(volatileSrc);
206 SkASSERT(volatileSrc.proxy()->asTextureProxy());
207 skgpu::Mipmapped mm = volatileSrc.proxy()->asTextureProxy()->mipmapped();
208 sk_sp<GrRenderTask> copyTask;
209 auto copy = GrSurfaceProxy::Copy(rContext.get(),
210 volatileSrc.refProxy(),
211 volatileSrc.origin(),
212 mm,
215 /*label=*/"ImageGpu_MakeWithVolatileSrc",
216 &copyTask);
217 if (!copy) {
218 return nullptr;
219 }
220 // We only attempt to make a dual-proxy image on a direct context. This optimziation requires
221 // knowing how things are ordered and recording-only contexts are not well ordered WRT other
222 // recording contexts.
223 if (auto direct = sk_ref_sp(rContext->asDirectContext())) {
224 int targetCount = volatileSrc.proxy()->getTaskTargetCount();
225 return sk_sp<SkImage>(new SkImage_Ganesh(std::move(direct),
226 std::move(volatileSrc),
227 std::move(copy),
228 std::move(copyTask),
229 targetCount,
230 std::move(colorInfo)));
231 }
232 GrSurfaceProxyView copyView(std::move(copy), volatileSrc.origin(), volatileSrc.swizzle());
233 return sk_make_sp<SkImage_Ganesh>(
234 std::move(rContext), kNeedNewImageUniqueID, std::move(copyView), std::move(colorInfo));
235}
@ kNeedNewImageUniqueID
Definition: SkImage_Base.h:33
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
sk_sp< GrSurfaceProxy > refProxy() const
int getTaskTargetCount() const
static sk_sp< GrSurfaceProxy > Copy(GrRecordingContext *, sk_sp< GrSurfaceProxy > src, GrSurfaceOrigin, skgpu::Mipmapped, SkIRect srcRect, SkBackingFit, skgpu::Budgeted, std::string_view label, RectsMustMatch=RectsMustMatch::kNo, sk_sp< GrRenderTask > *outTask=nullptr)
virtual GrTextureProxy * asTextureProxy()
skgpu::Mipmapped mipmapped() const
SkImage_Ganesh(sk_sp< GrImageContext > context, uint32_t uniqueID, GrSurfaceProxyView view, SkColorInfo info)
Definition: copy.py:1
Mipmapped
Definition: GpuTypes.h:53

◆ onAsyncRescaleAndReadPixels()

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

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

Reimplemented from SkImage_Base.

Definition at line 352 of file SkImage_Ganesh.cpp.

357 {
358 auto dContext = fContext->asDirectContext();
359 if (!dContext) {
360 // DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
361 callback(context, nullptr);
362 return;
363 }
364 auto ctx = dContext->priv().makeSC(this->makeView(dContext), this->imageInfo().colorInfo());
365 if (!ctx) {
366 callback(context, nullptr);
367 return;
368 }
369 ctx->asyncRescaleAndReadPixels(
370 dContext, info, srcRect, rescaleGamma, rescaleMode, callback, context);
371}
const SkImageInfo & imageInfo() const
Definition: SkImage.h:279
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ onAsyncRescaleAndReadPixelsYUV420()

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

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

Reimplemented from SkImage_Base.

Definition at line 373 of file SkImage_Ganesh.cpp.

381 {
382 auto dContext = fContext->asDirectContext();
383 if (!dContext) {
384 // DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
385 callback(context, nullptr);
386 return;
387 }
388 auto ctx = dContext->priv().makeSC(this->makeView(dContext), this->imageInfo().colorInfo());
389 if (!ctx) {
390 callback(context, nullptr);
391 return;
392 }
393 ctx->asyncRescaleAndReadPixelsYUV420(dContext,
394 yuvColorSpace,
395 readAlpha,
396 std::move(dstColorSpace),
397 srcRect,
398 dstSize,
399 rescaleGamma,
400 rescaleMode,
401 callback,
402 context);
403}

◆ onHasMipmaps()

bool SkImage_Ganesh::onHasMipmaps ( ) const
overridevirtual

Implements SkImage_Base.

Definition at line 243 of file SkImage_Ganesh.cpp.

243{ return fChooser.mipmapped() == skgpu::Mipmapped::kYes; }

◆ onIsProtected()

bool SkImage_Ganesh::onIsProtected ( ) const
overridevirtual

Implements SkImage_Base.

Definition at line 245 of file SkImage_Ganesh.cpp.

245 {
246 return fChooser.isProtected() == skgpu::Protected::kYes;
247}

◆ onMakeColorTypeAndColorSpace()

sk_sp< SkImage > SkImage_Ganesh::onMakeColorTypeAndColorSpace ( SkColorType  targetCT,
sk_sp< SkColorSpace targetCS,
GrDirectContext dContext 
) const
finalvirtual

Implements SkImage_Base.

Definition at line 308 of file SkImage_Ganesh.cpp.

310 {
311 SkColorInfo info(targetCT, this->alphaType(), std::move(targetCS));
312 if (!fContext->priv().matches(dContext)) {
313 return nullptr;
314 }
315
316 sk_sp<GrSurfaceProxy> proxy = fChooser.chooseProxy(dContext);
317
318 auto sfc = dContext->priv().makeSFCWithFallback(GrImageInfo(info, this->dimensions()),
320 /* sampleCount= */ 1,
322 proxy->isProtected());
323 if (!sfc) {
324 return nullptr;
325 }
326 // We respecify info's CT because we called MakeWithFallback.
327 auto ct = GrColorTypeToSkColorType(sfc->colorInfo().colorType());
328 info = info.makeColorType(ct);
329
330 // Draw this image's texture into the SFC.
331 auto [view, _] = skgpu::ganesh::AsView(dContext, this, skgpu::Mipmapped(this->hasMipmaps()));
332 auto texFP = GrTextureEffect::Make(std::move(view), this->alphaType());
333 auto colorFP =
334 GrColorSpaceXformEffect::Make(std::move(texFP), this->imageInfo().colorInfo(), info);
335 sfc->fillWithFP(std::move(colorFP));
336
337 return sk_make_sp<SkImage_Ganesh>(
338 sk_ref_sp(dContext), kNeedNewImageUniqueID, sfc->readSurfaceView(), std::move(info));
339}
static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct)
Definition: GrTypesPriv.h:589
static std::unique_ptr< GrFragmentProcessor > Make(std::unique_ptr< GrFragmentProcessor > child, SkColorSpace *src, SkAlphaType srcAT, SkColorSpace *dst, SkAlphaType dstAT)
std::unique_ptr< skgpu::ganesh::SurfaceFillContext > makeSFCWithFallback(GrImageInfo, SkBackingFit, int sampleCount, skgpu::Mipmapped, skgpu::Protected, GrSurfaceOrigin=kTopLeft_GrSurfaceOrigin, skgpu::Budgeted=skgpu::Budgeted::kYes)
GrProtected isProtected() const
static std::unique_ptr< GrFragmentProcessor > Make(GrSurfaceProxyView, SkAlphaType, const SkMatrix &=SkMatrix::I(), GrSamplerState::Filter=GrSamplerState::Filter::kNearest, GrSamplerState::MipmapMode mipmapMode=GrSamplerState::MipmapMode::kNone)
SkISize dimensions() const
Definition: SkImage.h:297
bool hasMipmaps() const
Definition: SkImage.cpp:292

◆ onReinterpretColorSpace()

sk_sp< SkImage > SkImage_Ganesh::onReinterpretColorSpace ( sk_sp< SkColorSpace newCS) const
finalvirtual

Implements SkImage_Base.

Definition at line 341 of file SkImage_Ganesh.cpp.

341 {
342 // It doesn't seem worth the complexity of trying to share the ProxyChooser among multiple
343 // images. Just fall back to the stable copy.
344 GrSurfaceProxyView view(fChooser.switchToStableProxy(), fOrigin, fSwizzle);
345 return sk_make_sp<SkImage_Ganesh>(
346 fContext,
348 std::move(view),
349 this->imageInfo().colorInfo().makeColorSpace(std::move(newCS)));
350}
sk_sp< SkImage > makeColorSpace(GrDirectContext *, sk_sp< SkColorSpace >) const override

◆ origin()

GrSurfaceOrigin SkImage_Ganesh::origin ( ) const
inlineoverridevirtual

Implements SkImage_GaneshBase.

Definition at line 127 of file SkImage_Ganesh.h.

127{ return fOrigin; }

◆ surfaceMustCopyOnWrite()

bool SkImage_Ganesh::surfaceMustCopyOnWrite ( GrSurfaceProxy surfaceProxy) const

Definition at line 239 of file SkImage_Ganesh.cpp.

239 {
240 return fChooser.surfaceMustCopyOnWrite(surfaceProxy);
241}

◆ textureSize()

size_t SkImage_Ganesh::textureSize ( ) const
overridevirtual

Returns an approximation of the amount of texture memory used by the image. Returns zero if the image is not texture backed or if the texture has an external format.

Implements SkImage.

Definition at line 306 of file SkImage_Ganesh.cpp.

306{ return fChooser.gpuMemorySize(); }

◆ type()

SkImage_Base::Type SkImage_Ganesh::type ( ) const
inlineoverridevirtual

Implements SkImage_Base.

Definition at line 73 of file SkImage_Ganesh.h.


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