Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
SkBitmapDevice Class Reference

#include <SkBitmapDevice.h>

Inheritance diagram for SkBitmapDevice:
SkDevice SkRefCnt SkRefCntBase

Classes

class  BDDraw
 

Public Member Functions

 SkBitmapDevice (const SkBitmap &bitmap)
 
 SkBitmapDevice (const SkBitmap &bitmap, const SkSurfaceProps &surfaceProps, void *externalHandle=nullptr)
 
void drawPaint (const SkPaint &paint) override
 
void drawPoints (SkCanvas::PointMode mode, size_t count, const SkPoint[], const SkPaint &paint) override
 
void drawRect (const SkRect &r, const SkPaint &paint) override
 
void drawOval (const SkRect &oval, const SkPaint &paint) override
 
void drawRRect (const SkRRect &rr, const SkPaint &paint) override
 
void drawPath (const SkPath &, const SkPaint &, bool pathIsMutable) override
 
void drawImageRect (const SkImage *, const SkRect *src, const SkRect &dst, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint) override
 
void drawVertices (const SkVertices *, sk_sp< SkBlender >, const SkPaint &, bool) override
 
void drawMesh (const SkMesh &, sk_sp< SkBlender >, const SkPaint &) override
 
void drawAtlas (const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp< SkBlender >, const SkPaint &) override
 
void pushClipStack () override
 
void popClipStack () override
 
void clipRect (const SkRect &rect, SkClipOp, bool aa) override
 
void clipRRect (const SkRRect &rrect, SkClipOp, bool aa) override
 
void clipPath (const SkPath &path, SkClipOp, bool aa) override
 
void clipRegion (const SkRegion &deviceRgn, SkClipOp) override
 
void replaceClip (const SkIRect &rect) override
 
bool isClipAntiAliased () const override
 
bool isClipEmpty () const override
 
bool isClipRect () const override
 
bool isClipWideOpen () const override
 
void android_utils_clipAsRgn (SkRegion *) const override
 
SkIRect devClipBounds () const override
 
void drawSpecial (SkSpecialImage *, const SkMatrix &, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint) override
 
sk_sp< SkSpecialImagemakeSpecial (const SkBitmap &) override
 
sk_sp< SkSpecialImagemakeSpecial (const SkImage *) override
 
sk_sp< SkSpecialImagesnapSpecial (const SkIRect &, bool forceCopy=false) override
 
sk_sp< SkDevicecreateDevice (const CreateInfo &, const SkPaint *) override
 
sk_sp< SkSurfacemakeSurface (const SkImageInfo &, const SkSurfaceProps &) override
 
void setImmutable () override
 
void * getRasterHandle () const override
 
- Public Member Functions inherited from SkDevice
 SkDevice (const SkImageInfo &, const SkSurfaceProps &)
 
const SkImageInfoimageInfo () const
 
int width () const
 
int height () const
 
bool isOpaque () const
 
SkIRect bounds () const
 
SkISize size () const
 
const SkSurfacePropssurfaceProps () const
 
SkScalerContextFlags scalerContextFlags () const
 
virtual SkStrikeDeviceInfo strikeDeviceInfo () const
 
bool writePixels (const SkPixmap &src, int x, int y)
 
bool readPixels (const SkPixmap &dst, int x, int y)
 
bool accessPixels (SkPixmap *pmap)
 
bool peekPixels (SkPixmap *)
 
const SkM44localToDevice44 () const
 
const SkMatrixlocalToDevice () const
 
const SkM44deviceToGlobal () const
 
const SkM44globalToDevice () const
 
SkIPoint getOrigin () const
 
bool isPixelAlignedToGlobal () const
 
SkMatrix getRelativeTransform (const SkDevice &) const
 
void setLocalToDevice (const SkM44 &localToDevice)
 
void setGlobalCTM (const SkM44 &ctm)
 
void getGlobalBounds (SkIRect *bounds) const
 
SkIRect getGlobalBounds () const
 
virtual SkIRect devClipBounds () const =0
 
virtual void pushClipStack ()=0
 
virtual void popClipStack ()=0
 
virtual void clipRect (const SkRect &rect, SkClipOp op, bool aa)=0
 
virtual void clipRRect (const SkRRect &rrect, SkClipOp op, bool aa)=0
 
virtual void clipPath (const SkPath &path, SkClipOp op, bool aa)=0
 
virtual void clipRegion (const SkRegion &region, SkClipOp op)=0
 
void clipShader (sk_sp< SkShader > sh, SkClipOp op)
 
virtual void replaceClip (const SkIRect &rect)=0
 
virtual bool isClipAntiAliased () const =0
 
virtual bool isClipEmpty () const =0
 
virtual bool isClipRect () const =0
 
virtual bool isClipWideOpen () const =0
 
