Debian Codegraph @

src/gpu/ganesh/GrOnFlushResourceProvider.h

raw
1 /*
2 * Copyright 2017 Google Inc.
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 GrOnFlushResourceProvider_DEFINED
9 #define GrOnFlushResourceProvider_DEFINED
10
11 #include "src/gpu/AtlasTypes.h"
12
13 class GrCaps;
14 class GrDrawingManager;
15 class GrOnFlushResourceProvider;
16 class GrSurfaceProxy;
17
18 /*
19 * This is the base class from which all pre-flush callback objects must be derived. It
20 * provides the "preFlush" / "postFlush" interface.
21 */
22 class GrOnFlushCallbackObject {
23 public:
24 virtual ~GrOnFlushCallbackObject() {}
25
26 /*
27 * The preFlush callback allows subsystems (e.g., text, path renderers) to create atlases
28 * for a specific flush.
29 *
30 * Returns true on success; false on memory allocation failure
31 */
32 virtual bool preFlush(GrOnFlushResourceProvider*) = 0;
33
34 /**
35 * Called once flushing is complete. startTokenForNextFlush can be used to track resources
36 * used in the current flush.
37 */
38 virtual void postFlush(skgpu::Token startTokenForNextFlush) {}
39
40 /**
41 * Tells the callback owner to hold onto this object when freeing GPU resources.
42 */
43 virtual bool retainOnFreeGpuResources() { return false; }
44 };
45
46 /*
47 * This class is a shallow wrapper around the drawing manager. It is passed into the
48 * onFlush callbacks and is intended to limit the functionality available to them.
49 * It should never have additional data members or virtual methods.
50 */
51 class GrOnFlushResourceProvider {
52 public:
53 explicit GrOnFlushResourceProvider(GrDrawingManager* drawingMgr) : fDrawingMgr(drawingMgr) {}
54
55 [[nodiscard]] bool instantiateProxy(GrSurfaceProxy*);
56
57 const GrCaps* caps() const;
58
59 #if defined(GPU_TEST_UTILS)
60 bool failFlushTimeCallbacks() const;
61 #endif
62
63 private:
64 GrOnFlushResourceProvider(const GrOnFlushResourceProvider&) = delete;
65 GrOnFlushResourceProvider& operator=(const GrOnFlushResourceProvider&) = delete;
66
67 GrDrawingManager* fDrawingMgr;
68 };
69
70 #endif