Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
skgpu::graphite::Image Class Referencefinal

#include <Image_Graphite.h>

Inheritance diagram for skgpu::graphite::Image:
skgpu::graphite::Image_Base SkImage_Base SkImage SkRefCnt SkRefCntBase

Public Member Functions

 Image (TextureProxyView, const SkColorInfo &)
 
 ~Image () override
 
const TextureProxyViewtextureProxyView () const
 
SkImage_Base::Type type () const override
 
bool onHasMipmaps () const override
 
bool onIsProtected () const override
 
size_t textureSize () const override
 
sk_sp< ImagecopyImage (Recorder *, const SkIRect &subset, Budgeted, Mipmapped, SkBackingFit, std::string_view label) const override
 
sk_sp< SkImageonReinterpretColorSpace (sk_sp< SkColorSpace >) const override
 
- Public Member Functions inherited from skgpu::graphite::Image_Base
 ~Image_Base () override
 
void notifyInUse (Recorder *, DrawContext *drawContext) const
 
bool isDynamic () const
 
virtual sk_sp< ImagecopyImage (Recorder *, const SkIRect &subset, Budgeted, Mipmapped, SkBackingFit, std::string_view label) const
 
bool isValid (GrRecordingContext *) const override
 
sk_sp< SkImageonMakeSubset (Recorder *, const SkIRect &, RequiredProperties) const override
 
sk_sp< SkImagemakeColorTypeAndColorSpace (Recorder *, SkColorType targetCT, sk_sp< SkColorSpace > targetCS, RequiredProperties) const override
 
bool onReadPixels (GrDirectContext *, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint) const override
 
bool getROPixels (GrDirectContext *, SkBitmap *, CachingHint=kAllow_CachingHint) const override
 
sk_sp< SkImageonMakeSubset (GrDirectContext *, const SkIRect &) const override
 
sk_sp< SkImageonMakeColorTypeAndColorSpace (SkColorType, sk_sp< SkColorSpace >, GrDirectContext *) const override
 
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
 
- 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< ImageWrapDevice (sk_sp< Device > device)
 
static sk_sp< ImageCopy (Recorder *, const TextureProxyView &srcView, const SkColorInfo &, const SkIRect &subset, Budgeted, Mipmapped, SkBackingFit, std::string_view label)
 

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 skgpu::graphite::Image_Base
 Image_Base (const SkImageInfo &info, uint32_t uniqueID)
 
void linkDevices (const Image_Base *)
 
void linkDevice (sk_sp< Device >)
 
- Protected Member Functions inherited from SkImage_Base
 SkImage_Base (const SkImageInfo &info, uint32_t uniqueID)
 

Detailed Description

Definition at line 25 of file Image_Graphite.h.

Constructor & Destructor Documentation

◆ Image()

skgpu::graphite::Image::Image ( TextureProxyView  view,
const SkColorInfo info 
)

Definition at line 35 of file Image_Graphite.cpp.

37 : Image_Base(SkImageInfo::Make(view.proxy()->dimensions(), info), kNeedNewImageUniqueID)
38 , fTextureProxyView(std::move(view)) {}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kNeedNewImageUniqueID
Definition: SkImage_Base.h:33
Image_Base(const SkImageInfo &info, uint32_t uniqueID)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ ~Image()

skgpu::graphite::Image::~Image ( )
overridedefault

Member Function Documentation

◆ Copy()

sk_sp< Image > skgpu::graphite::Image::Copy ( Recorder recorder,
const TextureProxyView srcView,
const SkColorInfo srcColorInfo,
const SkIRect subset,
Budgeted  budgeted,
Mipmapped  mipmapped,
SkBackingFit  backingFit,
std::string_view  label 
)
static

Definition at line 56 of file Image_Graphite.cpp.

