Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkDevice.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "src/core/SkDevice.h"
9
17#include "include/core/SkPath.h"
23#include "include/core/SkSpan.h"
28#include "include/private/chromium/Slug.h" // IWYU pragma: keep
34#include "src/core/SkMemset.h"
35#include "src/core/SkPathPriv.h"
36#include "src/core/SkRectPriv.h"
39#include "src/text/GlyphRun.h"
41
42#include <cstdint>
43
45 : fInfo(info)
46 , fSurfaceProps(surfaceProps) {
47 fDeviceToGlobal.setIdentity();
48 fGlobalToDevice.setIdentity();
49}
50
51void SkDevice::setDeviceCoordinateSystem(const SkM44& deviceToGlobal,
52 const SkM44& globalToDevice,
53 const SkM44& localToDevice,
54 int bufferOriginX,
55 int bufferOriginY) {
56 fDeviceToGlobal = deviceToGlobal;
57 fDeviceToGlobal.normalizePerspective();
58 fGlobalToDevice = globalToDevice;
59 fGlobalToDevice.normalizePerspective();
60
61 fLocalToDevice = localToDevice;
62 fLocalToDevice.normalizePerspective();
63 if (bufferOriginX | bufferOriginY) {
64 fDeviceToGlobal.preTranslate(bufferOriginX, bufferOriginY);
65 fGlobalToDevice.postTranslate(-bufferOriginX, -bufferOriginY);
66 fLocalToDevice.postTranslate(-bufferOriginX, -bufferOriginY);
67 }
68 fLocalToDevice33 = fLocalToDevice.asM33();
69 fLocalToDeviceDirty = true;
70}
71
72void SkDevice::setGlobalCTM(const SkM44& ctm) {
73 fLocalToDevice = ctm;
74 fLocalToDevice.normalizePerspective();
75 // Map from the global CTM state to this device's coordinate system.
76 fLocalToDevice.postConcat(fGlobalToDevice);
77 fLocalToDevice33 = fLocalToDevice.asM33();
78 fLocalToDeviceDirty = true;
79}
80
82 // pixelAligned is set to the identity + integer translation of the device-to-global matrix.
83 // If they are equal then the device is by definition pixel aligned.
84 SkM44 pixelAligned = SkM44();
85 pixelAligned.setRC(0, 3, SkScalarFloorToScalar(fDeviceToGlobal.rc(0, 3)));
86 pixelAligned.setRC(1, 3, SkScalarFloorToScalar(fDeviceToGlobal.rc(1, 3)));
87 return pixelAligned == fDeviceToGlobal;
88}
89
91 // getOrigin() is deprecated, the old origin has been moved into the fDeviceToGlobal matrix.
92 // This extracts the origin from the matrix, but asserts that a more complicated coordinate
93 // space hasn't been set of the device. This function can be removed once existing use cases
94 // have been updated to use the device-to-global matrix instead or have themselves been removed
95 // (e.g. Android's device-space clip regions are going away, and are not compatible with the
96 // generalized device coordinate system).
98 return SkIPoint::Make(SkScalarFloorToInt(fDeviceToGlobal.rc(0, 3)),
99 SkScalarFloorToInt(fDeviceToGlobal.rc(1, 3)));
100}
101
103 // To get the transform from this space to the other device's, transform from our space to
104 // global and then from global to the other device.
105 return (dstDevice.fGlobalToDevice * fDeviceToGlobal).asM33();
106}
107
108static inline bool is_int(float x) {
109 return x == (float) sk_float_round2int(x);
110}
111
112void SkDevice::drawRegion(const SkRegion& region, const SkPaint& paint) {
113 const SkMatrix& localToDevice = this->localToDevice();
114 bool isNonTranslate = localToDevice.getType() & ~(SkMatrix::kTranslate_Mask);
115 bool complexPaint = paint.getStyle() != SkPaint::kFill_Style || paint.getMaskFilter() ||
116 paint.getPathEffect();
117 bool antiAlias = paint.isAntiAlias() && (!is_int(localToDevice.getTranslateX()) ||
119 if (isNonTranslate || complexPaint || antiAlias) {
120 SkPath path;
121 region.getBoundaryPath(&path);
122 path.setIsVolatile(true);
123 return this->drawPath(path, paint, true);
124 }
125
126 SkRegion::Iterator it(region);
127 while (!it.done()) {
128 this->drawRect(SkRect::Make(it.rect()), paint);
129 it.next();
130 }
131}
132
133void SkDevice::drawArc(const SkRect& oval, SkScalar startAngle,
134 SkScalar sweepAngle, bool useCenter, const SkPaint& paint) {
135 SkPath path;
136 bool isFillNoPathEffect = SkPaint::kFill_Style == paint.getStyle() && !paint.getPathEffect();
137 SkPathPriv::CreateDrawArcPath(&path, oval, startAngle, sweepAngle, useCenter,
138 isFillNoPathEffect);
139 this->drawPath(path, paint);
140}
141
143 const SkRRect& inner, const SkPaint& paint) {
144 SkPath path;
145 path.addRRect(outer);
146 path.addRRect(inner);
147 path.setFillType(SkPathFillType::kEvenOdd);
148 path.setIsVolatile(true);
149
150 this->drawPath(path, paint, true);
151}
152
153void SkDevice::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
154 const SkPoint texCoords[4], sk_sp<SkBlender> blender,
155 const SkPaint& paint) {
157 auto vertices = SkPatchUtils::MakeVertices(cubics, colors, texCoords, lod.width(), lod.height(),
158 this->imageInfo().colorSpace());
159 if (vertices) {
160 this->drawVertices(vertices.get(), std::move(blender), paint);
161 }
162}
163
165 const SkRect& dst, SkFilterMode filter, const SkPaint& paint) {
166 SkLatticeIter iter(lattice, dst);
167
168 SkRect srcR, dstR;
169 SkColor c;
170 bool isFixedColor = false;
172
173 while (iter.next(&srcR, &dstR, &isFixedColor, &c)) {
174 // TODO: support this fast-path for GPU images
175 if (isFixedColor || (srcR.width() <= 1.0f && srcR.height() <= 1.0f &&
176 image->readPixels(nullptr, info, &c, 4, srcR.fLeft, srcR.fTop))) {
177 // Fast draw with drawRect, if this is a patch containing a single color
178 // or if this is a patch containing a single pixel.
179 if (0 != c || !paint.isSrcOver()) {
180 SkPaint paintCopy(paint);
181 int alpha = SkAlphaMul(SkColorGetA(c), SkAlpha255To256(paint.getAlpha()));
182 paintCopy.setColor(SkColorSetA(c, alpha));
183 this->drawRect(dstR, paintCopy);
184 }
185 } else {
186 this->drawImageRect(image, &srcR, dstR, SkSamplingOptions(filter), paint,
188 }
189 }
190}
191
192static SkPoint* quad_to_tris(SkPoint tris[6], const SkPoint quad[4]) {
193 tris[0] = quad[0];
194 tris[1] = quad[1];
195 tris[2] = quad[2];
196
197 tris[3] = quad[0];
198 tris[4] = quad[2];
199 tris[5] = quad[3];
200
201 return tris + 6;
202}
203
205 const SkRect tex[],
206 const SkColor colors[],
207 int quadCount,
208 sk_sp<SkBlender> blender,
209 const SkPaint& paint) {
210 const int triCount = quadCount << 1;
211 const int vertexCount = triCount * 3;
213 if (colors) {
215 }
217
218 SkPoint* vPos = builder.positions();
219 SkPoint* vTex = builder.texCoords();
220 SkColor* vCol = builder.colors();
221 for (int i = 0; i < quadCount; ++i) {
222 SkPoint tmp[4];
223 xform[i].toQuad(tex[i].width(), tex[i].height(), tmp);
224 vPos = quad_to_tris(vPos, tmp);
225
226 tex[i].toQuad(tmp);
227 vTex = quad_to_tris(vTex, tmp);
228
229 if (colors) {
230 SkOpts::memset32(vCol, colors[i], 6);
231 vCol += 6;
232 }
233 }
234 this->drawVertices(builder.detach().get(), std::move(blender), paint);
235}
236
238 const SkColor4f& color, SkBlendMode mode) {
240 paint.setColor4f(color);
241 paint.setBlendMode(mode);
242 paint.setAntiAlias(aa == SkCanvas::kAll_QuadAAFlags);
243
244 if (clip) {
245 // Draw the clip directly as a quad since it's a filled color with no local coords
247 clipPath.addPoly(clip, 4, true);
248 this->drawPath(clipPath, paint);
249 } else {
250 this->drawRect(r, paint);
251 }
252}
253
255 const SkPoint dstClips[], const SkMatrix preViewMatrices[],
256 const SkSamplingOptions& sampling, const SkPaint& paint,
257 SkCanvas::SrcRectConstraint constraint) {
258 SkASSERT(paint.getStyle() == SkPaint::kFill_Style);
259 SkASSERT(!paint.getPathEffect());
260
261 SkPaint entryPaint = paint;
262 const SkM44 baseLocalToDevice = this->localToDevice44();
263 int clipIndex = 0;
264 for (int i = 0; i < count; ++i) {
265 // TODO: Handle per-edge AA. Right now this mirrors the SkiaRenderer component of Chrome
266 // which turns off antialiasing unless all four edges should be antialiased. This avoids
267 // seaming in tiled composited layers.
268 entryPaint.setAntiAlias(images[i].fAAFlags == SkCanvas::kAll_QuadAAFlags);
269 entryPaint.setAlphaf(paint.getAlphaf() * images[i].fAlpha);
270
271 SkASSERT(images[i].fMatrixIndex < 0 || preViewMatrices);
272 if (images[i].fMatrixIndex >= 0) {
273 this->setLocalToDevice(baseLocalToDevice *
274 SkM44(preViewMatrices[images[i].fMatrixIndex]));
275 }
276
277 SkASSERT(!images[i].fHasClip || dstClips);
278 if (images[i].fHasClip) {
279 // Since drawImageRect requires a srcRect, the dst clip is implemented as a true clip
280 this->pushClipStack();
282 clipPath.addPoly(dstClips + clipIndex, 4, true);
283 this->clipPath(clipPath, SkClipOp::kIntersect, entryPaint.isAntiAlias());
284 clipIndex += 4;
285 }
286 this->drawImageRect(images[i].fImage.get(), &images[i].fSrcRect, images[i].fDstRect,
287 sampling, entryPaint, constraint);
288 if (images[i].fHasClip) {
289 this->popClipStack();
290 }
291 if (images[i].fMatrixIndex >= 0) {
292 this->setLocalToDevice(baseLocalToDevice);
293 }
294 }
295}
296
297///////////////////////////////////////////////////////////////////////////////////////////////////
298
299void SkDevice::drawDrawable(SkCanvas* canvas, SkDrawable* drawable, const SkMatrix* matrix) {
300 drawable->draw(canvas, matrix);
301}
302
303///////////////////////////////////////////////////////////////////////////////////////////////////
304
307void SkDevice::drawCoverageMask(const SkSpecialImage*, const SkMatrix& maskToDevice,
308 const SkSamplingOptions&, const SkPaint&) {
309 // This shouldn't be reached; SkCanvas will only call this if
310 // useDrawCoverageMaskForMaskFilters() is overridden to return true.
311 SK_ABORT("Must override if useDrawCoverageMaskForMaskFilters() is true");
312}
313
316sk_sp<SkSpecialImage> SkDevice::snapSpecial(const SkIRect&, bool forceCopy) { return nullptr; }
318 const SkISize& dstDims) {
319 return nullptr;
320}
324
329
331 const SkSamplingOptions& sampling,
332 const SkPaint& paint) {
333 sk_sp<SkSpecialImage> deviceImage = device->snapSpecial();
334 if (deviceImage) {
335#if defined(SK_DONT_PAD_LAYER_IMAGES) || defined(SK_RESOLVE_FILTERS_BEFORE_RESTORE)
336 this->drawSpecial(deviceImage.get(), device->getRelativeTransform(*this), sampling, paint);
337#else
338 // SkCanvas only calls drawDevice() when there are no filters (so the transform is pixel
339 // aligned). As such it can be drawn without clamping.
340 SkMatrix relativeTransform = device->getRelativeTransform(*this);
341 const bool strict = sampling != SkFilterMode::kNearest ||
342 !relativeTransform.isTranslate() ||
343 !SkScalarIsInt(relativeTransform.getTranslateX()) ||
344 !SkScalarIsInt(relativeTransform.getTranslateY());
345 this->drawSpecial(deviceImage.get(), relativeTransform, sampling, paint,
348#endif
349 }
350}
351
353 SkSpecialImage* src,
355 const SkImageFilter* filter,
356 const SkSamplingOptions& sampling,
357 const SkPaint& paint) {
358 SkASSERT(!paint.getImageFilter() && !paint.getMaskFilter());
359
360 skif::LayerSpace<SkIRect> targetOutput = mapping.deviceToLayer(
362
363 if (colorType == kUnknown_SkColorType) {
365 }
366
367 skif::Stats stats;
368 skif::Context ctx{this->createImageFilteringBackend(src ? src->props() : this->surfaceProps(),
369 colorType),
370 mapping,
371 targetOutput,
373 this->imageInfo().colorSpace(),
374 &stats};
375
378 stats.reportStats();
379 if (result) {
380 SkMatrix deviceMatrixWithOffset = mapping.layerToDevice();
381 deviceMatrixWithOffset.preTranslate(offset.fX, offset.fY);
382 this->drawSpecial(result.get(), deviceMatrixWithOffset, sampling, paint);
383 }
384}
385
386///////////////////////////////////////////////////////////////////////////////////////////////////
387
389 SkPixmap tempStorage;
390 if (nullptr == pmap) {
391 pmap = &tempStorage;
392 }
393 return this->onAccessPixels(pmap);
394}
395
397 SkPixmap tempStorage;
398 if (nullptr == pmap) {
399 pmap = &tempStorage;
400 }
401 return this->onPeekPixels(pmap);
402}
403
404//////////////////////////////////////////////////////////////////////////////////////////
405
406static sk_sp<SkShader> make_post_inverse_lm(const SkShader* shader, const SkMatrix& lm) {
407 SkMatrix inverse_lm;
408 if (!shader || !lm.invert(&inverse_lm)) {
409 return nullptr;
410 }
411
412#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) // b/256873449
413 // Legacy impl for old concat order. This does not work for arbitrary shader DAGs (when there is
414 // no single leaf local matrix).
415
416 // LMs pre-compose. In order to push a post local matrix, we peel off any existing local matrix
417 // and set a new local matrix of inverse_lm * prev_local_matrix.
418 SkMatrix prev_local_matrix;
419 const auto nested_shader = as_SB(shader)->makeAsALocalMatrixShader(&prev_local_matrix);
420 if (nested_shader) {
421 // unfurl the shader
422 shader = nested_shader.get();
423 }
424
425 return shader->makeWithLocalMatrix(inverse_lm * prev_local_matrix);
426#endif
427
428 return shader->makeWithLocalMatrix(inverse_lm);
429}
430
432 const sktext::GlyphRunList& glyphRunList,
433 const SkPaint& paint) {
434 if (!this->localToDevice().isFinite()) {
435 return;
436 }
437
438 if (!glyphRunList.hasRSXForm()) {
439 this->onDrawGlyphRunList(canvas, glyphRunList, paint);
440 } else {
441 this->simplifyGlyphRunRSXFormAndRedraw(canvas, glyphRunList, paint);
442 }
443}
444
445void SkDevice::simplifyGlyphRunRSXFormAndRedraw(SkCanvas* canvas,
446 const sktext::GlyphRunList& glyphRunList,
447 const SkPaint& paint) {
448 for (const sktext::GlyphRun& run : glyphRunList) {
449 if (run.scaledRotations().empty()) {
450 auto subList = glyphRunList.builder()->makeGlyphRunList(run, paint, {0, 0});
451 this->drawGlyphRunList(canvas, subList, paint);
452 } else {
453 SkPoint origin = glyphRunList.origin();
454 SkPoint sharedPos{0, 0}; // we're at the origin
455 SkGlyphID sharedGlyphID;
456 sktext::GlyphRun glyphRun {
457 run.font(),
458 SkSpan<const SkPoint>{&sharedPos, 1},
459 SkSpan<const SkGlyphID>{&sharedGlyphID, 1},
463 };
464
465 for (auto [i, glyphID, pos] : SkMakeEnumerate(run.source())) {
466 sharedGlyphID = glyphID;
467 auto [scos, ssin] = run.scaledRotations()[i];
468 SkRSXform rsxForm = SkRSXform::Make(scos, ssin, pos.x(), pos.y());
469 SkMatrix glyphToLocal;
470 glyphToLocal.setRSXform(rsxForm).postTranslate(origin.x(), origin.y());
471
472 // We want to rotate each glyph by the rsxform, but we don't want to rotate "space"
473 // (i.e. the shader that cares about the ctm) so we have to undo our little ctm
474 // trick with a localmatrixshader so that the shader draws as if there was no
475 // change to the ctm.
476 SkPaint invertingPaint{paint};
477 invertingPaint.setShader(make_post_inverse_lm(paint.getShader(), glyphToLocal));
478 SkAutoCanvasRestore acr(canvas, true);
479 canvas->concat(SkM44(glyphToLocal));
480 sktext::GlyphRunList subList =
481 glyphRunList.builder()->makeGlyphRunList(glyphRun, paint, {0, 0});
482 this->drawGlyphRunList(canvas, subList, invertingPaint);
483 }
484 }
485 }
486}
487
489 const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) {
490 return nullptr;
491}
492
494 SK_ABORT("Slug drawing not supported.");
495}
496
497//////////////////////////////////////////////////////////////////////////////////////////
498
500 return nullptr;
501}
502
504 // If we're doing linear blending, then we can disable the gamma hacks.
505 // Otherwise, leave them on. In either case, we still want the contrast boost:
506 // TODO: Can we be even smarter about mask gamma based on the dest transfer function?
507 const SkColorSpace* const cs = fInfo.colorSpace();
508 if (cs && cs->gammaIsLinear()) {
510 } else {
512 }
513}
514
515//////////////////////////////////////////////////////////////////////////////////////////
516
518 : SkNoPixelsDevice(bounds, props, nullptr) {}
519
521 sk_sp<SkColorSpace> colorSpace)
523 std::move(colorSpace)), props) {
524 // this fails if we enable this assert: DiscardableImageMapTest.GetDiscardableImagesInRectMaxImage
525 //SkASSERT(bounds.width() >= 0 && bounds.height() >= 0);
526
527 this->setOrigin(SkM44(), bounds.left(), bounds.top());
528 fClipStack.emplace_back(this->bounds(), /*isAA=*/false, /*isRect=*/true);
529}
530
532 // Resetting should only happen on the root SkNoPixelsDevice, so its device-to-global
533 // transform should be pixel aligned.
535 // We can only reset the device as long as its dimensions are not changing.
536 if (bounds.width() != this->width() || bounds.height() != this->height()) {
537 return false;
538 }
539
540 // And the canvas should have restored back to the original save count.
541 SkASSERT(fClipStack.size() == 1 && fClipStack[0].fDeferredSaveCount == 0);
542 // But in the event that the clip was modified w/o a save(), reset the tracking state
543 fClipStack[0].fClipBounds = this->bounds();
544 fClipStack[0].fIsAA = false;
545 fClipStack[0].fIsRect = true;
546
547 this->setOrigin(SkM44(), bounds.left(), bounds.top());
548 return true;
549}
550
552 SkASSERT(!fClipStack.empty());
553 fClipStack.back().fDeferredSaveCount++;
554}
555
557 SkASSERT(!fClipStack.empty());
558 if (fClipStack.back().fDeferredSaveCount > 0) {
559 fClipStack.back().fDeferredSaveCount--;
560 } else {
561 fClipStack.pop_back();
562 SkASSERT(!fClipStack.empty());
563 }
564}
565
566SkNoPixelsDevice::ClipState& SkNoPixelsDevice::writableClip() {
567 SkASSERT(!fClipStack.empty());
568 ClipState& current = fClipStack.back();
569 if (current.fDeferredSaveCount > 0) {
570 current.fDeferredSaveCount--;
571 // Stash current state in case 'current' moves during a resize
572 SkIRect bounds = current.fClipBounds;
573 bool aa = current.fIsAA;
574 bool rect = current.fIsRect;
575 return fClipStack.emplace_back(bounds, aa, rect);
576 } else {
577 return current;
578 }
579}
580
581void SkNoPixelsDevice::clipRect(const SkRect& rect, SkClipOp op, bool aa) {
582 this->writableClip().op(op, this->localToDevice44(), rect,
583 aa, /*fillsBounds=*/true);
584}
585
586void SkNoPixelsDevice::clipRRect(const SkRRect& rrect, SkClipOp op, bool aa) {
587 this->writableClip().op(op, this->localToDevice44(), rrect.getBounds(),
588 aa, /*fillsBounds=*/rrect.isRect());
589}
590
591void SkNoPixelsDevice::clipPath(const SkPath& path, SkClipOp op, bool aa) {
592 // Toggle op if the path is inverse filled
593 if (path.isInverseFillType()) {
595 }
596 this->writableClip().op(op, this->localToDevice44(), path.getBounds(),
597 aa, /*fillsBounds=*/false);
598}
599
601 this->writableClip().op(op, this->globalToDevice(), SkRect::Make(globalRgn.getBounds()),
602 /*isAA=*/false, /*fillsBounds=*/globalRgn.isRect());
603}
604
606 this->writableClip().fIsRect = false;
607}
608
610 SkIRect deviceRect = SkMatrixPriv::MapRect(this->globalToDevice(), SkRect::Make(rect)).round();
611 if (!deviceRect.intersect(this->bounds())) {
612 deviceRect.setEmpty();
613 }
614 auto& clip = this->writableClip();
615 clip.fClipBounds = deviceRect;
616 clip.fIsRect = true;
617 clip.fIsAA = false;
618}
619
620void SkNoPixelsDevice::ClipState::op(SkClipOp op, const SkM44& transform, const SkRect& bounds,
621 bool isAA, bool fillsBounds) {
622 const bool isRect = fillsBounds && SkMatrixPriv::IsScaleTranslateAsM33(transform);
623 fIsAA |= isAA;
624
625 SkRect devBounds = bounds.isEmpty() ? SkRect::MakeEmpty()
626 : SkMatrixPriv::MapRect(transform, bounds);
627 if (op == SkClipOp::kIntersect) {
628 if (!fClipBounds.intersect(isAA ? devBounds.roundOut() : devBounds.round())) {
629 fClipBounds.setEmpty();
630 }
631 // A rectangular clip remains rectangular if the intersection is a rect
632 fIsRect &= isRect;
633 } else if (isRect) {
634 // Conservatively, we can leave the clip bounds unchanged and respect the difference op.
635 // But, if we're subtracting out an axis-aligned rectangle that fully spans our existing
636 // clip on an axis, we can shrink the clip bounds.
639 if (SkRectPriv::Subtract(fClipBounds, isAA ? devBounds.roundIn() : devBounds.round(),
640 &difference)) {
641 fClipBounds = difference;
642 } else {
643 // The difference couldn't be represented as a rect
644 fIsRect = false;
645 }
646 } else {
647 // A non-rect shape was applied
648 fIsRect = false;
649 }
650}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
int count
static void round(SkPoint *p)
SkPoint pos
SkColor4f color
static bool isFinite(const SkRect &r)
kUnpremul_SkAlphaType
@ kUnknown_SkAlphaType
uninitialized
Definition SkAlphaType.h:27
#define SK_ABORT(message,...)
Definition SkAssert.h:70
#define SkASSERT(cond)
Definition SkAssert.h:116
SkBlendMode
Definition SkBlendMode.h:38
SkClipOp
Definition SkClipOp.h:13
#define SkAlphaMul(value, alpha256)
Definition SkColorPriv.h:34
static unsigned SkAlpha255To256(U8CPU alpha)
Definition SkColorPriv.h:24
SkColorType
Definition SkColorType.h:19
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20
uint32_t SkColor
Definition SkColor.h:37
static constexpr SkColor SkColorSetA(SkColor c, U8CPU a)
Definition SkColor.h:82
#define SkColorGetA(color)
Definition SkColor.h:61
static bool is_int(float x)
Definition SkDevice.cpp:108
static sk_sp< SkShader > make_post_inverse_lm(const SkShader *shader, const SkMatrix &lm)
Definition SkDevice.cpp:406
static SkPoint * quad_to_tris(SkPoint tris[6], const SkPoint quad[4])
Definition SkDevice.cpp:192
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)
Definition SkPath.cpp:3824
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381
SkFilterMode
#define SkScalarFloorToScalar(x)
Definition SkScalar.h:30
static bool SkScalarIsInt(SkScalar x)
Definition SkScalar.h:80
#define SkScalarFloorToInt(x)
Definition SkScalar.h:35
SkScalerContextFlags
SkShaderBase * as_SB(SkShader *shader)
uint16_t SkGlyphID
Definition SkTypes.h:179
SrcRectConstraint
Definition SkCanvas.h:1541
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition SkCanvas.h:1542
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition SkCanvas.h:1543
void concat(const SkMatrix &matrix)
@ kAll_QuadAAFlags
Definition SkCanvas.h:1665
bool gammaIsLinear() const
void drawFilteredImage(const skif::Mapping &mapping, SkSpecialImage *src, SkColorType ct, const SkImageFilter *, const SkSamplingOptions &, const SkPaint &)
Definition SkDevice.cpp:352
const SkImageInfo & imageInfo() const
Definition SkDevice.h:117
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)
Definition SkDevice.cpp:237
SkScalerContextFlags scalerContextFlags() const
Definition SkDevice.cpp:503
virtual void drawRegion(const SkRegion &r, const SkPaint &paint)
Definition SkDevice.cpp:112
int height() const
Definition SkDevice.h:120
SkIPoint getOrigin() const
Definition SkDevice.cpp:90
SkDevice(const SkImageInfo &, const SkSurfaceProps &)
Definition SkDevice.cpp:44
virtual void drawAtlas(const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp< SkBlender >, const SkPaint &)
Definition SkDevice.cpp:204
virtual void clipPath(const SkPath &path, SkClipOp op, bool aa)=0
void setLocalToDevice(const SkM44 &localToDevice)
Definition SkDevice.h:211
virtual bool onAccessPixels(SkPixmap *)
Definition SkDevice.h:534
virtual void drawCoverageMask(const SkSpecialImage *, const SkMatrix &maskToDevice, const SkSamplingOptions &, const SkPaint &)
Definition SkDevice.cpp:307
virtual sk_sp< skif::Backend > createImageFilteringBackend(const SkSurfaceProps &surfaceProps, SkColorType colorType) const
Definition SkDevice.cpp:325
void drawGlyphRunList(SkCanvas *, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
Definition SkDevice.cpp:431
virtual void drawEdgeAAImageSet(const SkCanvas::ImageSetEntry[], int count, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint)
Definition SkDevice.cpp:254
const SkM44 & globalToDevice() const
Definition SkDevice.h:191
virtual void drawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &)
Definition SkDevice.cpp:142
sk_sp< SkSpecialImage > snapSpecial()
Definition SkDevice.cpp:321
virtual void popClipStack()=0
virtual sk_sp< SkSpecialImage > snapSpecialScaled(const SkIRect &subset, const SkISize &dstDims)
Definition SkDevice.cpp:317
virtual void pushClipStack()=0
bool accessPixels(SkPixmap *pmap)
Definition SkDevice.cpp:388
const SkMatrix & localToDevice() const
Definition SkDevice.h:179
virtual void drawSlug(SkCanvas *, const sktext::gpu::Slug *slug, const SkPaint &paint)
Definition SkDevice.cpp:493
void setOrigin(const SkM44 &globalCTM, int x, int y)
Definition SkDevice.h:509
virtual void drawSpecial(SkSpecialImage *, const SkMatrix &localToDevice, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint constraint=SkCanvas::kStrict_SrcRectConstraint)
Definition SkDevice.cpp:305
bool isPixelAlignedToGlobal() const
Definition SkDevice.cpp:81
virtual void drawDevice(SkDevice *, const SkSamplingOptions &, const SkPaint &)
Definition SkDevice.cpp:330
virtual SkIRect devClipBounds() const =0
const SkSurfaceProps & surfaceProps() const
Definition SkDevice.h:131
virtual bool onPeekPixels(SkPixmap *)
Definition SkDevice.h:536
virtual sk_sp< SkSpecialImage > makeSpecial(const SkBitmap &)
Definition SkDevice.cpp:314
const SkM44 & deviceToGlobal() const
Definition SkDevice.h:186
virtual void drawDrawable(SkCanvas *, SkDrawable *, const SkMatrix *)
Definition SkDevice.cpp:299
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)
Definition SkDevice.cpp:51
void setGlobalCTM(const SkM44 &ctm)
Definition SkDevice.cpp:72
virtual sk_sp< sktext::gpu::Slug > convertGlyphRunListToSlug(const sktext::GlyphRunList &glyphRunList, const SkPaint &paint)
Definition SkDevice.cpp:488
bool peekPixels(SkPixmap *)
Definition SkDevice.cpp:396
virtual sk_sp< SkSurface > makeSurface(const SkImageInfo &, const SkSurfaceProps &)
Definition SkDevice.cpp:499
int width() const
Definition SkDevice.h:119
virtual void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], sk_sp< SkBlender >, const SkPaint &paint)
Definition SkDevice.cpp:153
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
Definition SkDevice.h:178
SkIRect bounds() const
Definition SkDevice.h:125
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)
Definition SkDevice.cpp:133
SkMatrix getRelativeTransform(const SkDevice &) const
Definition SkDevice.cpp:102
virtual void drawImageLattice(const SkImage *, const SkCanvas::Lattice &, const SkRect &dst, SkFilterMode, const SkPaint &)
Definition SkDevice.cpp:164
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
Definition SkImage.cpp:42
bool next(SkIRect *src, SkRect *dst, bool *isFixedColor=nullptr, SkColor *fixedColor=nullptr)
Definition SkM44.h:150
SkM44 & postConcat(const SkM44 &m)
Definition SkM44.h:355
SkM44 & postTranslate(SkScalar x, SkScalar y, SkScalar z=0)
Definition SkM44.cpp:100
void normalizePerspective()
Definition SkM44.cpp:226
SkScalar rc(int r, int c) const
Definition SkM44.h:261
SkMatrix asM33() const
Definition SkM44.h:409
void setRC(int r, int c, SkScalar value)
Definition SkM44.h:266
SkM44 & setIdentity()
Definition SkM44.h:293
SkM44 & preTranslate(SkScalar x, SkScalar y, SkScalar z=0)
Definition SkM44.cpp:89
static SkRect MapRect(const SkM44 &m, const SkRect &r)
Definition SkM44.cpp:216
static bool IsScaleTranslateAsM33(const SkM44 &m)
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:281
SkScalar getTranslateY() const
Definition SkMatrix.h:452
bool invert(SkMatrix *inverse) const
Definition SkMatrix.h:1206
bool isTranslate() const
Definition SkMatrix.h:248
SkMatrix & setRSXform(const SkRSXform &rsxForm)
Definition SkMatrix.cpp:420
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:263
SkScalar getTranslateX() const
Definition SkMatrix.h:445
@ kTranslate_Mask
translation SkMatrix
Definition SkMatrix.h:193
TypeMask getType() const
Definition SkMatrix.h:207
void clipRegion(const SkRegion &globalRgn, SkClipOp op) override
Definition SkDevice.cpp:600
void clipRect(const SkRect &rect, SkClipOp op, bool aa) override
Definition SkDevice.cpp:581
bool resetForNextPicture(const SkIRect &bounds)
Definition SkDevice.cpp:531
void onClipShader(sk_sp< SkShader > shader) override
Definition SkDevice.cpp:605
void popClipStack() override
Definition SkDevice.cpp:556
void replaceClip(const SkIRect &rect) override
Definition SkDevice.cpp:609
void clipPath(const SkPath &path, SkClipOp op, bool aa) override
Definition SkDevice.cpp:591
void pushClipStack() override
Definition SkDevice.cpp:551
SkNoPixelsDevice(const SkIRect &bounds, const SkSurfaceProps &props)
Definition SkDevice.cpp:517
void clipRRect(const SkRRect &rrect, SkClipOp op, bool aa) override
Definition SkDevice.cpp:586
void setColor(SkColor color)
Definition SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition SkPaint.h:170
@ kFill_Style
set to fill geometry
Definition SkPaint.h:193
bool isAntiAlias() const
Definition SkPaint.h:162
void setAlphaf(float a)
Definition SkPaint.cpp:130
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)
Definition SkPath.cpp:3290
SkPath & addPoly(const SkPoint pts[], int count, bool close)
Definition SkPath.cpp:880
const SkRect & getBounds() const
Definition SkPath.cpp:420
bool isRect() const
Definition SkRRect.h:84
const SkRect & getBounds() const
Definition SkRRect.h:279
static bool Subtract(const SkRect &a, const SkRect &b, SkRect *out)
Definition SkRect.cpp:252
const SkIRect & rect() const
Definition SkRegion.h:501
bool done() const
Definition SkRegion.h:488
bool getBoundaryPath(SkPath *path) const
bool isRect() const
Definition SkRegion.h:152
const SkIRect & getBounds() const
Definition SkRegion.h:165
virtual sk_sp< SkShader > makeAsALocalMatrixShader(SkMatrix *localMatrix) const
sk_sp< SkShader > makeWithLocalMatrix(const SkMatrix &) const
Definition SkShader.cpp:26
sk_sp< SkVertices > detach()
@ kHasTexCoords_BuilderFlag
Definition SkVertices.h:63
@ kHasColors_BuilderFlag
Definition SkVertices.h:64
@ kTriangles_VertexMode
Definition SkVertices.h:31
T * get() const
Definition SkRefCnt.h:303
bool empty() const
Definition SkTArray.h:194
int size() const
Definition SkTArray.h:416
T & emplace_back(Args &&... args)
Definition SkTArray.h:243
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)
Definition GlyphRun.cpp:189
bool hasRSXForm() const
Definition GlyphRun.h:105
SkPoint origin() const
Definition GlyphRun.h:114
GlyphRunBuilder * builder() const
Definition GlyphRun.h:118
const Paint & paint
VkDevice device
Definition main.cc:53
sk_sp< SkImage > image
Definition examples.cpp:29
SkBitmap source
Definition examples.cpp:28
float SkScalar
Definition extension.cpp:12
FlutterSemanticsFlag flags
GAsyncResult * result
std::array< MockImage, 3 > images
double x
void(* memset32)(uint32_t[], uint32_t, int)
Definition run.py:1
sk_sp< Backend > MakeRasterBackend(const SkSurfaceProps &surfaceProps, SkColorType colorType)
Definition ref_ptr.h:256
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition p3.cpp:47
Point offset
static constexpr SkIPoint Make(int32_t x, int32_t y)
bool intersect(const SkIRect &r)
Definition SkRect.h:513
constexpr int32_t top() const
Definition SkRect.h:120
constexpr int32_t height() const
Definition SkRect.h:165
constexpr int32_t width() const
Definition SkRect.h:158
void setEmpty()
Definition SkRect.h:242
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition SkRect.h:56
constexpr int32_t left() const
Definition SkRect.h:113
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37
SkColorSpace * colorSpace() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
constexpr float y() const
constexpr float x() const
void toQuad(SkScalar width, SkScalar height, SkPoint quad[4]) const
Definition SkRSXform.cpp:9
static SkRSXform Make(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty)
Definition SkRSXform.h:24
static SkRect Make(const SkISize &size)
Definition SkRect.h:669
static constexpr SkRect MakeEmpty()
Definition SkRect.h:595
void toQuad(SkPoint quad[4]) const
Definition SkRect.cpp:50
void roundIn(SkIRect *dst) const
Definition SkRect.h:1266
SkScalar fLeft
smaller x-axis bounds
Definition extension.cpp:14
void roundOut(SkIRect *dst) const
Definition SkRect.h:1241
void round(SkIRect *dst) const
Definition SkRect.h:1228
constexpr float height() const
Definition SkRect.h:769
constexpr float width() const
Definition SkRect.h:762
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15