aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-05 20:06:05 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-05 20:06:05 +0000
commit64cc810ad165724f9c666a75bd52e41c67f13564 (patch)
treedc05e9b5db78f18c9dcf75f9c62d2d05ea84a66f
parentacf3ecc7f70567a26f1435b5d3de45b316338b3e (diff)
Make SkOSWindow return the sample count and stencil bit count for its GL context.
Review URL: https://codereview.chromium.org/12437010 git-svn-id: http://skia.googlecode.com/svn/trunk@7995 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--experimental/iOSSampleApp/Shared/SkUIView.h6
-rw-r--r--experimental/iOSSampleApp/Shared/SkUIView.mm6
-rw-r--r--experimental/iOSSampleApp/SkSampleUIView.h2
-rw-r--r--experimental/iOSSampleApp/SkSampleUIView.mm24
-rw-r--r--include/views/SkOSWindow_Android.h10
-rw-r--r--include/views/SkOSWindow_Mac.h7
-rw-r--r--include/views/SkOSWindow_NaCl.h9
-rw-r--r--include/views/SkOSWindow_Unix.h9
-rw-r--r--include/views/SkOSWindow_Win.h12
-rwxr-xr-xinclude/views/SkOSWindow_iOS.h7
-rw-r--r--samplecode/SampleApp.cpp11
-rwxr-xr-xsrc/views/ios/SkOSWindow_iOS.mm4
-rw-r--r--src/views/mac/SkNSView.h2
-rw-r--r--src/views/mac/SkNSView.mm10
-rw-r--r--src/views/mac/SkOSWindow_Mac.mm4
-rw-r--r--src/views/unix/SkOSWindow_Unix.cpp26
-rw-r--r--src/views/win/SkOSWindow_win.cpp53
17 files changed, 152 insertions, 50 deletions
diff --git a/experimental/iOSSampleApp/Shared/SkUIView.h b/experimental/iOSSampleApp/Shared/SkUIView.h
index a3d05e37db..45c4df0abd 100644
--- a/experimental/iOSSampleApp/Shared/SkUIView.h
+++ b/experimental/iOSSampleApp/Shared/SkUIView.h
@@ -11,8 +11,8 @@
#import <OpenGLES/ES2/glext.h>
#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>
-#include "SkWindow.h"
-class SkOSWindow;
+#include "SkOSWindow_ios.h"
+
class SkEvent;
@class SkUIView;
@@ -43,4 +43,6 @@ class SkEvent;
- (void)onUpdateMenu:(SkOSMenu*)menu;
- (void)postInvalWithRect:(const SkIRect*)rectOrNil;
- (BOOL)onHandleEvent:(const SkEvent&)event;
+- (void)getAttachmentInfo:(SkOSWindow::AttachmentInfo*)info;
+
@end
diff --git a/experimental/iOSSampleApp/Shared/SkUIView.mm b/experimental/iOSSampleApp/Shared/SkUIView.mm
index 835e970666..10b55183c3 100644
--- a/experimental/iOSSampleApp/Shared/SkUIView.mm
+++ b/experimental/iOSSampleApp/Shared/SkUIView.mm
@@ -93,6 +93,12 @@
return false;
}
+- (void)getAttachmentInfo:(SkOSWindow::AttachmentInfo*)info {
+ // we don't have a GL context.
+ info->fSampleCount = 0;
+ info->fStencilBits = 0;
+}
+
#include "SkOSMenu.h"
- (void)onAddMenu:(const SkOSMenu*)menu {
[self.fOptionsDelegate view:self didAddMenu:menu];
diff --git a/experimental/iOSSampleApp/SkSampleUIView.h b/experimental/iOSSampleApp/SkSampleUIView.h
index 9bb195621d..a1009b84da 100644
--- a/experimental/iOSSampleApp/SkSampleUIView.h
+++ b/experimental/iOSSampleApp/SkSampleUIView.h
@@ -43,4 +43,6 @@ struct FPSState;
- (void)setSkTitle:(const char*)title;
- (void)postInvalWithRect:(const SkIRect*)rectOrNil;
+- (void)getAttachmentInfo:(SkOSWindow::AttachmentInfo*)info;
+
@end
diff --git a/experimental/iOSSampleApp/SkSampleUIView.mm b/experimental/iOSSampleApp/SkSampleUIView.mm
index 2ed5402ba6..9fc95bd152 100644
--- a/experimental/iOSSampleApp/SkSampleUIView.mm
+++ b/experimental/iOSSampleApp/SkSampleUIView.mm
@@ -61,8 +61,8 @@ public:
SkASSERT(false);
break;
}
-
- bool result = win->attach(fBackend, msaaSampleCount);
+ SkOSWindow::AttachmentInfo info;
+ bool result = win->attach(fBackend, msaaSampleCount, &info);
if (!result) {
SkDebugf("Failed to initialize GL");
return;
@@ -165,7 +165,9 @@ public:
virtual void windowSizeChanged(SampleWindow* win) SK_OVERRIDE {
#if SK_SUPPORT_GPU
if (NULL != fCurContext) {
- win->attach(fBackend, fMSAASampleCount);
+ SkOSWindow::AttachmentInfo info;
+
+ win->attach(fBackend, fMSAASampleCount, &info);
glBindFramebuffer(GL_FRAMEBUFFER, fLayerFBO);
GrBackendRenderTargetDesc desc;
@@ -173,9 +175,9 @@ public:
desc.fHeight = SkScalarRound(win->height());
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fRenderTargetHandle = fLayerFBO;
- glGetIntegerv(GL_SAMPLES, &desc.fSampleCnt);
- glGetIntegerv(GL_STENCIL_BITS, &desc.fStencilBits);
-
+ desc.fSampleCnt = info.fSampleCount;
+ desc.fStencilBits = info.fStencilBits;
+
SkSafeUnref(fCurRenderTarget);
fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc);
}
@@ -480,4 +482,14 @@ static FPSState gFPS;
}
}
+- (void)getAttachmentInfo:(SkOSWindow::AttachmentInfo*)info {
+ glBindRenderbuffer(GL_RENDERBUFFER, fGL.fRenderbuffer);
+ glGetRenderbufferParameteriv(GL_RENDERBUFFER,
+ GL_RENDERBUFFER_STENCIL_SIZE,
+ &info->fStencilBits);
+ glGetRenderbufferParameteriv(GL_RENDERBUFFER,
+ GL_RENDERBUFFER_SAMPLES_APPLE,
+ &info->fSampleCount);
+}
+
@end
diff --git a/include/views/SkOSWindow_Android.h b/include/views/SkOSWindow_Android.h
index ca9b7708f1..77c156cd23 100644
--- a/include/views/SkOSWindow_Android.h
+++ b/include/views/SkOSWindow_Android.h
@@ -24,7 +24,15 @@ public:
kNativeGL_BackEndType,
};
- bool attach(SkBackEndTypes /* attachType */, int /* msaaSampleCount */) {
+ struct AttachmentInfo {
+ int fSampleCount;
+ int fStencilBits;
+ };
+
+ bool attach(SkBackEndTypes /* attachType */, int /* msaaSampleCount */, AttachmentInfo* info) {
+ // These are the values requested in SkiaSampleView.java
+ info->fSampleCount = 0;
+ info->fStencilBits = 8;
return true;
}
void detach() {}
diff --git a/include/views/SkOSWindow_Mac.h b/include/views/SkOSWindow_Mac.h
index aa52021607..5dea2fc12e 100644
--- a/include/views/SkOSWindow_Mac.h
+++ b/include/views/SkOSWindow_Mac.h
@@ -26,8 +26,13 @@ public:
#endif
};
+ struct AttachmentInfo {
+ int fSampleCount;
+ int fStencilBits;
+ };
+
void detach();
- bool attach(SkBackEndTypes attachType, int msaaSampleCount);
+ bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
void present();
protected:
diff --git a/include/views/SkOSWindow_NaCl.h b/include/views/SkOSWindow_NaCl.h
index 52514cab71..22960236d3 100644
--- a/include/views/SkOSWindow_NaCl.h
+++ b/include/views/SkOSWindow_NaCl.h
@@ -24,7 +24,14 @@ public:
kNativeGL_BackEndType,
};
- bool attach(SkBackEndTypes /* attachType */, int /* msaaSampleCount */) {
+ struct AttachmentInfo {
+ int fSampleCount;
+ int fStencilBits;
+ };
+
+ bool attach(SkBackEndTypes /* attachType */, int /* msaaSampleCount */, AttachmentInfo* info) {
+ info->fSampleCount = 0;
+ info->fStencilBits = 0;
return true;
}
void detach() {}
diff --git a/include/views/SkOSWindow_Unix.h b/include/views/SkOSWindow_Unix.h
index f1a4698668..89265a4367 100644
--- a/include/views/SkOSWindow_Unix.h
+++ b/include/views/SkOSWindow_Unix.h
@@ -39,7 +39,12 @@ public:
kNativeGL_BackEndType,
};
- bool attach(SkBackEndTypes attachType, int msaaSampleCount);
+ struct AttachmentInfo {
+ int fSampleCount;
+ int fStencilBits;
+ };
+
+ bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
void detach();
void present();
@@ -61,7 +66,7 @@ private:
void mapWindowAndWait();
void closeWindow();
- void initWindow(int newMSAASampleCount);
+ void initWindow(int newMSAASampleCount, AttachmentInfo* info);
SkUnixWindow fUnixWindow;
diff --git a/include/views/SkOSWindow_Win.h b/include/views/SkOSWindow_Win.h
index ff289bd6a6..6b5977ce3f 100644
--- a/include/views/SkOSWindow_Win.h
+++ b/include/views/SkOSWindow_Win.h
@@ -37,7 +37,12 @@ public:
#endif // SK_SUPPORT_GPU
};
- bool attach(SkBackEndTypes attachType, int msaaSampleCount);
+ struct AttachmentInfo {
+ int fSampleCount;
+ int fStencilBits;
+ };
+
+ bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
void detach();
void present();
@@ -70,6 +75,7 @@ private:
EGLDisplay fDisplay;
EGLContext fContext;
EGLSurface fSurface;
+ EGLConfig fConfig;
#endif // SK_ANGLE
#endif // SK_SUPPORT_GPU
@@ -78,12 +84,12 @@ private:
SkBackEndTypes fAttached;
#if SK_SUPPORT_GPU
- bool attachGL(int msaaSampleCount);
+ bool attachGL(int msaaSampleCount, AttachmentInfo* info);
void detachGL();
void presentGL();
#if SK_ANGLE
- bool attachANGLE(int msaaSampleCount);
+ bool attachANGLE(int msaaSampleCount, AttachmentInfo* info);
void detachANGLE();
void presentANGLE();
#endif // SK_ANGLE
diff --git a/include/views/SkOSWindow_iOS.h b/include/views/SkOSWindow_iOS.h
index 1dd3997dfe..1984900ded 100755
--- a/include/views/SkOSWindow_iOS.h
+++ b/include/views/SkOSWindow_iOS.h
@@ -21,8 +21,13 @@ public:
kNativeGL_BackEndType,
};
+ struct AttachmentInfo {
+ int fSampleCount;
+ int fStencilBits;
+ };
+
void detach();
- bool attach(SkBackEndTypes attachType, int msaaSampleCount);
+ bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
void present();
protected:
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 6266085d78..badc7c01e8 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -188,8 +188,8 @@ public:
SkASSERT(false);
break;
}
-
- bool result = win->attach(fBackend, msaaSampleCount);
+ AttachmentInfo attachmentInfo;
+ bool result = win->attach(fBackend, msaaSampleCount, &attachmentInfo);
if (!result) {
SkDebugf("Failed to initialize GL");
return;
@@ -289,15 +289,16 @@ public:
virtual void windowSizeChanged(SampleWindow* win) {
#if SK_SUPPORT_GPU
if (fCurContext) {
- win->attach(fBackend, fMSAASampleCount);
+ AttachmentInfo attachmentInfo;
+ win->attach(fBackend, fMSAASampleCount, &attachmentInfo);
GrBackendRenderTargetDesc desc;
desc.fWidth = SkScalarRound(win->width());
desc.fHeight = SkScalarRound(win->height());
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
- GR_GL_GetIntegerv(fCurIntf, GR_GL_SAMPLES, &desc.fSampleCnt);
- GR_GL_GetIntegerv(fCurIntf, GR_GL_STENCIL_BITS, &desc.fStencilBits);
+ desc.fSampleCnt = attachmentInfo.fSampleCount;
+ desc.fStencilBits = attachmentInfo.fStencilBits;
GrGLint buffer;
GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer);
desc.fRenderTargetHandle = buffer;
diff --git a/src/views/ios/SkOSWindow_iOS.mm b/src/views/ios/SkOSWindow_iOS.mm
index 94579aa14b..04a219b6a7 100755
--- a/src/views/ios/SkOSWindow_iOS.mm
+++ b/src/views/ios/SkOSWindow_iOS.mm
@@ -51,7 +51,9 @@ void SkOSWindow::onUpdateMenu(SkOSMenu* menu) {
}
bool SkOSWindow::attach(SkBackEndTypes /* attachType */,
- int /* msaaSampleCount */) {
+ int /* msaaSampleCount */,
+ AttachmentInfo* info) {
+ [(SkUIView*)fHWND getAttachmentInfo:info];
bool success = true;
return success;
}
diff --git a/src/views/mac/SkNSView.h b/src/views/mac/SkNSView.h
index 109a9982cc..dfc81ea5bd 100644
--- a/src/views/mac/SkNSView.h
+++ b/src/views/mac/SkNSView.h
@@ -46,7 +46,7 @@ class SkEvent;
- (void)postInvalWithRect:(const SkIRect*)rectOrNil;
- (BOOL)onHandleEvent:(const SkEvent&)event;
-- (bool)attach:(SkOSWindow::SkBackEndTypes)attachType withMSAASampleCount:(int) sampleCount;
+- (bool)attach:(SkOSWindow::SkBackEndTypes)attachType withMSAASampleCount:(int) sampleCount andGetInfo:(SkOSWindow::AttachmentInfo*) info;
- (void)detach;
- (void)present;
@end
diff --git a/src/views/mac/SkNSView.mm b/src/views/mac/SkNSView.mm
index fc82ac4949..2d796e46b6 100644
--- a/src/views/mac/SkNSView.mm
+++ b/src/views/mac/SkNSView.mm
@@ -291,7 +291,6 @@ CGLContextObj createGLContext(int msaaSampleCount) {
if (!npix) {
CGLChoosePixelFormat(attributes, &format, &npix);
}
-
CGLContextObj ctx;
CGLCreateContext(format, NULL, &ctx);
CGLDestroyPixelFormat(format);
@@ -314,7 +313,8 @@ CGLContextObj createGLContext(int msaaSampleCount) {
}
}
- (bool)attach:(SkOSWindow::SkBackEndTypes)attachType
- withMSAASampleCount:(int) sampleCount {
+ withMSAASampleCount:(int) sampleCount
+ andGetInfo:(SkOSWindow::AttachmentInfo*) info {
if (nil == fGLContext) {
CGLContextObj ctx = createGLContext(sampleCount);
fGLContext = [[NSOpenGLContext alloc] initWithCGLContextObj:ctx];
@@ -324,9 +324,11 @@ CGLContextObj createGLContext(int msaaSampleCount) {
}
[fGLContext setView:self];
}
-
+
[fGLContext makeCurrentContext];
-
+ CGLPixelFormatObj format = CGLGetPixelFormat((CGLContextObj)[fGLContext CGLContextObj]);
+ CGLDescribePixelFormat(format, 0, kCGLPFASamples, &info->fSampleCount);
+ CGLDescribePixelFormat(format, 0, kCGLPFAStencilSize, &info->fStencilBits);
glViewport(0, 0, (int) self.bounds.size.width, (int) self.bounds.size.width);
glClearColor(0, 0, 0, 0);
glClearStencil(0);
diff --git a/src/views/mac/SkOSWindow_Mac.mm b/src/views/mac/SkOSWindow_Mac.mm
index 01c8677f4d..b0f006a884 100644
--- a/src/views/mac/SkOSWindow_Mac.mm
+++ b/src/views/mac/SkOSWindow_Mac.mm
@@ -65,8 +65,8 @@ void SkOSWindow::onUpdateMenu(const SkOSMenu* menu) {
[(SkNSView*)fHWND onUpdateMenu:menu];
}
-bool SkOSWindow::attach(SkBackEndTypes attachType, int sampleCount) {
- return [(SkNSView*)fHWND attach:attachType withMSAASampleCount:sampleCount];
+bool SkOSWindow::attach(SkBackEndTypes attachType, int sampleCount, AttachmentInfo* info) {
+ return [(SkNSView*)fHWND attach:attachType withMSAASampleCount:sampleCount andGetInfo:info];
}
void SkOSWindow::detach() {
diff --git a/src/views/unix/SkOSWindow_Unix.cpp b/src/views/unix/SkOSWindow_Unix.cpp
index 7da04bdc7c..f6e32e42f2 100644
--- a/src/views/unix/SkOSWindow_Unix.cpp
+++ b/src/views/unix/SkOSWindow_Unix.cpp
@@ -37,7 +37,7 @@ SkOSWindow::SkOSWindow(void* unused)
, fMSAASampleCount(0) {
fUnixWindow.fDisplay = NULL;
fUnixWindow.fGLContext = NULL;
- this->initWindow(0);
+ this->initWindow(0, NULL);
this->resize(WIDTH, HEIGHT);
}
@@ -59,12 +59,21 @@ void SkOSWindow::closeWindow() {
}
}
-void SkOSWindow::initWindow(int requestedMSAASampleCount) {
+void SkOSWindow::initWindow(int requestedMSAASampleCount, AttachmentInfo* info) {
if (fMSAASampleCount != requestedMSAASampleCount) {
this->closeWindow();
}
// presence of fDisplay means we already have a window
if (NULL != fUnixWindow.fDisplay) {
+ if (NULL != info) {
+ if (NULL != fVi) {
+ glXGetConfig(fUnixWindow.fDisplay, fVi, GLX_SAMPLES_ARB, &info->fSampleCount);
+ glXGetConfig(fUnixWindow.fDisplay, fVi, GLX_STENCIL_SIZE, &info->fStencilBits);
+ } else {
+ info->fSampleCount = 0;
+ info->fStencilBits = 0;
+ }
+ }
return;
}
fUnixWindow.fDisplay = XOpenDisplay(NULL);
@@ -101,6 +110,10 @@ void SkOSWindow::initWindow(int requestedMSAASampleCount) {
}
if (fVi) {
+ if (NULL != info) {
+ glXGetConfig(dsp, fVi, GLX_SAMPLES_ARB, &info->fSampleCount);
+ glXGetConfig(dsp, fVi, GLX_STENCIL_SIZE, &info->fStencilBits);
+ }
Colormap colorMap = XCreateColormap(dsp,
RootWindow(dsp, fVi->screen),
fVi->visual,
@@ -119,6 +132,10 @@ void SkOSWindow::initWindow(int requestedMSAASampleCount) {
CWEventMask | CWColormap,
&swa);
} else {
+ if (NULL != info) {
+ info->fSampleCount = 0;
+ info->fStencilBits = 0;
+ }
// Create a simple window instead. We will not be able to show GL
fUnixWindow.fWin = XCreateSimpleWindow(dsp,
DefaultRootWindow(dsp),
@@ -250,8 +267,9 @@ void SkOSWindow::mapWindowAndWait() {
}
-bool SkOSWindow::attach(SkBackEndTypes /* attachType */, int msaaSampleCount) {
- this->initWindow(msaaSampleCount);
+bool SkOSWindow::attach(SkBackEndTypes, int msaaSampleCount, AttachmentInfo* info) {
+ this->initWindow(msaaSampleCount, info);
+
if (NULL == fUnixWindow.fDisplay) {
return false;
}
diff --git a/src/views/win/SkOSWindow_win.cpp b/src/views/win/SkOSWindow_win.cpp
index 620bd7189c..1d247b24eb 100644
--- a/src/views/win/SkOSWindow_win.cpp
+++ b/src/views/win/SkOSWindow_win.cpp
@@ -324,7 +324,7 @@ void SkEvent::SignalQueueTimer(SkMSec delay)
#if SK_SUPPORT_GPU
-bool SkOSWindow::attachGL(int msaaSampleCount) {
+bool SkOSWindow::attachGL(int msaaSampleCount, AttachmentInfo* info) {
HDC dc = GetDC((HWND)fHWND);
if (NULL == fHGLRC) {
fHGLRC = SkCreateWGLContext(dc, msaaSampleCount, false);
@@ -337,8 +337,27 @@ bool SkOSWindow::attachGL(int msaaSampleCount) {
glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
}
if (wglMakeCurrent(dc, (HGLRC)fHGLRC)) {
- glViewport(0, 0, SkScalarRound(this->width()),
- SkScalarRound(this->height()));
+ // use DescribePixelFormat to get the stencil bit depth.
+ int pixelFormat = GetPixelFormat(dc);
+ PIXELFORMATDESCRIPTOR pfd;
+ DescribePixelFormat(dc, pixelFormat, sizeof(pfd), &pfd);
+ info->fStencilBits = pfd.cStencilBits;
+
+ // Get sample count if the MSAA WGL extension is present
+ SkWGLExtensions extensions;
+ if (extensions.hasExtension(dc, "WGL_ARB_multisample")) {
+ static const int kSampleCountAttr = SK_WGL_SAMPLES;
+ extensions.getPixelFormatAttribiv(dc,
+ pixelFormat,
+ 0,
+ 1,
+ &kSampleCountAttr,
+ &info->fSampleCount);
+ } else {
+ info->fSampleCount = 0;
+ }
+
+ glViewport(0, 0, SkScalarRound(this->width()), SkScalarRound(this->height()));
return true;
}
return false;
@@ -360,7 +379,8 @@ bool create_ANGLE(EGLNativeWindowType hWnd,
int msaaSampleCount,
EGLDisplay* eglDisplay,
EGLContext* eglContext,
- EGLSurface* eglSurface) {
+ EGLSurface* eglSurface,
+ EGLConfig* eglConfig) {
static const EGLint contextAttribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE, EGL_NONE
@@ -395,7 +415,6 @@ bool create_ANGLE(EGLNativeWindowType hWnd,
}
// Choose config
- EGLConfig config;
bool foundConfig = false;
if (msaaSampleCount) {
static const int kConfigAttribListCnt =
@@ -410,21 +429,19 @@ bool create_ANGLE(EGLNativeWindowType hWnd,
msaaConfigAttribList[kConfigAttribListCnt + 1] = EGL_SAMPLES;
msaaConfigAttribList[kConfigAttribListCnt + 2] = msaaSampleCount;
msaaConfigAttribList[kConfigAttribListCnt + 3] = EGL_NONE;
- if (eglChooseConfig(display, configAttribList,
- &config, 1, &numConfigs)) {
+ if (eglChooseConfig(display, configAttribList, eglConfig, 1, &numConfigs)) {
SkASSERT(numConfigs > 0);
foundConfig = true;
}
}
if (!foundConfig) {
- if (!eglChooseConfig(display, configAttribList,
- &config, 1, &numConfigs)) {
+ if (!eglChooseConfig(display, configAttribList, eglConfig, 1, &numConfigs)) {
return false;
}
}
// Create a surface
- EGLSurface surface = eglCreateWindowSurface(display, config,
+ EGLSurface surface = eglCreateWindowSurface(display, *eglConfig,
(EGLNativeWindowType)hWnd,
surfaceAttribList);
if (surface == EGL_NO_SURFACE) {
@@ -432,7 +449,7 @@ bool create_ANGLE(EGLNativeWindowType hWnd,
}
// Create a GL context
- EGLContext context = eglCreateContext(display, config,
+ EGLContext context = eglCreateContext(display, *eglConfig,
EGL_NO_CONTEXT,
contextAttribs );
if (context == EGL_NO_CONTEXT ) {
@@ -450,13 +467,14 @@ bool create_ANGLE(EGLNativeWindowType hWnd,
return true;
}
-bool SkOSWindow::attachANGLE(int msaaSampleCount) {
+bool SkOSWindow::attachANGLE(int msaaSampleCount, AttachmentInfo* info) {
if (EGL_NO_DISPLAY == fDisplay) {
bool bResult = create_ANGLE((HWND)fHWND,
msaaSampleCount,
&fDisplay,
&fContext,
- &fSurface);
+ &fSurface,
+ &fConfig);
if (false == bResult) {
return false;
}
@@ -470,6 +488,9 @@ bool SkOSWindow::attachANGLE(int msaaSampleCount) {
}
}
if (eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
+ eglGetConfigAttrib(fDisplay, fConfig, EGL_STENCIL_SIZE, &info->fStencilBits);
+ eglGetConfigAttrib(fDisplay, fConfig, EGL_SAMPLES, &info->fSampleCount);
+
SkAutoTUnref<const GrGLInterface> intf(GrGLCreateANGLEInterface());
if (intf ) {
@@ -507,7 +528,7 @@ void SkOSWindow::presentANGLE() {
#endif // SK_SUPPORT_GPU
// return true on success
-bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount) {
+bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo* info) {
// attach doubles as "windowResize" so we need to allo
// already bound states to pass through again
@@ -521,11 +542,11 @@ bool SkOSWindow::attach(SkBackEndTypes attachType, int msaaSampleCount) {
break;
#if SK_SUPPORT_GPU
case kNativeGL_BackEndType:
- result = attachGL(msaaSampleCount);
+ result = attachGL(msaaSampleCount, info);
break;
#if SK_ANGLE
case kANGLE_BackEndType:
- result = attachANGLE(msaaSampleCount);
+ result = attachANGLE(msaaSampleCount, info);
break;
#endif // SK_ANGLE
#endif // SK_SUPPORT_GPU