blob: 1ced0190a453d9fc730d106550ff87008f917c55 [file] [log] [blame]
commit-bot@chromium.org787227d2014-03-26 21:26:15 +00001#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
16namespace DM {
17
18static const bool kGPUDisabled = false;
19
20static inline SkSurface* NewGpuSurface(GrContextFactory* grFactory,
21 GrContextFactory::GLContextType type,
kkinnunen80549fc2014-06-30 06:36:31 -070022 GrGLStandard gpuAPI,
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000023 SkImageInfo info,
jvanverth4736e142014-11-07 07:12:46 -080024 int samples,
25 bool useDFText) {
26 uint32_t flags = useDFText ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0;
27 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
bsalomonafe30052015-01-16 07:32:33 -080028 return SkSurface::NewRenderTarget(grFactory->get(type, gpuAPI), SkSurface::kNo_Budgeted,
29 info, samples, &props);
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000030}
31
32} // namespace DM
33
34#else// !SK_SUPPORT_GPU
35
36// Ganesh is not available. Fake it.
37
kkinnunen80549fc2014-06-30 06:36:31 -070038enum GrGLStandard {
39 kNone_GrGLStandard,
40 kGL_GrGLStandard,
41 kGLES_GrGLStandard
42};
mtklein2ecf86e2014-11-06 08:06:39 -080043static const int kGrGLStandardCnt = 3;
kkinnunen80549fc2014-06-30 06:36:31 -070044
mtkleinb9eb4ac2015-02-02 18:26:03 -080045class GrContext {
46public:
47 void dumpCacheStats(SkString*) const {}
48 void dumpGpuStats(SkString*) const {}
49};
50
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000051class GrContextFactory {
52public:
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;
mtklein2ecf86e2014-11-06 08:06:39 -080061 static const int kGLContextTypeCnt = 1;
mtklein1e319f72014-07-15 08:27:06 -070062 void destroyContexts() {}
bsalomon2354f842014-07-28 13:48:36 -070063
64 void abandonContexts() {}
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000065};
66
67namespace DM {
68
69static const bool kGPUDisabled = true;
70
71static inline SkSurface* NewGpuSurface(GrContextFactory*,
72 GrContextFactory::GLContextType,
kkinnunen80549fc2014-06-30 06:36:31 -070073 GrGLStandard,
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000074 SkImageInfo,
jvanverth4736e142014-11-07 07:12:46 -080075 int,
76 bool) {
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000077 return NULL;
78}
79
80} // namespace DM
81
82#endif//SK_SUPPORT_GPU
83
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000084#endif//DMGpuSupport_DEFINED