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

#include <Image_YUVA_Graphite.h>

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

Public Member Functions

 ~Image_YUVA () override
 
SkImage_Base::Type type () const override
 
size_t textureSize () const override
 
bool onHasMipmaps () const override
 
bool onIsProtected () const override
 
sk_sp< SkImageonReinterpretColorSpace (sk_sp< SkColorSpace >) const override
 
const TextureProxyViewproxyView (int channelIndex) const
 
std::tuple< int, intuvSubsampleFactors () const
 
const SkYUVAInfoyuvaInfo () const
 
- Public Member Functions inherited from skgpu::graphite::Image_Base
 ~Image_Base () override
 
void notifyInUse (Recorder *) const
 
bool isDynamic () const
 
virtual sk_sp< ImagecopyImage (Recorder *, const SkIRect &subset, Budgeted, Mipmapped, SkBackingFit) 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< Image_YUVAMake (const Caps *caps, const SkYUVAInfo &yuvaInfo, SkSpan< TextureProxyView > planes, sk_sp< SkColorSpace > imageColorSpace)
 
static sk_sp< Image_YUVAWrapImages (const Caps *caps, const SkYUVAInfo &yuvaInfo, SkSpan< const sk_sp< SkImage > > images, sk_sp< SkColorSpace > imageColorSpace)
 

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 21 of file Image_YUVA_Graphite.h.

Constructor & Destructor Documentation

◆ ~Image_YUVA()

skgpu::graphite::Image_YUVA::~Image_YUVA ( )
overridedefault

Member Function Documentation

◆ Make()

sk_sp< Image_YUVA > skgpu::graphite::Image_YUVA::Make ( const Caps caps,
const SkYUVAInfo yuvaInfo,
SkSpan< TextureProxyView planes,
sk_sp< SkColorSpace imageColorSpace 
)
static

Definition at line 81 of file Image_YUVA_Graphite.cpp.

