Flutter Engine
The Flutter Engine
GrColorSpaceXform.h
Go to the documentation of this file.
1/*
2 * Copyright 2016 Google Inc.
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 GrColorSpaceXform_DEFINED
9#define GrColorSpaceXform_DEFINED
10
17
18#include <stdint.h>
19#include <memory>
20
21class GrColorInfo;
22class SkColorSpace;
23struct GrShaderCaps;
24
25namespace skgpu { class KeyBuilder; }
26
27 /**
28 * Represents a color space transformation
29 */
31public:
33
36
37 static sk_sp<GrColorSpaceXform> Make(const GrColorInfo& srcInfo, const GrColorInfo& dstInfo);
38
39 const SkColorSpaceXformSteps& steps() const { return fSteps; }
40
41 /**
42 * GrFragmentProcessor::addToKey() must call this and include the returned value in its
43 * computed key.
44 */
45 static uint32_t XformKey(const GrColorSpaceXform* xform);
46
47 static bool Equals(const GrColorSpaceXform* a, const GrColorSpaceXform* b);
48
49 SkColor4f apply(const SkColor4f& srcColor);
50
51private:
53
55};
56
58public:
59 /**
60 * Returns a fragment processor that calls the passed in fragment processor, and then converts
61 * the color space of the output from src to dst. If the child is null, fInputColor is used.
62 */
63 static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> child,
66 static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> child,
67 const GrColorInfo& srcInfo,
68 const GrColorInfo& dstInfo);
69
70 /**
71 * Returns a fragment processor that calls the passed in FP and then converts it with the given
72 * color xform. If the child is null, fInputColor is used. Returns child as-is if the xform is
73 * null (i.e. a no-op).
74 */
75 static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> child,
77
78 const char* name() const override { return "ColorSpaceXform"; }
79 std::unique_ptr<GrFragmentProcessor> clone() const override;
80
81 const GrColorSpaceXform* colorXform() const { return fColorXform.get(); }
82
83private:
84 GrColorSpaceXformEffect(std::unique_ptr<GrFragmentProcessor> child,
86
88
89 static OptimizationFlags OptFlags(const GrFragmentProcessor* child);
90 SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override;
91
92 std::unique_ptr<ProgramImpl> onMakeProgramImpl() const override;
93 void onAddToKey(const GrShaderCaps&, skgpu::KeyBuilder*) const override;
94 bool onIsEqual(const GrFragmentProcessor&) const override;
95
96 sk_sp<GrColorSpaceXform> fColorXform;
97
98 using INHERITED = GrFragmentProcessor;
99};
100
101#endif
SkAlphaType
Definition: SkAlphaType.h:26
const GrColorSpaceXform * colorXform() const
static std::unique_ptr< GrFragmentProcessor > Make(std::unique_ptr< GrFragmentProcessor > child, SkColorSpace *src, SkAlphaType srcAT, SkColorSpace *dst, SkAlphaType dstAT)
std::unique_ptr< GrFragmentProcessor > clone() const override
const char * name() const override
SkColor4f apply(const SkColor4f &srcColor)
const SkColorSpaceXformSteps & steps() const
static sk_sp< GrColorSpaceXform > Make(SkColorSpace *src, SkAlphaType srcAT, SkColorSpace *dst, SkAlphaType dstAT)
static bool Equals(const GrColorSpaceXform *a, const GrColorSpaceXform *b)
GrColorSpaceXform(const SkColorSpaceXformSteps &steps)
static uint32_t XformKey(const GrColorSpaceXform *xform)
GrFragmentProcessor(ClassID classID, OptimizationFlags optimizationFlags)
T * get() const
Definition: SkRefCnt.h:303
static bool b
struct MyStruct a[10]
dst
Definition: cp.py:12
Definition: GpuTools.h:21