aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/views/mac
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/mac')
-rw-r--r--src/views/mac/SkNSView.h2
-rw-r--r--src/views/mac/SkNSView.mm44
-rw-r--r--src/views/mac/SkOSWindow_Mac.mm4
3 files changed, 16 insertions, 34 deletions
diff --git a/src/views/mac/SkNSView.h b/src/views/mac/SkNSView.h
index bf6e67c71c..60727eb3e6 100644
--- a/src/views/mac/SkNSView.h
+++ b/src/views/mac/SkNSView.h
@@ -42,7 +42,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;
- (void)detach;
- (void)present;
@end
diff --git a/src/views/mac/SkNSView.mm b/src/views/mac/SkNSView.mm
index 9d52814afa..a6aa59cbef 100644
--- a/src/views/mac/SkNSView.mm
+++ b/src/views/mac/SkNSView.mm
@@ -225,36 +225,25 @@ static SkKey raw2key(UInt32 raw)
///////////////////////////////////////////////////////////////////////////////
#include <OpenGL/OpenGL.h>
-namespace {
-CGLContextObj createGLContext(int msaaSampleCount) {
+CGLContextObj createGLContext() {
GLint major, minor;
CGLGetVersion(&major, &minor);
- static const CGLPixelFormatAttribute attributes[] = {
+ const CGLPixelFormatAttribute attributes[] = {
kCGLPFAStencilSize, (CGLPixelFormatAttribute)8,
+#if USE_MSAA
+ kCGLPFASampleBuffers, 1,
+ kCGLPFAMultisample,
+ kCGLPFASamples, 8,
+#endif
kCGLPFAAccelerated,
kCGLPFADoubleBuffer,
(CGLPixelFormatAttribute)0
};
CGLPixelFormatObj format;
- GLint npix = 0;
- if (msaaSampleCount > 0) {
- static int kAttributeCount = SK_ARRAY_COUNT(attributes);
- CGLPixelFormatAttribute msaaAttributes[kAttributeCount + 5];
- memcpy(msaaAttributes, attributes, sizeof(attributes));
- SkASSERT(0 == msaaAttributes[kAttributeCount - 1]);
- msaaAttributes[kAttributeCount - 1] = kCGLPFASampleBuffers;
- msaaAttributes[kAttributeCount + 0] = (CGLPixelFormatAttribute)1;
- msaaAttributes[kAttributeCount + 1] = kCGLPFAMultisample;
- msaaAttributes[kAttributeCount + 2] = kCGLPFASamples;
- msaaAttributes[kAttributeCount + 3] = (CGLPixelFormatAttribute)msaaSampleCount;
- msaaAttributes[kAttributeCount + 4] = (CGLPixelFormatAttribute)0;
- CGLChoosePixelFormat(msaaAttributes, &format, &npix);
- }
- if (!npix) {
- CGLChoosePixelFormat(attributes, &format, &npix);
- }
+ GLint npix;
+ CGLChoosePixelFormat(attributes, &format, &npix);
CGLContextObj ctx;
CGLCreateContext(format, NULL, &ctx);
@@ -265,7 +254,6 @@ CGLContextObj createGLContext(int msaaSampleCount) {
CGLSetCurrentContext(ctx);
return ctx;
}
-}
- (void)viewDidMoveToWindow {
[super viewDidMoveToWindow];
@@ -277,15 +265,12 @@ CGLContextObj createGLContext(int msaaSampleCount) {
[fGLContext setView:self];
}
}
-- (bool)attach:(SkOSWindow::SkBackEndTypes)attachType withMSAASampleCount:(int) sampleCount {
+- (bool)attach:(SkOSWindow::SkBackEndTypes)attachType {
if (nil == fGLContext) {
- CGLContextObj ctx = createGLContext(sampleCount);
- fGLContext = [[NSOpenGLContext alloc] initWithCGLContextObj:ctx];
- CGLReleaseContext(ctx);
+ fGLContext = [[NSOpenGLContext alloc] initWithCGLContextObj:createGLContext()];
if (NULL == fGLContext) {
return false;
}
- [fGLContext setView:self];
}
[fGLContext makeCurrentContext];
@@ -298,13 +283,10 @@ CGLContextObj createGLContext(int msaaSampleCount) {
}
- (void)detach {
- [fGLContext release];
- fGLContext = nil;
+ [fGLContext clearDrawable];
}
- (void)present {
- if (nil != fGLContext) {
- [fGLContext flushBuffer];
- }
+ [fGLContext flushBuffer];
}
@end
diff --git a/src/views/mac/SkOSWindow_Mac.mm b/src/views/mac/SkOSWindow_Mac.mm
index a5d3fef706..4aa4eb5ff8 100644
--- a/src/views/mac/SkOSWindow_Mac.mm
+++ b/src/views/mac/SkOSWindow_Mac.mm
@@ -63,8 +63,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) {
+ return [(SkNSView*)fHWND attach:attachType];
}
void SkOSWindow::detach() {