aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2018-02-15 15:25:11 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-16 15:31:36 +0000
commit6848b716f7d51a2456535f9a1a5e1bed725fdd64 (patch)
tree8514e7344c88f9f7e6064c70b2a3b3f0d16dbde9 /tools
parent76a076bbdfe3e3837ff9e422d94124991062f583 (diff)
Fix flicker when changing backend on iOS viewer
This is the same fix from: https://skia-review.googlesource.com/c/skia/+/107941 Change-Id: I1367b1fc466cecbc2733b4e337376ce9f48cb6d8 Reviewed-on: https://skia-review.googlesource.com/107980 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/sk_app/ios/GLWindowContext_ios.cpp20
-rw-r--r--tools/sk_app/ios/RasterWindowContext_ios.cpp12
-rw-r--r--tools/sk_app/ios/WindowContextFactory_ios.h3
-rw-r--r--tools/sk_app/ios/Window_ios.cpp13
-rw-r--r--tools/sk_app/ios/Window_ios.h12
5 files changed, 28 insertions, 32 deletions
diff --git a/tools/sk_app/ios/GLWindowContext_ios.cpp b/tools/sk_app/ios/GLWindowContext_ios.cpp
index 2a57b33e30..aac7e20fd9 100644
--- a/tools/sk_app/ios/GLWindowContext_ios.cpp
+++ b/tools/sk_app/ios/GLWindowContext_ios.cpp
@@ -27,7 +27,7 @@ public:
void onSwapBuffers() override;
sk_sp<const GrGLInterface> onInitializeContext() override;
- void onDestroyContext() override;
+ void onDestroyContext() override {}
private:
SDL_Window* fWindow;
@@ -39,7 +39,7 @@ private:
GLWindowContext_ios::GLWindowContext_ios(const IOSWindowInfo& info, const DisplayParams& params)
: INHERITED(params)
, fWindow(info.fWindow)
- , fGLContext(nullptr) {
+ , fGLContext(info.fGLContext) {
// any config code here (particularly for msaa)?
@@ -52,12 +52,7 @@ GLWindowContext_ios::~GLWindowContext_ios() {
sk_sp<const GrGLInterface> GLWindowContext_ios::onInitializeContext() {
SkASSERT(fWindow);
-
- fGLContext = SDL_GL_CreateContext(fWindow);
- if (!fGLContext) {
- SkDebugf("%s\n", SDL_GetError());
- return nullptr;
- }
+ SkASSERT(fGLContext);
if (0 == SDL_GL_MakeCurrent(fWindow, fGLContext)) {
glClearStencil(0);
@@ -77,15 +72,6 @@ sk_sp<const GrGLInterface> GLWindowContext_ios::onInitializeContext() {
return GrGLMakeNativeInterface();
}
-void GLWindowContext_ios::onDestroyContext() {
- if (!fWindow || !fGLContext) {
- return;
- }
- SDL_GL_DeleteContext(fGLContext);
- fGLContext = nullptr;
-}
-
-
void GLWindowContext_ios::onSwapBuffers() {
if (fWindow && fGLContext) {
SDL_GL_SwapWindow(fWindow);
diff --git a/tools/sk_app/ios/RasterWindowContext_ios.cpp b/tools/sk_app/ios/RasterWindowContext_ios.cpp
index 53d7c1a372..18a6c36014 100644
--- a/tools/sk_app/ios/RasterWindowContext_ios.cpp
+++ b/tools/sk_app/ios/RasterWindowContext_ios.cpp
@@ -64,12 +64,7 @@ RasterWindowContext_ios::~RasterWindowContext_ios() {
sk_sp<const GrGLInterface> RasterWindowContext_ios::onInitializeContext() {
SkASSERT(fWindow);
-
- fGLContext = SDL_GL_CreateContext(fWindow);
- if (!fGLContext) {
- SkDebugf("%s\n", SDL_GetError());
- return nullptr;
- }
+ SkASSERT(fGLContext);
if (0 == SDL_GL_MakeCurrent(fWindow, fGLContext)) {
glClearStencil(0);
@@ -95,12 +90,7 @@ sk_sp<const GrGLInterface> RasterWindowContext_ios::onInitializeContext() {
}
void RasterWindowContext_ios::onDestroyContext() {
- if (!fWindow || !fGLContext) {
- return;
- }
fBackbufferSurface.reset(nullptr);
- SDL_GL_DeleteContext(fGLContext);
- fGLContext = nullptr;
}
sk_sp<SkSurface> RasterWindowContext_ios::getBackbufferSurface() { return fBackbufferSurface; }
diff --git a/tools/sk_app/ios/WindowContextFactory_ios.h b/tools/sk_app/ios/WindowContextFactory_ios.h
index 09999c4c83..93c6fbf450 100644
--- a/tools/sk_app/ios/WindowContextFactory_ios.h
+++ b/tools/sk_app/ios/WindowContextFactory_ios.h
@@ -19,7 +19,8 @@ struct DisplayParams;
namespace window_context_factory {
struct IOSWindowInfo {
- SDL_Window* fWindow;
+ SDL_Window* fWindow;
+ SDL_GLContext fGLContext;
};
inline WindowContext* NewVulkanForIOS(const IOSWindowInfo&, const DisplayParams&) {
diff --git a/tools/sk_app/ios/Window_ios.cpp b/tools/sk_app/ios/Window_ios.cpp
index ac0ad0caa0..9b2339d19e 100644
--- a/tools/sk_app/ios/Window_ios.cpp
+++ b/tools/sk_app/ios/Window_ios.cpp
@@ -71,10 +71,22 @@ bool Window_ios::initWindow() {
fWindowID = SDL_GetWindowID(fWindow);
gWindowMap.add(this);
+ fGLContext = SDL_GL_CreateContext(fWindow);
+ if (!fGLContext) {
+ SkDebugf("%s\n", SDL_GetError());
+ this->closeWindow();
+ return false;
+ }
+
return true;
}
void Window_ios::closeWindow() {
+ if (fGLContext) {
+ SDL_GL_DeleteContext(fGLContext);
+ fGLContext = nullptr;
+ }
+
if (fWindow) {
gWindowMap.remove(fWindowID);
SDL_DestroyWindow(fWindow);
@@ -251,6 +263,7 @@ bool Window_ios::attach(BackendType attachType) {
window_context_factory::IOSWindowInfo info;
info.fWindow = fWindow;
+ info.fGLContext = fGLContext;
switch (attachType) {
case kRaster_BackendType:
fWindowContext = NewRasterForIOS(info, fRequestedDisplayParams);
diff --git a/tools/sk_app/ios/Window_ios.h b/tools/sk_app/ios/Window_ios.h
index a0fed90697..260b133ff9 100644
--- a/tools/sk_app/ios/Window_ios.h
+++ b/tools/sk_app/ios/Window_ios.h
@@ -18,7 +18,12 @@ namespace sk_app {
class Window_ios : public Window {
public:
- Window_ios() : INHERITED(), fWindow(nullptr), fWindowID(0), fMSAASampleCount(1) {}
+ Window_ios()
+ : INHERITED()
+ , fWindow(nullptr)
+ , fWindowID(0)
+ , fGLContext(nullptr)
+ , fMSAASampleCount(1) {}
~Window_ios() override { this->closeWindow(); }
bool initWindow();
@@ -47,8 +52,9 @@ private:
static SkTDynamicHash<Window_ios, Uint32> gWindowMap;
- SDL_Window* fWindow;
- Uint32 fWindowID;
+ SDL_Window* fWindow;
+ Uint32 fWindowID;
+ SDL_GLContext fGLContext;
int fMSAASampleCount;