5#include "flutter/shell/common/snapshot_controller_skia.h"
8#include "flutter/flow/surface.h"
9#include "flutter/fml/trace_event.h"
10#include "flutter/shell/common/snapshot_controller.h"
20 const std::function<
void(
SkCanvas*)>& draw_callback) {
25 draw_callback(
surface->getCanvas());
28 dContext->flushAndSubmit();
34 device_snapshot =
surface->makeImageSnapshot();
37 if (device_snapshot ==
nullptr) {
43 if (
auto raster_image = device_snapshot->makeRasterImage()) {
54 std::function<
void(
SkCanvas*)> draw_callback) {
60 std::unique_ptr<Surface> pbuffer_surface;
61 Surface* snapshot_surface =
nullptr;
63 if (delegate.GetSurface() && delegate.GetSurface()->GetContext()) {
64 snapshot_surface = delegate.GetSurface().get();
65 }
else if (delegate.GetSnapshotSurfaceProducer()) {
67 delegate.GetSnapshotSurfaceProducer()->CreateSnapshotSurface();
68 if (pbuffer_surface && pbuffer_surface->GetContext()) {
69 snapshot_surface = pbuffer_surface.get();
73 if (!snapshot_surface) {
77 result = DrawSnapshot(sk_surface, draw_callback);
79 delegate.GetIsGpuDisabledSyncSwitch()->Execute(
88 snapshot_surface->MakeRenderContextCurrent();
89 if (!context_switch->GetResult()) {
95 double scale_factor = std::min(
96 1.0,
static_cast<double>(max_size) /
97 static_cast<double>(std::max(image_info.
width(),
103 if (scale_factor < 1.0) {
104 image_info = image_info.
makeWH(
105 static_cast<double>(image_info.
width()) * scale_factor,
106 static_cast<double>(image_info.
height()) * scale_factor);
118 <<
"DoMakeRasterSnapshot can not create GPU render target";
122 sk_surface->getCanvas()->scale(scale_factor, scale_factor);
123 result = DrawSnapshot(sk_surface, draw_callback);
135 return DoMakeRasterSnapshot(
size, [display_list](
SkCanvas* canvas) {
146 GetDelegate().GetSurface()->GetContext() ==
nullptr) {
150 if (
image ==
nullptr) {
156 auto result = DoMakeRasterSnapshot(
160 return result->skia_image();
164 const std::shared_ptr<impeller::RuntimeStage>& runtime_stage) {}
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
SK_API int maxRenderTargetSize() const
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
static sk_sp< SkColorSpace > MakeSRGB()
SkISize dimensions() const
static sk_sp< DlImage > Make(const SkImage *image)
Backend implementation of |DlCanvas| for |SkCanvas|.
void DrawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1) override
void CacheRuntimeStage(const std::shared_ptr< impeller::RuntimeStage > &runtime_stage) override
virtual sk_sp< SkImage > ConvertToRasterImage(sk_sp< SkImage > image) override
sk_sp< DlImage > MakeRasterSnapshot(sk_sp< DisplayList > display_list, SkISize size) override
const Delegate & GetDelegate()
#define FML_LOG(severity)
#define FML_DCHECK(condition)
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)
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
SkImageInfo makeWH(int newWidth, int newHeight) const
static SkImageInfo MakeN32Premul(int width, int height)
Represents the 2 code paths available when calling |SyncSwitchExecute|.
#define TRACE_EVENT0(category_group, name)