2 * Copyright 2019 Google LLC.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
9 #include "include/core/SkBitmap.h"
10 #include "include/core/SkCanvas.h"
11 #include "include/core/SkImageInfo.h"
12 #include "include/core/SkMatrix.h"
13 #include "include/core/SkRect.h"
14 #include "include/core/SkTypes.h"
15 #include "src/core/SkCanvasPriv.h"
16 #include "src/gpu/ganesh/GrFragmentProcessor.h"
17 #include "src/gpu/ganesh/SkGr.h"
18 #include "src/gpu/ganesh/SurfaceFillContext.h"
19 #include "src/gpu/ganesh/effects/GrTextureEffect.h"
20 #include "tools/Resources.h"
22 DEF_SIMPLE_GPU_GM(swizzle, rContext, canvas, 512, 512) {
23 auto sfc = SkCanvasPriv::TopDeviceSurfaceFillContext(canvas);
29 GetResourceAsBitmap("images/mandrill_512_q075.jpg", &bmp);
30 auto view = std::get<0>(GrMakeCachedBitmapProxyView(rContext, bmp, GrMipmapped::kNo));
34 std::unique_ptr<GrFragmentProcessor> imgFP =
35 GrTextureEffect::Make(std::move(view), bmp.alphaType(), SkMatrix());
36 auto fp = GrFragmentProcessor::SwizzleOutput(std::move(imgFP), skgpu::Swizzle("grb1"));
38 sfc->fillWithFP(std::move(fp));