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, |
jvanverth | 4736e14 | 2014-11-07 07:12:46 -0800 | [diff] [blame^] | 24 | int samples, |
| 25 | bool useDFText) { |
| 26 | uint32_t flags = useDFText ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; |
| 27 | SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); |
| 28 | return SkSurface::NewRenderTarget(grFactory->get(type, gpuAPI), info, samples, &props); |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | } // namespace DM |
| 32 | |
| 33 | #else// !SK_SUPPORT_GPU |
| 34 | |
| 35 | // Ganesh is not available. Fake it. |
| 36 | |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 37 | enum GrGLStandard { |
| 38 | kNone_GrGLStandard, |
| 39 | kGL_GrGLStandard, |
| 40 | kGLES_GrGLStandard |
| 41 | }; |
mtklein | 2ecf86e | 2014-11-06 08:06:39 -0800 | [diff] [blame] | 42 | static const int kGrGLStandardCnt = 3; |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 43 | |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 44 | class GrContextFactory { |
| 45 | public: |
| 46 | typedef int GLContextType; |
| 47 | |
| 48 | static const GLContextType kANGLE_GLContextType = 0, |
| 49 | kDebug_GLContextType = 0, |
| 50 | kMESA_GLContextType = 0, |
| 51 | kNVPR_GLContextType = 0, |
| 52 | kNative_GLContextType = 0, |
| 53 | kNull_GLContextType = 0; |
mtklein | 2ecf86e | 2014-11-06 08:06:39 -0800 | [diff] [blame] | 54 | static const int kGLContextTypeCnt = 1; |
mtklein | 1e319f7 | 2014-07-15 08:27:06 -0700 | [diff] [blame] | 55 | void destroyContexts() {} |
bsalomon | 2354f84 | 2014-07-28 13:48:36 -0700 | [diff] [blame] | 56 | |
| 57 | void abandonContexts() {} |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | namespace DM { |
| 61 | |
| 62 | static const bool kGPUDisabled = true; |
| 63 | |
| 64 | static inline SkSurface* NewGpuSurface(GrContextFactory*, |
| 65 | GrContextFactory::GLContextType, |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 66 | GrGLStandard, |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 67 | SkImageInfo, |
jvanverth | 4736e14 | 2014-11-07 07:12:46 -0800 | [diff] [blame^] | 68 | int, |
| 69 | bool) { |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 70 | return NULL; |
| 71 | } |
| 72 | |
| 73 | } // namespace DM |
| 74 | |
| 75 | #endif//SK_SUPPORT_GPU |
| 76 | |
| 77 | #endif//DMGpuSupport_DEFINED |