OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #ifndef WindowContext_DEFINED | 7 #ifndef WindowContext_DEFINED |
8 #define WindowContext_DEFINED | 8 #define WindowContext_DEFINED |
9 | 9 |
10 #include "DisplayParams.h" | 10 #include "DisplayParams.h" |
11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
| 12 #include "SkRefCnt.h" |
| 13 #include "SkSurfaceProps.h" |
12 | 14 |
| 15 class GrContext; |
13 class SkSurface; | 16 class SkSurface; |
| 17 class GrRenderTarget; |
14 | 18 |
15 namespace sk_app { | 19 namespace sk_app { |
16 | 20 |
17 // TODO: fill this out with an interface | |
18 class WindowContext { | 21 class WindowContext { |
19 public: | 22 public: |
| 23 WindowContext() : fContext(nullptr) |
| 24 , fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType) {} |
| 25 |
20 virtual ~WindowContext() {} | 26 virtual ~WindowContext() {} |
21 | 27 |
22 virtual SkSurface* getBackbufferSurface() = 0; | 28 virtual sk_sp<SkSurface> getBackbufferSurface() = 0; |
23 | 29 |
24 virtual void swapBuffers() = 0; | 30 virtual void swapBuffers() = 0; |
25 | 31 |
26 virtual bool makeCurrent() = 0; | |
27 | |
28 virtual bool isValid() = 0; | 32 virtual bool isValid() = 0; |
29 | 33 |
30 virtual void resize(uint32_t w, uint32_t h) = 0; | 34 virtual void resize(uint32_t w, uint32_t h) = 0; |
31 | 35 |
32 virtual const DisplayParams& getDisplayParams() = 0; | 36 const DisplayParams& getDisplayParams() { return fDisplayParams; } |
33 virtual void setDisplayParams(const DisplayParams& params) = 0; | 37 virtual void setDisplayParams(const DisplayParams& params) = 0; |
34 | 38 |
| 39 SkSurfaceProps getSurfaceProps() const { return fSurfaceProps; } |
| 40 void setSurfaceProps(const SkSurfaceProps& props) { |
| 41 fSurfaceProps = props; |
| 42 } |
| 43 |
35 virtual GrBackendContext getBackendContext() = 0; | 44 virtual GrBackendContext getBackendContext() = 0; |
| 45 |
| 46 sk_sp<SkSurface> createRenderSurface(sk_sp<GrRenderTarget>, int colorBits); |
| 47 void presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<GrRenderTarg
et> rt, |
| 48 int colorBits); |
| 49 |
| 50 protected: |
| 51 virtual bool isGpuContext() { return true; } |
| 52 |
| 53 GrContext* fContext; |
| 54 |
| 55 int fWidth; |
| 56 int fHeight; |
| 57 DisplayParams fDisplayParams; |
| 58 GrPixelConfig fPixelConfig; |
| 59 SkSurfaceProps fSurfaceProps; |
36 }; | 60 }; |
37 | 61 |
38 } // namespace sk_app | 62 } // namespace sk_app |
39 | 63 |
40 #endif | 64 #endif |
OLD | NEW |