15#include "third_party/skia/include/core/SkColorSpace.h"
16#include "third_party/skia/include/core/SkColorType.h"
17#include "third_party/skia/include/core/SkSurface.h"
18#include "third_party/skia/include/gpu/ganesh/GrBackendSurface.h"
19#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
20#include "third_party/skia/include/gpu/ganesh/gl/GrGLAssembleInterface.h"
21#include "third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h"
22#include "third_party/skia/include/gpu/ganesh/gl/GrGLDirectContext.h"
23#include "third_party/skia/include/gpu/ganesh/gl/GrGLTypes.h"
28 std::shared_ptr<TestEGLContext> context,
30 : surface_size_(
size), egl_context_(
std::move(context)) {
31 const EGLint attributes[] = {
32 EGL_WIDTH,
size.width,
33 EGL_HEIGHT,
size.height,
61 if (result == EGL_FALSE) {
65 return result == EGL_TRUE;
69 auto result = ::eglMakeCurrent(
egl_context_->display, EGL_NO_SURFACE,
70 EGL_NO_SURFACE, EGL_NO_CONTEXT);
72 if (result == EGL_FALSE) {
76 return result == EGL_TRUE;
82 if (result == EGL_FALSE) {
86 return result == EGL_TRUE;
95 if (
name ==
nullptr) {
98 auto symbol = ::eglGetProcAddress(
name);
100 FML_LOG(ERROR) <<
"Could not fetch symbol for name: " <<
name;
102 return reinterpret_cast<void*
>(symbol);
119 reinterpret_cast<PFNGLGETSTRINGPROC
>(
GetProcAddress(
"glGetString"));
125 auto c_version =
reinterpret_cast<const char*
>(get_string(GL_VERSION));
127 if (c_version == NULL) {
131 GrGLGetProc get_proc = [](
void* context,
const char name[]) -> GrGLFuncPtr {
132 return reinterpret_cast<GrGLFuncPtr
>(
137 std::string version(c_version);
138 auto interface = version.find(
"OpenGL ES") == std::string::npos
139 ? GrGLMakeAssembledGLInterface(
this, get_proc)
140 : GrGLMakeAssembledGLESInterface(
this, get_proc);
151 FML_CHECK(::eglGetCurrentContext() != EGL_NO_CONTEXT);
153 GrGLFramebufferInfo framebuffer_info = {};
158 framebuffer_info.fFormat = 0x8058;
160 framebuffer_info.fFormat = 0x93A1;
163 auto backend_render_target =
164 GrBackendRenderTargets::MakeGL(
width,
171 SkSurfaceProps surface_properties(0, kUnknown_SkPixelGeometry);
173 auto surface = SkSurfaces::WrapBackendRenderTarget(
175 backend_render_target,
176 kBottomLeft_GrSurfaceOrigin,
178 SkColorSpace::MakeSRGB(),
185 FML_LOG(ERROR) <<
"Could not wrap the surface while attempting to "
186 "snapshot the GL surface.";
197 FML_LOG(ERROR) <<
"Aborting snapshot because of on-screen surface "
198 "acquisition failure.";
202 auto device_snapshot =
surface->makeImageSnapshot();
204 if (!device_snapshot) {
205 FML_LOG(ERROR) <<
"Could not create the device snapshot while attempting "
206 "to snapshot the GL surface.";
210 auto host_snapshot = device_snapshot->makeRasterImage(
nullptr);
212 if (!host_snapshot) {
213 FML_LOG(ERROR) <<
"Could not create the host snapshot while attempting to "
214 "snapshot the GL surface.";
218 return host_snapshot;
232 const EGLint offscreen_surface_attributes[] = {
237 offscreen_surface_ = ::eglCreatePbufferSurface(
240 offscreen_surface_attributes
247 auto result = ::eglDestroySurface(
egl_context_->display, offscreen_surface_);
253 ::eglMakeCurrent(
egl_context_->display, offscreen_surface_,
256 if (result == EGL_FALSE) {
257 FML_LOG(ERROR) <<
"Could not make the resource context current. "
261 return result == EGL_TRUE;
void * GetProcAddress(const char *name) const
sk_sp< GrDirectContext > GetGrContext()
sk_sp< SkSurface > GetOnscreenSurface()
~TestGLOnscreenOnlySurface()
EGLSurface onscreen_surface_
uint32_t GetWindowFBOId() const
const DlISize surface_size_
const DlISize & GetSurfaceSize() const
sk_sp< SkImage > GetRasterSurfaceSnapshot()
std::shared_ptr< TestEGLContext > egl_context_
TestGLOnscreenOnlySurface(DlISize surface_size)
sk_sp< GrDirectContext > CreateGrContext()
uint32_t GetFramebuffer(uint32_t width, uint32_t height) const
sk_sp< GrDirectContext > skia_context_
TestGLSurface(DlISize surface_size)
bool MakeResourceCurrent()
#define FML_LOG(severity)
#define FML_CHECK(condition)
std::string GetEGLError()
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
DEF_SWITCHES_START aot vmservice shared library name