skia2/dm/DMGpuSupport.h
borenet 9d66696f6b Revert of Make NVPR a GL context option instead of a GL context (patchset #9 id:160001 of https://codereview.chromium.org/1448883002/ )
Reason for revert:
"Could not create surface" on Linux GTX660 bots

Original issue's description:
> Make NVPR a GL context option instead of a GL context
>
> Make NVPR a GL context option instead of a GL context.
> This may enable NVPR to be run with command buffer
> interface.
>
> No functionality change in DM or nanobench. NVPR can
> only be run with normal GL APIs.
>
> BUG=skia:2992
>
> Committed: https://skia.googlesource.com/skia/+/eeebdb538d476c1bfc8b63a946094ca1b505ecd1
>
> Committed: https://skia.googlesource.com/skia/+/64492c43c3faee7ab0f69b1c84e0267616f85e52

TBR=mtklein@google.com,bsalomon@google.com,jvanverth@google.com,scroggo@google.com,kkinnunen@nvidia.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:2992

Review URL: https://codereview.chromium.org/1513703002
2015-12-09 07:03:51 -08:00

101 lines
2.9 KiB
C++

/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#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"
// 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"
#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,
GrGLStandard gpuAPI,
SkImageInfo info,
int samples,
bool useDIText) {
uint32_t flags = useDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0;
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
return SkSurface::NewRenderTarget(grFactory->get(type, gpuAPI), SkSurface::kNo_Budgeted,
info, samples, &props);
}
} // namespace DM
#else// !SK_SUPPORT_GPU
// Ganesh is not available. Fake it.
enum GrGLStandard {
kNone_GrGLStandard,
kGL_GrGLStandard,
kGLES_GrGLStandard
};
static const int kGrGLStandardCnt = 3;
class GrContext {
public:
void dumpCacheStats(SkString*) const {}
void dumpGpuStats(SkString*) const {}
};
class GrContextFactory {
public:
GrContextFactory() {};
explicit GrContextFactory(const GrContextOptions&) {}
typedef int GLContextType;
static const GLContextType kANGLE_GLContextType = 0,
kANGLE_GL_GLContextType = 0,
kCommandBuffer_GLContextType = 0,
kDebug_GLContextType = 0,
kMESA_GLContextType = 0,
kNVPR_GLContextType = 0,
kNative_GLContextType = 0,
kNull_GLContextType = 0;
static const int kGLContextTypeCnt = 1;
void destroyContexts() {}
void abandonContexts() {}
};
namespace DM {
static const bool kGPUDisabled = true;
static inline SkSurface* NewGpuSurface(GrContextFactory*,
GrContextFactory::GLContextType,
GrGLStandard,
SkImageInfo,
int,
bool) {
return nullptr;
}
} // namespace DM
#endif//SK_SUPPORT_GPU
#endif//DMGpuSupport_DEFINED