| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdarg.h> |
| 8 #include <stddef.h> | 9 #include <stddef.h> |
| 9 #include <stdint.h> | 10 #include <stdint.h> |
| 10 | 11 |
| 11 #include <map> | 12 #include <map> |
| 12 #include <memory> | 13 #include <memory> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
| 16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 17 #include "base/macros.h" | 18 #include "base/macros.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 // Same as above, but assume to access the entire buffer. | 312 // Same as above, but assume to access the entire buffer. |
| 312 Buffer* RequestBufferAccess(ContextState* context_state, | 313 Buffer* RequestBufferAccess(ContextState* context_state, |
| 313 GLenum target, | 314 GLenum target, |
| 314 const char* func_name); | 315 const char* func_name); |
| 315 // Same as above, but it can be any buffer rather than the buffer bound to | 316 // Same as above, but it can be any buffer rather than the buffer bound to |
| 316 // |target|. Return true if access is granted; return false if a GL error is | 317 // |target|. Return true if access is granted; return false if a GL error is |
| 317 // generated. | 318 // generated. |
| 318 bool RequestBufferAccess(ErrorState* error_state, | 319 bool RequestBufferAccess(ErrorState* error_state, |
| 319 Buffer* buffer, | 320 Buffer* buffer, |
| 320 const char* func_name, | 321 const char* func_name, |
| 321 const char* message_tag); | 322 const char* error_message_format, ...); |
| 322 // Generates INVALID_OPERATION if offset + size is out of range. | 323 // Generates INVALID_OPERATION if offset + size is out of range. |
| 323 bool RequestBufferAccess(ErrorState* error_state, | 324 bool RequestBufferAccess(ErrorState* error_state, |
| 324 Buffer* buffer, | 325 Buffer* buffer, |
| 325 GLintptr offset, | 326 GLintptr offset, |
| 326 GLsizeiptr size, | 327 GLsizeiptr size, |
| 327 const char* func_name, | 328 const char* func_name, |
| 328 const char* message_tag); | 329 const char* error_message); |
| 329 // Returns false and generates INVALID_OPERATION if buffer at binding |ii| | 330 // Returns false and generates INVALID_OPERATION if buffer at binding |ii| |
| 330 // doesn't exist, is mapped, or smaller than |variable_sizes[ii]| * |count|. | 331 // doesn't exist, is mapped, or smaller than |variable_sizes[ii]| * |count|. |
| 331 // Return true otherwise. | 332 // Return true otherwise. |
| 332 bool RequestBuffersAccess( | 333 bool RequestBuffersAccess( |
| 333 ErrorState* error_state, | 334 ErrorState* error_state, |
| 334 const IndexedBufferBindingHost* bindings, | 335 const IndexedBufferBindingHost* bindings, |
| 335 const std::vector<GLsizeiptr>& variable_sizes, | 336 const std::vector<GLsizeiptr>& variable_sizes, |
| 336 GLsizei count, | 337 GLsizei count, |
| 337 const char* func_name, | 338 const char* func_name, |
| 338 const char* message_tag); | 339 const char* message_tag); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 // If data is NULL buffer will be initialized to 0 if shadowed. | 388 // If data is NULL buffer will be initialized to 0 if shadowed. |
| 388 void SetInfo(Buffer* buffer, | 389 void SetInfo(Buffer* buffer, |
| 389 GLenum target, | 390 GLenum target, |
| 390 GLsizeiptr size, | 391 GLsizeiptr size, |
| 391 GLenum usage, | 392 GLenum usage, |
| 392 bool use_shadow); | 393 bool use_shadow); |
| 393 | 394 |
| 394 void IncreaseMappedBufferCount(); | 395 void IncreaseMappedBufferCount(); |
| 395 void DecreaseMappedBufferCount(); | 396 void DecreaseMappedBufferCount(); |
| 396 | 397 |
| 398 // Same as public RequestBufferAccess taking similar arguments, but |
| 399 // allows caller to assemble the va_list. |
| 400 bool RequestBufferAccessV(ErrorState* error_state, |
| 401 Buffer* buffer, |
| 402 const char* func_name, |
| 403 const char* error_message_format, |
| 404 va_list varargs); |
| 405 |
| 397 std::unique_ptr<MemoryTypeTracker> memory_type_tracker_; | 406 std::unique_ptr<MemoryTypeTracker> memory_type_tracker_; |
| 398 MemoryTracker* memory_tracker_; | 407 MemoryTracker* memory_tracker_; |
| 399 scoped_refptr<FeatureInfo> feature_info_; | 408 scoped_refptr<FeatureInfo> feature_info_; |
| 400 | 409 |
| 401 // Info for each buffer in the system. | 410 // Info for each buffer in the system. |
| 402 typedef base::hash_map<GLuint, scoped_refptr<Buffer> > BufferMap; | 411 typedef base::hash_map<GLuint, scoped_refptr<Buffer> > BufferMap; |
| 403 BufferMap buffers_; | 412 BufferMap buffers_; |
| 404 | 413 |
| 405 // The maximum size of buffers. | 414 // The maximum size of buffers. |
| 406 GLsizeiptr max_buffer_size_; | 415 GLsizeiptr max_buffer_size_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 424 // so we could bypass checking each individual buffer as an optimization. | 433 // so we could bypass checking each individual buffer as an optimization. |
| 425 uint32_t mapped_buffer_count_; | 434 uint32_t mapped_buffer_count_; |
| 426 | 435 |
| 427 DISALLOW_COPY_AND_ASSIGN(BufferManager); | 436 DISALLOW_COPY_AND_ASSIGN(BufferManager); |
| 428 }; | 437 }; |
| 429 | 438 |
| 430 } // namespace gles2 | 439 } // namespace gles2 |
| 431 } // namespace gpu | 440 } // namespace gpu |
| 432 | 441 |
| 433 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 442 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
| OLD | NEW |