Index: src/gpu/GrGpu.cpp |
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp |
index 4e0464a4ce6cb74f0e2c734b5fef8b1f3685e391..029d9a4bf9ab962fde40540f491b593693597eb1 100644 |
--- a/src/gpu/GrGpu.cpp |
+++ b/src/gpu/GrGpu.cpp |
@@ -98,7 +98,7 @@ static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) |
* @param isRT Indicates if the texture can be a render target. |
*/ |
static bool check_texture_creation_params(const GrCaps& caps, const GrSurfaceDesc& desc, |
- bool* isRT) { |
+ bool* isRT, const SkTArray<GrMipLevel>& texels) { |
if (!caps.isConfigTexturable(desc.fConfig)) { |
return false; |
} |
@@ -124,16 +124,23 @@ static bool check_texture_creation_params(const GrCaps& caps, const GrSurfaceDes |
return false; |
} |
} |
+ |
+ for (int i = 0; i < texels.count(); ++i) { |
+ if (!texels[i].fPixels) { |
+ return false; |
+ } |
+ } |
return true; |
} |
GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budgeted, |
const SkTArray<GrMipLevel>& texels) { |
+ |
GrSurfaceDesc desc = origDesc; |
const GrCaps* caps = this->caps(); |
bool isRT = false; |
- bool textureCreationParamsValid = check_texture_creation_params(*caps, desc, &isRT); |
+ bool textureCreationParamsValid = check_texture_creation_params(*caps, desc, &isRT, texels); |
if (!textureCreationParamsValid) { |
return nullptr; |
} |
@@ -181,13 +188,7 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budget |
GrTexture* GrGpu::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, |
const void* srcData, size_t rowBytes) { |
- GrMipLevel level; |
- level.fPixels = srcData; |
- level.fRowBytes = rowBytes; |
- SkSTArray<1, GrMipLevel> levels; |
- levels.push_back(level); |
- |
- return this->createTexture(desc, budgeted, levels); |
+ return this->createTexture(desc, budgeted, SkTArray<GrMipLevel>()); |
cblume
2016/03/03 22:54:46
I'm not sure I understand this bit.
Won't this be
bsalomon
2016/03/03 23:02:40
Oops, I fixed this locally but uploaded without. W
|
} |
GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwnership ownership) { |
@@ -391,16 +392,11 @@ bool GrGpu::writePixels(GrSurface* surface, |
if (!surface) { |
return false; |
} |
- bool validMipDataFound = false; |
for (int currentMipLevel = 0; currentMipLevel < texels.count(); currentMipLevel++) { |
- if (texels[currentMipLevel].fPixels != nullptr) { |
- validMipDataFound = true; |
- break; |
+ if (!texels[currentMipLevel].fPixels ) { |
+ return false; |
} |
} |
- if (!validMipDataFound) { |
- return false; |
- } |
this->handleDirtyContext(); |
if (this->onWritePixels(surface, left, top, width, height, config, texels)) { |