summaryrefslogtreecommitdiffstats
path: root/cc/test/test_web_graphics_context_3d.h
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-17 01:03:26 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-17 01:03:26 +0000
commit3f6a906ce6b12e47c25420d4c72b86b86c16cab4 (patch)
treebe7256a7863c7f90df14cf3446167dc64bdb6304 /cc/test/test_web_graphics_context_3d.h
parentf94ad96ecf65eb040a6adbcb9237d0e6ed3210d1 (diff)
downloadchromium_src-3f6a906ce6b12e47c25420d4c72b86b86c16cab4.zip
chromium_src-3f6a906ce6b12e47c25420d4c72b86b86c16cab4.tar.gz
chromium_src-3f6a906ce6b12e47c25420d4c72b86b86c16cab4.tar.bz2
Implement shareResources==true in TestWebGraphicsContext3D
This moves the id namespace (for textures/buffers/images) in a separate struct, that can be shared across instance. Similarly to the other WGC3D implementations, there is only one global share group, that instances can opt into or be completely segregated (based on whether shareResources==true or not) BUG=None R=danakj@chromium.org Review URL: https://codereview.chromium.org/18796008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test/test_web_graphics_context_3d.h')
-rw-r--r--cc/test/test_web_graphics_context_3d.h71
1 files changed, 46 insertions, 25 deletions
diff --git a/cc/test/test_web_graphics_context_3d.h b/cc/test/test_web_graphics_context_3d.h
index 5952e36..41296b2 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"
@@ -171,8 +173,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 {
@@ -207,17 +209,54 @@ 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);
void CallAllSyncPointCallbacks();
void SwapBuffersComplete();
+ void CreateNamespace();
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_;
@@ -234,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_;
};