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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 virtual GLuint64 insertFenceSync(); | 278 virtual GLuint64 insertFenceSync(); |
279 virtual void genSyncToken(GLuint64 fence_sync, GLbyte* sync_token); | 279 virtual void genSyncToken(GLuint64 fence_sync, GLbyte* sync_token); |
280 virtual void waitSyncToken(const GLbyte* sync_token); | 280 virtual void waitSyncToken(const GLbyte* sync_token); |
281 virtual void verifySyncTokens(GLbyte** sync_tokens, GLsizei count); | 281 virtual void verifySyncTokens(GLbyte** sync_tokens, GLsizei count); |
282 | 282 |
283 const gpu::SyncToken& last_waited_sync_token() const { | 283 const gpu::SyncToken& last_waited_sync_token() const { |
284 return last_waited_sync_token_; | 284 return last_waited_sync_token_; |
285 } | 285 } |
286 | 286 |
287 const ContextProvider::Capabilities& test_capabilities() const { | 287 const gpu::Capabilities& test_capabilities() const { |
288 return test_capabilities_; | 288 return test_capabilities_; |
289 } | 289 } |
290 | 290 |
291 void set_context_lost(bool context_lost) { context_lost_ = context_lost; } | 291 void set_context_lost(bool context_lost) { context_lost_ = context_lost; } |
292 void set_times_bind_texture_succeeds(int times) { | 292 void set_times_bind_texture_succeeds(int times) { |
293 times_bind_texture_succeeds_ = times; | 293 times_bind_texture_succeeds_ = times; |
294 } | 294 } |
295 void set_times_end_query_succeeds(int times) { | 295 void set_times_end_query_succeeds(int times) { |
296 times_end_query_succeeds_ = times; | 296 times_end_query_succeeds_ = times; |
297 } | 297 } |
298 | 298 |
299 // When set, mapBufferCHROMIUM will return NULL after this many times. | 299 // When set, mapBufferCHROMIUM will return NULL after this many times. |
300 void set_times_map_buffer_chromium_succeeds(int times) { | 300 void set_times_map_buffer_chromium_succeeds(int times) { |
301 times_map_buffer_chromium_succeeds_ = times; | 301 times_map_buffer_chromium_succeeds_ = times; |
302 } | 302 } |
303 | 303 |
304 size_t NumTextures() const; | 304 size_t NumTextures() const; |
305 GLuint TextureAt(int i) const; | 305 GLuint TextureAt(int i) const; |
306 | 306 |
307 size_t NumUsedTextures() const { return used_textures_.size(); } | 307 size_t NumUsedTextures() const { return used_textures_.size(); } |
308 bool UsedTexture(int texture) const { | 308 bool UsedTexture(int texture) const { |
309 return ContainsKey(used_textures_, texture); | 309 return ContainsKey(used_textures_, texture); |
310 } | 310 } |
311 void ResetUsedTextures() { used_textures_.clear(); } | 311 void ResetUsedTextures() { used_textures_.clear(); } |
312 | 312 |
313 void set_have_extension_io_surface(bool have) { | 313 void set_have_extension_io_surface(bool have) { |
314 test_capabilities_.gpu.iosurface = have; | 314 test_capabilities_.iosurface = have; |
315 test_capabilities_.gpu.texture_rectangle = have; | 315 test_capabilities_.texture_rectangle = have; |
316 } | 316 } |
317 void set_have_extension_egl_image(bool have) { | 317 void set_have_extension_egl_image(bool have) { |
318 test_capabilities_.gpu.egl_image_external = have; | 318 test_capabilities_.egl_image_external = have; |
319 } | 319 } |
320 void set_have_post_sub_buffer(bool have) { | 320 void set_have_post_sub_buffer(bool have) { |
321 test_capabilities_.gpu.post_sub_buffer = have; | 321 test_capabilities_.post_sub_buffer = have; |
322 } | 322 } |
323 void set_have_commit_overlay_planes(bool have) { | 323 void set_have_commit_overlay_planes(bool have) { |
324 test_capabilities_.gpu.commit_overlay_planes = have; | 324 test_capabilities_.commit_overlay_planes = have; |
325 } | 325 } |
326 void set_have_discard_framebuffer(bool have) { | 326 void set_have_discard_framebuffer(bool have) { |
327 test_capabilities_.gpu.discard_framebuffer = have; | 327 test_capabilities_.discard_framebuffer = have; |
328 } | 328 } |
329 void set_support_compressed_texture_etc1(bool support) { | 329 void set_support_compressed_texture_etc1(bool support) { |
330 test_capabilities_.gpu.texture_format_etc1 = support; | 330 test_capabilities_.texture_format_etc1 = support; |
331 } | 331 } |
332 void set_support_texture_format_bgra8888(bool support) { | 332 void set_support_texture_format_bgra8888(bool support) { |
333 test_capabilities_.gpu.texture_format_bgra8888 = support; | 333 test_capabilities_.texture_format_bgra8888 = support; |
334 } | 334 } |
335 void set_support_texture_storage(bool support) { | 335 void set_support_texture_storage(bool support) { |
336 test_capabilities_.gpu.texture_storage = support; | 336 test_capabilities_.texture_storage = support; |
337 } | 337 } |
338 void set_support_texture_usage(bool support) { | 338 void set_support_texture_usage(bool support) { |
339 test_capabilities_.gpu.texture_usage = support; | 339 test_capabilities_.texture_usage = support; |
340 } | 340 } |
341 void set_support_sync_query(bool support) { | 341 void set_support_sync_query(bool support) { |
342 test_capabilities_.gpu.sync_query = support; | 342 test_capabilities_.sync_query = support; |
343 } | 343 } |
344 void set_support_image(bool support) { | 344 void set_support_image(bool support) { test_capabilities_.image = support; } |
345 test_capabilities_.gpu.image = support; | |
346 } | |
347 void set_support_texture_rectangle(bool support) { | 345 void set_support_texture_rectangle(bool support) { |
348 test_capabilities_.gpu.texture_rectangle = support; | 346 test_capabilities_.texture_rectangle = support; |
349 } | 347 } |
350 void set_support_texture_half_float_linear(bool support) { | 348 void set_support_texture_half_float_linear(bool support) { |
351 test_capabilities_.gpu.texture_half_float_linear = support; | 349 test_capabilities_.texture_half_float_linear = support; |
352 } | 350 } |
353 void set_msaa_is_slow(bool msaa_is_slow) { | 351 void set_msaa_is_slow(bool msaa_is_slow) { |
354 test_capabilities_.gpu.msaa_is_slow = msaa_is_slow; | 352 test_capabilities_.msaa_is_slow = msaa_is_slow; |
355 } | 353 } |
356 | 354 |
357 // When this context is lost, all contexts in its share group are also lost. | 355 // When this context is lost, all contexts in its share group are also lost. |
358 void add_share_group_context(TestWebGraphicsContext3D* context3d) { | 356 void add_share_group_context(TestWebGraphicsContext3D* context3d) { |
359 shared_contexts_.push_back(context3d); | 357 shared_contexts_.push_back(context3d); |
360 } | 358 } |
361 | 359 |
362 void set_max_texture_size(int size) { max_texture_size_ = size; } | 360 void set_max_texture_size(int size) { max_texture_size_ = size; } |
363 | 361 |
364 static const GLuint kExternalTextureId; | 362 static const GLuint kExternalTextureId; |
365 virtual GLuint NextTextureId(); | 363 virtual GLuint NextTextureId(); |
366 virtual void RetireTextureId(GLuint id); | 364 virtual void RetireTextureId(GLuint id); |
367 | 365 |
368 virtual GLuint NextBufferId(); | 366 virtual GLuint NextBufferId(); |
369 virtual void RetireBufferId(GLuint id); | 367 virtual void RetireBufferId(GLuint id); |
370 | 368 |
371 virtual GLuint NextImageId(); | 369 virtual GLuint NextImageId(); |
372 virtual void RetireImageId(GLuint id); | 370 virtual void RetireImageId(GLuint id); |
373 | 371 |
374 virtual GLuint NextFramebufferId(); | 372 virtual GLuint NextFramebufferId(); |
375 virtual void RetireFramebufferId(GLuint id); | 373 virtual void RetireFramebufferId(GLuint id); |
376 | 374 |
377 virtual GLuint NextRenderbufferId(); | 375 virtual GLuint NextRenderbufferId(); |
378 virtual void RetireRenderbufferId(GLuint id); | 376 virtual void RetireRenderbufferId(GLuint id); |
379 | 377 |
380 void SetMaxTransferBufferUsageBytes(size_t max_transfer_buffer_usage_bytes); | |
381 size_t max_used_transfer_buffer_usage_bytes() const { | |
382 return max_used_transfer_buffer_usage_bytes_; | |
383 } | |
384 | |
385 void SetMaxSamples(int max_samples); | 378 void SetMaxSamples(int max_samples); |
386 void set_test_support(TestContextSupport* test_support) { | 379 void set_test_support(TestContextSupport* test_support) { |
387 test_support_ = test_support; | 380 test_support_ = test_support; |
388 } | 381 } |
389 | 382 |
390 int width() const { return width_; } | 383 int width() const { return width_; } |
391 int height() const { return height_; } | 384 int height() const { return height_; } |
392 bool reshape_called() const { return reshape_called_; } | 385 bool reshape_called() const { return reshape_called_; } |
393 void clear_reshape_called() { reshape_called_ = false; } | 386 void clear_reshape_called() { reshape_called_ = false; } |
394 float scale_factor() const { return scale_factor_; } | 387 float scale_factor() const { return scale_factor_; } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 451 |
459 TestWebGraphicsContext3D(); | 452 TestWebGraphicsContext3D(); |
460 | 453 |
461 void CreateNamespace(); | 454 void CreateNamespace(); |
462 GLuint BoundTextureId(GLenum target); | 455 GLuint BoundTextureId(GLenum target); |
463 scoped_refptr<TestTexture> BoundTexture(GLenum target); | 456 scoped_refptr<TestTexture> BoundTexture(GLenum target); |
464 scoped_refptr<TestTexture> UnboundTexture(GLuint texture); | 457 scoped_refptr<TestTexture> UnboundTexture(GLuint texture); |
465 void CheckTextureIsBound(GLenum target); | 458 void CheckTextureIsBound(GLenum target); |
466 | 459 |
467 unsigned context_id_; | 460 unsigned context_id_; |
468 ContextProvider::Capabilities test_capabilities_; | 461 gpu::Capabilities test_capabilities_; |
469 int times_bind_texture_succeeds_; | 462 int times_bind_texture_succeeds_; |
470 int times_end_query_succeeds_; | 463 int times_end_query_succeeds_; |
471 bool context_lost_; | 464 bool context_lost_; |
472 int times_map_buffer_chromium_succeeds_; | 465 int times_map_buffer_chromium_succeeds_; |
473 int current_used_transfer_buffer_usage_bytes_; | |
474 int max_used_transfer_buffer_usage_bytes_; | |
475 base::Closure context_lost_callback_; | 466 base::Closure context_lost_callback_; |
476 std::unordered_set<unsigned> used_textures_; | 467 std::unordered_set<unsigned> used_textures_; |
477 unsigned next_program_id_; | 468 unsigned next_program_id_; |
478 std::unordered_set<unsigned> program_set_; | 469 std::unordered_set<unsigned> program_set_; |
479 unsigned next_shader_id_; | 470 unsigned next_shader_id_; |
480 std::unordered_set<unsigned> shader_set_; | 471 std::unordered_set<unsigned> shader_set_; |
481 unsigned next_framebuffer_id_; | 472 unsigned next_framebuffer_id_; |
482 std::unordered_set<unsigned> framebuffer_set_; | 473 std::unordered_set<unsigned> framebuffer_set_; |
483 unsigned current_framebuffer_; | 474 unsigned current_framebuffer_; |
484 std::vector<TestWebGraphicsContext3D*> shared_contexts_; | 475 std::vector<TestWebGraphicsContext3D*> shared_contexts_; |
(...skipping 14 matching lines...) Expand all Loading... |
499 | 490 |
500 scoped_refptr<Namespace> namespace_; | 491 scoped_refptr<Namespace> namespace_; |
501 static Namespace* shared_namespace_; | 492 static Namespace* shared_namespace_; |
502 | 493 |
503 base::WeakPtrFactory<TestWebGraphicsContext3D> weak_ptr_factory_; | 494 base::WeakPtrFactory<TestWebGraphicsContext3D> weak_ptr_factory_; |
504 }; | 495 }; |
505 | 496 |
506 } // namespace cc | 497 } // namespace cc |
507 | 498 |
508 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ | 499 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ |
OLD | NEW |