Debian Codegraph @

tools/gpu/BackendTextureImageFactory.h

raw
1 /*
2 * Copyright 2020 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 "include/core/SkColor.h"
9 #include "include/core/SkImageInfo.h"
10 #include "include/core/SkRefCnt.h"
11 #include "include/gpu/GpuTypes.h"
12
13 #if defined(SK_GANESH)
14 #include "include/gpu/ganesh/GrTypes.h"
15 #endif
16
17 class SkColorSpace;
18 class SkImage;
19 class SkPixmap;
20 struct SkISize;
21
22 #ifdef SK_GANESH
23 class GrDirectContext;
24 #endif
25
26 #ifdef SK_GRAPHITE
27 namespace skgpu::graphite {
28 class Recorder;
29 }
30 using Origin = skgpu::Origin; // TODO: Can we migrate Ganesh to use this?
31 #endif
32
33 namespace sk_gpu_test {
34
35 using Mipmapped = skgpu::Mipmapped;
36 using Protected = skgpu::Protected;
37 using Renderable = skgpu::Renderable;
38
39 #ifdef SK_GANESH
40 /**
41 * Creates a backend texture with pixmap contents and wraps it in a SkImage that safely deletes
42 * the texture when it goes away. Unlike using makeTextureImage() on a non-GPU image, this will
43 * fail rather than fallback if the pixmaps's color type doesn't map to a supported texture format.
44 * For testing purposes the texture can be made renderable to exercise different code paths for
45 * renderable textures/formats.
46 */
47 sk_sp<SkImage> MakeBackendTextureImage(GrDirectContext*,
48 const SkPixmap&,
49 Renderable,
50 GrSurfaceOrigin,
51 Protected = Protected::kNo);
52
53 /** Creates a solid color image. */
54 sk_sp<SkImage> MakeBackendTextureImage(GrDirectContext*,
55 const SkImageInfo& info,
56 SkColor4f,
57 Mipmapped = Mipmapped::kNo,
58 Renderable = Renderable::kNo,
59 GrSurfaceOrigin = GrSurfaceOrigin::kTopLeft_GrSurfaceOrigin,
60 Protected isProtected = Protected::kNo);
61 #endif // SK_GANESH
62
63 #ifdef SK_GRAPHITE
64 /*
65 * Graphite versions of MakeBackendTextureImage
66 */
67 sk_sp<SkImage> MakeBackendTextureImage(skgpu::graphite::Recorder*,
68 const SkPixmap&,
69 Mipmapped,
70 Renderable,
71 Origin,
72 Protected = Protected::kNo);
73
74 /** Creates a solid color image. */
75 sk_sp<SkImage> MakeBackendTextureImage(skgpu::graphite::Recorder*,
76 const SkImageInfo&,
77 SkColor4f,
78 Mipmapped,
79 Renderable,
80 Origin,
81 Protected = Protected::kNo);
82
83 #endif // SK_GRAPHITE
84
85 } // namespace sk_gpu_test