Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SkImage_Picture Class Reference

#include <SkImage_Picture.h>

Inheritance diagram for SkImage_Picture:
SkImage_Lazy SkImage_Base SkImage SkRefCnt SkRefCntBase

Public Member Functions

 SkImage_Picture (Validator *validator)
 
SkImage_Base::Type type () const override
 
const SkSurfacePropsprops () const
 
void replay (SkCanvas *) const
 
bool getImageKeyValues (uint32_t keyValues[SkTiledImageUtils::kNumImageKeyValues]) const
 
- Public Member Functions inherited from SkImage_Lazy
 SkImage_Lazy (Validator *validator)
 
bool isValid (GrRecordingContext *) const override
 
bool onHasMipmaps () const override
 
bool onIsProtected () const override
 
bool onReadPixels (GrDirectContext *, const SkImageInfo &, void *, size_t, int srcX, int srcY, CachingHint) const override
 
sk_sp< SkDataonRefEncoded () const override
 
sk_sp< SkImageonMakeSubset (GrDirectContext *, const SkIRect &) const override
 
sk_sp< SkImageonMakeSubset (skgpu::graphite::Recorder *, const SkIRect &, RequiredProperties) const override
 
bool getROPixels (GrDirectContext *, SkBitmap *, CachingHint) const override
 
sk_sp< SkImageonMakeColorTypeAndColorSpace (SkColorType, sk_sp< SkColorSpace >, GrDirectContext *) const override
 
sk_sp< SkImageonReinterpretColorSpace (sk_sp< SkColorSpace >) const final
 
void addUniqueIDListener (sk_sp< SkIDChangeListener >) const
 
sk_sp< SkCachedDatagetPlanes (const SkYUVAPixmapInfo::SupportedDataTypes &supportedDataTypes, SkYUVAPixmaps *pixmaps) const
 
sk_sp< SharedGeneratorgenerator () const
 
- 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 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 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< SkImageMake (sk_sp< SkPicture > picture, const SkISize &dimensions, const SkMatrix *matrix, const SkPaint *paint, SkImages::BitDepth bitDepth, sk_sp< SkColorSpace > colorSpace, SkSurfaceProps props)
 

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_Lazy
virtual bool readPixelsProxy (GrDirectContext *, const SkPixmap &) const
 
- Protected Member Functions inherited from SkImage_Base
 SkImage_Base (const SkImageInfo &info, uint32_t uniqueID)
 

Detailed Description

Definition at line 28 of file SkImage_Picture.h.

Constructor & Destructor Documentation

◆ SkImage_Picture()

SkImage_Picture::SkImage_Picture ( Validator validator)
inline

Definition at line 35 of file SkImage_Picture.h.

35: SkImage_Lazy(validator) {}

Member Function Documentation

◆ getImageKeyValues()

bool SkImage_Picture::getImageKeyValues ( uint32_t  keyValues[SkTiledImageUtils::kNumImageKeyValues]) const

Definition at line 64 of file SkImage_Picture.cpp.

