Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: src/gpu/gl/GrGLContext.cpp

Issue 1153813002: Remove init from GrGLContextInfo and caps classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/GrGLContext.cpp
diff --git a/src/gpu/gl/GrGLContext.cpp b/src/gpu/gl/GrGLContext.cpp
index fc8b195fd37858d48ac27182a75dd818a10bdb3d..8115687093b59115b3a90f76829ecb3fc90f100a 100644
--- a/src/gpu/gl/GrGLContext.cpp
+++ b/src/gpu/gl/GrGLContext.cpp
@@ -9,78 +9,63 @@
////////////////////////////////////////////////////////////////////////////////
-GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& that) {
- fInterface.reset(SkSafeRef(that.fInterface.get()));
- fGLVersion = that.fGLVersion;
- fGLSLGeneration = that.fGLSLGeneration;
- fVendor = that.fVendor;
- fRenderer = that.fRenderer;
- fIsMesa = that.fIsMesa;
- fIsChromium = that.fIsChromium;
- *fGLCaps = *that.fGLCaps.get();
- return *this;
-}
-
-bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
- this->reset();
- // We haven't validated the GrGLInterface yet, so check for GetString
- // function pointer
- if (interface->fFunctions.fGetString) {
- const GrGLubyte* verUByte;
- GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION));
- const char* ver = reinterpret_cast<const char*>(verUByte);
-
- const GrGLubyte* rendererUByte;
- GR_GL_CALL_RET(interface, rendererUByte, GetString(GR_GL_RENDERER));
- const char* renderer = reinterpret_cast<const char*>(rendererUByte);
+GrGLContext* GrGLContext::Create(const GrGLInterface* interface) {
+ // We haven't validated the GrGLInterface yet, so check for GetString function pointer
+ if (!interface->fFunctions.fGetString) {
+ return NULL;
+ }
+ ConstructorArgs args;
+ args.fInterface = interface;
- if (interface->validate()) {
+ const GrGLubyte* verUByte;
+ GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION));
+ const char* ver = reinterpret_cast<const char*>(verUByte);
- fGLVersion = GrGLGetVersionFromString(ver);
- if (GR_GL_INVALID_VER == fGLVersion) {
- return false;
- }
+ const GrGLubyte* rendererUByte;
+ GR_GL_CALL_RET(interface, rendererUByte, GetString(GR_GL_RENDERER));
+ const char* renderer = reinterpret_cast<const char*>(rendererUByte);
- if (!GrGetGLSLGeneration(interface, &fGLSLGeneration)) {
- return false;
- }
+ if (!interface->validate()) {
+ return NULL;
+ }
- fVendor = GrGLGetVendor(interface);
+ args.fGLVersion = GrGLGetVersionFromString(ver);
+ if (GR_GL_INVALID_VER == args.fGLVersion) {
+ return NULL;
+ }
- /*
- * Qualcomm drivers have a horrendous bug with some drivers. Though they claim to
- * support GLES 3.00, some perfectly valid GLSL300 shaders will only compile with
- * #version 100, and will fail to compile with #version 300 es. In the long term, we
- * need to lock this down to a specific driver version.
- */
- if (kQualcomm_GrGLVendor == fVendor) {
- fGLSLGeneration = k110_GrGLSLGeneration;
- }
+ if (!GrGetGLSLGeneration(interface, &args.fGLSLGeneration)) {
+ return NULL;
+ }
- fRenderer = GrGLGetRendererFromString(renderer);
+ args.fVendor = GrGLGetVendor(interface);
- fIsMesa = GrGLIsMesaFromVersionString(ver);
+ /*
+ * Qualcomm drivers have a horrendous bug with some drivers. Though they claim to
+ * support GLES 3.00, some perfectly valid GLSL300 shaders will only compile with
+ * #version 100, and will fail to compile with #version 300 es. In the long term, we
+ * need to lock this down to a specific driver version.
+ */
+ if (kQualcomm_GrGLVendor == args.fVendor) {
+ args.fGLSLGeneration = k110_GrGLSLGeneration;
+ }
- fIsChromium = GrGLIsChromiumFromRendererString(renderer);
+ args.fRenderer = GrGLGetRendererFromString(renderer);
- // This must occur before caps init.
- fInterface.reset(SkRef(interface));
+ args.fIsMesa = GrGLIsMesaFromVersionString(ver);
- return fGLCaps->init(*this, interface);
- }
- }
- return false;
+ args.fIsChromium = GrGLIsChromiumFromRendererString(renderer);
+ return SkNEW_ARGS(GrGLContext, (args));
}
-bool GrGLContextInfo::isInitialized() const { return SkToBool(fInterface.get()); }
+GrGLContextInfo::GrGLContextInfo(const ConstructorArgs& args) {
+ fInterface.reset(SkRef(args.fInterface));
+ fGLVersion = args.fGLVersion;
+ fGLSLGeneration = args.fGLSLGeneration;
+ fVendor = args.fVendor;
+ fRenderer = args.fRenderer;
+ fIsMesa = args.fIsMesa;
+ fIsChromium = args.fIsChromium;
-void GrGLContextInfo::reset() {
- fInterface.reset(NULL);
- fGLVersion = GR_GL_VER(0, 0);
- fGLSLGeneration = static_cast<GrGLSLGeneration>(0);
- fVendor = kOther_GrGLVendor;
- fRenderer = kOther_GrGLRenderer;
- fIsMesa = false;
- fIsChromium = false;
- fGLCaps->reset();
+ fGLCaps.reset(SkNEW_ARGS(GrGLCaps, (*this, fInterface)));
}

Powered by Google App Engine
This is Rietveld 408576698