aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrGpuFactory.cpp6
-rw-r--r--src/gpu/gl/GrGLCaps.cpp17
-rw-r--r--src/gpu/gl/GrGLCaps.h4
-rw-r--r--src/gpu/gl/GrGLContext.cpp (renamed from src/gpu/gl/GrGLContextInfo.cpp)101
-rw-r--r--src/gpu/gl/GrGLContext.h (renamed from src/gpu/gl/GrGLContextInfo.h)88
-rw-r--r--src/gpu/gl/GrGLProgram.cpp34
-rw-r--r--src/gpu/gl/GrGLProgram.h8
-rw-r--r--src/gpu/gl/GrGLShaderBuilder.cpp19
-rw-r--r--src/gpu/gl/GrGLShaderBuilder.h2
-rw-r--r--src/gpu/gl/GrGLShaderVar.h8
-rw-r--r--src/gpu/gl/GrGLUniformManager.h6
-rw-r--r--src/gpu/gl/GrGpuGL.cpp40
-rw-r--r--src/gpu/gl/GrGpuGL.h30
-rw-r--r--src/gpu/gl/GrGpuGL_program.cpp2
-rw-r--r--src/gpu/gl/SkGLContextHelper.cpp (renamed from src/gpu/gl/SkGLContext.cpp)12
-rw-r--r--src/gpu/gl/debug/GrGLCreateDebugInterface.cpp2
16 files changed, 206 insertions, 173 deletions
diff --git a/src/gpu/GrGpuFactory.cpp b/src/gpu/GrGpuFactory.cpp
index a5114469ae..a3c8eba452 100644
--- a/src/gpu/GrGpuFactory.cpp
+++ b/src/gpu/GrGpuFactory.cpp
@@ -34,9 +34,9 @@ GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrConte
#endif
return NULL;
}
- GrGLContextInfo ctxInfo(glInterface);
- if (ctxInfo.isInitialized()) {
- return SkNEW_ARGS(GrGpuGL, (ctxInfo, context));
+ GrGLContext ctx(glInterface);
+ if (ctx.isInitialized()) {
+ return SkNEW_ARGS(GrGpuGL, (ctx, context));
}
}
return NULL;
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 1276a65a19..d62a310fc6 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -7,7 +7,7 @@
#include "GrGLCaps.h"
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
#include "SkTSearch.h"
GrGLCaps::GrGLCaps() {
@@ -73,14 +73,13 @@ GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) {
return *this;
}
-void GrGLCaps::init(const GrGLContextInfo& ctxInfo) {
+void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
this->reset();
if (!ctxInfo.isInitialized()) {
return;
}
- const GrGLInterface* gli = ctxInfo.interface();
GrGLBinding binding = ctxInfo.binding();
GrGLVersion version = ctxInfo.version();
@@ -178,7 +177,7 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo) {
fUseNonVBOVertexAndIndexDynamicData = true;
}
- this->initFSAASupport(ctxInfo);
+ this->initFSAASupport(ctxInfo, gli);
this->initStencilFormats(ctxInfo);
}
@@ -227,7 +226,7 @@ int coverage_mode_compare(const GrGLCaps::MSAACoverageMode* left,
}
}
-void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo) {
+void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
fMSFBOType = kNone_MSFBOType;
if (kDesktop_GrGLBinding != ctxInfo.binding()) {
@@ -253,11 +252,11 @@ void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo) {
if (ctxInfo.hasExtension("GL_NV_framebuffer_multisample_coverage")) {
fCoverageAAType = kNVDesktop_CoverageAAType;
GrGLint count;
- GR_GL_GetIntegerv(ctxInfo.interface(),
+ GR_GL_GetIntegerv(gli,
GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES,
&count);
fMSAACoverageModes.setCount(count);
- GR_GL_GetIntegerv(ctxInfo.interface(),
+ GR_GL_GetIntegerv(gli,
GR_GL_MULTISAMPLE_COVERAGE_MODES,
(int*)&fMSAACoverageModes[0]);
// The NV driver seems to return the modes already sorted but the
@@ -269,9 +268,7 @@ void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo) {
}
}
if (kNone_MSFBOType != fMSFBOType) {
- GR_GL_GetIntegerv(ctxInfo.interface(),
- GR_GL_MAX_SAMPLES,
- &fMaxSampleCount);
+ GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount);
}
}
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 4143868ed8..48ceb33637 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -95,7 +95,7 @@ public:
* Initializes the GrGLCaps to the set of features supported in the current
* OpenGL context accessible via ctxInfo.
*/
- void init(const GrGLContextInfo& ctxInfo);
+ void init(const GrGLContextInfo& ctxInfo, const GrGLInterface* interface);
/**
* Call to note that a color config has been verified as a valid color
@@ -267,7 +267,7 @@ private:
}
};
- void initFSAASupport(const GrGLContextInfo& ctxInfo);
+ void initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli);
void initStencilFormats(const GrGLContextInfo& ctxInfo);
// tracks configs that have been verified to pass the FBO completeness when
diff --git a/src/gpu/gl/GrGLContextInfo.cpp b/src/gpu/gl/GrGLContext.cpp
index 1522618d03..ba4196de8e 100644
--- a/src/gpu/gl/GrGLContextInfo.cpp
+++ b/src/gpu/gl/GrGLContext.cpp
@@ -1,51 +1,23 @@
/*
- * Copyright 2012 Google Inc.
+ * Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
-GrGLContextInfo::~GrGLContextInfo() {
- GrSafeUnref(fInterface);
-}
-
-GrGLContextInfo::GrGLContextInfo() {
- this->reset();
-}
-
-GrGLContextInfo::GrGLContextInfo(const GrGLInterface* interface) {
- fInterface = NULL;
- this->initialize(interface);
-}
-
-GrGLContextInfo::GrGLContextInfo(const GrGLContextInfo& ctx) {
- fInterface = NULL;
- *this = ctx;
-}
-
-GrGLContextInfo& GrGLContextInfo::operator = (const GrGLContextInfo& ctx) {
- GrSafeAssign(fInterface, ctx.fInterface);
- fBindingInUse = ctx.fBindingInUse;
- fGLVersion = ctx.fGLVersion;
- fGLSLGeneration = ctx.fGLSLGeneration;
- fVendor = ctx.fVendor;
- fExtensions = ctx.fExtensions;
- fGLCaps = ctx.fGLCaps;
+////////////////////////////////////////////////////////////////////////////////
+GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& ctxInfo) {
+ fBindingInUse = ctxInfo.fBindingInUse;
+ fGLVersion = ctxInfo.fGLVersion;
+ fGLSLGeneration = ctxInfo.fGLSLGeneration;
+ fVendor = ctxInfo.fVendor;
+ fExtensions = ctxInfo.fExtensions;
+ fGLCaps = ctxInfo.fGLCaps;
return *this;
}
-
-void GrGLContextInfo::reset() {
- GrSafeSetNull(fInterface);
- fBindingInUse = kNone_GrGLBinding;
- fGLVersion = GR_GL_VER(0, 0);
- fGLSLGeneration = static_cast<GrGLSLGeneration>(0);
- fVendor = kOther_GrGLVendor;
- fExtensions.reset();
- fGLCaps.reset();
-}
-
+
bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
this->reset();
// We haven't validated the GrGLInterface yet, so check for GetString
@@ -57,19 +29,14 @@ bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
GrGLBinding binding = GrGLGetBindingInUseFromString(ver);
if (0 != binding && interface->validate(binding) && fExtensions.init(binding, interface)) {
-
- fInterface = interface;
- interface->ref();
-
fBindingInUse = binding;
fGLVersion = GrGLGetVersionFromString(ver);
- fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse,
- this->interface());
+ fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface);
fVendor = GrGLGetVendor(interface);
- fGLCaps.init(*this);
+ fGLCaps.init(*this, interface);
return true;
}
}
@@ -77,5 +44,45 @@ bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
}
bool GrGLContextInfo::isInitialized() const {
- return kNone_GrGLBinding != fBindingInUse;
+ return kNone_GrGLBinding != fBindingInUse;
+}
+
+void GrGLContextInfo::reset() {
+ fBindingInUse = kNone_GrGLBinding;
+ fGLVersion = GR_GL_VER(0, 0);
+ fGLSLGeneration = static_cast<GrGLSLGeneration>(0);
+ fVendor = kOther_GrGLVendor;
+ fExtensions.reset();
+ fGLCaps.reset();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+GrGLContext::GrGLContext(const GrGLInterface* interface) {
+ fInterface = NULL;
+ this->initialize(interface);
+}
+
+GrGLContext::GrGLContext(const GrGLContext& ctx) {
+ fInterface = NULL;
+ *this = ctx;
+}
+
+GrGLContext& GrGLContext::operator = (const GrGLContext& ctx) {
+ GrSafeAssign(fInterface, ctx.fInterface);
+ fInfo = ctx.fInfo;
+ return *this;
+}
+
+void GrGLContext::reset() {
+ GrSafeSetNull(fInterface);
+ fInfo.reset();
+}
+
+bool GrGLContext::initialize(const GrGLInterface* interface) {
+ if (fInfo.initialize(interface)) {
+ fInterface = interface;
+ interface->ref();
+ return true;
+ }
+ return false;
}
diff --git a/src/gpu/gl/GrGLContextInfo.h b/src/gpu/gl/GrGLContext.h
index bfadabe87f..05647cc9fa 100644
--- a/src/gpu/gl/GrGLContextInfo.h
+++ b/src/gpu/gl/GrGLContext.h
@@ -1,13 +1,13 @@
/*
- * Copyright 2012 Google Inc.
+ * Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef GrGLContextInfo_DEFINED
-#define GrGLContextInfo_DEFINED
+#ifndef GrGLContext_DEFINED
+#define GrGLContext_DEFINED
#include "gl/GrGLExtensions.h"
#include "gl/GrGLInterface.h"
@@ -18,36 +18,21 @@
#include "SkString.h"
/**
- * Encapsulates information about an OpenGL context including the GrGLInterface
- * used to make GL calls, the OpenGL version, the GrGLBinding type of the
- * context, and GLSL version.
+ * Encapsulates information about an OpenGL context including the OpenGL
+ * version, the GrGLBinding type of the context, and GLSL version.
*/
class GrGLContextInfo {
public:
-
- /**
- * Default constructor, creates an uninitialized GrGLContextInfo
- */
- GrGLContextInfo();
-
- /**
- * Creates a GrGLContextInfo from a GrGLInterface and the currently
- * bound OpenGL context accessible by the GrGLInterface.
- */
- explicit GrGLContextInfo(const GrGLInterface* interface);
-
/**
- * Copies a GrGLContextInfo
+ * Default constructor
*/
- GrGLContextInfo(const GrGLContextInfo& ctx);
-
- ~GrGLContextInfo();
+ GrGLContextInfo() { this->reset(); }
/**
* Copies a GrGLContextInfo
*/
- GrGLContextInfo& operator = (const GrGLContextInfo& ctx);
-
+ GrGLContextInfo& operator= (const GrGLContextInfo& ctxInfo);
+
/**
* Initializes a GrGLContextInfo from a GrGLInterface and the currently
* bound OpenGL context accessible by the GrGLInterface.
@@ -55,7 +40,6 @@ public:
bool initialize(const GrGLInterface* interface);
bool isInitialized() const;
- const GrGLInterface* interface() const { return fInterface; }
GrGLBinding binding() const { return fBindingInUse; }
GrGLVersion version() const { return fGLVersion; }
GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; }
@@ -74,10 +58,13 @@ public:
return fExtensions.has(ext);
}
-private:
+ /**
+ * Reset the information
+ */
void reset();
- const GrGLInterface* fInterface;
+private:
+
GrGLBinding fBindingInUse;
GrGLVersion fGLVersion;
GrGLSLGeneration fGLSLGeneration;
@@ -86,4 +73,51 @@ private:
GrGLCaps fGLCaps;
};
+/**
+ * Encapsulates the GrGLInterface used to make GL calls plus information
+ * about the context (via GrGLContextInfo).
+ */
+class GrGLContext {
+public:
+ /**
+ * Default constructor
+ */
+ GrGLContext() { this->reset(); }
+
+ /**
+ * Creates a GrGLContext from a GrGLInterface and the currently
+ * bound OpenGL context accessible by the GrGLInterface.
+ */
+ explicit GrGLContext(const GrGLInterface* interface);
+
+ /**
+ * Copies a GrGLContext
+ */
+ GrGLContext(const GrGLContext& ctx);
+
+ ~GrGLContext() { GrSafeUnref(fInterface); }
+
+ /**
+ * Copies a GrGLContext
+ */
+ GrGLContext& operator= (const GrGLContext& ctx);
+
+ /**
+ * Initializes a GrGLContext from a GrGLInterface and the currently
+ * bound OpenGL context accessible by the GrGLInterface.
+ */
+ bool initialize(const GrGLInterface* interface);
+ bool isInitialized() const { return fInfo.isInitialized(); }
+
+ const GrGLInterface* interface() const { return fInterface; }
+ const GrGLContextInfo& info() const { return fInfo; }
+ GrGLContextInfo& info() { return fInfo; }
+
+private:
+ void reset();
+
+ const GrGLInterface* fInterface;
+ GrGLContextInfo fInfo;
+};
+
#endif
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index eb493257f3..781e15fdde 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -20,8 +20,8 @@
SK_DEFINE_INST_COUNT(GrGLProgram)
-#define GL_CALL(X) GR_GL_CALL(fContextInfo.interface(), X)
-#define GL_CALL_RET(R, X) GR_GL_CALL_RET(fContextInfo.interface(), R, X)
+#define GL_CALL(X) GR_GL_CALL(fContext.interface(), X)
+#define GL_CALL_RET(R, X) GR_GL_CALL_RET(fContext.interface(), R, X)
SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false, "Print the source code for all shaders generated.");
@@ -229,7 +229,7 @@ void GrGLProgram::BuildDesc(const GrDrawState& drawState,
#endif
}
-GrGLProgram* GrGLProgram::Create(const GrGLContextInfo& gl,
+GrGLProgram* GrGLProgram::Create(const GrGLContext& gl,
const Desc& desc,
const GrEffectStage* stages[]) {
GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gl, desc, stages));
@@ -240,10 +240,10 @@ GrGLProgram* GrGLProgram::Create(const GrGLContextInfo& gl,
return program;
}
-GrGLProgram::GrGLProgram(const GrGLContextInfo& gl,
+GrGLProgram::GrGLProgram(const GrGLContext& gl,
const Desc& desc,
const GrEffectStage* stages[])
-: fContextInfo(gl)
+: fContext(gl)
, fUniformManager(gl) {
fDesc = desc;
fVShaderID = 0;
@@ -438,7 +438,7 @@ bool GrGLProgram::genEdgeCoverage(SkString* coverageVar,
builder->fFSCode.appendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName, fsName);
builder->fFSCode.append("\t\tedgeAlpha = clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0);\n"
"\t}\n");
- if (kES2_GrGLBinding == fContextInfo.binding()) {
+ if (kES2_GrGLBinding == fContext.info().binding()) {
builder->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n");
}
break;
@@ -451,7 +451,7 @@ bool GrGLProgram::genEdgeCoverage(SkString* coverageVar,
builder->fFSCode.appendf("\tfloat edgeAlpha = (%s.x*%s.x - %s.y);\n", fsName, fsName, fsName);
builder->fFSCode.append("\tedgeAlpha = sqrt(edgeAlpha*edgeAlpha / dot(gF, gF));\n");
builder->fFSCode.append("\tedgeAlpha = max(1.0 - edgeAlpha, 0.0);\n");
- if (kES2_GrGLBinding == fContextInfo.binding()) {
+ if (kES2_GrGLBinding == fContext.info().binding()) {
builder->fHeader.printf("#extension GL_OES_standard_derivatives: enable\n");
}
break;
@@ -548,7 +548,7 @@ void gen_attribute_coverage(GrGLShaderBuilder* segments,
void GrGLProgram::genGeometryShader(GrGLShaderBuilder* segments) const {
#if GR_GL_EXPERIMENTAL_GS
if (fDesc.fExperimentalGS) {
- GrAssert(fContextInfo.glslGeneration() >= k150_GrGLSLGeneration);
+ GrAssert(fContext.info().glslGeneration() >= k150_GrGLSLGeneration);
segments->fGSHeader.append("layout(triangles) in;\n"
"layout(triangle_strip, max_vertices = 6) out;\n");
segments->fGSCode.append("\tfor (int i = 0; i < 3; ++i) {\n"
@@ -597,7 +597,7 @@ void print_shader(GrGLint stringCnt,
}
// Compiles a GL shader, returns shader ID or 0 if failed params have same meaning as glShaderSource
-GrGLuint compile_shader(const GrGLContextInfo& gl,
+GrGLuint compile_shader(const GrGLContext& gl,
GrGLenum type,
int stringCnt,
const char** strings,
@@ -638,7 +638,7 @@ GrGLuint compile_shader(const GrGLContextInfo& gl,
}
// helper version of above for when shader is already flattened into a single SkString
-GrGLuint compile_shader(const GrGLContextInfo& gl, GrGLenum type, const SkString& shader) {
+GrGLuint compile_shader(const GrGLContext& gl, GrGLenum type, const SkString& shader) {
const GrGLchar* str = shader.c_str();
int length = shader.size();
return compile_shader(gl, type, 1, &str, &length);
@@ -657,7 +657,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) {
GrPrintf("\n");
}
- if (!(fVShaderID = compile_shader(fContextInfo, GR_GL_VERTEX_SHADER, shader))) {
+ if (!(fVShaderID = compile_shader(fContext, GR_GL_VERTEX_SHADER, shader))) {
return false;
}
@@ -667,7 +667,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) {
GrPrintf(shader.c_str());
GrPrintf("\n");
}
- if (!(fGShaderID = compile_shader(fContextInfo, GR_GL_GEOMETRY_SHADER, shader))) {
+ if (!(fGShaderID = compile_shader(fContext, GR_GL_GEOMETRY_SHADER, shader))) {
return false;
}
} else {
@@ -679,7 +679,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) {
GrPrintf(shader.c_str());
GrPrintf("\n");
}
- if (!(fFShaderID = compile_shader(fContextInfo, GR_GL_FRAGMENT_SHADER, shader))) {
+ if (!(fFShaderID = compile_shader(fContext, GR_GL_FRAGMENT_SHADER, shader))) {
return false;
}
@@ -689,7 +689,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) {
bool GrGLProgram::genProgram(const GrEffectStage* stages[]) {
GrAssert(0 == fProgramID);
- GrGLShaderBuilder builder(fContextInfo, fUniformManager);
+ GrGLShaderBuilder builder(fContext.info(), fUniformManager);
const GrAttribBindings& attribBindings = fDesc.fAttribBindings;
#if GR_GL_EXPERIMENTAL_GS
@@ -738,11 +738,11 @@ bool GrGLProgram::genProgram(const GrEffectStage* stages[]) {
// the dual source output has no canonical var name, have to
// declare an output, which is incompatible with gl_FragColor/gl_FragData.
bool dualSourceOutputWritten = false;
- builder.fHeader.append(GrGetGLSLVersionDecl(fContextInfo.binding(),
- fContextInfo.glslGeneration()));
+ builder.fHeader.append(GrGetGLSLVersionDecl(fContext.info().binding(),
+ fContext.info().glslGeneration()));
GrGLShaderVar colorOutput;
- bool isColorDeclared = GrGLSLSetupFSColorOuput(fContextInfo.glslGeneration(),
+ bool isColorDeclared = GrGLSLSetupFSColorOuput(fContext.info().glslGeneration(),
declared_color_output_name(),
&colorOutput);
if (isColorDeclared) {
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index ea39fa8e53..cde918b54b 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -11,7 +11,7 @@
#include "GrDrawState.h"
#include "GrGLEffect.h"
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
#include "GrGLSL.h"
#include "GrGLTexture.h"
#include "GrGLUniformManager.h"
@@ -55,7 +55,7 @@ public:
const GrGpuGL* gpu,
Desc* outDesc);
- static GrGLProgram* Create(const GrGLContextInfo& gl,
+ static GrGLProgram* Create(const GrGLContext& gl,
const Desc& desc,
const GrEffectStage* stages[]);
@@ -206,7 +206,7 @@ public:
static const AttribLayout kAttribLayouts[kGrVertexAttribTypeCount];
private:
- GrGLProgram(const GrGLContextInfo& gl,
+ GrGLProgram(const GrGLContext& gl,
const Desc& desc,
const GrEffectStage* stages[]);
@@ -290,7 +290,7 @@ private:
GrGLEffect* fEffects[GrDrawState::kNumStages];
Desc fDesc;
- const GrGLContextInfo& fContextInfo;
+ const GrGLContext& fContext;
GrGLUniformManager fUniformManager;
UniformHandles fUniformHandles;
diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp
index 1618fe5416..aa3505cba5 100644
--- a/src/gpu/gl/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/GrGLShaderBuilder.cpp
@@ -81,7 +81,8 @@ void append_swizzle(SkString* outAppend,
// varying by stage, if we use 1D textures for gradients!
//const int GrGLShaderBuilder::fCoordDims = 2;
-GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctx, GrGLUniformManager& uniformManager)
+GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo,
+ GrGLUniformManager& uniformManager)
: fUniforms(kVarsPerBlock)
, fVSAttrs(kVarsPerBlock)
, fVSOutputs(kVarsPerBlock)
@@ -90,7 +91,7 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctx, GrGLUniformMana
, fFSInputs(kVarsPerBlock)
, fFSOutputs(kMaxFSOutputs)
, fUsesGS(false)
- , fContext(ctx)
+ , fCtxInfo(ctxInfo)
, fUniformManager(uniformManager)
, fCurrentStageIdx(kNonStageIdx)
, fSetupFragPosition(false)
@@ -111,7 +112,7 @@ void GrGLShaderBuilder::appendTextureLookup(SkString* out,
sample_function_name(varyingType),
this->getUniformCStr(sampler.fSamplerUniform),
coordName);
- append_swizzle(out, *sampler.textureAccess(), fContext.caps());
+ append_swizzle(out, *sampler.textureAccess(), fCtxInfo.caps());
}
void GrGLShaderBuilder::appendTextureLookupAndModulate(
@@ -261,7 +262,7 @@ void GrGLShaderBuilder::addVarying(GrSLType type,
const char* GrGLShaderBuilder::fragmentPosition() {
#if 1
- if (fContext.caps().fragCoordConventionsSupport()) {
+ if (fCtxInfo.caps().fragCoordConventionsSupport()) {
if (!fSetupFragPosition) {
fFSHeader.append("#extension GL_ARB_fragment_coord_conventions: require\n");
fFSInputs.push_back().set(kVec4f_GrSLType,
@@ -327,7 +328,7 @@ void GrGLShaderBuilder::emitFunction(ShaderType shader,
fFSFunctions.append(*outName);
fFSFunctions.append("(");
for (int i = 0; i < argCnt; ++i) {
- args[i].appendDecl(fContext, &fFSFunctions);
+ args[i].appendDecl(fCtxInfo, &fFSFunctions);
if (i < argCnt - 1) {
fFSFunctions.append(", ");
}
@@ -365,7 +366,7 @@ inline void append_default_precision_qualifier(GrGLShaderVar::Precision p,
void GrGLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const {
for (int i = 0; i < vars.count(); ++i) {
- vars[i].appendDecl(fContext, out);
+ vars[i].appendDecl(fCtxInfo, out);
out->append(";\n");
}
}
@@ -373,7 +374,7 @@ void GrGLShaderBuilder::appendDecls(const VarArray& vars, SkString* out) const {
void GrGLShaderBuilder::appendUniformDecls(ShaderType stype, SkString* out) const {
for (int i = 0; i < fUniforms.count(); ++i) {
if (fUniforms[i].fVisibility & stype) {
- fUniforms[i].fVariable.appendDecl(fContext, out);
+ fUniforms[i].fVariable.appendDecl(fCtxInfo, out);
out->append(";\n");
}
}
@@ -406,13 +407,13 @@ void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const {
case kFragment_ShaderType:
*shaderStr = fHeader;
append_default_precision_qualifier(kDefaultFragmentPrecision,
- fContext.binding(),
+ fCtxInfo.binding(),
shaderStr);
shaderStr->append(fFSHeader);
this->appendUniformDecls(kFragment_ShaderType, shaderStr);
this->appendDecls(fFSInputs, shaderStr);
// We shouldn't have declared outputs on 1.10
- GrAssert(k110_GrGLSLGeneration != fContext.glslGeneration() || fFSOutputs.empty());
+ GrAssert(k110_GrGLSLGeneration != fCtxInfo.glslGeneration() || fFSOutputs.empty());
this->appendDecls(fFSOutputs, shaderStr);
shaderStr->append(fFSFunctions);
shaderStr->append("void main() {\n");
diff --git a/src/gpu/gl/GrGLShaderBuilder.h b/src/gpu/gl/GrGLShaderBuilder.h
index 87136cdf53..d50fbce9c8 100644
--- a/src/gpu/gl/GrGLShaderBuilder.h
+++ b/src/gpu/gl/GrGLShaderBuilder.h
@@ -217,7 +217,7 @@ private:
kNonStageIdx = -1,
};
- const GrGLContextInfo& fContext;
+ const GrGLContextInfo& fCtxInfo;
GrGLUniformManager& fUniformManager;
int fCurrentStageIdx;
SkString fFSFunctions;
diff --git a/src/gpu/gl/GrGLShaderVar.h b/src/gpu/gl/GrGLShaderVar.h
index 89fa087460..ecf0b479ae 100644
--- a/src/gpu/gl/GrGLShaderVar.h
+++ b/src/gpu/gl/GrGLShaderVar.h
@@ -8,7 +8,7 @@
#ifndef GrGLShaderVar_DEFINED
#define GrGLShaderVar_DEFINED
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
#include "GrGLSL.h"
#include "SkString.h"
@@ -252,7 +252,7 @@ public:
/**
* Write a declaration of this variable to out.
*/
- void appendDecl(const GrGLContextInfo& gl, SkString* out) const {
+ void appendDecl(const GrGLContextInfo& ctxInfo, SkString* out) const {
if (kUpperLeft_Origin == fOrigin) {
// this is the only place where we specify a layout modifier. If we use other layout
// modifiers in the future then they should be placed in a list.
@@ -260,10 +260,10 @@ public:
}
if (this->getTypeModifier() != kNone_TypeModifier) {
out->append(TypeModifierString(this->getTypeModifier(),
- gl.glslGeneration()));
+ ctxInfo.glslGeneration()));
out->append(" ");
}
- out->append(PrecisionString(fPrecision, gl.binding()));
+ out->append(PrecisionString(fPrecision, ctxInfo.binding()));
GrSLType effectiveType = this->getType();
if (this->isArray()) {
if (this->isUnsizedArray()) {
diff --git a/src/gpu/gl/GrGLUniformManager.h b/src/gpu/gl/GrGLUniformManager.h
index 8f435d3037..ee693a6a5b 100644
--- a/src/gpu/gl/GrGLUniformManager.h
+++ b/src/gpu/gl/GrGLUniformManager.h
@@ -14,7 +14,7 @@
#include "SkTArray.h"
-class GrGLContextInfo;
+class GrGLContext;
class SkMatrix;
/** Manages a program's uniforms.
@@ -25,7 +25,7 @@ public:
typedef int UniformHandle;
static const UniformHandle kInvalidUniformHandle = 0;
- GrGLUniformManager(const GrGLContextInfo& context) : fContext(context) {}
+ GrGLUniformManager(const GrGLContext& context) : fContext(context) {}
UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::kNonArray);
@@ -78,7 +78,7 @@ private:
};
SkTArray<Uniform, true> fUniforms;
- const GrGLContextInfo& fContext;
+ const GrGLContext& fContext;
};
#endif
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 92bac03b8a..8ea7e5cde4 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -147,17 +147,17 @@ static bool fbo_test(const GrGLInterface* gl, int w, int h) {
return status == GR_GL_FRAMEBUFFER_COMPLETE;
}
-GrGpuGL::GrGpuGL(const GrGLContextInfo& ctxInfo, GrContext* context)
+GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context)
: GrGpu(context)
- , fGLContextInfo(ctxInfo) {
+ , fGLContext(ctx) {
- GrAssert(ctxInfo.isInitialized());
+ GrAssert(ctx.isInitialized());
fillInConfigRenderableTable();
fPrintedCaps = false;
- GrGLClearErr(fGLContextInfo.interface());
+ GrGLClearErr(fGLContext.interface());
if (gPrintStartupSpew) {
const GrGLubyte* ext;
@@ -178,7 +178,7 @@ GrGpuGL::GrGpuGL(const GrGLContextInfo& ctxInfo, GrContext* context)
this->initCaps();
- fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContextInfo()));
+ fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContext()));
fHWGeometryState.setMaxAttribArrays(this->glCaps().maxVertexAttributes());
@@ -827,34 +827,34 @@ bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc,
}
namespace {
-bool renderbuffer_storage_msaa(GrGLContextInfo& ctxInfo,
+bool renderbuffer_storage_msaa(GrGLContext& ctx,
int sampleCount,
GrGLenum format,
int width, int height) {
- CLEAR_ERROR_BEFORE_ALLOC(ctxInfo.interface());
- GrAssert(GrGLCaps::kNone_MSFBOType != ctxInfo.caps().msFBOType());
+ CLEAR_ERROR_BEFORE_ALLOC(ctx.interface());
+ GrAssert(GrGLCaps::kNone_MSFBOType != ctx.info().caps().msFBOType());
bool created = false;
if (GrGLCaps::kNVDesktop_CoverageAAType ==
- ctxInfo.caps().coverageAAType()) {
+ ctx.info().caps().coverageAAType()) {
const GrGLCaps::MSAACoverageMode& mode =
- ctxInfo.caps().getMSAACoverageMode(sampleCount);
- GL_ALLOC_CALL(ctxInfo.interface(),
+ ctx.info().caps().getMSAACoverageMode(sampleCount);
+ GL_ALLOC_CALL(ctx.interface(),
RenderbufferStorageMultisampleCoverage(GR_GL_RENDERBUFFER,
mode.fCoverageSampleCnt,
mode.fColorSampleCnt,
format,
width, height));
- created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctxInfo.interface()));
+ created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
}
if (!created) {
// glRBMS will fail if requested samples is > max samples.
- sampleCount = GrMin(sampleCount, ctxInfo.caps().maxSampleCount());
- GL_ALLOC_CALL(ctxInfo.interface(),
+ sampleCount = GrMin(sampleCount, ctx.info().caps().maxSampleCount());
+ GL_ALLOC_CALL(ctx.interface(),
RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
sampleCount,
format,
width, height));
- created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctxInfo.interface()));
+ created = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
}
return created;
}
@@ -904,7 +904,7 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height,
GrAssert(desc->fSampleCnt > 0);
GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER,
desc->fMSColorRenderbufferID));
- if (!renderbuffer_storage_msaa(fGLContextInfo,
+ if (!renderbuffer_storage_msaa(fGLContext,
desc->fSampleCnt,
msColorFormat,
width, height)) {
@@ -920,7 +920,7 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height,
if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
goto FAILED;
}
- fGLContextInfo.caps().markConfigAsValidColorAttachment(
+ fGLContext.info().caps().markConfigAsValidColorAttachment(
desc->fConfig);
}
}
@@ -935,7 +935,7 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height,
if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
goto FAILED;
}
- fGLContextInfo.caps().markConfigAsValidColorAttachment(desc->fConfig);
+ fGLContext.info().caps().markConfigAsValidColorAttachment(desc->fConfig);
}
return true;
@@ -1131,7 +1131,7 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
// version on a GL that doesn't have an MSAA extension.
bool created;
if (samples > 0) {
- created = renderbuffer_storage_msaa(fGLContextInfo,
+ created = renderbuffer_storage_msaa(fGLContext,
samples,
sFmt.fInternalFormat,
width, height);
@@ -1220,7 +1220,7 @@ bool GrGpuGL::attachStencilBufferToRenderTarget(GrStencilBuffer* sb,
}
return false;
} else {
- fGLContextInfo.caps().markColorConfigAndStencilFormatAsVerified(
+ fGLContext.info().caps().markColorConfigAndStencilFormatAsVerified(
rt->config(),
glsb->format());
}
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index b47865cba7..a859d18595 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -13,7 +13,7 @@
#include "GrBinHashKey.h"
#include "GrDrawState.h"
#include "GrGpu.h"
-#include "GrGLContextInfo.h"
+#include "GrGLContext.h"
#include "GrGLIndexBuffer.h"
#include "GrGLIRect.h"
#include "GrGLProgram.h"
@@ -24,17 +24,13 @@
class GrGpuGL : public GrGpu {
public:
- GrGpuGL(const GrGLContextInfo& ctxInfo, GrContext* context);
+ GrGpuGL(const GrGLContext& ctx, GrContext* context);
virtual ~GrGpuGL();
- const GrGLInterface* glInterface() const {
- return fGLContextInfo.interface();
- }
- GrGLBinding glBinding() const { return fGLContextInfo.binding(); }
- GrGLVersion glVersion() const { return fGLContextInfo.version(); }
- GrGLSLGeneration glslGeneration() const {
- return fGLContextInfo.glslGeneration();
- }
+ const GrGLInterface* glInterface() const { return fGLContext.interface(); }
+ GrGLBinding glBinding() const { return fGLContext.info().binding(); }
+ GrGLVersion glVersion() const { return fGLContext.info().version(); }
+ GrGLSLGeneration glslGeneration() const { return fGLContext.info().glslGeneration(); }
// Used by GrGLProgram to bind necessary textures for GrGLEffects.
void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture);
@@ -55,7 +51,7 @@ public:
virtual void abandonResources() SK_OVERRIDE;
- const GrGLCaps& glCaps() const { return fGLContextInfo.caps(); }
+ const GrGLCaps& glCaps() const { return fGLContext.info().caps(); }
// Callbacks to update state tracking when related GL objects are bound or deleted
void notifyVertexBufferBind(GrGLuint id);
@@ -137,17 +133,15 @@ private:
// have been accounted for).
void flushBlend(bool isLines, GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff);
- bool hasExtension(const char* ext) const {
- return fGLContextInfo.hasExtension(ext);
- }
+ bool hasExtension(const char* ext) const { return fGLContext.info().hasExtension(ext); }
- const GrGLContextInfo& glContextInfo() const { return fGLContextInfo; }
+ const GrGLContext& glContext() const { return fGLContext; }
static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff);
class ProgramCache : public ::GrNoncopyable {
public:
- ProgramCache(const GrGLContextInfo& gl);
+ ProgramCache(const GrGLContext& gl);
void abandon();
GrGLProgram* getProgram(const GrGLProgram::Desc& desc, const GrEffectStage* stages[]);
@@ -188,7 +182,7 @@ private:
Entry fEntries[kMaxEntries];
int fCount;
unsigned int fCurrLRUStamp;
- const GrGLContextInfo& fGL;
+ const GrGLContext& fGL;
};
// sets the matrix for path stenciling (uses the GL fixed pipe matrices)
@@ -236,7 +230,7 @@ private:
void fillInConfigRenderableTable();
- GrGLContextInfo fGLContextInfo;
+ GrGLContext fGLContext;
// GL program-related state
ProgramCache* fProgramCache;
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index 8526100f9d..e5a71831ec 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -16,7 +16,7 @@ static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidU
#define SKIP_CACHE_CHECK true
#define GR_UINT32_MAX static_cast<uint32_t>(-1)
-GrGpuGL::ProgramCache::ProgramCache(const GrGLContextInfo& gl)
+GrGpuGL::ProgramCache::ProgramCache(const GrGLContext& gl)
: fCount(0)
, fCurrLRUStamp(0)
, fGL(gl) {
diff --git a/src/gpu/gl/SkGLContext.cpp b/src/gpu/gl/SkGLContextHelper.cpp
index 6076845082..9dcc8ecbb8 100644
--- a/src/gpu/gl/SkGLContext.cpp
+++ b/src/gpu/gl/SkGLContextHelper.cpp
@@ -1,23 +1,23 @@
/*
- * Copyright 2011 Google Inc.
+ * Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gl/SkGLContext.h"
+#include "gl/SkGLContextHelper.h"
#include "GrGLUtil.h"
-SK_DEFINE_INST_COUNT(SkGLContext)
+SK_DEFINE_INST_COUNT(SkGLContextHelper)
-SkGLContext::SkGLContext()
+SkGLContextHelper::SkGLContextHelper()
: fFBO(0)
, fColorBufferID(0)
, fDepthStencilBufferID(0)
, fGL(NULL) {
}
-SkGLContext::~SkGLContext() {
+SkGLContextHelper::~SkGLContextHelper() {
if (fGL) {
// TODO: determine why DeleteFramebuffers is generating a GL error in tests
@@ -29,7 +29,7 @@ SkGLContext::~SkGLContext() {
SkSafeUnref(fGL);
}
-bool SkGLContext::init(int width, int height) {
+bool SkGLContextHelper::init(int width, int height) {
if (fGL) {
fGL->unref();
this->destroyGLContext();
diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
index ab3501c14b..21a3d1bf71 100644
--- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
@@ -738,7 +738,7 @@ public:
// The solution to this is probably to alter SkDebugGlContext's
// "makeCurrent" method to make a call like "makeCurrent(this)" to
// the debug GL interface (assuming that the application will create
- // multiple SkGLContext's) to let it switch between the active
+ // multiple SkGLContextHelper's) to let it switch between the active
// context. Everything in the GrDebugGL object would then need to be
// moved to a GrContextObj and the GrDebugGL object would just switch
// between them. Note that this approach would also require that