commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 1 | #ifndef DMGpuSupport_DEFINED |
| 2 | #define DMGpuSupport_DEFINED |
| 3 | |
| 4 | // Provides Ganesh to DM, |
| 5 | // or if it's not available, fakes it enough so most code doesn't have to know that. |
| 6 | |
| 7 | #include "SkSurface.h" |
| 8 | |
| 9 | #if SK_SUPPORT_GPU |
| 10 | |
| 11 | // Ganesh is available. Yippee! |
| 12 | |
| 13 | # include "GrContext.h" |
| 14 | # include "GrContextFactory.h" |
| 15 | |
| 16 | namespace DM { |
| 17 | |
| 18 | static const bool kGPUDisabled = false; |
| 19 | |
| 20 | static inline SkSurface* NewGpuSurface(GrContextFactory* grFactory, |
| 21 | GrContextFactory::GLContextType type, |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 22 | GrGLStandard gpuAPI, |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 23 | SkImageInfo info, |
| 24 | int samples) { |
reed | 4a8126e | 2014-09-22 07:29:03 -0700 | [diff] [blame] | 25 | return SkSurface::NewRenderTarget(grFactory->get(type, gpuAPI), info, samples, NULL); |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | } // namespace DM |
| 29 | |
| 30 | #else// !SK_SUPPORT_GPU |
| 31 | |
| 32 | // Ganesh is not available. Fake it. |
| 33 | |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 34 | enum GrGLStandard { |
| 35 | kNone_GrGLStandard, |
| 36 | kGL_GrGLStandard, |
| 37 | kGLES_GrGLStandard |
| 38 | }; |
mtklein | 2ecf86e | 2014-11-06 08:06:39 -0800 | [diff] [blame^] | 39 | static const int kGrGLStandardCnt = 3; |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 40 | |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 41 | class GrContextFactory { |
| 42 | public: |
| 43 | typedef int GLContextType; |
| 44 | |
| 45 | static const GLContextType kANGLE_GLContextType = 0, |
| 46 | kDebug_GLContextType = 0, |
| 47 | kMESA_GLContextType = 0, |
| 48 | kNVPR_GLContextType = 0, |
| 49 | kNative_GLContextType = 0, |
| 50 | kNull_GLContextType = 0; |
mtklein | 2ecf86e | 2014-11-06 08:06:39 -0800 | [diff] [blame^] | 51 | static const int kGLContextTypeCnt = 1; |
mtklein | 1e319f7 | 2014-07-15 08:27:06 -0700 | [diff] [blame] | 52 | void destroyContexts() {} |
bsalomon | 2354f84 | 2014-07-28 13:48:36 -0700 | [diff] [blame] | 53 | |
| 54 | void abandonContexts() {} |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | namespace DM { |
| 58 | |
| 59 | static const bool kGPUDisabled = true; |
| 60 | |
| 61 | static inline SkSurface* NewGpuSurface(GrContextFactory*, |
| 62 | GrContextFactory::GLContextType, |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 63 | GrGLStandard, |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 64 | SkImageInfo, |
| 65 | int) { |
| 66 | return NULL; |
| 67 | } |
| 68 | |
| 69 | } // namespace DM |
| 70 | |
| 71 | #endif//SK_SUPPORT_GPU |
| 72 | |
| 73 | #endif//DMGpuSupport_DEFINED |