5#include "flutter/shell/platform/embedder/tests/embedder_test_context_gl.h"
9#include "flutter/fml/make_copyable.h"
10#include "flutter/fml/paths.h"
11#include "flutter/runtime/dart_vm.h"
12#include "flutter/shell/platform/embedder/tests/embedder_assertions.h"
13#include "flutter/shell/platform/embedder/tests/embedder_test_compositor_gl.h"
14#include "flutter/testing/testing.h"
16#include "third_party/dart/runtime/bin/elf_loader.h"
29void EmbedderTestContextGL::SetupSurface(
SkISize surface_size) {
31 gl_surface_ = std::make_unique<TestGLSurface>(surface_size);
34bool EmbedderTestContextGL::GLMakeCurrent() {
35 FML_CHECK(gl_surface_) <<
"GL surface must be initialized.";
36 return gl_surface_->MakeCurrent();
39bool EmbedderTestContextGL::GLClearCurrent() {
40 FML_CHECK(gl_surface_) <<
"GL surface must be initialized.";
41 return gl_surface_->ClearCurrent();
45 FML_CHECK(gl_surface_) <<
"GL surface must be initialized.";
46 gl_surface_present_count_++;
50 std::scoped_lock lock(gl_callback_mutex_);
59 [&]() {
return gl_surface_->GetRasterSurfaceSnapshot(); });
61 return gl_surface_->Present();
65 std::scoped_lock lock(gl_callback_mutex_);
66 gl_get_fbo_callback_ = std::move(
callback);
71 std::scoped_lock lock(gl_callback_mutex_);
72 gl_populate_existing_damage_callback_ = std::move(
callback);
76 std::scoped_lock lock(gl_callback_mutex_);
77 gl_present_callback_ = std::move(
callback);
80uint32_t EmbedderTestContextGL::GLGetFramebuffer(
FlutterFrameInfo frame_info) {
81 FML_CHECK(gl_surface_) <<
"GL surface must be initialized.";
85 std::scoped_lock lock(gl_callback_mutex_);
94 return gl_surface_->GetFramebuffer(
size.width,
size.height);
100 FML_CHECK(gl_surface_) <<
"GL surface must be initialized.";
104 std::scoped_lock lock(gl_callback_mutex_);
105 callback = gl_populate_existing_damage_callback_;
113bool EmbedderTestContextGL::GLMakeResourceCurrent() {
114 FML_CHECK(gl_surface_) <<
"GL surface must be initialized.";
115 return gl_surface_->MakeResourceCurrent();
119 FML_CHECK(gl_surface_) <<
"GL surface must be initialized.";
120 return gl_surface_->GetProcAddress(
name);
124 return gl_surface_present_count_;
133 return gl_surface_->GetWindowFBOId();
139 <<
"Set up the GL surface before setting up a compositor.";
140 compositor_ = std::make_unique<EmbedderTestCompositorGL>(
141 gl_surface_->GetSurfaceSize(), gl_surface_->GetGrContext());
std::function< void(FlutterPresentInfo present_info)> GLPresentCallback
void * GLGetProcAddress(const char *name)
virtual void SetupCompositor() override
void SetGLGetFBOCallback(GLGetFBOCallback callback)
Sets a callback that will be invoked (on the raster task runner) when the engine asks the embedder fo...
size_t GetSurfacePresentCount() const override
void GLPopulateExistingDamage(const intptr_t id, FlutterDamage *existing_damage)
uint32_t GetWindowFBOId() const
~EmbedderTestContextGL() override
EmbedderTestContextType GetContextType() const override
void SetGLPopulateExistingDamageCallback(GLPopulateExistingDamageCallback callback)
std::function< void(FlutterFrameInfo frame_info)> GLGetFBOCallback
void SetGLPresentCallback(GLPresentCallback callback)
Sets a callback that will be invoked (on the raster task runner) when the engine presents an fbo that...
std::function< void(intptr_t id, FlutterDamage *existing_damage)> GLPopulateExistingDamageCallback
EmbedderTestContextGL(std::string assets_path="")
std::unique_ptr< EmbedderTestCompositor > compositor_
void FireRootSurfacePresentCallbackIfPresent(const std::function< sk_sp< SkImage >(void)> &image_callback)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_CHECK(condition)
DEF_SWITCHES_START aot vmservice shared library name
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
A structure to represent a damage region.
FlutterUIntSize size
The size of the surface that will be backed by the fbo.