Chromium Code Reviews| Index: src/gpu/gl/GrGpuGL.cpp |
| diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp |
| index 12938f16a596e25b43ce969740c111182041d434..85722b4d51cd0cb5122ca7acfbe626d15f203935 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,18 @@ 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)) { |
| - texture->impl()->dirtyMipMaps(true); |
| - return true; |
| + bool success = false; |
| + if (GrPixelConfigIsCompressed(desc.fConfig)) { |
| + success = this->uploadCompressedTexData(desc, buffer, false, |
| + left, top, width, height); |
| } else { |
| - return false; |
| + success = this->uploadTexData(desc, false, |
| + left, top, width, height, |
| + config, buffer, rowBytes); |
| } |
| + |
|
robertphillips
2014/06/11 18:20:57
if (success) {
texture->impl()->dirtyMipMaps(tru
krajcevski
2014/06/11 18:58:41
Done.
|
| + texture->impl()->dirtyMipMaps(true); |
| + return success; |
| } |
| namespace { |
| @@ -704,15 +707,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 +735,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, |
| + 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) { |