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