gfx/skia/trunk/src/gpu/gl/GrGLContext.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/gpu/gl/GrGLContext.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +/*
     1.5 + * Copyright 2013 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#include "GrGLContext.h"
    1.12 +
    1.13 +////////////////////////////////////////////////////////////////////////////////
    1.14 +
    1.15 +GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& that) {
    1.16 +    fInterface.reset(SkSafeRef(that.fInterface.get()));
    1.17 +    fGLVersion      = that.fGLVersion;
    1.18 +    fGLSLGeneration = that.fGLSLGeneration;
    1.19 +    fVendor         = that.fVendor;
    1.20 +    fRenderer       = that.fRenderer;
    1.21 +    fIsMesa         = that.fIsMesa;
    1.22 +    fIsChromium     = that.fIsChromium;
    1.23 +    *fGLCaps        = *that.fGLCaps.get();
    1.24 +    return *this;
    1.25 +}
    1.26 +
    1.27 +bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
    1.28 +    this->reset();
    1.29 +    // We haven't validated the GrGLInterface yet, so check for GetString
    1.30 +    // function pointer
    1.31 +    if (interface->fFunctions.fGetString) {
    1.32 +        const GrGLubyte* verUByte;
    1.33 +        GR_GL_CALL_RET(interface, verUByte, GetString(GR_GL_VERSION));
    1.34 +        const char* ver = reinterpret_cast<const char*>(verUByte);
    1.35 +
    1.36 +        const GrGLubyte* rendererUByte;
    1.37 +        GR_GL_CALL_RET(interface, rendererUByte, GetString(GR_GL_RENDERER));
    1.38 +        const char* renderer = reinterpret_cast<const char*>(rendererUByte);
    1.39 +
    1.40 +        if (interface->validate()) {
    1.41 +
    1.42 +            fGLVersion = GrGLGetVersionFromString(ver);
    1.43 +
    1.44 +            fGLSLGeneration = GrGetGLSLGeneration(interface);
    1.45 +
    1.46 +            fVendor = GrGLGetVendor(interface);
    1.47 +
    1.48 +            fRenderer = GrGLGetRendererFromString(renderer);
    1.49 +
    1.50 +            fIsMesa = GrGLIsMesaFromVersionString(ver);
    1.51 +
    1.52 +            fIsChromium = GrGLIsChromiumFromRendererString(renderer);
    1.53 +
    1.54 +            // This must occur before caps init.
    1.55 +            fInterface.reset(SkRef(interface));
    1.56 +
    1.57 +            fGLCaps->init(*this, interface);
    1.58 +
    1.59 +            return true;
    1.60 +        }
    1.61 +    }
    1.62 +    return false;
    1.63 +}
    1.64 +
    1.65 +bool GrGLContextInfo::isInitialized() const {
    1.66 +    return NULL != fInterface.get();
    1.67 +}
    1.68 +
    1.69 +void GrGLContextInfo::reset() {
    1.70 +    fInterface.reset(NULL);
    1.71 +    fGLVersion = GR_GL_VER(0, 0);
    1.72 +    fGLSLGeneration = static_cast<GrGLSLGeneration>(0);
    1.73 +    fVendor = kOther_GrGLVendor;
    1.74 +    fRenderer = kOther_GrGLRenderer;
    1.75 +    fIsMesa = false;
    1.76 +    fIsChromium = false;
    1.77 +    fGLCaps->reset();
    1.78 +}

mercurial