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 GPU_COMMAND_BUFFER_CLIENT_BUFFER_TRACKER_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_BUFFER_TRACKER_H_
11 #include "gles2_impl_export.h"
12 #include "gpu/command_buffer/client/hash_tables.h"
13 #include "gpu/command_buffer/common/gles2_cmd_format.h"
17 class CommandBufferHelper
;
18 class MappedMemoryManager
;
22 // Tracks buffer objects for client side of command buffer.
23 class GLES2_IMPL_EXPORT BufferTracker
{
25 class GLES2_IMPL_EXPORT Buffer
{
35 shm_offset_(shm_offset
),
38 transfer_ready_token_(0) {
45 unsigned int size() const {
49 int32
shm_id() const {
53 uint32
shm_offset() const {
57 void* address() const {
61 void set_mapped(bool mapped
) {
69 void set_transfer_ready_token(int token
) {
70 transfer_ready_token_
= token
;
73 uint32
transfer_ready_token() const {
74 return transfer_ready_token_
;
78 friend class BufferTracker
;
79 friend class BufferTrackerTest
;
87 int32 transfer_ready_token_
;
90 BufferTracker(MappedMemoryManager
* manager
);
93 Buffer
* CreateBuffer(GLuint id
, GLsizeiptr size
);
94 Buffer
* GetBuffer(GLuint id
);
95 void RemoveBuffer(GLuint id
);
97 // Frees the block of memory associated with buffer, pending the passage
99 void FreePendingToken(Buffer
*, int32 token
);
102 typedef gpu::hash_map
<GLuint
, Buffer
*> BufferMap
;
104 MappedMemoryManager
* mapped_memory_
;
107 DISALLOW_COPY_AND_ASSIGN(BufferTracker
);
113 #endif // GPU_COMMAND_BUFFER_CLIENT_BUFFER_TRACKER_H_