OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrContext.h" | 9 #include "GrContext.h" |
10 #include "SkSurface.h" | 10 #include "SkSurface.h" |
11 #include "GLWindowContext.h" | 11 #include "GLWindowContext.h" |
12 | 12 |
13 #include "gl/GrGLDefines.h" | 13 #include "gl/GrGLDefines.h" |
14 | 14 |
15 #include "gl/GrGLUtil.h" | 15 #include "gl/GrGLUtil.h" |
16 #include "GrRenderTarget.h" | 16 #include "GrRenderTarget.h" |
17 #include "GrContext.h" | 17 #include "GrContext.h" |
18 | 18 |
19 #include "SkCanvas.h" | 19 #include "SkCanvas.h" |
20 #include "SkImage_Base.h" | 20 #include "SkImage_Base.h" |
21 | 21 |
22 namespace sk_app { | 22 namespace sk_app { |
23 | 23 |
24 GLWindowContext::GLWindowContext(void* platformData, const DisplayParams& params
) | 24 GLWindowContext::GLWindowContext(const DisplayParams& params) |
25 : WindowContext() | 25 : WindowContext() |
26 , fBackendContext(nullptr) | 26 , fBackendContext(nullptr) |
27 , fRenderTarget(nullptr) | 27 , fRenderTarget(nullptr) |
28 , fSurface(nullptr) { | 28 , fSurface(nullptr) { |
| 29 fDisplayParams = params; |
29 } | 30 } |
30 | 31 |
31 void GLWindowContext::initializeContext(void* platformData, const DisplayParams&
params) { | 32 void GLWindowContext::initializeContext() { |
32 | 33 this->onInitializeContext(); |
33 this->onInitializeContext(platformData, params); | |
34 | |
35 fDisplayParams = params; | |
36 | |
37 SkAutoTUnref<const GrGLInterface> glInterface; | 34 SkAutoTUnref<const GrGLInterface> glInterface; |
38 glInterface.reset(GrGLCreateNativeInterface()); | 35 glInterface.reset(GrGLCreateNativeInterface()); |
39 fBackendContext.reset(GrGLInterfaceRemoveNVPR(glInterface.get())); | 36 fBackendContext.reset(GrGLInterfaceRemoveNVPR(glInterface.get())); |
40 | 37 |
41 SkASSERT(nullptr == fContext); | 38 SkASSERT(nullptr == fContext); |
42 fContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fBackendCo
ntext.get()); | 39 fContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fBackendCo
ntext.get()); |
43 | 40 |
44 // We may not have real sRGB support (ANGLE, in particular), so check for | 41 // We may not have real sRGB support (ANGLE, in particular), so check for |
45 // that, and fall back to L32: | 42 // that, and fall back to L32: |
46 // | 43 // |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 return fSurface; | 88 return fSurface; |
92 } | 89 } |
93 | 90 |
94 void GLWindowContext::swapBuffers() { | 91 void GLWindowContext::swapBuffers() { |
95 this->presentRenderSurface(fSurface, fRenderTarget, fActualColorBits); | 92 this->presentRenderSurface(fSurface, fRenderTarget, fActualColorBits); |
96 this->onSwapBuffers(); | 93 this->onSwapBuffers(); |
97 } | 94 } |
98 | 95 |
99 void GLWindowContext::resize(uint32_t w, uint32_t h) { | 96 void GLWindowContext::resize(uint32_t w, uint32_t h) { |
100 this->destroyContext(); | 97 this->destroyContext(); |
101 | 98 this->initializeContext(); |
102 this->initializeContext(nullptr, fDisplayParams); | |
103 } | 99 } |
104 | 100 |
105 void GLWindowContext::setDisplayParams(const DisplayParams& params) { | 101 void GLWindowContext::setDisplayParams(const DisplayParams& params) { |
106 this->destroyContext(); | 102 this->destroyContext(); |
107 | 103 fDisplayParams = params; |
108 this->initializeContext(nullptr, params); | 104 this->initializeContext(); |
109 } | 105 } |
110 | 106 |
111 } //namespace sk_app | 107 } //namespace sk_app |
OLD | NEW |