2015-03-25 14:11:02 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2014-03-26 21:26:15 +00:00
|
|
|
#ifndef DMGpuSupport_DEFINED
|
|
|
|
#define DMGpuSupport_DEFINED
|
|
|
|
|
|
|
|
// Provides Ganesh to DM,
|
|
|
|
// or if it's not available, fakes it enough so most code doesn't have to know that.
|
|
|
|
|
|
|
|
#include "SkSurface.h"
|
|
|
|
|
2015-12-03 20:58:06 +00:00
|
|
|
// This should be safe to include even in no-gpu builds. Include by relative path so it
|
|
|
|
// can be found in non-gpu builds.
|
|
|
|
#include "../include/gpu/GrContextOptions.h"
|
|
|
|
|
2014-03-26 21:26:15 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
|
|
|
|
// Ganesh is available. Yippee!
|
|
|
|
|
|
|
|
# include "GrContext.h"
|
|
|
|
# include "GrContextFactory.h"
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
|
|
|
static const bool kGPUDisabled = false;
|
|
|
|
|
2016-03-31 01:56:19 +00:00
|
|
|
static inline sk_sp<SkSurface> NewGpuSurface(
|
|
|
|
sk_gpu_test::GrContextFactory* grFactory,
|
2016-04-01 20:38:04 +00:00
|
|
|
sk_gpu_test::GrContextFactory::ContextType type,
|
|
|
|
sk_gpu_test::GrContextFactory::ContextOptions options,
|
2016-03-31 01:56:19 +00:00
|
|
|
SkImageInfo info,
|
|
|
|
int samples,
|
|
|
|
bool useDIText) {
|
2015-08-31 19:39:41 +00:00
|
|
|
uint32_t flags = useDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0;
|
2014-11-07 15:12:46 +00:00
|
|
|
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
|
2016-03-24 01:59:25 +00:00
|
|
|
return SkSurface::MakeRenderTarget(grFactory->get(type, options), SkBudgeted::kNo,
|
|
|
|
info, samples, &props);
|
2014-03-26 21:26:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DM
|
|
|
|
|
|
|
|
#else// !SK_SUPPORT_GPU
|
|
|
|
|
|
|
|
// Ganesh is not available. Fake it.
|
|
|
|
|
2014-06-30 13:36:31 +00:00
|
|
|
enum GrGLStandard {
|
|
|
|
kNone_GrGLStandard,
|
|
|
|
kGL_GrGLStandard,
|
|
|
|
kGLES_GrGLStandard
|
|
|
|
};
|
2014-11-06 16:06:39 +00:00
|
|
|
static const int kGrGLStandardCnt = 3;
|
2014-06-30 13:36:31 +00:00
|
|
|
|
2015-02-03 02:26:03 +00:00
|
|
|
class GrContext {
|
|
|
|
public:
|
|
|
|
void dumpCacheStats(SkString*) const {}
|
|
|
|
void dumpGpuStats(SkString*) const {}
|
|
|
|
};
|
|
|
|
|
2016-03-31 01:56:19 +00:00
|
|
|
namespace sk_gpu_test {
|
2014-03-26 21:26:15 +00:00
|
|
|
class GrContextFactory {
|
|
|
|
public:
|
2015-05-27 20:23:23 +00:00
|
|
|
GrContextFactory() {};
|
|
|
|
explicit GrContextFactory(const GrContextOptions&) {}
|
|
|
|
|
2016-04-01 20:38:04 +00:00
|
|
|
typedef int ContextType;
|
|
|
|
|
|
|
|
static const ContextType kANGLE_ContextType = 0,
|
|
|
|
kANGLE_GL_ContextType = 0,
|
|
|
|
kCommandBuffer_ContextType = 0,
|
|
|
|
kDebugGL_ContextType = 0,
|
|
|
|
kMESA_ContextType = 0,
|
|
|
|
kNVPR_ContextType = 0,
|
|
|
|
kNativeGL_ContextType = 0,
|
|
|
|
kGL_ContextType = 0,
|
|
|
|
kGLES_ContextType = 0,
|
|
|
|
kNullGL_ContextType = 0;
|
|
|
|
static const int kContextTypeCnt = 1;
|
|
|
|
enum ContextOptions {
|
|
|
|
kNone_ContextOptions = 0,
|
|
|
|
kEnableNVPR_ContextOptions = 0x1,
|
2015-12-10 14:28:13 +00:00
|
|
|
};
|
2014-07-15 15:27:06 +00:00
|
|
|
void destroyContexts() {}
|
2014-07-28 20:48:36 +00:00
|
|
|
|
|
|
|
void abandonContexts() {}
|
2016-04-01 18:54:31 +00:00
|
|
|
|
|
|
|
void releaseResourcesAndAbandonContexts() {}
|
2014-03-26 21:26:15 +00:00
|
|
|
};
|
2016-03-31 01:56:19 +00:00
|
|
|
} // namespace sk_gpu_test
|
2014-03-26 21:26:15 +00:00
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
|
|
|
static const bool kGPUDisabled = true;
|
|
|
|
|
2016-03-31 01:56:19 +00:00
|
|
|
static inline SkSurface* NewGpuSurface(sk_gpu_test::GrContextFactory*,
|
2016-04-01 20:38:04 +00:00
|
|
|
sk_gpu_test::GrContextFactory::ContextType,
|
|
|
|
sk_gpu_test::GrContextFactory::ContextOptions,
|
2014-03-26 21:26:15 +00:00
|
|
|
SkImageInfo,
|
2014-11-07 15:12:46 +00:00
|
|
|
int,
|
|
|
|
bool) {
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2014-03-26 21:26:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DM
|
|
|
|
|
|
|
|
#endif//SK_SUPPORT_GPU
|
|
|
|
|
|
|
|
#endif//DMGpuSupport_DEFINED
|