gfx/skia/trunk/include/gpu/gl/GrGLExtensions.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/gpu/gl/GrGLExtensions.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     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 +#ifndef GrGLExtensions_DEFINED
    1.12 +#define GrGLExtensions_DEFINED
    1.13 +
    1.14 +#include "GrGLFunctions.h"
    1.15 +#include "SkString.h"
    1.16 +#include "SkTArray.h"
    1.17 +
    1.18 +struct GrGLInterface;
    1.19 +
    1.20 +/**
    1.21 + * This helper queries the current GL context for its extensions, remembers them, and can be
    1.22 + * queried. It supports both glGetString- and glGetStringi-style extension string APIs and will
    1.23 + * use the latter if it is available.
    1.24 + */
    1.25 +class SK_API GrGLExtensions {
    1.26 +public:
    1.27 +    GrGLExtensions() : fInitialized(false), fStrings(SkNEW(SkTArray<SkString>)) {}
    1.28 +
    1.29 +    GrGLExtensions(const GrGLExtensions&);
    1.30 +
    1.31 +    GrGLExtensions& operator=(const GrGLExtensions&);
    1.32 +
    1.33 +    void swap(GrGLExtensions* that) {
    1.34 +        fStrings.swap(&that->fStrings);
    1.35 +        SkTSwap(fInitialized, that->fInitialized);
    1.36 +    }
    1.37 +
    1.38 +    /**
    1.39 +     * We sometimes need to use this class without having yet created a GrGLInterface. This version
    1.40 +     * of init expects that getString is always non-NULL while getIntegerv and getStringi are non-
    1.41 +     * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail.
    1.42 +     */
    1.43 +    bool init(GrGLStandard standard,
    1.44 +              GrGLGetStringProc getString,
    1.45 +              GrGLGetStringiProc getStringi,
    1.46 +              GrGLGetIntegervProc getIntegerv);
    1.47 +
    1.48 +    bool isInitialized() const { return fInitialized; }
    1.49 +
    1.50 +    /**
    1.51 +     * Queries whether an extension is present. This will fail if init() has not been called.
    1.52 +     */
    1.53 +    bool has(const char[]) const;
    1.54 +
    1.55 +    /**
    1.56 +     * Removes an extension if present. Returns true if the extension was present before the call.
    1.57 +     */
    1.58 +    bool remove(const char[]);
    1.59 +
    1.60 +    /**
    1.61 +     * Adds an extension to list
    1.62 +     */
    1.63 +    void add(const char[]);
    1.64 +
    1.65 +    void reset() { fStrings->reset(); }
    1.66 +
    1.67 +    void print(const char* sep = "\n") const;
    1.68 +
    1.69 +private:
    1.70 +    bool                                fInitialized;
    1.71 +    SkAutoTDelete<SkTArray<SkString> >  fStrings;
    1.72 +};
    1.73 +
    1.74 +#endif

mercurial