blob: a3c487d596f8996ce3feb083acc6dd70706b0253 [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,
24 int samples) {
kkinnunen80549fc2014-06-30 06:36:31 -070025 return SkSurface::NewRenderTarget(grFactory->get(type, gpuAPI), info, samples);
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000026}
27
28} // namespace DM
29
30#else// !SK_SUPPORT_GPU
31
32// Ganesh is not available. Fake it.
33
kkinnunen80549fc2014-06-30 06:36:31 -070034enum GrGLStandard {
35 kNone_GrGLStandard,
36 kGL_GrGLStandard,
37 kGLES_GrGLStandard
38};
39
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000040class GrContextFactory {
41public:
42 typedef int GLContextType;
43
44 static const GLContextType kANGLE_GLContextType = 0,
45 kDebug_GLContextType = 0,
46 kMESA_GLContextType = 0,
47 kNVPR_GLContextType = 0,
48 kNative_GLContextType = 0,
49 kNull_GLContextType = 0;
mtklein1e319f72014-07-15 08:27:06 -070050 void destroyContexts() {}
bsalomon2354f842014-07-28 13:48:36 -070051
52 void abandonContexts() {}
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000053};
54
55namespace DM {
56
57static const bool kGPUDisabled = true;
58
59static inline SkSurface* NewGpuSurface(GrContextFactory*,
60 GrContextFactory::GLContextType,
kkinnunen80549fc2014-06-30 06:36:31 -070061 GrGLStandard,
commit-bot@chromium.org787227d2014-03-26 21:26:15 +000062 SkImageInfo,
63 int) {
64 return NULL;
65}
66
67} // namespace DM
68
69#endif//SK_SUPPORT_GPU
70
71#endif//DMGpuSupport_DEFINED