Remove unneeded field from GrGLTexture
git-svn-id: http://skia.googlecode.com/svn/trunk@2607 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrGLTexture.cpp b/src/gpu/GrGLTexture.cpp
index e302694..29c69b1 100644
--- a/src/gpu/GrGLTexture.cpp
+++ b/src/gpu/GrGLTexture.cpp
@@ -47,7 +47,6 @@
textureDesc.fTextureID,
textureDesc.fOwnsID);
fUploadFormat = textureDesc.fUploadFormat;
- fUploadByteCount = textureDesc.fUploadByteCount;
fUploadType = textureDesc.fUploadType;
fOrientation = textureDesc.fOrientation;
fScaleX = GrIntToScalar(textureDesc.fContentWidth) /
@@ -114,7 +113,11 @@
int height,
const void* srcData,
size_t rowBytes) {
-
+ GrIRect bounds = GrIRect::MakeWH(this->width(), this->height());
+ GrIRect subrect = GrIRect::MakeXYWH(x,y,width, height);
+ if (!bounds.contains(subrect)) {
+ return;
+ }
GPUGL->setSpareTextureUnit();
// ES2 glCompressedTexSubImage2D doesn't support any formats
@@ -124,8 +127,10 @@
// in case we need a temporary, trimmed copy of the src pixels
SkAutoSMalloc<128 * 128> tempStorage;
+ size_t bpp = GrBytesPerPixel(this->config());
+ size_t trimRowBytes = width * bpp;
if (!rowBytes) {
- rowBytes = fUploadByteCount * width;
+ rowBytes = trimRowBytes;
}
/*
* check whether to allocate a temporary buffer for flipping y or
@@ -137,14 +142,13 @@
bool flipY = kBottomUp_Orientation == fOrientation;
if (kDesktop_GrGLBinding == GPUGL->glBinding() && !flipY) {
// can't use this for flipping, only non-neg values allowed. :(
- if (srcData && rowBytes) {
- GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH,
- rowBytes / fUploadByteCount));
+ if (srcData && rowBytes != trimRowBytes) {
+ GrGLint rowLength = static_cast<GrGLint>(rowBytes / bpp);
+ GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, rowLength));
restoreGLRowLength = true;
}
} else {
- size_t trimRowBytes = width * fUploadByteCount;
- if (srcData && (trimRowBytes < rowBytes || flipY)) {
+ if (srcData && (trimRowBytes != rowBytes || flipY)) {
// copy the data into our new storage, skipping the trailing bytes
size_t trimSize = height * trimRowBytes;
const char* src = (const char*)srcData;
@@ -170,7 +174,7 @@
y = this->height() - (y + height);
}
GL_CALL(BindTexture(GR_GL_TEXTURE_2D, fTexIDObj->id()));
- GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, fUploadByteCount));
+ GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, static_cast<GrGLint>(bpp)));
GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, 0, x, y, width, height,
fUploadFormat, fUploadType, srcData));