aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/views/win
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-03 18:04:51 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-04-03 18:04:51 +0000
commit3c4d032aeb2831a64fd6eff570667d590e3ed209 (patch)
tree65bc1d75e4ee070b516870b0be319cfa63aee9c2 /src/views/win
parent5f017a4ab001baf1b9f433a9b02c6e01f93a97a1 (diff)
Revert 3857 (which was committed from wrong tree)
git-svn-id: http://skia.googlecode.com/svn/trunk@3588 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/views/win')
-rw-r--r--src/views/win/SkOSWindow_win.cpp110
1 files changed, 43 insertions, 67 deletions
diff --git a/src/views/win/SkOSWindow_win.cpp b/src/views/win/SkOSWindow_win.cpp
index ecd4c0cd03..c6d345c062 100644
--- a/src/views/win/SkOSWindow_win.cpp
+++ b/src/views/win/SkOSWindow_win.cpp
@@ -313,7 +313,7 @@ void SkEvent::SignalQueueTimer(SkMSec delay)
#define USE_MSAA 0
-HGLRC create_gl(HWND hwnd, int msaaSampleCount) {
+HGLRC create_gl(HWND hwnd) {
HDC dc = GetDC(hwnd);
@@ -328,7 +328,7 @@ HGLRC create_gl(HWND hwnd, int msaaSampleCount) {
int format = 0;
- static const GLint iAttrs[] = {
+ GLint iattrs[] = {
SK_WGL_DRAW_TO_WINDOW, TRUE,
SK_WGL_DOUBLE_BUFFER, TRUE,
SK_WGL_ACCELERATION, SK_WGL_FULL_ACCELERATION,
@@ -336,40 +336,40 @@ HGLRC create_gl(HWND hwnd, int msaaSampleCount) {
SK_WGL_COLOR_BITS, 24,
SK_WGL_ALPHA_BITS, 8,
SK_WGL_STENCIL_BITS, 8,
- 0, 0
+
+ // these must be kept last
+ SK_WGL_SAMPLE_BUFFERS, TRUE,
+ SK_WGL_SAMPLES, 0,
+ 0,0
};
- GLfloat fAttrs[] = {0, 0};
-
- if (msaaSampleCount > 0 &&
- extensions.hasExtension(dc, "WGL_ARB_multisample")) {
- static const int kIAttrsCount = SK_ARRAY_COUNT(iAttrs);
- GLint msaaIAttrs[kIAttrsCount + 4];
- memcpy(msaaIAttrs, iAttrs, sizeof(GLint) * 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;
- GLuint num;
- int formats[64];
- extensions.choosePixelFormat(dc, msaaIAttrs, fAttrs, 64, formats, &num);
- num = min(num,64);
- for (GLuint i = 0; i < num; ++i) {
- DescribePixelFormat(dc, formats[i], sizeof(pfd), &pfd);
- if (SetPixelFormat(dc, formats[i], &pfd)) {
- format = formats[i];
- break;
+ static const int kSampleBuffersValueIdx = SK_ARRAY_COUNT(iattrs) - 5;
+ static const int kSamplesValueIdx = SK_ARRAY_COUNT(iattrs) - 3;
+ if (USE_MSAA && extensions.hasExtension(dc, "WGL_ARB_multisample")) {
+ for (int samples = 16; samples > 1; --samples) {
+
+ iattrs[kSamplesValueIdx] = samples;
+ GLfloat fattrs[] = {0,0};
+ GLuint num;
+ int formats[64];
+ extensions.choosePixelFormat(dc, iattrs, fattrs, 64, formats, &num);
+ num = min(num,64);
+ for (GLuint i = 0; i < num; ++i) {
+ DescribePixelFormat(dc, formats[i], sizeof(pfd), &pfd);
+ if (SetPixelFormat(dc, formats[i], &pfd)) {
+ format = formats[i];
+ break;
+ }
}
}
}
if (0 == format) {
+ iattrs[kSampleBuffersValueIdx-1] = iattrs[kSampleBuffersValueIdx] = 0;
+ iattrs[kSamplesValueIdx-1] = iattrs[kSamplesValueIdx] = 0;
+ GLfloat fattrs[] = {0,0};
GLuint num;
- extensions.choosePixelFormat(dc, iAttrs, fAttrs, 1, &format, &num);
+ extensions.choosePixelFormat(dc, iattrs, fattrs, 1, &format, &num);
DescribePixelFormat(dc, format, sizeof(pfd), &pfd);
BOOL set = SetPixelFormat(dc, format, &pfd);
SkASSERT(TRUE == set);
@@ -382,9 +382,9 @@ HGLRC create_gl(HWND hwnd, int msaaSampleCount) {
return glrc;
}
-bool SkOSWindow::attachGL(int msaaSampleCount) {
+bool SkOSWindow::attachGL() {
if (NULL == fHGLRC) {
- fHGLRC = create_gl((HWND)fHWND, msaaSampleCount);
+ fHGLRC = create_gl((HWND)fHWND);
if (NULL == fHGLRC) {
return false;
}
@@ -413,15 +413,13 @@ void SkOSWindow::presentGL() {
}
#if SK_ANGLE
-bool create_ANGLE(EGLNativeWindowType hWnd,
- int msaaSampleCount,
- angle::EGLDisplay* eglDisplay,
- angle::EGLContext* eglContext,
- angle::EGLSurface* eglSurface) {
- static EGLint contextAttribs[] = {
+bool create_ANGLE(EGLNativeWindowType hWnd, EGLDisplay* eglDisplay,
+ EGLContext* eglContext, EGLSurface* eglSurface) {
+ EGLint contextAttribs[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE, EGL_NONE
};
- static EGLint configAttribList[] = {
+ EGLint configAttribList[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
@@ -430,7 +428,7 @@ bool create_ANGLE(EGLNativeWindowType hWnd,
EGL_STENCIL_SIZE, 8,
EGL_NONE
};
- static EGLint surfaceAttribList[] = {
+ EGLint surfaceAttribList[] = {
EGL_NONE, EGL_NONE
};
@@ -452,31 +450,9 @@ bool create_ANGLE(EGLNativeWindowType hWnd,
// Choose config
EGLConfig config;
- bool foundConfig = false;
- if (msaaSampleCount) {
- static int kConfigAttribListCnt = SK_ARRAY_COUNT(configAttribList);
- EGLint msaaConfigAttribList[kConfigAttribListCnt + 4];
- memcpy(msaaConfigAttribList,
- configAttribList,
- sizeof(configAttribList));
- SkASSERT(EGL_NONE == msaaConfigAttribList[kConfigAttribListCnt - 1]);
- msaaConfigAttribList[kConfigAttribListCnt - 1] = EGL_SAMPLE_BUFFERS;
- msaaConfigAttribList[kConfigAttribListCnt + 0] = 1;
- msaaConfigAttribList[kConfigAttribListCnt + 1] = EGL_SAMPLES;
- msaaConfigAttribList[kConfigAttribListCnt + 2] = msaaCount;
- msaaConfigAttribList[kConfigAttribListCnt + 3] = EGL_NONE;
- if (eglChooseConfig(display, configAttribList,
- &config, 1, &numConfigs)) {
- if (numConfigs > 0) {
- foundConfig = true;
- }
- }
- }
- if (!foundConfig) {
- if (!eglChooseConfig(display, configAttribList,
- &config, 1, &numConfigs)) {
- return false;
- }
+ if (!eglChooseConfig(display, configAttribList,
+ &config, 1, &numConfigs)) {
+ return false;
}
// Create a surface
@@ -506,7 +482,7 @@ bool create_ANGLE(EGLNativeWindowType hWnd,
return true;
}
-bool SkOSWindow::attachANGLE(int msaaSampleCount) {
+bool SkOSWindow::attachANGLE() {
if (EGL_NO_DISPLAY == fDisplay) {
bool bResult = create_ANGLE((HWND)fHWND, &fDisplay, &fContext, &fSurface);
if (false == bResult) {
@@ -664,7 +640,7 @@ void SkOSWindow::presentD3D9() {
}
// return true on success
-bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount) {
+bool SkOSWindow::attach(SkBackEndTypes attachType) {
// attach doubles as "windowResize" so we need to allo
// already bound states to pass through again
@@ -677,11 +653,11 @@ bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount) {
// nothing to do
break;
case kNativeGL_BackEndType:
- result = attachGL(msaaSampleCount);
+ result = attachGL();
break;
#if SK_ANGLE
case kANGLE_BackEndType:
- result = attachANGLE(msaaSampleCount);
+ result = attachANGLE();
break;
#endif
case kD3D9_BackEndType: