508 {
510 if (!dContext && canvas->recordingContext()) {
511 *errorMsg = "Not supported in DDL mode";
513 }
514 if (dContext && dContext->abandoned()) {
516 }
517
519
521
524
526 {.3f, .3f, .3f, .3f},
527 {1.f, .2f, .6f, .9f},
528 {0.f, .1f, 1.f, .1f},
529 {.7f, .8f, .2f, .7f},
530 };
532 230,
534 nullptr,
535 nullptr,
536 std::size(colors),
540
541 upmSurf->getCanvas()->drawPaint(
paint);
542 pmSurf ->getCanvas()->drawPaint(
paint);
543
544 auto pmImg = pmSurf->makeImageSnapshot();
545 auto upmImg = upmSurf->makeImageSnapshot();
546
547 if (dContext) {
550 if (!pmImg || !upmImg) {
551 *errorMsg = "could not make texture images";
553 }
554 }
556
558
559 for (const auto& img : {pmImg, upmImg}) {
560 canvas->save();
562 auto readInfo = img->imageInfo().makeAlphaType(readAT).makeWH(size, size);
563
564 auto* asyncContext = new AsyncContext();
565 img->asyncRescaleAndReadPixels(readInfo,
567 SkImage::RescaleGamma::kSrc,
568 SkImage::RescaleMode::kRepeatedCubic,
570 asyncContext);
571 if (dContext) {
572 dContext->submit();
573 }
574 while (!asyncContext->fCalled) {
575
577 dContext->checkAsyncWorkCompletion();
578 }
579 if (asyncContext->fResult) {
581 asyncContext->fResult->data(0),
582 asyncContext->fResult->rowBytes(0));
583 auto releasePixels = [](const void*, void* c) {
584 delete static_cast<AsyncContext*>(c);
585 };
587
588 canvas->drawImage(
result, 0, 0);
589 } else {
590 delete asyncContext;
591 *errorMsg = "async readback failed";
593 }
594 canvas->translate(size, 0);
595 }
596 canvas->restore();
597 canvas->translate(0, size);
598 }
600}
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
static SkPaint paint(SkColor color, float strokeWidth=-1.f, SkPaint::Join join=SkPaint::kMiter_Join)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
static void async_callback(void *c, std::unique_ptr< const SkImage::AsyncReadResult > result)
static sk_sp< SkShader > MakeRadial(const SkPoint ¢er, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
void setShader(sk_sp< SkShader > shader)
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
PODArray< SkColor > colors
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static constexpr SkIRect MakeSize(const SkISize &size)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)