Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / gm / swizzle.cpp
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"
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"
21
22 DEF_SIMPLE_GPU_GM(swizzle, rContext, canvas, 512, 512) {
23     auto sfc = SkCanvasPriv::TopDeviceSurfaceFillContext(canvas);
24     if (!sfc) {
25         return;
26     }
27
28     SkBitmap bmp;
29     GetResourceAsBitmap("images/mandrill_512_q075.jpg", &bmp);
30     auto view = std::get<0>(GrMakeCachedBitmapProxyView(rContext, bmp, GrMipmapped::kNo));
31     if (!view) {
32         return;
33     }
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"));
37
38     sfc->fillWithFP(std::move(fp));
39 }