virtual void android_utils_clipAsRgn (SkRegion *) const =0
 
virtual bool android_utils_clipWithStencil ()
 
virtual bool useDrawCoverageMaskForMaskFilters () const
 
virtual bool isNoPixelsDevice () const
 
virtual void * getRasterHandle () const
 
virtual GrRecordingContextrecordingContext () const
 
virtual skgpu::graphite::Recorderrecorder () const
 
virtual skgpu::ganesh::DeviceasGaneshDevice ()
 
virtual skgpu::graphite::DeviceasGraphiteDevice ()
 
virtual void setImmutable ()
 
virtual sk_sp< SkSurfacemakeSurface (const SkImageInfo &, const SkSurfaceProps &)
 
virtual sk_sp< SkDevicecreateDevice (const CreateInfo &, const SkPaint *)
 
void drawGlyphRunList (SkCanvas *, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
 
virtual sk_sp< sktext::gpu::SlugconvertGlyphRunListToSlug (const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
 
virtual void drawSlug (SkCanvas *, const sktext::gpu::Slug *slug, const SkPaint &paint)
 
virtual void drawPaint (const SkPaint &paint)=0
 
virtual void drawPoints (SkCanvas::PointMode mode, size_t count, const SkPoint[], const SkPaint &paint)=0
 
virtual void drawRect (const SkRect &r, const SkPaint &paint)=0
 
virtual void drawRegion (const SkRegion &r, const SkPaint &paint)
 
virtual void drawOval (const SkRect &oval, const SkPaint &paint)=0
 
virtual void drawArc (const SkArc &arc, const SkPaint &paint)
 
virtual void drawRRect (const SkRRect &rr, const SkPaint &paint)=0
 
virtual void drawDRRect (const SkRRect &outer, const SkRRect &inner, const SkPaint &)
 
virtual void drawPath (const SkPath &path, const SkPaint &paint, bool pathIsMutable=false)=0
 
virtual void drawImageRect (const SkImage *, const SkRect *src, const SkRect &dst, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint)=0
 
virtual bool shouldDrawAsTiledImageRect () const
 
virtual bool drawAsTiledImageRect (SkCanvas *, const SkImage *, const SkRect *src, const SkRect &dst, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint)
 
virtual void drawImageLattice (const SkImage *, const SkCanvas::Lattice &, const SkRect &dst, SkFilterMode, const SkPaint &)
 
virtual void drawVertices (const SkVertices *, sk_sp< SkBlender >, const SkPaint &, bool skipColorXform=false)=0
 
virtual void drawMesh (const SkMesh &mesh, sk_sp< SkBlender >, const SkPaint &)=0
 
virtual void drawShadow (const SkPath &, const SkDrawShadowRec &)
 
virtual void drawPatch (const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], sk_sp< SkBlender >, const SkPaint &paint)
 
virtual void drawAtlas (const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp< SkBlender >, const SkPaint &)
 
virtual void drawAnnotation (const SkRect &, const char[], SkData *)
 
virtual void drawEdgeAAQuad (const SkRect &rect, const SkPoint clip[4], SkCanvas::QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode)
 
virtual void drawEdgeAAImageSet (const SkCanvas::ImageSetEntry[], int count, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint)
 
virtual void drawDrawable (SkCanvas *, SkDrawable *, const SkMatrix *)
 
virtual sk_sp< SkSpecialImagesnapSpecial (const SkIRect &subset, bool forceCopy=false)
 
virtual sk_sp< SkSpecialImagesnapSpecialScaled (const SkIRect &subset, const SkISize &dstDims)
 
sk_sp< SkSpecialImagesnapSpecial ()
 
virtual void drawDevice (SkDevice *, const SkSamplingOptions &, const SkPaint &)
 
virtual void drawSpecial (SkSpecialImage *, const SkMatrix &localToDevice, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint constraint=SkCanvas::kStrict_SrcRectConstraint)
 
virtual void drawCoverageMask (const SkSpecialImage *, const SkMatrix &maskToDevice, const SkSamplingOptions &, const SkPaint &)
 
virtual bool drawBlurredRRect (const SkRRect &, const SkPaint &, float deviceSigma)
 
void drawFilteredImage (const skif::Mapping &mapping, SkSpecialImage *src, SkColorType ct, const SkImageFilter *, const SkSamplingOptions &, const SkPaint &)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< SkBitmapDeviceCreate (const SkImageInfo &, const SkSurfaceProps &, SkRasterHandleAllocator *=nullptr)
 

Friends

class SkDraw
 
class SkDrawBase
 
class SkDrawTiler
 
class SkSurface_Raster
 

Additional Inherited Members

- Protected Member Functions inherited from SkDevice
virtual sk_sp< SkSpecialImagemakeSpecial (const SkBitmap &)
 
virtual sk_sp< SkSpecialImagemakeSpecial (const SkImage *)
 
void setDeviceCoordinateSystem (const SkM44 &deviceToGlobal, const SkM44 &globalToDevice, const SkM44 &localToDevice, int bufferOriginX, int bufferOriginY)
 
void setOrigin (const SkM44 &globalCTM, int x, int y)
 
bool checkLocalToDeviceDirty ()
 

Detailed Description

Definition at line 45 of file SkBitmapDevice.h.

Constructor & Destructor Documentation

◆ SkBitmapDevice() [1/2]

SkBitmapDevice::SkBitmapDevice ( const SkBitmap bitmap)

Construct a new device with the specified bitmap as its backend. It is valid for the bitmap to have no pixels associated with it. In that case, any drawing to this device will have no effect.

Definition at line 230 of file SkBitmapDevice.cpp.

231 : SkDevice(bitmap.info(), SkSurfaceProps())
232 , fBitmap(bitmap)
233 , fRCStack(bitmap.width(), bitmap.height())
234 , fGlyphPainter(this->surfaceProps(), bitmap.colorType(), bitmap.colorSpace()) {
235 SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr));
236}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static bool valid_for_bitmap_device(const SkImageInfo &info, SkAlphaType *newAlphaType)
SkColorType colorType() const
Definition: SkBitmap.h:160
SkDevice(const SkImageInfo &, const SkSurfaceProps &)
Definition: SkDevice.cpp:45
const SkSurfaceProps & surfaceProps() const
Definition: SkDevice.h:131
Definition: bitmap.py:1

