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;
|
|
|
|
|
|
|
|
static inline SkSurface* NewGpuSurface(GrContextFactory* grFactory,
|
|
|
|
GrContextFactory::GLContextType type,
|
2015-12-10 14:28:13 +00:00
|
|
|
GrContextFactory::GLContextOptions options,
|
2014-03-26 21:26:15 +00:00
|
|
|
SkImageInfo info,
|
2014-11-07 15:12:46 +00:00
|
|
|
int samples,
|
2015-08-31 19:39:41 +00:00
|
|
|
bool useDIText) {
|
|
|
|
uint32_t flags = useDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0;
|
2014-11-07 15:12:46 +00:00
|
|
|
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
|
2016-02-25 16:33:02 +00:00
|
|
|
return SkSurface::NewRenderTarget(grFactory->get(type, options), SkBudgeted::kNo,
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
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 {}
|
|
|
|
};
|
|
|
|
|
2014-03-26 21:26:15 +00:00
|
|
|
class GrContextFactory {
|
|
|
|
public:
|
2015-05-27 20:23:23 +00:00
|
|
|
GrContextFactory() {};
|
|
|
|
explicit GrContextFactory(const GrContextOptions&) {}
|
|
|
|
|
2014-03-26 21:26:15 +00:00
|
|
|
typedef int GLContextType;
|
|
|
|
|
2015-08-27 17:38:39 +00:00
|
|
|
static const GLContextType kANGLE_GLContextType = 0,
|
2015-09-11 20:07:29 +00:00
|
|
|
kANGLE_GL_GLContextType = 0,
|
2016-03-03 15:39:48 +00:00
|
|
|
kCommandBuffer_GLContextType = 0,
|
2015-08-27 17:38:39 +00:00
|
|
|
kDebug_GLContextType = 0,
|
|
|
|
kMESA_GLContextType = 0,
|
|
|
|
kNVPR_GLContextType = 0,
|
|
|
|
kNative_GLContextType = 0,
|
|
|
|
kNull_GLContextType = 0;
|
2014-11-06 16:06:39 +00:00
|
|
|
static const int kGLContextTypeCnt = 1;
|
2015-12-10 14:28:13 +00:00
|
|
|
enum GLContextOptions {
|
|
|
|
kNone_GLContextOptions = 0,
|
|
|
|
kEnableNVPR_GLContextOptions = 0x1,
|
|
|
|
};
|
2014-07-15 15:27:06 +00:00
|
|
|
void destroyContexts() {}
|
2014-07-28 20:48:36 +00:00
|
|
|
|
|
|
|
void abandonContexts() {}
|
2014-03-26 21:26:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
|
|
|
static const bool kGPUDisabled = true;
|
|
|
|
|
|
|
|
static inline SkSurface* NewGpuSurface(GrContextFactory*,
|
|
|
|
GrContextFactory::GLContextType,
|
2015-12-10 14:28:13 +00:00
|
|
|
GrContextFactory::GLContextOptions,
|
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
|