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