◆ SkBitmapDevice() [2/2]

SkBitmapDevice::SkBitmapDevice ( const SkBitmap bitmap,
const SkSurfaceProps surfaceProps,
void *  externalHandle = nullptr 
)

Construct a new device with the specified bitmap as its backend. It is valid for the bitmap to have no pixels associated with it. In that case, any drawing to this device will have no effect.

Member Function Documentation

◆ android_utils_clipAsRgn()

void SkBitmapDevice::android_utils_clipAsRgn ( SkRegion rgn) const
overridevirtual

Implements SkDevice.

Definition at line 681 of file SkBitmapDevice.cpp.

681 {
682 const SkRasterClip& rc = fRCStack.rc();
683 if (rc.isAA()) {
684 rgn->setRect( rc.getBounds());
685 } else {
686 *rgn = rc.bwRgn();
687 }
688}
const SkRasterClip & rc() const
bool setRect(const SkIRect &rect)
Definition: SkRegion.cpp:192

◆ clipPath()

void SkBitmapDevice::clipPath ( const SkPath path,
SkClipOp  op,
bool  aa 
)
overridevirtual

Implements SkDevice.

Definition at line 634 of file SkBitmapDevice.cpp.

634 {
635 fRCStack.clipPath(this->localToDevice(), path, op, aa);
636}
const SkMatrix & localToDevice() const
Definition: SkDevice.h:179
void clipPath(const SkMatrix &ctm, const SkPath &path, SkClipOp op, bool aa)

◆ clipRect()

void SkBitmapDevice::clipRect ( const SkRect rect,
SkClipOp  op,
bool  aa 
)
overridevirtual

Implements SkDevice.

Definition at line 626 of file SkBitmapDevice.cpp.

626 {
627 fRCStack.clipRect(this->localToDevice(), rect, op, aa);
628}
void clipRect(const SkMatrix &ctm, const SkRect &rect, SkClipOp op, bool aa)

◆ clipRegion()

void SkBitmapDevice::clipRegion ( const SkRegion deviceRgn,
SkClipOp  op 
)
overridevirtual

Implements SkDevice.

Definition at line 642 of file SkBitmapDevice.cpp.

642 {
643 SkIPoint origin = this->getOrigin();
644 SkRegion tmp;
645 const SkRegion* ptr = &rgn;
646 if (origin.fX | origin.fY) {
647 // translate from "global/canvas" coordinates to relative to this device
648 rgn.translate(-origin.fX, -origin.fY, &tmp);
649 ptr = &tmp;
650 }
651 fRCStack.clipRegion(*ptr, op);
652}
SkIPoint getOrigin() const
Definition: SkDevice.cpp:91
void clipRegion(const SkRegion &rgn, SkClipOp op)
void translate(int dx, int dy)
Definition: SkRegion.h:349
int32_t fX
x-axis value
Definition: SkPoint_impl.h:29
int32_t fY
y-axis value
Definition: SkPoint_impl.h:30

◆ clipRRect()

void SkBitmapDevice::clipRRect ( const SkRRect rrect,
SkClipOp  op,
bool  aa 
)
overridevirtual

Implements SkDevice.

Definition at line 630 of file SkBitmapDevice.cpp.

