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, |
| 22 | SkImageInfo info, |
| 23 | int samples) { |
| 24 | return SkSurface::NewRenderTarget(grFactory->get(type), info, samples); |
| 25 | } |
| 26 | |
| 27 | } // namespace DM |
| 28 | |
| 29 | #else// !SK_SUPPORT_GPU |
| 30 | |
| 31 | // Ganesh is not available. Fake it. |
| 32 | |
| 33 | class GrContextFactory { |
| 34 | public: |
| 35 | typedef int GLContextType; |
| 36 | |
| 37 | static const GLContextType kANGLE_GLContextType = 0, |
| 38 | kDebug_GLContextType = 0, |
| 39 | kMESA_GLContextType = 0, |
| 40 | kNVPR_GLContextType = 0, |
| 41 | kNative_GLContextType = 0, |
| 42 | kNull_GLContextType = 0; |
| 43 | }; |
| 44 | |
| 45 | namespace DM { |
| 46 | |
| 47 | static const bool kGPUDisabled = true; |
| 48 | |
| 49 | static inline SkSurface* NewGpuSurface(GrContextFactory*, |
| 50 | GrContextFactory::GLContextType, |
| 51 | SkImageInfo, |
| 52 | int) { |
| 53 | return NULL; |
| 54 | } |
| 55 | |
| 56 | } // namespace DM |
| 57 | |
| 58 | #endif//SK_SUPPORT_GPU |
| 59 | |
| 60 | #endif//DMGpuSupport_DEFINED |