Index: src/gpu/GrTextureProvider.cpp |
diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp |
index cb652f7a7fd8c2e27b46fb7a4c802a4031b900e1..774d6052ce46241b8e99558fbbae2915e542fcb5 100644 |
--- a/src/gpu/GrTextureProvider.cpp |
+++ b/src/gpu/GrTextureProvider.cpp |
@@ -30,21 +30,32 @@ GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg |
static const uint32_t kFlags = kExact_ScratchTextureFlag | |
kNoCreate_ScratchTextureFlag; |
if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { |
- if (!srcData || texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, |
+ if (!srcData || texture->writePixels(NULL, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig, |
srcData, rowBytes)) { |
if (!budgeted) { |
texture->resourcePriv().makeUnbudgeted(); |
} |
+ if (srcData) { |
+ texture->setFromRawPixels(true); |
+ } |
return texture; |
} |
texture->unref(); |
} |
} |
- return fGpu->createTexture(desc, budgeted, srcData, rowBytes); |
+ GrTexture* tmp = fGpu->createTexture(desc, budgeted, srcData, rowBytes); |
+ if (tmp && srcData) { |
+ tmp->setFromRawPixels(true); |
+ } |
+ return tmp; |
} |
GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) { |
- return this->internalCreateApproxTexture(desc, 0); |
+ GrTexture* texture = this->internalCreateApproxTexture(desc, 0); |
+ if (texture) { |
+ SkASSERT(!texture->fromRawPixels2()); |
+ } |
+ return texture; |
} |
GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& desc, |
@@ -93,6 +104,7 @@ GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc, |
GrSurface* surface = static_cast<GrSurface*>(resource); |
GrRenderTarget* rt = surface->asRenderTarget(); |
if (rt && fGpu->caps()->discardRenderTargetSupport()) { |
+ // trash the existing DC in this case |
rt->discard(); |
} |
return surface->asTexture(); |