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