2020-06-04 17:30:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Google LLC.
|
|
|
|
*
|
|
|
|
* 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/SkCanvas.h"
|
|
|
|
#include "include/core/SkImageInfo.h"
|
|
|
|
#include "include/core/SkMatrix.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
#include "include/core/SkTypes.h"
|
2021-07-21 19:39:51 +00:00
|
|
|
#include "src/core/SkCanvasPriv.h"
|
2020-06-04 17:30:51 +00:00
|
|
|
#include "src/gpu/GrFragmentProcessor.h"
|
2021-04-28 16:39:21 +00:00
|
|
|
#include "src/gpu/SkGr.h"
|
2021-08-04 17:27:43 +00:00
|
|
|
#include "src/gpu/SurfaceFillContext.h"
|
2021-07-06 20:28:52 +00:00
|
|
|
#include "src/gpu/effects/GrTextureEffect.h"
|
2020-06-04 17:30:51 +00:00
|
|
|
#include "tools/Resources.h"
|
|
|
|
|
2021-07-21 19:39:51 +00:00
|
|
|
DEF_SIMPLE_GPU_GM(swizzle, rContext, canvas, 512, 512) {
|
|
|
|
auto sfc = SkCanvasPriv::TopDeviceSurfaceFillContext(canvas);
|
2021-07-30 14:59:25 +00:00
|
|
|
if (!sfc) {
|
|
|
|
return;
|
|
|
|
}
|
2021-07-21 19:39:51 +00:00
|
|
|
|
2020-06-04 17:30:51 +00:00
|
|
|
SkBitmap bmp;
|
|
|
|
GetResourceAsBitmap("images/mandrill_512_q075.jpg", &bmp);
|
2021-07-07 18:15:12 +00:00
|
|
|
auto view = std::get<0>(GrMakeCachedBitmapProxyView(rContext, bmp, GrMipmapped::kNo));
|
2020-06-04 17:30:51 +00:00
|
|
|
if (!view) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
std::unique_ptr<GrFragmentProcessor> imgFP =
|
|
|
|
GrTextureEffect::Make(std::move(view), bmp.alphaType(), SkMatrix());
|
|
|
|
auto fp = GrFragmentProcessor::SwizzleOutput(std::move(imgFP), GrSwizzle("grb1"));
|
|
|
|
|
2021-07-21 19:39:51 +00:00
|
|
|
sfc->fillWithFP(std::move(fp));
|
2020-06-04 17:30:51 +00:00
|
|
|
}
|