Make the debug interface a GrGLTestInterface subclass.

The debug interface subsumes the GrDebugGL singleton which allows multiple instances.

Fixes a few issues that existed before this CL (pack alignment wasn't tracked or respected, and we weren't initializing a texture id to 0 in one GM). Apparently this is not currently run on the bots.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1812323002

Review URL: https://codereview.chromium.org/1812323002
This commit is contained in:
bsalomon 2016-03-21 09:04:26 -07:00 committed by Commit bot
parent 423ba24cac
commit 3c481001b1
9 changed files with 1147 additions and 2406 deletions

View File

@ -87,7 +87,7 @@ protected:
// Useful for debugging whether errors result from use of RECTANGLE
// #define TARGET GR_GL_TEXTURE_2D
#define TARGET GR_GL_TEXTURE_RECTANGLE
GrGLuint id;
GrGLuint id = 0;
GR_GL_CALL(gl, GenTextures(1, &id));
GR_GL_CALL(gl, BindTexture(TARGET, id));
GR_GL_CALL(gl, TexParameteri(TARGET, GR_GL_TEXTURE_MAG_FILTER,

View File

@ -333,8 +333,6 @@
'<(skia_src_path)/gpu/gl/GrGLIndexBuffer.h',
'<(skia_src_path)/gpu/gl/GrGLInterface.cpp',
'<(skia_src_path)/gpu/gl/GrGLIRect.h',
'<(skia_src_path)/gpu/gl/GrGLNoOpInterface.cpp',
'<(skia_src_path)/gpu/gl/GrGLNoOpInterface.h',
'<(skia_src_path)/gpu/gl/GrGLPath.cpp',
'<(skia_src_path)/gpu/gl/GrGLPath.h',
'<(skia_src_path)/gpu/gl/GrGLPathRange.cpp',
@ -552,8 +550,6 @@
'<(skia_src_path)/gpu/gl/debug/GrShaderObj.cpp',
'<(skia_src_path)/gpu/gl/debug/GrProgramObj.h',
'<(skia_src_path)/gpu/gl/debug/GrProgramObj.cpp',
'<(skia_src_path)/gpu/gl/debug/GrDebugGL.h',
'<(skia_src_path)/gpu/gl/debug/GrDebugGL.cpp',
'<(skia_src_path)/gpu/gl/debug/GrVertexArrayObj.h',
# Sk files

View File

@ -324,19 +324,19 @@ public:
}
GrGLvoid getQueryObjecti64v(GrGLuint id, GrGLenum pname, GrGLint64 *params) override {
queryResult(id, pname, params);
this->queryResult(id, pname, params);
}
GrGLvoid getQueryObjectiv(GrGLuint id, GrGLenum pname, GrGLint *params) override {
queryResult(id, pname, params);
this->queryResult(id, pname, params);
}
GrGLvoid getQueryObjectui64v(GrGLuint id, GrGLenum pname, GrGLuint64 *params) override {
queryResult(id, pname, params);
this->queryResult(id, pname, params);
}
GrGLvoid getQueryObjectuiv(GrGLuint id, GrGLenum pname, GrGLuint *params) override {
queryResult(id, pname, params);
this->queryResult(id, pname, params);
}
GrGLvoid getShaderiv(GrGLuint shader, GrGLenum pname, GrGLint* params) override {
@ -353,13 +353,13 @@ public:
case GR_GL_EXTENSIONS:
return CombinedExtensionString();
case GR_GL_VERSION:
return (const GrGLubyte*)"4.0 Debug GL";
return (const GrGLubyte*)"4.0 Null GL";
case GR_GL_SHADING_LANGUAGE_VERSION:
return (const GrGLubyte*)"4.20.8 Debug GLSL";
return (const GrGLubyte*)"4.20.8 Null GLSL";
case GR_GL_VENDOR:
return (const GrGLubyte*)"Debug Vendor";
return (const GrGLubyte*)"Null Vendor";
case GR_GL_RENDERER:
return (const GrGLubyte*)"The Debug (Non-)Renderer";
return (const GrGLubyte*)"The Null (Non-)Renderer";
default:
SkFAIL("Unexpected name passed to GetString");
return nullptr;
@ -383,13 +383,6 @@ public:
}
}
GrGLvoid getTexLevelParameteriv(GrGLenum target, GrGLint level, GrGLenum pname,
GrGLint* params) override {
// we used to use this to query stuff about externally created textures,
// now we just require clients to tell us everything about the texture.
SkFAIL("Should never query texture parameters.");
}
GrGLint getUniformLocation(GrGLuint program, const char* name) override {
return ++fCurrUniformLocation;
}
@ -598,6 +591,8 @@ private:
break;
}
}
typedef GrGLTestInterface INHERITED;
};
const char* NullInterface::kExtensions[] = {

View File

@ -1,703 +0,0 @@
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrGLNoOpInterface.h"
#include "SkMutex.h"
#include "SkString.h"
// the OpenGLES 2.0 spec says this must be >= 128
static const GrGLint kDefaultMaxVertexUniformVectors = 128;
// the OpenGLES 2.0 spec says this must be >=16
static const GrGLint kDefaultMaxFragmentUniformVectors = 16;
// the OpenGLES 2.0 spec says this must be >= 8
static const GrGLint kDefaultMaxVertexAttribs = 8;
// the OpenGLES 2.0 spec says this must be >= 8
static const GrGLint kDefaultMaxVaryingVectors = 8;
static const char* kExtensions[] = {
"GL_ARB_framebuffer_object",
"GL_ARB_blend_func_extended",
"GL_ARB_timer_query",
"GL_ARB_draw_buffers",
"GL_ARB_occlusion_query",
"GL_EXT_stencil_wrap"
};
namespace {
const GrGLubyte* combined_extensions_string() {
static SkString gExtString;
static SkMutex gMutex;
gMutex.acquire();
if (0 == gExtString.size()) {
for (size_t i = 0; i < SK_ARRAY_COUNT(kExtensions) - 1; ++i) {
gExtString.append(kExtensions[i]);
gExtString.append(" ");
}
gExtString.append(kExtensions[SK_ARRAY_COUNT(kExtensions) - 1]);
}
gMutex.release();
return (const GrGLubyte*) gExtString.c_str();
}
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBindFragDataLocation(GrGLuint program,
GrGLuint colorNumber,
const GrGLchar* name) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendColor(GrGLclampf red,
GrGLclampf green,
GrGLclampf blue,
GrGLclampf alpha) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendEquation(GrGLenum mode) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendFunc(GrGLenum sfactor,
GrGLenum dfactor) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBufferSubData(GrGLenum target,
GrGLintptr offset,
GrGLsizeiptr size,
const GrGLvoid* data) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLClear(GrGLbitfield mask) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLClearColor(GrGLclampf red,
GrGLclampf green,
GrGLclampf blue,
GrGLclampf alpha) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLClearStencil(GrGLint s) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLColorMask(GrGLboolean red,
GrGLboolean green,
GrGLboolean blue,
GrGLboolean alpha) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCompileShader(GrGLuint shader) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCompressedTexImage2D(GrGLenum target,
GrGLint level,
GrGLenum internalformat,
GrGLsizei width,
GrGLsizei height,
GrGLint border,
GrGLsizei imageSize,
const GrGLvoid* data) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCompressedTexSubImage2D(GrGLenum target,
GrGLint level,
GrGLint xoffset,
GrGLint yoffset,
GrGLsizei width,
GrGLsizei height,
GrGLenum format,
GrGLsizei imageSize,
const GrGLvoid* data) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCopyTexSubImage2D(GrGLenum target,
GrGLint level,
GrGLint xoffset,
GrGLint yoffset,
GrGLint x,
GrGLint y,
GrGLsizei width,
GrGLsizei height) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCullFace(GrGLenum mode) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDepthMask(GrGLboolean flag) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDisable(GrGLenum cap) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDisableVertexAttribArray(GrGLuint index) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawArrays(GrGLenum mode,
GrGLint first,
GrGLsizei count) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawArraysInstanced(GrGLenum mode,
GrGLint first,
GrGLsizei count,
GrGLsizei primcount) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawBuffer(GrGLenum mode) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawBuffers(GrGLsizei n,
const GrGLenum* bufs) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawElements(GrGLenum mode,
GrGLsizei count,
GrGLenum type,
const GrGLvoid* indices) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawElementsInstanced(GrGLenum mode,
GrGLsizei count,
GrGLenum type,
const GrGLvoid* indices,
GrGLsizei primcount) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEnable(GrGLenum cap) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEnableVertexAttribArray(GrGLuint index) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEndQuery(GrGLenum target) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLFinish() {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLFlush() {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLFrontFace(GrGLenum mode) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLineWidth(GrGLfloat width) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLinkProgram(GrGLuint program) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixLoadf(GrGLenum, const GrGLfloat*) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixLoadIdentity(GrGLenum) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLQueryCounter(GrGLuint id, GrGLenum target) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLReadBuffer(GrGLenum src) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLScissor(GrGLint x,
GrGLint y,
GrGLsizei width,
GrGLsizei height) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLShaderSource(GrGLuint shader,
GrGLsizei count,
#if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE
const char* const * str,
#else
const char** str,
#endif
const GrGLint* length) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilFunc(GrGLenum func, GrGLint ref, GrGLuint mask) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilFuncSeparate(GrGLenum face,
GrGLenum func,
GrGLint ref,
GrGLuint mask) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilMask(GrGLuint mask) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilMaskSeparate(GrGLenum face, GrGLuint mask) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilOp(GrGLenum fail, GrGLenum zfail, GrGLenum zpass) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilOpSeparate(GrGLenum face,
GrGLenum fail,
GrGLenum zfail,
GrGLenum zpass) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexBuffer(GrGLenum target,
GrGLint internalformat,
GrGLuint buffer) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexImage2D(GrGLenum target,
GrGLint level,
GrGLint internalformat,
GrGLsizei width,
GrGLsizei height,
GrGLint border,
GrGLenum format,
GrGLenum type,
const GrGLvoid* pixels) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexParameteri(GrGLenum target,
GrGLenum pname,
GrGLint param) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexParameteriv(GrGLenum target,
GrGLenum pname,
const GrGLint* params) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexStorage2D(GrGLenum target,
GrGLsizei levels,
GrGLenum internalformat,
GrGLsizei width,
GrGLsizei height) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDiscardFramebuffer(GrGLenum target,
GrGLsizei numAttachments,
const GrGLenum* attachments) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexSubImage2D(GrGLenum target,
GrGLint level,
GrGLint xoffset,
GrGLint yoffset,
GrGLsizei width,
GrGLsizei height,
GrGLenum format,
GrGLenum type,
const GrGLvoid* pixels) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform1f(GrGLint location, GrGLfloat v0) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform1i(GrGLint location, GrGLint v0) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform1fv(GrGLint location,
GrGLsizei count,
const GrGLfloat* v) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform1iv(GrGLint location,
GrGLsizei count,
const GrGLint* v) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform2f(GrGLint location, GrGLfloat v0, GrGLfloat v1) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform2i(GrGLint location, GrGLint v0, GrGLint v1) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform2fv(GrGLint location,
GrGLsizei count,
const GrGLfloat* v) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform2iv(GrGLint location,
GrGLsizei count,
const GrGLint* v) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform3f(GrGLint location,
GrGLfloat v0,
GrGLfloat v1,
GrGLfloat v2) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform3i(GrGLint location,
GrGLint v0,
GrGLint v1,
GrGLint v2) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform3fv(GrGLint location,
GrGLsizei count,
const GrGLfloat* v) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform3iv(GrGLint location,
GrGLsizei count,
const GrGLint* v) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform4f(GrGLint location,
GrGLfloat v0,
GrGLfloat v1,
GrGLfloat v2,
GrGLfloat v3) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform4i(GrGLint location,
GrGLint v0,
GrGLint v1,
GrGLint v2,
GrGLint v3) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform4fv(GrGLint location,
GrGLsizei count,
const GrGLfloat* v) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform4iv(GrGLint location,
GrGLsizei count,
const GrGLint* v) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniformMatrix2fv(GrGLint location,
GrGLsizei count,
GrGLboolean transpose,
const GrGLfloat* value) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniformMatrix3fv(GrGLint location,
GrGLsizei count,
GrGLboolean transpose,
const GrGLfloat* value) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniformMatrix4fv(GrGLint location,
GrGLsizei count,
GrGLboolean transpose,
const GrGLfloat* value) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttrib1f(GrGLuint indx, const GrGLfloat value) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttrib2fv(GrGLuint indx, const GrGLfloat* values) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttrib3fv(GrGLuint indx, const GrGLfloat* values) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttrib4fv(GrGLuint indx, const GrGLfloat* values) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttribIPointer(GrGLuint indx,
GrGLint size,
GrGLenum type,
GrGLsizei stride,
const GrGLvoid* ptr) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttribPointer(GrGLuint indx,
GrGLint size,
GrGLenum type,
GrGLboolean normalized,
GrGLsizei stride,
const GrGLvoid* ptr) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttribDivisor(GrGLuint index, GrGLuint divisor) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLViewport(GrGLint x,
GrGLint y,
GrGLsizei width,
GrGLsizei height) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetFramebufferAttachmentParameteriv(GrGLenum target,
GrGLenum attachment,
GrGLenum pname,
GrGLint* params) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetRenderbufferParameteriv(GrGLenum target,
GrGLenum pname,
GrGLint* params) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLRenderbufferStorage(GrGLenum target,
GrGLenum internalformat,
GrGLsizei width,
GrGLsizei height) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLRenderbufferStorageMultisample(GrGLenum target,
GrGLsizei samples,
GrGLenum internalformat,
GrGLsizei width,
GrGLsizei height) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlitFramebuffer(GrGLint srcX0,
GrGLint srcY0,
GrGLint srcX1,
GrGLint srcY1,
GrGLint dstX0,
GrGLint dstY0,
GrGLint dstX1,
GrGLint dstY1,
GrGLbitfield mask,
GrGLenum filter) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLResolveMultisampleFramebuffer() {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBindFragDataLocationIndexed(GrGLuint program,
GrGLuint colorNumber,
GrGLuint index,
const GrGLchar * name) {
}
GrGLenum GR_GL_FUNCTION_TYPE noOpGLCheckFramebufferStatus(GrGLenum target) {
GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
return GR_GL_FRAMEBUFFER_COMPLETE;
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGenIds(GrGLsizei n, GrGLuint* ids) {
static int gCurrID = 1;
for (int i = 0; i < n; ++i) {
ids[i] = ++gCurrID;
}
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDeleteIds(GrGLsizei n, const GrGLuint* ids) {
}
GrGLenum GR_GL_FUNCTION_TYPE noOpGLGetError() {
return GR_GL_NO_ERROR;
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetIntegerv(GrGLenum pname, GrGLint* params) {
// TODO: remove from Ganesh the #defines for gets we don't use.
// We would like to minimize gets overall due to performance issues
switch (pname) {
case GR_GL_CONTEXT_PROFILE_MASK:
*params = GR_GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
break;
case GR_GL_STENCIL_BITS:
*params = 8;
break;
case GR_GL_SAMPLES:
*params = 1;
break;
case GR_GL_FRAMEBUFFER_BINDING:
*params = 0;
break;
case GR_GL_VIEWPORT:
params[0] = 0;
params[1] = 0;
params[2] = 800;
params[3] = 600;
break;
case GR_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
case GR_GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS:
case GR_GL_MAX_TEXTURE_IMAGE_UNITS:
case GR_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
*params = 8;
break;
case GR_GL_MAX_TEXTURE_COORDS:
*params = 8;
break;
case GR_GL_MAX_VERTEX_UNIFORM_VECTORS:
*params = kDefaultMaxVertexUniformVectors;
break;
case GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS:
*params = kDefaultMaxFragmentUniformVectors;
break;
case GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS:
*params = 16 * 4;
break;
case GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS:
*params = 0;
break;
case GR_GL_COMPRESSED_TEXTURE_FORMATS:
break;
case GR_GL_MAX_TEXTURE_SIZE:
*params = 8192;
break;
case GR_GL_MAX_RENDERBUFFER_SIZE:
*params = 8192;
break;
case GR_GL_MAX_SAMPLES:
*params = 32;
break;
case GR_GL_MAX_VERTEX_ATTRIBS:
*params = kDefaultMaxVertexAttribs;
break;
case GR_GL_MAX_VARYING_VECTORS:
*params = kDefaultMaxVaryingVectors;
break;
case GR_GL_NUM_EXTENSIONS:
*params = SK_ARRAY_COUNT(kExtensions);
break;
default:
SkFAIL("Unexpected pname to GetIntegerv");
}
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetInfoLog(GrGLuint program,
GrGLsizei bufsize,
GrGLsizei* length,
char* infolog) {
if (length) {
*length = 0;
}
if (bufsize > 0) {
*infolog = 0;
}
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetMultisamplefv(GrGLenum pname,
GrGLuint index,
GrGLfloat* val) {
val[0] = val[1] = 0.5f;
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetShaderOrProgramiv(GrGLuint program,
GrGLenum pname,
GrGLint* params) {
switch (pname) {
case GR_GL_LINK_STATUS: // fallthru
case GR_GL_COMPILE_STATUS:
*params = GR_GL_TRUE;
break;
case GR_GL_INFO_LOG_LENGTH:
*params = 0;
break;
// we don't expect any other pnames
default:
SkFAIL("Unexpected pname to GetProgramiv");
break;
}
}
namespace {
template <typename T>
void query_result(GrGLenum GLtarget, GrGLenum pname, T *params) {
switch (pname) {
case GR_GL_QUERY_RESULT_AVAILABLE:
*params = GR_GL_TRUE;
break;
case GR_GL_QUERY_RESULT:
*params = 0;
break;
default:
SkFAIL("Unexpected pname passed to GetQueryObject.");
break;
}
}
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryiv(GrGLenum GLtarget,
GrGLenum pname,
GrGLint *params) {
switch (pname) {
case GR_GL_CURRENT_QUERY:
*params = 0;
break;
case GR_GL_QUERY_COUNTER_BITS:
*params = 32;
break;
default:
SkFAIL("Unexpected pname passed GetQueryiv.");
}
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryObjecti64v(GrGLuint id,
GrGLenum pname,
GrGLint64 *params) {
query_result(id, pname, params);
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryObjectiv(GrGLuint id,
GrGLenum pname,
GrGLint *params) {
query_result(id, pname, params);
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryObjectui64v(GrGLuint id,
GrGLenum pname,
GrGLuint64 *params) {
query_result(id, pname, params);
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryObjectuiv(GrGLuint id,
GrGLenum pname,
GrGLuint *params) {
query_result(id, pname, params);
}
const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetString(GrGLenum name) {
switch (name) {
case GR_GL_EXTENSIONS:
return combined_extensions_string();
case GR_GL_VERSION:
return (const GrGLubyte*)"4.0 Debug GL";
case GR_GL_SHADING_LANGUAGE_VERSION:
return (const GrGLubyte*)"4.20.8 Debug GLSL";
case GR_GL_VENDOR:
return (const GrGLubyte*)"Debug Vendor";
case GR_GL_RENDERER:
return (const GrGLubyte*)"The Debug (Non-)Renderer";
default:
SkFAIL("Unexpected name passed to GetString");
return nullptr;
}
}
const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetStringi(GrGLenum name, GrGLuint i) {
switch (name) {
case GR_GL_EXTENSIONS:
if (static_cast<size_t>(i) <= SK_ARRAY_COUNT(kExtensions)) {
return (const GrGLubyte*) kExtensions[i];
} else {
return nullptr;
}
default:
SkFAIL("Unexpected name passed to GetStringi");
return nullptr;
}
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetTexLevelParameteriv(GrGLenum target,
GrGLint level,
GrGLenum pname,
GrGLint* params) {
// we used to use this to query stuff about externally created textures,
// now we just require clients to tell us everything about the texture.
SkFAIL("Should never query texture parameters.");
}
GrGLint GR_GL_FUNCTION_TYPE noOpGLGetUniformLocation(GrGLuint program, const char* name) {
static int gUniLocation = 0;
return ++gUniLocation;
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLInsertEventMarker(GrGLsizei length, const char* marker) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLPushGroupMarker(GrGLsizei length , const char* marker) {
}
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLPopGroupMarker() {
}

View File

@ -1,411 +0,0 @@
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrGLNoOpInterface_DEFINED
#define GrGLNoOpInterface_DEFINED
#include "gl/GrGLDefines.h"
#include "gl/GrGLTypes.h"
// These are constants/functions that are common to the Null and Debug GL interface implementations.
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBindFragDataLocation(GrGLuint program,
GrGLuint colorNumber,
const GrGLchar* name);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendColor(GrGLclampf red,
GrGLclampf green,
GrGLclampf blue,
GrGLclampf alpha);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendEquation(GrGLenum mode);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlendFunc(GrGLenum sfactor,
GrGLenum dfactor);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBufferSubData(GrGLenum target,
GrGLintptr offset,
GrGLsizeiptr size,
const GrGLvoid* data);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLClear(GrGLbitfield mask);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLClearColor(GrGLclampf red,
GrGLclampf green,
GrGLclampf blue,
GrGLclampf alpha);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLClearStencil(GrGLint s);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLColorMask(GrGLboolean red,
GrGLboolean green,
GrGLboolean blue,
GrGLboolean alpha);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCompileShader(GrGLuint shader);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCompressedTexImage2D(GrGLenum target,
GrGLint level,
GrGLenum internalformat,
GrGLsizei width,
GrGLsizei height,
GrGLint border,
GrGLsizei imageSize,
const GrGLvoid* data);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCompressedTexSubImage2D(GrGLenum target,
GrGLint level,
GrGLint xoffset,
GrGLint yoffset,
GrGLsizei width,
GrGLsizei height,
GrGLenum format,
GrGLsizei imageSize,
const GrGLvoid* data);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCopyTexSubImage2D(GrGLenum target,
GrGLint level,
GrGLint xoffset,
GrGLint yoffset,
GrGLint x,
GrGLint y,
GrGLsizei width,
GrGLsizei height);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLCullFace(GrGLenum mode);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDepthMask(GrGLboolean flag);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDisable(GrGLenum cap);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDisableVertexAttribArray(GrGLuint index);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawArrays(GrGLenum mode, GrGLint first, GrGLsizei count);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawArraysInstanced(GrGLenum mode,
GrGLint first,
GrGLsizei count,
GrGLsizei primcount);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawBuffer(GrGLenum mode);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawBuffers(GrGLsizei n,
const GrGLenum* bufs);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawElements(GrGLenum mode,
GrGLsizei count,
GrGLenum type,
const GrGLvoid* indices);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDrawElementsInstanced(GrGLenum mode,
GrGLsizei count,
GrGLenum type,
const GrGLvoid* indices,
GrGLsizei primcount);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEnable(GrGLenum cap);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEnableVertexAttribArray(GrGLuint index);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLEndQuery(GrGLenum target);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLFinish();
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLFlush();
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLFrontFace(GrGLenum mode);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixLoadf(GrGLenum, const GrGLfloat*);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLMatrixLoadIdentity(GrGLenum);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLineWidth(GrGLfloat width);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLLinkProgram(GrGLuint program);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLQueryCounter(GrGLuint id,
GrGLenum target);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLReadBuffer(GrGLenum src);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLScissor(GrGLint x,
GrGLint y,
GrGLsizei width,
GrGLsizei height);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLShaderSource(GrGLuint shader,
GrGLsizei count,
#if GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE
const char* const * str,
#else
const char** str,
#endif
const GrGLint* length);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilFunc(GrGLenum func, GrGLint ref, GrGLuint mask);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilFuncSeparate(GrGLenum face,
GrGLenum func,
GrGLint ref,
GrGLuint mask);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilMask(GrGLuint mask);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilMaskSeparate(GrGLenum face, GrGLuint mask);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilOp(GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLStencilOpSeparate(GrGLenum face,
GrGLenum fail,
GrGLenum zfail,
GrGLenum zpass);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexBuffer(GrGLenum target,
GrGLint internalformat,
GrGLuint buffer);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexImage2D(GrGLenum target,
GrGLint level,
GrGLint internalformat,
GrGLsizei width,
GrGLsizei height,
GrGLint border,
GrGLenum format,
GrGLenum type,
const GrGLvoid* pixels);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexParameteri(GrGLenum target, GrGLenum pname, GrGLint param);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexParameteriv(GrGLenum target,
GrGLenum pname,
const GrGLint* params);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexStorage2D(GrGLenum target,
GrGLsizei levels,
GrGLenum internalformat,
GrGLsizei width,
GrGLsizei height);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDiscardFramebuffer(GrGLenum target,
GrGLsizei numAttachments,
const GrGLenum* attachments);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLTexSubImage2D(GrGLenum target,
GrGLint level,
GrGLint xoffset,
GrGLint yoffset,
GrGLsizei width,
GrGLsizei height,
GrGLenum format,
GrGLenum type,
const GrGLvoid* pixels);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform1f(GrGLint location, GrGLfloat v0);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform1i(GrGLint location, GrGLint v0);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform1fv(GrGLint location,
GrGLsizei count,
const GrGLfloat* v);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform1iv(GrGLint location,
GrGLsizei count,
const GrGLint* v);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform2f(GrGLint location,
GrGLfloat v0,
GrGLfloat v1);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform2i(GrGLint location, GrGLint v0, GrGLint v1);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform2fv(GrGLint location,
GrGLsizei count,
const GrGLfloat* v);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform2iv(GrGLint location,
GrGLsizei count,
const GrGLint* v);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform3f(GrGLint location,
GrGLfloat v0,
GrGLfloat v1,
GrGLfloat v2);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform3i(GrGLint location,
GrGLint v0,
GrGLint v1,
GrGLint v2);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform3fv(GrGLint location,
GrGLsizei count,
const GrGLfloat* v);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform3iv(GrGLint location,
GrGLsizei count,
const GrGLint* v);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform4f(GrGLint location,
GrGLfloat v0,
GrGLfloat v1,
GrGLfloat v2,
GrGLfloat v3);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform4i(GrGLint location,
GrGLint v0,
GrGLint v1,
GrGLint v2,
GrGLint v3);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform4fv(GrGLint location,
GrGLsizei count,
const GrGLfloat* v);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniform4iv(GrGLint location,
GrGLsizei count,
const GrGLint* v);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniformMatrix2fv(GrGLint location,
GrGLsizei count,
GrGLboolean transpose,
const GrGLfloat* value);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniformMatrix3fv(GrGLint location,
GrGLsizei count,
GrGLboolean transpose,
const GrGLfloat* value);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLUniformMatrix4fv(GrGLint location,
GrGLsizei count,
GrGLboolean transpose,
const GrGLfloat* value);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttrib1f(GrGLuint indx, const GrGLfloat value);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttrib2fv(GrGLuint indx, const GrGLfloat* values);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttrib3fv(GrGLuint indx, const GrGLfloat* values);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttrib4fv(GrGLuint indx, const GrGLfloat* values);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttribIPointer(GrGLuint indx,
GrGLint size,
GrGLenum type,
GrGLsizei stride,
const GrGLvoid* ptr);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttribPointer(GrGLuint indx,
GrGLint size,
GrGLenum type,
GrGLboolean normalized,
GrGLsizei stride,
const GrGLvoid* ptr);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLVertexAttribDivisor(GrGLuint index, GrGLuint divisor);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLViewport(GrGLint x,
GrGLint y,
GrGLsizei width,
GrGLsizei height);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetFramebufferAttachmentParameteriv(GrGLenum target,
GrGLenum attachment,
GrGLenum pname,
GrGLint* params);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetRenderbufferParameteriv(GrGLenum target,
GrGLenum pname,
GrGLint* params);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLRenderbufferStorage(GrGLenum target,
GrGLenum internalformat,
GrGLsizei width,
GrGLsizei height);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLRenderbufferStorageMultisample(GrGLenum target,
GrGLsizei samples,
GrGLenum internalformat,
GrGLsizei width,
GrGLsizei height);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBlitFramebuffer(GrGLint srcX0,
GrGLint srcY0,
GrGLint srcX1,
GrGLint srcY1,
GrGLint dstX0,
GrGLint dstY0,
GrGLint dstX1,
GrGLint dstY1,
GrGLbitfield mask,
GrGLenum filter);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLResolveMultisampleFramebuffer();
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLBindFragDataLocationIndexed(GrGLuint program,
GrGLuint colorNumber,
GrGLuint index,
const GrGLchar * name);
GrGLenum GR_GL_FUNCTION_TYPE noOpGLCheckFramebufferStatus(GrGLenum target);
// this function can be used for all glGen*(GLsize i, GLuint*) functions
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGenIds(GrGLsizei n, GrGLuint* ids);
// this function function can be used for all glDelete*(GLsize i, const GLuint*)
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLDeleteIds(GrGLsizei n, const GrGLuint* ids);
GrGLenum GR_GL_FUNCTION_TYPE noOpGLGetError();
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetIntegerv(GrGLenum pname, GrGLint* params);
// can be used for both the program and shader info logs
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetInfoLog(GrGLuint program,
GrGLsizei bufsize,
GrGLsizei* length,
char* infolog);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetMultisamplefv(GrGLenum pname, GrGLuint index, GrGLfloat* val);
// can be used for both the program and shader params
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetShaderOrProgramiv(GrGLuint program,
GrGLenum pname,
GrGLint* params);
// Queries on bogus GLs just don't do anything at all. We could potentially make the timers work.
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryiv(GrGLenum GLtarget,
GrGLenum pname,
GrGLint *params);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryObjecti64v(GrGLuint id,
GrGLenum pname,
GrGLint64 *params);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryObjectiv(GrGLuint id, GrGLenum pname, GrGLint *params);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryObjectui64v(GrGLuint id,
GrGLenum pname,
GrGLuint64 *params);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetQueryObjectuiv(GrGLuint id,
GrGLenum pname,
GrGLuint *params);
const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetString(GrGLenum name);
const GrGLubyte* GR_GL_FUNCTION_TYPE noOpGLGetStringi(GrGLenum name, GrGLuint i);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLGetTexLevelParameteriv(GrGLenum target,
GrGLint level,
GrGLenum pname,
GrGLint* params);
GrGLint GR_GL_FUNCTION_TYPE noOpGLGetUniformLocation(GrGLuint program, const char* name);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLInsertEventMarker(GrGLsizei length, const char* marker);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLPushGroupMarker(GrGLsizei length , const char* marker);
GrGLvoid GR_GL_FUNCTION_TYPE noOpGLPopGroupMarker();
#endif

View File

@ -1,213 +0,0 @@
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrDebugGL.h"
#include "GrTextureObj.h"
#include "GrBufferObj.h"
#include "GrRenderBufferObj.h"
#include "GrFrameBufferObj.h"
#include "GrShaderObj.h"
#include "GrProgramObj.h"
#include "GrTextureUnitObj.h"
#include "GrVertexArrayObj.h"
GrDebugGL* GrDebugGL::gObj = nullptr;
int GrDebugGL::gStaticRefCount = 0;
GrDebugGL::Create GrDebugGL::gFactoryFunc[kObjTypeCount] = {
GrTextureObj::createGrTextureObj,
GrBufferObj::createGrBufferObj,
GrRenderBufferObj::createGrRenderBufferObj,
GrFrameBufferObj::createGrFrameBufferObj,
GrShaderObj::createGrShaderObj,
GrProgramObj::createGrProgramObj,
GrTextureUnitObj::createGrTextureUnitObj,
GrVertexArrayObj::createGrVertexArrayObj,
};
GrDebugGL::GrDebugGL()
: fPackRowLength(0)
, fUnPackRowLength(0)
, fCurTextureUnit(0)
, fArrayBuffer(nullptr)
, fElementArrayBuffer(nullptr)
, fFrameBuffer(nullptr)
, fRenderBuffer(nullptr)
, fProgram(nullptr)
, fTexture(nullptr)
, fVertexArray(nullptr)
, fAbandoned(false) {
for (int i = 0; i < kDefaultMaxTextureUnits; ++i) {
fTextureUnits[i] = reinterpret_cast<GrTextureUnitObj *>(
createObj(GrDebugGL::kTextureUnit_ObjTypes));
fTextureUnits[i]->ref();
fTextureUnits[i]->setNumber(i);
}
}
GrDebugGL::~GrDebugGL() {
// unref & delete the texture units first so they don't show up on the leak report
for (int i = 0; i < kDefaultMaxTextureUnits; ++i) {
fTextureUnits[i]->unref();
fTextureUnits[i]->deleteAction();
}
this->report();
for (int i = 0; i < fObjects.count(); ++i) {
delete fObjects[i];
}
fObjects.reset();
fArrayBuffer = nullptr;
fElementArrayBuffer = nullptr;
fFrameBuffer = nullptr;
fRenderBuffer = nullptr;
fProgram = nullptr;
fTexture = nullptr;
fVertexArray = nullptr;
}
GrFakeRefObj *GrDebugGL::findObject(GrGLuint ID, GrObjTypes type) {
for (int i = 0; i < fObjects.count(); ++i) {
if (fObjects[i]->getID() == ID) { // && fObjects[i]->getType() == type) {
// The application shouldn't be accessing objects
// that (as far as OpenGL knows) were already deleted
GrAlwaysAssert(!fObjects[i]->getDeleted());
GrAlwaysAssert(!fObjects[i]->getMarkedForDeletion());
return fObjects[i];
}
}
return nullptr;
}
void GrDebugGL::setArrayBuffer(GrBufferObj *arrayBuffer) {
if (fArrayBuffer) {
// automatically break the binding of the old buffer
GrAlwaysAssert(fArrayBuffer->getBound());
fArrayBuffer->resetBound();
GrAlwaysAssert(!fArrayBuffer->getDeleted());
fArrayBuffer->unref();
}
fArrayBuffer = arrayBuffer;
if (fArrayBuffer) {
GrAlwaysAssert(!fArrayBuffer->getDeleted());
fArrayBuffer->ref();
GrAlwaysAssert(!fArrayBuffer->getBound());
fArrayBuffer->setBound();
}
}
void GrDebugGL::setVertexArray(GrVertexArrayObj* vertexArray) {
if (vertexArray) {
SkASSERT(!vertexArray->getDeleted());
}
SkRefCnt_SafeAssign(fVertexArray, vertexArray);
}
void GrDebugGL::setElementArrayBuffer(GrBufferObj *elementArrayBuffer) {
if (fElementArrayBuffer) {
// automatically break the binding of the old buffer
GrAlwaysAssert(fElementArrayBuffer->getBound());
fElementArrayBuffer->resetBound();
GrAlwaysAssert(!fElementArrayBuffer->getDeleted());
fElementArrayBuffer->unref();
}
fElementArrayBuffer = elementArrayBuffer;
if (fElementArrayBuffer) {
GrAlwaysAssert(!fElementArrayBuffer->getDeleted());
fElementArrayBuffer->ref();
GrAlwaysAssert(!fElementArrayBuffer->getBound());
fElementArrayBuffer->setBound();
}
}
void GrDebugGL::setTexture(GrTextureObj *texture) {
fTextureUnits[fCurTextureUnit]->setTexture(texture);
}
void GrDebugGL::setFrameBuffer(GrFrameBufferObj *frameBuffer) {
if (fFrameBuffer) {
GrAlwaysAssert(fFrameBuffer->getBound());
fFrameBuffer->resetBound();
GrAlwaysAssert(!fFrameBuffer->getDeleted());
fFrameBuffer->unref();
}
fFrameBuffer = frameBuffer;
if (fFrameBuffer) {
GrAlwaysAssert(!fFrameBuffer->getDeleted());
fFrameBuffer->ref();
GrAlwaysAssert(!fFrameBuffer->getBound());
fFrameBuffer->setBound();
}
}
void GrDebugGL::setRenderBuffer(GrRenderBufferObj *renderBuffer) {
if (fRenderBuffer) {
GrAlwaysAssert(fRenderBuffer->getBound());
fRenderBuffer->resetBound();
GrAlwaysAssert(!fRenderBuffer->getDeleted());
fRenderBuffer->unref();
}
fRenderBuffer = renderBuffer;
if (fRenderBuffer) {
GrAlwaysAssert(!fRenderBuffer->getDeleted());
fRenderBuffer->ref();
GrAlwaysAssert(!fRenderBuffer->getBound());
fRenderBuffer->setBound();
}
}
void GrDebugGL::useProgram(GrProgramObj *program) {
if (fProgram) {
GrAlwaysAssert(fProgram->getInUse());
fProgram->resetInUse();
GrAlwaysAssert(!fProgram->getDeleted());
fProgram->unref();
}
fProgram = program;
if (fProgram) {
GrAlwaysAssert(!fProgram->getDeleted());
fProgram->ref();
GrAlwaysAssert(!fProgram->getInUse());
fProgram->setInUse();
}
}
void GrDebugGL::report() const {
for (int i = 0; i < fObjects.count(); ++i) {
if (!fAbandoned) {
GrAlwaysAssert(0 == fObjects[i]->getRefCount());
GrAlwaysAssert(fObjects[i]->getDeleted());
}
}
}

View File

@ -1,167 +0,0 @@
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrDebugGL_DEFINED
#define GrDebugGL_DEFINED
#include "SkTArray.h"
#include "gl/GrGLInterface.h"
class GrBufferObj;
class GrFakeRefObj;
class GrFrameBufferObj;
class GrProgramObj;
class GrRenderBufferObj;
class GrTextureObj;
class GrTextureUnitObj;
class GrVertexArrayObj;
////////////////////////////////////////////////////////////////////////////////
// This is the main debugging object. It is a singleton and keeps track of
// all the other debug objects.
class GrDebugGL {
public:
enum GrObjTypes {
kTexture_ObjTypes = 0,
kBuffer_ObjTypes,
kRenderBuffer_ObjTypes,
kFrameBuffer_ObjTypes,
kShader_ObjTypes,
kProgram_ObjTypes,
kTextureUnit_ObjTypes,
kVertexArray_ObjTypes,
kObjTypeCount
};
GrFakeRefObj *createObj(GrObjTypes type) {
GrFakeRefObj *temp = (*gFactoryFunc[type])();
fObjects.push_back(temp);
return temp;
}
GrFakeRefObj *findObject(GrGLuint ID, GrObjTypes type);
GrGLuint getMaxTextureUnits() const { return kDefaultMaxTextureUnits; }
void setCurTextureUnit(GrGLuint curTextureUnit) { fCurTextureUnit = curTextureUnit; }
GrGLuint getCurTextureUnit() const { return fCurTextureUnit; }
GrTextureUnitObj *getTextureUnit(int iUnit) {
GrAlwaysAssert(0 <= iUnit && kDefaultMaxTextureUnits > iUnit);
return fTextureUnits[iUnit];
}
void setArrayBuffer(GrBufferObj *arrayBuffer);
GrBufferObj *getArrayBuffer() { return fArrayBuffer; }
void setElementArrayBuffer(GrBufferObj *elementArrayBuffer);
GrBufferObj *getElementArrayBuffer() { return fElementArrayBuffer; }
void setVertexArray(GrVertexArrayObj* vertexArray);
GrVertexArrayObj* getVertexArray() { return fVertexArray; }
void setTexture(GrTextureObj *texture);
void setFrameBuffer(GrFrameBufferObj *frameBuffer);
GrFrameBufferObj *getFrameBuffer() { return fFrameBuffer; }
void setRenderBuffer(GrRenderBufferObj *renderBuffer);
GrRenderBufferObj *getRenderBuffer() { return fRenderBuffer; }
void useProgram(GrProgramObj *program);
void setPackRowLength(GrGLint packRowLength) {
fPackRowLength = packRowLength;
}
GrGLint getPackRowLength() const { return fPackRowLength; }
void setUnPackRowLength(GrGLint unPackRowLength) {
fUnPackRowLength = unPackRowLength;
}
GrGLint getUnPackRowLength() const { return fUnPackRowLength; }
static GrDebugGL *getInstance() {
// someone should admit to actually using this class
SkASSERT(0 < gStaticRefCount);
if (nullptr == gObj) {
gObj = new GrDebugGL;
}
return gObj;
}
void report() const;
static void staticRef() {
gStaticRefCount++;
}
static void staticUnRef() {
SkASSERT(gStaticRefCount > 0);
gStaticRefCount--;
if (0 == gStaticRefCount) {
delete gObj;
gObj = nullptr;
}
}
static void abandon() {
SkASSERT(gStaticRefCount > 0);
gObj->fAbandoned = true;
}
protected:
private:
// the OpenGLES 2.0 spec says this must be >= 2
static const GrGLint kDefaultMaxTextureUnits = 8;
GrGLint fPackRowLength;
GrGLint fUnPackRowLength;
GrGLuint fCurTextureUnit;
GrBufferObj* fArrayBuffer;
GrBufferObj* fElementArrayBuffer;
GrFrameBufferObj* fFrameBuffer;
GrRenderBufferObj* fRenderBuffer;
GrProgramObj* fProgram;
GrTextureObj* fTexture;
GrTextureUnitObj *fTextureUnits[kDefaultMaxTextureUnits];
GrVertexArrayObj *fVertexArray;
bool fAbandoned;
typedef GrFakeRefObj *(*Create)();
static Create gFactoryFunc[kObjTypeCount];
static GrDebugGL* gObj;
static int gStaticRefCount;
// global store of all objects
SkTArray<GrFakeRefObj *> fObjects;
GrDebugGL();
~GrDebugGL();
};
////////////////////////////////////////////////////////////////////////////////
// Helper macro to make creating an object (where you need to get back a derived
// type) easier
#define GR_CREATE(className, classEnum) \
reinterpret_cast<className *>(GrDebugGL::getInstance()->createObj(classEnum))
////////////////////////////////////////////////////////////////////////////////
// Helper macro to make finding objects less painful
#define GR_FIND(id, className, classEnum) \
reinterpret_cast<className *>(GrDebugGL::getInstance()->findObject(id, classEnum))
#endif // GrDebugGL_DEFINED

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ class GrTextureObj;
////////////////////////////////////////////////////////////////////////////////
// Although texture unit objects are allocated & deallocated like the other
// GL emulation objects they are derived from GrFakeRefObj to provide some
// uniformity in how the GrDebugGL class manages resources
// uniformity in how the debug interface class manages resources
class GrTextureUnitObj : public GrFakeRefObj {
GR_DEFINE_CREATOR(GrTextureUnitObj);