63 {
64 SkASSERT(!(mipmapped == Mipmapped::kYes && backingFit == SkBackingFit::kApprox));
65 if (!srcView) {
66 return nullptr;
67 }
68
69 SkASSERT(srcView.proxy()->isFullyLazy() ||
70 SkIRect::MakeSize(srcView.proxy()->dimensions()).contains(subset));
71
72 if (!recorder->priv().caps()->supportsReadPixels(srcView.proxy()->textureInfo())) {
73 if (!recorder->priv().caps()->isTexturable(srcView.proxy()->textureInfo())) {
74 // The texture is not blittable nor texturable so copying cannot be done.
75 return nullptr;
76 }
77 // Copy-as-draw
78 sk_sp<Image> srcImage(new Image(srcView, srcColorInfo));
79 return CopyAsDraw(recorder, srcImage.get(), subset, srcColorInfo,
80 budgeted, mipmapped, backingFit, std::move(label));
81 }
82
83
85 recorder->priv().caps()->getTextureInfoForSampledCopy(srcView.proxy()->textureInfo(),
86 mipmapped);
87
89 recorder->priv().caps(),
90 recorder->priv().resourceProvider(),
91 backingFit == SkBackingFit::kApprox ? GetApproxSize(subset.size()) : subset.size(),
92 textureInfo,
93 std::move(label),
94 budgeted);
95 if (!dst) {
96 return nullptr;
97 }
98
99 auto copyTask = CopyTextureToTextureTask::Make(srcView.refProxy(), subset, dst, {0, 0});
100 if (!copyTask) {
101 return nullptr;
102 }
103
104 recorder->priv().add(std::move(copyTask));
105
106 if (mipmapped == Mipmapped::kYes) {
107 if (!GenerateMipmaps(recorder, dst, srcColorInfo)) {
108 SKGPU_LOG_W("Image::Copy failed to generate mipmaps");
109 return nullptr;
110 }
111 }
112
113 return sk_sp<Image>(new Image({std::move(dst), srcView.swizzle()}, srcColorInfo));
114}
#define SKGPU_LOG_W(fmt,...)
Definition: Log.h:40
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool isTexturable(const TextureInfo &) const
Definition: Caps.cpp:66
virtual bool supportsReadPixels(const TextureInfo &textureInfo) const =0
virtual TextureInfo getTextureInfoForSampledCopy(const TextureInfo &textureInfo, Mipmapped mipmapped) const =0
static sk_sp< CopyTextureToTextureTask > Make(sk_sp< TextureProxy > srcProxy, SkIRect srcRect, sk_sp< TextureProxy > dstProxy, SkIPoint dstPoint, int dstLevel=0)
Definition: CopyTask.cpp:123
Image(TextureProxyView, const SkColorInfo &)
const Caps * caps() const
Definition: RecorderPriv.h:31
ResourceProvider * resourceProvider()
Definition: RecorderPriv.h:33
void add(sk_sp< Task >)
Definition: Recorder.cpp:485
static sk_sp< TextureProxy > Make(const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, std::string_view label, skgpu::Budgeted)
dst
Definition: cp.py:12
bool GenerateMipmaps(Recorder *recorder, sk_sp< TextureProxy > texture, const SkColorInfo &colorInfo)
sk_sp< Image > CopyAsDraw(Recorder *recorder, const SkImage *image, const SkIRect &subset, const SkColorInfo &dstColorInfo, Budgeted budgeted, Mipmapped mipmapped, SkBackingFit backingFit, std::string_view label)
SkISize GetApproxSize(SkISize size)
constexpr SkISize size() const
Definition: SkRect.h:172
static constexpr SkIRect MakeSize(const SkISize &size)
Definition: SkRect.h:66
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463

◆ copyImage()

sk_sp< Image > skgpu::graphite::Image::copyImage ( Recorder recorder,
const SkIRect subset,
Budgeted  budgeted,
Mipmapped  mipmapped,
SkBackingFit  backingFit,
std::string_view  label 
) const
overridevirtual

Reimplemented from skgpu::graphite::Image_Base.

