aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-05-22 12:25:41 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-22 12:25:41 -0700
commitf28cff71db2cbb1ff18a8fbf1e80ca761d1f69bc (patch)
treeb91e0e301f518cd417afb870824e84aa16297a7d /src/gpu
parenta624d12b2d10cff79ba4b31744d81cc2e0a8db5f (diff)
Store context options on caps.
Diffstat (limited to 'src/gpu')
-rwxr-xr-xsrc/gpu/GrContext.cpp24
-rwxr-xr-xsrc/gpu/GrContextFactory.cpp2
-rw-r--r--src/gpu/GrContextFactory.h7
-rw-r--r--src/gpu/GrDrawTarget.cpp10
-rw-r--r--src/gpu/GrGpu.h2
-rw-r--r--src/gpu/GrGpuFactory.cpp7
-rw-r--r--src/gpu/GrGpuFactory.h3
-rw-r--r--src/gpu/GrSWMaskHelper.cpp2
-rw-r--r--src/gpu/GrTest.cpp10
-rw-r--r--src/gpu/gl/GrGLCaps.cpp4
-rw-r--r--src/gpu/gl/GrGLCaps.h3
-rw-r--r--src/gpu/gl/GrGLContext.cpp7
-rw-r--r--src/gpu/gl/GrGLContext.h5
-rw-r--r--src/gpu/gl/GrGLGpu.cpp7
-rw-r--r--src/gpu/gl/GrGLGpu.h3
-rw-r--r--src/gpu/gl/GrGLProgramDataManager.cpp2
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.cpp2
17 files changed, 62 insertions, 38 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f4ca6c480e..3ed0b6baa2 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -15,6 +15,7 @@
#include "GrBatchTarget.h"
#include "GrBatchTest.h"
#include "GrCaps.h"
+#include "GrContextOptions.h"
#include "GrDefaultGeoProcFactory.h"
#include "GrGpuResource.h"
#include "GrGpuResourcePriv.h"
@@ -70,16 +71,16 @@ private:
GrContext* fContext;
};
+GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) {
+ GrContextOptions defaultOptions;
+ return Create(backend, backendContext, defaultOptions);
+}
+
GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
- const Options* opts) {
- GrContext* context;
- if (NULL == opts) {
- context = SkNEW_ARGS(GrContext, (Options()));
- } else {
- context = SkNEW_ARGS(GrContext, (*opts));
- }
+ const GrContextOptions& options) {
+ GrContext* context = SkNEW(GrContext);
- if (context->init(backend, backendContext)) {
+ if (context->init(backend, backendContext, options)) {
return context;
} else {
context->unref();
@@ -96,7 +97,7 @@ static int32_t next_id() {
return id;
}
-GrContext::GrContext(const Options& opts) : fOptions(opts), fUniqueID(next_id()) {
+GrContext::GrContext() : fUniqueID(next_id()) {
fGpu = NULL;
fResourceCache = NULL;
fResourceProvider = NULL;
@@ -110,10 +111,11 @@ GrContext::GrContext(const Options& opts) : fOptions(opts), fUniqueID(next_id())
fMaxTextureSizeOverride = 1 << 20;
}
-bool GrContext::init(GrBackend backend, GrBackendContext backendContext) {
+bool GrContext::init(GrBackend backend, GrBackendContext backendContext,
+ const GrContextOptions& options) {
SkASSERT(NULL == fGpu);
- fGpu = GrGpu::Create(backend, backendContext, this);
+ fGpu = GrGpu::Create(backend, backendContext, options, this);
if (NULL == fGpu) {
return false;
}
diff --git a/src/gpu/GrContextFactory.cpp b/src/gpu/GrContextFactory.cpp
index 1a3864ac14..7df19177eb 100755
--- a/src/gpu/GrContextFactory.cpp
+++ b/src/gpu/GrContextFactory.cpp
@@ -75,7 +75,7 @@ GrContext* GrContextFactory::get(GLContextType type, GrGLStandard forcedGpuAPI)
glCtx->makeCurrent();
GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get());
- grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, &fGlobalOptions));
+ grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions));
if (!grCtx.get()) {
return NULL;
}
diff --git a/src/gpu/GrContextFactory.h b/src/gpu/GrContextFactory.h
index 353e3d9c96..7fd4b77ce0 100644
--- a/src/gpu/GrContextFactory.h
+++ b/src/gpu/GrContextFactory.h
@@ -9,6 +9,7 @@
#define GrContextFactory_DEFINED
#include "GrContext.h"
+#include "GrContextOptions.h"
#include "gl/SkGLContext.h"
#include "SkTArray.h"
@@ -80,7 +81,7 @@ public:
}
}
- explicit GrContextFactory(const GrContext::Options& opts) : fGlobalOptions(opts) { }
+ explicit GrContextFactory(const GrContextOptions& opts) : fGlobalOptions(opts) { }
GrContextFactory() { }
~GrContextFactory() { this->destroyContexts(); }
@@ -126,7 +127,7 @@ public:
return NULL;
}
- const GrContext::Options& getGlobalOptions() const { return fGlobalOptions; }
+ const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
private:
struct GPUContext {
@@ -135,7 +136,7 @@ private:
GrContext* fGrContext;
};
SkTArray<GPUContext, true> fContexts;
- const GrContext::Options fGlobalOptions;
+ const GrContextOptions fGlobalOptions;
};
#endif
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 2d5d0b8ee6..e5baaa7404 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -11,6 +11,7 @@
#include "GrBatch.h"
#include "GrCaps.h"
#include "GrContext.h"
+#include "GrContextOptions.h"
#include "GrPath.h"
#include "GrPipeline.h"
#include "GrMemoryPool.h"
@@ -68,8 +69,8 @@ bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil
drawBounds->roundOut(&drawIBounds);
if (!copyRect.intersect(drawIBounds)) {
#ifdef SK_DEBUG
- GrContextDebugf(fContext, "Missed an early reject. "
- "Bailing on draw from setupDstReadIfNecessary.\n");
+ GrCapsDebugf(fCaps, "Missed an early reject. "
+ "Bailing on draw from setupDstReadIfNecessary.\n");
#endif
return false;
}
@@ -598,7 +599,7 @@ SkString GrShaderCaps::dump() const {
///////////////////////////////////////////////////////////////////////////////
-GrCaps::GrCaps() {
+GrCaps::GrCaps(const GrContextOptions& options) {
fMipMapSupport = false;
fNPOTTextureTileSupport = false;
fTwoSidedStencilSupport = false;
@@ -621,6 +622,9 @@ GrCaps::GrCaps() {
memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport));
memset(fConfigTextureSupport, 0, sizeof(fConfigTextureSupport));
+
+ fSupressPrints = options.fSuppressPrints;
+ fDrawPathMasksToCompressedTextureSupport = options.fDrawPathToCompressedTexture;
}
static SkString map_flags_to_string(uint32_t flags) {
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 6e8dc43f75..5b5be1b69b 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -31,7 +31,7 @@ public:
* not supported (at compile-time or run-time) this returns NULL. The context will not be
* fully constructed and should not be used by GrGpu until after this function returns.
*/
- static GrGpu* Create(GrBackend, GrBackendContext, GrContext* context);
+ static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, GrContext* context);
////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrGpuFactory.cpp b/src/gpu/GrGpuFactory.cpp
index bd572e6860..3001a0d41a 100644
--- a/src/gpu/GrGpuFactory.cpp
+++ b/src/gpu/GrGpuFactory.cpp
@@ -20,10 +20,13 @@ GrGpuFactoryRegistrar::GrGpuFactoryRegistrar(int i, CreateGpuProc proc) {
gGpuFactories[i] = proc;
}
-GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrContext* context) {
+GrGpu* GrGpu::Create(GrBackend backend,
+ GrBackendContext backendContext,
+ const GrContextOptions& options,
+ GrContext* context) {
SkASSERT((int)backend < kMaxNumBackends);
if (!gGpuFactories[backend]) {
return NULL;
}
- return (gGpuFactories[backend])(backendContext, context);
+ return (gGpuFactories[backend])(backendContext, options, context);
}
diff --git a/src/gpu/GrGpuFactory.h b/src/gpu/GrGpuFactory.h
index 180f264d96..aecc2c1705 100644
--- a/src/gpu/GrGpuFactory.h
+++ b/src/gpu/GrGpuFactory.h
@@ -12,8 +12,9 @@
class GrGpu;
class GrContext;
+struct GrContextOptions;
-typedef GrGpu* (*CreateGpuProc)(GrBackendContext, GrContext*);
+typedef GrGpu* (*CreateGpuProc)(GrBackendContext, const GrContextOptions& options, GrContext*);
class GrGpuFactoryRegistrar {
public:
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index aa922ca170..25911866cb 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -174,7 +174,7 @@ bool GrSWMaskHelper::init(const SkIRect& resultBounds,
resultBounds.height());
if (allowCompression &&
- fContext->getOptions().fDrawPathToCompressedTexture &&
+ fContext->getGpu()->caps()->drawPathMasksToCompressedTexturesSupport() &&
choose_compressed_fmt(fContext->getGpu()->caps(), &fCompressedFormat)) {
fCompressionMode = kCompress_CompressionMode;
}
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index 0801d03a6c..8580661fd3 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -7,6 +7,7 @@
*/
#include "GrTest.h"
+#include "GrContextOptions.h"
#include "GrGpuResourceCacheAccess.h"
#include "GrInOrderDrawBuffer.h"
@@ -138,7 +139,9 @@ class GrPipeline;
class MockGpu : public GrGpu {
public:
- MockGpu(GrContext* context) : INHERITED(context) { fCaps.reset(SkNEW(GrCaps)); }
+ MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(context) {
+ fCaps.reset(SkNEW_ARGS(GrCaps, (options)));
+ }
~MockGpu() override {}
bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const override {
return true;
@@ -249,15 +252,16 @@ private:
};
GrContext* GrContext::CreateMockContext() {
- GrContext* context = SkNEW_ARGS(GrContext, (Options()));
+ GrContext* context = SkNEW(GrContext);
context->initMockContext();
return context;
}
void GrContext::initMockContext() {
+ GrContextOptions options;
SkASSERT(NULL == fGpu);
- fGpu = SkNEW_ARGS(MockGpu, (this));
+ fGpu = SkNEW_ARGS(MockGpu, (this, options));
SkASSERT(fGpu);
this->initCommon();
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 2a97137f12..6f272b7b8e 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -12,7 +12,9 @@
#include "SkTSearch.h"
#include "SkTSort.h"
-GrGLCaps::GrGLCaps(const GrGLContextInfo& ctxInfo, const GrGLInterface* glInterface) {
+GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
+ const GrGLContextInfo& ctxInfo,
+ const GrGLInterface* glInterface) : INHERITED(contextOptions) {
fVerifiedColorConfigs.reset();
fStencilFormats.reset();
fStencilVerifiedColorConfigs.reset();
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index cd84242292..9d38c82ced 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -91,7 +91,8 @@ public:
* Initializes the GrGLCaps to the set of features supported in the current
* OpenGL context accessible via ctxInfo.
*/
- GrGLCaps(const GrGLContextInfo& ctxInfo, const GrGLInterface* glInterface);
+ GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo,
+ const GrGLInterface* glInterface);
/**
* Call to note that a color config has been verified as a valid color
diff --git a/src/gpu/gl/GrGLContext.cpp b/src/gpu/gl/GrGLContext.cpp
index 8115687093..335986508d 100644
--- a/src/gpu/gl/GrGLContext.cpp
+++ b/src/gpu/gl/GrGLContext.cpp
@@ -9,7 +9,7 @@
////////////////////////////////////////////////////////////////////////////////
-GrGLContext* GrGLContext::Create(const GrGLInterface* interface) {
+GrGLContext* GrGLContext::Create(const GrGLInterface* interface, const GrContextOptions& options) {
// We haven't validated the GrGLInterface yet, so check for GetString function pointer
if (!interface->fFunctions.fGetString) {
return NULL;
@@ -55,6 +55,9 @@ GrGLContext* GrGLContext::Create(const GrGLInterface* interface) {
args.fIsMesa = GrGLIsMesaFromVersionString(ver);
args.fIsChromium = GrGLIsChromiumFromRendererString(renderer);
+
+ args.fContextOptions = &options;
+
return SkNEW_ARGS(GrGLContext, (args));
}
@@ -67,5 +70,5 @@ GrGLContextInfo::GrGLContextInfo(const ConstructorArgs& args) {
fIsMesa = args.fIsMesa;
fIsChromium = args.fIsChromium;
- fGLCaps.reset(SkNEW_ARGS(GrGLCaps, (*this, fInterface)));
+ fGLCaps.reset(SkNEW_ARGS(GrGLCaps, (*args.fContextOptions, *this, fInterface)));
}
diff --git a/src/gpu/gl/GrGLContext.h b/src/gpu/gl/GrGLContext.h
index e84c8ecffc..50262cf44a 100644
--- a/src/gpu/gl/GrGLContext.h
+++ b/src/gpu/gl/GrGLContext.h
@@ -15,7 +15,7 @@
#include "GrGLSL.h"
#include "GrGLUtil.h"
-#include "SkString.h"
+struct GrContextOptions;
/**
* Encapsulates information about an OpenGL context including the OpenGL
@@ -51,6 +51,7 @@ protected:
GrGLRenderer fRenderer;
bool fIsMesa;
bool fIsChromium;
+ const GrContextOptions* fContextOptions;
};
GrGLContextInfo(const ConstructorArgs& args);
@@ -74,7 +75,7 @@ public:
* Creates a GrGLContext from a GrGLInterface and the currently
* bound OpenGL context accessible by the GrGLInterface.
*/
- static GrGLContext* Create(const GrGLInterface* interface);
+ static GrGLContext* Create(const GrGLInterface* interface, const GrContextOptions& options);
const GrGLInterface* interface() const { return fInterface; }
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 07aaaae26b..3a3b833a8f 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -157,7 +157,8 @@ bool GrGLGpu::BlendCoeffReferencesConstant(GrBlendCoeff coeff) {
///////////////////////////////////////////////////////////////////////////////
-GrGpu* GrGLGpu::Create(GrBackendContext backendContext, GrContext* context) {
+GrGpu* GrGLGpu::Create(GrBackendContext backendContext, const GrContextOptions& options,
+ GrContext* context) {
SkAutoTUnref<const GrGLInterface> glInterface(
reinterpret_cast<const GrGLInterface*>(backendContext));
if (!glInterface) {
@@ -168,7 +169,7 @@ GrGpu* GrGLGpu::Create(GrBackendContext backendContext, GrContext* context) {
if (!glInterface) {
return NULL;
}
- GrGLContext* glContext = GrGLContext::Create(glInterface);
+ GrGLContext* glContext = GrGLContext::Create(glInterface, options);
if (glContext) {
return SkNEW_ARGS(GrGLGpu, (glContext, context));
}
@@ -1436,7 +1437,7 @@ bool GrGLGpu::flushGLState(const DrawArgs& args) {
fCurrentProgram.reset(fProgramCache->getProgram(args));
if (NULL == fCurrentProgram.get()) {
- GrContextDebugf(this->getContext(), "Failed to create program!\n");
+ GrCapsDebugf(this->caps(), "Failed to create program!\n");
return false;
}
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index d7b11026f5..c777f7792a 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -32,7 +32,8 @@ class GrNonInstancedVertices;
class GrGLGpu : public GrGpu {
public:
- static GrGpu* Create(GrBackendContext backendContext, GrContext* context);
+ static GrGpu* Create(GrBackendContext backendContext, const GrContextOptions& options,
+ GrContext* context);
~GrGLGpu() override;
void contextAbandoned() override;
diff --git a/src/gpu/gl/GrGLProgramDataManager.cpp b/src/gpu/gl/GrGLProgramDataManager.cpp
index ef2f59e664..ce2598e246 100644
--- a/src/gpu/gl/GrGLProgramDataManager.cpp
+++ b/src/gpu/gl/GrGLProgramDataManager.cpp
@@ -261,7 +261,7 @@ void GrGLProgramDataManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix
#ifdef SK_DEBUG
void GrGLProgramDataManager::printUnused(const Uniform& uni) const {
if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation) {
- GrContextDebugf(fGpu->getContext(), "Unused uniform in shader\n");
+ GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n");
}
}
#endif
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 28e1fba20c..a3b0d686a4 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -207,7 +207,7 @@ bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
totalTextures += processor->numTextures();
if (totalTextures >= maxTextureUnits) {
- GrContextDebugf(fGpu->getContext(), "Program would use too many texture units\n");
+ GrCapsDebugf(fGpu->caps(), "Program would use too many texture units\n");
return false;
}
}