| OLD | NEW |
| 1 // Copyright 2011 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_FAKE_WEB_GRAPHICS_CONTEXT_3D_H_ | 5 #ifndef CC_FAKE_WEB_GRAPHICS_CONTEXT_3D_H_ |
| 6 #define CC_TEST_FAKE_WEB_GRAPHICS_CONTEXT_3D_H_ | 6 #define CC_FAKE_WEB_GRAPHICS_CONTEXT_3D_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include "base/compiler_specific.h" |
| 9 | 9 #include "cc/cc_export.h" |
| 10 #include "base/hash_tables.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/stl_util.h" | |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
| 14 #include "third_party/khronos/GLES2/gl2.h" | |
| 15 | 11 |
| 16 namespace cc { | 12 namespace cc { |
| 17 | 13 |
| 18 // WebGraphicsContext3D base class for use in WebKit unit tests. | 14 // WebGraphicsContext3D base class for use in unit tests. |
| 19 // All operations are no-ops (returning 0 if necessary). | 15 // All operations are no-ops (returning 0 if necessary). |
| 20 class FakeWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { | 16 class CC_EXPORT FakeWebGraphicsContext3D : |
| 17 public NON_EXPORTED_BASE(WebKit::WebGraphicsContext3D) { |
| 21 public: | 18 public: |
| 22 static scoped_ptr<FakeWebGraphicsContext3D> Create() { | 19 FakeWebGraphicsContext3D(); |
| 23 return make_scoped_ptr(new FakeWebGraphicsContext3D()); | |
| 24 } | |
| 25 static scoped_ptr<FakeWebGraphicsContext3D> Create( | |
| 26 const WebKit::WebGraphicsContext3D::Attributes& attributes) { | |
| 27 return make_scoped_ptr(new FakeWebGraphicsContext3D(attributes)); | |
| 28 } | |
| 29 virtual ~FakeWebGraphicsContext3D(); | 20 virtual ~FakeWebGraphicsContext3D(); |
| 30 | 21 |
| 31 virtual bool makeContextCurrent(); | 22 virtual bool makeContextCurrent(); |
| 32 | 23 |
| 33 virtual int width(); | 24 virtual int width(); |
| 34 virtual int height(); | 25 virtual int height(); |
| 35 | 26 |
| 36 virtual void reshape(int width, int height); | 27 virtual void reshape(int width, int height); |
| 37 | 28 |
| 38 virtual bool isGLES2Compliant(); | 29 virtual bool isGLES2Compliant(); |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 virtual void getQueryObjectuivEXT( | 575 virtual void getQueryObjectuivEXT( |
| 585 WebKit::WebGLId query, | 576 WebKit::WebGLId query, |
| 586 WebKit::WGC3Denum pname, | 577 WebKit::WGC3Denum pname, |
| 587 WebKit::WGC3Duint* params); | 578 WebKit::WGC3Duint* params); |
| 588 | 579 |
| 589 virtual void setContextLostCallback( | 580 virtual void setContextLostCallback( |
| 590 WebGraphicsContextLostCallback* callback); | 581 WebGraphicsContextLostCallback* callback); |
| 591 | 582 |
| 592 virtual void loseContextCHROMIUM(WebKit::WGC3Denum current, | 583 virtual void loseContextCHROMIUM(WebKit::WGC3Denum current, |
| 593 WebKit::WGC3Denum other); | 584 WebKit::WGC3Denum other); |
| 594 | |
| 595 // When set, MakeCurrent() will fail after this many times. | |
| 596 void set_times_make_current_succeeds(int times) { | |
| 597 times_make_current_succeeds_ = times; | |
| 598 } | |
| 599 void set_times_bind_texture_succeeds(int times) { | |
| 600 times_bind_texture_succeeds_ = times; | |
| 601 } | |
| 602 void set_times_end_query_succeeds(int times) { | |
| 603 times_end_query_succeeds_ = times; | |
| 604 } | |
| 605 | |
| 606 size_t NumTextures() const { return textures_.size(); } | |
| 607 WebKit::WebGLId TextureAt(int i) const { return textures_[i]; } | |
| 608 | |
| 609 size_t NumUsedTextures() const { return used_textures_.size(); } | |
| 610 bool UsedTexture(int texture) const { | |
| 611 return ContainsKey(used_textures_, texture); | |
| 612 } | |
| 613 void ResetUsedTextures() { used_textures_.clear(); } | |
| 614 | |
| 615 void set_have_extension_io_surface(bool have) { | |
| 616 have_extension_io_surface_ = have; | |
| 617 } | |
| 618 void set_have_extension_egl_image(bool have) { | |
| 619 have_extension_egl_image_ = have; | |
| 620 } | |
| 621 | |
| 622 static const WebKit::WebGLId kExternalTextureId; | |
| 623 virtual WebKit::WebGLId NextTextureId(); | |
| 624 | |
| 625 protected: | |
| 626 FakeWebGraphicsContext3D(); | |
| 627 FakeWebGraphicsContext3D( | |
| 628 const WebKit::WebGraphicsContext3D::Attributes& attributes); | |
| 629 | |
| 630 unsigned context_id_; | |
| 631 unsigned next_texture_id_; | |
| 632 Attributes attributes_; | |
| 633 bool have_extension_io_surface_; | |
| 634 bool have_extension_egl_image_; | |
| 635 int times_make_current_succeeds_; | |
| 636 int times_bind_texture_succeeds_; | |
| 637 int times_end_query_succeeds_; | |
| 638 bool context_lost_; | |
| 639 WebGraphicsContextLostCallback* context_lost_callback_; | |
| 640 std::vector<WebKit::WebGLId> textures_; | |
| 641 base::hash_set<WebKit::WebGLId> used_textures_; | |
| 642 int width_; | |
| 643 int height_; | |
| 644 }; | 585 }; |
| 645 | 586 |
| 646 } // namespace cc | 587 } // namespace cc |
| 647 | 588 |
| 648 #endif // CC_TEST_FAKE_WEB_GRAPHICS_CONTEXT_3D_H_ | 589 #endif // CC_FAKE_WEB_GRAPHICS_CONTEXT_3D_H_ |
| OLD | NEW |