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..fd5ed70efc54499188862bc9b818c572a66925d3 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" |
@@ -29,6 +31,11 @@ class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
const WebKit::WebGraphicsContext3D::Attributes& attributes) { |
return make_scoped_ptr(new TestWebGraphicsContext3D(attributes)); |
} |
+ static scoped_ptr<TestWebGraphicsContext3D> CreateShared() { |
+ WebKit::WebGraphicsContext3D::Attributes attrs; |
+ attrs.shareResources = true; |
danakj
2013/07/15 23:15:41
this defaults true, right? so won't Create() also
piman
2013/07/16 00:45:33
Done.
|
+ return Create(attrs); |
+ } |
virtual ~TestWebGraphicsContext3D(); |
virtual bool makeContextCurrent(); |
@@ -168,8 +175,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 +211,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; |
+ 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 +258,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 +273,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_; |
}; |