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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
13 #include "base/containers/scoped_ptr_hash_map.h" | 13 #include "base/containers/scoped_ptr_hash_map.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
19 #include "cc/output/context_provider.h" | 19 #include "cc/output/context_provider.h" |
20 #include "cc/test/ordered_texture_map.h" | 20 #include "cc/test/ordered_texture_map.h" |
21 #include "cc/test/test_texture.h" | 21 #include "cc/test/test_texture.h" |
22 #include "third_party/khronos/GLES2/gl2.h" | 22 #include "third_party/khronos/GLES2/gl2.h" |
23 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
24 | 24 |
| 25 #ifdef __cplusplus |
| 26 extern "C" { |
| 27 #endif |
| 28 |
| 29 typedef struct _ClientBuffer* ClientBuffer; |
| 30 |
| 31 #ifdef __cplusplus |
| 32 } |
| 33 #endif |
| 34 |
25 namespace cc { | 35 namespace cc { |
26 class TestContextSupport; | 36 class TestContextSupport; |
27 | 37 |
28 class TestWebGraphicsContext3D { | 38 class TestWebGraphicsContext3D { |
29 public: | 39 public: |
30 static scoped_ptr<TestWebGraphicsContext3D> Create(); | 40 static scoped_ptr<TestWebGraphicsContext3D> Create(); |
31 | 41 |
32 virtual ~TestWebGraphicsContext3D(); | 42 virtual ~TestWebGraphicsContext3D(); |
33 | 43 |
34 void set_context_lost_callback(const base::Closure& callback) { | 44 void set_context_lost_callback(const base::Closure& callback) { |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 253 |
244 virtual void bindBuffer(GLenum target, GLuint buffer); | 254 virtual void bindBuffer(GLenum target, GLuint buffer); |
245 virtual void bufferData(GLenum target, | 255 virtual void bufferData(GLenum target, |
246 GLsizeiptr size, | 256 GLsizeiptr size, |
247 const void* data, | 257 const void* data, |
248 GLenum usage); | 258 GLenum usage); |
249 virtual void* mapBufferCHROMIUM(GLenum target, | 259 virtual void* mapBufferCHROMIUM(GLenum target, |
250 GLenum access); | 260 GLenum access); |
251 virtual GLboolean unmapBufferCHROMIUM(GLenum target); | 261 virtual GLboolean unmapBufferCHROMIUM(GLenum target); |
252 | 262 |
253 virtual GLuint createImageCHROMIUM(GLsizei width, | 263 virtual GLuint createImageCHROMIUM(ClientBuffer buffer, |
| 264 GLsizei width, |
254 GLsizei height, | 265 GLsizei height, |
255 GLenum internalformat, | 266 GLenum internalformat); |
256 GLenum usage); | |
257 virtual void destroyImageCHROMIUM(GLuint image_id); | 267 virtual void destroyImageCHROMIUM(GLuint image_id); |
258 virtual void getImageParameterivCHROMIUM(GLuint image_id, | |
259 GLenum pname, | |
260 GLint* params); | |
261 virtual void* mapImageCHROMIUM(GLuint image_id); | |
262 virtual void unmapImageCHROMIUM(GLuint image_id); | |
263 virtual GLuint createGpuMemoryBufferImageCHROMIUM(GLsizei width, | 268 virtual GLuint createGpuMemoryBufferImageCHROMIUM(GLsizei width, |
264 GLsizei height, | 269 GLsizei height, |
265 GLenum internalformat, | 270 GLenum internalformat, |
266 GLenum usage); | 271 GLenum usage); |
| 272 |
267 virtual void texImageIOSurface2DCHROMIUM(GLenum target, | 273 virtual void texImageIOSurface2DCHROMIUM(GLenum target, |
268 GLsizei width, | 274 GLsizei width, |
269 GLsizei height, | 275 GLsizei height, |
270 GLuint io_surface_id, | 276 GLuint io_surface_id, |
271 GLuint plane) {} | 277 GLuint plane) {} |
272 | 278 |
273 virtual unsigned insertSyncPoint(); | 279 virtual unsigned insertSyncPoint(); |
274 virtual void waitSyncPoint(unsigned sync_point); | 280 virtual void waitSyncPoint(unsigned sync_point); |
275 | 281 |
276 unsigned last_waited_sync_point() const { return last_waited_sync_point_; } | 282 unsigned last_waited_sync_point() const { return last_waited_sync_point_; } |
277 | 283 |
278 const ContextProvider::Capabilities& test_capabilities() const { | 284 const ContextProvider::Capabilities& test_capabilities() const { |
279 return test_capabilities_; | 285 return test_capabilities_; |
280 } | 286 } |
281 | 287 |
282 void set_context_lost(bool context_lost) { context_lost_ = context_lost; } | 288 void set_context_lost(bool context_lost) { context_lost_ = context_lost; } |
283 void set_times_bind_texture_succeeds(int times) { | 289 void set_times_bind_texture_succeeds(int times) { |
284 times_bind_texture_succeeds_ = times; | 290 times_bind_texture_succeeds_ = times; |
285 } | 291 } |
286 void set_times_end_query_succeeds(int times) { | 292 void set_times_end_query_succeeds(int times) { |
287 times_end_query_succeeds_ = times; | 293 times_end_query_succeeds_ = times; |
288 } | 294 } |
289 | 295 |
290 // When set, mapImageCHROMIUM and mapBufferCHROMIUM will return NULL after | 296 // When set, mapBufferCHROMIUM will return NULL after this many times. |
291 // this many times. | |
292 void set_times_map_image_chromium_succeeds(int times) { | |
293 times_map_image_chromium_succeeds_ = times; | |
294 } | |
295 void set_times_map_buffer_chromium_succeeds(int times) { | 297 void set_times_map_buffer_chromium_succeeds(int times) { |
296 times_map_buffer_chromium_succeeds_ = times; | 298 times_map_buffer_chromium_succeeds_ = times; |
297 } | 299 } |
298 | 300 |
299 size_t NumTextures() const; | 301 size_t NumTextures() const; |
300 GLuint TextureAt(int i) const; | 302 GLuint TextureAt(int i) const; |
301 | 303 |
302 size_t NumUsedTextures() const { return used_textures_.size(); } | 304 size_t NumUsedTextures() const { return used_textures_.size(); } |
303 bool UsedTexture(int texture) const { | 305 bool UsedTexture(int texture) const { |
304 return ContainsKey(used_textures_, texture); | 306 return ContainsKey(used_textures_, texture); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 | 417 |
416 struct Namespace : public base::RefCountedThreadSafe<Namespace> { | 418 struct Namespace : public base::RefCountedThreadSafe<Namespace> { |
417 Namespace(); | 419 Namespace(); |
418 | 420 |
419 // Protects all fields. | 421 // Protects all fields. |
420 base::Lock lock; | 422 base::Lock lock; |
421 unsigned next_buffer_id; | 423 unsigned next_buffer_id; |
422 unsigned next_image_id; | 424 unsigned next_image_id; |
423 unsigned next_texture_id; | 425 unsigned next_texture_id; |
424 base::ScopedPtrHashMap<unsigned, Buffer> buffers; | 426 base::ScopedPtrHashMap<unsigned, Buffer> buffers; |
425 base::ScopedPtrHashMap<unsigned, Image> images; | 427 base::hash_set<unsigned> images; |
426 OrderedTextureMap textures; | 428 OrderedTextureMap textures; |
427 | 429 |
428 private: | 430 private: |
429 friend class base::RefCountedThreadSafe<Namespace>; | 431 friend class base::RefCountedThreadSafe<Namespace>; |
430 ~Namespace(); | 432 ~Namespace(); |
431 DISALLOW_COPY_AND_ASSIGN(Namespace); | 433 DISALLOW_COPY_AND_ASSIGN(Namespace); |
432 }; | 434 }; |
433 | 435 |
434 TestWebGraphicsContext3D(); | 436 TestWebGraphicsContext3D(); |
435 | 437 |
436 void CreateNamespace(); | 438 void CreateNamespace(); |
437 GLuint BoundTextureId(GLenum target); | 439 GLuint BoundTextureId(GLenum target); |
438 scoped_refptr<TestTexture> BoundTexture(GLenum target); | 440 scoped_refptr<TestTexture> BoundTexture(GLenum target); |
439 void CheckTextureIsBound(GLenum target); | 441 void CheckTextureIsBound(GLenum target); |
440 | 442 |
441 unsigned context_id_; | 443 unsigned context_id_; |
442 ContextProvider::Capabilities test_capabilities_; | 444 ContextProvider::Capabilities test_capabilities_; |
443 int times_bind_texture_succeeds_; | 445 int times_bind_texture_succeeds_; |
444 int times_end_query_succeeds_; | 446 int times_end_query_succeeds_; |
445 bool context_lost_; | 447 bool context_lost_; |
446 int times_map_image_chromium_succeeds_; | |
447 int times_map_buffer_chromium_succeeds_; | 448 int times_map_buffer_chromium_succeeds_; |
448 int current_used_transfer_buffer_usage_bytes_; | 449 int current_used_transfer_buffer_usage_bytes_; |
449 int max_used_transfer_buffer_usage_bytes_; | 450 int max_used_transfer_buffer_usage_bytes_; |
450 base::Closure context_lost_callback_; | 451 base::Closure context_lost_callback_; |
451 base::hash_set<unsigned> used_textures_; | 452 base::hash_set<unsigned> used_textures_; |
452 unsigned next_program_id_; | 453 unsigned next_program_id_; |
453 base::hash_set<unsigned> program_set_; | 454 base::hash_set<unsigned> program_set_; |
454 unsigned next_shader_id_; | 455 unsigned next_shader_id_; |
455 base::hash_set<unsigned> shader_set_; | 456 base::hash_set<unsigned> shader_set_; |
456 std::vector<TestWebGraphicsContext3D*> shared_contexts_; | 457 std::vector<TestWebGraphicsContext3D*> shared_contexts_; |
(...skipping 13 matching lines...) Expand all Loading... |
470 | 471 |
471 scoped_refptr<Namespace> namespace_; | 472 scoped_refptr<Namespace> namespace_; |
472 static Namespace* shared_namespace_; | 473 static Namespace* shared_namespace_; |
473 | 474 |
474 base::WeakPtrFactory<TestWebGraphicsContext3D> weak_ptr_factory_; | 475 base::WeakPtrFactory<TestWebGraphicsContext3D> weak_ptr_factory_; |
475 }; | 476 }; |
476 | 477 |
477 } // namespace cc | 478 } // namespace cc |
478 | 479 |
479 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ | 480 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ |
OLD | NEW |