84 {
85 if (!yuvaInfo.isValid()) {
86 return nullptr;
87 }
89 yuvaInfo.dimensions(), kAssumedColorType, yuva_alpha_type(yuvaInfo), imageColorSpace);
91 return nullptr;
92 }
93
94 // Invoke the PlaneProxyFactoryFn for each plane and validate it against the plane config
95 const int numPlanes = yuvaInfo.numPlanes();
96 SkISize planeDimensions[SkYUVAInfo::kMaxPlanes];
97 if (numPlanes != yuvaInfo.planeDimensions(planeDimensions)) {
98 return nullptr;
99 }
100 uint32_t pixmapChannelmasks[SkYUVAInfo::kMaxPlanes];
101 for (int i = 0; i < numPlanes; ++i) {
102 if (!planes[i] || !caps->isTexturable(planes[i].proxy()->textureInfo())) {
103 return nullptr;
104 }
105 if (planes[i].dimensions() != planeDimensions[i]) {
106 return nullptr;
107 }
108 pixmapChannelmasks[i] = caps->channelMask(planes[i].proxy()->textureInfo());
109 }
110
111 // Re-arrange the proxies from planes to channels
112 SkYUVAInfo::YUVALocations locations = yuvaInfo.toYUVALocations(pixmapChannelmasks);
113 int expectedPlanes;
114 if (!SkYUVAInfo::YUVALocation::AreValidLocations(locations, &expectedPlanes) ||
115 expectedPlanes != numPlanes) {
116 return nullptr;
117 }
118 // Y channel should match the YUVAInfo dimensions
119 if (planes[locations[kY].fPlane].dimensions() != yuvaInfo.dimensions()) {
120 return nullptr;
121 }
122 // UV channels should have planes with the same dimensions and subsampling factor.
123 if (planes[locations[kU].fPlane].dimensions() != planes[locations[kV].fPlane].dimensions()) {
124 return nullptr;
125 }
126 // If A channel is present, it should match the Y channel
127 if (locations[kA].fPlane >= 0 &&
128 planes[locations[kA].fPlane].dimensions() != yuvaInfo.dimensions()) {
129 return nullptr;
130 }
131
132 if (yuvaInfo.planeSubsamplingFactors(locations[kU].fPlane) !=
133 yuvaInfo.planeSubsamplingFactors(locations[kV].fPlane)) {
134 return nullptr;
135 }
136
137 // Re-arrange into YUVA channel order and apply the location to the swizzle
138 YUVAProxies channelProxies;
139 for (int i = 0; i < SkYUVAInfo::kYUVAChannelCount; ++i) {
140 auto [plane, channel] = locations[i];
141 if (plane >= 0) {
142 // Compose the YUVA location with the data swizzle. replaceSwizzle() is used since
143 // selectChannelInR() effectively does the composition (vs. Swizzle::Concat).
144 Swizzle channelSwizzle = planes[plane].swizzle().selectChannelInR((int) channel);
145 channelProxies[i] = planes[plane].replaceSwizzle(channelSwizzle);
146 } else if (i == kA) {
147 // The alpha channel is allowed to be not provided, set it to an empty view
148 channelProxies[i] = {};
149 } else {
150 SKGPU_LOG_W("YUVA channel %d does not have a valid location", i);
151 return nullptr;
152 }
153 }
154
155 return sk_sp<Image_YUVA>(new Image_YUVA(std::move(channelProxies),
156 yuvaInfo,
157 std::move(imageColorSpace)));
158}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
#define SKGPU_LOG_W(fmt,...)
Definition Log.h:40
static bool SkImageInfoIsValid(const SkImageInfo &info)
static constexpr auto kAssumedColorType
SkISize dimensions() const
Definition SkImage.h:297
int numPlanes() const
Definition SkYUVAInfo.h:204
static constexpr int kMaxPlanes
Definition SkYUVAInfo.h:98
YUVALocations toYUVALocations(const uint32_t *channelFlags) const
std::tuple< int, int > planeSubsamplingFactors(int planeIdx) const
Definition SkYUVAInfo.h:163
int planeDimensions(SkISize planeDimensions[kMaxPlanes]) const
Definition SkYUVAInfo.h:192
std::array< YUVALocation, kYUVAChannelCount > YUVALocations
Definition SkYUVAInfo.h:32
static constexpr int kYUVAChannelCount
Definition SkYUVAInfo.h:29
bool isValid() const
Definition SkYUVAInfo.h:233
SkISize dimensions() const
Definition SkYUVAInfo.h:171
const SkYUVAInfo & yuvaInfo() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static bool AreValidLocations(const SkYUVAInfo::YUVALocations &locations, int *numPlanes=nullptr)

◆ onHasMipmaps()

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

Implements SkImage_Base.

Definition at line 43 of file Image_YUVA_Graphite.h.

43{ return fMipmapped == Mipmapped::kYes; }

◆ onIsProtected()

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

Implements SkImage_Base.

Definition at line 45 of file Image_YUVA_Graphite.h.

45{ return fProtected == Protected::kYes; }

◆ onReinterpretColorSpace()

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

Implements SkImage_Base.

Definition at line 225 of file Image_YUVA_Graphite.cpp.

225 {
226 sk_sp<Image_YUVA> view{new Image_YUVA(fProxies,
227 fYUVAInfo,
228 std::move(newCS))};
229 // The new Image object shares the same texture planes, so it should also share linked Devices
230 view->linkDevices(this);
231 return view;
232}

◆ proxyView()

const TextureProxyView & skgpu::graphite::Image_YUVA::proxyView ( int  channelIndex) const
inline

Definition at line 52 of file Image_YUVA_Graphite.h.

52 {
53 SkASSERT(channelIndex >= 0 && channelIndex < SkYUVAInfo::kYUVAChannelCount);
54 return fProxies[channelIndex];
55 }
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ textureSize()

size_t skgpu::graphite::Image_YUVA::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 194 of file Image_YUVA_Graphite.cpp.

