xref: /aosp_15_r20/external/skia/src/gpu/graphite/KeyContext.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 #include "src/gpu/graphite/KeyContext.h"
9 
10 #include "src/gpu/graphite/PaintParams.h"
11 #include "src/gpu/graphite/RecorderPriv.h"
12 
13 namespace skgpu::graphite {
14 
KeyContext(skgpu::graphite::Recorder * recorder,const SkM44 & local2Dev,const SkColorInfo & dstColorInfo,OptimizeSampling optimizeSampling,const SkColor4f & paintColor)15 KeyContext::KeyContext(skgpu::graphite::Recorder* recorder,
16                        const SkM44& local2Dev,
17                        const SkColorInfo& dstColorInfo,
18                        OptimizeSampling optimizeSampling,
19                        const SkColor4f& paintColor)
20         : fRecorder(recorder)
21         , fLocal2Dev(local2Dev)
22         , fLocalMatrix(nullptr)
23         , fDstColorInfo(dstColorInfo)
24         , fOptimizeSampling(optimizeSampling)
25         , fCaps(recorder->priv().caps()) {
26     fDictionary = fRecorder->priv().shaderCodeDictionary();
27     fRTEffectDict = fRecorder->priv().runtimeEffectDictionary();
28     fPaintColor = PaintParams::Color4fPrepForDst(paintColor, fDstColorInfo).makeOpaque().premul();
29     fPaintColor.fA = paintColor.fA;
30 }
31 
KeyContext(const KeyContext & other)32 KeyContext::KeyContext(const KeyContext& other)
33         : fRecorder(other.fRecorder)
34         , fLocal2Dev(other.fLocal2Dev)
35         , fLocalMatrix(other.fLocalMatrix)
36         , fDictionary(other.fDictionary)
37         , fRTEffectDict(other.fRTEffectDict)
38         , fDstColorInfo(other.fDstColorInfo)
39         , fPaintColor(other.fPaintColor)
40         , fScope(other.fScope)
41         , fOptimizeSampling(other.fOptimizeSampling)
42         , fCaps(other.fCaps) {}
43 
44 } // namespace skgpu::graphite
45