Added debug GL Interface. This interface tracks various GL objects in order to find leaks & invalid accesses.

Core Review: http://codereview.appspot.com/5846049/




git-svn-id: http://skia.googlecode.com/svn/trunk@3426 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
robertphillips@google.com 2012-03-19 14:42:13 +00:00
parent 6c5ccd95f7
commit 0da3719050
6 changed files with 1064 additions and 2 deletions

View File

@ -20,6 +20,7 @@
#include "SkImageEncoder.h"
#include "gl/SkNativeGLContext.h"
#include "gl/SkNullGLContext.h"
#include "gl/SkDebugGLContext.h"
#include "SkNWayCanvas.h"
#include "SkPicture.h"
#include "SkString.h"
@ -208,6 +209,12 @@ public:
return true;
}
void cleanup() {
fGLContext.reset(NULL);
fGrContext.reset(NULL);
fRenderTarget.reset(NULL);
}
bool isValid() {
return NULL != fGLContext.get();
}
@ -231,6 +238,7 @@ private:
static GLHelper gRealGLHelper;
static GLHelper gNullGLHelper;
static GLHelper gDebugGLHelper;
static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size,
Backend backend, GLHelper* glHelper) {
@ -512,8 +520,10 @@ int main (int argc, char * const argv[]) {
determine_gpu_context_size(defineDict, &contextWidth, &contextHeight);
SkAutoTUnref<SkGLContext> realGLCtx(new SkNativeGLContext);
SkAutoTUnref<SkGLContext> nullGLCtx(new SkNullGLContext);
SkAutoTUnref<SkGLContext> debugGLCtx(new SkDebugGLContext);
gRealGLHelper.init(realGLCtx.get(), contextWidth, contextHeight);
gNullGLHelper.init(nullGLCtx.get(), contextWidth, contextHeight);
gDebugGLHelper.init(debugGLCtx.get(), contextWidth, contextHeight);
#endif
BenchTimer timer = BenchTimer(gRealGLHelper.glContext());
@ -617,5 +627,8 @@ int main (int argc, char * const argv[]) {
log_progress("\n");
}
// need to clean up here rather than post-main to allow leak detection to work
gDebugGLHelper.cleanup();
return 0;
}

View File

@ -102,6 +102,7 @@
'../include/gpu/gl/SkMesaGLContext.h',
'../include/gpu/gl/SkNativeGLContext.h',
'../include/gpu/gl/SkNullGLContext.h',
'../include/gpu/gl/SkDebugGLContext.h',
'../src/gpu/GrPrintf_skia.cpp',
'../src/gpu/SkGpuCanvas.cpp',
@ -112,6 +113,7 @@
'../src/gpu/gl/SkGLContext.cpp',
'../src/gpu/gl/SkNullGLContext.cpp',
'../src/gpu/gl/SkDebugGLContext.cpp',
'../src/gpu/android/SkNativeGLContext_android.cpp',
@ -252,6 +254,7 @@
'../src/gpu/gl/GrGLContextInfo.h',
'../src/gpu/gl/GrGLCreateNativeInterface_none.cpp',
'../src/gpu/gl/GrGLCreateNullInterface.cpp',
'../src/gpu/gl/GrGLCreateDebugInterface.cpp',
'../src/gpu/gl/GrGLDefaultInterface_none.cpp',
'../src/gpu/gl/GrGLDefaultInterface_native.cpp',
'../src/gpu/gl/GrGLIndexBuffer.cpp',

View File

@ -71,8 +71,8 @@ GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface*);
* also NULL GrContext creation will fail.
*
* The default interface is returned by GrGLDefaultInterface. This function's
* implementation is platform-specifc. Several have been provided, along with an
* implementation that simply returns NULL. It is implementation-specific
* implementation is platform-specific. Several have been provided, along with
* an implementation that simply returns NULL. It is implementation-specific
* whether the same GrGLInterface is returned or whether a new one is created
* at each call. Some platforms may not be able to use a single GrGLInterface
* because extension function ptrs vary across contexts. Note that GrGLInterface
@ -107,6 +107,12 @@ const GrGLInterface* GrGLCreateMesaInterface();
*/
const GrGLInterface* GrGLCreateNullInterface();
/**
* Creates a debugging GrGLInterface that doesn't draw anything. Used for
* finding memory leaks and invalid memory accesses.
*/
const GrGLInterface* GrGLCreateDebugInterface();
typedef unsigned int GrGLenum;
typedef unsigned char GrGLboolean;
typedef unsigned int GrGLbitfield;

View File

@ -0,0 +1,27 @@
/*
* 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 SkDebugGLContext_DEFINED
#define SkDebugGLContext_DEFINED
#include "SkGLContext.h"
class SkDebugGLContext : public SkGLContext {
public:
SkDebugGLContext() {};
virtual void makeCurrent() const SK_OVERRIDE {};
protected:
virtual const GrGLInterface* createGLContext() SK_OVERRIDE;
virtual void destroyGLContext() SK_OVERRIDE {};
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
/*
* 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 "gl/SkDebugGLContext.h"
const GrGLInterface* SkDebugGLContext::createGLContext() {
return GrGLCreateDebugInterface();
};