Index: src/gpu/gl/GrGpuGL.cpp |
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp |
index 12938f16a596e25b43ce969740c111182041d434..a534d83cd76c8becc0ed0764d9ab3dcfd9c610f7 100644 |
--- a/src/gpu/gl/GrGpuGL.cpp |
+++ b/src/gpu/gl/GrGpuGL.cpp |
@@ -201,8 +201,7 @@ GrPixelConfig GrGpuGL::preferredWritePixelsConfig(GrPixelConfig writeConfig, |
} |
bool GrGpuGL::canWriteTexturePixels(const GrTexture* texture, GrPixelConfig srcConfig) const { |
- if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture->config() || |
- GrPixelConfigIsCompressed(srcConfig) || GrPixelConfigIsCompressed(texture->config())) { |
+ if (kIndex_8_GrPixelConfig == srcConfig || kIndex_8_GrPixelConfig == texture->config()) { |
return false; |
} |
if (srcConfig != texture->config() && kGLES_GrGLStandard == this->glStandard()) { |
@@ -478,14 +477,24 @@ bool GrGpuGL::onWriteTexturePixels(GrTexture* texture, |
desc.fTextureID = glTex->textureID(); |
desc.fOrigin = glTex->origin(); |
- if (this->uploadTexData(desc, false, |
- left, top, width, height, |
- config, buffer, rowBytes)) { |
+ bool success = false; |
+ if (GrPixelConfigIsCompressed(desc.fConfig)) { |
+ // We check that config == desc.fConfig in GrGpuGL::canWriteTexturePixels() |
+ SkASSERT(config == desc.fConfig); |
+ success = this->uploadCompressedTexData(desc, buffer, false, |
+ left, top, width, height); |
+ } else { |
+ success = this->uploadTexData(desc, false, |
+ left, top, width, height, |
+ config, buffer, rowBytes); |
+ } |
+ |
+ if (success) { |
texture->impl()->dirtyMipMaps(true); |
return true; |
- } else { |
- return false; |
} |
+ |
+ return false; |
} |
namespace { |
@@ -704,15 +713,25 @@ bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc, |
} |
bool GrGpuGL::uploadCompressedTexData(const GrGLTexture::Desc& desc, |
- const void* data) { |
- SkASSERT(NULL != data); |
+ const void* data, |
+ bool isNewTexture, |
+ int left, int top, int width, int height) { |
+ SkASSERT(NULL != data || isNewTexture); |
// No support for software flip y, yet... |
SkASSERT(kBottomLeft_GrSurfaceOrigin != desc.fOrigin); |
+ if (-1 == width) { |
+ width = desc.fWidth; |
+ } |
+ |
+ if (-1 == height) { |
+ height = desc.fHeight; |
+ } |
+ |
// Make sure that the width and height that we pass to OpenGL |
// is a multiple of the block size. |
- int dataSize = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fHeight); |
+ int dataSize = GrCompressedFormatDataSize(desc.fConfig, width, height); |
// We only need the internal format for compressed 2D textures. |
GrGLenum internalFormat = 0; |
@@ -722,14 +741,26 @@ bool GrGpuGL::uploadCompressedTexData(const GrGLTexture::Desc& desc, |
bool succeeded = true; |
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); |
- GL_ALLOC_CALL(this->glInterface(), |
- CompressedTexImage2D(GR_GL_TEXTURE_2D, |
- 0, // level |
- internalFormat, |
- desc.fWidth, desc.fHeight, |
- 0, // border |
- dataSize, |
- data)); |
+ |
+ if (isNewTexture) { |
+ GL_ALLOC_CALL(this->glInterface(), |
+ CompressedTexImage2D(GR_GL_TEXTURE_2D, |
+ 0, // level |
+ internalFormat, |
robertphillips
2014/06/11 19:24:46
Is this path okay if width != desc.fWidth || heigh
krajcevski
2014/06/11 21:21:43
OK, I've added asserts up above.
|
+ width, height, |
+ 0, // border |
+ dataSize, |
+ data)); |
+ } else { |
+ GL_ALLOC_CALL(this->glInterface(), |
+ CompressedTexSubImage2D(GR_GL_TEXTURE_2D, |
+ 0, // level |
+ left, top, |
+ width, height, |
+ internalFormat, |
+ dataSize, |
+ data)); |
+ } |
GrGLenum error = check_alloc_error(desc, this->glInterface()); |
if (error != GR_GL_NO_ERROR) { |