| Index: src/utils/win/SkWGL_win.cpp
|
| diff --git a/src/utils/win/SkWGL_win.cpp b/src/utils/win/SkWGL_win.cpp
|
| index 65ffaf1ecf8981d35f408b3fe34e7272401e2f73..e3333538fa8ac5fe4e43a58e7b6f54df65df8503 100644
|
| --- a/src/utils/win/SkWGL_win.cpp
|
| +++ b/src/utils/win/SkWGL_win.cpp
|
| @@ -288,38 +288,41 @@ SkWGLExtensions::SkWGLExtensions()
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| static void get_pixel_formats_to_try(HDC dc, const SkWGLExtensions& extensions,
|
| - bool doubleBuffered, int msaaSampleCount,
|
| + bool doubleBuffered, int msaaSampleCount, bool tenBitColor,
|
| int formatsToTry[2]) {
|
| - int iAttrs[] = {
|
| - SK_WGL_DRAW_TO_WINDOW, TRUE,
|
| - SK_WGL_DOUBLE_BUFFER, (doubleBuffered ? TRUE : FALSE),
|
| - SK_WGL_ACCELERATION, SK_WGL_FULL_ACCELERATION,
|
| - SK_WGL_SUPPORT_OPENGL, TRUE,
|
| - SK_WGL_COLOR_BITS, 24,
|
| - SK_WGL_ALPHA_BITS, 8,
|
| - SK_WGL_STENCIL_BITS, 8,
|
| - 0, 0
|
| + auto appendAttr = [](SkTDArray<int>& attrs, int attr, int value) {
|
| + attrs.push(attr);
|
| + attrs.push(value);
|
| };
|
|
|
| + SkTDArray<int> iAttrs;
|
| + appendAttr(iAttrs, SK_WGL_DRAW_TO_WINDOW, TRUE);
|
| + appendAttr(iAttrs, SK_WGL_DOUBLE_BUFFER, (doubleBuffered ? TRUE : FALSE));
|
| + appendAttr(iAttrs, SK_WGL_ACCELERATION, SK_WGL_FULL_ACCELERATION);
|
| + appendAttr(iAttrs, SK_WGL_SUPPORT_OPENGL, TRUE);
|
| + if (tenBitColor) {
|
| + appendAttr(iAttrs, SK_WGL_RED_BITS, 10);
|
| + appendAttr(iAttrs, SK_WGL_GREEN_BITS, 10);
|
| + appendAttr(iAttrs, SK_WGL_BLUE_BITS, 10);
|
| + appendAttr(iAttrs, SK_WGL_ALPHA_BITS, 2);
|
| + } else {
|
| + appendAttr(iAttrs, SK_WGL_COLOR_BITS, 24);
|
| + appendAttr(iAttrs, SK_WGL_ALPHA_BITS, 8);
|
| + }
|
| + appendAttr(iAttrs, SK_WGL_STENCIL_BITS, 8);
|
| +
|
| float fAttrs[] = {0, 0};
|
|
|
| // Get a MSAA format if requested and possible.
|
| if (msaaSampleCount > 0 &&
|
| extensions.hasExtension(dc, "WGL_ARB_multisample")) {
|
| - static const int kIAttrsCount = SK_ARRAY_COUNT(iAttrs);
|
| - int msaaIAttrs[kIAttrsCount + 4];
|
| - memcpy(msaaIAttrs, iAttrs, sizeof(int) * kIAttrsCount);
|
| - SkASSERT(0 == msaaIAttrs[kIAttrsCount - 2] &&
|
| - 0 == msaaIAttrs[kIAttrsCount - 1]);
|
| - msaaIAttrs[kIAttrsCount - 2] = SK_WGL_SAMPLE_BUFFERS;
|
| - msaaIAttrs[kIAttrsCount - 1] = TRUE;
|
| - msaaIAttrs[kIAttrsCount + 0] = SK_WGL_SAMPLES;
|
| - msaaIAttrs[kIAttrsCount + 1] = msaaSampleCount;
|
| - msaaIAttrs[kIAttrsCount + 2] = 0;
|
| - msaaIAttrs[kIAttrsCount + 3] = 0;
|
| + SkTDArray<int> msaaIAttrs = iAttrs;
|
| + appendAttr(msaaIAttrs, SK_WGL_SAMPLE_BUFFERS, TRUE);
|
| + appendAttr(msaaIAttrs, SK_WGL_SAMPLES, msaaSampleCount);
|
| + appendAttr(msaaIAttrs, 0, 0);
|
| unsigned int num;
|
| int formats[64];
|
| - extensions.choosePixelFormat(dc, msaaIAttrs, fAttrs, 64, formats, &num);
|
| + extensions.choosePixelFormat(dc, msaaIAttrs.begin(), fAttrs, 64, formats, &num);
|
| num = SkTMin(num, 64U);
|
| formatsToTry[0] = extensions.selectFormat(formats, num, dc, msaaSampleCount);
|
| }
|
| @@ -327,7 +330,8 @@ static void get_pixel_formats_to_try(HDC dc, const SkWGLExtensions& extensions,
|
| // Get a non-MSAA format
|
| int* format = -1 == formatsToTry[0] ? &formatsToTry[0] : &formatsToTry[1];
|
| unsigned int num;
|
| - extensions.choosePixelFormat(dc, iAttrs, fAttrs, 1, format, &num);
|
| + appendAttr(iAttrs, 0, 0);
|
| + extensions.choosePixelFormat(dc, iAttrs.begin(), fAttrs, 1, format, &num);
|
| }
|
|
|
| static HGLRC create_gl_context(HDC dc, SkWGLExtensions extensions, SkWGLContextRequest contextType) {
|
| @@ -393,7 +397,8 @@ static HGLRC create_gl_context(HDC dc, SkWGLExtensions extensions, SkWGLContextR
|
| return glrc;
|
| }
|
|
|
| -HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, SkWGLContextRequest contextType) {
|
| +HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, bool tenBitColor,
|
| + SkWGLContextRequest contextType) {
|
| SkWGLExtensions extensions;
|
| if (!extensions.hasExtension(dc, "WGL_ARB_pixel_format")) {
|
| return nullptr;
|
| @@ -402,7 +407,7 @@ HGLRC SkCreateWGLContext(HDC dc, int msaaSampleCount, SkWGLContextRequest contex
|
| BOOL set = FALSE;
|
|
|
| int pixelFormatsToTry[] = { -1, -1 };
|
| - get_pixel_formats_to_try(dc, extensions, true, msaaSampleCount, pixelFormatsToTry);
|
| + get_pixel_formats_to_try(dc, extensions, true, msaaSampleCount, tenBitColor, pixelFormatsToTry);
|
| for (int f = 0;
|
| !set && -1 != pixelFormatsToTry[f] && f < SK_ARRAY_COUNT(pixelFormatsToTry);
|
| ++f) {
|
| @@ -429,7 +434,7 @@ SkWGLPbufferContext* SkWGLPbufferContext::Create(HDC parentDC, int msaaSampleCou
|
| for (int dblBuffer = 0; dblBuffer < 2; ++dblBuffer) {
|
| int pixelFormatsToTry[] = { -1, -1 };
|
| get_pixel_formats_to_try(parentDC, extensions, (0 != dblBuffer), msaaSampleCount,
|
| - pixelFormatsToTry);
|
| + false, pixelFormatsToTry);
|
| for (int f = 0; -1 != pixelFormatsToTry[f] && f < SK_ARRAY_COUNT(pixelFormatsToTry); ++f) {
|
| HPBUFFER pbuf = extensions.createPbuffer(parentDC, pixelFormatsToTry[f], 1, 1, nullptr);
|
| if (0 != pbuf) {
|
|
|