68 std::string_view label,
78 info.makeColorType(ct),
85bool valid_client_provided_image(
const SkImage* clientProvided,
88 if (!clientProvided ||
89 !
as_IB(clientProvided)->isGraphiteBacked() ||
97 if ((origChannels & clientChannels) != origChannels) {
102 auto graphiteImage =
static_cast<const Image*
>(clientProvided);
104 SKGPU_LOG_E(
"Client provided image must have a TopLeft origin.");
111#if defined(SK_USE_LEGACY_BLUR_GRAPHITE)
140 paint.setShader(std::move(blurEffect));
142 return device->snapSpecial(subset);
160 builder.uniform(
"kernel") = kernel;
168 return eval_blur(recorder,
builder.makeShader(), dstRect,
169 input->
colorType(), std::move(outCS), outProps);
186 builder.uniform(
"offsetsAndKernel") = offsetsAndKernel;
194 return eval_blur(recorder,
builder.makeShader(), dstRect,
195 input->
colorType(), std::move(outCS), outProps);
212 if (kernelArea <= kMaxBlurSamples && radiusX > 0 && radiusY > 0) {
214 return blur_2d(recorder, sigma, {radiusX, radiusY}, std::move(input), srcRect, tileMode,
215 dstRect, std::move(outCS), outProps);
219 SkIRect intermediateDstRect = dstRect;
222 intermediateDstRect.
outset(0, radiusY);
228 input = blur_1d(recorder, sigma.
width(), radiusX, {1.f, 0.f},
229 std::move(input), srcRect, tileMode, intermediateDstRect,
235 dstRect.
offset(-intermediateDstRect.
left(), -intermediateDstRect.
top());
239 input = blur_1d(recorder, sigma.
height(), radiusY, {0.f, 1.f},
240 std::move(input), srcRect, tileMode, dstRect, outCS, outProps);
257 auto inputImage = input->
asImage();
265 inputImage->imageInfo().makeWH(targetSrcWidth, targetSrcHeight),
274 (dstRect.
top() - srcRect.
top()) * sy,
282 auto scaledOutput = blur_impl(
288 std::move(scaledInput),
300 auto scaledOutputImage = scaledOutput->asImage();
303 scaledOutputImage.get(),
304 scaledOutput->subset(),
305 scaledOutputImage->imageInfo().makeWH(dstRect.
width(), dstRect.
height()),
312 SkIRect outputDstRect = outputImage->bounds();
315 std::move(outputImage),
324class PromiseLazyInstantiateCallback {
330 std::string_view label)
331 : fReleaseHelper(
std::move(releaseHelper))
332 , fFulfillProc(fulfillProc)
333 , fFulfillContext(fulfillContext)
334 , fTextureReleaseProc(textureReleaseProc)
337 PromiseLazyInstantiateCallback(PromiseLazyInstantiateCallback&&) =
default;
338 PromiseLazyInstantiateCallback(
const PromiseLazyInstantiateCallback&) {
343 PromiseLazyInstantiateCallback& operator=(PromiseLazyInstantiateCallback&&) =
default;
344 PromiseLazyInstantiateCallback& operator=(
const PromiseLazyInstantiateCallback&) {
351 auto [ backendTexture, textureReleaseCtx ] = fFulfillProc(fFulfillContext);
352 if (!backendTexture.isValid()) {
353 SKGPU_LOG_W(
"FulfillProc returned an invalid backend texture");
363 SKGPU_LOG_W(
"Failed to wrap BackendTexture returned by fulfill proc");
366 texture->setReleaseCallback(std::move(textureReleaseCB));
385 std::string_view label) {
390 if (
bitmap.dimensions().area() <= 1) {
397 if (!textureInfo.isValid()) {
406 if (ct !=
bitmap.info().colorType()) {
426 std::vector<MipLevel> texels;
427 if (mipLevelCount == 1) {
428 texels.resize(mipLevelCount);
429 texels[0].fPixels = bmpToUpload.
getPixels();
430 texels[0].fRowBytes = bmpToUpload.
rowBytes();
440 texels.resize(mipLevelCount);
442 texels[0].fPixels = bmpToUpload.
getPixels();
443 texels[0].fRowBytes = bmpToUpload.
rowBytes();
445 for (
int i = 1;
i < mipLevelCount; ++
i) {
447 mipmaps->
getLevel(
i - 1, &generatedMipLevel);
472 recorder, proxy, colorInfo, colorInfo, texels,
475 SKGPU_LOG_E(
"MakeBitmapProxyView: Could not create UploadInstance");
485 return {{std::move(proxy), swizzle}, ct};
497 std::string_view label) {
505 PromiseLazyInstantiateCallback
callback{std::move(releaseHelper), fulfillProc,
506 fulfillContext, textureReleaseProc, std::move(label)};
519 std::string_view label) {
532 return sk_make_sp<skgpu::graphite::Image>(std::move(view), colorInfo.
makeColorType(ct));
540 size_t colorSize = 0;
549 size_t bytesPerPixel =
info.bytesPerPixel();
551 colorSize = (size_t)dimensions.
width() * dimensions.
height() * bytesPerPixel;
554 size_t finalSize = colorSize *
info.numSamples();
557 finalSize += colorSize/3;
569 std::string_view label) {
605 "width", srcIRect.
width(),
"height", srcIRect.
height());
607 "width", dstInfo.
width(),
"height", dstInfo.
height());
637 if (finalSize == srcIRect.
size()) {
658 std::move(linearGamma));
660 "RescaleLinearGammaTexture", &surfaceProps);
673 srcRect = gammaDstRect;
683 }
else if (srcRect.
width() < finalSize.
width()) {
694 if (nextDims == finalSize) {
696 stepDstRect = dstRect;
700 "RescaleImageTempTexture", &surfaceProps);
750 for (
int i = 0;
i < 2; ++
i) {
751 scratchSurfaces[
i] = make_renderable_scratch_surface(
757 "GenerateMipmapsScratchTexture");
758 if (!scratchSurfaces[
i]) {
763 for (
int mipLevel = 1; srcSize.
width() > 1 || srcSize.
height() > 1; ++mipLevel) {
767 Surface* scratchSurface = scratchSurfaces[(mipLevel - 1) & 1].
get();
779 Flush(scratchSurface);
782 static_cast<const Surface*
>(scratchSurface)->readSurfaceView().refProxy(),
790 recorder->
priv().
add(std::move(copyTask));
792 scratchImg = scratchSurface->
asImage();
811 if (
as_IB(imageIn)->isGraphiteBacked()) {
822 result = clientImageProvider->findOrCreate(
825 if (!valid_client_provided_image(
826 result.get(), imageIn, {mipmapped == Mipmapped::kYes})) {
851 auto gi =
reinterpret_cast<const Image*
>(
image);
874class GraphiteBackend :
876#if defined(SK_USE_LEGACY_BLUR_GRAPHITE)
889 , fRecorder(recorder) {}
898 std::move(colorSpace));
904 props ? *props : this->surfaceProps(),
906 "ImageFilterResult");
915 "ImageFilterCachedBitmap");
922 proxy->textureInfo());
923 return sk_make_sp<skgpu::graphite::Image>(
928 const SkBlurEngine* getBlurEngine()
const override {
return this; }
937#if defined(SK_USE_LEGACY_BLUR_GRAPHITE)
939 float maxSigma()
const override {
943 bool supportsOnlyDecalTiling()
const override {
return false; }
949 const SkIRect& dstRect)
const override {
951 "sigmaX", sigma.
width(),
"sigmaY", sigma.
height());
954 return skgpu::graphite::blur_impl(fRecorder, sigma, std::move(
src), srcRect, tileMode,
955 dstRect,
sk_ref_sp(cs), this->surfaceProps());
958 bool useLegacyFilterResultBlur()
const override {
return false; }
967 this->surfaceProps(),
984 return sk_make_sp<GraphiteBackend>(recorder, surfaceProps,
colorType);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define SKGPU_LOG_E(fmt,...)
#define SKGPU_LOG_W(fmt,...)
static sk_sp< Effect > Create()
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kUnknown_SkColorType
uninitialized
size_t SkCompressedFormatDataSize(SkTextureCompressionType compressionType, SkISize dimensions, bool mipmapped)
#define sk_float_ceil2int(x)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static uint32_t SkColorTypeChannelFlags(SkColorType ct)
static bool SkColorTypeIsAlphaOnly(SkColorType ct)
static bool SkImageInfoIsValid(const SkImageInfo &info)
static SkImage_Base * as_IB(SkImage *image)
sk_sp< T > sk_ref_sp(T *obj)
#define SK_ScalarInfinity
static constexpr bool SkToBool(const T &x)
#define TRACE_EVENT_SCOPE_THREAD
SkISize dimensions() const
const SkPixmap & pixmap() const
SkColorType colorType() const
const SkImageInfo & info() const
bool tryAllocPixels(const SkImageInfo &info, size_t rowBytes)
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
SkColorInfo makeAlphaType(SkAlphaType newAlphaType) const
SkColorInfo makeColorType(SkColorType newColorType) const
SkColorType colorType() const
bool gammaIsLinear() const
sk_sp< SkColorSpace > makeLinearGamma() const
const SkImageInfo & imageInfo() const
SkISize dimensions() const
SkAlphaType alphaType() const
SkColorType colorType() const
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z=0)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
static SkMipmap * Build(const SkPixmap &src, SkDiscardableFactoryProc, bool computeContents=true)
bool getLevel(int index, Level *) const
static int ComputeLevelCount(int baseWidth, int baseHeight)
SkColorType colorType() const
const void * addr() const
static SkSamplingOptions AnisoFallback(bool imageIsMipped)
virtual sk_sp< SkImage > asImage() const =0
sk_sp< SkSpecialImage > makeSubset(const SkIRect &subset) const
const SkIRect & subset() const
virtual sk_sp< SkShader > asShader(SkTileMode, const SkSamplingOptions &, const SkMatrix &lm, bool strict=true) const
SkColorType colorType() const
virtual SkImageInfo imageInfo() const
static sk_sp< RefCntedCallback > Make(Callback proc, Context ctx)
static constexpr Swizzle Concat(const Swizzle &a, const Swizzle &b)
skgpu::Swizzle getReadSwizzle(SkColorType, const TextureInfo &) const
bool isTexturable(const TextureInfo &) const
virtual TextureInfo getDefaultStorageTextureInfo(SkColorType) const =0
virtual bool isStorage(const TextureInfo &) const =0
SkColorType getRenderableColorType(SkColorType) const
virtual TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const =0
bool areColorTypeAndTextureInfoCompatible(SkColorType, const TextureInfo &) const
static sk_sp< CopyTextureToTextureTask > Make(sk_sp< TextureProxy > srcProxy, SkIRect srcRect, sk_sp< TextureProxy > dstProxy, SkIPoint dstPoint, int dstLevel=0)
static sk_sp< Device > Make(Recorder *recorder, sk_sp< TextureProxy >, SkISize deviceSize, const SkColorInfo &, const SkSurfaceProps &, LoadOp initialLoadOp, bool registerWithRecorder=true)
const TextureProxyView & textureProxyView() const
Protected isProtected() const
const Caps * caps() const
ResourceProvider * resourceProvider()
static sk_sp< TextureProxy > CreateCachedProxy(Recorder *, const SkBitmap &, std::string_view label)
ImageProvider * clientImageProvider()
sk_sp< Image > asImage() const
static sk_sp< Surface > MakeScratch(Recorder *recorder, const SkImageInfo &info, std::string_view label, Budgeted budgeted=Budgeted::kYes, Mipmapped mipmapped=Mipmapped::kNo, SkBackingFit backingFit=SkBackingFit::kApprox)
TextureProxy * proxy() const
static sk_sp< TextureProxy > Make(const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, std::string_view label, skgpu::Budgeted)
const TextureInfo & textureInfo() const
static sk_sp< TextureProxy > MakeLazy(const Caps *, SkISize dimensions, const TextureInfo &, skgpu::Budgeted, Volatile, LazyInstantiateCallback &&)
static UploadInstance Make(Recorder *, sk_sp< TextureProxy > targetProxy, const SkColorInfo &srcColorInfo, const SkColorInfo &dstColorInfo, SkSpan< const MipLevel > levels, const SkIRect &dstRect, std::unique_ptr< ConditionalUploadContext >)
static sk_sp< UploadTask > Make(UploadList *)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
static float max(float r, float g, float b)
static float min(float r, float g, float b)
void * GraphitePromiseTextureFulfillContext
std::tuple< skgpu::graphite::BackendTexture, GraphitePromiseTextureReleaseContext >(*)(GraphitePromiseTextureFulfillContext) GraphitePromiseTextureFulfillProc
void(*)(GraphitePromiseTextureReleaseContext) GraphitePromiseTextureReleaseProc
sk_sp< const SkImage > image
SkSamplingOptions sampling
sk_sp< SkSpecialImage > MakeGraphite(skgpu::graphite::Recorder *recorder, const SkIRect &subset, sk_sp< SkImage > image, const SkSurfaceProps &props)
SK_API sk_sp< SkImage > AsImage(sk_sp< const SkSurface >)
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
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
const myers::Point & get(const myers::Segment &)
bool GenerateMipmaps(Recorder *recorder, sk_sp< TextureProxy > texture, const SkColorInfo &colorInfo)
SkColorType ComputeShaderCoverageMaskTargetFormat(const Caps *caps)
sk_sp< SkImage > RescaleImage(Recorder *recorder, const SkImage *srcImage, SkIRect srcIRect, const SkImageInfo &dstInfo, SkImage::RescaleGamma rescaleGamma, SkImage::RescaleMode rescaleMode)
void Flush(sk_sp< SkSurface > surface)
sk_sp< TextureProxy > MakePromiseImageLazyProxy(const Caps *caps, SkISize dimensions, TextureInfo textureInfo, Volatile isVolatile, sk_sp< RefCntedCallback > releaseHelper, GraphitePromiseTextureFulfillProc fulfillProc, GraphitePromiseTextureFulfillContext fulfillContext, GraphitePromiseTextureReleaseProc textureReleaseProc, std::string_view label)
sk_sp< SkImage > MakeFromBitmap(Recorder *recorder, const SkColorInfo &colorInfo, const SkBitmap &bitmap, sk_sp< SkMipmap > mipmaps, Budgeted budgeted, SkImage::RequiredProperties requiredProps, std::string_view label)
std::pair< sk_sp< SkImage >, SkSamplingOptions > GetGraphiteBacked(Recorder *recorder, const SkImage *imageIn, SkSamplingOptions sampling)
size_t ComputeSize(SkISize dimensions, const TextureInfo &info)
std::tuple< TextureProxyView, SkColorType > MakeBitmapProxyView(Recorder *recorder, const SkBitmap &bitmap, sk_sp< SkMipmap > mipmapsIn, Mipmapped mipmapped, Budgeted budgeted, std::string_view label)
TextureProxyView AsView(const SkImage *image)
sk_sp< Image > CopyAsDraw(Recorder *recorder, const SkImage *image, const SkIRect &subset, const SkColorInfo &dstColorInfo, Budgeted budgeted, Mipmapped mipmapped, SkBackingFit backingFit, std::string_view label)
static constexpr int kMaxBlurSamples
static constexpr float kMaxLinearBlurSigma
void Compute2DBlurOffsets(SkISize radius, std::array< SkV4, kMaxBlurSamples/2 > &offsets)
const SkRuntimeEffect * GetLinearBlur1DEffect(int radius)
int BlurSigmaRadius(float sigma)
constexpr int BlurKernelWidth(int radius)
void Compute2DBlurKernel(SkSize sigma, SkISize radius, SkSpan< float > kernel)
const SkRuntimeEffect * GetBlur2DEffect(const SkISize &radii)
void Compute1DBlurLinearKernel(float sigma, int radius, std::array< SkV4, kMaxBlurSamples/2 > &offsetsAndKernel)
SkSamplingOptions(SkFilterMode::kLinear))
sk_sp< Backend > MakeGraphiteBackend(skgpu::graphite::Recorder *recorder, const SkSurfaceProps &surfaceProps, SkColorType colorType)
static constexpr SkCubicResampler CatmullRom()
SkIRect makeOutset(int32_t dx, int32_t dy) const
bool intersect(const SkIRect &r)
constexpr int32_t top() const
constexpr SkISize size() const
constexpr int32_t height() const
static constexpr SkIRect MakeSize(const SkISize &size)
constexpr int32_t width() const
void offset(int32_t dx, int32_t dy)
constexpr SkIRect makeOffset(int32_t dx, int32_t dy) const
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
constexpr SkIPoint topLeft() const
void outset(int32_t dx, int32_t dy)
constexpr int32_t left() const
static constexpr SkISize Make(int32_t w, int32_t h)
constexpr int32_t width() const
constexpr int32_t height() const
constexpr int64_t area() const
const SkColorInfo & colorInfo() const
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
SkImageInfo makeDimensions(SkISize newSize) const
SkColorSpace * colorSpace() const
SkISize dimensions() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkColorType colorType() const
static SkRect Make(const SkISize &size)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
void roundOut(SkIRect *dst) const
constexpr float height() const
constexpr float width() const
const SkMipmapMode mipmap
std::shared_ptr< const fml::Mapping > data
#define TRACE_EVENT0(category_group, name)
#define TRACE_EVENT_INSTANT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val)