| 1 |
/* |
| 2 |
* Copyright 2023 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 |
#ifndef GrFragmentProcessors_DEFINED |
| 9 |
#define GrFragmentProcessors_DEFINED |
| 10 |
|
| 11 |
#include "include/effects/SkRuntimeEffect.h" |
| 12 |
|
| 13 |
#include <tuple> |
| 14 |
#include <memory> |
| 15 |
|
| 16 |
class GrColorInfo; |
| 17 |
class GrFragmentProcessor; |
| 18 |
class SkBlenderBase; |
| 19 |
class SkColorFilter; |
| 20 |
class SkMaskFilter; |
| 21 |
class SkMatrix; |
| 22 |
class SkSurfaceProps; |
| 23 |
class SkShader; |
| 24 |
struct GrFPArgs; |
| 25 |
namespace skgpu::ganesh { class SurfaceDrawContext; } |
| 26 |
|
| 27 |
using GrFPResult = std::tuple<bool, std::unique_ptr<GrFragmentProcessor>>; |
| 28 |
|
| 29 |
namespace SkShaders { |
| 30 |
class MatrixRec; |
| 31 |
} |
| 32 |
|
| 33 |
namespace GrFragmentProcessors { |
| 34 |
/** |
| 35 |
* Returns a GrFragmentProcessor that implements this blend for the Ganesh GPU backend. |
| 36 |
* The GrFragmentProcessor expects premultiplied inputs and returns a premultiplied output. |
| 37 |
*/ |
| 38 |
std::unique_ptr<GrFragmentProcessor> Make(const SkBlenderBase*, |
| 39 |
std::unique_ptr<GrFragmentProcessor> srcFP, |
| 40 |
std::unique_ptr<GrFragmentProcessor> dstFP, |
| 41 |
const GrFPArgs& fpArgs); |
| 42 |
|
| 43 |
/** |
| 44 |
* Returns a GrFragmentProcessor that implements the color filter in GPU shader code. |
| 45 |
* |
| 46 |
* The fragment processor receives a input FP that generates a premultiplied input color, and |
| 47 |
* produces a premultiplied output color. |
| 48 |
* |
| 49 |
* A GrFPFailure indicates that the color filter isn't implemented for the GPU backend. |
| 50 |
*/ |
| 51 |
GrFPResult Make(skgpu::ganesh::SurfaceDrawContext*, |
| 52 |
const SkColorFilter*, |
| 53 |
std::unique_ptr<GrFragmentProcessor> inputFP, |
| 54 |
const GrColorInfo& dstColorInfo, |
| 55 |
const SkSurfaceProps&); |
| 56 |
|
| 57 |
std::unique_ptr<GrFragmentProcessor> Make(const SkMaskFilter*, |
| 58 |
const GrFPArgs&, |
| 59 |
const SkMatrix& ctm); |
| 60 |
|
| 61 |
bool IsSupported(const SkMaskFilter*); |
| 62 |
|
| 63 |
/** |
| 64 |
* Call on the root SkShader to produce a GrFragmentProcessor. |
| 65 |
* |
| 66 |
* The returned GrFragmentProcessor expects an unpremultiplied input color and produces a |
| 67 |
* premultiplied output. |
| 68 |
*/ |
| 69 |
std::unique_ptr<GrFragmentProcessor> Make(const SkShader*, const GrFPArgs&, const SkMatrix& ctm); |
| 70 |
std::unique_ptr<GrFragmentProcessor> Make(const SkShader*, |
| 71 |
const GrFPArgs&, |
| 72 |
const SkShaders::MatrixRec&); |
| 73 |
|
| 74 |
/** |
| 75 |
* Returns a GrFragmentProcessor for the passed-in runtime effect child. The processor will be |
| 76 |
* created with generic/null inputs, since the runtime effect is responsible for filling in the |
| 77 |
* arguments to the function. |
| 78 |
*/ |
| 79 |
GrFPResult MakeChildFP(const SkRuntimeEffect::ChildPtr& child, |
| 80 |
const GrFPArgs& childArgs); |
| 81 |
|
| 82 |
} // namespace GrFragmentProcessors |
| 83 |
|
| 84 |
#endif |