630 {
631 fRCStack.clipRRect(this->localToDevice(), rrect, op, aa);
632}
void clipRRect(const SkMatrix &ctm, const SkRRect &rrect, SkClipOp op, bool aa)

◆ Create()

sk_sp< SkBitmapDevice > SkBitmapDevice::Create ( const SkImageInfo origInfo,
const SkSurfaceProps surfaceProps,
SkRasterHandleAllocator allocator = nullptr 
)
static

Definition at line 248 of file SkBitmapDevice.cpp.

250 {
251 SkAlphaType newAT = origInfo.alphaType();
252 if (!valid_for_bitmap_device(origInfo, &newAT)) {
253 return nullptr;
254 }
255
256 SkRasterHandleAllocator::Handle hndl = nullptr;
257 const SkImageInfo info = origInfo.makeAlphaType(newAT);
259
260 if (kUnknown_SkColorType == info.colorType()) {
261 if (!bitmap.setInfo(info)) {
262 return nullptr;
263 }
264 } else if (allocator) {
265 hndl = allocator->allocBitmap(info, &bitmap);
266 if (!hndl) {
267 return nullptr;
268 }
269 } else if (info.isOpaque()) {
270 // If this bitmap is opaque, we don't have any sensible default color,
271 // so we just return uninitialized pixels.
272 if (!bitmap.tryAllocPixels(info)) {
273 return nullptr;
274 }
275 } else {
276 // This bitmap has transparency, so we'll zero the pixels (to transparent).
277 // We use the flag as a faster alloc-then-eraseColor(SK_ColorTRANSPARENT).
278 if (!bitmap.tryAllocPixelsFlags(info, SkBitmap::kZeroPixels_AllocFlag)) {
279 return nullptr;
280 }
281 }
282
283 return sk_make_sp<SkBitmapDevice>(bitmap, surfaceProps, hndl);
284}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
SkAlphaType
Definition: SkAlphaType.h:26
@ kUnknown_SkColorType
uninitialized
Definition: SkColorType.h:20
@ kZeroPixels_AllocFlag
zero pixel memory. No effect. This is the default.
Definition: SkBitmap.h:435
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
Definition: SkImageInfo.h:466
SkAlphaType alphaType() const
Definition: SkImageInfo.h:375

◆ createDevice()

sk_sp< SkDevice > SkBitmapDevice::createDevice ( const CreateInfo ,
const SkPaint  
)
overridevirtual

Create a new device based on CreateInfo. If the paint is not null, then it represents a preview of how the new device will be composed with its creator device (this).

The subclass may be handed this device in drawDevice(), so it must always return a device that it knows how to draw, and that it knows how to identify if it is not of the same subclass (since drawDevice is passed a SkDevice*). If the subclass cannot fulfill that contract (e.g. PDF cannot support some settings on the paint) it should return NULL, and the caller may then decide to explicitly create a bitmapdevice, knowing that later it could not call drawDevice with it (but it could call drawSprite or drawBitmap).

Reimplemented from SkDevice.

Definition at line 292 of file SkBitmapDevice.cpp.

292 {
294 this->surfaceProps().cloneWithPixelGeometry(cinfo.fPixelGeometry);
295
296 // Need to force L32 for now if we have an image filter.
297 // If filters ever support other colortypes, e.g. F16, we can modify this check.
298 SkImageInfo info = cinfo.fInfo;
299 if (layerPaint && layerPaint->getImageFilter()) {
300 // TODO: can we query the imagefilter, to see if it can handle floats (so we don't always
301 // use N32 when the layer itself was float)?
302 info = info.makeColorType(kN32_SkColorType);
303 }
304
305 return SkBitmapDevice::Create(info, surfaceProps, cinfo.fAllocator);
306}
static sk_sp< SkBitmapDevice > Create(const SkImageInfo &, const SkSurfaceProps &, SkRasterHandleAllocator *=nullptr)
SkSurfaceProps cloneWithPixelGeometry(SkPixelGeometry newPixelGeometry) const

◆ devClipBounds()

SkIRect SkBitmapDevice::devClipBounds ( ) const
overridevirtual

Returns the bounding box of the current clip, in this device's coordinate space. No pixels outside of these bounds will be touched by draws unless the clip is further modified (at which point this will return the updated bounds).

Implements SkDevice.

Definition at line 690 of file SkBitmapDevice.cpp.

690 {
691 return fRCStack.rc().getBounds();
692}
const SkIRect & getBounds() const
Definition: SkRasterClip.h:60

◆ drawAtlas()