194 {
195 // We could look at the plane config and plane count to determine how many different textures
196 // to expect, but it's theoretically possible for an Image_YUVA to be constructed where the
197 // same TextureProxy is aliased to both the U and the V planes (and similarly for the Y and A)
198 // even when the plane config specifies that those channels are not packed into the same texture
199 //
200 // Given that it's simpler to just sum the total gpu memory of non-duplicate textures.
201 size_t size = 0;
202 for (int i = 0; i < SkYUVAInfo::kYUVAChannelCount; ++i) {
203 if (!fProxies[i]) {
204 continue; // Null channels (A) have no size.
205 }
206 bool repeat = false;
207 for (int j = 0; j < i - 1; ++j) {
208 if (fProxies[i].proxy() == fProxies[j].proxy()) {
209 repeat = true;
210 break;
211 }
212 }
213 if (!repeat) {
214 if (fProxies[i].proxy()->isInstantiated()) {
215 size += fProxies[i].proxy()->texture()->gpuMemorySize();
216 } else {
217 size += fProxies[i].proxy()->uninstantiatedGpuMemorySize();
218 }
219 }
220 }
221
222 return size;
223}
static unsigned repeat(SkFixed fx, int max)
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

◆ type()

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

Implements SkImage_Base.

Definition at line 39 of file Image_YUVA_Graphite.h.

◆ uvSubsampleFactors()

std::tuple< int, int > skgpu::graphite::Image_YUVA::uvSubsampleFactors ( ) const
inline

Definition at line 57 of file Image_YUVA_Graphite.h.

57{ return fUVSubsampleFactors; }

◆ WrapImages()

sk_sp< Image_YUVA > skgpu::graphite::Image_YUVA::WrapImages ( const Caps caps,
const SkYUVAInfo yuvaInfo,
SkSpan< const sk_sp< SkImage > >  images,
sk_sp< SkColorSpace imageColorSpace 
)
static

Definition at line 160 of file Image_YUVA_Graphite.cpp.

163 {
164 if (SkTo<int>(images.size()) < yuvaInfo.numPlanes()) {
165 return nullptr;
166 }
167
168 TextureProxyView planes[SkYUVAInfo::kMaxPlanes];
169 for (int i = 0; i < yuvaInfo.numPlanes(); ++i) {
170 planes[i] = AsView(images[i]);
171 if (!planes[i]) {
172 // A null image, or not graphite-backed, or not backed by a single texture.
173 return nullptr;
174 }
175 // The YUVA shader expects to sample from the red channel for single-channel textures, so
176 // reset the swizzle for alpha-only textures to compensate for that
177 if (images[i]->isAlphaOnly()) {
178 planes[i] = planes[i].makeSwizzle(Swizzle("aaaa"));
179 }
180 }
181
182 sk_sp<Image_YUVA> image = Make(caps, yuvaInfo, SkSpan(planes), std::move(imageColorSpace));
183 if (image) {
184 // Unlike the other factories, this YUVA image shares the texture proxies with each plane
185 // Image, so if those are linked to Devices, it must inherit those same links.
186 for (int plane = 0; plane < yuvaInfo.numPlanes(); ++plane) {
187 SkASSERT(as_IB(images[plane])->isGraphiteBacked());
188 image->linkDevices(static_cast<Image_Base*>(images[plane].get()));
189 }
190 }
191 return image;
192}
static SkImage_Base * as_IB(SkImage *image)
bool isGraphiteBacked() const
bool isAlphaOnly() const
Definition SkImage.cpp:239
Image_Base(const SkImageInfo &info, uint32_t uniqueID)
static sk_sp< Image_YUVA > Make(const Caps *caps, const SkYUVAInfo &yuvaInfo, SkSpan< TextureProxyView > planes, sk_sp< SkColorSpace > imageColorSpace)
sk_sp< SkImage > image
Definition examples.cpp:29
std::array< MockImage, 3 > images
const myers::Point & get(const myers::Segment &)
TextureProxyView AsView(const SkImage *image)

◆ yuvaInfo()

const SkYUVAInfo & skgpu::graphite::Image_YUVA::yuvaInfo ( ) const
inline

Definition at line 59 of file Image_YUVA_Graphite.h.

59{ return fYUVAInfo; }

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