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

Side by Side Diff: gpu/command_buffer/service/service_discardable_manager.h

Issue 2814583002: Service/ClientDiscardableManager (Closed)
Patch Set: rename Created 3 years, 8 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
(Empty)
1 // Copyright (c) 2017 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 GPU_COMMAND_BUFFER_SERVICE_SERVICE_DISCARDABLE_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_SERVICE_DISCARDABLE_MANAGER_H_
7
8 #include <vector>
9
10 #include "base/containers/mru_cache.h"
11 #include "gpu/command_buffer/common/discardable_handle.h"
12 #include "gpu/command_buffer/service/context_group.h"
13 #include "gpu/gpu_export.h"
14
15 namespace gpu {
16
17 class GPU_EXPORT ServiceDiscardableManager
18 : public base::RefCounted<ServiceDiscardableManager> {
piman 2017/05/02 22:21:03 nit: does this need to be refcounted, or could it
ericrk 2017/05/10 21:36:03 This is now a singly-owned object on GpuChannelMan
19 public:
20 ServiceDiscardableManager();
21
22 void InsertLockedTexture(uint32_t texture_id,
23 size_t texture_size,
24 gles2::ContextGroup* context_group,
25 ServiceDiscardableHandle handle);
26 // Returns false if texture_id does not exist.
27 bool UnlockTexture(uint32_t texture_id,
28 const gles2::ContextGroup* context_group);
29
30 // Called when a texture is deleted externally, via glDeleteTextures, to
31 // clean up state.
32 void OnTextureDeleted(uint32_t texture_id,
33 const gles2::ContextGroup* context_group);
34
35 // Test only functions:
36 size_t NumCacheEntriesForTesting() const { return entries_.size(); }
37 bool IsEntryLockedForTesting(uint32_t texture_id,
38 const gles2::ContextGroup* context_group) const;
39
40 private:
41 friend class base::RefCounted<ServiceDiscardableManager>;
42 ~ServiceDiscardableManager();
43
44 void EnforceLimits();
45
46 struct GpuDiscardableEntry {
47 ServiceDiscardableHandle handle;
48 size_t size;
49 };
50 struct GpuDiscardableEntryKey {
51 uint32_t texture_id;
52 const gles2::ContextGroup* context_group;
53 };
54 struct GpuDiscardableEntryKeyCompare {
55 bool operator()(const GpuDiscardableEntryKey& lhs,
56 const GpuDiscardableEntryKey& rhs) const {
57 return lhs.context_group < rhs.context_group ||
58 (lhs.context_group == rhs.context_group &&
59 lhs.texture_id < rhs.texture_id);
60 }
61 };
62 using EntryCache = base::MRUCache<GpuDiscardableEntryKey,
63 GpuDiscardableEntry,
64 GpuDiscardableEntryKeyCompare>;
65 EntryCache entries_;
66
67 size_t total_size_ = 0;
68 };
69
70 } // namespace gpu
71
72 #endif // GPU_COMMAND_BUFFER_SERVICE_SERVICE_DISCARDABLE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698