Debian Codegraph @

tools/gpu/ProtectedUtils.h

raw
1 /*
2 * Copyright 2023 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 ProtectedUtils_DEFINED
9 #define ProtectedUtils_DEFINED
10
11 #include "include/core/SkColor.h"
12 #include "include/core/SkRefCnt.h"
13
14 class GrDirectContext;
15 class SkImage;
16 class SkSurface;
17 class SkSurfaceProps;
18 struct SkISize;
19
20 #ifdef SK_GRAPHITE
21 namespace skgpu {
22 enum class Protected : bool;
23 }
24 namespace skgpu::graphite {
25 class Recorder;
26 }
27 #endif
28
29 namespace ProtectedUtils {
30
31 #ifdef SK_GANESH
32 /*
33 * These factories create Surfaces and Images with an explicitly specified protected status.
34 * If the Surface/Image cannot be created with the specified protected status nullptr will
35 * be returned.
36 */
37
38 sk_sp<SkSurface> CreateProtectedSkSurface(GrDirectContext*,
39 SkISize size,
40 bool textureable,
41 bool isProtected,
42 const SkSurfaceProps* = nullptr);
43
44 void CheckImageBEProtection(SkImage*, bool expectingProtected);
45
46 sk_sp<SkImage> CreateProtectedSkImage(GrDirectContext*,
47 SkISize size,
48 SkColor4f color,
49 bool isProtected);
50 #endif
51
52 #ifdef SK_GRAPHITE
53 sk_sp<SkSurface> CreateProtectedSkSurface(skgpu::graphite::Recorder*,
54 SkISize size,
55 skgpu::Protected);
56
57 sk_sp<SkImage> CreateProtectedSkImage(skgpu::graphite::Recorder*,
58 SkISize size,
59 SkColor4f color,
60 skgpu::Protected);
61 #endif
62
63 } // namespace ProtectedUtils
64
65 #endif // ProtectedUtils_DEFINED