| 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 #ifndef SKCOMMANDBUFFERGLCONTEXT_DEFINED | 8 #ifndef SKCOMMANDBUFFERGLCONTEXT_DEFINED |
| 9 #define SKCOMMANDBUFFERGLCONTEXT_DEFINED | 9 #define SKCOMMANDBUFFERGLCONTEXT_DEFINED |
| 10 | 10 |
| 11 #if SK_COMMAND_BUFFER | 11 #if SK_COMMAND_BUFFER |
| 12 | 12 |
| 13 #include "gl/SkGLContext.h" | 13 #include "gl/SkGLContext.h" |
| 14 | 14 |
| 15 class SkCommandBufferGLContext : public SkGLContext { | 15 class SkCommandBufferGLContext : public SkGLContext { |
| 16 public: | 16 public: |
| 17 ~SkCommandBufferGLContext() override; | 17 ~SkCommandBufferGLContext() override; |
| 18 | 18 |
| 19 static SkCommandBufferGLContext* Create() { | 19 static SkCommandBufferGLContext* CreateES2() { |
| 20 SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext; | 20 SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext(kGLES2_Cont
extVersion); |
| 21 if (!ctx->isValid()) { | 21 if (!ctx->isValid()) { |
| 22 delete ctx; | 22 delete ctx; |
| 23 return nullptr; | 23 return nullptr; |
| 24 } |
| 25 return ctx; |
| 26 } |
| 27 static SkCommandBufferGLContext* CreateES3() { |
| 28 SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext(kGLES3_Cont
extVersion); |
| 29 if (!ctx->isValid()) { |
| 30 delete ctx; |
| 31 return nullptr; |
| 24 } | 32 } |
| 25 return ctx; | 33 return ctx; |
| 26 } | 34 } |
| 27 | 35 |
| 28 static SkCommandBufferGLContext* Create(void* nativeWindow, int msaaSampleCo
unt) { | 36 static SkCommandBufferGLContext* Create(void* nativeWindow, int msaaSampleCo
unt) { |
| 29 SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext(nativeWindo
w, | 37 SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext(nativeWindo
w, |
| 30 msaaSampleC
ount); | 38 msaaSampleC
ount); |
| 31 if (!ctx->isValid()) { | 39 if (!ctx->isValid()) { |
| 32 delete ctx; | 40 delete ctx; |
| 33 return nullptr; | 41 return nullptr; |
| 34 } | 42 } |
| 35 return ctx; | 43 return ctx; |
| 36 } | 44 } |
| 37 | 45 |
| 38 void presentCommandBuffer(); | 46 void presentCommandBuffer(); |
| 39 | 47 |
| 40 bool makeCurrent(); | 48 bool makeCurrent(); |
| 41 int getStencilBits(); | 49 int getStencilBits(); |
| 42 int getSampleCount(); | 50 int getSampleCount(); |
| 43 | 51 |
| 44 private: | 52 private: |
| 45 SkCommandBufferGLContext(); | 53 enum ContextVersion { |
| 54 kGLES2_ContextVersion, |
| 55 kGLES3_ContextVersion |
| 56 }; |
| 57 SkCommandBufferGLContext(ContextVersion minContextVersion); |
| 46 SkCommandBufferGLContext(void* nativeWindow, int msaaSampleCount); | 58 SkCommandBufferGLContext(void* nativeWindow, int msaaSampleCount); |
| 47 void initializeGLContext(void* nativeWindow, const int* configAttribs, | 59 void initializeGLContext(ContextVersion minContextVersion, void* nativeWindo
w, |
| 48 const int* surfaceAttribs); | 60 const int* configAttribs, const int* surfaceAttribs
); |
| 49 void destroyGLContext(); | 61 void destroyGLContext(); |
| 50 | 62 |
| 51 void onPlatformMakeCurrent() const override; | 63 void onPlatformMakeCurrent() const override; |
| 52 void onPlatformSwapBuffers() const override; | 64 void onPlatformSwapBuffers() const override; |
| 53 GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override; | 65 GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override; |
| 54 | 66 |
| 55 void* fContext; | 67 void* fContext; |
| 56 void* fDisplay; | 68 void* fDisplay; |
| 57 void* fSurface; | 69 void* fSurface; |
| 58 void* fConfig; | 70 void* fConfig; |
| 59 }; | 71 }; |
| 60 | 72 |
| 61 #endif // SK_COMMAND_BUFFER | 73 #endif // SK_COMMAND_BUFFER |
| 62 | 74 |
| 63 #endif | 75 #endif |
| OLD | NEW |