OLD | NEW |
(Empty) | |
| 1 |
| 2 /* |
| 3 * Copyright 2016 Google Inc. |
| 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. |
| 7 */ |
| 8 #ifndef GLWindowContext_DEFINED |
| 9 #define GLWindowContext_DEFINED |
| 10 |
| 11 |
| 12 #include "gl/GrGLInterface.h" |
| 13 |
| 14 #include "SkRefCnt.h" |
| 15 #include "GrRenderTarget.h" |
| 16 #include "SkSurface.h" |
| 17 |
| 18 #include "WindowContext.h" |
| 19 |
| 20 class GrContext; |
| 21 |
| 22 namespace sk_app { |
| 23 |
| 24 class GLWindowContext : public WindowContext { |
| 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; |
| 30 |
| 31 bool isValid() override { return SkToBool(fBackendContext.get()); } |
| 32 |
| 33 void resize(uint32_t w, uint32_t h) override; |
| 34 void swapBuffers() override; |
| 35 |
| 36 const DisplayParams& getDisplayParams() override { return fDisplayParams; } |
| 37 void setDisplayParams(const DisplayParams& params) override; |
| 38 |
| 39 GrBackendContext getBackendContext() override { |
| 40 return (GrBackendContext) fBackendContext.get(); |
| 41 } |
| 42 |
| 43 protected: |
| 44 GLWindowContext(void*, const DisplayParams&); |
| 45 void initializeContext(void*, const DisplayParams&); |
| 46 virtual void onInitializeContext(void*, const DisplayParams&) = 0; |
| 47 void destroyContext(); |
| 48 virtual void onDestroyContext() = 0; |
| 49 virtual void onSwapBuffers() = 0; |
| 50 |
| 51 SkAutoTUnref<const GrGLInterface> fBackendContext; |
| 52 sk_sp<GrRenderTarget> fRenderTarget; |
| 53 sk_sp<SkSurface> fBackbuffer; |
| 54 |
| 55 // parameters obtained from the native window |
| 56 int fWidth; |
| 57 int fHeight; |
| 58 int fSampleCount; |
| 59 int fStencilBits; |
| 60 int fColorBits; |
| 61 int fActualColorBits; |
| 62 }; |
| 63 |
| 64 } // namespace sk_app |
| 65 |
| 66 #endif |
OLD | NEW |