OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2016 Google Inc. | 3 * Copyright 2016 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 #ifndef GLWindowContext_DEFINED | 8 #ifndef GLWindowContext_DEFINED |
9 #define GLWindowContext_DEFINED | 9 #define GLWindowContext_DEFINED |
10 | 10 |
11 | 11 |
12 #include "gl/GrGLInterface.h" | 12 #include "gl/GrGLInterface.h" |
13 | 13 |
14 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
15 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
16 #include "SkSurface.h" | 16 #include "SkSurface.h" |
17 | 17 |
18 #include "WindowContext.h" | 18 #include "WindowContext.h" |
19 | 19 |
20 class GrContext; | 20 class GrContext; |
21 | 21 |
22 namespace sk_app { | 22 namespace sk_app { |
23 | 23 |
24 class GLWindowContext : public WindowContext { | 24 class GLWindowContext : public WindowContext { |
25 public: | 25 public: |
26 // This is defined in the platform .cpp file | |
27 static GLWindowContext* Create(void* platformData, const DisplayParams& para
ms); | |
28 | |
29 sk_sp<SkSurface> getBackbufferSurface() override; | 26 sk_sp<SkSurface> getBackbufferSurface() override; |
30 | 27 |
31 bool isValid() override { return SkToBool(fBackendContext.get()); } | 28 bool isValid() override { return SkToBool(fBackendContext.get()); } |
32 | 29 |
33 void resize(uint32_t w, uint32_t h) override; | 30 void resize(uint32_t w, uint32_t h) override; |
34 void swapBuffers() override; | 31 void swapBuffers() override; |
35 | 32 |
36 void setDisplayParams(const DisplayParams& params) override; | 33 void setDisplayParams(const DisplayParams& params) override; |
37 | 34 |
38 GrBackendContext getBackendContext() override { | 35 GrBackendContext getBackendContext() override { |
39 return (GrBackendContext) fBackendContext.get(); | 36 return (GrBackendContext) fBackendContext.get(); |
40 } | 37 } |
41 | 38 |
42 protected: | 39 protected: |
43 GLWindowContext(void*, const DisplayParams&); | 40 GLWindowContext(const DisplayParams&); |
44 void initializeContext(void*, const DisplayParams&); | 41 // This should be called by subclass constructor. It is also called when win
dow/display |
45 virtual void onInitializeContext(void*, const DisplayParams&) = 0; | 42 // parameters change. This will in turn call onInitializeContext(). |
| 43 void initializeContext(); |
| 44 virtual void onInitializeContext() = 0; |
| 45 |
| 46 // This should be called by subclass destructor. It is also called when wind
ow/display |
| 47 // parameters change prior to initializing a new GL context. This will in tu
rn call |
| 48 // onDestroyContext(). |
46 void destroyContext(); | 49 void destroyContext(); |
47 virtual void onDestroyContext() = 0; | 50 virtual void onDestroyContext() = 0; |
| 51 |
48 virtual void onSwapBuffers() = 0; | 52 virtual void onSwapBuffers() = 0; |
49 | 53 |
50 SkAutoTUnref<const GrGLInterface> fBackendContext; | 54 SkAutoTUnref<const GrGLInterface> fBackendContext; |
51 sk_sp<GrRenderTarget> fRenderTarget; | 55 sk_sp<GrRenderTarget> fRenderTarget; |
52 sk_sp<SkSurface> fSurface; | 56 sk_sp<SkSurface> fSurface; |
53 | 57 |
54 // parameters obtained from the native window | 58 // parameters obtained from the native window |
55 // Note that the platform .cpp file is responsible for | 59 // Note that the platform .cpp file is responsible for |
56 // initializing fSampleCount, fStencilBits, and fColorBits! | 60 // initializing fSampleCount, fStencilBits, and fColorBits! |
57 int fSampleCount; | 61 int fSampleCount; |
58 int fStencilBits; | 62 int fStencilBits; |
59 int fColorBits; | 63 int fColorBits; |
60 int fActualColorBits; | 64 int fActualColorBits; |
61 }; | 65 }; |
62 | 66 |
63 } // namespace sk_app | 67 } // namespace sk_app |
64 | 68 |
65 #endif | 69 #endif |
OLD | NEW |