DebugGLTestContext.cpp revision 160b478eed1dd4924a86a87fd60c91139e08ff71
10da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
20da3719050473344b6013fd7b614611984f20effrobertphillips@google.com/*
30da3719050473344b6013fd7b614611984f20effrobertphillips@google.com * Copyright 2012 Google Inc.
40da3719050473344b6013fd7b614611984f20effrobertphillips@google.com *
50da3719050473344b6013fd7b614611984f20effrobertphillips@google.com * Use of this source code is governed by a BSD-style license that can be
60da3719050473344b6013fd7b614611984f20effrobertphillips@google.com * found in the LICENSE file.
70da3719050473344b6013fd7b614611984f20effrobertphillips@google.com */
80da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
90da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
100da3719050473344b6013fd7b614611984f20effrobertphillips@google.com#include "gl/GrGLInterface.h"
11dd743fefad9764ad86d7f69deec32e9a3b5de47frobertphillips@google.com#include "GrDebugGL.h"
12dd743fefad9764ad86d7f69deec32e9a3b5de47frobertphillips@google.com#include "GrShaderObj.h"
13dd743fefad9764ad86d7f69deec32e9a3b5de47frobertphillips@google.com#include "GrProgramObj.h"
14dd743fefad9764ad86d7f69deec32e9a3b5de47frobertphillips@google.com#include "GrBufferObj.h"
15dd743fefad9764ad86d7f69deec32e9a3b5de47frobertphillips@google.com#include "GrTextureUnitObj.h"
16dd743fefad9764ad86d7f69deec32e9a3b5de47frobertphillips@google.com#include "GrTextureObj.h"
17dd743fefad9764ad86d7f69deec32e9a3b5de47frobertphillips@google.com#include "GrFrameBufferObj.h"
18dd743fefad9764ad86d7f69deec32e9a3b5de47frobertphillips@google.com#include "GrRenderBufferObj.h"
19ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com#include "GrVertexArrayObj.h"
20670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com#include "SkFloatingPoint.h"
218f9436161a83ea89818a486db1577e24ad33ec7bbsalomon@google.com#include "../GrGLNoOpInterface.h"
220da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
238f9436161a83ea89818a486db1577e24ad33ec7bbsalomon@google.comnamespace { // suppress no previous prototype warning
24cf6285b89b8820641ffb6871d4b3275bfe783f51caryclark@google.com
250da3719050473344b6013fd7b614611984f20effrobertphillips@google.com////////////////////////////////////////////////////////////////////////////////
26f6f123d23608a4a5fe9c812d2452039a18da7e0brobertphillips@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLActiveTexture(GrGLenum texture) {
27fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
28ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    // Ganesh offsets the texture unit indices
29ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    texture -= GR_GL_TEXTURE0;
30ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    GrAlwaysAssert(texture < GrDebugGL::getInstance()->getMaxTextureUnits());
310da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
320da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrDebugGL::getInstance()->setCurTextureUnit(texture);
330da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
340da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
350da3719050473344b6013fd7b614611984f20effrobertphillips@google.com////////////////////////////////////////////////////////////////////////////////
36fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLAttachShader(GrGLuint programID,
37ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                 GrGLuint shaderID) {
38ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
39fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrProgramObj *program = GR_FIND(programID, GrProgramObj,
40ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                    GrDebugGL::kProgram_ObjTypes);
410da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrAlwaysAssert(program);
420da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
43fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrShaderObj *shader = GR_FIND(shaderID,
44fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                  GrShaderObj,
45ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                  GrDebugGL::kShader_ObjTypes);
460da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrAlwaysAssert(shader);
470da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
480da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    program->AttachShader(shader);
490da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
500da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
51ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLBeginQuery(GrGLenum target, GrGLuint id) {
52ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com}
53ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
54fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLBindAttribLocation(GrGLuint program,
55fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                                       GrGLuint index,
56ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                       const char* name) {
57ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com}
58ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
59ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com////////////////////////////////////////////////////////////////////////////////
60fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLBindTexture(GrGLenum target,
61ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                GrGLuint textureID) {
62ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
63ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    // we don't use cube maps
64fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrAlwaysAssert(target == GR_GL_TEXTURE_2D);
65ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                    // || target == GR_GL_TEXTURE_CUBE_MAP);
66ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
67ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    // a textureID of 0 is acceptable - it binds to the default texture target
68fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrTextureObj *texture = GR_FIND(textureID, GrTextureObj,
69ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                    GrDebugGL::kTexture_ObjTypes);
70ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
71ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    GrDebugGL::getInstance()->setTexture(texture);
72ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com}
73ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
740da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
750da3719050473344b6013fd7b614611984f20effrobertphillips@google.com////////////////////////////////////////////////////////////////////////////////
76fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLBufferData(GrGLenum target,
77fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                               GrGLsizeiptr size,
78fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                               const GrGLvoid* data,
79409566a17d7aa898f1753e5d1734324a1330d7c3robertphillips@google.com                                               GrGLenum usage) {
80fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
81ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                   GR_GL_ELEMENT_ARRAY_BUFFER == target);
820da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrAlwaysAssert(size >= 0);
83fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrAlwaysAssert(GR_GL_STREAM_DRAW == usage ||
84fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                   GR_GL_STATIC_DRAW == usage ||
85ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                   GR_GL_DYNAMIC_DRAW == usage);
860da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
870da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrBufferObj *buffer = NULL;
880da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    switch (target) {
890da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_ARRAY_BUFFER:
900da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            buffer = GrDebugGL::getInstance()->getArrayBuffer();
910da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
920da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_ELEMENT_ARRAY_BUFFER:
930da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
940da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
950da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        default:
9688cb22b6b4816c7a9ca6c5b795965b4606f9eb7bcommit-bot@chromium.org            SkFAIL("Unexpected target to glBufferData");
970da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
980da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
990da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
1000da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrAlwaysAssert(buffer);
1010da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrAlwaysAssert(buffer->getBound());
1020da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
103f6f123d23608a4a5fe9c812d2452039a18da7e0brobertphillips@google.com    buffer->allocate(size, reinterpret_cast<const GrGLchar *>(data));
1040da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    buffer->setUsage(usage);
1050da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
1060da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
107ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
108fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLPixelStorei(GrGLenum pname,
109ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                GrGLint param) {
110670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com
111670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    switch (pname) {
112670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        case GR_GL_UNPACK_ROW_LENGTH:
113670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            GrDebugGL::getInstance()->setUnPackRowLength(param);
114670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            break;
115670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        case GR_GL_PACK_ROW_LENGTH:
116670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            GrDebugGL::getInstance()->setPackRowLength(param);
117670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            break;
118670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        case GR_GL_UNPACK_ALIGNMENT:
119670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            break;
120670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        case GR_GL_PACK_ALIGNMENT:
121670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            GrAlwaysAssert(false);
122670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            break;
123670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        default:
124670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            GrAlwaysAssert(false);
125670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            break;
126670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    }
127670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com}
128ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
129fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLReadPixels(GrGLint x,
130fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                               GrGLint y,
131fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                               GrGLsizei width,
132fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                               GrGLsizei height,
133fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                               GrGLenum format,
134fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                               GrGLenum type,
135670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com                                               GrGLvoid* pixels) {
136670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com
137670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    GrGLint pixelsInRow = width;
138670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    if (0 < GrDebugGL::getInstance()->getPackRowLength()) {
139670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        pixelsInRow = GrDebugGL::getInstance()->getPackRowLength();
140670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    }
141670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com
142670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    GrGLint componentsPerPixel = 0;
143670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com
144670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    switch (format) {
145670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        case GR_GL_RGBA:
146670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            // fallthrough
147670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        case GR_GL_BGRA:
148670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            componentsPerPixel = 4;
149670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            break;
150670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        case GR_GL_RGB:
151670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            componentsPerPixel = 3;
152670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            break;
153d32369e745d760f76a18dbd027ece4a97f28b4d5robertphillips@google.com        case GR_GL_RED:
154d32369e745d760f76a18dbd027ece4a97f28b4d5robertphillips@google.com            componentsPerPixel = 1;
155d32369e745d760f76a18dbd027ece4a97f28b4d5robertphillips@google.com            break;
156670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        default:
157670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            GrAlwaysAssert(false);
158670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            break;
159670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    }
160670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com
161670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    GrGLint alignment = 4;  // the pack alignment (one of 1, 2, 4 or 8)
162670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    // Ganesh currently doesn't support setting GR_GL_PACK_ALIGNMENT
163670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com
164670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    GrGLint componentSize = 0;  // size (in bytes) of a single component
165670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com
166670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    switch (type) {
167670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        case GR_GL_UNSIGNED_BYTE:
168670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            componentSize = 1;
169670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            break;
170670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        default:
171670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            GrAlwaysAssert(false);
172670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com            break;
173670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    }
174670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com
175670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    GrGLint rowStride = 0;  // number of components (not bytes) to skip
176670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    if (componentSize >= alignment) {
177670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        rowStride = componentsPerPixel * pixelsInRow;
178670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    } else {
179fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        float fTemp =
180fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            sk_float_ceil(componentSize * componentsPerPixel * pixelsInRow /
181670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com                          static_cast<float>(alignment));
182670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        rowStride = static_cast<GrGLint>(alignment * fTemp / componentSize);
183670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    }
184670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com
185670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    GrGLchar *scanline = static_cast<GrGLchar *>(pixels);
186670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    for (int y = 0; y < height; ++y) {
187670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        memset(scanline, 0, componentsPerPixel * componentSize * width);
188670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com        scanline += rowStride;
189670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com    }
190670ff9ae7f37356bff08b30a356bb0c52dc8d62erobertphillips@google.com}
191f6f123d23608a4a5fe9c812d2452039a18da7e0brobertphillips@google.com
192ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com GrGLvoid GR_GL_FUNCTION_TYPE debugGLUseProgram(GrGLuint programID) {
193ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
194ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // A programID of 0 is legal
195fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     GrProgramObj *program = GR_FIND(programID,
196fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                     GrProgramObj,
197ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                     GrDebugGL::kProgram_ObjTypes);
198ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
199ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrDebugGL::getInstance()->useProgram(program);
200ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com }
201ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
202fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindFramebuffer(GrGLenum target,
203ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                     GrGLuint frameBufferID) {
204ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
20531975cf8f52c3b7020249cccd367f82761c2d15brobertphillips@google.com     GrAlwaysAssert(GR_GL_FRAMEBUFFER == target ||
20631975cf8f52c3b7020249cccd367f82761c2d15brobertphillips@google.com                    GR_GL_READ_FRAMEBUFFER == target ||
20731975cf8f52c3b7020249cccd367f82761c2d15brobertphillips@google.com                    GR_GL_DRAW_FRAMEBUFFER);
208ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
209fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     // a frameBufferID of 0 is acceptable - it binds to the default
210ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // frame buffer
211fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     GrFrameBufferObj *frameBuffer = GR_FIND(frameBufferID,
212fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                             GrFrameBufferObj,
213ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                             GrDebugGL::kFrameBuffer_ObjTypes);
214ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
215ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrDebugGL::getInstance()->setFrameBuffer(frameBuffer);
216ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com }
217ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
218ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com GrGLvoid GR_GL_FUNCTION_TYPE debugGLBindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) {
219ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
220ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
221ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
222ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // a renderBufferID of 0 is acceptable - it unbinds the bound render buffer
223fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     GrRenderBufferObj *renderBuffer = GR_FIND(renderBufferID,
224fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                               GrRenderBufferObj,
225ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                               GrDebugGL::kRenderBuffer_ObjTypes);
226ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
227ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrDebugGL::getInstance()->setRenderBuffer(renderBuffer);
228ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com }
229ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
230ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteTextures(GrGLsizei n, const GrGLuint* textures) {
231ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
232ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // first potentially unbind the texture
233ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // TODO: move this into GrDebugGL as unBindTexture?
234fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     for (unsigned int i = 0;
235fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com          i < GrDebugGL::getInstance()->getMaxTextureUnits();
236ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com          ++i) {
237ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrTextureUnitObj *pTU = GrDebugGL::getInstance()->getTextureUnit(i);
238ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
239ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         if (pTU->getTexture()) {
240ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com             for (int j = 0; j < n; ++j) {
241ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
242ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 if (textures[j] == pTU->getTexture()->getID()) {
243ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                     // this ID is the current texture - revert the binding to 0
244ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                     pTU->setTexture(NULL);
245ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 }
246ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com             }
247ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         }
248ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     }
249ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
250ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // TODO: fuse the following block with DeleteRenderBuffers?
251fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     // Open GL will remove a deleted render buffer from the active
252ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // frame buffer but not from any other frame buffer
253ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     if (GrDebugGL::getInstance()->getFrameBuffer()) {
254ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
255ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrFrameBufferObj *frameBuffer = GrDebugGL::getInstance()->getFrameBuffer();
256ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
257ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         for (int i = 0; i < n; ++i) {
258ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
259fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com             if (NULL != frameBuffer->getColor() &&
260ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 textures[i] == frameBuffer->getColor()->getID()) {
261ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 frameBuffer->setColor(NULL);
262fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com             }
263fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com             if (NULL != frameBuffer->getDepth() &&
264ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 textures[i] == frameBuffer->getDepth()->getID()) {
265ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 frameBuffer->setDepth(NULL);
266ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com             }
267fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com             if (NULL != frameBuffer->getStencil() &&
268ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 textures[i] == frameBuffer->getStencil()->getID()) {
269ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 frameBuffer->setStencil(NULL);
270ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com             }
271ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         }
272ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     }
273ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
274ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // then actually "delete" the buffers
275ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     for (int i = 0; i < n; ++i) {
276fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         GrTextureObj *buffer = GR_FIND(textures[i],
277fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                        GrTextureObj,
278ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                        GrDebugGL::kTexture_ObjTypes);
279ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(buffer);
280ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
281ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         // OpenGL gives no guarantees if a texture is deleted while attached to
282ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         // something other than the currently bound frame buffer
283ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(!buffer->getBound());
284ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
285ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(!buffer->getDeleted());
286ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         buffer->deleteAction();
287ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     }
288ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
289ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com }
290ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
291fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteFramebuffers(GrGLsizei n,
292ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                        const GrGLuint *frameBuffers) {
293ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
294ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // first potentially unbind the buffers
295ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     if (GrDebugGL::getInstance()->getFrameBuffer()) {
296ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         for (int i = 0; i < n; ++i) {
297ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
298fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com             if (frameBuffers[i] ==
299ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 GrDebugGL::getInstance()->getFrameBuffer()->getID()) {
300ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 // this ID is the current frame buffer - rebind to the default
301ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 GrDebugGL::getInstance()->setFrameBuffer(NULL);
302ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com             }
303ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         }
304ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     }
305ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
306ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // then actually "delete" the buffers
307ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     for (int i = 0; i < n; ++i) {
308fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         GrFrameBufferObj *buffer = GR_FIND(frameBuffers[i],
309fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                            GrFrameBufferObj,
310ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                            GrDebugGL::kFrameBuffer_ObjTypes);
311ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(buffer);
312ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
313ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(!buffer->getDeleted());
314ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         buffer->deleteAction();
315ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     }
316ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com }
317ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
318fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com GrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteRenderbuffers(GrGLsizei n,
319ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                         const GrGLuint *renderBuffers) {
320ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
321ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // first potentially unbind the buffers
322ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     if (GrDebugGL::getInstance()->getRenderBuffer()) {
323ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         for (int i = 0; i < n; ++i) {
324ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
325fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com             if (renderBuffers[i] ==
326ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 GrDebugGL::getInstance()->getRenderBuffer()->getID()) {
327fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                 // this ID is the current render buffer - make no
328ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 // render buffer be bound
329ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 GrDebugGL::getInstance()->setRenderBuffer(NULL);
330ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com             }
331ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         }
332ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     }
333ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
334ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // TODO: fuse the following block with DeleteTextures?
335fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     // Open GL will remove a deleted render buffer from the active frame
336ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // buffer but not from any other frame buffer
337ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     if (GrDebugGL::getInstance()->getFrameBuffer()) {
338ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
339fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         GrFrameBufferObj *frameBuffer =
340ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                               GrDebugGL::getInstance()->getFrameBuffer();
341ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
342ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         for (int i = 0; i < n; ++i) {
343ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
344fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com             if (NULL != frameBuffer->getColor() &&
345ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 renderBuffers[i] == frameBuffer->getColor()->getID()) {
346ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 frameBuffer->setColor(NULL);
347fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com             }
348fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com             if (NULL != frameBuffer->getDepth() &&
349ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 renderBuffers[i] == frameBuffer->getDepth()->getID()) {
350ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 frameBuffer->setDepth(NULL);
351ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com             }
352fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com             if (NULL != frameBuffer->getStencil() &&
353ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 renderBuffers[i] == frameBuffer->getStencil()->getID()) {
354ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                 frameBuffer->setStencil(NULL);
355ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com             }
356ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         }
357ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     }
358ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
359ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // then actually "delete" the buffers
360ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     for (int i = 0; i < n; ++i) {
361fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         GrRenderBufferObj *buffer = GR_FIND(renderBuffers[i],
362fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                             GrRenderBufferObj,
363ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                             GrDebugGL::kRenderBuffer_ObjTypes);
364ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(buffer);
365ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
366fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         // OpenGL gives no guarantees if a render buffer is deleted
367fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         // while attached to something other than the currently
368ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         // bound frame buffer
369ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(!buffer->getColorBound());
370ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(!buffer->getDepthBound());
3711308f6e6dd2786695c2e8c5d5781b045b7058493commit-bot@chromium.org         // However, at GrContext destroy time we release all GrRsources and so stencil buffers
3721308f6e6dd2786695c2e8c5d5781b045b7058493commit-bot@chromium.org         // may get deleted before FBOs that refer to them.
3731308f6e6dd2786695c2e8c5d5781b045b7058493commit-bot@chromium.org         //GrAlwaysAssert(!buffer->getStencilBound());
374ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
375ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(!buffer->getDeleted());
376ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         buffer->deleteAction();
377ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     }
378ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com }
379ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
380fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferRenderbuffer(GrGLenum target,
381fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                                             GrGLenum attachment,
382fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                                             GrGLenum renderbuffertarget,
383ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                             GrGLuint renderBufferID) {
384ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
385ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
386fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
387fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                    GR_GL_DEPTH_ATTACHMENT == attachment ||
388ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                    GR_GL_STENCIL_ATTACHMENT == attachment);
389ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget);
390ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
391ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer();
392ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // A render buffer cannot be attached to the default framebuffer
393ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrAlwaysAssert(NULL != framebuffer);
394ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
395fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     // a renderBufferID of 0 is acceptable - it unbinds the current
396ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // render buffer
397fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     GrRenderBufferObj *renderbuffer = GR_FIND(renderBufferID,
398fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                               GrRenderBufferObj,
399ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                               GrDebugGL::kRenderBuffer_ObjTypes);
400ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
401ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     switch (attachment) {
402ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     case GR_GL_COLOR_ATTACHMENT0:
403ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         framebuffer->setColor(renderbuffer);
404ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         break;
405ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     case GR_GL_DEPTH_ATTACHMENT:
406ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         framebuffer->setDepth(renderbuffer);
407ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         break;
408ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     case GR_GL_STENCIL_ATTACHMENT:
409ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         framebuffer->setStencil(renderbuffer);
410ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         break;
411ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     default:
412ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(false);
413ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         break;
414ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     };
415ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
416ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com }
417ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
418ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com ////////////////////////////////////////////////////////////////////////////////
419fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com GrGLvoid GR_GL_FUNCTION_TYPE debugGLFramebufferTexture2D(GrGLenum target,
420fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                                          GrGLenum attachment,
421fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                                          GrGLenum textarget,
422fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                                          GrGLuint textureID,
423ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                          GrGLint level) {
424ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
425ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
426fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
427fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                    GR_GL_DEPTH_ATTACHMENT == attachment ||
428ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                    GR_GL_STENCIL_ATTACHMENT == attachment);
429ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget);
430ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
431ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrFrameBufferObj *framebuffer = GrDebugGL::getInstance()->getFrameBuffer();
432ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // A texture cannot be attached to the default framebuffer
433ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrAlwaysAssert(NULL != framebuffer);
434ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
435ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     // A textureID of 0 is allowed - it unbinds the currently bound texture
436fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     GrTextureObj *texture = GR_FIND(textureID, GrTextureObj,
437ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                     GrDebugGL::kTexture_ObjTypes);
438ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     if (texture) {
439fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com         // The texture shouldn't be bound to a texture unit - this
440ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         // could lead to a feedback loop
441ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(!texture->getBound());
442ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     }
443ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
444ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     GrAlwaysAssert(0 == level);
445ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
446ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     switch (attachment) {
447ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     case GR_GL_COLOR_ATTACHMENT0:
448ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         framebuffer->setColor(texture);
449ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         break;
450ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     case GR_GL_DEPTH_ATTACHMENT:
451ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         framebuffer->setDepth(texture);
452ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         break;
453ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     case GR_GL_STENCIL_ATTACHMENT:
454ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         framebuffer->setStencil(texture);
455ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         break;
456ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     default:
457ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         GrAlwaysAssert(false);
458ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com         break;
459ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com     };
460ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com }
461ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com
4620da3719050473344b6013fd7b614611984f20effrobertphillips@google.comGrGLuint GR_GL_FUNCTION_TYPE debugGLCreateProgram() {
4630da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
464fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrProgramObj *program = GR_CREATE(GrProgramObj,
465ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                      GrDebugGL::kProgram_ObjTypes);
4660da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
4670da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    return program->getID();
4680da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
4690da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
4700da3719050473344b6013fd7b614611984f20effrobertphillips@google.comGrGLuint GR_GL_FUNCTION_TYPE debugGLCreateShader(GrGLenum type) {
471fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
472fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrAlwaysAssert(GR_GL_VERTEX_SHADER == type ||
473ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                   GR_GL_FRAGMENT_SHADER == type);
4740da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
475ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    GrShaderObj *shader = GR_CREATE(GrShaderObj, GrDebugGL::kShader_ObjTypes);
476ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    shader->setType(type);
4770da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
4780da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    return shader->getID();
4790da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
4800da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
4810da3719050473344b6013fd7b614611984f20effrobertphillips@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteProgram(GrGLuint programID) {
4820da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
483fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrProgramObj *program = GR_FIND(programID,
484fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                    GrProgramObj,
485ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                    GrDebugGL::kProgram_ObjTypes);
4860da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrAlwaysAssert(program);
4870da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
4880da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    if (program->getRefCount()) {
4890da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        // someone is still using this program so we can't delete it here
4900da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        program->setMarkedForDeletion();
4910da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    } else {
4920da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        program->deleteAction();
4930da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
4940da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
4950da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
4960da3719050473344b6013fd7b614611984f20effrobertphillips@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteShader(GrGLuint shaderID) {
4970da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
498fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrShaderObj *shader = GR_FIND(shaderID,
499fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                  GrShaderObj,
500ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                  GrDebugGL::kShader_ObjTypes);
5010da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrAlwaysAssert(shader);
5020da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
5030da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    if (shader->getRefCount()) {
5040da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        // someone is still using this shader so we can't delete it here
5050da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        shader->setMarkedForDeletion();
5060da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    } else {
5070da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        shader->deleteAction();
5080da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
5090da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
5100da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
511fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.comGrGLvoid debugGenObjs(GrDebugGL::GrObjTypes type,
512fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                      GrGLsizei n,
513ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                      GrGLuint* ids) {
5140da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
515ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com   for (int i = 0; i < n; ++i) {
516ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com        GrFakeRefObj *obj = GrDebugGL::getInstance()->createObj(type);
517ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com        GrAlwaysAssert(obj);
518ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com        ids[i] = obj->getID();
5190da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
5200da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
5210da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
522ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLGenBuffers(GrGLsizei n, GrGLuint* ids) {
523ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    debugGenObjs(GrDebugGL::kBuffer_ObjTypes, n, ids);
524ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com}
525ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
526cffff79a40bd7672e13b31b9801a3f3cda64875ecommit-bot@chromium.orgGrGLvoid GR_GL_FUNCTION_TYPE debugGLGenerateMipmap(GrGLenum level) {
527cffff79a40bd7672e13b31b9801a3f3cda64875ecommit-bot@chromium.org}
528cffff79a40bd7672e13b31b9801a3f3cda64875ecommit-bot@chromium.org
529fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLGenFramebuffers(GrGLsizei n,
530ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                    GrGLuint* ids) {
531ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    debugGenObjs(GrDebugGL::kFrameBuffer_ObjTypes, n, ids);
532f6f123d23608a4a5fe9c812d2452039a18da7e0brobertphillips@google.com}
533f6f123d23608a4a5fe9c812d2452039a18da7e0brobertphillips@google.com
534fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLGenRenderbuffers(GrGLsizei n,
535ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                     GrGLuint* ids) {
536ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    debugGenObjs(GrDebugGL::kRenderBuffer_ObjTypes, n, ids);
537ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com}
538ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
539ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLGenTextures(GrGLsizei n, GrGLuint* ids) {
540b82c3993c2f753e5caaff2df9648ebdafc68595fbsalomon@google.com    debugGenObjs(GrDebugGL::kTexture_ObjTypes, n, ids);
54187c6d7a99ee7fee2dcc537a1ccad95fc5a9bd26bbsalomon@google.com}
54287c6d7a99ee7fee2dcc537a1ccad95fc5a9bd26bbsalomon@google.com
543ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLGenVertexArrays(GrGLsizei n, GrGLuint* ids) {
544ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    debugGenObjs(GrDebugGL::kVertexArray_ObjTypes, n, ids);
545ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com}
54687c6d7a99ee7fee2dcc537a1ccad95fc5a9bd26bbsalomon@google.com
547ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteVertexArrays(GrGLsizei n, const GrGLuint* ids) {
548ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    for (GrGLsizei i = 0; i < n; ++i) {
549ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        GrVertexArrayObj* array =
550ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            GR_FIND(ids[i], GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes);
551ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        GrAlwaysAssert(array);
552ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com
553ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        // Deleting the current vertex array binds object 0
554ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        if (GrDebugGL::getInstance()->getVertexArray() == array) {
555ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            GrDebugGL::getInstance()->setVertexArray(NULL);
556ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        }
557ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com
558ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        if (array->getRefCount()) {
559ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            // someone is still using this vertex array so we can't delete it here
560ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            array->setMarkedForDeletion();
561ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        } else {
562ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com            array->deleteAction();
563ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com        }
564ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    }
565ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com}
566ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com
567ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLBindVertexArray(GrGLuint id) {
568ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    GrVertexArrayObj* array = GR_FIND(id, GrVertexArrayObj, GrDebugGL::kVertexArray_ObjTypes);
5696918d482d64f045a4c980b2fb267bc939953638ebsalomon@google.com    GrAlwaysAssert((0 == id) || NULL != array);
570ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    GrDebugGL::getInstance()->setVertexArray(array);
571ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com}
572ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com
573ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLBindBuffer(GrGLenum target, GrGLuint bufferID) {
574ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.com    GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || GR_GL_ELEMENT_ARRAY_BUFFER == target);
5750da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
576fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrBufferObj *buffer = GR_FIND(bufferID,
577fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                  GrBufferObj,
578ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                  GrDebugGL::kBuffer_ObjTypes);
5798f9436161a83ea89818a486db1577e24ad33ec7bbsalomon@google.com    // 0 is a permissible bufferID - it unbinds the current buffer
5800da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
5810da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    switch (target) {
5820da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_ARRAY_BUFFER:
5830da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            GrDebugGL::getInstance()->setArrayBuffer(buffer);
5840da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
5850da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_ELEMENT_ARRAY_BUFFER:
5860da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            GrDebugGL::getInstance()->setElementArrayBuffer(buffer);
5870da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
5880da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        default:
58988cb22b6b4816c7a9ca6c5b795965b4606f9eb7bcommit-bot@chromium.org            SkFAIL("Unexpected target to glBindBuffer");
5900da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
5910da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
5920da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
5930da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
5940da3719050473344b6013fd7b614611984f20effrobertphillips@google.com// deleting a bound buffer has the side effect of binding 0
595ecd84842b3f65918eb040c53391172b6413fd7adbsalomon@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLDeleteBuffers(GrGLsizei n, const GrGLuint* ids) {
5960da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    // first potentially unbind the buffers
5970da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    for (int i = 0; i < n; ++i) {
5980da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
599fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        if (GrDebugGL::getInstance()->getArrayBuffer() &&
6000da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            ids[i] == GrDebugGL::getInstance()->getArrayBuffer()->getID()) {
6010da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            // this ID is the current array buffer
6020da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            GrDebugGL::getInstance()->setArrayBuffer(NULL);
6030da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        }
604fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        if (GrDebugGL::getInstance()->getElementArrayBuffer() &&
605fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            ids[i] ==
606ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                GrDebugGL::getInstance()->getElementArrayBuffer()->getID()) {
6070da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            // this ID is the current element array buffer
6080da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            GrDebugGL::getInstance()->setElementArrayBuffer(NULL);
6090da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        }
6100da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
6110da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
6120da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    // then actually "delete" the buffers
6130da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    for (int i = 0; i < n; ++i) {
614fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com        GrBufferObj *buffer = GR_FIND(ids[i],
615fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                      GrBufferObj,
616ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                      GrDebugGL::kBuffer_ObjTypes);
6170da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        GrAlwaysAssert(buffer);
6180da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
6190da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        GrAlwaysAssert(!buffer->getDeleted());
6200da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        buffer->deleteAction();
6210da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
6220da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
6230da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
6240da3719050473344b6013fd7b614611984f20effrobertphillips@google.com// map a buffer to the caller's address space
625160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.orgGrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBufferRange(GrGLenum target, GrGLintptr offset,
626160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org                                                    GrGLsizeiptr length, GrGLbitfield access) {
627fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
628ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                   GR_GL_ELEMENT_ARRAY_BUFFER == target);
629160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org
630160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    // We only expect read access and we expect that the buffer or range is always invalidated.
631160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    GrAlwaysAssert(!SkToBool(GR_GL_MAP_READ_BIT & access));
632160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    GrAlwaysAssert((GR_GL_MAP_INVALIDATE_BUFFER_BIT | GR_GL_MAP_INVALIDATE_RANGE_BIT) & access);
6330da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
6340da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrBufferObj *buffer = NULL;
6350da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    switch (target) {
6360da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_ARRAY_BUFFER:
6370da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            buffer = GrDebugGL::getInstance()->getArrayBuffer();
6380da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
6390da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_ELEMENT_ARRAY_BUFFER:
6400da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
6410da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
6420da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        default:
643160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            SkFAIL("Unexpected target to glMapBufferRange");
6440da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
6450da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
6460da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
647160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    if (NULL != buffer) {
648160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        GrAlwaysAssert(offset >= 0 && offset + length <= buffer->getSize());
6490da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        GrAlwaysAssert(!buffer->getMapped());
650160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        buffer->setMapped(offset, length);
651160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        return buffer->getDataPtr() + offset;
6520da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
6530da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
6540da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrAlwaysAssert(false);
6550da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    return NULL;        // no buffer bound to the target
6560da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
6570da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
658160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.orgGrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access) {
659160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    GrAlwaysAssert(GR_GL_WRITE_ONLY == access);
660160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org
661160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    GrBufferObj *buffer = NULL;
662160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    switch (target) {
663160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        case GR_GL_ARRAY_BUFFER:
664160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            buffer = GrDebugGL::getInstance()->getArrayBuffer();
665160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            break;
666160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        case GR_GL_ELEMENT_ARRAY_BUFFER:
667160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
668160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            break;
669160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        default:
670160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            SkFAIL("Unexpected target to glMapBuffer");
671160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            break;
672160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    }
673160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org
674160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    return debugGLMapBufferRange(target, 0, buffer->getSize(),
675160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org                                 GR_GL_MAP_WRITE_BIT | GR_GL_MAP_INVALIDATE_BUFFER_BIT);
676160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org}
677160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org
6780da3719050473344b6013fd7b614611984f20effrobertphillips@google.com// remove a buffer from the caller's address space
679fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com// TODO: check if the "access" method from "glMapBuffer" was honored
6800da3719050473344b6013fd7b614611984f20effrobertphillips@google.comGrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) {
6810da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
682fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
683ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                   GR_GL_ELEMENT_ARRAY_BUFFER == target);
6840da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
6850da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrBufferObj *buffer = NULL;
6860da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    switch (target) {
6870da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_ARRAY_BUFFER:
6880da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            buffer = GrDebugGL::getInstance()->getArrayBuffer();
6890da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
6900da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_ELEMENT_ARRAY_BUFFER:
6910da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
6920da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
6930da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        default:
69488cb22b6b4816c7a9ca6c5b795965b4606f9eb7bcommit-bot@chromium.org            SkFAIL("Unexpected target to glUnmapBuffer");
6950da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
6960da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
6970da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
698160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    if (NULL != buffer) {
6990da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        GrAlwaysAssert(buffer->getMapped());
7000da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        buffer->resetMapped();
7010da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        return GR_GL_TRUE;
7020da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
7030da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
7040da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrAlwaysAssert(false);
7050da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
7060da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
7070da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
708160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.orgGrGLvoid GR_GL_FUNCTION_TYPE debugGLFlushMappedBufferRange(GrGLenum target,
709160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org                                                           GrGLintptr offset,
710160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org                                                           GrGLsizeiptr length) {
711160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
712160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org                   GR_GL_ELEMENT_ARRAY_BUFFER == target);
713160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org
714160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    GrBufferObj *buffer = NULL;
715160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    switch (target) {
716160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        case GR_GL_ARRAY_BUFFER:
717160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            buffer = GrDebugGL::getInstance()->getArrayBuffer();
718160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            break;
719160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        case GR_GL_ELEMENT_ARRAY_BUFFER:
720160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
721160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            break;
722160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        default:
723160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            SkFAIL("Unexpected target to glUnmapBuffer");
724160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            break;
725160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    }
726160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org
727160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    if (NULL != buffer) {
728160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        GrAlwaysAssert(buffer->getMapped());
729160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        GrAlwaysAssert(offset >= 0 && (offset + length) <= buffer->getMappedLength());
730160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    } else {
731160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org        GrAlwaysAssert(false);
732160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    }
733160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org}
734160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org
735160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org
736fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.comGrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target,
737fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com                                                         GrGLenum value,
738ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                                                         GrGLint* params) {
7390da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
740fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
741ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                   GR_GL_ELEMENT_ARRAY_BUFFER == target);
742fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    GrAlwaysAssert(GR_GL_BUFFER_SIZE == value ||
743ebde3e0e74ccb82042b742dddb9b3cf877c82f6frobertphillips@google.com                   GR_GL_BUFFER_USAGE == value);
7440da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
7450da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrBufferObj *buffer = NULL;
7460da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    switch (target) {
7470da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_ARRAY_BUFFER:
7480da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            buffer = GrDebugGL::getInstance()->getArrayBuffer();
7490da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
7500da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_ELEMENT_ARRAY_BUFFER:
7510da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
752fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com            break;
7530da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
7540da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
7550da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    GrAlwaysAssert(buffer);
7560da3719050473344b6013fd7b614611984f20effrobertphillips@google.com
7570da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    switch (value) {
7580da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_BUFFER_MAPPED:
7590da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            *params = GR_GL_FALSE;
760160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            if (NULL != buffer)
7610da3719050473344b6013fd7b614611984f20effrobertphillips@google.com                *params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE;
7620da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
7630da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_BUFFER_SIZE:
7640da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            *params = 0;
765160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            if (NULL != buffer)
7662cfa3200fda29279eba1240170c7e873d12f9d48commit-bot@chromium.org                *params = SkToInt(buffer->getSize());
7670da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
7680da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        case GR_GL_BUFFER_USAGE:
7690da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            *params = GR_GL_STATIC_DRAW;
770160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org            if (NULL != buffer)
7710da3719050473344b6013fd7b614611984f20effrobertphillips@google.com                *params = buffer->getUsage();
7720da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
7730da3719050473344b6013fd7b614611984f20effrobertphillips@google.com        default:
77488cb22b6b4816c7a9ca6c5b795965b4606f9eb7bcommit-bot@chromium.org            SkFAIL("Unexpected value to glGetBufferParamateriv");
7750da3719050473344b6013fd7b614611984f20effrobertphillips@google.com            break;
7760da3719050473344b6013fd7b614611984f20effrobertphillips@google.com    }
7770da3719050473344b6013fd7b614611984f20effrobertphillips@google.com};
778cf6285b89b8820641ffb6871d4b3275bfe783f51caryclark@google.com} // end of namespace
779cf6285b89b8820641ffb6871d4b3275bfe783f51caryclark@google.com
780ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com////////////////////////////////////////////////////////////////////////////////
781ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.comstruct GrDebugGLInterface : public GrGLInterface {
782ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
783ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.compublic:
784409566a17d7aa898f1753e5d1734324a1330d7c3robertphillips@google.com    SK_DECLARE_INST_COUNT(GrDebugGLInterface)
785409566a17d7aa898f1753e5d1734324a1330d7c3robertphillips@google.com
786ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    GrDebugGLInterface()
787ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com        : fWrapped(NULL) {
788622a17091b69df8d54d318c88f34851677a6d9c2robertphillips@google.com        GrDebugGL::staticRef();
789622a17091b69df8d54d318c88f34851677a6d9c2robertphillips@google.com    }
790622a17091b69df8d54d318c88f34851677a6d9c2robertphillips@google.com
791622a17091b69df8d54d318c88f34851677a6d9c2robertphillips@google.com    virtual ~GrDebugGLInterface() {
792622a17091b69df8d54d318c88f34851677a6d9c2robertphillips@google.com        GrDebugGL::staticUnRef();
793ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    }
794ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
795ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    void setWrapped(GrGLInterface *interface) {
796ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com        fWrapped.reset(interface);
797ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    }
798ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
799ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    // TODO: there are some issues w/ wrapping another GL interface inside the
800ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    // debug interface:
801ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    //      Since none of the "gl" methods are member functions they don't get
802ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    //      a "this" pointer through which to access "fWrapped"
803fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      This could be worked around by having all of them access the
804fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      "glInterface" pointer - i.e., treating the debug interface as a
805ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    //      true singleton
806ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    //
807fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      The problem with this is that we also want to handle OpenGL
808fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      contexts. The natural way to do this is to have multiple debug
809fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      interfaces. Each of which represents a separate context. The
810fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      static ID count would still uniquify IDs across all of them.
811fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      The problem then is that we couldn't treat the debug GL
812fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      interface as a singleton (since there would be one for each
813ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    //      context).
814ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    //
815fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      The solution to this is probably to alter SkDebugGlContext's
816fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      "makeCurrent" method to make a call like "makeCurrent(this)" to
817fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      the debug GL interface (assuming that the application will create
8186177e6999d23a4268ffd98dedfb1da00e272a89brobertphillips@google.com    //      multiple SkGLContextHelper's) to let it switch between the active
819fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      context. Everything in the GrDebugGL object would then need to be
820fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      moved to a GrContextObj and the GrDebugGL object would just switch
821fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    //      between them. Note that this approach would also require that
822ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    //      SkDebugGLContext wrap an arbitrary other context
823ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    //      and then pass the wrapped interface to the debug GL interface.
824ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
825ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.comprotected:
826ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.comprivate:
827ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
828ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    SkAutoTUnref<GrGLInterface> fWrapped;
829ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
830ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com    typedef GrGLInterface INHERITED;
831ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com};
832ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com
833ba0cc3ef1109c5ebba7e3fffda5408ce6120eb9drobertphillips@google.com////////////////////////////////////////////////////////////////////////////////
8340da3719050473344b6013fd7b614611984f20effrobertphillips@google.comconst GrGLInterface* GrGLCreateDebugInterface() {
835409566a17d7aa898f1753e5d1734324a1330d7c3robertphillips@google.com    GrGLInterface* interface = SkNEW(GrDebugGLInterface);
836409566a17d7aa898f1753e5d1734324a1330d7c3robertphillips@google.com
8379e90aed5de82732cc9921f01388d3063a41a053bcommit-bot@chromium.org    interface->fStandard = kGL_GrGLStandard;
838c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org
839c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    GrGLInterface::Functions* functions = &interface->fFunctions;
840c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fActiveTexture = debugGLActiveTexture;
841c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fAttachShader = debugGLAttachShader;
842c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBeginQuery = debugGLBeginQuery;
843c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBindAttribLocation = debugGLBindAttribLocation;
844c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBindBuffer = debugGLBindBuffer;
845c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBindFragDataLocation = noOpGLBindFragDataLocation;
846c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBindTexture = debugGLBindTexture;
847c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBindVertexArray = debugGLBindVertexArray;
848c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBlendColor = noOpGLBlendColor;
849c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBlendFunc = noOpGLBlendFunc;
850c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBufferData = debugGLBufferData;
851c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBufferSubData = noOpGLBufferSubData;
852c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fClear = noOpGLClear;
853c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fClearColor = noOpGLClearColor;
854c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fClearStencil = noOpGLClearStencil;
855c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fColorMask = noOpGLColorMask;
856c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fCompileShader = noOpGLCompileShader;
857c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fCompressedTexImage2D = noOpGLCompressedTexImage2D;
858c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fCopyTexSubImage2D = noOpGLCopyTexSubImage2D;
859c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fCreateProgram = debugGLCreateProgram;
860c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fCreateShader = debugGLCreateShader;
861c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fCullFace = noOpGLCullFace;
862c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDeleteBuffers = debugGLDeleteBuffers;
863c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDeleteProgram = debugGLDeleteProgram;
864c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDeleteQueries = noOpGLDeleteIds;
865c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDeleteShader = debugGLDeleteShader;
866c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDeleteTextures = debugGLDeleteTextures;
867c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDeleteVertexArrays = debugGLDeleteVertexArrays;
868c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDepthMask = noOpGLDepthMask;
869c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDisable = noOpGLDisable;
870c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray;
871c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDrawArrays = noOpGLDrawArrays;
872c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDrawBuffer = noOpGLDrawBuffer;
873c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDrawBuffers = noOpGLDrawBuffers;
874c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDrawElements = noOpGLDrawElements;
875c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fEnable = noOpGLEnable;
876c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray;
877c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fEndQuery = noOpGLEndQuery;
878c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fFinish = noOpGLFinish;
879c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fFlush = noOpGLFlush;
880160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    functions->fFlushMappedBufferRange = debugGLFlushMappedBufferRange;
881c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fFrontFace = noOpGLFrontFace;
882c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGenerateMipmap = debugGLGenerateMipmap;
883c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGenBuffers = debugGLGenBuffers;
884c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGenQueries = noOpGLGenIds;
885c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGenTextures = debugGLGenTextures;
886c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetBufferParameteriv = debugGLGetBufferParameteriv;
887c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetError = noOpGLGetError;
888c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetIntegerv = noOpGLGetIntegerv;
889c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetQueryObjecti64v = noOpGLGetQueryObjecti64v;
890c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetQueryObjectiv = noOpGLGetQueryObjectiv;
891c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetQueryObjectui64v = noOpGLGetQueryObjectui64v;
892c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetQueryObjectuiv = noOpGLGetQueryObjectuiv;
893c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetQueryiv = noOpGLGetQueryiv;
894c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetProgramInfoLog = noOpGLGetInfoLog;
895c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetProgramiv = noOpGLGetShaderOrProgramiv;
896c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetShaderInfoLog = noOpGLGetInfoLog;
897c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetShaderiv = noOpGLGetShaderOrProgramiv;
898c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetString = noOpGLGetString;
899c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetStringi = noOpGLGetStringi;
900c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv;
901c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetUniformLocation = noOpGLGetUniformLocation;
902c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGenVertexArrays = debugGLGenVertexArrays;
903c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fLineWidth = noOpGLLineWidth;
904c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fLinkProgram = noOpGLLinkProgram;
905160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    functions->fMapBuffer = debugGLMapBuffer;
906160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    functions->fMapBufferRange = debugGLMapBufferRange;
907c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fPixelStorei = debugGLPixelStorei;
908c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fQueryCounter = noOpGLQueryCounter;
909c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fReadBuffer = noOpGLReadBuffer;
910c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fReadPixels = debugGLReadPixels;
911c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fScissor = noOpGLScissor;
912c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fShaderSource = noOpGLShaderSource;
913c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fStencilFunc = noOpGLStencilFunc;
914c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fStencilFuncSeparate = noOpGLStencilFuncSeparate;
915c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fStencilMask = noOpGLStencilMask;
916c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate;
917c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fStencilOp = noOpGLStencilOp;
918c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fStencilOpSeparate = noOpGLStencilOpSeparate;
919c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fTexImage2D = noOpGLTexImage2D;
920c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fTexParameteri = noOpGLTexParameteri;
921c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fTexParameteriv = noOpGLTexParameteriv;
922c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fTexSubImage2D = noOpGLTexSubImage2D;
923c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fTexStorage2D = noOpGLTexStorage2D;
924c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDiscardFramebuffer = noOpGLDiscardFramebuffer;
925c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform1f = noOpGLUniform1f;
926c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform1i = noOpGLUniform1i;
927c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform1fv = noOpGLUniform1fv;
928c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform1iv = noOpGLUniform1iv;
929c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform2f = noOpGLUniform2f;
930c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform2i = noOpGLUniform2i;
931c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform2fv = noOpGLUniform2fv;
932c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform2iv = noOpGLUniform2iv;
933c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform3f = noOpGLUniform3f;
934c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform3i = noOpGLUniform3i;
935c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform3fv = noOpGLUniform3fv;
936c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform3iv = noOpGLUniform3iv;
937c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform4f = noOpGLUniform4f;
938c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform4i = noOpGLUniform4i;
939c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform4fv = noOpGLUniform4fv;
940c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniform4iv = noOpGLUniform4iv;
941c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniformMatrix2fv = noOpGLUniformMatrix2fv;
942c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniformMatrix3fv = noOpGLUniformMatrix3fv;
943c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUniformMatrix4fv = noOpGLUniformMatrix4fv;
944160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org    functions->fUnmapBuffer = debugGLUnmapBuffer;
945c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fUseProgram = debugGLUseProgram;
946c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fVertexAttrib4fv = noOpGLVertexAttrib4fv;
947c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fVertexAttribPointer = noOpGLVertexAttribPointer;
948c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fViewport = noOpGLViewport;
949c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBindFramebuffer = debugGLBindFramebuffer;
950c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBindRenderbuffer = debugGLBindRenderbuffer;
951c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fCheckFramebufferStatus = noOpGLCheckFramebufferStatus;
952c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDeleteFramebuffers = debugGLDeleteFramebuffers;
953c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fDeleteRenderbuffers = debugGLDeleteRenderbuffers;
954c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fFramebufferRenderbuffer = debugGLFramebufferRenderbuffer;
955c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fFramebufferTexture2D = debugGLFramebufferTexture2D;
956c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGenFramebuffers = debugGLGenFramebuffers;
957c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGenRenderbuffers = debugGLGenRenderbuffers;
958c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetFramebufferAttachmentParameteriv =
9598f9436161a83ea89818a486db1577e24ad33ec7bbsalomon@google.com                                    noOpGLGetFramebufferAttachmentParameteriv;
960c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fGetRenderbufferParameteriv = noOpGLGetRenderbufferParameteriv;
961c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fRenderbufferStorage = noOpGLRenderbufferStorage;
962c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fRenderbufferStorageMultisample =
9638f9436161a83ea89818a486db1577e24ad33ec7bbsalomon@google.com                                    noOpGLRenderbufferStorageMultisample;
964c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBlitFramebuffer = noOpGLBlitFramebuffer;
965c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fResolveMultisampleFramebuffer =
9668f9436161a83ea89818a486db1577e24ad33ec7bbsalomon@google.com                                    noOpGLResolveMultisampleFramebuffer;
967f66967243c3732523c2035f7d6dbf65c2d20b264commit-bot@chromium.org    functions->fMatrixLoadf = noOpGLMatrixLoadf;
968f66967243c3732523c2035f7d6dbf65c2d20b264commit-bot@chromium.org    functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
969160b478eed1dd4924a86a87fd60c91139e08ff71commit-bot@chromium.org
970c72425ae368bfcb47de7d2532eb90d305ec0d1cfcommit-bot@chromium.org    functions->fBindFragDataLocationIndexed =
9718f9436161a83ea89818a486db1577e24ad33ec7bbsalomon@google.com                                    noOpGLBindFragDataLocationIndexed;
972409566a17d7aa898f1753e5d1734324a1330d7c3robertphillips@google.com
973f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org    interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functions->fGetStringi,
974f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org                                functions->fGetIntegerv);
975f535561b3baeb5f19c5b81fb439818bdde00d882commit-bot@chromium.org
976409566a17d7aa898f1753e5d1734324a1330d7c3robertphillips@google.com    return interface;
9770da3719050473344b6013fd7b614611984f20effrobertphillips@google.com}
978