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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2  * Copyright 2013 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     9 #ifndef GrGLContext_DEFINED
    10 #define GrGLContext_DEFINED
    12 #include "gl/GrGLExtensions.h"
    13 #include "gl/GrGLInterface.h"
    14 #include "GrGLCaps.h"
    15 #include "GrGLSL.h"
    16 #include "GrGLUtil.h"
    18 #include "SkString.h"
    20 /**
    21  * Encapsulates information about an OpenGL context including the OpenGL
    22  * version, the GrGLStandard type of the context, and GLSL version.
    23  */
    24 class GrGLContextInfo {
    25 public:
    26     /**
    27      * Default constructor
    28      */
    29     GrGLContextInfo() {
    30         fGLCaps.reset(SkNEW(GrGLCaps));
    31         this->reset();
    32     }
    34     GrGLContextInfo(const GrGLContextInfo& that) {
    35         fGLCaps.reset(SkNEW(GrGLCaps));
    36         *this = that;
    37     }
    39     GrGLContextInfo& operator= (const GrGLContextInfo&);
    41     /**
    42      * Initializes a GrGLContextInfo from a GrGLInterface and the currently
    43      * bound OpenGL context accessible by the GrGLInterface.
    44      */
    45     bool initialize(const GrGLInterface* interface);
    46     bool isInitialized() const;
    48     GrGLStandard standard() const { return fInterface->fStandard; }
    49     GrGLVersion version() const { return fGLVersion; }
    50     GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; }
    51     GrGLVendor vendor() const { return fVendor; }
    52     GrGLRenderer renderer() const { return fRenderer; }
    53     /** Is this a mesa-based driver. Does not mean it is the osmesa software rasterizer. */
    54     bool isMesa() const { return fIsMesa; }
    55     /** Are we running inside Chromium (using the command buffer)? We make some different tradeoffs
    56         about what errors to check for because queries are synchronous. We should probably expose
    57         this as an option for clients other than Chromium. */
    58     bool isChromium() const { return fIsChromium; }
    59     const GrGLCaps* caps() const { return fGLCaps.get(); }
    60     GrGLCaps* caps() { return fGLCaps; }
    61     bool hasExtension(const char* ext) const {
    62         if (!this->isInitialized()) {
    63             return false;
    64         }
    65         return fInterface->hasExtension(ext);
    66     }
    68     /**
    69      * Reset the information
    70      */
    71     void reset();
    73 protected:
    74     SkAutoTUnref<const GrGLInterface>   fInterface;
    75     GrGLVersion                         fGLVersion;
    76     GrGLSLGeneration                    fGLSLGeneration;
    77     GrGLVendor                          fVendor;
    78     GrGLRenderer                        fRenderer;
    79     bool                                fIsMesa;
    80     bool                                fIsChromium;
    81     SkAutoTUnref<GrGLCaps>              fGLCaps;
    82 };
    84 /**
    85  * Extension of GrGLContextInfo that also provides access to GrGLInterface.
    86  */
    87 class GrGLContext : public GrGLContextInfo {
    88 public:
    89     /**
    90      * Creates a GrGLContext from a GrGLInterface and the currently
    91      * bound OpenGL context accessible by the GrGLInterface.
    92      */
    93     explicit GrGLContext(const GrGLInterface* interface) {
    94         this->initialize(interface);
    95     }
    97     GrGLContext(const GrGLContext& that) : INHERITED(that) {}
    99     GrGLContext& operator= (const GrGLContext& that) {
   100         this->INHERITED::operator=(that);
   101         return *this;
   102     }
   104     const GrGLInterface* interface() const { return fInterface.get(); }
   106 private:
   107     typedef GrGLContextInfo INHERITED;
   108 };
   110 #endif

mercurial