Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: cc/output/context_cache_controller.h

Issue 2286873003: Provide TaskRunner to ContextCacheController (Closed)
Patch Set: fix unittests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_ 5 #ifndef CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_
6 #define CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_ 6 #define CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_
7 7
8 #include <cstdint> 8 #include <cstdint>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
12 #include "cc/base/cc_export.h" 13 #include "cc/base/cc_export.h"
13 14
14 class GrContext; 15 class GrContext;
15 16
17 namespace base {
18 class SingleThreadTaskRunner;
19 }
20
16 namespace gpu { 21 namespace gpu {
17 class ContextSupport; 22 class ContextSupport;
18 } 23 }
19 24
20 namespace cc { 25 namespace cc {
21 26
22 // ContextCacheController manages clearing cached data on ContextProvider when 27 // ContextCacheController manages clearing cached data on ContextProvider when
23 // appropriate. Currently, cache clearing happens when the ContextProvider 28 // appropriate. Currently, cache clearing happens when the ContextProvider
24 // transitions from visible to not visible. As a ContextProvider may have 29 // transitions from visible to not visible. As a ContextProvider may have
25 // multiple clients, ContextCacheController tracks visibility across all 30 // multiple clients, ContextCacheController tracks visibility across all
26 // clients and only cleans up when appropriate. 31 // clients and only cleans up when appropriate.
27 // 32 //
28 // Note: Virtuals on this function are for testing only. This function is not 33 // Note: Virtuals on this function are for testing only. This function is not
29 // designed to have multiple implementations. 34 // designed to have multiple implementations.
30 class CC_EXPORT ContextCacheController { 35 class CC_EXPORT ContextCacheController {
31 public: 36 public:
32 class CC_EXPORT ScopedVisibility { 37 class CC_EXPORT ScopedVisibility {
33 public: 38 public:
34 ~ScopedVisibility(); 39 ~ScopedVisibility();
35 40
36 private: 41 private:
37 friend class ContextCacheController; 42 friend class ContextCacheController;
38 ScopedVisibility(); 43 ScopedVisibility();
39 void Release(); 44 void Release();
40 45
41 bool released_ = false; 46 bool released_ = false;
42 }; 47 };
43 48
44 explicit ContextCacheController(gpu::ContextSupport* context_support); 49 ContextCacheController(
50 gpu::ContextSupport* context_support,
51 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
45 virtual ~ContextCacheController(); 52 virtual ~ContextCacheController();
46 53
47 void SetGrContext(GrContext* gr_context); 54 void SetGrContext(GrContext* gr_context);
48 55
49 // Clients of the owning ContextProvider should call this function when they 56 // Clients of the owning ContextProvider should call this function when they
50 // become visible. The returned ScopedVisibility pointer must be passed back 57 // become visible. The returned ScopedVisibility pointer must be passed back
51 // to ClientBecameNotVisible or it will DCHECK in its destructor. 58 // to ClientBecameNotVisible or it will DCHECK in its destructor.
52 virtual std::unique_ptr<ScopedVisibility> ClientBecameVisible(); 59 virtual std::unique_ptr<ScopedVisibility> ClientBecameVisible();
53 60
54 // When a client becomes not visible (either due to a visibility change or 61 // When a client becomes not visible (either due to a visibility change or
55 // because it is being deleted), it must pass back any ScopedVisibility 62 // because it is being deleted), it must pass back any ScopedVisibility
56 // pointers it owns via this function. 63 // pointers it owns via this function.
57 virtual void ClientBecameNotVisible( 64 virtual void ClientBecameNotVisible(
58 std::unique_ptr<ScopedVisibility> scoped_visibility); 65 std::unique_ptr<ScopedVisibility> scoped_visibility);
59 66
60 protected: 67 protected:
61 std::unique_ptr<ScopedVisibility> CreateScopedVisibilityForTesting() const; 68 std::unique_ptr<ScopedVisibility> CreateScopedVisibilityForTesting() const;
62 void ReleaseScopedVisibilityForTesting( 69 void ReleaseScopedVisibilityForTesting(
63 std::unique_ptr<ScopedVisibility> scoped_visibility) const; 70 std::unique_ptr<ScopedVisibility> scoped_visibility) const;
64 71
65 private: 72 private:
66 gpu::ContextSupport* context_support_; 73 gpu::ContextSupport* context_support_;
74 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
danakj 2016/09/19 18:59:17 Remind me why this is here? It's not used.
ericrk 2016/09/19 20:00:27 I'm going to use it in a follow-up CL I'll send af
67 GrContext* gr_context_ = nullptr; 75 GrContext* gr_context_ = nullptr;
68 76
69 uint32_t num_clients_visible_ = 0; 77 uint32_t num_clients_visible_ = 0;
70 }; 78 };
71 79
72 } // namespace cc 80 } // namespace cc
73 81
74 #endif // CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_ 82 #endif // CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698