blob: 475a984550a245792582db856dc50d5ea45fb816 [file] [log] [blame]
John Stileseed56f02020-06-04 13:30:51 -04001/*
2 * Copyright 2019 Google LLC.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "gm/gm.h"
9#include "include/core/SkCanvas.h"
10#include "include/core/SkImageInfo.h"
11#include "include/core/SkMatrix.h"
12#include "include/core/SkRect.h"
13#include "include/core/SkTypes.h"
John Stileseed56f02020-06-04 13:30:51 -040014#include "src/gpu/GrFragmentProcessor.h"
Brian Salomoneebe7352020-12-09 16:37:04 -050015#include "src/gpu/GrSurfaceDrawContext.h"
Brian Salomon27c42022021-04-28 12:39:21 -040016#include "src/gpu/SkGr.h"
Robert Phillips550de7f2021-07-06 16:28:52 -040017#include "src/gpu/effects/GrTextureEffect.h"
John Stileseed56f02020-06-04 13:30:51 -040018#include "tools/Resources.h"
John Stileseed56f02020-06-04 13:30:51 -040019
Robert Phillipsba701382021-07-07 14:15:12 -040020DEF_SIMPLE_GPU_GM(swizzle, rContext, sdc, canvas, 512, 512) {
John Stileseed56f02020-06-04 13:30:51 -040021 SkBitmap bmp;
22 GetResourceAsBitmap("images/mandrill_512_q075.jpg", &bmp);
Robert Phillipsba701382021-07-07 14:15:12 -040023 auto view = std::get<0>(GrMakeCachedBitmapProxyView(rContext, bmp, GrMipmapped::kNo));
John Stileseed56f02020-06-04 13:30:51 -040024 if (!view) {
25 return;
26 }
27 std::unique_ptr<GrFragmentProcessor> imgFP =
28 GrTextureEffect::Make(std::move(view), bmp.alphaType(), SkMatrix());
29 auto fp = GrFragmentProcessor::SwizzleOutput(std::move(imgFP), GrSwizzle("grb1"));
30
Robert Phillipsba701382021-07-07 14:15:12 -040031 sdc->fillWithFP(std::move(fp));
John Stileseed56f02020-06-04 13:30:51 -040032}