blob: 335da086199427f3d3cc055d784e95fdd7f4af1a [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
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000045class GrContextFactory {
46public:
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;
mtklein2ecf86e2014-11-06 08:06:39 -080055 static const int kGLContextTypeCnt = 1;
mtklein1e319f72014-07-15 08:27:06 -070056 void destroyContexts() {}
bsalomon2354f842014-07-28 13:48:36 -070057
58 void abandonContexts() {}
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000059};
60
61namespace DM {
62
63static const bool kGPUDisabled = true;
64
65static inline SkSurface* NewGpuSurface(GrContextFactory*,
66 GrContextFactory::GLContextType,
kkinnunen80549fc2014-06-30 06:36:31 -070067 GrGLStandard,
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000068 SkImageInfo,
jvanverth4736e142014-11-07 07:12:46 -080069 int,
70 bool) {
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000071 return NULL;
72}
73
74} // namespace DM
75
76#endif//SK_SUPPORT_GPU
77
mtklein82d28432015-01-15 12:46:02 -080078GrContextFactory* GetThreadLocalGrContextFactory();
79
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000080#endif//DMGpuSupport_DEFINED