Index: src/gpu/gl/GrGLGpu.cpp |
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp |
index bf0b297c8cf064620b4ac55586c9672ff969f75c..153c8b3d3e7e2f6fda51e5dc85054bb2d3070aab 100644 |
--- a/src/gpu/gl/GrGLGpu.cpp |
+++ b/src/gpu/gl/GrGLGpu.cpp |
@@ -484,6 +484,7 @@ GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc, |
surfDesc.fHeight = desc.fHeight; |
surfDesc.fConfig = desc.fConfig; |
surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount()); |
+ surfDesc.fTextureStorageAllocator = desc.fTextureStorageAllocator; |
// FIXME: this should be calling resolve_origin(), but Chrome code is currently |
// assuming the old behaviour, which is that backend textures are always |
// BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: |
@@ -649,8 +650,11 @@ bool GrGLGpu::onWritePixels(GrSurface* surface, |
success = this->uploadCompressedTexData(glTex->desc(), glTex->target(), buffer, |
kWrite_UploadType, left, top, width, height); |
} else { |
- success = this->uploadTexData(glTex->desc(), glTex->target(), kWrite_UploadType, |
- left, top, width, height, config, buffer, rowBytes); |
+ success = this->uploadTexData( |
+ glTex->desc(), |
+ reinterpret_cast<GrGLTextureInfo*>(glTex->getTextureHandle()), |
+ kWrite_UploadType, left, top, width, height, config, buffer, |
+ rowBytes); |
} |
if (success) { |
@@ -687,8 +691,11 @@ bool GrGLGpu::onTransferPixels(GrSurface* surface, |
GL_CALL(BindBuffer(glBuffer->bufferType(), glBuffer->bufferID())); |
bool success = false; |
- success = this->uploadTexData(glTex->desc(), glTex->target(), kTransfer_UploadType, |
- left, top, width, height, config, buffer, rowBytes); |
+ success = this->uploadTexData( |
+ glTex->desc(), |
+ reinterpret_cast<GrGLTextureInfo*>(glTex->getTextureHandle()), |
+ kTransfer_UploadType, left, top, width, height, config, buffer, |
+ rowBytes); |
if (success) { |
glTex->texturePriv().dirtyMipMaps(true); |
@@ -729,7 +736,7 @@ static inline GrGLenum check_alloc_error(const GrSurfaceDesc& desc, |
} |
bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc, |
- GrGLenum target, |
+ GrGLTextureInfo* info, |
UploadType uploadType, |
int left, int top, int width, int height, |
GrPixelConfig dataConfig, |
@@ -826,20 +833,32 @@ bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc, |
!(0 == left && 0 == top && desc.fWidth == width && desc.fHeight == height)) { |
succeeded = false; |
} else { |
- CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); |
- GL_ALLOC_CALL(this->glInterface(), TexImage2D(target, 0, internalFormat, desc.fWidth, |
- desc.fHeight, 0, externalFormat, |
- externalType, dataOrOffset)); |
- GrGLenum error = check_alloc_error(desc, this->glInterface()); |
- if (error != GR_GL_NO_ERROR) { |
- succeeded = false; |
- } |
+ if (desc.fTextureStorageAllocator) { |
+ succeeded = desc.fTextureStorageAllocator->allocateTextureStorage( |
+ info->fID, width, height); |
+ if (succeeded && dataOrOffset) { |
+ GL_CALL(TexSubImage2D(info->fTarget, |
+ 0, // level |
+ left, top, |
+ width, height, |
+ externalFormat, externalType, dataOrOffset)); |
+ } |
+ } else { |
+ CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); |
+ GL_ALLOC_CALL(this->glInterface(), TexImage2D( |
+ info->fTarget, 0, internalFormat, desc.fWidth, desc.fHeight, 0, externalFormat, |
+ externalType, dataOrOffset)); |
+ GrGLenum error = check_alloc_error(desc, this->glInterface()); |
+ if (error != GR_GL_NO_ERROR) { |
+ succeeded = false; |
+ } |
+ } |
} |
} else { |
if (swFlipY || glFlipY) { |
top = desc.fHeight - (top + height); |
} |
- GL_CALL(TexSubImage2D(target, |
+ GL_CALL(TexSubImage2D(info->fTarget, |
0, // level |
left, top, |
width, height, |
@@ -1105,8 +1124,12 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc, |
idDesc.fInfo.fID = 0; |
GL_CALL(GenTextures(1, &idDesc.fInfo.fID)); |
idDesc.fLifeCycle = lifeCycle; |
- // We only support GL_TEXTURE_2D at the moment. |
- idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; |
+ |
+ if (desc.fTextureStorageAllocator) { |
+ idDesc.fInfo.fTarget = desc.fTextureStorageAllocator->textureStorageTarget(); |
+ } else { |
+ idDesc.fInfo.fTarget = GR_GL_TEXTURE_2D; |
+ } |
if (!idDesc.fInfo.fID) { |
return return_null_texture(); |
@@ -1144,7 +1167,7 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc, |
GL_CALL(TexParameteri(idDesc.fInfo.fTarget, |
GR_GL_TEXTURE_WRAP_T, |
initialTexParams.fWrapT)); |
- if (!this->uploadTexData(desc, idDesc.fInfo.fTarget, kNewTexture_UploadType, 0, 0, |
+ if (!this->uploadTexData(desc, &idDesc.fInfo, kNewTexture_UploadType, 0, 0, |
desc.fWidth, desc.fHeight, |
desc.fConfig, srcData, rowBytes)) { |
GL_CALL(DeleteTextures(1, &idDesc.fInfo.fID)); |