Fix GL MSAA support in Mac Viewer.

The Mac GLContext is designed to not constantly teardown on resizes
and minor DisplayParams changes. However, for MSAA we do have to
tear it down.

Change-Id: I1a9d765068fa5f6b22dff49f6355c29e1affb686
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/226850
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
Jim Van Verth 2019-07-11 16:23:49 -04:00 committed by Skia Commit-Bot
parent c3f28e3cf0
commit af545d7f8e
2 changed files with 12 additions and 2 deletions

View File

@ -90,8 +90,8 @@ void GLWindowContext::resize(int w, int h) {
}
void GLWindowContext::setDisplayParams(const DisplayParams& params) {
this->destroyContext();
fDisplayParams = params;
this->destroyContext();
this->initializeContext();
}

View File

@ -28,7 +28,7 @@ public:
void onSwapBuffers() override;
sk_sp<const GrGLInterface> onInitializeContext() override;
void onDestroyContext() override {}
void onDestroyContext() override;
void resize(int w, int h) override;
@ -136,6 +136,16 @@ sk_sp<const GrGLInterface> GLWindowContext_mac::onInitializeContext() {
return GrGLMakeNativeInterface();
}
void GLWindowContext_mac::onDestroyContext() {
// We only need to tear down the GLContext if we've changed the sample count.
if (fGLContext && fSampleCount != fDisplayParams.fMSAASampleCount) {
[fPixelFormat release];
fPixelFormat = nil;
[fGLContext release];
fGLContext = nil;
}
}
void GLWindowContext_mac::onSwapBuffers() {
[fGLContext flushBuffer];
}