65 {
66
67 auto sharedGenerator = this->generator();
68 SkAutoMutexExclusive mutex(sharedGenerator->fMutex);
69
70 auto pictureIG = static_cast<SkPictureImageGenerator*>(sharedGenerator->fGenerator.get());
71 if (pictureIG->fPaint.getMaybeNull()) {
72 // A full paint complicates the potential key too much.
73 return false;
74 }
75
76 const SkImageInfo& ii = sharedGenerator->getInfo();
77 if (!ii.colorSpace()->isSRGB()) {
78 // We only return key values if the colorSpace is sRGB.
79 return false;
80 }
81
82 const SkMatrix& m = pictureIG->fMatrix;
83 if (!m.isIdentity() && !m.isTranslate()) {
84 // To keep the key small we only cache simple (<= translation) matrices
85 return false;
86 }
87
88 bool isU8 = ii.colorType() != kRGBA_F16_SkColorType;
89 uint32_t pixelGeometry = this->props()->pixelGeometry();
90 uint32_t surfacePropFlags = this->props()->flags();
91 int width = ii.width();
92 int height = ii.height();
93 float transX = m.getTranslateX();
94 float transY = m.getTranslateY();
95
96 SkASSERT(pixelGeometry <= 4);
97 SkASSERT(surfacePropFlags < 8);
98 SkASSERT(SkTFitsIn<uint32_t>(width));
99 SkASSERT(SkTFitsIn<uint32_t>(height));
100 SkASSERT(sizeof(float) == sizeof(uint32_t));
101
102 // The 0th slot usually holds either the SkBitmap's ID or the image's. In those two cases
103 // slot #1 is zero so we can reuse the 0th slot here.
104 keyValues[0] = (isU8 ? 0x1 : 0x0) | // 1 bit
105 (pixelGeometry << 1) | // 3 bits
106 (surfacePropFlags << 4); // 3 bits
107 keyValues[1] = pictureIG->fPicture->uniqueID();
108 SkASSERT(keyValues[1] != 0); // Double check we don't collide w/ bitmap or image keys
109 keyValues[2] = width;
110 keyValues[3] = height;
111 memcpy(&keyValues[4], &transX, sizeof(uint32_t));
112 memcpy(&keyValues[5], &transY, sizeof(uint32_t));
113 return true;
114}
#define SkASSERT(cond)
Definition SkAssert.h:116
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition SkColorType.h:38
bool isSRGB() const
sk_sp< SharedGenerator > generator() const
const SkSurfaceProps * props() const
int width() const
Definition SkImage.h:285
int height() const
Definition SkImage.h:291
uint32_t flags() const
SkPixelGeometry pixelGeometry() const
SkColorSpace * colorSpace() const
int width() const
SkColorType colorType() const
int height() const

◆ Make()

sk_sp< SkImage > SkImage_Picture::Make ( sk_sp< SkPicture picture,
const SkISize dimensions,
const SkMatrix matrix,
const SkPaint paint,
SkImages::BitDepth  bitDepth,
sk_sp< SkColorSpace colorSpace,
SkSurfaceProps  props 
)
static

Definition at line 35 of file SkImage_Picture.cpp.

38 {
39 auto gen = SkImageGenerators::MakeFromPicture(dimensions, std::move(picture), matrix, paint,
40 bitDepth, std::move(colorSpace), props);
41
43 SharedGenerator::Make(std::move(gen)), nullptr, nullptr);
44
45 return validator ? sk_make_sp<SkImage_Picture>(&validator) : nullptr;
46}
static sk_sp< SharedGenerator > Make(std::unique_ptr< SkImageGenerator > gen)
SkColorSpace * colorSpace() const
Definition SkImage.cpp:156
SkISize dimensions() const
Definition SkImage.h:297
const Paint & paint
std::unique_ptr< SkImageGenerator > MakeFromPicture(const SkISize &, sk_sp< SkPicture >, const SkMatrix *, const SkPaint *, SkImages::BitDepth, sk_sp< SkColorSpace >, SkSurfaceProps props)
Definition gen.py:1

◆ props()

const SkSurfaceProps * SkImage_Picture::props ( ) const

Definition at line 48 of file SkImage_Picture.cpp.

48 {
49 auto pictureIG = static_cast<SkPictureImageGenerator*>(this->generator()->fGenerator.get());
50 return &pictureIG->fProps;
51}
std::unique_ptr< SkImageGenerator > fGenerator

◆ replay()

void SkImage_Picture::replay ( SkCanvas canvas) const

Definition at line 53 of file SkImage_Picture.cpp.

53 {
54 auto sharedGenerator = this->generator();
55 SkAutoMutexExclusive mutex(sharedGenerator->fMutex);
56
57 auto pictureIG = static_cast<SkPictureImageGenerator*>(sharedGenerator->fGenerator.get());
59 canvas->drawPicture(pictureIG->fPicture,
60 &pictureIG->fMatrix,
61 pictureIG->fPaint.getMaybeNull());
62}
void clear(SkColor color)
Definition SkCanvas.h:1199
void drawPicture(const SkPicture *picture)
Definition SkCanvas.h:1961
constexpr SkColor4f kTransparent
Definition SkColor.h:434

◆ type()

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

Reimplemented from SkImage_Lazy.

Definition at line 37 of file SkImage_Picture.h.


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