Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Protected Member Functions | List of all members
SkSpecialImage Class Referenceabstract

#include <SkSpecialImage.h>

Inheritance diagram for SkSpecialImage:
SkRefCnt SkRefCntBase SkSpecialImage_Gpu SkSpecialImage_Raster skgpu::graphite::SpecialImage

Public Types

typedef void * ReleaseContext
 
typedef void(* RasterReleaseProc) (void *pixels, ReleaseContext)
 

Public Member Functions

const SkSurfacePropsprops () const
 
int width () const
 
int height () const
 
SkISize dimensions () const
 
const SkIRectsubset () const
 
uint32_t uniqueID () const
 
virtual SkISize backingStoreDimensions () const =0
 
virtual size_t getSize () const =0
 
bool isExactFit () const
 
const SkColorInfocolorInfo () const
 
SkAlphaType alphaType () const
 
SkColorType colorType () const
 
SkColorSpacegetColorSpace () const
 
void draw (SkCanvas *canvas, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, const SkPaint *paint, bool strict=true) const
 
void draw (SkCanvas *canvas, SkScalar x, SkScalar y) const
 
sk_sp< SkSpecialImagemakeSubset (const SkIRect &subset) const
 
sk_sp< SkSpecialImagemakePixelOutset () const
 
virtual sk_sp< SkImageasImage () const =0
 
virtual sk_sp< SkShaderasShader (SkTileMode, const SkSamplingOptions &, const SkMatrix &lm, bool strict=true) const
 
virtual bool isGaneshBacked () const
 
virtual bool isGraphiteBacked () const
 
virtual GrRecordingContextgetContext () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Protected Member Functions

 SkSpecialImage (const SkIRect &subset, uint32_t uniqueID, const SkColorInfo &, const SkSurfaceProps &)
 
virtual sk_sp< SkSpecialImageonMakeBackingStoreSubset (const SkIRect &subset) const =0
 

Detailed Description

This is a restricted form of SkImage solely intended for internal use. It differs from SkImage in that:

Note: the contents of the backing storage outside of the subset rect are undefined.

Definition at line 49 of file SkSpecialImage.h.

Member Typedef Documentation

◆ RasterReleaseProc

typedef void(* SkSpecialImage::RasterReleaseProc) (void *pixels, ReleaseContext)

Definition at line 52 of file SkSpecialImage.h.

◆ ReleaseContext

Definition at line 51 of file SkSpecialImage.h.

Constructor & Destructor Documentation

◆ SkSpecialImage()

SkSpecialImage::SkSpecialImage ( const SkIRect subset,
uint32_t  uniqueID,
const SkColorInfo colorInfo,
const SkSurfaceProps props 
)
protected

Definition at line 29 of file SkSpecialImage.cpp.

33 : fSubset(subset)
35 , fColorInfo(colorInfo)
36 , fProps(props) {
37}
@ kNeedNewImageUniqueID_SpecialImage
static uint32_t ImageID()
Definition: SkPixelRef.cpp:19
uint32_t uniqueID() const
const SkIRect & subset() const
const SkSurfaceProps & props() const
const SkColorInfo & colorInfo() const

Member Function Documentation

◆ alphaType()

SkAlphaType SkSpecialImage::alphaType ( ) const
inline

Definition at line 70 of file SkSpecialImage.h.

70{ return fColorInfo.alphaType(); }
SkAlphaType alphaType() const
Definition: SkImageInfo.h:141

◆ asImage()

virtual sk_sp< SkImage > SkSpecialImage::asImage ( ) const
pure virtual

Create an SkImage view of the contents of this special image, pointing to the same underlying memory.

TODO: If SkImages::MakeFiltered were to return an SkShader that accounted for the subset constraint and offset, then this could move to a private virtual for use in draw() and asShader().

Implemented in SkSpecialImage_Raster, SkSpecialImage_Gpu, and skgpu::graphite::SpecialImage.

◆ asShader()

