14 const std::shared_ptr<AndroidContextGLImpeller>& android_context)
15 : android_context_(android_context) {
16 offscreen_surface_ = android_context_->CreateOffscreenSurface();
18 if (!offscreen_surface_) {
19 FML_DLOG(ERROR) <<
"Could not create offscreen surface.";
37 GrDirectContext* gr_context) {
38 auto surface = std::make_unique<GPUSurfaceGLImpeller>(
40 android_context_->GetImpellerContext(),
52 onscreen_surface_.reset();
59 return RecreateOnscreenSurfaceAndMakeOnscreenContextCurrent();
64 if (!offscreen_surface_) {
67 return android_context_->ResourceContextMakeCurrent(offscreen_surface_.get());
72 return android_context_->ResourceContextClearCurrent();
78 const std::shared_ptr<PlatformViewAndroidJNI>& jni_facade) {
79 native_window_ = std::move(
window);
80 return RecreateOnscreenSurfaceAndMakeOnscreenContextCurrent();
85 if (!onscreen_surface_ || !onscreen_surface_->IsValid()) {
86 onscreen_surface_ = android_context_->CreateOffscreenSurface();
87 if (!onscreen_surface_) {
88 FML_DLOG(ERROR) <<
"Could not create offscreen surface for snapshot.";
94 if (!android_context_->OnscreenContextMakeCurrent(onscreen_surface_.get())) {
95 FML_DLOG(ERROR) <<
"Could not make snapshot surface current.";
98 return std::make_unique<GPUSurfaceGLImpeller>(
100 android_context_->GetImpellerContext(),
106std::shared_ptr<impeller::Context>
108 return android_context_->GetImpellerContext();
112std::unique_ptr<GLContextResult>
114 return std::make_unique<GLContextDefaultResult>(OnGLContextMakeCurrent());
117bool AndroidSurfaceGLImpeller::OnGLContextMakeCurrent() {
118 if (!onscreen_surface_) {
122 return android_context_->OnscreenContextMakeCurrent(onscreen_surface_.get());
127 if (!onscreen_surface_) {
131 return android_context_->OnscreenContextClearCurrent();
139 info.supports_partial_repaint =
false;
145 const std::optional<DlIRect>& region) {
154 if (!onscreen_surface_) {
157 return onscreen_surface_->Present();
173bool AndroidSurfaceGLImpeller::
174 RecreateOnscreenSurfaceAndMakeOnscreenContextCurrent() {
176 if (!native_window_) {
179 onscreen_surface_.reset();
180 auto onscreen_surface =
181 android_context_->CreateOnscreenSurface(native_window_->handle());
182 if (!onscreen_surface) {
183 FML_DLOG(ERROR) <<
"Could not create onscreen surface.";
186 onscreen_surface_ = std::move(onscreen_surface);
187 return OnGLContextMakeCurrent();
SurfaceFrame::FramebufferInfo GLContextFramebufferInfo() const override
bool ResourceContextMakeCurrent() override
bool ResourceContextClearCurrent() override
void TeardownOnScreenContext() override
bool SetNativeWindow(fml::RefPtr< AndroidNativeWindow > window, const std::shared_ptr< PlatformViewAndroidJNI > &jni_facade) override
sk_sp< const GrGLInterface > GetGLInterface() const override
bool GLContextClearCurrent() override
bool GLContextPresent(const GLPresentInfo &present_info) override
AndroidSurfaceGLImpeller(const std::shared_ptr< AndroidContextGLImpeller > &android_context)
void GLContextSetDamageRegion(const std::optional< DlIRect > ®ion) override
~AndroidSurfaceGLImpeller() override
GLFBOInfo GLContextFBO(GLFrameInfo frame_info) const override
bool IsValid() const override
std::shared_ptr< impeller::Context > GetImpellerContext() override
std::unique_ptr< GLContextResult > GLContextMakeCurrent() override
std::unique_ptr< Surface > CreateSnapshotSurface() override
std::unique_ptr< Surface > CreateGPUSurface(GrDirectContext *gr_context) override
bool OnScreenSurfaceResize(const DlISize &size) override
#define FML_DLOG(severity)
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