15#define EGL_PROTECTED_CONTENT_EXT 0x32C0
16#define GL_GLEXT_PROTOTYPES
18#include <EGL/eglext.h>
25 auto display = eglGetCurrentDisplay();
26 auto dsurface = eglGetCurrentSurface(EGL_DRAW);
27 auto rsurface = eglGetCurrentSurface(EGL_READ);
28 auto context = eglGetCurrentContext();
29 return [display, dsurface, rsurface, context] {
30 eglMakeCurrent(display, dsurface, rsurface, context);
36 EGLGLTestContext(
GrGLStandard forcedGpuAPI, EGLGLTestContext* shareContext);
37 ~EGLGLTestContext()
override;
40 void destroyEGLImage(
GrEGLImage)
const override;
42 std::unique_ptr<sk_gpu_test::GLTestContext> makeNew()
const override;
45 void destroyGLContext();
47 void onPlatformMakeNotCurrent()
const override;
48 void onPlatformMakeCurrent()
const override;
49 std::function<void()> onPlatformGetAutoContextRestore()
const override;
50 GrGLFuncPtr onPlatformGetProcAddress(
const char*)
const override;
52 PFNEGLCREATEIMAGEKHRPROC fEglCreateImageProc =
nullptr;
53 PFNEGLDESTROYIMAGEKHRPROC fEglDestroyImageProc =
nullptr;
60static EGLContext create_gles_egl_context(EGLDisplay display,
61 EGLConfig surfaceConfig,
62 EGLContext eglShareContext,
63 EGLint eglContextClientVersion,
64 bool createProtected) {
66 std::vector<EGLint> contextAttribs = {
67 EGL_CONTEXT_CLIENT_VERSION, eglContextClientVersion,
70 if (createProtected) {
72 contextAttribs.push_back(EGL_TRUE);
75 contextAttribs.push_back(EGL_NONE);
77 return eglCreateContext(display, surfaceConfig, eglShareContext, contextAttribs.data());
80static EGLContext create_gl_egl_context(EGLDisplay display,
81 EGLConfig surfaceConfig,
82 EGLContext eglShareContext,
83 bool createProtected) {
85 std::vector<EGLint> contextAttribs;
87 if (createProtected) {
89 contextAttribs.push_back(EGL_TRUE);
92 contextAttribs.push_back(EGL_NONE);
94 return eglCreateContext(display, surfaceConfig, eglShareContext, contextAttribs.data());
97EGLGLTestContext::EGLGLTestContext(
GrGLStandard forcedGpuAPI, EGLGLTestContext* shareContext)
99 , fDisplay(EGL_NO_DISPLAY)
100 , fSurface(EGL_NO_SURFACE) {
102 EGLContext eglShareContext = shareContext ? shareContext->fContext :
nullptr;
120 for (;
nullptr ==
gl.get() && api < apiLimit; ++api) {
121 fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
125 eglInitialize(fDisplay, &majorVersion, &minorVersion);
127 const char*
extensions = eglQueryString(fDisplay, EGL_EXTENSIONS);
130 SkDebugf(
"VENDOR: %s\n", eglQueryString(fDisplay, EGL_VENDOR));
131 SkDebugf(
"APIS: %s\n", eglQueryString(fDisplay, EGL_CLIENT_APIS));
132 SkDebugf(
"VERSION: %s\n", eglQueryString(fDisplay, EGL_VERSION));
137 if (!eglBindAPI(gles ? EGL_OPENGL_ES_API : EGL_OPENGL_API)) {
141 EGLint numConfigs = 0;
142 const EGLint configAttribs[] = {
143 EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
144 EGL_RENDERABLE_TYPE, gles ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
152 EGLConfig surfaceConfig;
153 if (!eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs)) {
154 SkDebugf(
"eglChooseConfig failed. EGL Error: 0x%08x\n", eglGetError());
158 if (0 == numConfigs) {
159 SkDebugf(
"No suitable EGL config found.\n");
164 if (createProtected && !strstr(
extensions,
"EGL_EXT_protected_content")) {
165 SkDebugf(
"Missing EGL_EXT_protected_content support!\n");
166 createProtected =
false;
170#if defined(GR_EGL_TRY_GLES3_THEN_GLES2)
173 fContext = create_gles_egl_context(fDisplay, surfaceConfig, eglShareContext, 3,
176 fContext = create_gles_egl_context(fDisplay, surfaceConfig, eglShareContext, 2,
180 fContext = create_gles_egl_context(fDisplay, surfaceConfig, eglShareContext, 2,
184 fContext = create_gl_egl_context(fDisplay, surfaceConfig, eglShareContext,
188 SkDebugf(
"eglCreateContext failed. EGL Error: 0x%08x\n", eglGetError());
192 static const EGLint kSurfaceAttribs[] = {
196 createProtected ? EGL_TRUE : EGL_NONE,
200 fSurface = eglCreatePbufferSurface(fDisplay, surfaceConfig, kSurfaceAttribs);
201 if (EGL_NO_SURFACE == fSurface) {
202 SkDebugf(
"eglCreatePbufferSurface failed. EGL Error: 0x%08x\n", eglGetError());
203 this->destroyGLContext();
208 if (!eglMakeCurrent(fDisplay, fSurface, fSurface,
fContext)) {
209 SkDebugf(
"eglMakeCurrent failed. EGL Error: 0x%08x\n", eglGetError());
210 this->destroyGLContext();
217 SkDebugf(
"Failed to create gl interface.\n");
218 this->destroyGLContext();
222 if (!
gl->validate()) {
223 SkDebugf(
"Failed to validate gl interface.\n");
224 this->destroyGLContext();
228 fEglCreateImageProc = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress(
"eglCreateImageKHR");
229 fEglDestroyImageProc =
230 (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress(
"eglDestroyImageKHR");
233 this->
init(std::move(
gl));
244EGLGLTestContext::~EGLGLTestContext() {
246 this->destroyGLContext();
249void EGLGLTestContext::destroyGLContext() {
252 if (eglGetCurrentContext() ==
fContext) {
254 eglMakeCurrent(fDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
256 eglDestroyContext(fDisplay,
fContext);
261 eglDestroySurface(fDisplay, fSurface);
262 fSurface = EGL_NO_SURFACE;
266 fDisplay = EGL_NO_DISPLAY;
272 if (!this->
gl()->hasExtension(
"EGL_KHR_gl_texture_2D_image") || !fEglCreateImageProc) {
279 (void)fEglCreateImageProc;
285 fEglDestroyImageProc(fDisplay,
image);
291 if (!this->
gl()->hasExtension(
"GL_OES_EGL_image_external")) {
296 EGLImageTargetTexture2DProc glEGLImageTargetTexture2D =
297 (EGLImageTargetTexture2DProc) eglGetProcAddress(
"glEGLImageTargetTexture2DOES");
298 if (!glEGLImageTargetTexture2D) {
322std::unique_ptr<sk_gpu_test::GLTestContext> EGLGLTestContext::makeNew()
const {
323 std::unique_ptr<sk_gpu_test::GLTestContext> ctx(
new EGLGLTestContext(this->
gl()->fStandard,
331void EGLGLTestContext::onPlatformMakeNotCurrent()
const {
332 if (!eglMakeCurrent(fDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT )) {
333 SkDebugf(
"Could not reset the context.\n");
337void EGLGLTestContext::onPlatformMakeCurrent()
const {
338 if (!eglMakeCurrent(fDisplay, fSurface, fSurface,
fContext)) {
339 SkDebugf(
"Could not set the context.\n");
343std::function<void()> EGLGLTestContext::onPlatformGetAutoContextRestore()
const {
344 if (eglGetCurrentContext() ==
fContext) {
347 return context_restorer();
350GrGLFuncPtr EGLGLTestContext::onPlatformGetProcAddress(
const char* procName)
const {
351 return eglGetProcAddress(procName);
358 GLTestContext *shareContext) {
359 EGLGLTestContext* eglShareContext =
reinterpret_cast<EGLGLTestContext*
>(shareContext);
360 EGLGLTestContext *ctx =
new EGLGLTestContext(forcedGpuAPI, eglShareContext);
361 if (!ctx->isValid()) {
bool gCreateProtectedContext
#define EGL_PROTECTED_CONTENT_EXT
#define GR_EGL_GL_TEXTURE_2D
#define GR_EGL_GL_TEXTURE_LEVEL
#define GR_GL_TEXTURE_EXTERNAL
#define GR_GL_CALL_NOERRCHECK(IFACE, X)
#define GR_GL_CALL(IFACE, X)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
Dart_NativeFunction function
SK_API sk_sp< const GrGLInterface > MakeEGL()
sk_sp< const SkImage > image
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
GLTestContext * CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, GLTestContext *shareContext)