aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-04-04 18:15:49 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-04-04 18:15:49 +0000
commit5e76223ca7c414758f2e566aaa2407187da129b5 (patch)
tree6a9f2534fe14891ca6903b760ae54326855c9f21
parentf987d1b2348258970cae675135b6dedda079de48 (diff)
move trimStorage to outer scope, so its memory is still valid later on when
we reference the newly assigned src pixels. git-svn-id: http://skia.googlecode.com/svn/trunk@1046 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--gpu/src/GrGpuGL.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/gpu/src/GrGpuGL.cpp b/gpu/src/GrGpuGL.cpp
index 50e7386893..1d159e3dcc 100644
--- a/gpu/src/GrGpuGL.cpp
+++ b/gpu/src/GrGpuGL.cpp
@@ -668,6 +668,9 @@ GrTexture* GrGpuGL::createTextureHelper(const TextureDesc& desc,
glDesc.fUploadByteCount = GrTexture::BytesPerPixel(desc.fFormat);
+ // in case we need a temporary, trimmed copy of the src pixels
+ GrAutoSMalloc<128 * 128> trimStorage;
+
/*
* check if our srcData has extra bytes past each row. If so, we need
* to trim those off here, since GL doesn't let us pass the rowBytes as
@@ -679,14 +682,12 @@ GrTexture* GrGpuGL::createTextureHelper(const TextureDesc& desc,
rowBytes / glDesc.fUploadByteCount));
}
} else {
- GrAutoSMalloc<128 * 128> trimStorage;
size_t trimRowBytes = desc.fWidth * glDesc.fUploadByteCount;
if (srcData && (trimRowBytes < rowBytes)) {
+ // copy the data into our new storage, skipping the trailing bytes
size_t trimSize = desc.fHeight * trimRowBytes;
- trimStorage.realloc(trimSize);
- // now copy the data into our new storage, skipping the trailing bytes
const char* src = (const char*)srcData;
- char* dst = (char*)trimStorage.get();
+ char* dst = (char*)trimStorage.realloc(trimSize);
for (uint32_t y = 0; y < desc.fHeight; y++) {
memcpy(dst, src, trimRowBytes);
src += rowBytes;