9#if defined(SK_BUILD_FOR_WIN) && !defined(_M_ARM64) && !defined(WINUWP)
19 if (
nullptr == this->fGetExtensionsString) {
22 if (!strcmp(
"WGL_ARB_extensions_string",
ext)) {
26 size_t extLength = strlen(
ext);
29 size_t n = strcspn(extensionString,
" ");
30 if (n == extLength && 0 == strncmp(
ext, extensionString, n)) {
33 if (0 == extensionString[n]) {
36 extensionString += n+1;
41 return fGetExtensionsString(hdc);
45 const int* piAttribIList,
46 const FLOAT* pfAttribFList,
49 UINT* nNumFormats)
const {
50 return fChoosePixelFormat(hdc, piAttribIList, pfAttribFList,
51 nMaxFormats, piFormats, nNumFormats);
58 const int *piAttributes,
59 int *piValues)
const {
60 return fGetPixelFormatAttribiv(hdc, iPixelFormat, iLayerPlane,
61 nAttributes, piAttributes, piValues);
68 const int *piAttributes,
69 float *pfValues)
const {
70 return fGetPixelFormatAttribfv(hdc, iPixelFormat, iLayerPlane,
71 nAttributes, piAttributes, pfValues);
75 const int *attribList)
const {
76 return fCreateContextAttribs(hDC, hShareContext, attribList);
80 return fSwapInterval(interval);
87 const int *piAttribList)
const {
88 return fCreatePbuffer(hDC, iPixelFormat, iWidth, iHeight, piAttribList);
92 return fGetPbufferDC(hPbuffer);
96 return fReleasePbufferDC(hPbuffer, hDC);
100 return fDestroyPbuffer(hPbuffer);
108 int fChoosePixelFormatRank;
112 if (
a.fSampleCnt <
b.fSampleCnt) {
114 }
else if (
b.fSampleCnt <
a.fSampleCnt) {
116 }
else if (
a.fChoosePixelFormatRank <
b.fChoosePixelFormatRank) {
126 int desiredSampleCount)
const {
128 if (formatCount <= 0) {
137 rankedFormats.
resize(formatCount);
138 for (
int i = 0;
i < formatCount; ++
i) {
147 rankedFormats[
i].fFormat = formats[
i];
148 rankedFormats[
i].fSampleCnt =
std::max(1, numSamples);
149 rankedFormats[
i].fChoosePixelFormatRank =
i;
152 int idx = SkTSearch<PixelFormat, pf_less>(rankedFormats.
begin(),
153 rankedFormats.
size(),
160 if (desiredSampleCount == 1 && rankedFormats[idx].fSampleCnt != 1) {
163 return rankedFormats[idx].fFormat;
170 #define STR_LIT(X) L## #X
172 #define STR_LIT(X) #X
175#define TEMP_CLASS STR_LIT("TempClass")
177HWND create_temp_window() {
178 HMODULE module = GetModuleHandle(
nullptr);
182 windowRect.right = 8;
184 windowRect.bottom = 8;
188 wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
189 wc.lpfnWndProc = (WNDPROC) DefWindowProc;
192 wc.hInstance = module;
193 wc.hIcon =
LoadIcon(
nullptr, IDI_WINLOGO);
194 wc.hCursor = LoadCursor(
nullptr, IDC_ARROW);
195 wc.hbrBackground =
nullptr;
196 wc.lpszMenuName =
nullptr;
197 wc.lpszClassName = TEMP_CLASS;
199 if(!RegisterClass(&wc)) {
203 DWORD style, exStyle;
204 exStyle = WS_EX_CLIENTEDGE;
207 AdjustWindowRectEx(&windowRect, style,
false, exStyle);
208 if(!(wnd = CreateWindowEx(exStyle,
210 STR_LIT(
"PlaceholderWindow"),
211 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | style,
213 windowRect.right-windowRect.left,
214 windowRect.bottom-windowRect.top,
218 UnregisterClass(TEMP_CLASS, module);
221 ShowWindow(wnd, SW_HIDE);
226void destroy_temp_window(HWND wnd) {
228 HMODULE module = GetModuleHandle(
nullptr);
229 UnregisterClass(TEMP_CLASS, module);
233#define GET_PROC(NAME, SUFFIX) f##NAME = \
234 (NAME##Proc) wglGetProcAddress("wgl" #NAME #SUFFIX)
237SkWGLExtensions::GetExtensionsStringProc SkWGLExtensions::fGetExtensionsString =
nullptr;
238SkWGLExtensions::ChoosePixelFormatProc SkWGLExtensions::fChoosePixelFormat =
nullptr;
239SkWGLExtensions::GetPixelFormatAttribfvProc SkWGLExtensions::fGetPixelFormatAttribfv =
nullptr;
240SkWGLExtensions::GetPixelFormatAttribivProc SkWGLExtensions::fGetPixelFormatAttribiv =
nullptr;
241SkWGLExtensions::CreateContextAttribsProc SkWGLExtensions::fCreateContextAttribs =
nullptr;
242SkWGLExtensions::SwapIntervalProc SkWGLExtensions::fSwapInterval =
nullptr;
243SkWGLExtensions::CreatePbufferProc SkWGLExtensions::fCreatePbuffer =
nullptr;
244SkWGLExtensions::GetPbufferDCProc SkWGLExtensions::fGetPbufferDC =
nullptr;
245SkWGLExtensions::ReleasePbufferDCProc SkWGLExtensions::fReleasePbufferDC =
nullptr;
246SkWGLExtensions::DestroyPbufferProc SkWGLExtensions::fDestroyPbuffer =
nullptr;
254 HDC prevDC = wglGetCurrentDC();
255 HGLRC prevGLRC = wglGetCurrentContext();
257 PIXELFORMATDESCRIPTOR tempPFD;
259 ZeroMemory(&tempPFD,
sizeof(tempPFD));
260 tempPFD.nSize =
sizeof(tempPFD);
261 tempPFD.nVersion = 1;
262 tempPFD.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
263 tempPFD.iPixelType = PFD_TYPE_RGBA;
264 tempPFD.cColorBits = 32;
265 tempPFD.cDepthBits = 0;
266 tempPFD.cStencilBits = 8;
267 tempPFD.iLayerType = PFD_MAIN_PLANE;
268 HWND tempWND = create_temp_window();
270 HDC tempDC = GetDC(tempWND);
271 int tempFormat = ChoosePixelFormat(tempDC, &tempPFD);
272 SetPixelFormat(tempDC, tempFormat, &tempPFD);
273 HGLRC tempGLRC = wglCreateContext(tempDC);
275 wglMakeCurrent(tempDC, tempGLRC);
277 #if defined(__clang__)
278 #pragma clang diagnostic push
279 #pragma clang diagnostic ignored "-Wcast-function-type"
293 #if defined(__clang__)
294 #pragma clang diagnostic pop
297 wglMakeCurrent(tempDC,
nullptr);
298 wglDeleteContext(tempGLRC);
299 destroy_temp_window(tempWND);
302 wglMakeCurrent(prevDC, prevGLRC);
309 bool doubleBuffered,
int msaaSampleCount,
bool deepColor,
310 int formatsToTry[2]) {
332 float fAttrs[] = {0, 0};
335 if (msaaSampleCount > 0 &&
336 extensions.hasExtension(dc,
"WGL_ARB_multisample")) {
340 appendAttr(msaaIAttrs, 0, 0);
343 extensions.choosePixelFormat(dc, msaaIAttrs.
begin(), fAttrs, 64, formats, &num);
345 formatsToTry[0] =
extensions.selectFormat(formats, num, dc, msaaSampleCount);
349 int*
format = -1 == formatsToTry[0] ? &formatsToTry[0] : &formatsToTry[1];
351 appendAttr(iAttrs, 0, 0);
357 HDC prevDC = wglGetCurrentDC();
358 HGLRC prevGLRC = wglGetCurrentContext();
360 HGLRC glrc =
nullptr;
362 if (!
extensions.hasExtension(dc,
"WGL_EXT_create_context_es2_profile")) {
363 wglMakeCurrent(prevDC, prevGLRC);
366 static const int glesAttribs[] = {
372 glrc =
extensions.createContextAttribs(dc, shareContext, glesAttribs);
373 if (
nullptr == glrc) {
374 wglMakeCurrent(prevDC, prevGLRC);
379 extensions.hasExtension(dc,
"WGL_ARB_create_context")) {
380 static const int kCoreGLVersions[] = {
388 int coreProfileAttribs[] = {
394 for (
size_t v = 0; v <
std::size(kCoreGLVersions) / 2; ++v) {
395 coreProfileAttribs[1] = kCoreGLVersions[2 * v];
396 coreProfileAttribs[3] = kCoreGLVersions[2 * v + 1];
397 glrc =
extensions.createContextAttribs(dc, shareContext, coreProfileAttribs);
405 if (
nullptr == glrc) {
406 glrc = wglCreateContext(dc);
408 if (!wglShareLists(shareContext, glrc)) {
409 wglDeleteContext(glrc);
416 wglMakeCurrent(prevDC, prevGLRC);
424 if (!
extensions.hasExtension(dc,
"WGL_ARB_pixel_format")) {
430 int pixelFormatsToTry[] = { -1, -1 };
431 get_pixel_formats_to_try(dc,
extensions,
true, msaaSampleCount, deepColor, pixelFormatsToTry);
433 !
set && -1 != pixelFormatsToTry[
f] &&
f <
std::size(pixelFormatsToTry);
435 PIXELFORMATDESCRIPTOR pfd;
436 DescribePixelFormat(dc, pixelFormatsToTry[
f],
sizeof(pfd), &pfd);
437 set = SetPixelFormat(dc, pixelFormatsToTry[
f], &pfd);
444 return create_gl_context(dc,
extensions, contextType, shareContext);
449 HGLRC shareContext) {
451 if (!
extensions.hasExtension(parentDC,
"WGL_ARB_pixel_format") ||
452 !
extensions.hasExtension(parentDC,
"WGL_ARB_pbuffer")) {
462 static int gPixelFormats[2] = { -1, -1 };
467 int pixelFormatsToTry[2] = { -1, -1 };
468 get_pixel_formats_to_try(parentDC,
extensions,
false, 0,
false, pixelFormatsToTry);
469 gPixelFormats[0] = pixelFormatsToTry[0];
473 int pixelFormatsToTry[2] = { -1, -1 };
474 get_pixel_formats_to_try(parentDC,
extensions,
true, 0,
false, pixelFormatsToTry);
475 gPixelFormats[1] = pixelFormatsToTry[0];
480 for (
int pixelFormat : gPixelFormats) {
481 if (-1 == pixelFormat) {
484 HPBUFFER pbuf =
extensions.createPbuffer(parentDC, pixelFormat, 1, 1,
nullptr);
488 HGLRC glrc = create_gl_context(dc,
extensions, contextType, shareContext);
502 wglDeleteContext(fGLRC);
507SkWGLPbufferContext::SkWGLPbufferContext(HPBUFFER pbuffer, HDC dc, HGLRC glrc)
void SkTQSort(T *begin, T *end, const C &lessThan)
#define SK_WGL_DRAW_TO_WINDOW
#define SK_WGL_ACCELERATION
HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, bool deepColor, SkWGLContextRequest context, HGLRC shareContext=nullptr)
#define SK_WGL_COLOR_BITS
#define SK_WGL_CONTEXT_CORE_PROFILE_BIT
#define SK_WGL_GREEN_BITS
#define SK_WGL_STENCIL_BITS
#define SK_WGL_SUPPORT_OPENGL
#define SK_WGL_FULL_ACCELERATION
@ kGLES_SkWGLContextRequest
@ kGLPreferCoreProfile_SkWGLContextRequest
#define SK_WGL_CONTEXT_MINOR_VERSION
#define SK_WGL_SAMPLE_BUFFERS
#define SK_WGL_CONTEXT_PROFILE_MASK
#define SK_WGL_DOUBLE_BUFFER
#define SK_WGL_ALPHA_BITS
#define SK_WGL_CONTEXT_ES2_PROFILE_BIT
#define SK_WGL_CONTEXT_MAJOR_VERSION
void push_back(const T &v)
int releasePbufferDC(HPBUFFER, HDC) const
HPBUFFER createPbuffer(HDC, int, int, int, const int *) const
BOOL swapInterval(int interval) const
BOOL choosePixelFormat(HDC hdc, const int *, const FLOAT *, UINT, int *, UINT *) const
int selectFormat(const int formats[], int formatCount, HDC dc, int desiredSampleCount) const
const char * getExtensionsString(HDC hdc) const
bool hasExtension(HDC dc, const char *ext) const
BOOL getPixelFormatAttribiv(HDC, int, int, UINT, const int *, int *) const
BOOL destroyPbuffer(HPBUFFER) const
HGLRC createContextAttribs(HDC, HGLRC, const int *) const
BOOL getPixelFormatAttribfv(HDC hdc, int, int, UINT, const int *, FLOAT *) const
HDC getPbufferDC(HPBUFFER) const
static sk_sp< SkWGLPbufferContext > Create(HDC parentDC, SkWGLContextRequest contextType, HGLRC shareContext)
~SkWGLPbufferContext() override
uint32_t uint32_t * format
static float max(float r, float g, float b)
static float min(float r, float g, float b)
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
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...