OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ | 5 #ifndef CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ |
6 #define CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ | 6 #define CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
| 11 #include <unordered_map> |
| 12 #include <unordered_set> |
11 #include <vector> | 13 #include <vector> |
12 | 14 |
13 #include "base/callback.h" | 15 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
15 #include "base/containers/hash_tables.h" | |
16 #include "base/containers/scoped_ptr_hash_map.h" | |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
22 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
23 #include "cc/output/context_provider.h" | 23 #include "cc/output/context_provider.h" |
24 #include "cc/test/ordered_texture_map.h" | 24 #include "cc/test/ordered_texture_map.h" |
25 #include "cc/test/test_texture.h" | 25 #include "cc/test/test_texture.h" |
26 #include "gpu/command_buffer/common/sync_token.h" | 26 #include "gpu/command_buffer/common/sync_token.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 struct TextureTargets { | 398 struct TextureTargets { |
399 TextureTargets(); | 399 TextureTargets(); |
400 ~TextureTargets(); | 400 ~TextureTargets(); |
401 | 401 |
402 void BindTexture(GLenum target, GLuint id); | 402 void BindTexture(GLenum target, GLuint id); |
403 void UnbindTexture(GLuint id); | 403 void UnbindTexture(GLuint id); |
404 | 404 |
405 GLuint BoundTexture(GLenum target); | 405 GLuint BoundTexture(GLenum target); |
406 | 406 |
407 private: | 407 private: |
408 typedef base::hash_map<GLenum, GLuint> TargetTextureMap; | 408 typedef std::unordered_map<GLenum, GLuint> TargetTextureMap; |
409 TargetTextureMap bound_textures_; | 409 TargetTextureMap bound_textures_; |
410 }; | 410 }; |
411 | 411 |
412 struct Buffer { | 412 struct Buffer { |
413 Buffer(); | 413 Buffer(); |
414 ~Buffer(); | 414 ~Buffer(); |
415 | 415 |
416 GLenum target; | 416 GLenum target; |
417 scoped_ptr<uint8_t[]> pixels; | 417 scoped_ptr<uint8_t[]> pixels; |
418 size_t size; | 418 size_t size; |
(...skipping 14 matching lines...) Expand all Loading... |
433 | 433 |
434 struct Namespace : public base::RefCountedThreadSafe<Namespace> { | 434 struct Namespace : public base::RefCountedThreadSafe<Namespace> { |
435 Namespace(); | 435 Namespace(); |
436 | 436 |
437 // Protects all fields. | 437 // Protects all fields. |
438 base::Lock lock; | 438 base::Lock lock; |
439 unsigned next_buffer_id; | 439 unsigned next_buffer_id; |
440 unsigned next_image_id; | 440 unsigned next_image_id; |
441 unsigned next_texture_id; | 441 unsigned next_texture_id; |
442 unsigned next_renderbuffer_id; | 442 unsigned next_renderbuffer_id; |
443 base::ScopedPtrHashMap<unsigned, scoped_ptr<Buffer>> buffers; | 443 std::unordered_map<unsigned, scoped_ptr<Buffer>> buffers; |
444 base::hash_set<unsigned> images; | 444 std::unordered_set<unsigned> images; |
445 OrderedTextureMap textures; | 445 OrderedTextureMap textures; |
446 base::hash_set<unsigned> renderbuffer_set; | 446 std::unordered_set<unsigned> renderbuffer_set; |
447 | 447 |
448 private: | 448 private: |
449 friend class base::RefCountedThreadSafe<Namespace>; | 449 friend class base::RefCountedThreadSafe<Namespace>; |
450 ~Namespace(); | 450 ~Namespace(); |
451 DISALLOW_COPY_AND_ASSIGN(Namespace); | 451 DISALLOW_COPY_AND_ASSIGN(Namespace); |
452 }; | 452 }; |
453 | 453 |
454 TestWebGraphicsContext3D(); | 454 TestWebGraphicsContext3D(); |
455 | 455 |
456 void CreateNamespace(); | 456 void CreateNamespace(); |
457 GLuint BoundTextureId(GLenum target); | 457 GLuint BoundTextureId(GLenum target); |
458 scoped_refptr<TestTexture> BoundTexture(GLenum target); | 458 scoped_refptr<TestTexture> BoundTexture(GLenum target); |
459 scoped_refptr<TestTexture> UnboundTexture(GLuint texture); | 459 scoped_refptr<TestTexture> UnboundTexture(GLuint texture); |
460 void CheckTextureIsBound(GLenum target); | 460 void CheckTextureIsBound(GLenum target); |
461 | 461 |
462 unsigned context_id_; | 462 unsigned context_id_; |
463 ContextProvider::Capabilities test_capabilities_; | 463 ContextProvider::Capabilities test_capabilities_; |
464 int times_bind_texture_succeeds_; | 464 int times_bind_texture_succeeds_; |
465 int times_end_query_succeeds_; | 465 int times_end_query_succeeds_; |
466 bool context_lost_; | 466 bool context_lost_; |
467 int times_map_buffer_chromium_succeeds_; | 467 int times_map_buffer_chromium_succeeds_; |
468 int current_used_transfer_buffer_usage_bytes_; | 468 int current_used_transfer_buffer_usage_bytes_; |
469 int max_used_transfer_buffer_usage_bytes_; | 469 int max_used_transfer_buffer_usage_bytes_; |
470 base::Closure context_lost_callback_; | 470 base::Closure context_lost_callback_; |
471 base::hash_set<unsigned> used_textures_; | 471 std::unordered_set<unsigned> used_textures_; |
472 unsigned next_program_id_; | 472 unsigned next_program_id_; |
473 base::hash_set<unsigned> program_set_; | 473 std::unordered_set<unsigned> program_set_; |
474 unsigned next_shader_id_; | 474 unsigned next_shader_id_; |
475 base::hash_set<unsigned> shader_set_; | 475 std::unordered_set<unsigned> shader_set_; |
476 unsigned next_framebuffer_id_; | 476 unsigned next_framebuffer_id_; |
477 base::hash_set<unsigned> framebuffer_set_; | 477 std::unordered_set<unsigned> framebuffer_set_; |
478 unsigned current_framebuffer_; | 478 unsigned current_framebuffer_; |
479 std::vector<TestWebGraphicsContext3D*> shared_contexts_; | 479 std::vector<TestWebGraphicsContext3D*> shared_contexts_; |
480 int max_texture_size_; | 480 int max_texture_size_; |
481 bool reshape_called_; | 481 bool reshape_called_; |
482 int width_; | 482 int width_; |
483 int height_; | 483 int height_; |
484 float scale_factor_; | 484 float scale_factor_; |
485 TestContextSupport* test_support_; | 485 TestContextSupport* test_support_; |
486 gfx::Rect update_rect_; | 486 gfx::Rect update_rect_; |
487 UpdateType last_update_type_; | 487 UpdateType last_update_type_; |
488 GLuint64 next_insert_fence_sync_; | 488 GLuint64 next_insert_fence_sync_; |
489 gpu::SyncToken last_waited_sync_token_; | 489 gpu::SyncToken last_waited_sync_token_; |
490 int unpack_alignment_; | 490 int unpack_alignment_; |
491 | 491 |
492 unsigned bound_buffer_; | 492 unsigned bound_buffer_; |
493 TextureTargets texture_targets_; | 493 TextureTargets texture_targets_; |
494 | 494 |
495 scoped_refptr<Namespace> namespace_; | 495 scoped_refptr<Namespace> namespace_; |
496 static Namespace* shared_namespace_; | 496 static Namespace* shared_namespace_; |
497 | 497 |
498 base::WeakPtrFactory<TestWebGraphicsContext3D> weak_ptr_factory_; | 498 base::WeakPtrFactory<TestWebGraphicsContext3D> weak_ptr_factory_; |
499 }; | 499 }; |
500 | 500 |
501 } // namespace cc | 501 } // namespace cc |
502 | 502 |
503 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ | 503 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ |
OLD | NEW |