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

Side by Side Diff: command_buffer/service/cross/resource.h

Issue 234002: More work in Command Buffers... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « command_buffer/service/cross/gl/texture_gl.cc ('k') | command_buffer/service/cross/resource.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 unsigned int flags_; 96 unsigned int flags_;
97 private: 97 private:
98 DISALLOW_COPY_AND_ASSIGN(IndexBuffer); 98 DISALLOW_COPY_AND_ASSIGN(IndexBuffer);
99 }; 99 };
100 100
101 // VertexStruct class, representing a vertex struct resource. 101 // VertexStruct class, representing a vertex struct resource.
102 class VertexStruct: public Resource { 102 class VertexStruct: public Resource {
103 public: 103 public:
104 // The representation of an input data stream. 104 // The representation of an input data stream.
105 struct Element { 105 struct Element {
106 ResourceID vertex_buffer; 106 ResourceId vertex_buffer;
107 unsigned int offset; 107 unsigned int offset;
108 unsigned int stride; 108 unsigned int stride;
109 vertex_struct::Type type; 109 vertex_struct::Type type;
110 vertex_struct::Semantic semantic; 110 vertex_struct::Semantic semantic;
111 unsigned int semantic_index; 111 unsigned int semantic_index;
112 }; 112 };
113 113
114 explicit VertexStruct(unsigned int count) 114 explicit VertexStruct(unsigned int count)
115 : count_(count), 115 : count_(count),
116 elements_(new Element[count]) { 116 elements_(new Element[count]) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // Base of ResourceMap. Contains most of the implementation of ResourceMap, to 215 // Base of ResourceMap. Contains most of the implementation of ResourceMap, to
216 // avoid template bloat. 216 // avoid template bloat.
217 class ResourceMapBase { 217 class ResourceMapBase {
218 public: 218 public:
219 ResourceMapBase() : resources_() {} 219 ResourceMapBase() : resources_() {}
220 ~ResourceMapBase() {} 220 ~ResourceMapBase() {}
221 221
222 // Assigns a resource to a resource ID. Assigning a resource to an ID that 222 // Assigns a resource to a resource ID. Assigning a resource to an ID that
223 // already has an existing resource will destroy that existing resource. The 223 // already has an existing resource will destroy that existing resource. The
224 // map takes ownership of the resource. 224 // map takes ownership of the resource.
225 void Assign(ResourceID id, Resource* resource); 225 void Assign(ResourceId id, Resource* resource);
226 // Destroys a resource. 226 // Destroys a resource.
227 bool Destroy(ResourceID id); 227 bool Destroy(ResourceId id);
228 // Destroy all resources. 228 // Destroy all resources.
229 void DestroyAllResources(); 229 void DestroyAllResources();
230 // Gets a resource by ID. 230 // Gets a resource by ID.
231 Resource *Get(ResourceID id) { 231 Resource *Get(ResourceId id) {
232 return (id < resources_.size()) ? resources_[id] : NULL; 232 return (id < resources_.size()) ? resources_[id] : NULL;
233 } 233 }
234 private: 234 private:
235 typedef std::vector<Resource *> Container; 235 typedef std::vector<Resource *> Container;
236 Container resources_; 236 Container resources_;
237 }; 237 };
238 238
239 // Resource Map class, allowing resource ID <-> Resource association. This is a 239 // Resource Map class, allowing resource ID <-> Resource association. This is a
240 // dense map, optimized for retrieval (O(1)). 240 // dense map, optimized for retrieval (O(1)).
241 template<class T> class ResourceMap { 241 template<class T> class ResourceMap {
242 public: 242 public:
243 ResourceMap() : container_() {} 243 ResourceMap() : container_() {}
244 ~ResourceMap() {} 244 ~ResourceMap() {}
245 245
246 // Assigns a resource to a resource ID. Assigning a resource to an ID that 246 // Assigns a resource to a resource ID. Assigning a resource to an ID that
247 // already has an existing resource will destroy that existing resource. The 247 // already has an existing resource will destroy that existing resource. The
248 // map takes ownership of the resource. 248 // map takes ownership of the resource.
249 void Assign(ResourceID id, T* resource) { 249 void Assign(ResourceId id, T* resource) {
250 container_.Assign(id, resource); 250 container_.Assign(id, resource);
251 } 251 }
252 // Destroys a resource. 252 // Destroys a resource.
253 bool Destroy(ResourceID id) { 253 bool Destroy(ResourceId id) {
254 return container_.Destroy(id); 254 return container_.Destroy(id);
255 } 255 }
256 // Destroy all resources. 256 // Destroy all resources.
257 void DestroyAllResources() { 257 void DestroyAllResources() {
258 return container_.DestroyAllResources(); 258 return container_.DestroyAllResources();
259 } 259 }
260 // Gets a resource by ID. 260 // Gets a resource by ID.
261 T *Get(ResourceID id) { 261 T *Get(ResourceId id) {
262 return down_cast<T*>(container_.Get(id)); 262 return down_cast<T*>(container_.Get(id));
263 } 263 }
264 private: 264 private:
265 ResourceMapBase container_; 265 ResourceMapBase container_;
266 }; 266 };
267 267
268 } // namespace command_buffer 268 } // namespace command_buffer
269 } // namespace o3d 269 } // namespace o3d
270 270
271 #endif // O3D_COMMAND_BUFFER_SERVICE_CROSS_RESOURCE_H_ 271 #endif // O3D_COMMAND_BUFFER_SERVICE_CROSS_RESOURCE_H_
OLDNEW
« no previous file with comments | « command_buffer/service/cross/gl/texture_gl.cc ('k') | command_buffer/service/cross/resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698