Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Unified Diff: src/gpu/GrTextureProvider.cpp

Issue 1765633002: Don't allow nullptr in texels array params (unless using a transfer buffer). (Closed) Base URL: https://skia.googlesource.com/skia@usesdk
Patch Set: more Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrTextureProvider.cpp
diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp
index 2d422f717f5e777ff8af2c2dc486465b963a47e9..fef9ed4d7dd8d6a2f3b1bccbf2d635522d2ed205 100644
--- a/src/gpu/GrTextureProvider.cpp
+++ b/src/gpu/GrTextureProvider.cpp
@@ -37,6 +37,15 @@ GrTexture* GrTextureProvider::createMipMappedTexture(const GrSurfaceDesc& desc,
if (this->isAbandoned()) {
return nullptr;
}
+ if (mipLevelCount && !texels) {
+ return nullptr;
+ }
+ for (int i = 0; i < mipLevelCount; ++i) {
+ if (!texels[i].fPixels) {
+ return nullptr;
+ }
+ }
+
if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) &&
!fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
return nullptr;
@@ -48,8 +57,8 @@ GrTexture* GrTextureProvider::createMipMappedTexture(const GrSurfaceDesc& desc,
static const uint32_t kFlags = kExact_ScratchTextureFlag |
kNoCreate_ScratchTextureFlag;
if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) {
- if (texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
- baseMipLevel.fPixels, baseMipLevel.fRowBytes)) {
+ if (!texels || texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
+ baseMipLevel.fPixels, baseMipLevel.fRowBytes)) {
if (SkBudgeted::kNo == budgeted) {
texture->resourcePriv().makeUnbudgeted();
}
@@ -69,12 +78,13 @@ GrTexture* GrTextureProvider::createMipMappedTexture(const GrSurfaceDesc& desc,
GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
const void* srcData, size_t rowBytes) {
- const int mipLevelCount = 1;
- GrMipLevel texels[mipLevelCount];
- texels[0].fPixels = srcData;
- texels[0].fRowBytes = rowBytes;
-
- return this->createMipMappedTexture(desc, budgeted, texels, mipLevelCount);
+ if (srcData) {
+ GrMipLevel texels;
+ texels.fPixels = srcData;
+ texels.fRowBytes = rowBytes;
+ return this->createMipMappedTexture(desc, budgeted, &texels, 1);
+ }
+ return this->createMipMappedTexture(desc, budgeted, nullptr, 0);
}
GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) {
« src/gpu/GrGpu.cpp ('K') | « src/gpu/GrGpu.cpp ('k') | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698