8 #ifndef SkImage_DEFINED
9 #define SkImage_DEFINED
22 #if defined(SK_GRAPHITE_ENABLED)
23 #include "include/gpu/graphite/GraphiteTypes.h"
30 #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
31 #include <android/hardware_buffer.h>
50 class SkPromiseImageTexture;
56 #if defined(SK_GRAPHITE_ENABLED)
61 enum class Volatile : bool;
148 RasterReleaseProc rasterReleaseProc,
205 std::optional<SkAlphaType> alphaType = std::nullopt);
224 kLast = kBC1_RGBA8_UNORM,
227 static constexpr
int kCompressionTypeCount =
static_cast<int>(CompressionType::kLast) + 1;
229 static const CompressionType kETC1_CompressionType = CompressionType::kETC2_RGB8_UNORM;
243 int width,
int height,
292 int width,
int height,
293 CompressionType type,
299 typedef void (*TextureReleaseProc)(ReleaseContext releaseContext);
330 TextureReleaseProc textureReleaseProc =
nullptr,
331 ReleaseContext releaseContext =
nullptr);
365 TextureReleaseProc textureReleaseProc =
nullptr,
366 ReleaseContext releaseContext =
nullptr);
394 bool limitToMaxTextureSize =
false);
443 TextureReleaseProc textureReleaseProc =
nullptr,
444 ReleaseContext releaseContext =
nullptr);
472 bool limitToMaxTextureSize =
false,
475 using PromiseImageTextureContext =
void*;
476 using PromiseImageTextureFulfillProc =
478 using PromiseImageTextureReleaseProc = void (*)(PromiseImageTextureContext);
519 PromiseImageTextureFulfillProc textureFulfillProc,
520 PromiseImageTextureReleaseProc textureReleaseProc,
521 PromiseImageTextureContext textureContext);
548 PromiseImageTextureFulfillProc textureFulfillProc,
549 PromiseImageTextureReleaseProc textureReleaseProc,
550 PromiseImageTextureContext textureContexts[]);
554 #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
566 AHardwareBuffer* hardwareBuffer,
585 AHardwareBuffer* hardwareBuffer,
600 int width()
const {
return fInfo.width(); }
606 int height()
const {
return fInfo.height(); }
696 const SkMatrix* localMatrix =
nullptr)
const;
700 return this->makeShader(tmx, tmy, sampling, &lm);
706 const SkMatrix* lm =
nullptr)
const {
724 const SkMatrix* localMatrix =
nullptr)
const;
728 return this->makeRawShader(tmx, tmy, sampling, &lm);
734 const SkMatrix* lm =
nullptr)
const {
794 void flush(
GrDirectContext* context)
const { this->flush(context, {}); }
871 CachingHint cachingHint = kAllow_CachingHint)
const;
908 CachingHint cachingHint = kAllow_CachingHint)
const;
910 #ifndef SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API
913 int srcX,
int srcY,
CachingHint cachingHint = kAllow_CachingHint)
const;
915 CachingHint cachingHint = kAllow_CachingHint)
const;
928 virtual const void*
data(
int i)
const = 0;
1046 CachingHint cachingHint = kAllow_CachingHint)
const;
1155 #ifdef SK_GRAPHITE_ENABLED
1158 using GraphitePromiseImageContext =
void*;
1160 using GraphitePromiseTextureReleaseContext =
void*;
1162 using GraphitePromiseImageFulfillProc =
1163 std::tuple<skgpu::graphite::BackendTexture, GraphitePromiseTextureReleaseContext>
1164 (*)(GraphitePromiseImageContext);
1165 using GraphitePromiseImageReleaseProc = void (*)(GraphitePromiseImageContext);
1166 using GraphitePromiseTextureReleaseProc = void (*)(GraphitePromiseTextureReleaseContext);
1214 static sk_sp<SkImage> MakeGraphitePromiseTexture(skgpu::graphite::Recorder*,
1216 const skgpu::graphite::TextureInfo&,
1218 skgpu::graphite::Volatile,
1219 GraphitePromiseImageFulfillProc,
1220 GraphitePromiseImageReleaseProc,
1221 GraphitePromiseTextureReleaseProc,
1222 GraphitePromiseImageContext);
1240 static sk_sp<SkImage> MakeGraphiteFromBackendTexture(skgpu::graphite::Recorder*,
1241 const skgpu::graphite::BackendTexture&,
1246 struct RequiredImageProperties {
1247 skgpu::graphite::Mipmapped fMipmapped;
1272 RequiredImageProperties = {})
const;
1292 skgpu::graphite::Recorder*,
1293 RequiredImageProperties = {})
const;
1311 skgpu::graphite::Recorder*,
1312 RequiredImageProperties = {})
const;
1331 skgpu::graphite::Recorder*,
1332 RequiredImageProperties = {})
const;
1500 friend class SkImage_Base;
1501 friend class SkImage_Raster;
1502 friend class SkMipmapBuilder;
1505 const uint32_t fUniqueID;
GrProtected
Definition: GrTypes.h:142
GrSurfaceOrigin
GPU SkImage and SkSurfaces can be stored such that (0, 0) in texture space may correspond to either t...
Definition: GrTypes.h:153
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:154
GrSemaphoresSubmitted
Enum used as return value when flush with semaphores so the client knows whether the valid semaphores...
Definition: GrTypes.h:238
GrMipmapped
Used to say whether a texture has mip levels allocated or not.
Definition: GrTypes.h:124
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
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
SkColorType
Describes how pixel bits encode color.
Definition: SkColorType.h:19
@ kNone
glyph outlines unchanged
SkYUVColorSpace
Definition: SkImageInfo.h:66
SkTileMode
Definition: SkTileMode.h:13
@ kClamp
Replicate the edge color if the shader draws outside of its original bounds.
Definition: GrBackendSurface.h:69
Definition: GrContextThreadSafeProxy.h:164
Definition: GrDirectContext.h:54
Definition: GrRecordingContext.h:45
A description of a set GrBackendTextures that hold the planar data described by a SkYUVAInfo.
Definition: GrYUVABackendTextures.h:19
A set of GrBackendTextures that hold the planar data for an image described a SkYUVAInfo.
Definition: GrYUVABackendTextures.h:82
SkBitmap describes a two-dimensional raster pixel array.
Definition: SkBitmap.h:51
SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed.
Definition: SkCanvas.h:102
Describes pixel and encoding.
Definition: SkImageInfo.h:95
Definition: SkColorSpace.h:107
SkData holds an immutable data buffer.
Definition: SkData.h:22
Base class for image filters.
Definition: SkImageFilter.h:30
Definition: SkImageGenerator.h:39
The result from asyncRescaleAndReadPixels() or asyncRescaleAndReadPixelsYUV420().
Definition: SkImage.h:919
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:81
sk_sp< SkImage > makeSubset(const SkIRect &subset, GrDirectContext *direct=nullptr) const
Returns subset of this image.
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.
sk_sp< SkImage > makeColorSpace(sk_sp< SkColorSpace > target, GrDirectContext *direct=nullptr) const
Creates SkImage in target SkColorSpace.
void * ReleaseContext
Caller data passed to RasterReleaseProc; may be nullptr.
Definition: SkImage.h:86
const SkImageInfo & imageInfo() const
Returns a SkImageInfo describing the width, height, color type, alpha type, and color space of the Sk...
Definition: SkImage.h:594
sk_sp< SkImage > makeNonTextureImage() const
Returns raster image or lazy image.
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.
BitDepth
Definition: SkImage.h:246
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:612
static sk_sp< SkImage > MakeFromEncoded(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
Return an image backed by the encoded data, but attempt to defer decoding until the image is actually...
sk_sp< SkShader > makeShader(const SkSamplingOptions &sampling, const SkMatrix *lm=nullptr) const
Definition: SkImage.h:705
static sk_sp< SkImage > MakeFromBitmap(const SkBitmap &bitmap)
Creates SkImage from bitmap, sharing or copying bitmap pixels.
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:626
void * ReadPixelsContext
Client-provided context that is passed to client-provided ReadPixelsContext.
Definition: SkImage.h:936
static sk_sp< SkImage > MakeFromRaster(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
Creates SkImage from pixmap, sharing SkPixmap pixels.
SkAlphaType alphaType() const
Returns SkAlphaType.
bool isLazyGenerated() const
Returns true if SkImage is backed by an image-generator or other service that creates and caches its ...
std::function< void(GrBackendTexture)> BackendTextureReleaseProc
Defines a callback function, taking one parameter of type GrBackendTexture with no return value.
Definition: SkImage.h:1395
bool readPixels(const SkPixmap &dst, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
RescaleMode
Definition: SkImage.h:945
sk_sp< SkData > encodeToData(SkEncodedImageFormat encodedImageFormat, int quality) const
Encodes SkImage pixels, returning result as SkData.
bool isTextureBacked() const
Returns true if the contents of SkImage was created on or uploaded to GPU memory, and is available as...
sk_sp< SkShader > makeRawShader(const SkSamplingOptions &sampling, const SkMatrix &lm) const
Definition: SkImage.h:730
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:600
RescaleGamma
Definition: SkImage.h:943
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
Definition: SkImage.h:726
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< SkImage > makeColorTypeAndColorSpace(SkColorType targetColorType, sk_sp< SkColorSpace > targetColorSpace, GrDirectContext *direct=nullptr) const
Experimental.
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
Returns raster image.
static sk_sp< SkImage > MakeRasterData(const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes)
Creates SkImage from SkImageInfo, sharing pixels.
size_t textureSize() const
Returns an approximation of the amount of texture memory used by the image.
CompressionType
Definition: SkImage.h:218
SkColorType colorType() const
Returns SkColorType if known; otherwise, returns kUnknown_SkColorType.
bool isValid(GrRecordingContext *context) const
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.
static sk_sp< SkImage > MakeFromPicture(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.
sk_sp< SkImage > makeWithFilter(GrRecordingContext *context, const SkImageFilter *filter, const SkIRect &subset, const SkIRect &clipBounds, SkIRect *outSubset, SkIPoint *offset) const
Creates filtered SkImage.
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:690
static sk_sp< SkImage > MakeFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
Creates SkImage from data returned by imageGenerator.
int height() const
Returns pixel row count.
Definition: SkImage.h:606
SkIRect bounds() const
Returns SkIRect { 0, 0, width(), height() }.
Definition: SkImage.h:618
sk_sp< SkData > refEncodedData() const
Returns encoded SkImage pixels as SkData, if SkImage was created from supported encoded stream format...
static sk_sp< SkImage > MakeRasterCopy(const SkPixmap &pixmap)
Creates SkImage from SkPixmap and copy of pixels.
CachingHint
Definition: SkImage.h:828
@ kDisallow_CachingHint
disallows internally caching decoded and copied pixels
Definition: SkImage.h:830
@ kAllow_CachingHint
allows internally caching decoded and copied pixels
Definition: SkImage.h:829
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &sampling, const SkMatrix &lm) const
Definition: SkImage.h:698
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
Definition: SkImage.h:733
static sk_sp< SkImage > MakeRasterFromCompressed(sk_sp< SkData > data, int width, int height, CompressionType type)
Creates a CPU-backed SkImage from compressed data.
void(ReadPixelsContext, std::unique_ptr< const AsyncReadResult >) ReadPixelsCallback
Client-provided callback to asyncRescaleAndReadPixels() or asyncRescaleAndReadPixelsYUV420() that is ...
Definition: SkImage.h:941
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...
sk_sp< SkData > encodeToData() const
Encodes SkImage pixels, returning result as SkData.
bool asLegacyBitmap(SkBitmap *bitmap, LegacyBitmapMode legacyBitmapMode=kRO_LegacyBitmapMode) const
Deprecated.
sk_sp< SkShader > makeShader(const SkSamplingOptions &sampling, const SkMatrix &lm) const
Definition: SkImage.h:702
LegacyBitmapMode
Deprecated.
Definition: SkImage.h:1426
@ kRO_LegacyBitmapMode
returned bitmap is read-only and immutable
Definition: SkImage.h:1427
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:39
SkPixmap provides a utility to pair SkImageInfo with pixels and row bytes.
Definition: SkPixmap.h:31
Definition: SkRefCnt.h:118
Describes properties and constraints of a given SkSurface.
Definition: SkSurfaceProps.h:52
SkSurface is responsible for managing the pixels that a canvas draws into.
Definition: SkSurface.h:60
Helper to store SkPixmap planes as described by a SkYUVAPixmapInfo.
Definition: SkYUVAPixmaps.h:171
Definition: SkCanvas.h:71
Budgeted
Indicates whether an allocation should count against a cache budget.
Definition: GpuTypes.h:30
Struct to supply options to flush calls.
Definition: GrTypes.h:225
Definition: SkSamplingOptions.h:50
SkIPoint holds two 32-bit integer coordinates.
Definition: SkPoint.h:27
SkIRect holds four 32-bit integer coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:31
static constexpr SkIRect SK_WARN_UNUSED_RESULT MakeWH(int32_t w, int32_t h)
Returns constructed SkIRect set to (0, 0, w, h).
Definition: SkRect.h:55
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:19
Describes pixel dimensions and encoding.
Definition: SkImageInfo.h:192
Definition: SkSamplingOptions.h:58