Address some valgrind issues

https://codereview.appspot.com/7448051/



git-svn-id: http://skia.googlecode.com/svn/trunk@7966 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
robertphillips@google.com 2013-03-04 20:03:44 +00:00
parent cc690201d2
commit 37ebe3fbf6
4 changed files with 13 additions and 5 deletions

View File

@ -51,7 +51,7 @@ static bool SkStrContains(const char string[], const char subchar) {
static inline char *SkStrDup(const char string[]) {
char *ret = (char *) sk_malloc_throw(strlen(string)+1);
memcpy(ret,string,strlen(string));
memcpy(ret,string,strlen(string)+1);
return ret;
}

View File

@ -202,8 +202,12 @@ void GrGLProgram::BuildDesc(const GrDrawState& drawState,
} else {
desc->fCoverageAttributeIndex = GrDrawState::kCoverageOverrideAttribIndexValue;
}
desc->fEdgeAttributeIndex = drawState.getAttribIndex(GrDrawState::kEdge_AttribIndex);
desc->fTexCoordAttributeIndex = drawState.getAttribIndex(GrDrawState::kTexCoord_AttribIndex);
if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) {
desc->fEdgeAttributeIndex = drawState.getAttribIndex(GrDrawState::kEdge_AttribIndex);
}
if (GrDrawState::AttributesBindExplicitTexCoords(desc->fAttribBindings)) {
desc->fTexCoordAttributeIndex = drawState.getAttribIndex(GrDrawState::kTexCoord_AttribIndex);
}
#if GR_DEBUG
// verify valid vertex attribute state

View File

@ -10,6 +10,7 @@
#ifndef GrGpuGL_DEFINED
#define GrGpuGL_DEFINED
#include "GrBinHashKey.h"
#include "GrDrawState.h"
#include "GrGpu.h"
@ -292,7 +293,7 @@ private:
this->setVertexBufferID(0);
}
for (int i = 0; i < fAttribArrayCount; ++i) {
if (fAttribArrays[i].vertexBufferID() == id) {
if (fAttribArrays[i].isVertexBufferIDBound(id)) {
fAttribArrays[i].invalidate();
}
}
@ -379,7 +380,9 @@ private:
fAttribPointerIsValid = false;
}
GrGLuint vertexBufferID() const { return fVertexBufferID; }
bool isVertexBufferIDBound(GrGLuint id) const {
return fAttribPointerIsValid && id == fVertexBufferID;
}
private:
bool fEnableIsValid;
bool fAttribPointerIsValid;

View File

@ -52,6 +52,7 @@ static void color_gradproc(skiatest::Reporter* reporter, const GradRec& rec) {
REPORTER_ASSERT(reporter, SkShader::kColor_GradientType == s->asAGradient(NULL));
SkShader::GradientInfo info;
info.fColors = NULL;
info.fColorCount = 0;
s->asAGradient(&info);
REPORTER_ASSERT(reporter, 1 == info.fColorCount);