10#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
11#include "third_party/skia/include/gpu/ganesh/GrRecordingContext.h"
13#ifdef IMPELLER_SUPPORTS_RENDERING
22 const auto transformed_rect =
23 source_rect.TransformAndClipBounds(transformation);
29 const DlMatrix& surface_transformation)
34 const DlMatrix& surface_transformation,
36 std::unique_ptr<EmbeddedViewParams>
params)
37 : render_surface_size_(
39 surface_transformation_(surface_transformation),
43 DlRect::MakeSize(frame_size))) {}
53 return slice_->canvas();
57 return render_surface_size_;
69 return slice_->getRegion();
73 if (has_engine_rendered_contents_.has_value()) {
74 return has_engine_rendered_contents_.value();
78 slice_->dispatch(dl_op_spy);
79 has_engine_rendered_contents_ = dl_op_spy.
did_draw() && !slice_->is_empty();
81 return has_engine_rendered_contents_.value();
86 return view_identifier_;
90 return embedded_view_params_.get();
97 auto recording_context = skia_surface.recordingContext();
100 FML_DCHECK(recording_context) <<
"Recording context was null.";
102 auto direct_context = recording_context->asDirectContext();
103 if (direct_context ==
nullptr) {
106 FML_LOG(ERROR) <<
"Embedder asked to invalidate cached graphics API state "
107 "but Flutter is not using a graphics API.";
109 direct_context->resetContext(kAll_GrBackendState);
115 bool clear_surface) {
116 TRACE_EVENT0(
"flutter",
"EmbedderExternalView::Render");
119 <<
"Unnecessarily asked to render into a render target when there was "
120 "nothing to render.";
122#ifdef IMPELLER_SUPPORTS_RENDERING
124 if (impeller_target) {
128 dl_builder.SetTransform(surface_transformation_);
129 slice_->render_into(&dl_builder);
130 auto display_list = dl_builder.Build();
146 FML_LOG(FATAL) <<
"Impeller opt-out unavailable.";
156 if (invalidate_api_state) {
160 FML_LOG(ERROR) <<
"Could not make the surface current.";
168 if (invalidate_api_state) {
172 FML_LOG(ERROR) <<
"Could not clear the current surface.";
178 auto canvas = skia_surface->getCanvas();
188 slice_->render_into(&dl_canvas);
196void EmbedderExternalView::TryEndRecording()
const {
197 if (slice_->recording_ended()) {
200 slice_->end_recording();
Developer-facing API for rendering anything within the engine.
void Clear(DlColor color)
bool did_draw()
Returns true if any non transparent content has been drawn.
Backend implementation of |DlCanvas| for |SkCanvas|.
int GetSaveCount() const override
void SetTransform(const DlMatrix &matrix) override
void RestoreToCount(int restore_count) override
const EmbeddedViewParams * GetEmbeddedViewParams() const
RenderTargetDescriptor CreateRenderTargetDescriptor() const
bool Render(const EmbedderRenderTarget &render_target, bool clear_surface=true)
EmbedderExternalView(const DlISize &frame_size, const DlMatrix &surface_transformation)
const DlRegion & GetDlRegion() const
bool HasPlatformView() const
ViewIdentifier GetViewIdentifier() const
DlISize GetRenderSurfaceSize() const
bool HasEngineRenderedContents()
Describes a surface whose backing store is managed by the embedder. The type of surface depends on th...
virtual impeller::RenderTarget * GetImpellerRenderTarget() const =0
An impeller render target the rasterizer can use to draw into the backing store.
virtual sk_sp< SkSurface > GetSkiaSurface() const =0
A render surface the rasterizer can use to draw into the backing store of this render target.
virtual SetCurrentResult MaybeClearCurrent() const
Clear the current render target.
virtual std::shared_ptr< impeller::AiksContext > GetAiksContext() const =0
Returns the AiksContext that should be used for rendering, if this render target is backed by Impelle...
virtual SetCurrentResult MaybeMakeCurrent() const
Make the render target current.
virtual DlISize GetRenderTargetSize() const =0
Returns the size of the render target.
Wraps a closure that is invoked in the destructor unless released by the caller.
EmbedderExternalView::ViewIdentifier view_identifier
const EmbeddedViewParams * params
#define FML_LOG(severity)
#define FML_DCHECK(condition)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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 void InvalidateApiState(SkSurface &skia_surface)
static DlISize TransformedSurfaceSize(const DlISize &size, const DlMatrix &transformation)
bool RenderToTarget(ContentContext &context, RenderTarget render_target, const sk_sp< flutter::DisplayList > &display_list, Rect cull_rect, bool reset_host_buffer, bool is_onscreen)
Render the provided display list to the render target.
static constexpr DlColor kTransparent()
std::optional< PlatformViewID > platform_view_id
A 4x4 matrix using column-major storage.
RoundOut(const TRect< U > &r)
static constexpr TRect MakeSize(const TSize< U > &size)
#define TRACE_EVENT0(category_group, name)