simplify GrTextureAdjuster given there is only one subclass

Intended as a pre-cl for https://codereview.chromium.org/2241353002#

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2242373002

Review-Url: https://codereview.chromium.org/2242373002
diff --git a/src/gpu/GrImageIDTextureAdjuster.cpp b/src/gpu/GrImageIDTextureAdjuster.cpp
index 989102e..2bfa21c 100644
--- a/src/gpu/GrImageIDTextureAdjuster.cpp
+++ b/src/gpu/GrImageIDTextureAdjuster.cpp
@@ -17,32 +17,13 @@
 
 static bool bmp_is_alpha_only(const SkBitmap& bm) { return kAlpha_8_SkColorType == bm.colorType(); }
 
-// SkImage's don't have a way of communicating whether they're alpha-only. So we fallback to
-// inspecting the texture.
-static bool tex_image_is_alpha_only(const SkImage_Base& img) {
-    return GrPixelConfigIsAlphaOnly(img.peekTexture()->config());
-}
-
+// By construction this texture adjuster always represents an entire SkImage, so use the
+// image's dimensions for the key's rectangle.
 GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img)
-    : INHERITED(img->peekTexture(), SkIRect::MakeWH(img->width(), img->height()),
-                tex_image_is_alpha_only(*img))
-    , fImageBase(img) {}
-
-void GrImageTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) {
-    // By construction this texture adjuster always represents an entire SkImage, so use the
-    // image's width and height for the key's rectangle.
-    GrUniqueKey baseKey;
-    GrMakeKeyFromImageID(&baseKey, fImageBase->uniqueID(),
-                         SkIRect::MakeWH(fImageBase->width(), fImageBase->height()));
-    MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
-}
-
-void GrImageTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
-    // We don't currently have a mechanism for notifications on Images!
-}
-
-SkColorSpace* GrImageTextureAdjuster::getColorSpace() {
-    return fImageBase->onImageInfo().colorSpace();
+    : GrTextureAdjuster(img->peekTexture(), SkIRect::MakeSize(img->dimensions()), img->uniqueID(),
+                        img->onImageInfo().colorSpace())
+{
+    SkASSERT(img->peekTexture());
 }
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrImageIDTextureAdjuster.h b/src/gpu/GrImageIDTextureAdjuster.h
index 6092fcf..327bf8f 100644
--- a/src/gpu/GrImageIDTextureAdjuster.h
+++ b/src/gpu/GrImageIDTextureAdjuster.h
@@ -15,23 +15,9 @@
 class SkImage_Base;
 class SkImageCacherator;
 
-/** Implementation for texture-backed SkImages. The image must stay in scope and unmodified while
-    this object exists. */
 class GrImageTextureAdjuster : public GrTextureAdjuster {
 public:
     explicit GrImageTextureAdjuster(const SkImage_Base* img);
-
-protected:
-    SkColorSpace* getColorSpace() override;
-
-private:
-    void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override;
-
-    void didCacheCopy(const GrUniqueKey& copyKey) override;
-
-    const SkImage_Base* fImageBase;
-
-    typedef GrTextureAdjuster INHERITED;
 };
 
 /** This class manages the conversion of SW-backed bitmaps to GrTextures. If the input bitmap is
diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp
index 4456980..20b77cb 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -112,11 +112,14 @@
     return copyDC->asTexture().release();
 }
 
-GrTextureAdjuster::GrTextureAdjuster(GrTexture* original,
-                                     const SkIRect& contentArea,
-                                     bool isAlphaOnly)
-    : INHERITED(contentArea.width(), contentArea.height(), isAlphaOnly)
-    , fOriginal(original) {
+GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea,
+                                     uint32_t uniqueID, SkColorSpace* cs)
+    : INHERITED(contentArea.width(), contentArea.height(),
+                GrPixelConfigIsAlphaOnly(original->config()))
+    , fOriginal(original)
+    , fColorSpace(cs)
+    , fUniqueID(uniqueID)
+{
     SkASSERT(SkIRect::MakeWH(original->width(), original->height()).contains(contentArea));
     if (contentArea.fLeft > 0 || contentArea.fTop > 0 ||
         contentArea.fRight < original->width() || contentArea.fBottom < original->height()) {
@@ -124,6 +127,20 @@
     }
 }
 
+void GrTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) {
+    GrUniqueKey baseKey;
+    GrMakeKeyFromImageID(&baseKey, fUniqueID, SkIRect::MakeWH(this->width(), this->height()));
+    MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
+}
+
+void GrTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
+    // We don't currently have a mechanism for notifications on Images!
+}
+
+SkColorSpace* GrTextureAdjuster::getColorSpace() {
+    return fColorSpace;
+}
+
 GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) {
     GrTexture* texture = this->originalTexture();
     GrContext* context = texture->getContext();
diff --git a/src/gpu/GrTextureParamsAdjuster.h b/src/gpu/GrTextureParamsAdjuster.h
index 4377ae5..879c660 100644
--- a/src/gpu/GrTextureParamsAdjuster.h
+++ b/src/gpu/GrTextureParamsAdjuster.h
@@ -142,13 +142,14 @@
                                 SkColorSpace* dstColorSpace,
                                 SkSourceGammaTreatment) override;
 
-protected:
-    /** The whole texture is content. */
-    explicit GrTextureAdjuster(GrTexture* original, bool isAlphaOnly)
-        : INHERITED(original->width(), original->height(), isAlphaOnly)
-        , fOriginal(original) {}
+    // We do not ref the texture nor the colorspace, so the caller must keep them in scope while
+    // this Adjuster is alive.
+    GrTextureAdjuster(GrTexture*, const SkIRect& area, uint32_t uniqueID, SkColorSpace*);
 
-    GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea, bool isAlphaOnly);
+protected:
+    SkColorSpace* getColorSpace() override;
+    void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override;
+    void didCacheCopy(const GrUniqueKey& copyKey) override;
 
     GrTexture* originalTexture() const { return fOriginal; }
 
@@ -158,6 +159,8 @@
 private:
     SkTLazy<SkIRect>    fContentArea;
     GrTexture*          fOriginal;
+    SkColorSpace*       fColorSpace;
+    uint32_t            fUniqueID;
 
     GrTexture* refCopy(const CopyParams &copyParams);