Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Unified Diff: src/utils/win/SkWGL_win.cpp

Issue 1919993002: Added --deepColor option to SampleApp, triggers creation of a ten-bit/channel buffer on Windows. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/utils/win/SkWGL.h ('k') | src/views/SkWindow.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..dc1b4caf1a576fbda2f049a9f3bd2ee9787fdf65 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 deepColor,
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 (deepColor) {
+ 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 deepColor,
+ 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, deepColor, 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) {
« no previous file with comments | « src/utils/win/SkWGL.h ('k') | src/views/SkWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698