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

Side by Side Diff: src/gpu/GrTextureProvider.cpp

Issue 1777013002: Fix nullptr access in GrTextureProvider::createMipMappedTexture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix nullptr access in GrTextureProvider::createMipMappedTexture Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrTextureProvider.h" 8 #include "GrTextureProvider.h"
9 #include "GrTexturePriv.h" 9 #include "GrTexturePriv.h"
10 #include "GrResourceCache.h" 10 #include "GrResourceCache.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 } 47 }
48 48
49 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) && 49 if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) &&
50 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { 50 !fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
51 return nullptr; 51 return nullptr;
52 } 52 }
53 if (!GrPixelConfigIsCompressed(desc.fConfig) && 53 if (!GrPixelConfigIsCompressed(desc.fConfig) &&
54 !desc.fTextureStorageAllocator.fAllocateTextureStorage) { 54 !desc.fTextureStorageAllocator.fAllocateTextureStorage) {
55 if (mipLevelCount < 2) { 55 if (mipLevelCount < 2) {
56 const GrMipLevel& baseMipLevel = texels[0];
57 static const uint32_t kFlags = kExact_ScratchTextureFlag | 56 static const uint32_t kFlags = kExact_ScratchTextureFlag |
58 kNoCreate_ScratchTextureFlag; 57 kNoCreate_ScratchTextureFlag;
59 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { 58 if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) {
60 if (!texels || texture->writePixels(0, 0, desc.fWidth, desc.fHei ght, desc.fConfig, 59 if (!mipLevelCount ||
61 baseMipLevel.fPixels, baseMi pLevel.fRowBytes)) { 60 texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.f Config,
61 texels[0].fPixels, texels[0].fRowBytes) ) {
62 if (SkBudgeted::kNo == budgeted) { 62 if (SkBudgeted::kNo == budgeted) {
63 texture->resourcePriv().makeUnbudgeted(); 63 texture->resourcePriv().makeUnbudgeted();
64 } 64 }
65 return texture; 65 return texture;
66 } 66 }
67 texture->unref(); 67 texture->unref();
68 } 68 }
69 } 69 }
70 } 70 }
71 71
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke y) { 192 GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& ke y) {
193 ASSERT_SINGLE_OWNER 193 ASSERT_SINGLE_OWNER
194 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key); 194 GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key);
195 if (resource) { 195 if (resource) {
196 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture(); 196 GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture();
197 SkASSERT(texture); 197 SkASSERT(texture);
198 return texture; 198 return texture;
199 } 199 }
200 return NULL; 200 return NULL;
201 } 201 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698