Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private 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
 
void clipShader (sk_sp< SkShader > sh, SkClipOp op)
 
virtual bool android_utils_clipWithStencil ()
 
virtual bool useDrawCoverageMaskForMaskFilters () const
 
virtual bool isNoPixelsDevice () const
 
virtual GrRecordingContextrecordingContext () const
 
virtual skgpu::graphite::Recorderrecorder () const
 
virtual skgpu::ganesh::DeviceasGaneshDevice ()
 
virtual skgpu::graphite::DeviceasGraphiteDevice ()
 
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 drawRegion (const SkRegion &r, const SkPaint &paint)
 
virtual void drawArc (const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
 
virtual void drawDRRect (const SkRRect &outer, const SkRRect &inner, const SkPaint &)
 
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 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 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< SkSpecialImagesnapSpecialScaled (const SkIRect &subset, const SkISize &dstDims)
 
sk_sp< SkSpecialImagesnapSpecial ()
 
virtual void drawDevice (SkDevice *, const SkSamplingOptions &, const SkPaint &)
 
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)
 

Private Member Functions

void onClipShader (sk_sp< SkShader >) override
 
void onDrawGlyphRunList (SkCanvas *, const sktext::GlyphRunList &, const SkPaint &paint) override
 
bool onReadPixels (const SkPixmap &, int x, int y) override
 
bool onWritePixels (const SkPixmap &, int, int) override
 
bool onPeekPixels (SkPixmap *) override
 
bool onAccessPixels (SkPixmap *) override
 

Friends

class SkDraw
 
class SkDrawBase
 
class SkDrawTiler
 
class SkSurface_Raster
 

Additional Inherited Members

- Protected Member Functions inherited from SkDevice
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
const SkSurfaceProps & surfaceProps() const
Definition SkDevice.h:131

◆ 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:90
void clipRegion(const SkRegion &rgn, SkClipOp op)
void translate(int dx, int dy)
Definition SkRegion.h:349
int32_t fX
x-axis value
int32_t fY
y-axis value

◆ 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
SkAlphaType alphaType() const

◆ 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
SkImageInfo makeColorType(SkColorType newColorType) 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

◆ 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
virtual void drawAtlas(const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp< SkBlender >, const SkPaint &)
Definition SkDevice.cpp:204
const Paint & paint

◆ 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 }
438 SkMatrix matrix = SkMatrix::RectToRect(tmpSrc, dst);
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 &&
463 sampling != SkSamplingOptions()) {
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.
508 if (CanApplyDstMatrixAsCTM(matrix, paint)) {
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
518 sampling, &matrix, kNever_SkCopyPixelsMode);
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)
#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
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
sk_sp< SkImage > image
Definition examples.cpp:29
float SkScalar
Definition extension.cpp:12
struct MyStruct s
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition SkRecords.h:208
dst
Definition cp.py:12
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:3522

◆ 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
const SkDraw * next()
static bool NeedsTiling(SkBitmapDevice *dev)
bool needsTiling() const
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

◆ 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:3534
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 }
588 draw.fRC = &fRCStack.rc();
589 draw.drawBitmap(resultBM, SkMatrix::I(), nullptr, sampling, paint);
590 }
591}
bool accessPixels(SkPixmap *pmap)
Definition SkDevice.cpp:388
SkPixmap fDst
Definition SkDrawBase.h:151
const SkMatrix * fCTM
Definition SkDrawBase.h:153
static const SkMatrix & I()

◆ 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

◆ 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}

◆ makeSpecial() [2/2]

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

Reimplemented from SkDevice.

Definition at line 596 of file SkBitmapDevice.cpp.

596 {
597 return SkSpecialImages::MakeFromRaster(SkIRect::MakeWH(image->width(), image->height()),
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)

◆ onAccessPixels()

bool SkBitmapDevice::onAccessPixels ( SkPixmap pmap)
overrideprivatevirtual

Reimplemented from SkDevice.

Definition at line 308 of file SkBitmapDevice.cpp.

308 {
309 if (this->onPeekPixels(pmap)) {
310 fBitmap.notifyPixelsChanged();
311 return true;
312 }
313 return false;
314}
bool onPeekPixels(SkPixmap *) override
void notifyPixelsChanged() const
Definition SkBitmap.cpp:365

◆ onClipShader()

void SkBitmapDevice::onClipShader ( sk_sp< SkShader sh)
overrideprivatevirtual

Implements SkDevice.

Definition at line 638 of file SkBitmapDevice.cpp.

638 {
639 fRCStack.clipShader(std::move(sh));
640}
void clipShader(sk_sp< SkShader > sh)

◆ onDrawGlyphRunList()

void SkBitmapDevice::onDrawGlyphRunList ( SkCanvas canvas,
const sktext::GlyphRunList glyphRunList,
const SkPaint paint 
)
overrideprivatevirtual

Implements SkDevice.

Definition at line 532 of file SkBitmapDevice.cpp.

534 {
535 SkASSERT(!glyphRunList.hasRSXForm());
536 LOOP_TILER( drawGlyphRunList(canvas, &fGlyphPainter, glyphRunList, paint), nullptr )
537}
void drawGlyphRunList(SkCanvas *, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
Definition SkDevice.cpp:431
bool hasRSXForm() const
Definition GlyphRun.h:105

◆ onPeekPixels()

bool SkBitmapDevice::onPeekPixels ( SkPixmap pmap)
overrideprivatevirtual

Reimplemented from SkDevice.

Definition at line 316 of file SkBitmapDevice.cpp.

316 {
317 const SkImageInfo info = fBitmap.info();
318 if (fBitmap.getPixels() && (kUnknown_SkColorType != info.colorType())) {
319 pmap->reset(fBitmap.info(), fBitmap.getPixels(), fBitmap.rowBytes());
320 return true;
321 }
322 return false;
323}
size_t rowBytes() const
Definition SkBitmap.h:238
void * getPixels() const
Definition SkBitmap.h:283
const SkImageInfo & info() const
Definition SkBitmap.h:139
void reset()
Definition SkPixmap.cpp:32

◆ onReadPixels()

bool SkBitmapDevice::onReadPixels ( const SkPixmap pm,
int  x,
int  y 
)
overrideprivatevirtual

Reimplemented from SkDevice.

Definition at line 338 of file SkBitmapDevice.cpp.

338 {
339 return fBitmap.readPixels(pm, x, y);
340}
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY) const
Definition SkBitmap.cpp:488
double y
double x

◆ onWritePixels()

bool SkBitmapDevice::onWritePixels ( const SkPixmap pm,
int  x,
int  y 
)
overrideprivatevirtual

Reimplemented from SkDevice.

Definition at line 325 of file SkBitmapDevice.cpp.

325 {
326 // since we don't stop creating un-pixeled devices yet, check for no pixels here
327 if (nullptr == fBitmap.getPixels()) {
328 return false;
329 }
330
331 if (fBitmap.writePixels(pm, x, y)) {
332 fBitmap.notifyPixelsChanged();
333 return true;
334 }
335 return false;
336}
bool writePixels(const SkPixmap &src, int dstX, int dstY)
Definition SkBitmap.cpp:501

◆ 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}

Friends And Related Symbol 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: