xref: /aosp_15_r20/external/skia/include/gpu/graphite/precompile/Precompile.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2024 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_precompile_Precompile_DEFINED
9 #define skgpu_graphite_precompile_Precompile_DEFINED
10 
11 #include "include/core/SkSpan.h"
12 #include "include/gpu/graphite/GraphiteTypes.h"
13 
14 namespace skgpu::graphite {
15 
16 class Context;
17 class PaintOptions;
18 class PrecompileContext;
19 
20 /**
21  *  Describes the required properties of a RenderPass that will be combined with the
22  *  other portions of the Precompilation API (i.e., paintOptions and drawTypes) to yield
23  *  a pipeline.
24  */
25 struct SK_API RenderPassProperties {
26     DepthStencilFlags fDSFlags      = DepthStencilFlags::kNone;
27     SkColorType       fDstCT        = kRGBA_8888_SkColorType;
28     bool              fRequiresMSAA = false;
29 };
30 
31 /**
32  * Precompilation allows clients to create pipelines ahead of time based on what they expect
33  * to draw. This can reduce performance hitches, due to inline compilation, during the actual
34  * drawing. Graphite will always be able to perform an inline compilation if some SkPaint
35  * combination was omitted from precompilation.
36  *
37  *   @param precompileContext    thread-safe helper holding required portions of the Context
38  *   @param paintOptions         captures a set of SkPaints that will be drawn
39  *   @param drawTypes            communicates which primitives those paints will be drawn with
40  *   @param renderPassProperties describes the RenderPasses needed for the desired Pipelines
41  */
42 void SK_API Precompile(PrecompileContext* precompileContext,
43                        const PaintOptions& paintOptions,
44                        DrawTypeFlags drawTypes,
45                        SkSpan<const RenderPassProperties> renderPassProperties);
46 
47 } // namespace skgpu::graphite
48 
49 #endif // skgpu_graphite_precompile_Precompile_DEFINED
50