From 4075ec80e1c36e414e57746c772298be3b49a74e Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Tue, 17 Jan 2017 16:41:03 +0000 Subject: [PATCH] Revert "Revert "Enforce our rules about valid images when making textures"" This reverts commit 8bbdd49805bd77fec61e6e31f59d31a361e8be30. Reason for revert: Original change re-landed. Original change's description: > Revert "Enforce our rules about valid images when making textures" > > This reverts commit 7035f3c466826a4116e2f31deb64d1645ea9441b. > > Reason for revert: Need to revert earlier change to fix DEPS roll. > > Original change's description: > > Enforce our rules about valid images when making textures > > > > I'm working to make GrUploadPixmapToTexture more robust > > and easier to follow. This is one step on that journey. > > > > BUG=skia: > > > > Change-Id: I3ac39057e20ff8249843bb41ceca25f629aff31c > > Reviewed-on: https://skia-review.googlesource.com/7037 > > Commit-Queue: Brian Osman > > Reviewed-by: Matt Sarett > > Reviewed-by: Brian Salomon > > > > TBR=bsalomon@google.com,msarett@google.com,robertphillips@google.com,brianosman@google.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=skia: > > Change-Id: I1d7fef2d3777f0fcabc6c36749908409bd31a0f1 > Reviewed-on: https://skia-review.googlesource.com/7094 > Commit-Queue: Brian Osman > Reviewed-by: Brian Osman > TBR=bsalomon@google.com,msarett@google.com,robertphillips@google.com,brianosman@google.com # Not skipping CQ checks because original CL landed > 1 day ago. BUG=skia: Change-Id: I53319ebca4b13175014e6000d7b613932d02612b Reviewed-on: https://skia-review.googlesource.com/7114 Commit-Queue: Brian Osman Reviewed-by: Brian Osman --- src/gpu/SkGr.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 3cca52f..50c7cc2 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -23,6 +23,7 @@ #include "SkColorFilter.h" #include "SkConfig8888.h" #include "SkData.h" +#include "SkImageInfoPriv.h" #include "SkMaskFilter.h" #include "SkMessageBus.h" #include "SkMipMap.h" @@ -125,6 +126,10 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud SkPixmap tmpPixmap; SkBitmap tmpBitmap; + if (!SkImageInfoIsValid(pixmap.info())) { + return nullptr; + } + const GrCaps* caps = ctx->caps(); GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *caps); @@ -199,6 +204,10 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware : SkDestinationSurfaceColorMode::kLegacy; + if (!SkImageInfoIsValid(bitmap.info())) { + return nullptr; + } + GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps()); // We don't support Gray8 directly in the GL backend, so fail-over to GrUploadBitmapToTexture. @@ -210,11 +219,6 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b return nullptr; } - SkASSERT(sizeof(int) <= sizeof(uint32_t)); - if (bitmap.width() < 0 || bitmap.height() < 0) { - return nullptr; - } - SkAutoPixmapUnlock srcUnlocker; if (!bitmap.requestLock(&srcUnlocker)) { return nullptr; @@ -264,6 +268,10 @@ GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b GrTexture* GrUploadMipMapToTexture(GrContext* ctx, const SkImageInfo& info, const GrMipLevel* texels, int mipLevelCount) { + if (!SkImageInfoIsValid(info)) { + return nullptr; + } + const GrCaps* caps = ctx->caps(); return ctx->textureProvider()->createMipMappedTexture(GrImageInfoToSurfaceDesc(info, *caps), SkBudgeted::kYes, texels, -- 2.7.4