Skia
2D Graphics Library
SkImage.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkImage_DEFINED
9 #define SkImage_DEFINED
10 
13 #include "include/core/SkM44.h"
14 #include "include/core/SkRefCnt.h"
16 #include "include/core/SkScalar.h"
17 #include "include/core/SkShader.h"
19 #include "include/gpu/GrTypes.h"
20 #include <functional> // std::function
21 
22 #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
23 #include <android/hardware_buffer.h>
24 #endif
25 
26 class SkData;
27 class SkCanvas;
28 class SkImage;
29 class SkImageFilter;
30 class SkImageGenerator;
31 class SkMipmap;
32 class SkPaint;
33 class SkPicture;
34 class SkSurface;
35 class SkYUVAPixmaps;
36 class GrBackendTexture;
37 class GrDirectContext;
38 class GrRecordingContext;
41 
58 class SK_API SkImage : public SkRefCnt {
59 public:
60 
63  typedef void* ReleaseContext;
64 
80  static sk_sp<SkImage> MakeRasterCopy(const SkPixmap& pixmap);
81 
97  size_t rowBytes);
98 
102  typedef void (*RasterReleaseProc)(const void* pixels, ReleaseContext);
103 
124  static sk_sp<SkImage> MakeFromRaster(const SkPixmap& pixmap,
125  RasterReleaseProc rasterReleaseProc,
126  ReleaseContext releaseContext);
127 
144  static sk_sp<SkImage> MakeFromBitmap(const SkBitmap& bitmap);
145 
157  static sk_sp<SkImage> MakeFromGenerator(std::unique_ptr<SkImageGenerator> imageGenerator);
158 
182 
183  /*
184  * Experimental:
185  * Skia | GL_COMPRESSED_* | MTLPixelFormat* | VK_FORMAT_*_BLOCK
186  * --------------------------------------------------------------------------------------
187  * kETC2_RGB8_UNORM | ETC1_RGB8 | ETC2_RGB8 (iOS-only) | ETC2_R8G8B8_UNORM
188  * | RGB8_ETC2 | |
189  * --------------------------------------------------------------------------------------
190  * kBC1_RGB8_UNORM | RGB_S3TC_DXT1_EXT | N/A | BC1_RGB_UNORM
191  * --------------------------------------------------------------------------------------
192  * kBC1_RGBA8_UNORM | RGBA_S3TC_DXT1_EXT | BC1_RGBA (macOS-only)| BC1_RGBA_UNORM
193  */
194  enum class CompressionType {
195  kNone,
196  kETC2_RGB8_UNORM, // the same as ETC1
197 
198  kBC1_RGB8_UNORM,
199  kBC1_RGBA8_UNORM,
200  kLast = kBC1_RGBA8_UNORM,
201  };
202 
203  static constexpr int kCompressionTypeCount = static_cast<int>(CompressionType::kLast) + 1;
204 
205  static const CompressionType kETC1_CompressionType = CompressionType::kETC2_RGB8_UNORM;
206 
226  sk_sp<SkData> data,
227  int width, int height,
228  CompressionType type,
229  GrMipmapped mipMapped = GrMipmapped::kNo,
230  GrProtected isProtected = GrProtected::kNo);
231 
244  int width, int height,
245  CompressionType type);
246 
249  typedef void (*TextureReleaseProc)(ReleaseContext releaseContext);
250 
275  const GrBackendTexture& backendTexture,
276  GrSurfaceOrigin origin,
277  SkColorType colorType,
278  SkAlphaType alphaType,
279  sk_sp<SkColorSpace> colorSpace,
280  TextureReleaseProc textureReleaseProc = nullptr,
281  ReleaseContext releaseContext = nullptr);
282 
311  const GrBackendTexture& backendTexture,
312  GrSurfaceOrigin origin,
313  SkAlphaType alphaType,
314  sk_sp<SkColorSpace> colorSpace,
315  TextureReleaseProc textureReleaseProc = nullptr,
316  ReleaseContext releaseContext = nullptr);
317 
344  const SkPixmap& pixmap,
345  bool buildMips,
346  bool limitToMaxTextureSize = false);
347 
363  const GrBackendTexture& backendTexture,
364  GrSurfaceOrigin textureOrigin,
365  SkColorType colorType,
366  SkAlphaType alphaType = kPremul_SkAlphaType,
367  sk_sp<SkColorSpace> colorSpace = nullptr);
368 
384  const GrYUVABackendTextures& yuvaTextures,
385  sk_sp<SkColorSpace> imageColorSpace = nullptr,
386  TextureReleaseProc textureReleaseProc = nullptr,
387  ReleaseContext releaseContext = nullptr);
388 
413  const SkYUVAPixmaps& pixmaps,
414  GrMipMapped buildMips = GrMipmapped::kNo,
415  bool limitToMaxTextureSize = false,
416  sk_sp<SkColorSpace> imageColorSpace = nullptr);
417 
418  enum class BitDepth {
419  kU8,
420  kF16,
421  };
422 
437  static sk_sp<SkImage> MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions,
438  const SkMatrix* matrix, const SkPaint* paint,
439  BitDepth bitDepth,
440  sk_sp<SkColorSpace> colorSpace);
441 
442 #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
443 
453  static sk_sp<SkImage> MakeFromAHardwareBuffer(
454  AHardwareBuffer* hardwareBuffer,
455  SkAlphaType alphaType = kPremul_SkAlphaType,
456  sk_sp<SkColorSpace> colorSpace = nullptr,
457  GrSurfaceOrigin surfaceOrigin = kTopLeft_GrSurfaceOrigin);
458 
470  static sk_sp<SkImage> MakeFromAHardwareBufferWithData(
471  GrDirectContext* context,
472  const SkPixmap& pixmap,
473  AHardwareBuffer* hardwareBuffer,
474  GrSurfaceOrigin surfaceOrigin = kTopLeft_GrSurfaceOrigin);
475 #endif
476 
482  const SkImageInfo& imageInfo() const { return fInfo; }
483 
488  int width() const { return fInfo.width(); }
489 
494  int height() const { return fInfo.height(); }
495 
500  SkISize dimensions() const { return SkISize::Make(fInfo.width(), fInfo.height()); }
501 
506  SkIRect bounds() const { return SkIRect::MakeWH(fInfo.width(), fInfo.height()); }
507 
514  uint32_t uniqueID() const { return fUniqueID; }
515 
526 
534 
548 
564 
572  bool isAlphaOnly() const;
573 
578  bool isOpaque() const { return SkAlphaTypeIsOpaque(this->alphaType()); }
579 
584  const SkMatrix* localMatrix = nullptr) const;
585 
587  const SkMatrix& lm) const {
588  return this->makeShader(tmx, tmy, sampling, &lm);
589  }
590  sk_sp<SkShader> makeShader(const SkSamplingOptions& sampling, const SkMatrix& lm) const {
591  return this->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, sampling, &lm);
592  }
594  const SkMatrix* lm = nullptr) const {
595  return this->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, sampling, lm);
596  }
597 
599 
600 #ifdef SK_SUPPORT_LEGACY_IMPLICIT_FILTERQUALITY
601 
613  sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy,
614  const SkMatrix* localMatrix = nullptr) const;
615  sk_sp<SkShader> makeShader(SkTileMode tmx, SkTileMode tmy, const SkMatrix& localMatrix) const {
616  return this->makeShader(tmx, tmy, &localMatrix);
617  }
618 
626  sk_sp<SkShader> makeShader(const SkMatrix* localMatrix = nullptr) const {
627  return this->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, localMatrix);
628  }
629  sk_sp<SkShader> makeShader(const SkMatrix& localMatrix) const {
630  return this->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, &localMatrix);
631  }
632 #endif
633 
643  bool peekPixels(SkPixmap* pixmap) const;
644 
652  bool isTextureBacked() const;
653 
667  bool isValid(GrRecordingContext* context) const;
668 
681 
682  void flush(GrDirectContext* context) { this->flush(context, {}); }
683 
688 
700  GrBackendTexture getBackendTexture(bool flushPendingGrContextIO,
701  GrSurfaceOrigin* origin = nullptr) const;
702 
715  enum CachingHint {
718  };
719 
754  const SkImageInfo& dstInfo,
755  void* dstPixels,
756  size_t dstRowBytes,
757  int srcX, int srcY,
758  CachingHint cachingHint = kAllow_CachingHint) const;
759 
792  const SkPixmap& dst,
793  int srcX,
794  int srcY,
795  CachingHint cachingHint = kAllow_CachingHint) const;
796 
797 #ifndef SK_IMAGE_READ_PIXELS_DISABLE_LEGACY_API
798 
799  bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
800  int srcX, int srcY, CachingHint cachingHint = kAllow_CachingHint) const;
801  bool readPixels(const SkPixmap& dst, int srcX, int srcY,
802  CachingHint cachingHint = kAllow_CachingHint) const;
803 #endif
804 
807  public:
812 
813  virtual ~AsyncReadResult() = default;
814  virtual int count() const = 0;
815  virtual const void* data(int i) const = 0;
816  virtual size_t rowBytes(int i) const = 0;
817 
818  protected:
819  AsyncReadResult() = default;
820  };
821 
823  using ReadPixelsContext = void*;
824 
828  using ReadPixelsCallback = void(ReadPixelsContext, std::unique_ptr<const AsyncReadResult>);
829 
830  enum class RescaleGamma : bool { kSrc, kLinear };
831 
832  enum class RescaleMode {
833  kNearest,
834  kRepeatedLinear,
835  kRepeatedCubic,
836  };
837 
869  const SkIRect& srcRect,
870  RescaleGamma rescaleGamma,
871  RescaleMode rescaleMode,
872  ReadPixelsCallback callback,
873  ReadPixelsContext context);
874 
905  sk_sp<SkColorSpace> dstColorSpace,
906  const SkIRect& srcRect,
907  const SkISize& dstSize,
908  RescaleGamma rescaleGamma,
909  RescaleMode rescaleMode,
910  ReadPixelsCallback callback,
911  ReadPixelsContext context);
912 
931  bool scalePixels(const SkPixmap& dst, const SkSamplingOptions&,
932  CachingHint cachingHint = kAllow_CachingHint) const;
933 
957  sk_sp<SkData> encodeToData(SkEncodedImageFormat encodedImageFormat, int quality) const;
958 
971 
983 
1001  sk_sp<SkImage> makeSubset(const SkIRect& subset, GrDirectContext* direct = nullptr) const;
1002 
1006  bool hasMipmaps() const;
1007 
1013 
1036  SkBudgeted = SkBudgeted::kYes) const;
1037 
1049 
1063  sk_sp<SkImage> makeRasterImage(CachingHint cachingHint = kDisallow_CachingHint) const;
1064 
1090  const SkImageFilter* filter, const SkIRect& subset,
1091  const SkIRect& clipBounds, SkIRect* outSubset,
1092  SkIPoint* offset) const;
1093 
1097  typedef std::function<void(GrBackendTexture)> BackendTextureReleaseProc;
1098 
1121  sk_sp<SkImage> image,
1122  GrBackendTexture* backendTexture,
1123  BackendTextureReleaseProc* backendTextureReleaseProc);
1124 
1129  };
1130 
1141  bool asLegacyBitmap(SkBitmap* bitmap,
1142  LegacyBitmapMode legacyBitmapMode = kRO_LegacyBitmapMode) const;
1143 
1152  bool isLazyGenerated() const;
1153 
1171  GrDirectContext* direct = nullptr) const;
1172 
1188  sk_sp<SkColorSpace> targetColorSpace,
1189  GrDirectContext* direct = nullptr) const;
1190 
1196 
1197 private:
1198  SkImage(const SkImageInfo& info, uint32_t uniqueID);
1199 
1200  friend class SkBitmap;
1201  friend class SkImage_Base;
1202  friend class SkMipmapBuilder;
1203 
1204  SkImageInfo fInfo;
1205  const uint32_t fUniqueID;
1206 
1207  sk_sp<SkImage> withMipmaps(sk_sp<SkMipmap>) const;
1208 
1209  using INHERITED = SkRefCnt;
1210 };
1211 
1212 #endif
SkTileMode::kClamp
@ kClamp
Replicate the edge color if the shader draws outside of its original bounds.
GrRecordingContext
Definition: GrRecordingContext.h:34
SkImage::bounds
SkIRect bounds() const
Returns SkIRect { 0, 0, width(), height() }.
Definition: SkImage.h:506
SkImage::makeRasterImage
sk_sp< SkImage > makeRasterImage(CachingHint cachingHint=kDisallow_CachingHint) const
Returns raster image.
SkImage::readPixels
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.
SkYUVAPixmaps
Helper to store SkPixmap planes as described by a SkYUVAPixmapInfo.
Definition: SkYUVAPixmaps.h:171
SkImageGenerator
Definition: SkImageGenerator.h:28
GrSemaphoresSubmitted
GrSemaphoresSubmitted
Enum used as return value when flush with semaphores so the client knows whether the valid semaphores...
Definition: GrTypes.h:284
SkImage
Definition: SkImage.h:58
SkRefCnt
Definition: SkRefCnt.h:118
SkM44.h
SkImage::MakeFromYUVATextures
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.
SkImage::isValid
bool isValid(GrRecordingContext *context) const
Returns true if SkImage can be drawn on either raster surface or GPU surface.
SkSurface
Definition: SkSurface.h:46
SkImage::refEncodedData
sk_sp< SkData > refEncodedData() const
Returns encoded SkImage pixels as SkData, if SkImage was created from supported encoded stream format...
SkImage::makeColorTypeAndColorSpace
sk_sp< SkImage > makeColorTypeAndColorSpace(SkColorType targetColorType, sk_sp< SkColorSpace > targetColorSpace, GrDirectContext *direct=nullptr) const
Experimental.
SkImage::makeNonTextureImage
sk_sp< SkImage > makeNonTextureImage() const
Returns raster image or lazy image.
SkYUVColorSpace
SkYUVColorSpace
Definition: SkImageInfo.h:148
SkImage::colorType
SkColorType colorType() const
Returns SkColorType if known; otherwise, returns kUnknown_SkColorType.
SkImage::AsyncReadResult::operator=
AsyncReadResult & operator=(const AsyncReadResult &)=delete
SkImage::isLazyGenerated
bool isLazyGenerated() const
Returns true if SkImage is backed by an image-generator or other service that creates and caches its ...
SkImage::ReleaseContext
void * ReleaseContext
Caller data passed to RasterReleaseProc; may be nullptr.
Definition: SkImage.h:63
kTopLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:199
SkImage::kAllow_CachingHint
@ kAllow_CachingHint
allows internally caching decoded and copied pixels
Definition: SkImage.h:716
GrSurfaceOrigin
GrSurfaceOrigin
GPU SkImage and SkSurfaces can be stored such that (0, 0) in texture space may correspond to either t...
Definition: GrTypes.h:198
SkCubicResampler
Definition: SkSamplingOptions.h:46
SkImage::MakeFromAdoptedTexture
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
GrProtected
Definition: GrTypes.h:187
SkImage::MakeFromPicture
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.
SkImage::MakeRasterData
static sk_sp< SkImage > MakeRasterData(const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes)
Creates SkImage from SkImageInfo, sharing pixels.
SkImage::CachingHint
CachingHint
Definition: SkImage.h:715
SkImage::BackendTextureReleaseProc
std::function< void(GrBackendTexture)> BackendTextureReleaseProc
Defines a callback function, taking one parameter of type GrBackendTexture with no return value.
Definition: SkImage.h:1097
SkFontHinting::kNone
@ kNone
glyph outlines unchanged
SkImage::makeShader
sk_sp< SkShader > makeShader(const SkSamplingOptions &sampling, const SkMatrix *lm=nullptr) const
Definition: SkImage.h:593
SkImage::isTextureBacked
bool isTextureBacked() const
Returns true the contents of SkImage was created on or uploaded to GPU memory, and is available as a ...
SkImage::AsyncReadResult::~AsyncReadResult
virtual ~AsyncReadResult()=default
SkImage::RescaleMode
RescaleMode
Definition: SkImage.h:832
SkImage::scalePixels
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...
SkImage::ReadPixelsContext
void * ReadPixelsContext
Client-provided context that is passed to client-provided ReadPixelsContext.
Definition: SkImage.h:823
SkImage::makeShader
sk_sp< SkShader > makeShader(const SkSamplingOptions &sampling, const SkMatrix &lm) const
Definition: SkImage.h:590
SkData
SkData holds an immutable data buffer.
Definition: SkData.h:22
SkImage::readPixels
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.
SkImage::MakeFromCompressedTexture
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.
SkRefCnt.h
SkImage::refColorSpace
sk_sp< SkColorSpace > refColorSpace() const
Returns a smart pointer to SkColorSpace, the range of colors, associated with SkImage.
SkImage::isOpaque
bool isOpaque() const
Returns true if pixels ignore their alpha value and are treated as fully opaque.
Definition: SkImage.h:578
GrYUVABackendTextures
A set of GrBackendTextures that hold the planar data for an image described a SkYUVAInfo.
Definition: GrYUVABackendTextures.h:82
SkImage::AsyncReadResult::AsyncReadResult
AsyncReadResult()=default
GrMipmapped
GrMipmapped
Used to say whether a texture has mip levels allocated or not.
Definition: GrTypes.h:169
SkScalar.h
SkTileMode
SkTileMode
Definition: SkTileMode.h:13
sk_sp< SkImage >
SkSamplingOptions
Definition: SkSamplingOptions.h:50
GrFlushInfo
Struct to supply options to flush calls.
Definition: GrTypes.h:271
SkImage::MakeFromGenerator
static sk_sp< SkImage > MakeFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
Creates SkImage from data returned by imageGenerator.
SkImage::MakeFromTexture
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.
SkPaint
Definition: SkPaint.h:39
SkImage::flush
void flush(GrDirectContext *context)
Definition: SkImage.h:682
SK_API
#define SK_API
Definition: SkTypes.h:181
SkImage::MakeFromRaster
static sk_sp< SkImage > MakeFromRaster(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
Creates SkImage from pixmap, sharing SkPixmap pixels.
SkImage::readPixels
bool readPixels(const SkPixmap &dst, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
SkImage::makeColorSpace
sk_sp< SkImage > makeColorSpace(sk_sp< SkColorSpace > target, GrDirectContext *direct=nullptr) const
Creates SkImage in target SkColorSpace.
SkImage::AsyncReadResult::operator=
AsyncReadResult & operator=(AsyncReadResult &&)=delete
SkImage::BitDepth
BitDepth
Definition: SkImage.h:418
SkImage::MakeFromEncoded
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...
SkImage::MakeTextureFromCompressed
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.
SkImageInfo
Definition: SkImageInfo.h:283
SkImage::MakeRasterCopy
static sk_sp< SkImage > MakeRasterCopy(const SkPixmap &pixmap)
Creates SkImage from SkPixmap and copy of pixels.
SkISize
Definition: SkSize.h:13
SkCanvas
Definition: SkCanvas.h:90
SkPicture
Definition: SkPicture.h:39
SkImage::withDefaultMipmaps
sk_sp< SkImage > withDefaultMipmaps() const
Returns an image with the same "base" pixels as the this image, but with mipmap levels automatically ...
SkEncodedImageFormat
SkEncodedImageFormat
Enum describing format of encoded data.
Definition: SkEncodedImageFormat.h:16
SkImage::LegacyBitmapMode
LegacyBitmapMode
Deprecated.
Definition: SkImage.h:1127
SkISize::Make
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:17
SkIRect::MakeWH
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
SkImage::hasMipmaps
bool hasMipmaps() const
Returns true if the image has mipmap levels.
SkImage::makeShader
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.
SkFilterMode::kLinear
@ kLinear
SkImage::AsyncReadResult::AsyncReadResult
AsyncReadResult(const AsyncReadResult &)=delete
SkImage::uniqueID
uint32_t uniqueID() const
Returns value unique to image.
Definition: SkImage.h:514
SkImage::encodeToData
sk_sp< SkData > encodeToData(SkEncodedImageFormat encodedImageFormat, int quality) const
Encodes SkImage pixels, returning result as SkData.
SkImage::ReadPixelsCallback
void(ReadPixelsContext, std::unique_ptr< const AsyncReadResult >) ReadPixelsCallback
Client-provided callback to asyncRescaleAndReadPixels() or asyncRescaleAndReadPixelsYUV420() that is ...
Definition: SkImage.h:828
SkImage::makeWithFilter
sk_sp< SkImage > makeWithFilter(GrRecordingContext *context, const SkImageFilter *filter, const SkIRect &subset, const SkIRect &clipBounds, SkIRect *outSubset, SkIPoint *offset) const
Creates filtered SkImage.
SkBudgeted
SkBudgeted
Indicates whether an allocation should count against a cache budget.
Definition: SkTypes.h:594
SkImage::asLegacyBitmap
bool asLegacyBitmap(SkBitmap *bitmap, LegacyBitmapMode legacyBitmapMode=kRO_LegacyBitmapMode) const
Deprecated.
SkImage::height
int height() const
Returns pixel row count.
Definition: SkImage.h:494
SkImage::asyncRescaleAndReadPixelsYUV420
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.
SkImage::encodeToData
sk_sp< SkData > encodeToData() const
Encodes SkImage pixels, returning result as SkData.
SkImage::MakeCrossContextFromPixmap
static sk_sp< SkImage > MakeCrossContextFromPixmap(GrDirectContext *context, const SkPixmap &pixmap, bool buildMips, bool limitToMaxTextureSize=false)
Creates SkImage from pixmap.
GrTypes.h
SkImage::flushAndSubmit
void flushAndSubmit(GrDirectContext *)
Version of flush() that uses a default GrFlushInfo.
SkPixmap
Definition: SkPixmap.h:31
SkImage::makeTextureImage
sk_sp< SkImage > makeTextureImage(GrDirectContext *, GrMipmapped=GrMipmapped::kNo, SkBudgeted=SkBudgeted::kYes) const
Returns SkImage backed by GPU texture associated with context.
SkFilterMode::kNearest
@ kNearest
SkImage::AsyncReadResult::data
virtual const void * data(int i) const =0
SkImage::RescaleGamma
RescaleGamma
Definition: SkImage.h:830
GrDirectContext
Definition: GrDirectContext.h:47
SkImage::width
int width() const
Returns pixel count in each row.
Definition: SkImage.h:488
SkBlendMode::kSrc
@ kSrc
replaces destination
SkImage::AsyncReadResult::count
virtual int count() const =0
SkMatrix
Definition: SkMatrix.h:48
SkTileMode.h
SkImage::kRO_LegacyBitmapMode
@ kRO_LegacyBitmapMode
returned bitmap is read-only and immutable
Definition: SkImage.h:1128
SkImage::isAlphaOnly
bool isAlphaOnly() const
Returns true if SkImage pixels represent transparency only.
SkImage::AsyncReadResult
The result from asyncRescaleAndReadPixels() or asyncRescaleAndReadPixelsYUV420().
Definition: SkImage.h:806
SkIRect
Definition: SkRect.h:28
SkCoverageMode::kLast
@ kLast
SkImage::colorSpace
SkColorSpace * colorSpace() const
Returns SkColorSpace, the range of colors, associated with SkImage.
SkImage::MakeFromYUVAPixmaps
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.
SkImage::MakeFromBitmap
static sk_sp< SkImage > MakeFromBitmap(const SkBitmap &bitmap)
Creates SkImage from bitmap, sharing or copying bitmap pixels.
SkImage::AsyncReadResult::AsyncReadResult
AsyncReadResult(AsyncReadResult &&)=delete
SkImage::imageInfo
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
SkImage::peekPixels
bool peekPixels(SkPixmap *pixmap) const
Copies SkImage pixel address, row bytes, and SkImageInfo to pixmap, if address is available,...
SkImage::readPixels
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
Deprecated.
GrBackendTexture
Definition: GrBackendSurface.h:54
SkImage::alphaType
SkAlphaType alphaType() const
Returns SkAlphaType.
SkImage::AsyncReadResult::rowBytes
virtual size_t rowBytes(int i) const =0
GrProtected::kNo
@ kNo
GrContextThreadSafeProxy
Can be used to perform actions related to the generating GrContext in a thread safe manner.
Definition: GrContextThreadSafeProxy.h:30
SkImage::makeShader
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &sampling, const SkMatrix &lm) const
Definition: SkImage.h:586
SkImage::flush
GrSemaphoresSubmitted flush(GrDirectContext *context, const GrFlushInfo &flushInfo)
Flushes any pending uses of texture-backed images in the GPU backend.
SkImage::dimensions
SkISize dimensions() const
Returns SkISize { width(), height() }.
Definition: SkImage.h:500
SkColorType
SkColorType
Definition: SkImageInfo.h:64
SkImage::makeSubset
sk_sp< SkImage > makeSubset(const SkIRect &subset, GrDirectContext *direct=nullptr) const
Returns subset of this image.
SkImage::reinterpretColorSpace
sk_sp< SkImage > reinterpretColorSpace(sk_sp< SkColorSpace > newColorSpace) const
Creates a new SkImage identical to this one, but with a different SkColorSpace.
SkIPoint
Definition: SkPoint.h:25
kPremul_SkAlphaType
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkImageInfo.h:40
SkImage::getBackendTexture
GrBackendTexture getBackendTexture(bool flushPendingGrContextIO, GrSurfaceOrigin *origin=nullptr) const
Retrieves the back-end texture.
SkShader.h
SkAlphaType
SkAlphaType
Definition: SkImageInfo.h:37
SkAlphaTypeIsOpaque
static bool SkAlphaTypeIsOpaque(SkAlphaType at)
Returns true if SkAlphaType equals kOpaque_SkAlphaType.
Definition: SkImageInfo.h:52
SkImage::MakeBackendTextureFromSkImage
static bool MakeBackendTextureFromSkImage(GrDirectContext *context, sk_sp< SkImage > image, GrBackendTexture *backendTexture, BackendTextureReleaseProc *backendTextureReleaseProc)
Creates a GrBackendTexture from the provided SkImage.
GrMipmapped::kNo
@ kNo
SkImageInfo.h
SkImage::MakeRasterFromCompressed
static sk_sp< SkImage > MakeRasterFromCompressed(sk_sp< SkData > data, int width, int height, CompressionType type)
Creates a CPU-backed SkImage from compressed data.
SkBitmap
Definition: SkBitmap.h:50
SkImage::asyncRescaleAndReadPixels
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.
SkImageEncoder.h
SkColorSpace
Definition: SkColorSpace.h:104
SkImage::CompressionType
CompressionType
Definition: SkImage.h:194
SkBudgeted::kYes
@ kYes
SkSamplingOptions.h
SkImageFilter
Base class for image filters.
Definition: SkImageFilter.h:31
SkImage::kDisallow_CachingHint
@ kDisallow_CachingHint
disallows internally caching decoded and copied pixels
Definition: SkImage.h:717