GrGLCaps.h revision 06604b95622359640a1c2028b885646deda28d52
1f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com/*
2f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * Copyright 2012 Google Inc.
3f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com *
4f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * Use of this source code is governed by a BSD-style license that can be
5f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * found in the LICENSE file.
6f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */
7f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
8f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
9f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com#ifndef GrGLCaps_DEFINED
10f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com#define GrGLCaps_DEFINED
11f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
121aa202935ff698f1f35c5435455073fd9f1d08debsalomon#include <functional>
131aa202935ff698f1f35c5435455073fd9f1d08debsalomon
143183a4136364cfe18b3584302e71ea528a018401mtklein#include "glsl/GrGLSL.h"
15cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon#include "GrCaps.h"
168dc7c3a839b38b73af34cc2674a06f49eb1ce527egdaniel#include "GrGLStencilAttachment.h"
17cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon#include "GrSwizzle.h"
18e4b231428e8c14cbc82d20cfb12eb08fc45f8df6piotaixr#include "SkChecksum.h"
192aa1f7e6799501974532d35c1f6c3a0447121b95mtklein#include "SkTHash.h"
20a2d71482db8b6d752a51c96da74768d7dfc27932robertphillips@google.com#include "SkTArray.h"
21f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
22f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.comclass GrGLContextInfo;
23e9c0fc616d2a1632c285885b9b656b68ca8d4f24jvanverthclass GrGLSLCaps;
241aa202935ff698f1f35c5435455073fd9f1d08debsalomonclass GrGLRenderTarget;
25f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
26f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com/**
27f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * Stores some capabilities of a GL context. Most are determined by the GL
28f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * version and the extensions string. It also tracks formats that have passed
29f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com * the FBO completeness test.
30f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com */
314b91f768b348aa1cebeb54f3ff9331938734c242bsalomonclass GrGLCaps : public GrCaps {
32f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.compublic:
338dc7c3a839b38b73af34cc2674a06f49eb1ce527egdaniel    typedef GrGLStencilAttachment::Format StencilFormat;
34f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
35f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /**
36f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * The type of MSAA for FBOs supported. Different extensions have different
37f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * semantics of how / when a resolve is performed.
38f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     */
39f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    enum MSFBOType {
40f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com        /**
41f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com         * no support for MSAA FBOs
42f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com         */
43fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        kNone_MSFBOType = 0,
44f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com        /**
456fc1b4998917791a73bf54428513940fe77dc058skia.committer@gmail.com         * GL3.0-style MSAA FBO (GL_ARB_framebuffer_object).
46f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com         */
47347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com        kDesktop_ARB_MSFBOType,
48f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com        /**
49f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com         * earlier GL_EXT_framebuffer* extensions
50f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com         */
51347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com        kDesktop_EXT_MSFBOType,
52f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com        /**
53a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org         * Similar to kDesktop_ARB but with additional restrictions on glBlitFramebuffer.
54a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org         */
55a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org        kES_3_0_MSFBOType,
56a8e5a06f69b7e0cb17a4b3203f0a7a1d52aa73eccommit-bot@chromium.org        /**
57f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com         * GL_APPLE_framebuffer_multisample ES extension
58f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com         */
59347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com        kES_Apple_MSFBOType,
60f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com        /**
61347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com         * GL_IMG_multisampled_render_to_texture. This variation does not have MSAA renderbuffers.
62347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com         * Instead the texture is multisampled when bound to the FBO and then resolved automatically
63347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com         * when read. It also defines an alternate value for GL_MAX_SAMPLES (which we call
64347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com         * GR_GL_MAX_SAMPLES_IMG).
65f3a60c09b975f50bbd14215df10effffd2fd46e8bsalomon@google.com         */
66347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com        kES_IMG_MsToTexture_MSFBOType,
67347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com        /**
68347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com         * GL_EXT_multisampled_render_to_texture. Same as the IMG one above but uses the standard
69347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com         * GL_MAX_SAMPLES value.
70347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com         */
71347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com        kES_EXT_MsToTexture_MSFBOType,
72dded69693dd3779f081326cde24c3954505b129dvbuzinov        /**
73dded69693dd3779f081326cde24c3954505b129dvbuzinov         * GL_NV_framebuffer_mixed_samples.
74dded69693dd3779f081326cde24c3954505b129dvbuzinov         */
75dded69693dd3779f081326cde24c3954505b129dvbuzinov        kMixedSamples_MSFBOType,
766b0cf0273fdffbbdf69235b57b5b5a311e7f1ca6bsalomon@google.com
77dded69693dd3779f081326cde24c3954505b129dvbuzinov        kLast_MSFBOType = kMixedSamples_MSFBOType
786b0cf0273fdffbbdf69235b57b5b5a311e7f1ca6bsalomon@google.com    };
796b0cf0273fdffbbdf69235b57b5b5a311e7f1ca6bsalomon@google.com
8052ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org    enum InvalidateFBType {
8152ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org        kNone_InvalidateFBType,
8252ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org        kDiscard_InvalidateFBType,       //<! glDiscardFramebuffer()
8352ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org        kInvalidate_InvalidateFBType,     //<! glInvalidateFramebuffer()
8452ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org
8552ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org        kLast_InvalidateFBType = kInvalidate_InvalidateFBType
86f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    };
87f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
88160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    enum MapBufferType {
89160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        kNone_MapBufferType,
90160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        kMapBuffer_MapBufferType,         // glMapBuffer()
91160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        kMapBufferRange_MapBufferType,    // glMapBufferRange()
92160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        kChromium_MapBufferType,          // GL_CHROMIUM_map_sub
93160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org
94160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        kLast_MapBufferType = kChromium_MapBufferType,
95160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    };
96160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org
97d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth    enum TransferBufferType {
98d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth        kNone_TransferBufferType,
99d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth        kPBO_TransferBufferType,          // ARB_pixel_buffer_object
100d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth        kChromium_TransferBufferType,     // CHROMIUM_pixel_transfer_buffer_object
101d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth
102d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth        kLast_TransferBufferType = kChromium_TransferBufferType,
103d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth    };
104d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth
105f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /**
106f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * Initializes the GrGLCaps to the set of features supported in the current
107f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * OpenGL context accessible via ctxInfo.
108f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     */
109682c269a1511200322916af83053e26004c0ec40bsalomon    GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo,
110682c269a1511200322916af83053e26004c0ec40bsalomon             const GrGLInterface* glInterface);
111f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
11241e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon    bool isConfigTexturable(GrPixelConfig config) const override {
11341e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon        SkASSERT(kGrPixelConfigCnt > config);
11441e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon        return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag);
11541e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon    }
11641e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon
11741e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon    bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override {
11841e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon        SkASSERT(kGrPixelConfigCnt > config);
11941e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon        if (withMSAA) {
12041e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon            return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderableWithMSAA_Flag);
12141e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon        } else {
12241e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon            return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderable_Flag);
12341e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon        }
12441e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon    }
12541e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon
126cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon    /** Returns the mapping between GrPixelConfig components and GL internal format components. */
127cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon    const GrSwizzle& configSwizzle(GrPixelConfig config) const {
128cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon        return fConfigTable[config].fSwizzle;
129cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon    }
130cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon
13176148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    bool getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
13276148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon                            GrGLenum* internalFormat, GrGLenum* externalFormat,
13376148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon                            GrGLenum* externalType) const;
13476148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon
13576148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    bool getCompressedTexImageFormats(GrPixelConfig surfaceConfig, GrGLenum* internalFormat) const;
13676148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon
13776148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
13876148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon                             GrGLenum* externalFormat, GrGLenum* externalType) const;
13976148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon
14076148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    bool getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const;
14176148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon
142304473749db1ee877addb3ddf090d2e36ede2c2absalomon    /**
143304473749db1ee877addb3ddf090d2e36ede2c2absalomon    * Gets an array of legal stencil formats. These formats are not guaranteed
144304473749db1ee877addb3ddf090d2e36ede2c2absalomon    * to be supported by the driver but are legal GLenum names given the GL
145304473749db1ee877addb3ddf090d2e36ede2c2absalomon    * version and extensions supported.
146304473749db1ee877addb3ddf090d2e36ede2c2absalomon    */
147304473749db1ee877addb3ddf090d2e36ede2c2absalomon    const SkTArray<StencilFormat, true>& stencilFormats() const {
148304473749db1ee877addb3ddf090d2e36ede2c2absalomon        return fStencilFormats;
149304473749db1ee877addb3ddf090d2e36ede2c2absalomon    }
150304473749db1ee877addb3ddf090d2e36ede2c2absalomon
151304473749db1ee877addb3ddf090d2e36ede2c2absalomon    /**
152304473749db1ee877addb3ddf090d2e36ede2c2absalomon     * Has a stencil format index been found for the config (or we've found that no format works).
153304473749db1ee877addb3ddf090d2e36ede2c2absalomon     */
154304473749db1ee877addb3ddf090d2e36ede2c2absalomon    bool hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config) const {
155304473749db1ee877addb3ddf090d2e36ede2c2absalomon        return fConfigTable[config].fStencilFormatIndex != ConfigInfo::kUnknown_StencilIndex;
156304473749db1ee877addb3ddf090d2e36ede2c2absalomon    }
157304473749db1ee877addb3ddf090d2e36ede2c2absalomon
158304473749db1ee877addb3ddf090d2e36ede2c2absalomon    /**
159304473749db1ee877addb3ddf090d2e36ede2c2absalomon     * Gets the stencil format index for the config. This assumes
160304473749db1ee877addb3ddf090d2e36ede2c2absalomon     * hasStencilFormatBeenDeterminedForConfig has already been checked. Returns a value < 0 if
161304473749db1ee877addb3ddf090d2e36ede2c2absalomon     * no stencil format is supported with the config. Otherwise, returned index refers to the array
162304473749db1ee877addb3ddf090d2e36ede2c2absalomon     * returned by stencilFormats().
163304473749db1ee877addb3ddf090d2e36ede2c2absalomon     */
164304473749db1ee877addb3ddf090d2e36ede2c2absalomon    int getStencilFormatIndexForConfig(GrPixelConfig config) const {
165304473749db1ee877addb3ddf090d2e36ede2c2absalomon        SkASSERT(this->hasStencilFormatBeenDeterminedForConfig(config));
166304473749db1ee877addb3ddf090d2e36ede2c2absalomon        return fConfigTable[config].fStencilFormatIndex;
167304473749db1ee877addb3ddf090d2e36ede2c2absalomon    }
168304473749db1ee877addb3ddf090d2e36ede2c2absalomon
169304473749db1ee877addb3ddf090d2e36ede2c2absalomon    /**
170304473749db1ee877addb3ddf090d2e36ede2c2absalomon     * If index is >= 0 this records an index into stencilFormats() as the best stencil format for
171304473749db1ee877addb3ddf090d2e36ede2c2absalomon     * the config. If < 0 it records that the config has no supported stencil format index.
172304473749db1ee877addb3ddf090d2e36ede2c2absalomon     */
173304473749db1ee877addb3ddf090d2e36ede2c2absalomon    void setStencilFormatIndexForConfig(GrPixelConfig config, int index) {
174304473749db1ee877addb3ddf090d2e36ede2c2absalomon        SkASSERT(!this->hasStencilFormatBeenDeterminedForConfig(config));
175304473749db1ee877addb3ddf090d2e36ede2c2absalomon        if (index < 0) {
176304473749db1ee877addb3ddf090d2e36ede2c2absalomon            fConfigTable[config].fStencilFormatIndex = ConfigInfo::kUnsupported_StencilFormatIndex;
177304473749db1ee877addb3ddf090d2e36ede2c2absalomon        } else {
178304473749db1ee877addb3ddf090d2e36ede2c2absalomon            fConfigTable[config].fStencilFormatIndex = index;
179304473749db1ee877addb3ddf090d2e36ede2c2absalomon        }
180304473749db1ee877addb3ddf090d2e36ede2c2absalomon    }
181304473749db1ee877addb3ddf090d2e36ede2c2absalomon
182f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /**
183f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * Call to note that a color config has been verified as a valid color
184f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * attachment. This may save future calls to glCheckFramebufferStatus
185f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * using isConfigVerifiedColorAttachment().
186f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     */
187f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    void markConfigAsValidColorAttachment(GrPixelConfig config) {
188480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon        fConfigTable[config].fFlags |= ConfigInfo::kVerifiedColorAttachment_Flag;
189f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    }
190f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
191f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /**
192f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * Call to check whether a config has been verified as a valid color
193f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * attachment.
194f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     */
195f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool isConfigVerifiedColorAttachment(GrPixelConfig config) const {
196480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon        return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kVerifiedColorAttachment_Flag);
197f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    }
198f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
199f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /**
200f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * Reports the type of MSAA FBO support.
201f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     */
202f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    MSFBOType msFBOType() const { return fMSFBOType; }
203f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
204f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /**
205347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com     * Does the supported MSAA FBO extension have MSAA renderbuffers?
206347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com     */
207347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com    bool usesMSAARenderBuffers() const {
208347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com        return kNone_MSFBOType != fMSFBOType &&
209347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com               kES_IMG_MsToTexture_MSFBOType != fMSFBOType &&
210dded69693dd3779f081326cde24c3954505b129dvbuzinov               kES_EXT_MsToTexture_MSFBOType != fMSFBOType &&
211dded69693dd3779f081326cde24c3954505b129dvbuzinov               kMixedSamples_MSFBOType != fMSFBOType;
212347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com    }
213347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com
214347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com    /**
215347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com     * Is the MSAA FBO extension one where the texture is multisampled when bound to an FBO and
216347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com     * then implicitly resolved when read.
217347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com     */
218347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com    bool usesImplicitMSAAResolve() const {
219347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com        return kES_IMG_MsToTexture_MSFBOType == fMSFBOType ||
220347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com               kES_EXT_MsToTexture_MSFBOType == fMSFBOType;
221347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com    }
222347c382d580cd1bc223e11a355b6a1c65d206e34bsalomon@google.com
22352ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org    InvalidateFBType invalidateFBType() const { return fInvalidateFBType; }
22452ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org
225160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    /// What type of buffer mapping is supported?
226160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    MapBufferType mapBufferType() const { return fMapBufferType; }
227f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
228d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth    /// What type of transfer buffer is supported?
229d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth    TransferBufferType transferBufferType() const { return fTransferBufferType; }
230d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth
231f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /// The maximum number of fragment uniform vectors (GLES has min. 16).
232f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; }
233f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
234a15f7e5b96ee3d71fdbcb4f9cf02f6a09b4b11accommit-bot@chromium.org    /// maximum number of attribute values per vertex
23560da4176425c74cf112d7e116f54a530a82d0d68bsalomon@google.com    int maxVertexAttributes() const { return fMaxVertexAttributes; }
23660da4176425c74cf112d7e116f54a530a82d0d68bsalomon@google.com
237a15f7e5b96ee3d71fdbcb4f9cf02f6a09b4b11accommit-bot@chromium.org    /// maximum number of texture units accessible in the fragment shader.
238a15f7e5b96ee3d71fdbcb4f9cf02f6a09b4b11accommit-bot@chromium.org    int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; }
239a15f7e5b96ee3d71fdbcb4f9cf02f6a09b4b11accommit-bot@chromium.org
240f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /**
241f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * Depending on the ES extensions present the BGRA external format may
24241e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon     * correspond to either a BGRA or RGBA internalFormat. On desktop GL it is
243f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     * RGBA.
244f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com     */
24541e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon    bool bgraIsInternalFormat() const;
246f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
247f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /// Is there support for GL_UNPACK_ROW_LENGTH
248f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; }
249f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
250f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /// Is there support for GL_UNPACK_FLIP_Y
251f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool unpackFlipYSupport() const { return fUnpackFlipYSupport; }
252f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
253f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /// Is there support for GL_PACK_ROW_LENGTH
254f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool packRowLengthSupport() const { return fPackRowLengthSupport; }
255f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
256f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /// Is there support for GL_PACK_REVERSE_ROW_ORDER
257f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool packFlipYSupport() const { return fPackFlipYSupport; }
258f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
259f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /// Is there support for texture parameter GL_TEXTURE_USAGE
260f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool textureUsageSupport() const { return fTextureUsageSupport; }
261f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
262f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    /// Is there support for glTexStorage
263f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool texStorageSupport() const { return fTexStorageSupport; }
264f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
265443e5a52b7e85070c26a068cd3b0aad126502395robertphillips@google.com    /// Is there support for GL_RED and GL_R8
266443e5a52b7e85070c26a068cd3b0aad126502395robertphillips@google.com    bool textureRedSupport() const { return fTextureRedSupport; }
267443e5a52b7e85070c26a068cd3b0aad126502395robertphillips@google.com
268e76b7ccb860b7ffcd86a42af8eecfe30f96493fabsalomon@google.com    /// Is GL_ARB_IMAGING supported
269e76b7ccb860b7ffcd86a42af8eecfe30f96493fabsalomon@google.com    bool imagingSupport() const { return fImagingSupport; }
270e76b7ccb860b7ffcd86a42af8eecfe30f96493fabsalomon@google.com
27107631cf14e22e772f901baf68545ee48c3d1e014bsalomon@google.com    /// Is there support for Vertex Array Objects?
27207631cf14e22e772f901baf68545ee48c3d1e014bsalomon@google.com    bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; }
27307631cf14e22e772f901baf68545ee48c3d1e014bsalomon@google.com
274626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton    /// Is there support for GL_EXT_direct_state_access?
275626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton    bool directStateAccessSupport() const { return fDirectStateAccessSupport; }
276626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton
277626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton    /// Is there support for GL_KHR_debug?
278626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton    bool debugSupport() const { return fDebugSupport; }
279626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton
2803f801cbb67895fa9fa29498aa017a7666960a627jvanverth    /// Is there support for ES2 compatability?
2813f801cbb67895fa9fa29498aa017a7666960a627jvanverth    bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; }
2823f801cbb67895fa9fa29498aa017a7666960a627jvanverth
283d472792a72c0c433a205d42a73e0b77d65f8d76fcdalton    /// Can we call glDisable(GL_MULTISAMPLE)?
28476148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    bool multisampleDisableSupport() const { return fMultisampleDisableSupport; }
285d472792a72c0c433a205d42a73e0b77d65f8d76fcdalton
28606604b95622359640a1c2028b885646deda28d52cdalton    /// Is there support for glDraw*Indirect? Note that the baseInstance fields of indirect draw
28706604b95622359640a1c2028b885646deda28d52cdalton    /// commands cannot be used unless we have base instance support.
28806604b95622359640a1c2028b885646deda28d52cdalton    bool drawIndirectSupport() const { return fDrawIndirectSupport; }
28906604b95622359640a1c2028b885646deda28d52cdalton
29006604b95622359640a1c2028b885646deda28d52cdalton    /// Is there support for glMultiDraw*Indirect? Note that the baseInstance fields of indirect
29106604b95622359640a1c2028b885646deda28d52cdalton    /// draw commands cannot be used unless we have base instance support.
29206604b95622359640a1c2028b885646deda28d52cdalton    bool multiDrawIndirectSupport() const { return fMultiDrawIndirectSupport; }
29306604b95622359640a1c2028b885646deda28d52cdalton
29406604b95622359640a1c2028b885646deda28d52cdalton    /// Are the baseInstance fields supported in indirect draw commands?
29506604b95622359640a1c2028b885646deda28d52cdalton    bool baseInstanceSupport() const { return fBaseInstanceSupport; }
29606604b95622359640a1c2028b885646deda28d52cdalton
29707631cf14e22e772f901baf68545ee48c3d1e014bsalomon@google.com    /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content.
29876148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; }
29996966a5a1ffc2f03eef1b5523308299aa4195f50bsalomon@google.com
3001aa202935ff698f1f35c5435455073fd9f1d08debsalomon    /// Does ReadPixels support reading readConfig pixels from a FBO that is renderTargetConfig?
3011aa202935ff698f1f35c5435455073fd9f1d08debsalomon    bool readPixelsSupported(GrPixelConfig renderTargetConfig,
3027928ef613f11a3c97fd939090197b8ae2be44b7absalomon                             GrPixelConfig readConfig,
3031aa202935ff698f1f35c5435455073fd9f1d08debsalomon                             std::function<void (GrGLenum, GrGLint*)> getIntegerv,
3041aa202935ff698f1f35c5435455073fd9f1d08debsalomon                             std::function<bool ()> bindRenderTarget) const;
305631cdcb4a6b926b6447f328b81911a4499fb3698skia.committer@gmail.com
3062b1b8c083b969a2a798b03d1754a3fc99ea054dfbsalomon@google.com    bool isCoreProfile() const { return fIsCoreProfile; }
3071d89c93b2a61a9679f444b19b6fce4325ae7df65robertphillips@google.com
308c1f56b518218d1caa65d6b7101bebf0d28c02a92joshualitt    bool bindFragDataLocationSupport() const { return fBindFragDataLocationSupport; }
309c1f56b518218d1caa65d6b7101bebf0d28c02a92joshualitt
3107bdd70ab9162980f3173c98c48234f9f345665a3joshualitt    bool bindUniformLocationSupport() const { return fBindUniformLocationSupport; }
3117bdd70ab9162980f3173c98c48234f9f345665a3joshualitt
3127ea33f5e1ae9eb1fb1e7377d6edf6acdcf71d103bsalomon    /// Are textures with GL_TEXTURE_EXTERNAL_OES type supported.
3137ea33f5e1ae9eb1fb1e7377d6edf6acdcf71d103bsalomon    bool externalTextureSupport() const { return fExternalTextureSupport; }
3147ea33f5e1ae9eb1fb1e7377d6edf6acdcf71d103bsalomon
315e5286e0b37abe4d0db67a6b3d87b2d5a12a70ab3bsalomon    /// Are textures with GL_TEXTURE_RECTANGLE type supported.
316e5286e0b37abe4d0db67a6b3d87b2d5a12a70ab3bsalomon    bool rectangleTextureSupport() const { return fRectangleTextureSupport; }
317e5286e0b37abe4d0db67a6b3d87b2d5a12a70ab3bsalomon
318cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon    /// GL_ARB_texture_swizzle
319cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon    bool textureSwizzleSupport() const { return fTextureSwizzleSupport; }
320cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon
321160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    /**
32216921ec30a81976129d507b1148c93a322e61a4fbsalomon     * Is there support for enabling/disabling sRGB writes for sRGB-capable color attachments?
32316921ec30a81976129d507b1148c93a322e61a4fbsalomon     * If false this does not mean sRGB is not supported but rather that if it is supported
32416921ec30a81976129d507b1148c93a322e61a4fbsalomon     * it cannot be turned off for configs that support it.
32516921ec30a81976129d507b1148c93a322e61a4fbsalomon     */
32616921ec30a81976129d507b1148c93a322e61a4fbsalomon    bool srgbWriteControl() const { return fSRGBWriteControl; }
32716921ec30a81976129d507b1148c93a322e61a4fbsalomon
32816921ec30a81976129d507b1148c93a322e61a4fbsalomon    /**
329160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org     * Returns a string containing the caps info.
330160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org     */
33136352bf5e38f45a70ee4f4fc132a38048d38206dmtklein    SkString dump() const override;
332beb8b3a4da83ce30e313e72ae0e444870acecb7ecommit-bot@chromium.org
33388c7b988ba7792e51e741567426069cd9cc852ddbsalomon    bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; }
33488c7b988ba7792e51e741567426069cd9cc852ddbsalomon    bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; }
33588c7b988ba7792e51e741567426069cd9cc852ddbsalomon
336f529439fea003851d986a0573a7e0465754b2a48egdaniel    const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
337e9c0fc616d2a1632c285885b9b656b68ca8d4f24jvanverth
338f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.comprivate:
33976148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    enum ExternalFormatUsage {
34076148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        kTexImage_ExternalFormatUsage,
34176148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        kOther_ExternalFormatUsage,
34276148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon
34376148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        kLast_ExternalFormatUsage = kOther_ExternalFormatUsage
34476148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    };
34576148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1;
34676148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig,
34776148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon                           ExternalFormatUsage usage, GrGLenum* externalFormat,
34876148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon                           GrGLenum* externalType) const;
34976148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon
3504cd6713af1c699b79e04b590109768300faee531cdalton    void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*);
35105ded891272772d43acc16345b2f90a4560df090egdaniel    void initGLSL(const GrGLContextInfo&);
352cfe62e30848eadead4358b0385e57723779b762bkkinnunen    bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*);
353424cc26add7ed491c6941d0c0c3a0e6d83190307bsalomon
354b7e7d5748d74c7482436b33733d7770484bb62e3egdaniel    void onApplyOptionsOverrides(const GrContextOptions& options) override;
355b7e7d5748d74c7482436b33733d7770484bb62e3egdaniel
3567388051d745590d7759e7ed49c233caec6bea0f7commit-bot@chromium.org    void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*);
3571dd0542ca37cf1b4a2ab0ea41f8009ded097fd47cdalton    void initBlendEqationSupport(const GrGLContextInfo&);
3587388051d745590d7759e7ed49c233caec6bea0f7commit-bot@chromium.org    void initStencilFormats(const GrGLContextInfo&);
3596b7938f9cb250086a7c6325cf31576f894ca4a1bcommit-bot@chromium.org    // This must be called after initFSAASupport().
360cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon    void initConfigTable(const GrGLContextInfo&, const GrGLInterface* gli, GrGLSLCaps* glslCaps);
36142dc8136914ee0777bb9110a5e04a75016687c0dcommit-bot@chromium.org
362cba99b88fd5fb39def7a094dc32c0745c7a1cfeajvanverth    void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
363cba99b88fd5fb39def7a094dc32c0745c7a1cfeajvanverth                                  const GrGLInterface* intf,
364cba99b88fd5fb39def7a094dc32c0745c7a1cfeajvanverth                                  GrGLSLCaps* glslCaps);
365cba99b88fd5fb39def7a094dc32c0745c7a1cfeajvanverth
3661aa202935ff698f1f35c5435455073fd9f1d08debsalomon    GrGLStandard fStandard;
3671aa202935ff698f1f35c5435455073fd9f1d08debsalomon
368f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    SkTArray<StencilFormat, true> fStencilFormats;
369f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
370f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    int fMaxFragmentUniformVectors;
37160da4176425c74cf112d7e116f54a530a82d0d68bsalomon@google.com    int fMaxVertexAttributes;
372a15f7e5b96ee3d71fdbcb4f9cf02f6a09b4b11accommit-bot@chromium.org    int fMaxFragmentTextureUnits;
37360da4176425c74cf112d7e116f54a530a82d0d68bsalomon@google.com
37452ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org    MSFBOType           fMSFBOType;
37552ffbf6be05eb30671529ec86268967fb85c9810commit-bot@chromium.org    InvalidateFBType    fInvalidateFBType;
376160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    MapBufferType       fMapBufferType;
377d7a2c1f5fd710581d6233de5c202d3f2627948e0jvanverth    TransferBufferType  fTransferBufferType;
3786b0cf0273fdffbbdf69235b57b5b5a311e7f1ca6bsalomon@google.com
379f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool fUnpackRowLengthSupport : 1;
380f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool fUnpackFlipYSupport : 1;
381f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool fPackRowLengthSupport : 1;
382f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool fPackFlipYSupport : 1;
383f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool fTextureUsageSupport : 1;
384f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com    bool fTexStorageSupport : 1;
385443e5a52b7e85070c26a068cd3b0aad126502395robertphillips@google.com    bool fTextureRedSupport : 1;
386e76b7ccb860b7ffcd86a42af8eecfe30f96493fabsalomon@google.com    bool fImagingSupport  : 1;
38707631cf14e22e772f901baf68545ee48c3d1e014bsalomon@google.com    bool fVertexArrayObjectSupport : 1;
388626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton    bool fDirectStateAccessSupport : 1;
389626e1ffe84c24a969dc56ca70ab2e950bf5034c4cdalton    bool fDebugSupport : 1;
3903f801cbb67895fa9fa29498aa017a7666960a627jvanverth    bool fES2CompatibilitySupport : 1;
391d472792a72c0c433a205d42a73e0b77d65f8d76fcdalton    bool fMultisampleDisableSupport : 1;
39206604b95622359640a1c2028b885646deda28d52cdalton    bool fDrawIndirectSupport : 1;
39306604b95622359640a1c2028b885646deda28d52cdalton    bool fMultiDrawIndirectSupport : 1;
39406604b95622359640a1c2028b885646deda28d52cdalton    bool fBaseInstanceSupport : 1;
39596966a5a1ffc2f03eef1b5523308299aa4195f50bsalomon@google.com    bool fUseNonVBOVertexAndIndexDynamicData : 1;
3962b1b8c083b969a2a798b03d1754a3fc99ea054dfbsalomon@google.com    bool fIsCoreProfile : 1;
397c1f56b518218d1caa65d6b7101bebf0d28c02a92joshualitt    bool fBindFragDataLocationSupport : 1;
39816921ec30a81976129d507b1148c93a322e61a4fbsalomon    bool fSRGBWriteControl : 1;
39988c7b988ba7792e51e741567426069cd9cc852ddbsalomon    bool fRGBA8888PixelsOpsAreSlow : 1;
40088c7b988ba7792e51e741567426069cd9cc852ddbsalomon    bool fPartialFBOReadIsSlow : 1;
4017bdd70ab9162980f3173c98c48234f9f345665a3joshualitt    bool fBindUniformLocationSupport : 1;
4027ea33f5e1ae9eb1fb1e7377d6edf6acdcf71d103bsalomon    bool fExternalTextureSupport : 1;
403e5286e0b37abe4d0db67a6b3d87b2d5a12a70ab3bsalomon    bool fRectangleTextureSupport : 1;
404cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon    bool fTextureSwizzleSupport : 1;
4055816233d237e5c214f14f1c92eda4a87c898ea11joshualitt
4067928ef613f11a3c97fd939090197b8ae2be44b7absalomon    /** Number type of the components (with out considering number of bits.) */
4077928ef613f11a3c97fd939090197b8ae2be44b7absalomon    enum FormatType {
4087928ef613f11a3c97fd939090197b8ae2be44b7absalomon        kNormalizedFixedPoint_FormatType,
4097928ef613f11a3c97fd939090197b8ae2be44b7absalomon        kFloat_FormatType,
4107928ef613f11a3c97fd939090197b8ae2be44b7absalomon    };
4117928ef613f11a3c97fd939090197b8ae2be44b7absalomon
4127928ef613f11a3c97fd939090197b8ae2be44b7absalomon    struct ReadPixelsFormat {
4137928ef613f11a3c97fd939090197b8ae2be44b7absalomon        ReadPixelsFormat() : fFormat(0), fType(0) {}
4147928ef613f11a3c97fd939090197b8ae2be44b7absalomon        GrGLenum fFormat;
4157928ef613f11a3c97fd939090197b8ae2be44b7absalomon        GrGLenum fType;
4167928ef613f11a3c97fd939090197b8ae2be44b7absalomon    };
4177928ef613f11a3c97fd939090197b8ae2be44b7absalomon
41876148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    struct ConfigFormats {
41976148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        ConfigFormats() {
42076148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon            // Inits to known bad GL enum values.
42176148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon            memset(this, 0xAB, sizeof(ConfigFormats));
42276148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        }
42376148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        GrGLenum fBaseInternalFormat;
42476148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        GrGLenum fSizedInternalFormat;
42576148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon
42676148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        /** The external format and type are to be used when uploading/downloading data using this
42776148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon            config where both the CPU data and GrSurface are the same config. To get the external
42876148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon            format and type when converting between configs while copying to/from memory use
42976148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon            getExternalFormat().
43076148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon            The kTexImage external format is usually the same as kOther except for kSRGBA on some
43176148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon            GL contexts. */
43276148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        GrGLenum fExternalFormat[kExternalFormatUsageCnt];
43376148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        GrGLenum fExternalType;
43476148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon
43576148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon
43676148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        // Either the base or sized internal format depending on the GL and config.
43776148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        GrGLenum fInternalFormatTexImage;
43876148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon        GrGLenum fInternalFormatRenderbuffer;
43976148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon    };
44076148af6df1f8da67cbed13b4d8216b36a41b3ddbsalomon
441304473749db1ee877addb3ddf090d2e36ede2c2absalomon    struct ConfigInfo {
4427928ef613f11a3c97fd939090197b8ae2be44b7absalomon        ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {}
443304473749db1ee877addb3ddf090d2e36ede2c2absalomon
444304473749db1ee877addb3ddf090d2e36ede2c2absalomon        ConfigFormats fFormats;
445304473749db1ee877addb3ddf090d2e36ede2c2absalomon
4467928ef613f11a3c97fd939090197b8ae2be44b7absalomon        FormatType fFormatType;
4477928ef613f11a3c97fd939090197b8ae2be44b7absalomon
4487928ef613f11a3c97fd939090197b8ae2be44b7absalomon        // On ES contexts there are restrictions on type type/format that may be used for
4497928ef613f11a3c97fd939090197b8ae2be44b7absalomon        // ReadPixels. One is implicitly specified by the current FBO's format. The other is
4507928ef613f11a3c97fd939090197b8ae2be44b7absalomon        // queryable. This stores the queried option (lazily).
4517928ef613f11a3c97fd939090197b8ae2be44b7absalomon        ReadPixelsFormat fSecondReadPixelsFormat;
4527928ef613f11a3c97fd939090197b8ae2be44b7absalomon
453304473749db1ee877addb3ddf090d2e36ede2c2absalomon        enum {
454304473749db1ee877addb3ddf090d2e36ede2c2absalomon            // This indicates that a stencil format has not yet been determined for the config.
455304473749db1ee877addb3ddf090d2e36ede2c2absalomon            kUnknown_StencilIndex = -1,
456304473749db1ee877addb3ddf090d2e36ede2c2absalomon            // This indicates that there is no supported stencil format for the config.
457304473749db1ee877addb3ddf090d2e36ede2c2absalomon            kUnsupported_StencilFormatIndex = -2
458304473749db1ee877addb3ddf090d2e36ede2c2absalomon        };
459480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon
460480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon        // Index fStencilFormats.
461480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon        int      fStencilFormatIndex;
462480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon
463480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon        enum {
46441e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon            kVerifiedColorAttachment_Flag = 0x1,
46541e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon            kTextureable_Flag             = 0x2,
46641e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon            kRenderable_Flag              = 0x4,
46741e4384ea0208631ab7847266c3369b17ed7fbf3bsalomon            kRenderableWithMSAA_Flag      = 0x8,
468480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon        };
469480e8c0b9e1f84273ed242652e7246948bb4e0dcbsalomon        uint32_t fFlags;
470cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon
471cdee009886babe6df7743a9b5b3e2cc0a5f21adfbsalomon        GrSwizzle fSwizzle;
472304473749db1ee877addb3ddf090d2e36ede2c2absalomon    };
473304473749db1ee877addb3ddf090d2e36ede2c2absalomon
474304473749db1ee877addb3ddf090d2e36ede2c2absalomon    ConfigInfo fConfigTable[kGrPixelConfigCnt];
475304473749db1ee877addb3ddf090d2e36ede2c2absalomon
4764b91f768b348aa1cebeb54f3ff9331938734c242bsalomon    typedef GrCaps INHERITED;
477f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com};
478f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com
479f7fa806d84abf1cba47bfa8679e875a75d76599ebsalomon@google.com#endif
480