Skia
2D Graphics Library
SkTiledImageUtils Namespace Reference

SkTiledImageUtils' DrawImage/DrawImageRect methods are intended to be direct replacements for their SkCanvas equivalents. More...

Functions

SK_API void DrawImageRect (SkCanvas *canvas, const SkImage *image, const SkRect &src, const SkRect &dst, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
 
void DrawImageRect (SkCanvas *canvas, const sk_sp< SkImage > &image, const SkRect &src, const SkRect &dst, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
 
void DrawImageRect (SkCanvas *canvas, const SkImage *image, const SkRect &dst, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
 
void DrawImageRect (SkCanvas *canvas, const sk_sp< SkImage > &image, const SkRect &dst, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
 
void DrawImage (SkCanvas *canvas, const SkImage *image, SkScalar x, SkScalar y, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
 
void DrawImage (SkCanvas *canvas, const sk_sp< SkImage > &image, SkScalar x, SkScalar y, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
 
SK_API void GetImageKeyValues (const SkImage *image, uint32_t keyValues[kNumImageKeyValues])
 Retrieves a set of values that can be used as part of a cache key for the provided image. More...
 

Variables

static constexpr int kNumImageKeyValues = 6
 

Detailed Description

SkTiledImageUtils' DrawImage/DrawImageRect methods are intended to be direct replacements for their SkCanvas equivalents.

The SkTiledImageUtils calls will break SkBitmap-backed SkImages into smaller tiles and draw them if the original image is too large to be uploaded to the GPU. If the original image doesn't need tiling or is already gpu-backed the DrawImage/DrawImageRect calls will fall through to the matching SkCanvas call.

Function Documentation

◆ DrawImage() [1/2]

void SkTiledImageUtils::DrawImage ( SkCanvas canvas,
const sk_sp< SkImage > &  image,
SkScalar  x,
SkScalar  y,
const SkSamplingOptions sampling = {},
const SkPaint paint = nullptr,
SkCanvas::SrcRectConstraint  constraint = SkCanvas::kFast_SrcRectConstraint 
)
inline

◆ DrawImage() [2/2]

void SkTiledImageUtils::DrawImage ( SkCanvas canvas,
const SkImage image,
SkScalar  x,
SkScalar  y,
const SkSamplingOptions sampling = {},
const SkPaint paint = nullptr,
SkCanvas::SrcRectConstraint  constraint = SkCanvas::kFast_SrcRectConstraint 
)
inline

◆ DrawImageRect() [1/4]

void SkTiledImageUtils::DrawImageRect ( SkCanvas canvas,
const sk_sp< SkImage > &  image,
const SkRect dst,
const SkSamplingOptions sampling = {},
const SkPaint paint = nullptr,
SkCanvas::SrcRectConstraint  constraint = SkCanvas::kFast_SrcRectConstraint 
)
inline

◆ DrawImageRect() [2/4]

void SkTiledImageUtils::DrawImageRect ( SkCanvas canvas,
const sk_sp< SkImage > &  image,
const SkRect src,
const SkRect dst,
const SkSamplingOptions sampling = {},
const SkPaint paint = nullptr,
SkCanvas::SrcRectConstraint  constraint = SkCanvas::kFast_SrcRectConstraint 
)
inline

◆ DrawImageRect() [3/4]

void SkTiledImageUtils::DrawImageRect ( SkCanvas canvas,
const SkImage image,
const SkRect dst,
const SkSamplingOptions sampling = {},
const SkPaint paint = nullptr,
SkCanvas::SrcRectConstraint  constraint = SkCanvas::kFast_SrcRectConstraint 
)
inline

◆ DrawImageRect() [4/4]

SK_API void SkTiledImageUtils::DrawImageRect ( SkCanvas canvas,
const SkImage image,
const SkRect src,
const SkRect dst,
const SkSamplingOptions sampling = {},
const SkPaint paint = nullptr,
SkCanvas::SrcRectConstraint  constraint = SkCanvas::kFast_SrcRectConstraint 
)

◆ GetImageKeyValues()

SK_API void SkTiledImageUtils::GetImageKeyValues ( const SkImage image,
uint32_t  keyValues[kNumImageKeyValues] 
)

Retrieves a set of values that can be used as part of a cache key for the provided image.

Unfortunately, SkImage::uniqueID isn't sufficient as an SkImage cache key. In particular, SkBitmap-backed SkImages can share a single SkBitmap and refer to different subsets of it. In this situation the optimal key is based on the SkBitmap's generation ID and the subset rectangle. For Picture-backed images this method will attempt to generate a concise internally-based key (i.e., containing picture ID, matrix translation, width and height, etc.). For complicated Picture-backed images (i.e., those w/ a paint or a full matrix) it will fall back to using 'image's unique key.

Parameters
imageThe image for which key values are desired
keyValuesThe resulting key values

Variable Documentation

◆ kNumImageKeyValues

constexpr int SkTiledImageUtils::kNumImageKeyValues = 6
staticconstexpr