sk_sp< SkShader > SkSpecialImage::asShader ( SkTileMode  tileMode,
const SkSamplingOptions sampling,
const SkMatrix lm,
bool  strict = true 
) const
virtual

Create an SkShader that samples the contents of this special image, applying tile mode for any sample that falls outside its internal subset.

'strict' defaults to true and applies shader-based tiling to the subset. If the subset is the same as the backing store dimensions, it is automatically degraded to non-strict (HW tiling and sampling). 'strict' can be set to false if it's known that the subset boundaries aren't visible AND the texel data in adjacent rows/cols is valid to be included by the given sampling options.

Reimplemented in SkSpecialImage_Raster.

Definition at line 52 of file SkSpecialImage.cpp.

55 {
56 // The special image's logical (0,0) is at its subset's topLeft() so we need to account for
57 // that in the local matrix used when sampling.
58 SkMatrix subsetOrigin = SkMatrix::Translate(-this->subset().topLeft());
59 subsetOrigin.postConcat(lm);
60
61 if (strict) {
62 // However, we don't need to modify the subset itself since that is defined with respect
63 // to the base image, and the local matrix is applied before any tiling/clamping.
64 const SkRect subset = SkRect::Make(this->subset());
65
66 // asImage() w/o a subset makes no copy; create the SkImageShader directly to remember
67 // the subset used to access the image.
69 this->asImage(), subset, tileMode, tileMode, sampling, &subsetOrigin);
70 } else {
71 // Ignore 'subset' other than its origin translation applied to the local matrix.
72 return this->asImage()->makeShader(tileMode, tileMode, sampling, subsetOrigin);
73 }
74}
static sk_sp< SkShader > MakeSubset(sk_sp< SkImage >, const SkRect &subset, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix, bool clampAsIfUnpremul=false)
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
SkMatrix & postConcat(const SkMatrix &other)
Definition: SkMatrix.cpp:683
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
virtual sk_sp< SkImage > asImage() const =0
SkSamplingOptions sampling
Definition: SkRecords.h:337
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669

◆ backingStoreDimensions()

virtual SkISize SkSpecialImage::backingStoreDimensions ( ) const
pure virtual

◆ colorInfo()

const SkColorInfo & SkSpecialImage::colorInfo ( ) const
inline

Definition at line 69 of file SkSpecialImage.h.

69{ return fColorInfo; }

◆ colorType()

SkColorType SkSpecialImage::colorType ( ) const
inline

Definition at line 71 of file SkSpecialImage.h.

71{ return fColorInfo.colorType(); }
SkColorType colorType() const
Definition: SkImageInfo.h:140

◆ dimensions()

SkISize SkSpecialImage::dimensions ( ) const
inline

Definition at line 58 of file SkSpecialImage.h.

58{ return { this->width(), this->height() }; }
int width() const
int height() const

◆ draw() [1/2]

void SkSpecialImage::draw ( SkCanvas canvas,
SkScalar  x,
SkScalar  y 
) const
inline

Definition at line 82 of file SkSpecialImage.h.

82 {
83 this->draw(canvas, x, y, SkSamplingOptions(), nullptr);
84 }
void draw(SkCanvas *canvas, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, const SkPaint *paint, bool strict=true) const
double y
double x
SkSamplingOptions(SkFilterMode::kLinear))

◆ draw() [2/2]

void SkSpecialImage::draw ( SkCanvas canvas,
SkScalar  x,
SkScalar  y,
const SkSamplingOptions sampling,
const SkPaint paint,
bool  strict = true 
) const

Draw this SpecialImage into the canvas, automatically taking into account the image's subset

Definition at line 39 of file SkSpecialImage.cpp.

