5#ifndef FLUTTER_LIB_UI_PAINTING_IMAGE_ENCODING_IMPL_H_
6#define FLUTTER_LIB_UI_PAINTING_IMAGE_ENCODING_IMPL_H_
8#include "flutter/lib/ui/ui_dart_state.h"
17template <
typename SyncSwitch>
21 const std::shared_ptr<const SyncSwitch>& is_gpu_disabled_sync_switch) {
25 is_gpu_disabled_sync_switch->Execute(
26 typename SyncSwitch::Handlers()
27 .SetIfTrue([&
surface, &surface_info] {
30 .SetIfFalse([&
surface, &surface_info, resource_context] {
31 if (resource_context) {
40 FML_LOG(
ERROR) <<
"Could not create a surface to copy the texture into.";
45 if (resource_context) {
46 resource_context->flushAndSubmit();
49 auto snapshot =
surface->makeImageSnapshot();
51 if (snapshot ==
nullptr) {
56 return snapshot->makeRasterImage();
SkISize dimensions() const
#define FML_LOG(severity)
sk_sp< const SkImage > image
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
sk_sp< SkImage > ConvertToRasterUsingResourceContext(const sk_sp< SkImage > &image, const fml::WeakPtr< GrDirectContext > &resource_context, const std::shared_ptr< const SyncSwitch > &is_gpu_disabled_sync_switch)
static SkImageInfo MakeN32Premul(int width, int height)