Debian Codegraph @

include/private/gpu/ganesh/GrTextureGenerator.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 GrTextureGenerator_DEFINED
9 #define GrTextureGenerator_DEFINED
10
11 #include "include/core/SkImageGenerator.h"
12 #include "include/gpu/ganesh/GrTypes.h"
13 #include "include/private/base/SkAPI.h"
14
15 #include <cstdint>
16
17 class GrRecordingContext;
18 class GrSurfaceProxyView;
19 enum class GrImageTexGenPolicy : int;
20 namespace skgpu { enum class Mipmapped : bool; }
21 struct SkImageInfo;
22
23 class SK_API GrTextureGenerator : public SkImageGenerator {
24 public:
25 bool isTextureGenerator() const final { return true; }
26
27 /**
28 * If the generator can natively/efficiently return its pixels as a GPU image (backed by a
29 * texture) this will return that image. If not, this will return NULL.
30 *
31 * Regarding the GrRecordingContext parameter:
32 *
33 * It must be non-NULL. The generator should only succeed if:
34 * - its internal context is the same
35 * - it can somehow convert its texture into one that is valid for the provided context.
36 *
37 * If the mipmapped parameter is kYes, the generator should try to create a TextureProxy that
38 * at least has the mip levels allocated and the base layer filled in. If this is not possible,
39 * the generator is allowed to return a non mipped proxy, but this will have some additional
40 * overhead in later allocating mips and copying of the base layer.
41 *
42 * GrImageTexGenPolicy determines whether or not a new texture must be created (and its budget
43 * status) or whether this may (but is not required to) return a pre-existing texture that is
44 * retained by the generator (kDraw).
45 */
46 GrSurfaceProxyView generateTexture(GrRecordingContext*,
47 const SkImageInfo& info,
48 skgpu::Mipmapped mipmapped,
49 GrImageTexGenPolicy);
50
51 // External clients should override GrExternalTextureGenerator instead of trying to implement
52 // this (which uses private Skia types)
53 virtual GrSurfaceProxyView onGenerateTexture(GrRecordingContext*, const SkImageInfo&,
54 skgpu::Mipmapped, GrImageTexGenPolicy) = 0;
55
56 // Most internal SkImageGenerators produce textures and views that use kTopLeft_GrSurfaceOrigin.
57 // If the generator may produce textures with different origins (e.g.
58 // GrAHardwareBufferImageGenerator) it should override this function to return the correct
59 // origin. Implementations should be thread-safe.
60 virtual GrSurfaceOrigin origin() const { return kTopLeft_GrSurfaceOrigin; }
61
62 protected:
63 GrTextureGenerator(const SkImageInfo& info, uint32_t uniqueId = kNeedNewImageUniqueID);
64 };
65
66 #endif // GrTextureGenerator_DEFINED