Definition at line 128 of file Image_Graphite.cpp.

133 {
134 this->notifyInUse(recorder, /*drawContext=*/nullptr);
135 return Image::Copy(recorder, fTextureProxyView, this->imageInfo().colorInfo(),
136 subset, budgeted, mipmapped, backingFit, std::move(label));
137}
const SkImageInfo & imageInfo() const
Definition: SkImage.h:279
void notifyInUse(Recorder *, DrawContext *drawContext) const
static sk_sp< Image > Copy(Recorder *, const TextureProxyView &srcView, const SkColorInfo &, const SkIRect &subset, Budgeted, Mipmapped, SkBackingFit, std::string_view label)

◆ onHasMipmaps()

bool skgpu::graphite::Image::onHasMipmaps ( ) const
inlineoverridevirtual

Implements SkImage_Base.

Definition at line 49 of file Image_Graphite.h.

49 {
50 return fTextureProxyView.proxy()->mipmapped() == Mipmapped::kYes;
51 }
Mipmapped mipmapped() const
Definition: TextureProxy.h:35

◆ onIsProtected()

bool skgpu::graphite::Image::onIsProtected ( ) const
inlineoverridevirtual

Implements SkImage_Base.

Definition at line 53 of file Image_Graphite.h.

53 {
54 return fTextureProxyView.proxy()->isProtected();
55 }

◆ onReinterpretColorSpace()

sk_sp< SkImage > skgpu::graphite::Image::onReinterpretColorSpace ( sk_sp< SkColorSpace newCS) const
overridevirtual

Implements SkImage_Base.

Definition at line 139 of file Image_Graphite.cpp.

139 {
140 sk_sp<Image> view = sk_make_sp<Image>(fTextureProxyView,
141 this->imageInfo().colorInfo()
142 .makeColorSpace(std::move(newCS)));
143 // The new Image object shares the same texture proxy, so it should also share linked Devices
144 view->linkDevices(this);
145 return view;
146}
sk_sp< SkImage > makeColorSpace(GrDirectContext *, sk_sp< SkColorSpace >) const override

◆ textureProxyView()

const TextureProxyView & skgpu::graphite::Image::textureProxyView ( ) const
inline

Definition at line 45 of file Image_Graphite.h.

45{ return fTextureProxyView; }

◆ textureSize()

size_t skgpu::graphite::Image::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 116 of file Image_Graphite.cpp.

116 {
117 if (!fTextureProxyView.proxy()) {
118 return 0;
119 }
120
121 if (!fTextureProxyView.proxy()->texture()) {
122 return fTextureProxyView.proxy()->uninstantiatedGpuMemorySize();
123 }
124
125 return fTextureProxyView.proxy()->texture()->gpuMemorySize();
126}
size_t gpuMemorySize() const
Definition: Resource.h:104
const Texture * texture() const
size_t uninstantiatedGpuMemorySize() const

◆ type()

SkImage_Base::Type skgpu::graphite::Image::type ( ) const
inlineoverridevirtual

Implements SkImage_Base.

Definition at line 47 of file Image_Graphite.h.

◆ WrapDevice()

sk_sp< Image > skgpu::graphite::Image::WrapDevice ( sk_sp< Device device)
static

Definition at line 42 of file Image_Graphite.cpp.

42 {
43 TextureProxyView proxy = device->readSurfaceView();
44 if (!proxy) {
45 return nullptr;
46 }
47 // NOTE: If the device was created with an approx backing fit, its SkImageInfo reports the
48 // logical dimensions, but its proxy has the approximate fit. These larger dimensions are
49 // propagated to the SkImageInfo of this image view.
50 sk_sp<Image> image = sk_make_sp<Image>(std::move(proxy),
51 device->imageInfo().colorInfo());
52 image->linkDevice(std::move(device));
53 return image;
54}
VkDevice device
Definition: main.cc:53
sk_sp< const SkImage > image
Definition: SkRecords.h:269

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