 |
Skia
2D Graphics Library
|
Go to the documentation of this file.
8 #ifndef SkImage_DEFINED
9 #define SkImage_DEFINED
22 #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
23 #include <android/hardware_buffer.h>
125 RasterReleaseProc rasterReleaseProc,
200 kLast = kBC1_RGBA8_UNORM,
203 static constexpr
int kCompressionTypeCount =
static_cast<int>(CompressionType::kLast) + 1;
205 static const CompressionType kETC1_CompressionType = CompressionType::kETC2_RGB8_UNORM;
227 int width,
int height,
244 int width,
int height,
280 TextureReleaseProc textureReleaseProc =
nullptr,
315 TextureReleaseProc textureReleaseProc =
nullptr,
346 bool limitToMaxTextureSize =
false);
386 TextureReleaseProc textureReleaseProc =
nullptr,
415 bool limitToMaxTextureSize =
false,
442 #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
454 AHardwareBuffer* hardwareBuffer,
473 AHardwareBuffer* hardwareBuffer,
488 int width()
const {
return fInfo.width(); }
494 int height()
const {
return fInfo.height(); }
584 const SkMatrix* localMatrix =
nullptr)
const;
588 return this->makeShader(tmx, tmy, sampling, &lm);
594 const SkMatrix* lm =
nullptr)
const {
600 #ifdef SK_SUPPORT_LEGACY_IMPLICIT_FILTERQUALITY
614 const SkMatrix* localMatrix =
nullptr)
const;
616 return this->makeShader(tmx, tmy, &localMatrix);
758 CachingHint cachingHint = kAllow_CachingHint)
const;
795 CachingHint cachingHint = kAllow_CachingHint)
const;
797 #ifndef SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API
800 int srcX,
int srcY,
CachingHint cachingHint = kAllow_CachingHint)
const;
802 CachingHint cachingHint = kAllow_CachingHint)
const;
815 virtual const void*
data(
int i)
const = 0;
932 CachingHint cachingHint = kAllow_CachingHint)
const;
1201 friend class SkImage_Base;
1202 friend class SkMipmapBuilder;
1205 const uint32_t fUniqueID;
@ kClamp
Replicate the edge color if the shader draws outside of its original bounds.
Definition: GrRecordingContext.h:34
SkIRect bounds() const
Returns SkIRect { 0, 0, width(), height() }.
Definition: SkImage.h:506
sk_sp< SkImage > makeRasterImage(CachingHint cachingHint=kDisallow_CachingHint) const
Returns raster 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.
Helper to store SkPixmap planes as described by a SkYUVAPixmapInfo.
Definition: SkYUVAPixmaps.h:171
Definition: SkImageGenerator.h:28
GrSemaphoresSubmitted
Enum used as return value when flush with semaphores so the client knows whether the valid semaphores...
Definition: GrTypes.h:284
Definition: SkRefCnt.h:118
static sk_sp< SkImage > MakeFromYUVATextures(GrRecordingContext *context, const GrYUVABackendTextures &yuvaTextures, sk_sp< SkColorSpace > imageColorSpace=nullptr, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
Creates an SkImage from YUV[A] planar textures.
bool isValid(GrRecordingContext *context) const
Returns true if SkImage can be drawn on either raster surface or GPU surface.
Definition: SkSurface.h:46
sk_sp< SkData > refEncodedData() const
Returns encoded SkImage pixels as SkData, if SkImage was created from supported encoded stream format...
sk_sp< SkImage > makeColorTypeAndColorSpace(SkColorType targetColorType, sk_sp< SkColorSpace > targetColorSpace, GrDirectContext *direct=nullptr) const
Experimental.
sk_sp< SkImage > makeNonTextureImage() const
Returns raster image or lazy image.
SkYUVColorSpace
Definition: SkImageInfo.h:148
SkColorType colorType() const
Returns SkColorType if known; otherwise, returns kUnknown_SkColorType.
AsyncReadResult & operator=(const AsyncReadResult &)=delete
bool isLazyGenerated() const
Returns true if SkImage is backed by an image-generator or other service that creates and caches its ...
void * ReleaseContext
Caller data passed to RasterReleaseProc; may be nullptr.
Definition: SkImage.h:63
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:199
@ kAllow_CachingHint
allows internally caching decoded and copied pixels
Definition: SkImage.h:716
GrSurfaceOrigin
GPU SkImage and SkSurfaces can be stored such that (0, 0) in texture space may correspond to either t...
Definition: GrTypes.h:198
Definition: SkSamplingOptions.h:46
static sk_sp< SkImage > MakeFromAdoptedTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin textureOrigin, SkColorType colorType, SkAlphaType alphaType=kPremul_SkAlphaType, sk_sp< SkColorSpace > colorSpace=nullptr)
Creates SkImage from backendTexture associated with context.
GrProtected
Definition: GrTypes.h:187
static sk_sp< SkImage > MakeFromPicture(sk_sp< SkPicture > picture, const SkISize &dimensions, const SkMatrix *matrix, const SkPaint *paint, BitDepth bitDepth, sk_sp< SkColorSpace > colorSpace)
Creates SkImage from picture.
static sk_sp< SkImage > MakeRasterData(const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes)
Creates SkImage from SkImageInfo, sharing pixels.
CachingHint
Definition: SkImage.h:715
std::function< void(GrBackendTexture)> BackendTextureReleaseProc
Defines a callback function, taking one parameter of type GrBackendTexture with no return value.
Definition: SkImage.h:1097
@ kNone
glyph outlines unchanged
sk_sp< SkShader > makeShader(const SkSamplingOptions &sampling, const SkMatrix *lm=nullptr) const
Definition: SkImage.h:593
bool isTextureBacked() const
Returns true the contents of SkImage was created on or uploaded to GPU memory, and is available as a ...
virtual ~AsyncReadResult()=default
RescaleMode
Definition: SkImage.h:832
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...
void * ReadPixelsContext
Client-provided context that is passed to client-provided ReadPixelsContext.
Definition: SkImage.h:823
sk_sp< SkShader > makeShader(const SkSamplingOptions &sampling, const SkMatrix &lm) const
Definition: SkImage.h:590
SkData holds an immutable data buffer.
Definition: SkData.h:22
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.
static sk_sp< SkImage > MakeFromCompressedTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
Creates an SkImage from a GPU backend texture.
sk_sp< SkColorSpace > refColorSpace() const
Returns a smart pointer to 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:578
A set of GrBackendTextures that hold the planar data for an image described a SkYUVAInfo.
Definition: GrYUVABackendTextures.h:82
AsyncReadResult()=default
GrMipmapped
Used to say whether a texture has mip levels allocated or not.
Definition: GrTypes.h:169
SkTileMode
Definition: SkTileMode.h:13
Definition: SkSamplingOptions.h:50
Struct to supply options to flush calls.
Definition: GrTypes.h:271
static sk_sp< SkImage > MakeFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
Creates SkImage from data returned by imageGenerator.
static sk_sp< SkImage > MakeFromTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
Creates SkImage from GPU texture associated with context.
void flush(GrDirectContext *context)
Definition: SkImage.h:682
#define SK_API
Definition: SkTypes.h:181
static sk_sp< SkImage > MakeFromRaster(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
Creates SkImage from pixmap, sharing SkPixmap pixels.
bool readPixels(const SkPixmap &dst, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
sk_sp< SkImage > makeColorSpace(sk_sp< SkColorSpace > target, GrDirectContext *direct=nullptr) const
Creates SkImage in target SkColorSpace.
AsyncReadResult & operator=(AsyncReadResult &&)=delete
BitDepth
Definition: SkImage.h:418
static sk_sp< SkImage > MakeFromEncoded(sk_sp< SkData > encoded)
Return an image backed by the encoded data, but attempt to defer decoding until the image is actually...
static sk_sp< SkImage > MakeTextureFromCompressed(GrDirectContext *direct, sk_sp< SkData > data, int width, int height, CompressionType type, GrMipmapped mipMapped=GrMipmapped::kNo, GrProtected isProtected=GrProtected::kNo)
Creates a GPU-backed SkImage from compressed data.
Definition: SkImageInfo.h:283
static sk_sp< SkImage > MakeRasterCopy(const SkPixmap &pixmap)
Creates SkImage from SkPixmap and copy of pixels.
Definition: SkCanvas.h:90
Definition: SkPicture.h:39
sk_sp< SkImage > withDefaultMipmaps() const
Returns an image with the same "base" pixels as the this image, but with mipmap levels automatically ...
LegacyBitmapMode
Deprecated.
Definition: SkImage.h:1127
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:17
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:52
bool hasMipmaps() const
Returns true if the image has mipmap levels.
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.
AsyncReadResult(const AsyncReadResult &)=delete
uint32_t uniqueID() const
Returns value unique to image.
Definition: SkImage.h:514
sk_sp< SkData > encodeToData(SkEncodedImageFormat encodedImageFormat, int quality) const
Encodes SkImage pixels, returning result as SkData.
void(ReadPixelsContext, std::unique_ptr< const AsyncReadResult >) ReadPixelsCallback
Client-provided callback to asyncRescaleAndReadPixels() or asyncRescaleAndReadPixelsYUV420() that is ...
Definition: SkImage.h:828
sk_sp< SkImage > makeWithFilter(GrRecordingContext *context, const SkImageFilter *filter, const SkIRect &subset, const SkIRect &clipBounds, SkIRect *outSubset, SkIPoint *offset) const
Creates filtered SkImage.
SkBudgeted
Indicates whether an allocation should count against a cache budget.
Definition: SkTypes.h:594
bool asLegacyBitmap(SkBitmap *bitmap, LegacyBitmapMode legacyBitmapMode=kRO_LegacyBitmapMode) const
Deprecated.
int height() const
Returns pixel row count.
Definition: SkImage.h:494
void asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace, sk_sp< SkColorSpace > dstColorSpace, const SkIRect &srcRect, const SkISize &dstSize, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context)
Similar to asyncRescaleAndReadPixels but performs an additional conversion to YUV.
sk_sp< SkData > encodeToData() const
Encodes SkImage pixels, returning result as SkData.
static sk_sp< SkImage > MakeCrossContextFromPixmap(GrDirectContext *context, const SkPixmap &pixmap, bool buildMips, bool limitToMaxTextureSize=false)
Creates SkImage from pixmap.
void flushAndSubmit(GrDirectContext *)
Version of flush() that uses a default GrFlushInfo.
Definition: SkPixmap.h:31
sk_sp< SkImage > makeTextureImage(GrDirectContext *, GrMipmapped=GrMipmapped::kNo, SkBudgeted=SkBudgeted::kYes) const
Returns SkImage backed by GPU texture associated with context.
virtual const void * data(int i) const =0
RescaleGamma
Definition: SkImage.h:830
Definition: GrDirectContext.h:47
int width() const
Returns pixel count in each row.
Definition: SkImage.h:488
@ kSrc
replaces destination
virtual int count() const =0
Definition: SkMatrix.h:48
@ kRO_LegacyBitmapMode
returned bitmap is read-only and immutable
Definition: SkImage.h:1128
bool isAlphaOnly() const
Returns true if SkImage pixels represent transparency only.
The result from asyncRescaleAndReadPixels() or asyncRescaleAndReadPixelsYUV420().
Definition: SkImage.h:806
SkColorSpace * colorSpace() const
Returns SkColorSpace, the range of colors, associated with SkImage.
static sk_sp< SkImage > MakeFromYUVAPixmaps(GrRecordingContext *context, const SkYUVAPixmaps &pixmaps, GrMipMapped buildMips=GrMipmapped::kNo, bool limitToMaxTextureSize=false, sk_sp< SkColorSpace > imageColorSpace=nullptr)
Creates SkImage from SkYUVAPixmaps.
static sk_sp< SkImage > MakeFromBitmap(const SkBitmap &bitmap)
Creates SkImage from bitmap, sharing or copying bitmap pixels.
AsyncReadResult(AsyncReadResult &&)=delete
const SkImageInfo & imageInfo() const
Returns a SkImageInfo describing the width, height, color type, alpha type, and color space of the Sk...
Definition: SkImage.h:482
bool peekPixels(SkPixmap *pixmap) const
Copies SkImage pixel address, row bytes, and SkImageInfo to pixmap, if address is available,...
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
Deprecated.
Definition: GrBackendSurface.h:54
SkAlphaType alphaType() const
Returns SkAlphaType.
virtual size_t rowBytes(int i) const =0
Can be used to perform actions related to the generating GrContext in a thread safe manner.
Definition: GrContextThreadSafeProxy.h:30
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &sampling, const SkMatrix &lm) const
Definition: SkImage.h:586
GrSemaphoresSubmitted flush(GrDirectContext *context, const GrFlushInfo &flushInfo)
Flushes any pending uses of texture-backed images in the GPU backend.
SkISize dimensions() const
Returns SkISize { width(), height() }.
Definition: SkImage.h:500
SkColorType
Definition: SkImageInfo.h:64
sk_sp< SkImage > makeSubset(const SkIRect &subset, GrDirectContext *direct=nullptr) const
Returns subset of this image.
sk_sp< SkImage > reinterpretColorSpace(sk_sp< SkColorSpace > newColorSpace) const
Creates a new SkImage identical to this one, but with a different SkColorSpace.
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkImageInfo.h:40
GrBackendTexture getBackendTexture(bool flushPendingGrContextIO, GrSurfaceOrigin *origin=nullptr) const
Retrieves the back-end texture.
SkAlphaType
Definition: SkImageInfo.h:37
static bool SkAlphaTypeIsOpaque(SkAlphaType at)
Returns true if SkAlphaType equals kOpaque_SkAlphaType.
Definition: SkImageInfo.h:52
static bool MakeBackendTextureFromSkImage(GrDirectContext *context, sk_sp< SkImage > image, GrBackendTexture *backendTexture, BackendTextureReleaseProc *backendTextureReleaseProc)
Creates a GrBackendTexture from the provided SkImage.
static sk_sp< SkImage > MakeRasterFromCompressed(sk_sp< SkData > data, int width, int height, CompressionType type)
Creates a CPU-backed SkImage from compressed data.
Definition: SkBitmap.h:50
void asyncRescaleAndReadPixels(const SkImageInfo &info, const SkIRect &srcRect, RescaleGamma rescaleGamma, RescaleMode rescaleMode, ReadPixelsCallback callback, ReadPixelsContext context)
Makes image pixel data available to caller, possibly asynchronously.
Definition: SkColorSpace.h:104
CompressionType
Definition: SkImage.h:194
Base class for image filters.
Definition: SkImageFilter.h:31
@ kDisallow_CachingHint
disallows internally caching decoded and copied pixels
Definition: SkImage.h:717