Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
swizzle.cpp
Go to the documentation of this file.
1/*
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"
13#include "include/core/SkRect.h"
18#include "src/gpu/ganesh/SkGr.h"
21#include "tools/DecodeUtils.h"
22#include "tools/Resources.h"
23
24DEF_SIMPLE_GPU_GM(swizzle, rContext, canvas, 512, 512) {
26 if (!sfc) {
27 return;
28 }
29
30 SkBitmap bmp;
31 ToolUtils::GetResourceAsBitmap("images/mandrill_512_q075.jpg", &bmp);
32 auto view = std::get<0>(GrMakeCachedBitmapProxyView(
33 rContext, bmp, /*label=*/"Gm_Swizzle", skgpu::Mipmapped::kNo));
34 if (!view) {
35 return;
36 }
37 std::unique_ptr<GrFragmentProcessor> imgFP =
38 GrTextureEffect::Make(std::move(view), bmp.alphaType(), SkMatrix());
39 auto fp = GrFragmentProcessor::SwizzleOutput(std::move(imgFP), skgpu::Swizzle("grb1"));
40
41 sfc->fillWithFP(std::move(fp));
42}
std::tuple< GrSurfaceProxyView, GrColorType > GrMakeCachedBitmapProxyView(GrRecordingContext *rContext, const SkBitmap &bitmap, std::string_view label, skgpu::Mipmapped mipmapped)
Definition SkGr.cpp:188
static std::unique_ptr< GrFragmentProcessor > SwizzleOutput(std::unique_ptr< GrFragmentProcessor >, const skgpu::Swizzle &)
static std::unique_ptr< GrFragmentProcessor > Make(GrSurfaceProxyView, SkAlphaType, const SkMatrix &=SkMatrix::I(), GrSamplerState::Filter=GrSamplerState::Filter::kNearest, GrSamplerState::MipmapMode mipmapMode=GrSamplerState::MipmapMode::kNone)
SkAlphaType alphaType() const
Definition SkBitmap.h:162
bool GetResourceAsBitmap(const char *resource, SkBitmap *dst)
Definition DecodeUtils.h:21
SurfaceFillContext * TopDeviceSurfaceFillContext(const SkCanvas *canvas)
Definition GrCanvas.cpp:27
DEF_SIMPLE_GPU_GM(swizzle, rContext, canvas, 512, 512)
Definition swizzle.cpp:24