Pass GrMipMapped boolean down to GrResourceProvider::createTexture

This is the portion of:

https://skia-review.googlesource.com/c/skia/+/266916/ (Update two of GrResourceProvider's createTexture entry points)

I still care about.

Converting the boolean to an int and passing that down is dubious at best.

Change-Id: I830cc3bfad36526bfa7884e21c9f376585d27f0b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341397
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index f0513ec..abbc09f 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -12,6 +12,7 @@
 #include "include/private/GrSingleOwner.h"
 #include "src/core/SkConvertPixels.h"
 #include "src/core/SkMathPriv.h"
+#include "src/core/SkMipmap.h"
 #include "src/gpu/GrAttachment.h"
 #include "src/gpu/GrCaps.h"
 #include "src/gpu/GrDataUtils.h"
@@ -47,37 +48,39 @@
                                                    GrRenderable renderable,
                                                    int renderTargetSampleCnt,
                                                    SkBudgeted budgeted,
+                                                   GrMipMapped mipMapped,
                                                    GrProtected isProtected,
-                                                   const GrMipLevel texels[],
-                                                   int mipLevelCount) {
+                                                   const GrMipLevel texels[]) {
     ASSERT_SINGLE_OWNER
 
-    SkASSERT(mipLevelCount > 0);
-
     if (this->isAbandoned()) {
         return nullptr;
     }
 
-    GrMipmapped mipMapped = mipLevelCount > 1 ? GrMipmapped::kYes : GrMipmapped::kNo;
+    int numMipLevels = 1;
+    if (mipMapped == GrMipMapped::kYes) {
+        numMipLevels = SkMipmap::ComputeLevelCount(dimensions.fWidth, dimensions.fHeight) + 1;
+    }
+
     if (!fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
                                       mipMapped)) {
         return nullptr;
     }
     // Current rule is that you can provide no level data, just the base, or all the levels.
-    bool hasPixels = mipLevelCount && texels[0].fPixels;
+    bool hasPixels = texels[0].fPixels;
     auto scratch = this->getExactScratch(dimensions, format, renderable, renderTargetSampleCnt,
                                          budgeted, mipMapped, isProtected);
     if (scratch) {
         if (!hasPixels) {
             return scratch;
         }
-        return this->writePixels(std::move(scratch), colorType, dimensions, texels, mipLevelCount);
+        return this->writePixels(std::move(scratch), colorType, dimensions, texels, numMipLevels);
     }
     SkAutoSTMalloc<14, GrMipLevel> tmpTexels;
     SkAutoSTArray<14, std::unique_ptr<char[]>> tmpDatas;
     GrColorType tempColorType = GrColorType::kUnknown;
     if (hasPixels) {
-        tempColorType = this->prepareLevels(format, colorType, dimensions, texels, mipLevelCount,
+        tempColorType = this->prepareLevels(format, colorType, dimensions, texels, numMipLevels,
                                             &tmpTexels, &tmpDatas);
         if (tempColorType == GrColorType::kUnknown) {
             return nullptr;
@@ -85,7 +88,7 @@
     }
     return fGpu->createTexture(dimensions, format, renderable, renderTargetSampleCnt, budgeted,
                                isProtected, colorType, tempColorType, tmpTexels.get(),
-                               mipLevelCount);
+                               numMipLevels);
 }
 
 sk_sp<GrTexture> GrResourceProvider::getExactScratch(SkISize dimensions,
@@ -136,7 +139,7 @@
         return this->writePixels(std::move(tex), colorType, dimensions, &mipLevel, 1);
     } else {
         return this->createTexture(dimensions, format, colorType, renderable, renderTargetSampleCnt,
-                                   budgeted, isProtected, &mipLevel, 1);
+                                   budgeted, GrMipMapped::kNo, isProtected, &mipLevel);
     }
 }