void SkBitmapDevice::drawAtlas ( const SkRSXform  xform[],
const SkRect  tex[],
const SkColor  colors[],
int  count,
sk_sp< SkBlender blender,
const SkPaint paint 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 555 of file SkBitmapDevice.cpp.

560 {
561 // set this to true for performance comparisons with the old drawVertices way
562 if ((false)) {
563 this->SkDevice::drawAtlas(xform, tex, colors, count, std::move(blender), paint);
564 return;
565 }
566 BDDraw(this).drawAtlas(xform, tex, colors, count, std::move(blender), paint);
567}
int count
Definition: FontMgrTest.cpp:50
virtual void drawAtlas(const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp< SkBlender >, const SkPaint &)
Definition: SkDevice.cpp:203
const Paint & paint
Definition: color_source.cc:38
PODArray< SkColor > colors
Definition: SkRecords.h:276

◆ drawImageRect()

void SkBitmapDevice::drawImageRect ( const SkImage image,
const SkRect src,
const SkRect dst,
const SkSamplingOptions sampling,
const SkPaint paint,
SkCanvas::SrcRectConstraint  constraint 
)
overridevirtual

Implements SkDevice.

Definition at line 414 of file SkBitmapDevice.cpp.

416 {
417 SkASSERT(dst.isFinite());
418 SkASSERT(dst.isSorted());
419
421 // TODO: Elevate direct context requirement to public API and remove cheat.
422 auto dContext = as_IB(image)->directContext();
423 if (!as_IB(image)->getROPixels(dContext, &bitmap)) {
424 return;
425 }
426
427 SkRect bitmapBounds, tmpSrc, tmpDst;
428 SkBitmap tmpBitmap;
429
430 bitmapBounds.setIWH(bitmap.width(), bitmap.height());
431
432 // Compute matrix from the two rectangles
433 if (src) {
434 tmpSrc = *src;
435 } else {
436 tmpSrc = bitmapBounds;
437 }
439
440 const SkRect* dstPtr = &dst;
441 const SkBitmap* bitmapPtr = &bitmap;
442
443 // clip the tmpSrc to the bounds of the bitmap, and recompute dstRect if
444 // needed (if the src was clipped). No check needed if src==null.
445 bool srcIsSubset = false;
446 if (src) {
447 if (!bitmapBounds.contains(*src)) {
448 if (!tmpSrc.intersect(bitmapBounds)) {
449 return; // nothing to draw
450 }
451 // recompute dst, based on the smaller tmpSrc
452 matrix.mapRect(&tmpDst, tmpSrc);
453 if (!tmpDst.isFinite()) {
454 return;
455 }
456 dstPtr = &tmpDst;
457 }
458 srcIsSubset = !tmpSrc.contains(bitmapBounds);
459 }
460
461 if (srcIsSubset &&
462 SkCanvas::kFast_SrcRectConstraint == constraint &&
464 // src is smaller than the bounds of the bitmap, and we are filtering, so we don't know
465 // how much more of the bitmap we need, so we can't use extractSubset or drawBitmap,
466 // but we must use a shader w/ dst bounds (which can access all of the bitmap needed).
467 goto USE_SHADER;
468 }
469
470 if (srcIsSubset) {
471 // since we may need to clamp to the borders of the src rect within
472 // the bitmap, we extract a subset.
473 const SkIRect srcIR = tmpSrc.roundOut();
474 if (!bitmap.extractSubset(&tmpBitmap, srcIR)) {
475 return;
476 }
477 bitmapPtr = &tmpBitmap;
478
479 // Since we did an extract, we need to adjust the matrix accordingly
480 SkScalar dx = 0, dy = 0;
481 if (srcIR.fLeft > 0) {
482 dx = SkIntToScalar(srcIR.fLeft);
483 }
484 if (srcIR.fTop > 0) {
485 dy = SkIntToScalar(srcIR.fTop);
486 }
487 if (dx || dy) {
488 matrix.preTranslate(dx, dy);
489 }
490
491#ifdef SK_DRAWBITMAPRECT_FAST_OFFSET
492 SkRect extractedBitmapBounds = SkRect::MakeXYWH(dx, dy,
493 SkIntToScalar(bitmapPtr->width()),
494 SkIntToScalar(bitmapPtr->height()));
495#else
496 SkRect extractedBitmapBounds;
497 extractedBitmapBounds.setIWH(bitmapPtr->width(), bitmapPtr->height());
498#endif
499 if (extractedBitmapBounds == tmpSrc) {
500 // no fractional part in src, we can just call drawBitmap
501 goto USE_DRAWBITMAP;
502 }
503 } else {
504 USE_DRAWBITMAP:
505 // We can go faster by just calling drawBitmap, which will concat the
506 // matrix with the CTM, and try to call drawSprite if it can. If not,
507 // it will make a shader and call drawRect, as we do below.
509 this->drawBitmap(*bitmapPtr, matrix, dstPtr, sampling, paint);
510 return;
511 }
512 }
513
514 USE_SHADER:
515
516 // construct a shader, so we can call drawRect with the dst
519 if (!s) {
520 return;
521 }
522
523 SkPaint paintWithShader(paint);
524 paintWithShader.setStyle(SkPaint::kFill_Style);
525 paintWithShader.setShader(std::move(s));
526
527 // Call ourself, in case the subclass wanted to share this setup code
528 // but handle the drawRect code themselves.
529 this->drawRect(*dstPtr, paintWithShader);
530}
static bool CanApplyDstMatrixAsCTM(const SkMatrix &m, const SkPaint &paint)
@ kNever_SkCopyPixelsMode
never copy src pixels (even if they are marked mutable)
Definition: SkImagePriv.h:20
sk_sp< SkShader > SkMakeBitmapShaderForPaint(const SkPaint &paint, const SkBitmap &src, SkTileMode, SkTileMode, const SkSamplingOptions &, const SkMatrix *localMatrix, SkCopyPixelsMode)
static SkImage_Base * as_IB(SkImage *image)
Definition: SkImage_Base.h:201
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawRect(const SkRect &r, const SkPaint &paint) override
int width() const
Definition: SkBitmap.h:149
int height() const
Definition: SkBitmap.h:158
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition: SkCanvas.h:1543
virtual GrDirectContext * directContext() const
Definition: SkImage_Base.h:115
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
Definition: SkMatrix.h:157
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
float SkScalar
Definition: extension.cpp:12
struct MyStruct s
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
sk_sp< const SkImage > image
Definition: SkRecords.h:269
SkSamplingOptions sampling
Definition: SkRecords.h:337
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
dst
Definition: cp.py:12
SkSamplingOptions(SkFilterMode::kLinear))
Definition: SkRect.h:32
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
bool isFinite() const
Definition: SkRect.h:711
bool intersect(const SkRect &r)
Definition: SkRect.cpp:114
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659
bool contains(SkScalar x, SkScalar y) const
Definition: extension.cpp:19
void roundOut(SkIRect *dst) const
Definition: SkRect.h:1241
void setIWH(int32_t width, int32_t height)
Definition: SkRect.h:950

