Fix correctness issue with SkImageImageFilter and unpremul images

Unpremul images passed to SkImageImageFilter draw incorrectly, when an intermediate SurfaceContext is not used.
For repro steps see https://fiddle.skia.org/c/76d202e60b05a6aab9c8a074863f0b68.
CL fixes SkSpecialImage::MakeFromImage to not hardcode premul alpha type, but read alpha type from the source SkImage.
CL fixes SkImageImageFilter to generate correct fragment shader for unpremul images: e.g. color.rgb *= color.a.

Bug: skia:14045
Change-Id: I3b27849d64294efc783bebcc62d66ff59e164a15
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/630196
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/gm/imagefiltersunpremul.cpp b/gm/imagefiltersunpremul.cpp
new file mode 100644
index 0000000..82b4288
--- /dev/null
+++ b/gm/imagefiltersunpremul.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2023 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm/gm.h"
+#include "include/core/SkBitmap.h"
+#include "include/core/SkCanvas.h"
+#include "include/core/SkColor.h"
+#include "include/core/SkImage.h"
+#include "include/core/SkPaint.h"
+#include "include/effects/SkImageFilters.h"
+
+DEF_SIMPLE_GM_BG(imagefiltersunpremul, canvas, 64, 64, SK_ColorBLACK) {
+    // Draw an kUnpremul_SkAlphaType image using SkImageFilters::Image() and
+    // verify alpha channel was blended correctly.
+    SkBitmap bitmap;
+    bitmap.allocPixels(SkImageInfo::Make(64, 64, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType));
+    bitmap.eraseColor(SkColorSetARGB(50, 255, 0, 0));
+    SkPaint paint;
+    paint.setImageFilter(SkImageFilters::Image(SkImage::MakeFromBitmap(bitmap)));
+    canvas->drawPaint(paint);
+}
diff --git a/gn/gm.gni b/gn/gm.gni
index bdf4192..b951c22 100644
--- a/gn/gm.gni
+++ b/gn/gm.gni
@@ -228,6 +228,7 @@
   "$_gm/imagefiltersscaled.cpp",
   "$_gm/imagefiltersstroked.cpp",
   "$_gm/imagefilterstransformed.cpp",
+  "$_gm/imagefiltersunpremul.cpp",
   "$_gm/imagefromyuvtextures.cpp",
   "$_gm/imagemagnifier.cpp",
   "$_gm/imagemakewithfilter.cpp",
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 1a16c94..580c0bc 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -134,7 +134,7 @@
                                    subset,
                                    image->uniqueID(),
                                    std::move(view),
-                                   { ct, kPremul_SkAlphaType, image->refColorSpace() },
+                                   { ct, image->alphaType(), image->refColorSpace() },
                                    props);
     }
 #endif