OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_ | |
6 #define CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_ | |
7 | |
8 #include <cstdint> | |
9 #include <memory> | |
10 | |
11 #include "base/macros.h" | |
12 #include "cc/base/cc_export.h" | |
13 | |
14 class GrContext; | |
15 | |
16 namespace gpu { | |
17 class ContextSupport; | |
18 } | |
19 | |
20 namespace cc { | |
21 | |
22 // ContextCacheController manages clearing cached data on ContextProvider when | |
danakj
2016/08/26 23:49:08
My one thought is that it's a bit weird that the i
ericrk
2016/08/29 22:43:22
Yeah, I had a similar thought, but I assumed there
| |
23 // appropriate. Currently, cache clearing happens when the Context provider | |
danakj
2016/08/26 23:49:08
when the ContextProvider
ericrk
2016/08/29 22:43:22
Done.
| |
24 // transitions from Visible to Not Visible. As a ContextProvider may have | |
danakj
2016/08/26 23:49:08
visible to not visible
ericrk
2016/08/29 22:43:22
Done.
| |
25 // multiple clients, ContextCacheController tracks visibility across all | |
26 // clients and only cleans up when appropriate. | |
27 class CC_EXPORT ContextCacheController { | |
ericrk
2016/08/26 22:55:47
This name is a bit silly - I'm thinking of a bette
danakj
2016/08/26 23:49:08
lies it's perfect
| |
28 public: | |
29 class ScopedVisibility { | |
30 public: | |
31 ~ScopedVisibility(); | |
32 | |
33 private: | |
34 friend class ContextCacheController; | |
35 ScopedVisibility(); | |
36 void Release(); | |
37 | |
38 bool released_ = false; | |
39 }; | |
40 | |
41 explicit ContextCacheController(gpu::ContextSupport* context_support); | |
42 void SetGrContext(GrContext* gr_context); | |
danakj
2016/08/26 23:49:08
whitespace after constructors/destructor plz
ericrk
2016/08/29 22:43:22
Done.
| |
43 | |
44 // Clients of the owning ContextProvider should call this function when they | |
45 // become visible. The returned ScopedVisibility pointer must be passed back | |
46 // to ClientBecameNotVisible or it will DCHECK in its destructor. | |
47 std::unique_ptr<ScopedVisibility> ClientBecameVisible(); | |
48 | |
49 // When a client becomes not visible (either due to a visibility change or | |
50 // because it is being deleted), it must pass back any ScopedVisibility | |
51 // pointers it owns via this function. | |
52 void ClientBecameNotVisible( | |
53 std::unique_ptr<ScopedVisibility> scoped_visibility); | |
54 | |
55 private: | |
56 gpu::ContextSupport* context_support_; | |
57 GrContext* gr_context_ = nullptr; | |
58 | |
59 uint32_t num_clients_visible_ = 0; | |
60 }; | |
61 | |
62 } // namespace cc | |
63 | |
64 #endif // CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_ | |
OLD | NEW |