42 {
43 SkRect dst = SkRect::MakeXYWH(x, y, this->subset().width(), this->subset().height());
44
45 canvas->drawImageRect(this->asImage(), SkRect::Make(this->subset()), dst,
48}
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition: SkCanvas.h:1542
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition: SkCanvas.h:1543
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
const Paint & paint
Definition: color_source.cc:38
dst
Definition: cp.py:12
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ getColorSpace()

SkColorSpace * SkSpecialImage::getColorSpace ( ) const
inline

Definition at line 72 of file SkSpecialImage.h.

72{ return fColorInfo.colorSpace(); }
SkColorSpace * colorSpace() const
Definition: SkImageInfo.cpp:66

◆ getContext()

virtual GrRecordingContext * SkSpecialImage::getContext ( ) const
inlinevirtual

Return the GrRecordingContext if the SkSpecialImage is GrTexture-backed

Reimplemented in SkSpecialImage_Gpu.

Definition at line 138 of file SkSpecialImage.h.

138{ return nullptr; }

◆ getSize()

virtual size_t SkSpecialImage::getSize ( ) const
pure virtual

◆ height()

int SkSpecialImage::height ( ) const
inline

Definition at line 57 of file SkSpecialImage.h.

57{ return fSubset.height(); }
constexpr int32_t height() const
Definition: SkRect.h:165

◆ isExactFit()

bool SkSpecialImage::isExactFit ( ) const
inline

Definition at line 67 of file SkSpecialImage.h.

67{ return fSubset == SkIRect::MakeSize(this->backingStoreDimensions()); }
virtual SkISize backingStoreDimensions() const =0
static constexpr SkIRect MakeSize(const SkISize &size)
Definition: SkRect.h:66

◆ isGaneshBacked()

virtual bool SkSpecialImage::isGaneshBacked ( ) const
inlinevirtual

If the SpecialImage is backed by a gpu texture, return true.

Reimplemented in SkSpecialImage_Gpu.

Definition at line 132 of file SkSpecialImage.h.

132{ return false; }

◆ isGraphiteBacked()

virtual bool SkSpecialImage::isGraphiteBacked ( ) const
inlinevirtual

Reimplemented in skgpu::graphite::SpecialImage.

Definition at line 133 of file SkSpecialImage.h.

133{ return false; }

◆ makePixelOutset()

sk_sp< SkSpecialImage > SkSpecialImage::makePixelOutset ( ) const
inline

Return a special image with a 1px larger subset in the backing store compared to this image. This should only be used when it's externally known that those outer pixels are valid.

Definition at line 100 of file SkSpecialImage.h.

100 {
101 return this->onMakeBackingStoreSubset(this->subset().makeOutset(1, 1));
102 }
virtual sk_sp< SkSpecialImage > onMakeBackingStoreSubset(const SkIRect &subset) const =0

◆ makeSubset()

sk_sp< SkSpecialImage > SkSpecialImage::makeSubset ( const SkIRect subset) const
inline

Extract a subset of this special image and return it as a special image. It may or may not point to the same backing memory. The input 'subset' is relative to the special image's content rect.

Definition at line 91 of file SkSpecialImage.h.

91 {
92 SkIRect absolute = subset.makeOffset(this->subset().topLeft());
93 return this->onMakeBackingStoreSubset(absolute);
94 }
Definition: SkRect.h:32
constexpr SkIRect makeOffset(int32_t dx, int32_t dy) const
Definition: SkRect.h:300

◆ onMakeBackingStoreSubset()

virtual sk_sp< SkSpecialImage > SkSpecialImage::onMakeBackingStoreSubset ( const SkIRect subset) const
protectedpure virtual

◆ props()

const SkSurfaceProps & SkSpecialImage::props ( ) const
inline

Definition at line 54 of file SkSpecialImage.h.

54{ return fProps; }

◆ subset()

const SkIRect & SkSpecialImage::subset ( ) const
inline

Definition at line 59 of file SkSpecialImage.h.

59{ return fSubset; }

◆ uniqueID()

uint32_t SkSpecialImage::uniqueID ( ) const
inline

Definition at line 61 of file SkSpecialImage.h.

61{ return fUniqueID; }

◆ width()

int SkSpecialImage::width ( ) const
inline

Definition at line 56 of file SkSpecialImage.h.

56{ return fSubset.width(); }
constexpr int32_t width() const
Definition: SkRect.h:158

The documentation for this class was generated from the following files: