8 #ifndef SkImage_DEFINED
9 #define SkImage_DEFINED
16 #include "include/private/base/SkAPI.h"
107 std::optional<SkAlphaType> alphaType = std::nullopt);
283 int width()
const {
return fInfo.width(); }
289 int height()
const {
return fInfo.height(); }
379 const SkMatrix* localMatrix =
nullptr)
const;
385 const SkMatrix* lm =
nullptr)
const;
401 const SkMatrix* localMatrix =
nullptr)
const;
407 const SkMatrix* lm =
nullptr)
const;
504 CachingHint cachingHint = kAllow_CachingHint)
const;
541 CachingHint cachingHint = kAllow_CachingHint)
const;
543 #ifndef SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API
546 int srcX,
int srcY,
CachingHint cachingHint = kAllow_CachingHint)
const;
548 CachingHint cachingHint = kAllow_CachingHint)
const;
561 virtual const void*
data(
int i)
const = 0;
693 CachingHint cachingHint = kAllow_CachingHint)
const;
806 CachingHint cachingHint = kDisallow_CachingHint)
const;
808 #if !defined(SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API)
810 return this->makeRasterImage(
nullptr, cachingHint);
927 friend class SkImage_Base;
928 friend class SkImage_Raster;
929 friend class SkMipmapBuilder;
932 const uint32_t fUniqueID;
static bool SkAlphaTypeIsOpaque(SkAlphaType at)
Returns true if SkAlphaType equals kOpaque_SkAlphaType.
Definition: SkAlphaType.h:41
SkAlphaType
Describes how to interpret the alpha component of a pixel.
Definition: SkAlphaType.h:26
SkColorType
Describes how pixel bits encode color.
Definition: SkColorType.h:19
SkYUVColorSpace
Definition: SkImageInfo.h:68
SkTextureCompressionType
Definition: SkTextureCompressionType.h:20
SkTileMode
Definition: SkTileMode.h:13
Definition: GrDirectContext.h:62
Definition: GrRecordingContext.h:42
SkBitmap describes a two-dimensional raster pixel array.
Definition: SkBitmap.h:59
Definition: SkColorSpace.h:107
SkData holds an immutable data buffer.
Definition: SkData.h:25
Base class for image filters.
Definition: SkImageFilter.h:35
Definition: SkImageGenerator.h:28
The result from asyncRescaleAndReadPixels() or asyncRescaleAndReadPixelsYUV420().
Definition: SkImage.h:552
AsyncReadResult(const AsyncReadResult &)=delete
AsyncReadResult & operator=(const AsyncReadResult &)=delete
virtual ~AsyncReadResult()=default
virtual size_t rowBytes(int i) const =0
virtual int count() const =0
AsyncReadResult(AsyncReadResult &&)=delete
virtual const void * data(int i) const =0
AsyncReadResult & operator=(AsyncReadResult &&)=delete
AsyncReadResult()=default
SkImage describes a two dimensional array of pixels to draw.
Definition: SkImage.h:270
bool readPixels(GrDirectContext *context, const SkPixmap &dst, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
Copies a SkRect of pixels from SkImage to dst.
bool isAlphaOnly() const
Returns true if SkImage pixels represent transparency only.
const SkImageInfo & imageInfo() const
Returns a SkImageInfo describing the width, height, color type, alpha type, and color space of the Sk...
Definition: SkImage.h:277
sk_sp< SkColorSpace > refColorSpace() const
Returns a smart pointer to SkColorSpace, the range of colors, associated with SkImage.
void asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, sk_sp< SkColorSpace > dstColorSpace, const SkIRect &srcRect, const SkISize &dstSize, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context) const
Similar to asyncRescaleAndReadPixels but performs an additional conversion to YUV.
void asyncRescaleAndReadPixelsYUVA420(SkYUVColorSpace yuvColorSpace, sk_sp< SkColorSpace > dstColorSpace, const SkIRect &srcRect, const SkISize &dstSize, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context) const
Identical to asyncRescaleAndReadPixelsYUV420 but a fourth plane is returned in the AsyncReadResult pa...
sk_sp< SkImage > reinterpretColorSpace(sk_sp< SkColorSpace > newColorSpace) const
Creates a new SkImage identical to this one, but with a different SkColorSpace.
SkISize dimensions() const
Returns SkISize { width(), height() }.
Definition: SkImage.h:295
sk_sp< SkShader > makeShader(const SkSamplingOptions &sampling, const SkMatrix *lm=nullptr) const
virtual sk_sp< SkImage > makeColorSpace(GrDirectContext *direct, sk_sp< SkColorSpace > target) const =0
Creates SkImage in target SkColorSpace.
bool readPixels(GrDirectContext *context, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
Copies SkRect of pixels from SkImage to dstPixels.
uint32_t uniqueID() const
Returns value unique to image.
Definition: SkImage.h:309
void * ReadPixelsContext
Client-provided context that is passed to client-provided ReadPixelsContext.
Definition: SkImage.h:569
SkAlphaType alphaType() const
Returns SkAlphaType.
virtual bool isLazyGenerated() const =0
Returns true if SkImage is backed by an image-generator or other service that creates and caches its ...
bool readPixels(const SkPixmap &dst, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
RescaleMode
Definition: SkImage.h:578
virtual sk_sp< SkImage > makeSubset(GrDirectContext *direct, const SkIRect &subset) const =0
Returns subset of this image.
sk_sp< SkImage > makeNonTextureImage(GrDirectContext *=nullptr) const
Returns raster image or lazy image.
sk_sp< SkShader > makeRawShader(const SkSamplingOptions &sampling, const SkMatrix &lm) const
Defaults to clamp in both X and Y.
bool peekPixels(SkPixmap *pixmap) const
Copies SkImage pixel address, row bytes, and SkImageInfo to pixmap, if address is available,...
int width() const
Returns pixel count in each row.
Definition: SkImage.h:283
RescaleGamma
Definition: SkImage.h:576
virtual sk_sp< SkImage > makeColorTypeAndColorSpace(skgpu::graphite::Recorder *, SkColorType targetColorType, sk_sp< SkColorSpace > targetColorSpace, RequiredProperties) const =0
Experimental.
sk_sp< SkImage > withDefaultMipmaps() const
Returns an image with the same "base" pixels as the this image, but with mipmap levels automatically ...
sk_sp< SkShader > makeRawShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &sampling, const SkMatrix &lm) const
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Make a shader with the specified tiling and mipmap sampling.
sk_sp< SkShader > makeRawShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
makeRawShader functions like makeShader, but for images that contain non-color data.
sk_sp< SkImage > makeRasterImage(CachingHint cachingHint=kDisallow_CachingHint) const
Definition: SkImage.h:809
virtual sk_sp< SkImage > makeSubset(skgpu::graphite::Recorder *, const SkIRect &subset, RequiredProperties) const =0
Returns subset of this image.
virtual sk_sp< SkImage > makeColorSpace(skgpu::graphite::Recorder *, sk_sp< SkColorSpace > targetColorSpace, RequiredProperties) const =0
Creates SkImage in target SkColorSpace.
SkColorType colorType() const
Returns SkColorType if known; otherwise, returns kUnknown_SkColorType.
virtual bool isValid(GrRecordingContext *context) const =0
Returns true if SkImage can be drawn on either raster surface or GPU surface.
void asyncRescaleAndReadPixels(const SkImageInfo &info, const SkIRect &srcRect, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context) const
Makes image pixel data available to caller, possibly asynchronously.
SkColorSpace * colorSpace() const
Returns SkColorSpace, the range of colors, associated with SkImage.
bool isOpaque() const
Returns true if pixels ignore their alpha value and are treated as fully opaque.
Definition: SkImage.h:373
virtual bool isTextureBacked() const =0
Returns true if the contents of SkImage was created on or uploaded to GPU memory, and is available as...
virtual size_t textureSize() const =0
Returns an approximation of the amount of texture memory used by the image.
int height() const
Returns pixel row count.
Definition: SkImage.h:289
SkIRect bounds() const
Returns SkIRect { 0, 0, width(), height() }.
Definition: SkImage.h:301
virtual sk_sp< SkImage > makeColorTypeAndColorSpace(GrDirectContext *direct, SkColorType targetColorType, sk_sp< SkColorSpace > targetCS) const =0
Experimental.
sk_sp< SkData > refEncodedData() const
Returns encoded SkImage pixels as SkData, if SkImage was created from supported encoded stream format...
CachingHint
Definition: SkImage.h:461
@ kDisallow_CachingHint
disallows internally caching decoded and copied pixels
Definition: SkImage.h:463
@ kAllow_CachingHint
allows internally caching decoded and copied pixels
Definition: SkImage.h:462
bool isProtected() const
Returns true if the image holds protected content.
sk_sp< SkImage > makeRasterImage(GrDirectContext *, CachingHint cachingHint=kDisallow_CachingHint) const
Returns raster image.
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &sampling, const SkMatrix &lm) const
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
Deprecated.
bool hasMipmaps() const
Returns true if the image has mipmap levels.
sk_sp< SkShader > makeRawShader(const SkSamplingOptions &sampling, const SkMatrix *lm=nullptr) const
void(ReadPixelsContext, std::unique_ptr< const AsyncReadResult >) ReadPixelsCallback
Client-provided callback to asyncRescaleAndReadPixels() or asyncRescaleAndReadPixelsYUV420() that is ...
Definition: SkImage.h:574
bool scalePixels(const SkPixmap &dst, const SkSamplingOptions &, CachingHint cachingHint=kAllow_CachingHint) const
Copies SkImage to dst, scaling pixels to fit dst.width() and dst.height(), and converting pixels to m...
bool asLegacyBitmap(SkBitmap *bitmap, LegacyBitmapMode legacyBitmapMode=kRO_LegacyBitmapMode) const
Deprecated.
sk_sp< SkShader > makeShader(const SkSamplingOptions &sampling, const SkMatrix &lm) const
Defaults to clamp in both X and Y.
LegacyBitmapMode
Deprecated.
Definition: SkImage.h:816
@ kRO_LegacyBitmapMode
returned bitmap is read-only and immutable
Definition: SkImage.h:817
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
SkPaint controls options applied when drawing.
Definition: SkPaint.h:44
SkPicture records drawing commands made to SkCanvas.
Definition: SkPicture.h:44
SkPixmap provides a utility to pair SkImageInfo with pixels and row bytes.
Definition: SkPixmap.h:40
Definition: SkRefCnt.h:119
Shaders specify the source color(s) for what is being drawn.
Definition: SkShader.h:35
Describes properties and constraints of a given SkSurface.
Definition: SkSurfaceProps.h:52
SK_API sk_sp< SkImage > RasterFromData(const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes)
Creates CPU-backed SkImage from pixel data described by info.
SK_API sk_sp< SkImage > RasterFromCompressedTextureData(sk_sp< SkData > data, int width, int height, SkTextureCompressionType type)
Creates a CPU-backed SkImage from compressed data.
SK_API sk_sp< SkImage > DeferredFromPicture(sk_sp< SkPicture > picture, const SkISize &dimensions, const SkMatrix *matrix, const SkPaint *paint, BitDepth bitDepth, sk_sp< SkColorSpace > colorSpace, SkSurfaceProps props)
Creates SkImage from picture.
void * ReleaseContext
Caller data passed to RasterReleaseProc; may be nullptr.
Definition: SkImage.h:50
BitDepth
Definition: SkImage.h:123
@ kF16
uses 16-bit float per color component
@ kU8
uses 8-bit unsigned int per color component
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
Creates CPU-backed SkImage from pixmap, sharing SkPixmap pixels.
SK_API sk_sp< SkImage > MakeWithFilter(sk_sp< SkImage > src, const SkImageFilter *filter, const SkIRect &subset, const SkIRect &clipBounds, SkIRect *outSubset, SkIPoint *offset)
Creates a filtered SkImage on the CPU.
void(const void *pixels, ReleaseContext) RasterReleaseProc
Function called when SkImage no longer shares pixels.
Definition: SkImage.h:54
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
Return a SkImage using the encoded data, but attempts to defer decoding until the image is actually u...
SK_API sk_sp< SkImage > RasterFromPixmapCopy(const SkPixmap &pixmap)
Creates a CPU-backed SkImage from pixmap, copying the pixel data.
SK_API sk_sp< SkImage > RasterFromBitmap(const SkBitmap &bitmap)
Creates a CPU-backed SkImage from bitmap, sharing or copying bitmap pixels.
SK_API sk_sp< SkImage > DeferredFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
Creates SkImage from data returned by imageGenerator.
Definition: SkCanvas.h:73
SkIRect holds four 32-bit integer coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:32
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Returns constructed SkIRect set to (0, 0, w, h).
Definition: SkRect.h:56
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:19
Describes pixel dimensions and encoding.
Definition: SkImageInfo.h:194
Definition: SkImage.h:728
bool operator!=(const RequiredProperties &other) const
Definition: SkImage.h:735
bool operator==(const RequiredProperties &other) const
Definition: SkImage.h:731
bool fMipmapped
Definition: SkImage.h:729
bool operator<(const RequiredProperties &other) const
Definition: SkImage.h:737
Definition: SkSamplingOptions.h:58