◆ drawMesh()

void SkBitmapDevice::drawMesh ( const SkMesh ,
sk_sp< SkBlender ,
const SkPaint  
)
overridevirtual

Implements SkDevice.

Definition at line 551 of file SkBitmapDevice.cpp.

551 {
552 // TODO(brianosman): Implement, maybe with a subclass of BitmapDevice that has SkSL support.
553}

◆ drawOval()

void SkBitmapDevice::drawOval ( const SkRect oval,
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 357 of file SkBitmapDevice.cpp.

357 {
358 // call the VIRTUAL version, so any subclasses who do handle drawPath aren't
359 // required to override drawOval.
360 this->drawPath(SkPath::Oval(oval), paint, true);
361}
void drawPath(const SkPath &, const SkPaint &, bool pathIsMutable) override
static SkPath Oval(const SkRect &, SkPathDirection=SkPathDirection::kCW)
Definition: SkPath.cpp:3590

◆ drawPaint()

void SkBitmapDevice::drawPaint ( const SkPaint paint)
overridevirtual

Implements SkDevice.

Definition at line 344 of file SkBitmapDevice.cpp.

344 {
345 BDDraw(this).drawPaint(paint);
346}

◆ drawPath()

void SkBitmapDevice::drawPath ( const SkPath path,
const SkPaint paint,
bool  pathIsMutable 
)
overridevirtual

If pathIsMutable, then the implementation is allowed to cast path to a non-const pointer and modify it in place (as an optimization). Canvas may do this to implement helpers such as drawOval, by placing a temp path on the stack to hold the representation of the oval.

Implements SkDevice.

Definition at line 373 of file SkBitmapDevice.cpp.

375 {
376 const SkRect* bounds = nullptr;
377 if (SkDrawTiler::NeedsTiling(this) && !path.isInverseFillType()) {
378 bounds = &path.getBounds();
379 }
380 SkDrawTiler tiler(this, bounds ? Bounder(*bounds, paint).bounds() : nullptr);
381 if (tiler.needsTiling()) {
382 pathIsMutable = false;
383 }
384 while (const SkDraw* draw = tiler.next()) {
385 draw->drawPath(path, paint, nullptr, pathIsMutable);
386 }
387}
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
SkIRect bounds() const
Definition: SkDevice.h:125
static bool NeedsTiling(SkBitmapDevice *dev)
Definition: SkDraw.h:38
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57

◆ drawPoints()

void SkBitmapDevice::drawPoints ( SkCanvas::PointMode  mode,
size_t  count,
const SkPoint  pts[],
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 348 of file SkBitmapDevice.cpp.

349 {
350 LOOP_TILER( drawPoints(mode, count, pts, paint, nullptr), nullptr)
351}
#define LOOP_TILER(code, boundsPtr)
void drawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint[], const SkPaint &paint) override
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ drawRect()

void SkBitmapDevice::drawRect ( const SkRect r,
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 353 of file SkBitmapDevice.cpp.

353 {
355}

◆ drawRRect()

void SkBitmapDevice::drawRRect ( const SkRRect rr,
const SkPaint paint 
)
overridevirtual

Implements SkDevice.

Definition at line 363 of file SkBitmapDevice.cpp.

363 {
364#ifdef SK_IGNORE_BLURRED_RRECT_OPT
365 // call the VIRTUAL version, so any subclasses who do handle drawPath aren't
366 // required to override drawRRect.
367 this->drawPath(SkPath::RRect(rrect), paint, true);
368#else
370#endif
371}
void drawRRect(const SkRRect &rr, const SkPaint &paint) override
static SkPath RRect(const SkRRect &, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:3602
const SkRect & getBounds() const
Definition: SkRRect.h:279
SkRRect rrect
Definition: SkRecords.h:232

◆ drawSpecial()

void SkBitmapDevice::drawSpecial ( SkSpecialImage ,
const SkMatrix localToDevice,
const SkSamplingOptions ,
const SkPaint ,
SkCanvas::SrcRectConstraint  constraint 
)
overridevirtual

Draw the special image's subset to this device, subject to the given matrix transform instead of the device's current local to device matrix.

If 'constraint' is kFast, the rendered geometry of the image still reflects the extent of the SkSpecialImage's subset, but it's assumed that the pixel data beyond the subset is valid (e.g. SkSpecialImage::makeSubset() was called to crop a larger image).

Reimplemented from SkDevice.

Definition at line 571 of file SkBitmapDevice.cpp.

575 {
576 SkASSERT(!paint.getImageFilter());
577 SkASSERT(!paint.getMaskFilter());
578 SkASSERT(!src->isGaneshBacked());
579 SkASSERT(!src->isGraphiteBacked());
580
581 SkBitmap resultBM;
582 if (SkSpecialImages::AsBitmap(src, &resultBM)) {
583 SkDraw draw;
584 if (!this->accessPixels(&draw.fDst)) {
585 return; // no pixels to draw to so skip it
586 }
587 draw.fCTM = &localToDevice;
588 draw.fRC = &fRCStack.rc();
589 draw.drawBitmap(resultBM, SkMatrix::I(), nullptr, sampling, paint);
590 }
591}
bool accessPixels(SkPixmap *pmap)
Definition: SkDevice.cpp:383
SkPixmap fDst
Definition: SkDrawBase.h:153
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
bool AsBitmap(const SkSpecialImage *img, SkBitmap *result)

◆ drawVertices()

void SkBitmapDevice::drawVertices ( const SkVertices ,
sk_sp< SkBlender ,
const SkPaint ,
bool  skipColorXform 
)
overridevirtual

If skipColorXform is true, then the implementation should assume that the provided vertex colors are already in the destination color space.

Implements SkDevice.

Definition at line 539 of file SkBitmapDevice.cpp.

542 {
543#ifdef SK_LEGACY_IGNORE_DRAW_VERTICES_BLEND_WITH_NO_SHADER
544 if (!paint.getShader()) {
546 }
547#endif
548 BDDraw(this).drawVertices(vertices, std::move(blender), paint, skipColorXform);
549}
static sk_sp< SkBlender > Mode(SkBlendMode mode)

◆ getRasterHandle()

void * SkBitmapDevice::getRasterHandle ( ) const
inlineoverridevirtual

Reimplemented from SkDevice.

Definition at line 116 of file SkBitmapDevice.h.

116{ return fRasterHandle; }

◆ isClipAntiAliased()

bool SkBitmapDevice::isClipAntiAliased ( ) const
overridevirtual

Implements SkDevice.

Definition at line 676 of file SkBitmapDevice.cpp.

676 {
677 const SkRasterClip& rc = fRCStack.rc();
678 return !rc.isEmpty() && rc.isAA();
679}

◆ isClipEmpty()

bool SkBitmapDevice::isClipEmpty ( ) const
overridevirtual

Implements SkDevice.

Definition at line 667 of file SkBitmapDevice.cpp.

667 {
668 return fRCStack.rc().isEmpty();
669}
bool isEmpty() const
Definition: SkRasterClip.h:47

◆ isClipRect()

bool SkBitmapDevice::isClipRect ( ) const
overridevirtual

Implements SkDevice.

Definition at line 671 of file SkBitmapDevice.cpp.

671 {
672 const SkRasterClip& rc = fRCStack.rc();
673 return !rc.isEmpty() && rc.isRect() && !SkToBool(rc.clipShader());
674}
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35

◆ isClipWideOpen()

bool SkBitmapDevice::isClipWideOpen ( ) const
overridevirtual

Implements SkDevice.

Definition at line 660 of file SkBitmapDevice.cpp.

660 {
661 const SkRasterClip& rc = fRCStack.rc();
662 // If we're AA, we can't be wide-open (we would represent that as BW)
663 return rc.isBW() && rc.bwRgn().isRect() &&
664 rc.bwRgn().getBounds() == SkIRect{0, 0, this->width(), this->height()};
665}
int height() const
Definition: SkDevice.h:120
int width() const
Definition: SkDevice.h:119

◆ makeSpecial() [1/2]

sk_sp< SkSpecialImage > SkBitmapDevice::makeSpecial ( const SkBitmap bitmap)
overridevirtual

Reimplemented from SkDevice.

Definition at line 592 of file SkBitmapDevice.cpp.

592 {
593 return SkSpecialImages::MakeFromRaster(bitmap.bounds(), bitmap, this->surfaceProps());
594}
sk_sp< SkSpecialImage > MakeFromRaster(const SkIRect &subset, const SkBitmap &bm, const SkSurfaceProps &props)

◆ makeSpecial() [2/2]

sk_sp< SkSpecialImage > SkBitmapDevice::makeSpecial ( const SkImage image)
overridevirtual

Reimplemented from SkDevice.

Definition at line 596 of file SkBitmapDevice.cpp.

596 {
599 this->surfaceProps());
600}
int width() const
Definition: SkImage.h:285
sk_sp< SkImage > makeNonTextureImage(GrDirectContext *=nullptr) const
Definition: SkImage.cpp:260
int height() const
Definition: SkImage.h:291
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56

◆ makeSurface()

sk_sp< SkSurface > SkBitmapDevice::makeSurface ( const SkImageInfo info,
const SkSurfaceProps props 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 612 of file SkBitmapDevice.cpp.

612 {
613 return SkSurfaces::Raster(info, &props);
614}
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)

◆ popClipStack()

void SkBitmapDevice::popClipStack ( )
overridevirtual

Implements SkDevice.

Definition at line 622 of file SkBitmapDevice.cpp.

622 {
623 fRCStack.restore();
624}

◆ pushClipStack()

void SkBitmapDevice::pushClipStack ( )
overridevirtual

Implements SkDevice.

Definition at line 618 of file SkBitmapDevice.cpp.

618 {
619 fRCStack.save();
620}

◆ replaceClip()

void SkBitmapDevice::replaceClip ( const SkIRect rect)
overridevirtual

Implements SkDevice.

Definition at line 654 of file SkBitmapDevice.cpp.

654 {
655 // Transform from "global/canvas" coordinates to relative to this device
656 SkRect deviceRect = SkMatrixPriv::MapRect(this->globalToDevice(), SkRect::Make(rect));
657 fRCStack.replaceClip(deviceRect.round());
658}
const SkM44 & globalToDevice() const
Definition: SkDevice.h:191
static SkRect MapRect(const SkM44 &m, const SkRect &r)
Definition: SkM44.cpp:216
void replaceClip(const SkIRect &rect)
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
void round(SkIRect *dst) const
Definition: SkRect.h:1228

◆ setImmutable()

void SkBitmapDevice::setImmutable ( )
inlineoverridevirtual

Reimplemented from SkDevice.

Definition at line 114 of file SkBitmapDevice.h.

114{ fBitmap.setImmutable(); }
void setImmutable()
Definition: SkBitmap.cpp:400

◆ snapSpecial()

sk_sp< SkSpecialImage > SkBitmapDevice::snapSpecial ( const SkIRect bounds,
bool  forceCopy = false 
)
overridevirtual

Reimplemented from SkDevice.

Definition at line 602 of file SkBitmapDevice.cpp.

602 {
603 if (forceCopy) {
604 return SkSpecialImages::CopyFromRaster(bounds, fBitmap, this->surfaceProps());
605 } else {
606 return SkSpecialImages::MakeFromRaster(bounds, fBitmap, this->surfaceProps());
607 }
608}
sk_sp< SkSpecialImage > CopyFromRaster(const SkIRect &subset, const SkBitmap &bm, const SkSurfaceProps &props)

Friends And Related Function Documentation

◆ SkDraw

friend class SkDraw
friend

Definition at line 120 of file SkBitmapDevice.h.

◆ SkDrawBase

friend class SkDrawBase
friend

Definition at line 121 of file SkBitmapDevice.h.

◆ SkDrawTiler

friend class SkDrawTiler
friend

Definition at line 122 of file SkBitmapDevice.h.

◆ SkSurface_Raster

friend class SkSurface_Raster
friend

Definition at line 123 of file SkBitmapDevice.h.


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