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