| 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 <stdarg.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // 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|. |
| 332 // Return true otherwise. | 332 // Return true otherwise. |
| 333 bool RequestBuffersAccess( | 333 bool RequestBuffersAccess( |
| 334 ErrorState* error_state, | 334 ErrorState* error_state, |
| 335 const IndexedBufferBindingHost* bindings, | 335 const IndexedBufferBindingHost* bindings, |
| 336 const std::vector<GLsizeiptr>& variable_sizes, | 336 const std::vector<GLsizeiptr>& variable_sizes, |
| 337 GLsizei count, | 337 GLsizei count, |
| 338 const char* func_name, | 338 const char* func_name, |
| 339 const char* message_tag); | 339 const char* message_tag); |
| 340 | 340 |
| 341 uint32_t mapped_buffer_count() const { | |
| 342 return mapped_buffer_count_; | |
| 343 } | |
| 344 | |
| 345 private: | 341 private: |
| 346 friend class Buffer; | 342 friend class Buffer; |
| 347 friend class TestHelper; // Needs access to DoBufferData. | 343 friend class TestHelper; // Needs access to DoBufferData. |
| 348 friend class BufferManagerTestBase; // Needs access to DoBufferSubData. | 344 friend class BufferManagerTestBase; // Needs access to DoBufferSubData. |
| 349 friend class IndexedBufferBindingHostTest; // Needs access to SetInfo. | 345 friend class IndexedBufferBindingHostTest; // Needs access to SetInfo. |
| 350 | 346 |
| 351 void StartTracking(Buffer* buffer); | 347 void StartTracking(Buffer* buffer); |
| 352 void StopTracking(Buffer* buffer); | 348 void StopTracking(Buffer* buffer); |
| 353 | 349 |
| 354 // Does a glBufferSubData and updates the appropriate accounting. | 350 // Does a glBufferSubData and updates the appropriate accounting. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 385 bool UseShadowBuffer(GLenum target, GLenum usage); | 381 bool UseShadowBuffer(GLenum target, GLenum usage); |
| 386 | 382 |
| 387 // Sets the size, usage and initial data of a buffer. | 383 // Sets the size, usage and initial data of a buffer. |
| 388 // If data is NULL buffer will be initialized to 0 if shadowed. | 384 // If data is NULL buffer will be initialized to 0 if shadowed. |
| 389 void SetInfo(Buffer* buffer, | 385 void SetInfo(Buffer* buffer, |
| 390 GLenum target, | 386 GLenum target, |
| 391 GLsizeiptr size, | 387 GLsizeiptr size, |
| 392 GLenum usage, | 388 GLenum usage, |
| 393 bool use_shadow); | 389 bool use_shadow); |
| 394 | 390 |
| 395 void IncreaseMappedBufferCount(); | |
| 396 void DecreaseMappedBufferCount(); | |
| 397 | |
| 398 // Same as public RequestBufferAccess taking similar arguments, but | 391 // Same as public RequestBufferAccess taking similar arguments, but |
| 399 // allows caller to assemble the va_list. | 392 // allows caller to assemble the va_list. |
| 400 bool RequestBufferAccessV(ErrorState* error_state, | 393 bool RequestBufferAccessV(ErrorState* error_state, |
| 401 Buffer* buffer, | 394 Buffer* buffer, |
| 402 const char* func_name, | 395 const char* func_name, |
| 403 const char* error_message_format, | 396 const char* error_message_format, |
| 404 va_list varargs); | 397 va_list varargs); |
| 405 | 398 |
| 406 std::unique_ptr<MemoryTypeTracker> memory_type_tracker_; | 399 std::unique_ptr<MemoryTypeTracker> memory_type_tracker_; |
| 407 MemoryTracker* memory_tracker_; | 400 MemoryTracker* memory_tracker_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 422 | 415 |
| 423 // Counts the number of Buffer allocated with 'this' as its manager. | 416 // Counts the number of Buffer allocated with 'this' as its manager. |
| 424 // Allows to check no Buffer will outlive this. | 417 // Allows to check no Buffer will outlive this. |
| 425 unsigned int buffer_count_; | 418 unsigned int buffer_count_; |
| 426 | 419 |
| 427 GLuint primitive_restart_fixed_index_; | 420 GLuint primitive_restart_fixed_index_; |
| 428 | 421 |
| 429 bool lost_context_; | 422 bool lost_context_; |
| 430 bool use_client_side_arrays_for_stream_buffers_; | 423 bool use_client_side_arrays_for_stream_buffers_; |
| 431 | 424 |
| 432 // Keep track of total mapped buffer count. In most use cases it should be 0, | |
| 433 // so we could bypass checking each individual buffer as an optimization. | |
| 434 uint32_t mapped_buffer_count_; | |
| 435 | |
| 436 DISALLOW_COPY_AND_ASSIGN(BufferManager); | 425 DISALLOW_COPY_AND_ASSIGN(BufferManager); |
| 437 }; | 426 }; |
| 438 | 427 |
| 439 } // namespace gles2 | 428 } // namespace gles2 |
| 440 } // namespace gpu | 429 } // namespace gpu |
| 441 | 430 |
| 442 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ | 431 #endif // GPU_COMMAND_BUFFER_SERVICE_BUFFER_MANAGER_H_ |
| OLD | NEW |