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,sk_sp<TextureProxy> dstTexture,SkIPoint dstOffset)15 KeyContext::KeyContext(skgpu::graphite::Recorder* recorder,
16 const SkM44& local2Dev,
17 const SkColorInfo& dstColorInfo,
18 OptimizeSampling optimizeSampling,
19 const SkColor4f& paintColor,
20 sk_sp<TextureProxy> dstTexture,
21 SkIPoint dstOffset)
22 : fRecorder(recorder)
23 , fLocal2Dev(local2Dev)
24 , fLocalMatrix(nullptr)
25 , fDstColorInfo(dstColorInfo)
26 , fOptimizeSampling(optimizeSampling)
27 , fCaps(recorder->priv().caps())
28 , fDstTexture(std::move(dstTexture))
29 , fDstOffset(dstOffset) {
30 fDictionary = fRecorder->priv().shaderCodeDictionary();
31 fRTEffectDict = fRecorder->priv().runtimeEffectDictionary();
32 fPaintColor = PaintParams::Color4fPrepForDst(paintColor, fDstColorInfo).makeOpaque().premul();
33 fPaintColor.fA = paintColor.fA;
34 }
35
KeyContext(const KeyContext & other)36 KeyContext::KeyContext(const KeyContext& other)
37 : fRecorder(other.fRecorder)
38 , fLocal2Dev(other.fLocal2Dev)
39 , fLocalMatrix(other.fLocalMatrix)
40 , fDictionary(other.fDictionary)
41 , fRTEffectDict(other.fRTEffectDict)
42 , fDstColorInfo(other.fDstColorInfo)
43 , fPaintColor(other.fPaintColor)
44 , fScope(other.fScope)
45 , fOptimizeSampling(other.fOptimizeSampling)
46 , fCaps(other.fCaps)
47 , fDstTexture(other.fDstTexture)
48 , fDstOffset(other.fDstOffset) {}
49
50 } // namespace skgpu::graphite
51