OLD | NEW |
(Empty) | |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ |
| 6 #define CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/compiler_specific.h" |
| 11 #include "base/hash_tables.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/stl_util.h" |
| 14 #include "cc/fake_web_graphics_context_3d.h" |
| 15 #include "third_party/khronos/GLES2/gl2.h" |
| 16 |
| 17 namespace cc { |
| 18 |
| 19 class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
| 20 public: |
| 21 static scoped_ptr<TestWebGraphicsContext3D> Create() { |
| 22 return make_scoped_ptr(new TestWebGraphicsContext3D()); |
| 23 } |
| 24 static scoped_ptr<TestWebGraphicsContext3D> Create( |
| 25 const WebKit::WebGraphicsContext3D::Attributes& attributes) { |
| 26 return make_scoped_ptr(new TestWebGraphicsContext3D(attributes)); |
| 27 } |
| 28 virtual ~TestWebGraphicsContext3D(); |
| 29 |
| 30 virtual bool makeContextCurrent(); |
| 31 |
| 32 virtual int width(); |
| 33 virtual int height(); |
| 34 |
| 35 virtual void reshape(int width, int height); |
| 36 |
| 37 virtual bool isContextLost(); |
| 38 virtual WebKit::WGC3Denum getGraphicsResetStatusARB(); |
| 39 |
| 40 virtual void attachShader(WebKit::WebGLId program, WebKit::WebGLId shader); |
| 41 virtual void bindBuffer(WebKit::WGC3Denum target, WebKit::WebGLId buffer); |
| 42 virtual void bindFramebuffer( |
| 43 WebKit::WGC3Denum target, WebKit::WebGLId framebuffer); |
| 44 virtual void bindRenderbuffer( |
| 45 WebKit::WGC3Denum target, WebKit::WebGLId renderbuffer); |
| 46 virtual void bindTexture( |
| 47 WebKit::WGC3Denum target, |
| 48 WebKit::WebGLId texture_id); |
| 49 |
| 50 virtual WebKit::WGC3Denum checkFramebufferStatus(WebKit::WGC3Denum target); |
| 51 |
| 52 virtual Attributes getContextAttributes(); |
| 53 |
| 54 virtual WebKit::WebString getString(WebKit::WGC3Denum name); |
| 55 virtual WebKit::WGC3Dint getUniformLocation( |
| 56 WebKit::WebGLId program, |
| 57 const WebKit::WGC3Dchar* name); |
| 58 virtual WebKit::WGC3Dsizeiptr getVertexAttribOffset( |
| 59 WebKit::WGC3Duint index, |
| 60 WebKit::WGC3Denum pname); |
| 61 |
| 62 virtual WebKit::WGC3Dboolean isBuffer(WebKit::WebGLId buffer); |
| 63 virtual WebKit::WGC3Dboolean isEnabled(WebKit::WGC3Denum cap); |
| 64 virtual WebKit::WGC3Dboolean isFramebuffer(WebKit::WebGLId framebuffer); |
| 65 virtual WebKit::WGC3Dboolean isProgram(WebKit::WebGLId program); |
| 66 virtual WebKit::WGC3Dboolean isRenderbuffer(WebKit::WebGLId renderbuffer); |
| 67 virtual WebKit::WGC3Dboolean isShader(WebKit::WebGLId shader); |
| 68 virtual WebKit::WGC3Dboolean isTexture(WebKit::WebGLId texture); |
| 69 |
| 70 virtual void useProgram(WebKit::WebGLId program); |
| 71 |
| 72 virtual WebKit::WebGLId createBuffer(); |
| 73 virtual WebKit::WebGLId createFramebuffer(); |
| 74 virtual WebKit::WebGLId createProgram(); |
| 75 virtual WebKit::WebGLId createRenderbuffer(); |
| 76 virtual WebKit::WebGLId createShader(WebKit::WGC3Denum); |
| 77 virtual WebKit::WebGLId createTexture(); |
| 78 |
| 79 virtual void deleteBuffer(WebKit::WebGLId id); |
| 80 virtual void deleteFramebuffer(WebKit::WebGLId id); |
| 81 virtual void deleteProgram(WebKit::WebGLId id); |
| 82 virtual void deleteRenderbuffer(WebKit::WebGLId id); |
| 83 virtual void deleteShader(WebKit::WebGLId id); |
| 84 virtual void deleteTexture(WebKit::WebGLId texture_id); |
| 85 |
| 86 virtual void endQueryEXT(WebKit::WGC3Denum target); |
| 87 virtual void getQueryObjectuivEXT( |
| 88 WebKit::WebGLId query, |
| 89 WebKit::WGC3Denum pname, |
| 90 WebKit::WGC3Duint* params); |
| 91 |
| 92 virtual void setContextLostCallback( |
| 93 WebGraphicsContextLostCallback* callback); |
| 94 |
| 95 virtual void loseContextCHROMIUM(WebKit::WGC3Denum current, |
| 96 WebKit::WGC3Denum other); |
| 97 |
| 98 // When set, MakeCurrent() will fail after this many times. |
| 99 void set_times_make_current_succeeds(int times) { |
| 100 times_make_current_succeeds_ = times; |
| 101 } |
| 102 void set_times_bind_texture_succeeds(int times) { |
| 103 times_bind_texture_succeeds_ = times; |
| 104 } |
| 105 void set_times_end_query_succeeds(int times) { |
| 106 times_end_query_succeeds_ = times; |
| 107 } |
| 108 |
| 109 size_t NumTextures() const { return textures_.size(); } |
| 110 WebKit::WebGLId TextureAt(int i) const { return textures_[i]; } |
| 111 |
| 112 size_t NumUsedTextures() const { return used_textures_.size(); } |
| 113 bool UsedTexture(int texture) const { |
| 114 return ContainsKey(used_textures_, texture); |
| 115 } |
| 116 void ResetUsedTextures() { used_textures_.clear(); } |
| 117 |
| 118 void set_have_extension_io_surface(bool have) { |
| 119 have_extension_io_surface_ = have; |
| 120 } |
| 121 void set_have_extension_egl_image(bool have) { |
| 122 have_extension_egl_image_ = have; |
| 123 } |
| 124 |
| 125 static const WebKit::WebGLId kExternalTextureId; |
| 126 virtual WebKit::WebGLId NextTextureId(); |
| 127 |
| 128 protected: |
| 129 TestWebGraphicsContext3D(); |
| 130 TestWebGraphicsContext3D( |
| 131 const WebKit::WebGraphicsContext3D::Attributes& attributes); |
| 132 |
| 133 unsigned context_id_; |
| 134 unsigned next_texture_id_; |
| 135 Attributes attributes_; |
| 136 bool have_extension_io_surface_; |
| 137 bool have_extension_egl_image_; |
| 138 int times_make_current_succeeds_; |
| 139 int times_bind_texture_succeeds_; |
| 140 int times_end_query_succeeds_; |
| 141 bool context_lost_; |
| 142 WebGraphicsContextLostCallback* context_lost_callback_; |
| 143 std::vector<WebKit::WebGLId> textures_; |
| 144 base::hash_set<WebKit::WebGLId> used_textures_; |
| 145 int width_; |
| 146 int height_; |
| 147 }; |
| 148 |
| 149 } // namespace cc |
| 150 |
| 151 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ |
OLD | NEW |