cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / gpu / command_buffer / client / buffer_tracker.h
blobe61c50188afcdc8b93211dcd1258052da6265536
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_
8 #include <GLES2/gl2.h>
10 #include <queue>
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"
15 namespace gpu {
17 class CommandBufferHelper;
18 class MappedMemoryManager;
20 namespace gles2 {
22 // Tracks buffer objects for client side of command buffer.
23 class GLES2_IMPL_EXPORT BufferTracker {
24 public:
25 class GLES2_IMPL_EXPORT Buffer {
26 public:
27 Buffer(GLuint id,
28 unsigned int size,
29 int32 shm_id,
30 uint32 shm_offset,
31 void* address)
32 : id_(id),
33 size_(size),
34 shm_id_(shm_id),
35 shm_offset_(shm_offset),
36 address_(address),
37 mapped_(false),
38 transfer_ready_token_(0) {
41 GLenum id() const {
42 return id_;
45 unsigned int size() const {
46 return size_;
49 int32 shm_id() const {
50 return shm_id_;
53 uint32 shm_offset() const {
54 return shm_offset_;
57 void* address() const {
58 return address_;
61 void set_mapped(bool mapped) {
62 mapped_ = mapped;
65 bool mapped() const {
66 return 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_;
77 private:
78 friend class BufferTracker;
79 friend class BufferTrackerTest;
81 GLuint id_;
82 unsigned int size_;
83 int32 shm_id_;
84 uint32 shm_offset_;
85 void* address_;
86 bool mapped_;
87 int32 transfer_ready_token_;
90 BufferTracker(MappedMemoryManager* manager);
91 ~BufferTracker();
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
98 // of a token.
99 void FreePendingToken(Buffer*, int32 token);
101 private:
102 typedef gpu::hash_map<GLuint, Buffer*> BufferMap;
104 MappedMemoryManager* mapped_memory_;
105 BufferMap buffers_;
107 DISALLOW_COPY_AND_ASSIGN(BufferTracker);
110 } // namespace gles2
111 } // namespace gpu
113 #endif // GPU_COMMAND_BUFFER_CLIENT_BUFFER_TRACKER_H_