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