Chromium Code Reviews| 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 : | |
| 20 public NON_EXPORTED_BASE(FakeWebGraphicsContext3D) { | |
|
piman
2013/02/11 19:53:00
nit: don't think NON_EXPORTED_BASE is useful since
| |
| 21 public: | |
| 22 static scoped_ptr<TestWebGraphicsContext3D> Create() { | |
| 23 return make_scoped_ptr(new TestWebGraphicsContext3D()); | |
| 24 } | |
| 25 static scoped_ptr<TestWebGraphicsContext3D> Create( | |
| 26 const WebKit::WebGraphicsContext3D::Attributes& attributes) { | |
| 27 return make_scoped_ptr(new TestWebGraphicsContext3D(attributes)); | |
| 28 } | |
| 29 virtual ~TestWebGraphicsContext3D(); | |
| 30 | |
| 31 virtual bool makeContextCurrent(); | |
| 32 | |
| 33 virtual int width(); | |
| 34 virtual int height(); | |
| 35 | |
| 36 virtual void reshape(int width, int height); | |
| 37 | |
| 38 virtual bool isContextLost(); | |
| 39 virtual WebKit::WGC3Denum getGraphicsResetStatusARB(); | |
| 40 | |
| 41 virtual void attachShader(WebKit::WebGLId program, WebKit::WebGLId shader); | |
| 42 virtual void bindBuffer(WebKit::WGC3Denum target, WebKit::WebGLId buffer); | |
| 43 virtual void bindFramebuffer( | |
| 44 WebKit::WGC3Denum target, WebKit::WebGLId framebuffer); | |
| 45 virtual void bindRenderbuffer( | |
| 46 WebKit::WGC3Denum target, WebKit::WebGLId renderbuffer); | |
| 47 virtual void bindTexture( | |
| 48 WebKit::WGC3Denum target, | |
| 49 WebKit::WebGLId texture_id); | |
| 50 | |
| 51 virtual WebKit::WGC3Denum checkFramebufferStatus(WebKit::WGC3Denum target); | |
| 52 | |
| 53 virtual Attributes getContextAttributes(); | |
| 54 | |
| 55 virtual WebKit::WebString getString(WebKit::WGC3Denum name); | |
| 56 virtual WebKit::WGC3Dint getUniformLocation( | |
| 57 WebKit::WebGLId program, | |
| 58 const WebKit::WGC3Dchar* name); | |
| 59 virtual WebKit::WGC3Dsizeiptr getVertexAttribOffset( | |
| 60 WebKit::WGC3Duint index, | |
| 61 WebKit::WGC3Denum pname); | |
| 62 | |
| 63 virtual WebKit::WGC3Dboolean isBuffer(WebKit::WebGLId buffer); | |
| 64 virtual WebKit::WGC3Dboolean isEnabled(WebKit::WGC3Denum cap); | |
| 65 virtual WebKit::WGC3Dboolean isFramebuffer(WebKit::WebGLId framebuffer); | |
| 66 virtual WebKit::WGC3Dboolean isProgram(WebKit::WebGLId program); | |
| 67 virtual WebKit::WGC3Dboolean isRenderbuffer(WebKit::WebGLId renderbuffer); | |
| 68 virtual WebKit::WGC3Dboolean isShader(WebKit::WebGLId shader); | |
| 69 virtual WebKit::WGC3Dboolean isTexture(WebKit::WebGLId texture); | |
| 70 | |
| 71 virtual void useProgram(WebKit::WebGLId program); | |
| 72 | |
| 73 virtual WebKit::WebGLId createBuffer(); | |
| 74 virtual WebKit::WebGLId createFramebuffer(); | |
| 75 virtual WebKit::WebGLId createProgram(); | |
| 76 virtual WebKit::WebGLId createRenderbuffer(); | |
| 77 virtual WebKit::WebGLId createShader(WebKit::WGC3Denum); | |
| 78 virtual WebKit::WebGLId createTexture(); | |
| 79 | |
| 80 virtual void deleteBuffer(WebKit::WebGLId id); | |
| 81 virtual void deleteFramebuffer(WebKit::WebGLId id); | |
| 82 virtual void deleteProgram(WebKit::WebGLId id); | |
| 83 virtual void deleteRenderbuffer(WebKit::WebGLId id); | |
| 84 virtual void deleteShader(WebKit::WebGLId id); | |
| 85 virtual void deleteTexture(WebKit::WebGLId texture_id); | |
| 86 | |
| 87 virtual void endQueryEXT(WebKit::WGC3Denum target); | |
| 88 virtual void getQueryObjectuivEXT( | |
| 89 WebKit::WebGLId query, | |
| 90 WebKit::WGC3Denum pname, | |
| 91 WebKit::WGC3Duint* params); | |
| 92 | |
| 93 virtual void setContextLostCallback( | |
| 94 WebGraphicsContextLostCallback* callback); | |
| 95 | |
| 96 virtual void loseContextCHROMIUM(WebKit::WGC3Denum current, | |
| 97 WebKit::WGC3Denum other); | |
| 98 | |
| 99 // When set, MakeCurrent() will fail after this many times. | |
| 100 void set_times_make_current_succeeds(int times) { | |
| 101 times_make_current_succeeds_ = times; | |
| 102 } | |
| 103 void set_times_bind_texture_succeeds(int times) { | |
| 104 times_bind_texture_succeeds_ = times; | |
| 105 } | |
| 106 void set_times_end_query_succeeds(int times) { | |
| 107 times_end_query_succeeds_ = times; | |
| 108 } | |
| 109 | |
| 110 size_t NumTextures() const { return textures_.size(); } | |
| 111 WebKit::WebGLId TextureAt(int i) const { return textures_[i]; } | |
| 112 | |
| 113 size_t NumUsedTextures() const { return used_textures_.size(); } | |
| 114 bool UsedTexture(int texture) const { | |
| 115 return ContainsKey(used_textures_, texture); | |
| 116 } | |
| 117 void ResetUsedTextures() { used_textures_.clear(); } | |
| 118 | |
| 119 void set_have_extension_io_surface(bool have) { | |
| 120 have_extension_io_surface_ = have; | |
| 121 } | |
| 122 void set_have_extension_egl_image(bool have) { | |
| 123 have_extension_egl_image_ = have; | |
| 124 } | |
| 125 | |
| 126 static const WebKit::WebGLId kExternalTextureId; | |
| 127 virtual WebKit::WebGLId NextTextureId(); | |
| 128 | |
| 129 protected: | |
| 130 TestWebGraphicsContext3D(); | |
| 131 TestWebGraphicsContext3D( | |
| 132 const WebKit::WebGraphicsContext3D::Attributes& attributes); | |
| 133 | |
| 134 unsigned context_id_; | |
| 135 unsigned next_texture_id_; | |
| 136 Attributes attributes_; | |
| 137 bool have_extension_io_surface_; | |
| 138 bool have_extension_egl_image_; | |
| 139 int times_make_current_succeeds_; | |
| 140 int times_bind_texture_succeeds_; | |
| 141 int times_end_query_succeeds_; | |
| 142 bool context_lost_; | |
| 143 WebGraphicsContextLostCallback* context_lost_callback_; | |
| 144 std::vector<WebKit::WebGLId> textures_; | |
| 145 base::hash_set<WebKit::WebGLId> used_textures_; | |
| 146 int width_; | |
| 147 int height_; | |
| 148 }; | |
| 149 | |
| 150 } // namespace cc | |
| 151 | |
| 152 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ | |
| OLD | NEW |