Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
skwindow::internal::ANGLEWindowContext Class Referenceabstract

#include <ANGLEWindowContext.h>

Inheritance diagram for skwindow::internal::ANGLEWindowContext:
skwindow::internal::GLWindowContext skwindow::WindowContext

Public Member Functions

 ~ANGLEWindowContext () override
 
 GLWindowContext (const DisplayParams &)
 
- Public Member Functions inherited from skwindow::internal::GLWindowContext
sk_sp< SkSurfacegetBackbufferSurface () override
 
bool isValid () override
 
void resize (int w, int h) override
 
void setDisplayParams (const DisplayParams &params) override
 
- Public Member Functions inherited from skwindow::WindowContext
 WindowContext (const DisplayParams &)
 
virtual ~WindowContext ()
 
void swapBuffers ()
 
virtual void activate (bool isActive)
 
const DisplayParamsgetDisplayParams ()
 
GrDirectContextdirectContext () const
 
int width () const
 
int height () const
 
SkISize dimensions () const
 
int sampleCount () const
 
int stencilBits () const
 

Protected Member Functions

void onSwapBuffers () override
 
sk_sp< const GrGLInterfaceonInitializeContext () override
 
void onDestroyContext () override
 
virtual EGLDisplay onGetEGLDisplay (PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT) const =0
 
virtual NativeWindowType onGetNativeWindow () const =0
 
virtual SkISize onGetSize () const =0
 
virtual int onGetStencilBits () const =0
 
- Protected Member Functions inherited from skwindow::internal::GLWindowContext
 GLWindowContext (const DisplayParams &)
 
void initializeContext ()
 
void destroyContext ()
 
- Protected Member Functions inherited from skwindow::WindowContext
virtual bool isGpuContext ()
 

Additional Inherited Members

- Protected Attributes inherited from skwindow::internal::GLWindowContext
sk_sp< const GrGLInterfacefBackendContext
 
sk_sp< SkSurfacefSurface
 
- Protected Attributes inherited from skwindow::WindowContext
sk_sp< GrDirectContextfContext
 
int fWidth
 
int fHeight
 
DisplayParams fDisplayParams
 
int fSampleCount = 1
 
int fStencilBits = 0
 

Detailed Description

Definition at line 18 of file ANGLEWindowContext.h.

Constructor & Destructor Documentation

◆ ~ANGLEWindowContext()

skwindow::internal::ANGLEWindowContext::~ANGLEWindowContext ( )
override

Definition at line 15 of file ANGLEWindowContext.cpp.

Member Function Documentation

◆ GLWindowContext()

skwindow::internal::GLWindowContext::GLWindowContext ( const DisplayParams params)

Definition at line 31 of file GLWindowContext.cpp.

27 , fBackendContext(nullptr)
28 , fSurface(nullptr) {
30}
static uint32_t GrNextPow2(uint32_t n)
Definition SkMathPriv.h:302
DisplayParams fDisplayParams
WindowContext(const DisplayParams &)
sk_sp< const GrGLInterface > fBackendContext
const EmbeddedViewParams * params

◆ onDestroyContext()

void skwindow::internal::ANGLEWindowContext::onDestroyContext ( )
overrideprotectedvirtual

Implements skwindow::internal::GLWindowContext.

Definition at line 100 of file ANGLEWindowContext.cpp.

