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 | |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 45 | class GrContextFactory { |
| 46 | public: |
| 47 | typedef int GLContextType; |
| 48 | |
| 49 | static const GLContextType kANGLE_GLContextType = 0, |
| 50 | kDebug_GLContextType = 0, |
| 51 | kMESA_GLContextType = 0, |
| 52 | kNVPR_GLContextType = 0, |
| 53 | kNative_GLContextType = 0, |
| 54 | kNull_GLContextType = 0; |
mtklein | 2ecf86e | 2014-11-06 08:06:39 -0800 | [diff] [blame] | 55 | static const int kGLContextTypeCnt = 1; |
mtklein | 1e319f7 | 2014-07-15 08:27:06 -0700 | [diff] [blame] | 56 | void destroyContexts() {} |
bsalomon | 2354f84 | 2014-07-28 13:48:36 -0700 | [diff] [blame] | 57 | |
| 58 | void abandonContexts() {} |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | namespace DM { |
| 62 | |
| 63 | static const bool kGPUDisabled = true; |
| 64 | |
| 65 | static inline SkSurface* NewGpuSurface(GrContextFactory*, |
| 66 | GrContextFactory::GLContextType, |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 67 | GrGLStandard, |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 68 | SkImageInfo, |
jvanverth | 4736e14 | 2014-11-07 07:12:46 -0800 | [diff] [blame] | 69 | int, |
| 70 | bool) { |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 71 | return NULL; |
| 72 | } |
| 73 | |
| 74 | } // namespace DM |
| 75 | |
| 76 | #endif//SK_SUPPORT_GPU |
| 77 | |
mtklein | 82d2843 | 2015-01-15 12:46:02 -0800 | [diff] [blame] | 78 | GrContextFactory* GetThreadLocalGrContextFactory(); |
| 79 | |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 80 | #endif//DMGpuSupport_DEFINED |