Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SkSpecialImage_Raster Class Referencefinal
Inheritance diagram for SkSpecialImage_Raster:
SkSpecialImage SkRefCnt SkRefCntBase

Public Member Functions

 SkSpecialImage_Raster (const SkIRect &subset, const SkBitmap &bm, const SkSurfaceProps &props)
 
bool getROPixels (SkBitmap *bm) const
 
SkISize backingStoreDimensions () const override
 
size_t getSize () const override
 
sk_sp< SkImageasImage () const override
 
sk_sp< SkSpecialImageonMakeBackingStoreSubset (const SkIRect &subset) const override
 
sk_sp< SkShaderasShader (SkTileMode tileMode, const SkSamplingOptions &sampling, const SkMatrix &lm, bool strict) const override
 
- Public Member Functions inherited from SkSpecialImage
const SkSurfacePropsprops () const
 
int width () const
 
int height () const
 
SkISize dimensions () const
 
const SkIRectsubset () const
 
uint32_t uniqueID () const
 
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 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
 

Additional Inherited Members

- Public Types inherited from SkSpecialImage
typedef void * ReleaseContext
 
typedef void(* RasterReleaseProc) (void *pixels, ReleaseContext)
 
- Protected Member Functions inherited from SkSpecialImage
 SkSpecialImage (const SkIRect &subset, uint32_t uniqueID, const SkColorInfo &, const SkSurfaceProps &)
 

Detailed Description

Definition at line 76 of file SkSpecialImage.cpp.

Constructor & Destructor Documentation

◆ SkSpecialImage_Raster()

SkSpecialImage_Raster::SkSpecialImage_Raster ( const SkIRect subset,
const SkBitmap bm,
const SkSurfaceProps props 
)
inline

Definition at line 78 of file SkSpecialImage.cpp.

80 , fBitmap(bm) {
81 SkASSERT(bm.pixelRef());
82 SkASSERT(fBitmap.getPixels());
83 }
#define SkASSERT(cond)
Definition SkAssert.h:116
SkPixelRef * pixelRef() const
Definition SkBitmap.h:720
void * getPixels() const
Definition SkBitmap.h:283
const SkImageInfo & info() const
Definition SkBitmap.h:139
uint32_t getGenerationID() const
Definition SkBitmap.cpp:361
const SkIRect & subset() const
const SkSurfaceProps & props() const
const SkColorInfo & colorInfo() const

Member Function Documentation

◆ asImage()

sk_sp< SkImage > SkSpecialImage_Raster::asImage ( ) const
inlineoverridevirtual

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().

Implements SkSpecialImage.

Definition at line 93 of file SkSpecialImage.cpp.

93{ return fBitmap.asImage(); }
sk_sp< SkImage > asImage() const
Definition SkBitmap.cpp:645

◆ asShader()

sk_sp< SkShader > SkSpecialImage_Raster::asShader ( SkTileMode  tileMode,
const SkSamplingOptions sampling,
const SkMatrix lm,
bool  strict 
) const
inlineoverridevirtual

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 from SkSpecialImage.

Definition at line 100 of file SkSpecialImage.cpp.

103 {
104 if (strict) {
105 // TODO(skbug.com/12784): SkImage::makeShader() doesn't support a subset yet, but
106 // SkBitmap supports subset views so create the shader from the subset bitmap instead of
107 // fBitmap.
108 SkBitmap subsetBM;
109 if (!this->getROPixels(&subsetBM)) {
110 return nullptr;
111 }
112 return subsetBM.makeShader(tileMode, tileMode, sampling, lm);
113 } else {
114 // The special image's logical (0,0) is at its subset's topLeft() so we need to
115 // account for that in the local matrix used when sampling.
116 SkMatrix subsetOrigin = SkMatrix::Translate(-this->subset().topLeft());
117 subsetOrigin.postConcat(lm);
118 return fBitmap.makeShader(tileMode, tileMode, sampling, subsetOrigin);
119 }
120 }
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition SkBitmap.cpp:669
SkMatrix & postConcat(const SkMatrix &other)
Definition SkMatrix.cpp:683
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition SkMatrix.h:91
bool getROPixels(SkBitmap *bm) const

◆ backingStoreDimensions()

SkISize SkSpecialImage_Raster::backingStoreDimensions ( ) const
inlineoverridevirtual

Implements SkSpecialImage.

Definition at line 89 of file SkSpecialImage.cpp.

89{ return fBitmap.dimensions(); }
SkISize dimensions() const
Definition SkBitmap.h:388

◆ getROPixels()

bool SkSpecialImage_Raster::getROPixels ( SkBitmap bm) const
inline

Definition at line 85 of file SkSpecialImage.cpp.

85 {
86 return fBitmap.extractSubset(bm, this->subset());
87 }
bool extractSubset(SkBitmap *dst, const SkIRect &subset) const
Definition SkBitmap.cpp:453

◆ getSize()

size_t SkSpecialImage_Raster::getSize ( ) const
inlineoverridevirtual

Implements SkSpecialImage.

Definition at line 91 of file SkSpecialImage.cpp.

91{ return fBitmap.computeByteSize(); }
size_t computeByteSize() const
Definition SkBitmap.h:293

◆ onMakeBackingStoreSubset()

sk_sp< SkSpecialImage > SkSpecialImage_Raster::onMakeBackingStoreSubset ( const SkIRect subset) const
inlineoverridevirtual

Implements SkSpecialImage.

Definition at line 95 of file SkSpecialImage.cpp.

95 {
96 // No need to extract subset, onGetROPixels handles that when needed
97 return SkSpecialImages::MakeFromRaster(subset, fBitmap, this->props());
98 }

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