100 {
101 eglMakeCurrent(fDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
102 if (EGL_NO_CONTEXT != fEGLContext) {
103 eglDestroyContext(fDisplay, fEGLContext);
104 }
105 if (EGL_NO_SURFACE != fEGLSurface) {
106 eglDestroySurface(fDisplay, fEGLSurface);
107 }
108 if (EGL_NO_DISPLAY != fDisplay) {
109 eglTerminate(fDisplay);
110 }
111}

◆ onGetEGLDisplay()

virtual EGLDisplay skwindow::internal::ANGLEWindowContext::onGetEGLDisplay ( PFNEGLGETPLATFORMDISPLAYEXTPROC  eglGetPlatformDisplayEXT) const
protectedpure virtual

◆ onGetNativeWindow()

virtual NativeWindowType skwindow::internal::ANGLEWindowContext::onGetNativeWindow ( ) const
protectedpure virtual

◆ onGetSize()

virtual SkISize skwindow::internal::ANGLEWindowContext::onGetSize ( ) const
protectedpure virtual

◆ onGetStencilBits()

virtual int skwindow::internal::ANGLEWindowContext::onGetStencilBits ( ) const
protectedpure virtual

◆ onInitializeContext()

sk_sp< const GrGLInterface > skwindow::internal::ANGLEWindowContext::onInitializeContext ( )
overrideprotectedvirtual

Implements skwindow::internal::GLWindowContext.

Definition at line 17 of file ANGLEWindowContext.cpp.

17 {
18 PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT =
19 (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
20
21 // We expect ANGLE to support this extension
22 if (!eglGetPlatformDisplayEXT) {
23 return nullptr;
24 }
25
26 fDisplay = this->onGetEGLDisplay(eglGetPlatformDisplayEXT);
27 if (EGL_NO_DISPLAY == fDisplay) {
28 return nullptr;
29 }
30
31 EGLint majorVersion;
32 EGLint minorVersion;
33 if (!eglInitialize(fDisplay, &majorVersion, &minorVersion)) {
34 SkDebugf("Could not initialize display!\n");
35 return nullptr;
36 }
37 EGLint numConfigs;
39 const int sampleBuffers = fSampleCount > 1 ? 1 : 0;
40 const int eglSampleCnt = fSampleCount > 1 ? fSampleCount : 0;
41 const EGLint configAttribs[] = {EGL_RENDERABLE_TYPE,
42 // We currently only support ES3.
43 EGL_OPENGL_ES3_BIT,
44 EGL_RED_SIZE,
45 8,
46 EGL_GREEN_SIZE,
47 8,
48 EGL_BLUE_SIZE,
49 8,
50 EGL_ALPHA_SIZE,
51 8,
52 EGL_SAMPLE_BUFFERS,
53 sampleBuffers,
54 EGL_SAMPLES,
55 eglSampleCnt,
56 EGL_NONE};
57
58 EGLConfig surfaceConfig;
59 if (!eglChooseConfig(fDisplay, configAttribs, &surfaceConfig, 1, &numConfigs)) {
60 SkDebugf("Could not create choose config!\n");
61 return nullptr;
62 }
63 // We currently only support ES3.
64 const EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE};
65 fEGLContext = eglCreateContext(fDisplay, surfaceConfig, nullptr, contextAttribs);
66 if (EGL_NO_CONTEXT == fEGLContext) {
67 SkDebugf("Could not create context!\n");
68 return nullptr;
69 }
70 fEGLSurface =
71 eglCreateWindowSurface(fDisplay, surfaceConfig, this->onGetNativeWindow(), nullptr);
72 if (EGL_NO_SURFACE == fEGLSurface) {
73 SkDebugf("Could not create surface!\n");
74 return nullptr;
75 }
76 if (!eglMakeCurrent(fDisplay, fEGLSurface, fEGLSurface, fEGLContext)) {
77 SkDebugf("Could not make context current!\n");
78 return nullptr;
79 }
80
82 nullptr,
83 [](void* ctx, const char name[]) -> GrGLFuncPtr { return eglGetProcAddress(name); }));
84 if (interface) {
85 interface->fFunctions.fClearStencil(0);
86 interface->fFunctions.fClearColor(0, 0, 0, 0);
87 interface->fFunctions.fStencilMask(0xffffffff);
88 interface->fFunctions.fClear(GR_GL_STENCIL_BUFFER_BIT | GR_GL_COLOR_BUFFER_BIT);
89
91
92 SkISize size = this->onGetSize();
93 fWidth = size.width();
94 fHeight = size.height();
95 interface->fFunctions.fViewport(0, 0, fWidth, fHeight);
96 }
97 return interface;
98}
SK_API sk_sp< const GrGLInterface > GrGLMakeAssembledInterface(void *ctx, GrGLGetProc get)
#define GR_GL_STENCIL_BUFFER_BIT
Definition GrGLDefines.h:22
#define GR_GL_COLOR_BUFFER_BIT
Definition GrGLDefines.h:23
void(* GrGLFuncPtr)()
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
const DisplayParams & getDisplayParams()
virtual SkISize onGetSize() const =0
virtual int onGetStencilBits() const =0
virtual EGLDisplay onGetEGLDisplay(PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT) const =0
virtual NativeWindowType onGetNativeWindow() const =0
const char * name
Definition fuchsia.cc:50
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
Definition switches.h:259
constexpr int32_t width() const
Definition SkSize.h:36

◆ onSwapBuffers()

void skwindow::internal::ANGLEWindowContext::onSwapBuffers ( )
overrideprotectedvirtual

Implements skwindow::WindowContext.

Definition at line 113 of file ANGLEWindowContext.cpp.

113 {
114 if (!eglSwapBuffers(fDisplay, fEGLSurface)) {
115 SkDebugf("Could not complete eglSwapBuffers.\n");
116 }
117}

The documentation for this class was generated from the following files: