Don't allow nullptr in texels array params (unless using a transfer buffer).
Require all levels in writePixels to have a non-nullptr.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1765633002
Committed: https://skia.googlesource.com/skia/+/8ee78f31b2a29a5f76403755ea17bad9be74a3ec
Review URL: https://codereview.chromium.org/1765633002
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index c593f31..afeeda7 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -99,7 +99,7 @@
* @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 @@
return false;
}
}
+
+ for (int i = 0; i < texels.count(); ++i) {
+ if (!texels[i].fPixels) {
+ return false;
+ }
+ }
return true;
}
@@ -134,7 +140,7 @@
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 @@
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 @@
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)) {