Revert "Enforce our rules about valid images when making textures"
authorBrian Osman <brianosman@google.com>
Sat, 14 Jan 2017 23:41:12 +0000 (23:41 +0000)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Sat, 14 Jan 2017 23:41:28 +0000 (23:41 +0000)
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 <brianosman@google.com>
> Reviewed-by: Matt Sarett <msarett@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
>

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 <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
src/gpu/SkGr.cpp

index 50c7cc2..3cca52f 100644 (file)
@@ -23,7 +23,6 @@
 #include "SkColorFilter.h"
 #include "SkConfig8888.h"
 #include "SkData.h"
-#include "SkImageInfoPriv.h"
 #include "SkMaskFilter.h"
 #include "SkMessageBus.h"
 #include "SkMipMap.h"
@@ -126,10 +125,6 @@ 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);
 
@@ -204,10 +199,6 @@ 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.
@@ -219,6 +210,11 @@ 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;
@@ -268,10 +264,6 @@ 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,