blob: 33d8995b446dfece327c584b16163598921006e7 [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);
28 return SkSurface::NewRenderTarget(grFactory->get(type, gpuAPI), info, samples, &props);
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000029}
30
31} // namespace DM
32
33#else// !SK_SUPPORT_GPU
34
35// Ganesh is not available. Fake it.
36
kkinnunen80549fc2014-06-30 06:36:31 -070037enum GrGLStandard {
38 kNone_GrGLStandard,
39 kGL_GrGLStandard,
40 kGLES_GrGLStandard
41};
mtklein2ecf86e2014-11-06 08:06:39 -080042static const int kGrGLStandardCnt = 3;
kkinnunen80549fc2014-06-30 06:36:31 -070043
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000044class GrContextFactory {
45public:
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;
mtklein2ecf86e2014-11-06 08:06:39 -080054 static const int kGLContextTypeCnt = 1;
mtklein1e319f72014-07-15 08:27:06 -070055 void destroyContexts() {}
bsalomon2354f842014-07-28 13:48:36 -070056
57 void abandonContexts() {}
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000058};
59
60namespace DM {
61
62static const bool kGPUDisabled = true;
63
64static inline SkSurface* NewGpuSurface(GrContextFactory*,
65 GrContextFactory::GLContextType,
kkinnunen80549fc2014-06-30 06:36:31 -070066 GrGLStandard,
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000067 SkImageInfo,
jvanverth4736e142014-11-07 07:12:46 -080068 int,
69 bool) {
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000070 return NULL;
71}
72
73} // namespace DM
74
75#endif//SK_SUPPORT_GPU
76
77#endif//DMGpuSupport_DEFINED