Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2604)

Unified Diff: cc/test/test_web_graphics_context_3d.h

Issue 18796008: Implement shareResources==true in TestWebGraphicsContext3D (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix destruction race Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/test/fake_output_surface.h ('k') | cc/test/test_web_graphics_context_3d.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c9448bed1e7f2045ab55d2269eff76f647535d4f 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,17 +206,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_;
@@ -230,35 +269,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_;
};
« no previous file with comments | « cc/test/fake_output_surface.h ('k') | cc/test/test_web_graphics_context_3d.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698