Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
KeyContext.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 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 skgpu_graphite_KeyContext_DEFINED
9#define skgpu_graphite_KeyContext_DEFINED
10
12#include "include/core/SkM44.h"
17
18namespace skgpu::graphite {
19
20class Caps;
21enum class DstReadRequirement;
22class Recorder;
23class RuntimeEffectDictionary;
24class ShaderCodeDictionary;
25
26// The key context must always be able to provide a valid ShaderCodeDictionary and
27// SkRuntimeEffectDictionary. Depending on the calling context it can also supply a
28// backend-specific resource providing object (e.g., a Recorder).
30public:
31 // Constructor for the pre-compile code path (i.e., no Recorder)
44
45 // Constructor for the ExtractPaintData code path (i.e., with a Recorder)
47 const SkM44& local2Dev,
49 const SkColor4f& paintColor,
52
53 KeyContext(const KeyContext&);
54
55 Recorder* recorder() const { return fRecorder; }
56
57 const Caps* caps() const { return fCaps; }
58
59 const SkM44& local2Dev() const { return fLocal2Dev; }
60 const SkMatrix* localMatrix() const { return fLocalMatrix; }
61
64
65 const SkColorInfo& dstColorInfo() const { return fDstColorInfo; }
66
67 // Proxy to the destination texture, if it needs to be read from, or null otherwise.
68 sk_sp<TextureProxy> dstTexture() const { return fDstTexture; }
69 // Offset within dstTexture to the top-left corner of the area that needs to be read.
70 SkIPoint dstOffset() const { return fDstOffset; }
71
72 const SkPMColor4f& paintColor() const { return fPaintColor; }
73
74 enum class Scope {
77 };
78
79 Scope scope() const { return fScope; }
80
81protected:
82 Recorder* fRecorder = nullptr;
88 // Although stored as premul the paint color is actually comprised of an opaque RGB portion
89 // and a separate alpha portion. The two portions will never be used together but are stored
90 // together to reduce the number of uniforms.
93
94private:
95 const Caps* fCaps = nullptr;
96 sk_sp<TextureProxy> fDstTexture;
97 SkIPoint fDstOffset;
98};
99
101public:
102 KeyContextWithLocalMatrix(const KeyContext& other, const SkMatrix& childLM)
103 : KeyContext(other) {
104 if (fLocalMatrix) {
105 fStorage = SkMatrix::Concat(childLM, *fLocalMatrix);
106 } else {
107 fStorage = childLM;
108 }
109
110 fLocalMatrix = &fStorage;
111 }
112
113private:
115 KeyContextWithLocalMatrix& operator=(const KeyContextWithLocalMatrix&) = delete;
116
117 SkMatrix fStorage;
118};
119
121public:
123 // We want to keep fPaintColor's alpha value but replace the RGB with values in the new
124 // color space
126 tmp.fA = 1.0f;
128 fPaintColor.fR = tmp.fR;
129 fPaintColor.fG = tmp.fG;
130 fPaintColor.fB = tmp.fB;
132 }
133
134private:
136 KeyContextWithColorInfo& operator=(const KeyContextWithColorInfo&) = delete;
137};
138
140public:
144
145private:
147 KeyContextWithScope& operator=(const KeyContextWithScope&) = delete;
148};
149
150} // namespace skgpu::graphite
151
152#endif // skgpu_graphite_KeyContext_DEFINED
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
constexpr SkPMColor4f SK_PMColor4fBLACK
Definition SkM44.h:150
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
Definition SkMatrix.h:1775
KeyContextWithColorInfo(const KeyContext &other, const SkColorInfo &info)
Definition KeyContext.h:122
KeyContextWithLocalMatrix(const KeyContext &other, const SkMatrix &childLM)
Definition KeyContext.h:102
KeyContextWithScope(const KeyContext &other, KeyContext::Scope scope)
Definition KeyContext.h:141
const SkM44 & local2Dev() const
Definition KeyContext.h:59
RuntimeEffectDictionary * rtEffectDict() const
Definition KeyContext.h:63
SkIPoint dstOffset() const
Definition KeyContext.h:70
Recorder * recorder() const
Definition KeyContext.h:55
RuntimeEffectDictionary * fRTEffectDict
Definition KeyContext.h:86
const SkMatrix * localMatrix() const
Definition KeyContext.h:60
const SkPMColor4f & paintColor() const
Definition KeyContext.h:72
KeyContext(const Caps *caps, ShaderCodeDictionary *dict, RuntimeEffectDictionary *rtEffectDict, const SkColorInfo &dstColorInfo, sk_sp< TextureProxy > dstTexture, SkIPoint dstOffset)
Definition KeyContext.h:32
sk_sp< TextureProxy > dstTexture() const
Definition KeyContext.h:68
const SkColorInfo & dstColorInfo() const
Definition KeyContext.h:65
ShaderCodeDictionary * fDictionary
Definition KeyContext.h:85
ShaderCodeDictionary * dict() const
Definition KeyContext.h:62
const Caps * caps() const
Definition KeyContext.h:57
Definition ref_ptr.h:256
void apply(float rgba[4]) const
const float * vec() const
Definition SkColor.h:308
float fB
blue component
Definition SkColor.h:265
float fR
red component
Definition SkColor.h:263
float fG
green component
Definition SkColor.h:264
float fA
alpha component
Definition SkColor.h:266