scroggo | 478652e | 2015-03-25 07:11:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 8 | #ifndef DMGpuSupport_DEFINED |
| 9 | #define DMGpuSupport_DEFINED |
| 10 | |
| 11 | // Provides Ganesh to DM, |
| 12 | // or if it's not available, fakes it enough so most code doesn't have to know that. |
| 13 | |
| 14 | #include "SkSurface.h" |
| 15 | |
| 16 | #if SK_SUPPORT_GPU |
| 17 | |
| 18 | // Ganesh is available. Yippee! |
| 19 | |
| 20 | # include "GrContext.h" |
| 21 | # include "GrContextFactory.h" |
| 22 | |
| 23 | namespace DM { |
| 24 | |
| 25 | static const bool kGPUDisabled = false; |
| 26 | |
| 27 | static inline SkSurface* NewGpuSurface(GrContextFactory* grFactory, |
| 28 | GrContextFactory::GLContextType type, |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 29 | GrGLStandard gpuAPI, |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 30 | SkImageInfo info, |
jvanverth | 4736e14 | 2014-11-07 07:12:46 -0800 | [diff] [blame] | 31 | int samples, |
bsalomon | afcd7cd | 2015-08-31 12:39:41 -0700 | [diff] [blame^] | 32 | bool useDIText) { |
| 33 | uint32_t flags = useDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0; |
jvanverth | 4736e14 | 2014-11-07 07:12:46 -0800 | [diff] [blame] | 34 | SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); |
bsalomon | afe3005 | 2015-01-16 07:32:33 -0800 | [diff] [blame] | 35 | return SkSurface::NewRenderTarget(grFactory->get(type, gpuAPI), SkSurface::kNo_Budgeted, |
| 36 | info, samples, &props); |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | } // namespace DM |
| 40 | |
| 41 | #else// !SK_SUPPORT_GPU |
| 42 | |
| 43 | // Ganesh is not available. Fake it. |
| 44 | |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 45 | enum GrGLStandard { |
| 46 | kNone_GrGLStandard, |
| 47 | kGL_GrGLStandard, |
| 48 | kGLES_GrGLStandard |
| 49 | }; |
mtklein | 2ecf86e | 2014-11-06 08:06:39 -0800 | [diff] [blame] | 50 | static const int kGrGLStandardCnt = 3; |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 51 | |
mtklein | b9eb4ac | 2015-02-02 18:26:03 -0800 | [diff] [blame] | 52 | class GrContext { |
| 53 | public: |
| 54 | void dumpCacheStats(SkString*) const {} |
| 55 | void dumpGpuStats(SkString*) const {} |
| 56 | }; |
| 57 | |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 58 | struct GrContextOptions {}; |
| 59 | |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 60 | class GrContextFactory { |
| 61 | public: |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 62 | GrContextFactory() {}; |
| 63 | explicit GrContextFactory(const GrContextOptions&) {} |
| 64 | |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 65 | typedef int GLContextType; |
| 66 | |
hendrikw | 885bf09 | 2015-08-27 10:38:39 -0700 | [diff] [blame] | 67 | static const GLContextType kANGLE_GLContextType = 0, |
| 68 | kCommandBuffer_GLContextType = 0, |
| 69 | kDebug_GLContextType = 0, |
| 70 | kMESA_GLContextType = 0, |
| 71 | kNVPR_GLContextType = 0, |
| 72 | kNative_GLContextType = 0, |
| 73 | kNull_GLContextType = 0; |
mtklein | 2ecf86e | 2014-11-06 08:06:39 -0800 | [diff] [blame] | 74 | static const int kGLContextTypeCnt = 1; |
mtklein | 1e319f7 | 2014-07-15 08:27:06 -0700 | [diff] [blame] | 75 | void destroyContexts() {} |
bsalomon | 2354f84 | 2014-07-28 13:48:36 -0700 | [diff] [blame] | 76 | |
| 77 | void abandonContexts() {} |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | namespace DM { |
| 81 | |
| 82 | static const bool kGPUDisabled = true; |
| 83 | |
| 84 | static inline SkSurface* NewGpuSurface(GrContextFactory*, |
| 85 | GrContextFactory::GLContextType, |
kkinnunen | 80549fc | 2014-06-30 06:36:31 -0700 | [diff] [blame] | 86 | GrGLStandard, |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 87 | SkImageInfo, |
jvanverth | 4736e14 | 2014-11-07 07:12:46 -0800 | [diff] [blame] | 88 | int, |
| 89 | bool) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 90 | return nullptr; |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | } // namespace DM |
| 94 | |
| 95 | #endif//SK_SUPPORT_GPU |
| 96 | |
commit-bot@chromium.org | 787227d | 2014-03-26 21:26:15 +0000 | [diff] [blame] | 97 | #endif//DMGpuSupport_DEFINED |