• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 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 CONTENT_COMMON_GPU_GPU_MEMORY_TRACKING_H_
6 #define CONTENT_COMMON_GPU_GPU_MEMORY_TRACKING_H_
7 
8 #include "base/basictypes.h"
9 #include "base/process/process.h"
10 #include "content/common/content_export.h"
11 #include "gpu/command_buffer/service/memory_tracking.h"
12 
13 namespace content {
14 
15 class GpuMemoryManager;
16 
17 // All decoders in a context group point to a single GpuMemoryTrackingGroup,
18 // which tracks GPU resource consumption for the entire context group.
19 class CONTENT_EXPORT GpuMemoryTrackingGroup {
20  public:
21   ~GpuMemoryTrackingGroup();
22   void TrackMemoryAllocatedChange(
23       uint64 old_size,
24       uint64 new_size,
25       gpu::gles2::MemoryTracker::Pool tracking_pool);
26   bool EnsureGPUMemoryAvailable(uint64 size_needed);
GetPid()27   base::ProcessId GetPid() const {
28     return pid_;
29   }
GetSize()30   uint64 GetSize() const {
31     return size_;
32   }
GetMemoryTracker()33   gpu::gles2::MemoryTracker* GetMemoryTracker() const {
34     return memory_tracker_;
35   }
36 
37  private:
38   friend class GpuMemoryManager;
39 
40   GpuMemoryTrackingGroup(base::ProcessId pid,
41                          gpu::gles2::MemoryTracker* memory_tracker,
42                          GpuMemoryManager* memory_manager);
43 
44   base::ProcessId pid_;
45   uint64 size_;
46 
47   // Set and used only during the Manage function, to determine which
48   // non-surface clients should be hibernated.
49   bool hibernated_;
50 
51   gpu::gles2::MemoryTracker* memory_tracker_;
52   GpuMemoryManager* memory_manager_;
53 };
54 
55 }  // namespace content
56 
57 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_TRACKING_H_
58