We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / content / common / gpu / gpu_memory_manager_client.h
blob0c6c7d0920ffc3e55ba1b68ee82ddc6ea95e6a3f
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.
5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_CLIENT_H_
6 #define CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_CLIENT_H_
8 #include <list>
10 #include "base/basictypes.h"
11 #include "content/common/content_export.h"
12 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
13 #include "gpu/command_buffer/service/memory_tracking.h"
14 #include "ui/gfx/geometry/size.h"
16 namespace content {
18 class GpuMemoryManager;
19 class GpuMemoryTrackingGroup;
21 // The interface that the GPU memory manager uses to manipulate a client (to
22 // send it allocation information and query its properties).
23 class CONTENT_EXPORT GpuMemoryManagerClient {
24 public:
25 virtual ~GpuMemoryManagerClient() {}
27 // Returns surface size.
28 virtual gfx::Size GetSurfaceSize() const = 0;
30 // Returns the memory tracker for this stub.
31 virtual gpu::gles2::MemoryTracker* GetMemoryTracker() const = 0;
33 // Sets buffer usage depending on Memory Allocation
34 virtual void SetMemoryAllocation(
35 const gpu::MemoryAllocation& allocation) = 0;
37 virtual void SuggestHaveFrontBuffer(bool suggest_have_frontbuffer) = 0;
39 // Returns in bytes the total amount of GPU memory for the GPU which this
40 // context is currently rendering on. Returns false if no extension exists
41 // to get the exact amount of GPU memory.
42 virtual bool GetTotalGpuMemory(uint64* bytes) = 0;
45 // The state associated with a GPU memory manager client. This acts as the
46 // handle through which the client interacts with the GPU memory manager.
47 class CONTENT_EXPORT GpuMemoryManagerClientState {
48 public:
49 ~GpuMemoryManagerClientState();
50 void SetVisible(bool visible);
52 private:
53 friend class GpuMemoryManager;
55 GpuMemoryManagerClientState(GpuMemoryManager* memory_manager,
56 GpuMemoryManagerClient* client,
57 GpuMemoryTrackingGroup* tracking_group,
58 bool has_surface,
59 bool visible);
61 // The memory manager this client is hanging off of.
62 GpuMemoryManager* memory_manager_;
64 // The client to send allocations to.
65 GpuMemoryManagerClient* client_;
67 // The tracking group for this client.
68 GpuMemoryTrackingGroup* tracking_group_;
70 // Offscreen commandbuffers will not have a surface.
71 const bool has_surface_;
73 // Whether or not this client is visible.
74 bool visible_;
76 // If the client has a surface, then this is an iterator in the
77 // clients_visible_mru_ if this client is visible and
78 // clients_nonvisible_mru_ if this is non-visible. Otherwise this is an
79 // iterator in clients_nonsurface_.
80 std::list<GpuMemoryManagerClientState*>::iterator list_iterator_;
81 bool list_iterator_valid_;
83 // Set to disable allocating a frontbuffer or to disable allocations
84 // for clients that don't have surfaces.
85 bool hibernated_;
88 } // namespace content
90 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_CLIENT_H_