Chromium Code Reviews| Index: cc/test/test_web_graphics_context_3d.h |
| diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h |
| index 086ab0f9dfdd5d3b920c7b9402c300ba0ed4cf60..ad57220eb6205ddb7d763ead7119ae9076548baf 100644 |
| --- a/cc/test/test_web_graphics_context_3d.h |
| +++ b/cc/test/test_web_graphics_context_3d.h |
| @@ -9,9 +9,11 @@ |
| #include "base/compiler_specific.h" |
| #include "base/containers/hash_tables.h" |
| +#include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/weak_ptr.h" |
| #include "base/stl_util.h" |
| +#include "base/synchronization/lock.h" |
| #include "cc/base/scoped_ptr_hash_map.h" |
| #include "cc/debug/fake_web_graphics_context_3d.h" |
| #include "third_party/khronos/GLES2/gl2.h" |
| @@ -168,8 +170,8 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
| times_map_buffer_chromium_succeeds_ = times; |
| } |
| - size_t NumTextures() const { return textures_.size(); } |
| - WebKit::WebGLId TextureAt(int i) const { return textures_[i]; } |
| + size_t NumTextures() const; |
| + WebKit::WebGLId TextureAt(int i) const; |
| size_t NumUsedTextures() const { return used_textures_.size(); } |
| bool UsedTexture(int texture) const { |
| @@ -204,6 +206,45 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
| void SetMemoryAllocation(WebKit::WebGraphicsMemoryAllocation allocation); |
| protected: |
| + struct Buffer { |
| + Buffer(); |
| + ~Buffer(); |
| + |
| + WebKit::WGC3Denum target; |
| + scoped_ptr<uint8[]> pixels; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(Buffer); |
| + }; |
| + |
| + struct Image { |
| + Image(); |
| + ~Image(); |
| + |
| + scoped_ptr<uint8[]> pixels; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(Image); |
| + }; |
| + |
| + struct Namespace : public base::RefCountedThreadSafe<Namespace> { |
| + Namespace(); |
| + |
| + // Protects all fields; |
|
danakj
2013/07/16 03:26:11
nit: s/;/./
piman
2013/07/16 04:50:55
Done.
|
| + base::Lock lock; |
| + unsigned next_buffer_id; |
| + unsigned next_image_id; |
| + unsigned next_texture_id; |
| + std::vector<WebKit::WebGLId> textures; |
| + ScopedPtrHashMap<unsigned, Buffer> buffers; |
| + ScopedPtrHashMap<unsigned, Image> images; |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<Namespace>; |
| + ~Namespace(); |
| + DISALLOW_COPY_AND_ASSIGN(Namespace); |
| + }; |
| + |
| TestWebGraphicsContext3D(); |
| TestWebGraphicsContext3D( |
| const WebKit::WebGraphicsContext3D::Attributes& attributes); |
| @@ -212,9 +253,6 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
| void SwapBuffersComplete(); |
| unsigned context_id_; |
| - unsigned next_buffer_id_; |
| - unsigned next_image_id_; |
| - unsigned next_texture_id_; |
| Attributes attributes_; |
| bool support_swapbuffers_complete_callback_; |
| bool have_extension_io_surface_; |
| @@ -230,35 +268,17 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
| WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* |
| memory_allocation_changed_callback_; |
| std::vector<WebGraphicsSyncPointCallback*> sync_point_callbacks_; |
| - std::vector<WebKit::WebGLId> textures_; |
| base::hash_set<WebKit::WebGLId> used_textures_; |
| std::vector<WebKit::WebGraphicsContext3D*> shared_contexts_; |
| int max_texture_size_; |
| int width_; |
| int height_; |
| - struct Buffer { |
| - Buffer(); |
| - ~Buffer(); |
| - |
| - WebKit::WGC3Denum target; |
| - scoped_ptr<uint8[]> pixels; |
| - |
| - private: |
| - DISALLOW_COPY_AND_ASSIGN(Buffer); |
| - }; |
| - ScopedPtrHashMap<unsigned, Buffer> buffers_; |
| unsigned bound_buffer_; |
| - struct Image { |
| - Image(); |
| - ~Image(); |
| - scoped_ptr<uint8[]> pixels; |
| + scoped_refptr<Namespace> namespace_; |
| + static Namespace* shared_namespace_; |
| - private: |
| - DISALLOW_COPY_AND_ASSIGN(Image); |
| - }; |
| - ScopedPtrHashMap<unsigned, Image> images_; |
| base::WeakPtrFactory<TestWebGraphicsContext3D> weak_ptr_factory_; |
| }; |