46 , fSurfaceProps(surfaceProps) {
52 const SkM44& globalToDevice,
53 const SkM44& localToDevice,
63 if (bufferOriginX | bufferOriginY) {
64 fDeviceToGlobal.
preTranslate(bufferOriginX, bufferOriginY);
65 fGlobalToDevice.
postTranslate(-bufferOriginX, -bufferOriginY);
68 fLocalToDevice33 = fLocalToDevice.
asM33();
69 fLocalToDeviceDirty =
true;
77 fLocalToDevice33 = fLocalToDevice.
asM33();
78 fLocalToDeviceDirty =
true;
87 return pixelAligned == fDeviceToGlobal;
105 return (dstDevice.fGlobalToDevice * fDeviceToGlobal).asM33();
116 paint.getPathEffect();
119 if (isNonTranslate || complexPaint || antiAlias) {
122 path.setIsVolatile(
true);
145 path.addRRect(outer);
146 path.addRRect(inner);
148 path.setIsVolatile(
true);
158 this->imageInfo().colorSpace());
170 bool isFixedColor =
false;
173 while (iter.
next(&srcR, &dstR, &isFixedColor, &c)) {
175 if (isFixedColor || (srcR.
width() <= 1.0f && srcR.
height() <= 1.0f &&
179 if (0 != c || !
paint.isSrcOver()) {
210 const int triCount = quadCount << 1;
211 const int vertexCount = triCount * 3;
218 SkPoint* vPos = builder.positions();
219 SkPoint* vTex = builder.texCoords();
220 SkColor* vCol = builder.colors();
221 for (
int i = 0; i < quadCount; ++i) {
241 paint.setBlendMode(mode);
264 for (
int i = 0; i <
count; ++i) {
272 if (
images[i].fMatrixIndex >= 0) {
287 sampling, entryPaint, constraint);
291 if (images[i].fMatrixIndex >= 0) {
300 drawable->
draw(canvas, matrix);
311 SK_ABORT(
"Must override if useDrawCoverageMaskForMaskFilters() is true");
335#if defined(SK_DONT_PAD_LAYER_IMAGES) || defined(SK_RESOLVE_FILTERS_BEFORE_RESTORE)
390 if (
nullptr == pmap) {
398 if (
nullptr == pmap) {
408 if (!shader || !lm.
invert(&inverse_lm)) {
412#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
422 shader = nested_shader.get();
441 this->simplifyGlyphRunRSXFormAndRedraw(canvas, glyphRunList,
paint);
445void SkDevice::simplifyGlyphRunRSXFormAndRedraw(
SkCanvas* canvas,
449 if (
run.scaledRotations().empty()) {
466 sharedGlyphID = glyphID;
467 auto [scos, ssin] =
run.scaledRotations()[i];
494 SK_ABORT(
"Slug drawing not supported.");
523 std::move(colorSpace)), props) {
541 SkASSERT(fClipStack.
size() == 1 && fClipStack[0].fDeferredSaveCount == 0);
543 fClipStack[0].fClipBounds = this->
bounds();
544 fClipStack[0].fIsAA =
false;
545 fClipStack[0].fIsRect =
true;
553 fClipStack.
back().fDeferredSaveCount++;
558 if (fClipStack.
back().fDeferredSaveCount > 0) {
559 fClipStack.
back().fDeferredSaveCount--;
566SkNoPixelsDevice::ClipState& SkNoPixelsDevice::writableClip() {
568 ClipState& current = fClipStack.
back();
569 if (current.fDeferredSaveCount > 0) {
570 current.fDeferredSaveCount--;
573 bool aa = current.fIsAA;
574 bool rect = current.fIsRect;
593 if (path.isInverseFillType()) {
602 false, globalRgn.
isRect());
606 this->writableClip().fIsRect =
false;
611 if (!deviceRect.
intersect(this->bounds())) {
614 auto& clip = this->writableClip();
615 clip.fClipBounds = deviceRect;
621 bool isAA,
bool fillsBounds) {
628 if (!fClipBounds.intersect(isAA ? devBounds.
roundOut() : devBounds.
round())) {
629 fClipBounds.setEmpty();
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static void round(SkPoint *p)
static bool isFinite(const SkRect &r)
@ kUnknown_SkAlphaType
uninitialized
#define SK_ABORT(message,...)
#define SkAlphaMul(value, alpha256)
static unsigned SkAlpha255To256(U8CPU alpha)
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kUnknown_SkColorType
uninitialized
static constexpr SkColor SkColorSetA(SkColor c, U8CPU a)
#define SkColorGetA(color)
static bool is_int(float x)
static sk_sp< SkShader > make_post_inverse_lm(const SkShader *shader, const SkMatrix &lm)
static SkPoint * quad_to_tris(SkPoint tris[6], const SkPoint quad[4])
constexpr SkEnumerate< Iter > SkMakeEnumerate(C &c)
#define sk_float_round2int(x)
static SkImageFilter_Base * as_IFB(SkImageFilter *filter)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static std::unique_ptr< SkEncoder > Make(SkWStream *dst, const SkPixmap *src, const SkYUVAPixmaps *srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options)
static size_t difference(size_t minuend, size_t subtrahend)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
sk_sp< T > sk_ref_sp(T *obj)
#define SkScalarFloorToScalar(x)
static bool SkScalarIsInt(SkScalar x)
#define SkScalarFloorToInt(x)
@ kFakeGammaAndBoostContrast
SkShaderBase * as_SB(SkShader *shader)
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
@ kFast_SrcRectConstraint
sample outside bounds; faster
void concat(const SkMatrix &matrix)
bool gammaIsLinear() const
void drawFilteredImage(const skif::Mapping &mapping, SkSpecialImage *src, SkColorType ct, const SkImageFilter *, const SkSamplingOptions &, const SkPaint &)
const SkImageInfo & imageInfo() const
virtual void drawVertices(const SkVertices *, sk_sp< SkBlender >, const SkPaint &, bool skipColorXform=false)=0
virtual void drawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], SkCanvas::QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode)
SkScalerContextFlags scalerContextFlags() const
virtual void drawRegion(const SkRegion &r, const SkPaint &paint)
SkIPoint getOrigin() const
SkDevice(const SkImageInfo &, const SkSurfaceProps &)
virtual void drawAtlas(const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp< SkBlender >, const SkPaint &)
virtual void clipPath(const SkPath &path, SkClipOp op, bool aa)=0
void setLocalToDevice(const SkM44 &localToDevice)
virtual bool onAccessPixels(SkPixmap *)
virtual void drawCoverageMask(const SkSpecialImage *, const SkMatrix &maskToDevice, const SkSamplingOptions &, const SkPaint &)
virtual sk_sp< skif::Backend > createImageFilteringBackend(const SkSurfaceProps &surfaceProps, SkColorType colorType) const
void drawGlyphRunList(SkCanvas *, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
virtual void drawEdgeAAImageSet(const SkCanvas::ImageSetEntry[], int count, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint)
const SkM44 & globalToDevice() const
virtual void drawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &)
sk_sp< SkSpecialImage > snapSpecial()
virtual void popClipStack()=0
virtual sk_sp< SkSpecialImage > snapSpecialScaled(const SkIRect &subset, const SkISize &dstDims)
virtual void pushClipStack()=0
bool accessPixels(SkPixmap *pmap)
const SkMatrix & localToDevice() const
virtual void drawSlug(SkCanvas *, const sktext::gpu::Slug *slug, const SkPaint &paint)
void setOrigin(const SkM44 &globalCTM, int x, int y)
virtual void drawSpecial(SkSpecialImage *, const SkMatrix &localToDevice, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint constraint=SkCanvas::kStrict_SrcRectConstraint)
bool isPixelAlignedToGlobal() const
virtual void drawDevice(SkDevice *, const SkSamplingOptions &, const SkPaint &)
virtual SkIRect devClipBounds() const =0
const SkSurfaceProps & surfaceProps() const
virtual bool onPeekPixels(SkPixmap *)
virtual sk_sp< SkSpecialImage > makeSpecial(const SkBitmap &)
const SkM44 & deviceToGlobal() const
virtual void drawDrawable(SkCanvas *, SkDrawable *, const SkMatrix *)
virtual void onDrawGlyphRunList(SkCanvas *, const sktext::GlyphRunList &, const SkPaint &paint)=0
void setDeviceCoordinateSystem(const SkM44 &deviceToGlobal, const SkM44 &globalToDevice, const SkM44 &localToDevice, int bufferOriginX, int bufferOriginY)
void setGlobalCTM(const SkM44 &ctm)
virtual sk_sp< sktext::gpu::Slug > convertGlyphRunListToSlug(const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
bool peekPixels(SkPixmap *)
virtual sk_sp< SkSurface > makeSurface(const SkImageInfo &, const SkSurfaceProps &)
virtual void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], sk_sp< SkBlender >, const SkPaint &paint)
virtual void drawRect(const SkRect &r, const SkPaint &paint)=0
virtual void drawImageRect(const SkImage *, const SkRect *src, const SkRect &dst, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint)=0
const SkM44 & localToDevice44() const
virtual void drawPath(const SkPath &path, const SkPaint &paint, bool pathIsMutable=false)=0
virtual void drawArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
SkMatrix getRelativeTransform(const SkDevice &) const
virtual void drawImageLattice(const SkImage *, const SkCanvas::Lattice &, const SkRect &dst, SkFilterMode, const SkPaint &)
void draw(SkCanvas *, const SkMatrix *=nullptr)
skif::FilterResult filterImage(const skif::Context &context) const
bool readPixels(GrDirectContext *context, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
bool next(SkIRect *src, SkRect *dst, bool *isFixedColor=nullptr, SkColor *fixedColor=nullptr)
SkM44 & postConcat(const SkM44 &m)
SkM44 & postTranslate(SkScalar x, SkScalar y, SkScalar z=0)
void normalizePerspective()
SkScalar rc(int r, int c) const
void setRC(int r, int c, SkScalar value)
SkM44 & preTranslate(SkScalar x, SkScalar y, SkScalar z=0)
static SkRect MapRect(const SkM44 &m, const SkRect &r)
static bool IsScaleTranslateAsM33(const SkM44 &m)
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
SkScalar getTranslateY() const
bool invert(SkMatrix *inverse) const
SkMatrix & setRSXform(const SkRSXform &rsxForm)
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
SkScalar getTranslateX() const
@ kTranslate_Mask
translation SkMatrix
void clipRegion(const SkRegion &globalRgn, SkClipOp op) override
void clipRect(const SkRect &rect, SkClipOp op, bool aa) override
bool resetForNextPicture(const SkIRect &bounds)
void onClipShader(sk_sp< SkShader > shader) override
void popClipStack() override
void replaceClip(const SkIRect &rect) override
void clipPath(const SkPath &path, SkClipOp op, bool aa) override
void pushClipStack() override
SkNoPixelsDevice(const SkIRect &bounds, const SkSurfaceProps &props)
void clipRRect(const SkRRect &rrect, SkClipOp op, bool aa) override
void setColor(SkColor color)
void setAntiAlias(bool aa)
@ kFill_Style
set to fill geometry
static sk_sp< SkVertices > MakeVertices(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], int lodX, int lodY, SkColorSpace *colorSpace=nullptr)
static SkISize GetLevelOfDetail(const SkPoint cubics[12], const SkMatrix *matrix)
static void CreateDrawArcPath(SkPath *path, const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, bool isFillNoPathEffect)
SkPath & addPoly(const SkPoint pts[], int count, bool close)
const SkRect & getBounds() const
const SkRect & getBounds() const
static bool Subtract(const SkRect &a, const SkRect &b, SkRect *out)
const SkIRect & rect() const
bool getBoundaryPath(SkPath *path) const
const SkIRect & getBounds() const
virtual sk_sp< SkShader > makeAsALocalMatrixShader(SkMatrix *localMatrix) const
sk_sp< SkShader > makeWithLocalMatrix(const SkMatrix &) const
sk_sp< SkVertices > detach()
@ kHasTexCoords_BuilderFlag
T & emplace_back(Args &&... args)
sk_sp< SkSpecialImage > imageAndOffset(const Context &ctx, SkIPoint *offset) const
const SkMatrix & deviceToLayer() const
const SkMatrix & layerToDevice() const
GlyphRunList makeGlyphRunList(const GlyphRun &run, const SkPaint &paint, SkPoint origin)
GlyphRunBuilder * builder() const
FlutterSemanticsFlag flags
std::array< MockImage, 3 > images
void(* memset32)(uint32_t[], uint32_t, int)
sk_sp< Backend > MakeRasterBackend(const SkSurfaceProps &surfaceProps, SkColorType colorType)
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
static constexpr SkIPoint Make(int32_t x, int32_t y)
bool intersect(const SkIRect &r)
constexpr int32_t top() const
constexpr int32_t height() const
constexpr int32_t width() const
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
constexpr int32_t left() const
constexpr int32_t width() const
constexpr int32_t height() const
SkColorSpace * colorSpace() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
constexpr float y() const
constexpr float x() const
static SkRect Make(const SkISize &size)
static constexpr SkRect MakeEmpty()
void toQuad(SkPoint quad[4]) const
void roundIn(SkIRect *dst) const
SkScalar fLeft
smaller x-axis bounds
void roundOut(SkIRect *dst) const
void round(SkIRect *dst) const
constexpr float height() const
constexpr float width() const
SkScalar fTop
smaller y-axis bounds