Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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) 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 *) const
 
bool isDynamic () 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 SkMipmaponPeekMips () const
 
sk_sp< SkMipmaprefMips () const
 
virtual GrImageContextcontext () const
 
virtual GrDirectContextdirectContext () const
 
virtual void generatingSurfaceIsDeleted ()
 
virtual sk_sp< SkDataonRefEncoded () const
 
virtual bool onAsLegacyBitmap (GrDirectContext *, SkBitmap *) const
 
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< SkImageonMakeWithMipmaps (sk_sp< SkMipmap >) const
 
- 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
 
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
 
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
 
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)
 

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)
 
- Static Protected Member Functions inherited from skgpu::graphite::Image_Base
static sk_sp< ImageCopyAsDraw (Recorder *, const Image_Base *, const SkIRect &subset, const SkColorInfo &dstColorInfo, Budgeted, Mipmapped, SkBackingFit)
 

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
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 
)
static

Definition at line 56 of file Image_Graphite.cpp.

62 {
63 SkASSERT(!(mipmapped == Mipmapped::kYes && backingFit == SkBackingFit::kApprox));
64 if (!srcView) {
65 return nullptr;
66 }
67
68 SkASSERT(srcView.proxy()->isFullyLazy() ||
69 SkIRect::MakeSize(srcView.proxy()->dimensions()).contains(subset));
70
71 if (!recorder->priv().caps()->supportsReadPixels(srcView.proxy()->textureInfo())) {
72 if (!recorder->priv().caps()->isTexturable(srcView.proxy()->textureInfo())) {
73 // The texture is not blittable nor texturable so copying cannot be done.
74 return nullptr;
75 }
76 // Copy-as-draw
77 sk_sp<Image> srcImage(new Image(srcView, srcColorInfo));
78 return CopyAsDraw(recorder, srcImage.get(), subset, srcColorInfo,
79 budgeted, mipmapped, backingFit);
80 }
81
82
84 recorder->priv().caps()->getTextureInfoForSampledCopy(srcView.proxy()->textureInfo(),
85 mipmapped);
86
88 recorder->priv().caps(),
89 recorder->priv().resourceProvider(),
90 backingFit == SkBackingFit::kApprox ? GetApproxSize(subset.size()) : subset.size(),
91 textureInfo,
92 budgeted);
93 if (!dst) {
94 return nullptr;
95 }
96
97 auto copyTask = CopyTextureToTextureTask::Make(srcView.refProxy(), subset, dst, {0, 0});
98 if (!copyTask) {
99 return nullptr;
100 }
101
102 recorder->priv().add(std::move(copyTask));
103
104 if (mipmapped == Mipmapped::kYes) {
105 if (!GenerateMipmaps(recorder, dst, srcColorInfo)) {
106 SKGPU_LOG_W("Image::Copy failed to generate mipmaps");
107 return nullptr;
108 }
109 }
110
111 return sk_sp<Image>(new Image({std::move(dst), srcView.swizzle()}, srcColorInfo));
112}
#define SKGPU_LOG_W(fmt,...)
Definition Log.h:40
#define SkASSERT(cond)
Definition SkAssert.h:116
bool isTexturable(const TextureInfo &) const
Definition Caps.cpp:65
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:119
static sk_sp< Image > CopyAsDraw(Recorder *, const Image_Base *, const SkIRect &subset, const SkColorInfo &dstColorInfo, Budgeted, Mipmapped, SkBackingFit)
Image(TextureProxyView, const SkColorInfo &)
const Caps * caps() const
ResourceProvider * resourceProvider()
void add(sk_sp< Task >)
Definition Recorder.cpp:477
static sk_sp< TextureProxy > Make(const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, skgpu::Budgeted)
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 JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
dst
Definition cp.py:12
bool GenerateMipmaps(Recorder *recorder, sk_sp< TextureProxy > texture, const SkColorInfo &colorInfo)
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 
) const
overridevirtual

Reimplemented from skgpu::graphite::Image_Base.

Definition at line 126 of file Image_Graphite.cpp.

130 {
131 this->notifyInUse(recorder);
132 return Image::Copy(recorder, fTextureProxyView, this->imageInfo().colorInfo(),
133 subset, budgeted, mipmapped, backingFit);
134}
const SkImageInfo & imageInfo() const
Definition SkImage.h:279
void notifyInUse(Recorder *) const
static sk_sp< Image > Copy(Recorder *, const TextureProxyView &srcView, const SkColorInfo &, const SkIRect &subset, Budgeted, Mipmapped, SkBackingFit)

◆ onHasMipmaps()

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

Implements SkImage_Base.

Definition at line 48 of file Image_Graphite.h.

48 {
49 return fTextureProxyView.proxy()->mipmapped() == Mipmapped::kYes;
50 }
Mipmapped mipmapped() const

◆ onIsProtected()

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

Implements SkImage_Base.

Definition at line 52 of file Image_Graphite.h.

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

◆ onReinterpretColorSpace()

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

Implements SkImage_Base.

Definition at line 136 of file Image_Graphite.cpp.

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

◆ textureProxyView()

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

Definition at line 44 of file Image_Graphite.h.

44{ 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 114 of file Image_Graphite.cpp.

114 {
115 if (!fTextureProxyView.proxy()) {
116 return 0;
117 }
118
119 if (!fTextureProxyView.proxy()->texture()) {
120 return fTextureProxyView.proxy()->uninstantiatedGpuMemorySize();
121 }
122
123 return fTextureProxyView.proxy()->texture()->gpuMemorySize();
124}
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 46 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< SkImage > image
Definition examples.cpp:29

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