• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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 "experimental/graphite/src/ContextUtils.h"
9 
10 #include <string>
11 #include "experimental/graphite/src/ContextPriv.h"
12 #include "experimental/graphite/src/DrawTypes.h"
13 #include "experimental/graphite/src/PaintParams.h"
14 #include "include/core/SkPaint.h"
15 #include "include/private/SkUniquePaintParamsID.h"
16 #include "src/core/SkBlenderBase.h"
17 #include "src/core/SkKeyHelpers.h"
18 #include "src/core/SkShaderCodeDictionary.h"
19 #include "src/core/SkUniform.h"
20 #include "src/core/SkUniformData.h"
21 
22 namespace skgpu {
23 
ExtractPaintData(SkShaderCodeDictionary * dict,const PaintParams & p)24 std::tuple<SkUniquePaintParamsID, std::unique_ptr<SkUniformBlock>> ExtractPaintData(
25         SkShaderCodeDictionary* dict,
26         const PaintParams& p) {
27 
28     SkPaintParamsKeyBuilder builder(dict);
29     std::unique_ptr<SkUniformBlock> block = std::make_unique<SkUniformBlock>();
30 
31     p.toKey(dict, SkBackend::kGraphite, &builder, block.get());
32 
33     std::unique_ptr<SkPaintParamsKey> key = builder.snap();
34 
35     auto entry = dict->findOrCreate(std::move(key));
36 
37     return { entry->uniqueID(), std::move(block) };
38 }
39 
40 } // namespace skgpu
41