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

Unified Diff: src/gpu/GrGpu.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: Upload again in case prev didn't work 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrTextureProvider.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrGpu.cpp
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index c593f311e4d7a502a1242b824d31c1e59b47e16e..afeeda7ae61eefe802acf0efadf3f32918d5bed4 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -99,7 +99,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;
}
@@ -125,6 +125,12 @@ 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;
}
@@ -134,7 +140,7 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budget
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;
}
@@ -180,17 +186,6 @@ GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budget
return tex;
}
-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);
-}
-
GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwnership ownership) {
this->handleDirtyContext();
if (!this->caps()->isConfigTexturable(desc.fConfig)) {
@@ -392,16 +387,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)) {
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrTextureProvider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698