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 <memory> |
11 #include <unordered_map> | 12 #include <unordered_map> |
12 #include <unordered_set> | 13 #include <unordered_set> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "base/callback.h" | 16 #include "base/callback.h" |
16 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.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" |
27 #include "third_party/khronos/GLES2/gl2.h" | 27 #include "third_party/khronos/GLES2/gl2.h" |
28 #include "ui/gfx/geometry/rect.h" | 28 #include "ui/gfx/geometry/rect.h" |
29 | 29 |
30 extern "C" typedef struct _ClientBuffer* ClientBuffer; | 30 extern "C" typedef struct _ClientBuffer* ClientBuffer; |
31 | 31 |
32 namespace cc { | 32 namespace cc { |
33 class TestContextSupport; | 33 class TestContextSupport; |
34 | 34 |
35 class TestWebGraphicsContext3D { | 35 class TestWebGraphicsContext3D { |
36 public: | 36 public: |
37 static scoped_ptr<TestWebGraphicsContext3D> Create(); | 37 static std::unique_ptr<TestWebGraphicsContext3D> Create(); |
38 | 38 |
39 virtual ~TestWebGraphicsContext3D(); | 39 virtual ~TestWebGraphicsContext3D(); |
40 | 40 |
41 void set_context_lost_callback(const base::Closure& callback) { | 41 void set_context_lost_callback(const base::Closure& callback) { |
42 context_lost_callback_ = callback; | 42 context_lost_callback_ = callback; |
43 } | 43 } |
44 | 44 |
45 virtual void reshapeWithScaleFactor(int width, | 45 virtual void reshapeWithScaleFactor(int width, |
46 int height, | 46 int height, |
47 float scale_factor); | 47 float scale_factor); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 private: | 412 private: |
413 using TargetTextureMap = std::unordered_map<GLenum, GLuint>; | 413 using TargetTextureMap = std::unordered_map<GLenum, GLuint>; |
414 TargetTextureMap bound_textures_; | 414 TargetTextureMap bound_textures_; |
415 }; | 415 }; |
416 | 416 |
417 struct Buffer { | 417 struct Buffer { |
418 Buffer(); | 418 Buffer(); |
419 ~Buffer(); | 419 ~Buffer(); |
420 | 420 |
421 GLenum target; | 421 GLenum target; |
422 scoped_ptr<uint8_t[]> pixels; | 422 std::unique_ptr<uint8_t[]> pixels; |
423 size_t size; | 423 size_t size; |
424 | 424 |
425 private: | 425 private: |
426 DISALLOW_COPY_AND_ASSIGN(Buffer); | 426 DISALLOW_COPY_AND_ASSIGN(Buffer); |
427 }; | 427 }; |
428 | 428 |
429 struct Image { | 429 struct Image { |
430 Image(); | 430 Image(); |
431 ~Image(); | 431 ~Image(); |
432 | 432 |
433 scoped_ptr<uint8_t[]> pixels; | 433 std::unique_ptr<uint8_t[]> pixels; |
434 | 434 |
435 private: | 435 private: |
436 DISALLOW_COPY_AND_ASSIGN(Image); | 436 DISALLOW_COPY_AND_ASSIGN(Image); |
437 }; | 437 }; |
438 | 438 |
439 struct Namespace : public base::RefCountedThreadSafe<Namespace> { | 439 struct Namespace : public base::RefCountedThreadSafe<Namespace> { |
440 Namespace(); | 440 Namespace(); |
441 | 441 |
442 // Protects all fields. | 442 // Protects all fields. |
443 base::Lock lock; | 443 base::Lock lock; |
444 unsigned next_buffer_id; | 444 unsigned next_buffer_id; |
445 unsigned next_image_id; | 445 unsigned next_image_id; |
446 unsigned next_texture_id; | 446 unsigned next_texture_id; |
447 unsigned next_renderbuffer_id; | 447 unsigned next_renderbuffer_id; |
448 std::unordered_map<unsigned, scoped_ptr<Buffer>> buffers; | 448 std::unordered_map<unsigned, std::unique_ptr<Buffer>> buffers; |
449 std::unordered_set<unsigned> images; | 449 std::unordered_set<unsigned> images; |
450 OrderedTextureMap textures; | 450 OrderedTextureMap textures; |
451 std::unordered_set<unsigned> renderbuffer_set; | 451 std::unordered_set<unsigned> renderbuffer_set; |
452 | 452 |
453 private: | 453 private: |
454 friend class base::RefCountedThreadSafe<Namespace>; | 454 friend class base::RefCountedThreadSafe<Namespace>; |
455 ~Namespace(); | 455 ~Namespace(); |
456 DISALLOW_COPY_AND_ASSIGN(Namespace); | 456 DISALLOW_COPY_AND_ASSIGN(Namespace); |
457 }; | 457 }; |
458 | 458 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 499 |
500 scoped_refptr<Namespace> namespace_; | 500 scoped_refptr<Namespace> namespace_; |
501 static Namespace* shared_namespace_; | 501 static Namespace* shared_namespace_; |
502 | 502 |
503 base::WeakPtrFactory<TestWebGraphicsContext3D> weak_ptr_factory_; | 503 base::WeakPtrFactory<TestWebGraphicsContext3D> weak_ptr_factory_; |
504 }; | 504 }; |
505 | 505 |
506 } // namespace cc | 506 } // namespace cc |
507 | 507 |
508 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ | 508 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ |
OLD | NEW |