| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "cc/base/scoped_ptr_hash_map.h" |
| 14 #include "cc/debug/fake_web_graphics_context_3d.h" | 15 #include "cc/debug/fake_web_graphics_context_3d.h" |
| 15 #include "third_party/khronos/GLES2/gl2.h" | 16 #include "third_party/khronos/GLES2/gl2.h" |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 18 | 19 |
| 19 class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { | 20 class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
| 20 public: | 21 public: |
| 21 static scoped_ptr<TestWebGraphicsContext3D> Create() { | 22 static scoped_ptr<TestWebGraphicsContext3D> Create() { |
| 22 return make_scoped_ptr(new TestWebGraphicsContext3D()); | 23 return make_scoped_ptr(new TestWebGraphicsContext3D()); |
| 23 } | 24 } |
| 24 static scoped_ptr<TestWebGraphicsContext3D> Create( | 25 static scoped_ptr<TestWebGraphicsContext3D> Create( |
| 25 const WebKit::WebGraphicsContext3D::Attributes& attributes) { | 26 const WebKit::WebGraphicsContext3D::Attributes& attributes) { |
| 26 return make_scoped_ptr(new TestWebGraphicsContext3D(attributes)); | 27 return make_scoped_ptr(new TestWebGraphicsContext3D(attributes)); |
| 27 } | 28 } |
| 28 virtual ~TestWebGraphicsContext3D(); | 29 virtual ~TestWebGraphicsContext3D(); |
| 29 | 30 |
| 30 virtual bool makeContextCurrent(); | 31 virtual bool makeContextCurrent(); |
| 31 | 32 |
| 32 virtual int width(); | 33 virtual int width(); |
| 33 virtual int height(); | 34 virtual int height(); |
| 34 | 35 |
| 35 virtual void reshape(int width, int height); | 36 virtual void reshape(int width, int height); |
| 36 | 37 |
| 37 virtual bool isContextLost(); | 38 virtual bool isContextLost(); |
| 38 virtual WebKit::WGC3Denum getGraphicsResetStatusARB(); | 39 virtual WebKit::WGC3Denum getGraphicsResetStatusARB(); |
| 39 | 40 |
| 40 virtual void attachShader(WebKit::WebGLId program, WebKit::WebGLId shader); | 41 virtual void attachShader(WebKit::WebGLId program, WebKit::WebGLId shader); |
| 41 virtual void bindBuffer(WebKit::WGC3Denum target, WebKit::WebGLId buffer); | |
| 42 virtual void bindFramebuffer( | 42 virtual void bindFramebuffer( |
| 43 WebKit::WGC3Denum target, WebKit::WebGLId framebuffer); | 43 WebKit::WGC3Denum target, WebKit::WebGLId framebuffer); |
| 44 virtual void bindRenderbuffer( | 44 virtual void bindRenderbuffer( |
| 45 WebKit::WGC3Denum target, WebKit::WebGLId renderbuffer); | 45 WebKit::WGC3Denum target, WebKit::WebGLId renderbuffer); |
| 46 virtual void bindTexture( | 46 virtual void bindTexture( |
| 47 WebKit::WGC3Denum target, | 47 WebKit::WGC3Denum target, |
| 48 WebKit::WebGLId texture_id); | 48 WebKit::WebGLId texture_id); |
| 49 | 49 |
| 50 virtual WebKit::WGC3Denum checkFramebufferStatus(WebKit::WGC3Denum target); | 50 virtual WebKit::WGC3Denum checkFramebufferStatus(WebKit::WGC3Denum target); |
| 51 | 51 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 const WebKit::WGC3Dbyte* mailbox) { } | 98 const WebKit::WGC3Dbyte* mailbox) { } |
| 99 virtual void consumeTextureCHROMIUM(WebKit::WGC3Denum target, | 99 virtual void consumeTextureCHROMIUM(WebKit::WGC3Denum target, |
| 100 const WebKit::WGC3Dbyte* mailbox) { } | 100 const WebKit::WGC3Dbyte* mailbox) { } |
| 101 | 101 |
| 102 virtual void setContextLostCallback( | 102 virtual void setContextLostCallback( |
| 103 WebGraphicsContextLostCallback* callback); | 103 WebGraphicsContextLostCallback* callback); |
| 104 | 104 |
| 105 virtual void loseContextCHROMIUM(WebKit::WGC3Denum current, | 105 virtual void loseContextCHROMIUM(WebKit::WGC3Denum current, |
| 106 WebKit::WGC3Denum other); | 106 WebKit::WGC3Denum other); |
| 107 | 107 |
| 108 // Takes ownership of the |callback|. |
| 109 virtual void signalSyncPoint(unsigned sync_point, |
| 110 WebGraphicsSyncPointCallback* callback); |
| 111 |
| 112 virtual void prepareTexture(); |
| 113 virtual void finish(); |
| 114 virtual void flush(); |
| 115 |
| 116 virtual void bindBuffer(WebKit::WGC3Denum target, WebKit::WebGLId buffer); |
| 117 virtual void bufferData(WebKit::WGC3Denum target, |
| 118 WebKit::WGC3Dsizeiptr size, |
| 119 const void* data, |
| 120 WebKit::WGC3Denum usage); |
| 121 virtual void* mapBufferCHROMIUM(WebKit::WGC3Denum target, |
| 122 WebKit::WGC3Denum access); |
| 123 virtual WebKit::WGC3Dboolean unmapBufferCHROMIUM(WebKit::WGC3Denum target); |
| 124 |
| 108 // When set, MakeCurrent() will fail after this many times. | 125 // When set, MakeCurrent() will fail after this many times. |
| 109 void set_times_make_current_succeeds(int times) { | 126 void set_times_make_current_succeeds(int times) { |
| 110 times_make_current_succeeds_ = times; | 127 times_make_current_succeeds_ = times; |
| 111 } | 128 } |
| 112 void set_times_bind_texture_succeeds(int times) { | 129 void set_times_bind_texture_succeeds(int times) { |
| 113 times_bind_texture_succeeds_ = times; | 130 times_bind_texture_succeeds_ = times; |
| 114 } | 131 } |
| 115 void set_times_end_query_succeeds(int times) { | 132 void set_times_end_query_succeeds(int times) { |
| 116 times_end_query_succeeds_ = times; | 133 times_end_query_succeeds_ = times; |
| 117 } | 134 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 135 // When this context is lost, all contexts in its share group are also lost. | 152 // When this context is lost, all contexts in its share group are also lost. |
| 136 void add_share_group_context(WebKit::WebGraphicsContext3D* context3d) { | 153 void add_share_group_context(WebKit::WebGraphicsContext3D* context3d) { |
| 137 shared_contexts_.push_back(context3d); | 154 shared_contexts_.push_back(context3d); |
| 138 } | 155 } |
| 139 | 156 |
| 140 void set_max_texture_size(int size) { max_texture_size_ = size; } | 157 void set_max_texture_size(int size) { max_texture_size_ = size; } |
| 141 | 158 |
| 142 static const WebKit::WebGLId kExternalTextureId; | 159 static const WebKit::WebGLId kExternalTextureId; |
| 143 virtual WebKit::WebGLId NextTextureId(); | 160 virtual WebKit::WebGLId NextTextureId(); |
| 144 | 161 |
| 162 virtual WebKit::WebGLId NextBufferId(); |
| 163 |
| 145 protected: | 164 protected: |
| 146 TestWebGraphicsContext3D(); | 165 TestWebGraphicsContext3D(); |
| 147 TestWebGraphicsContext3D( | 166 TestWebGraphicsContext3D( |
| 148 const WebKit::WebGraphicsContext3D::Attributes& attributes); | 167 const WebKit::WebGraphicsContext3D::Attributes& attributes); |
| 149 | 168 |
| 169 void CallAllSyncPointCallbacks(); |
| 170 |
| 150 unsigned context_id_; | 171 unsigned context_id_; |
| 172 unsigned next_buffer_id_; |
| 151 unsigned next_texture_id_; | 173 unsigned next_texture_id_; |
| 152 Attributes attributes_; | 174 Attributes attributes_; |
| 153 bool have_extension_io_surface_; | 175 bool have_extension_io_surface_; |
| 154 bool have_extension_egl_image_; | 176 bool have_extension_egl_image_; |
| 155 int times_make_current_succeeds_; | 177 int times_make_current_succeeds_; |
| 156 int times_bind_texture_succeeds_; | 178 int times_bind_texture_succeeds_; |
| 157 int times_end_query_succeeds_; | 179 int times_end_query_succeeds_; |
| 158 bool context_lost_; | 180 bool context_lost_; |
| 159 WebGraphicsContextLostCallback* context_lost_callback_; | 181 WebGraphicsContextLostCallback* context_lost_callback_; |
| 182 std::vector<WebGraphicsSyncPointCallback*> sync_point_callbacks_; |
| 160 std::vector<WebKit::WebGLId> textures_; | 183 std::vector<WebKit::WebGLId> textures_; |
| 161 base::hash_set<WebKit::WebGLId> used_textures_; | 184 base::hash_set<WebKit::WebGLId> used_textures_; |
| 162 std::vector<WebKit::WebGraphicsContext3D*> shared_contexts_; | 185 std::vector<WebKit::WebGraphicsContext3D*> shared_contexts_; |
| 163 int max_texture_size_; | 186 int max_texture_size_; |
| 164 int width_; | 187 int width_; |
| 165 int height_; | 188 int height_; |
| 189 |
| 190 struct Buffer { |
| 191 Buffer(); |
| 192 ~Buffer(); |
| 193 |
| 194 WebKit::WGC3Denum target; |
| 195 scoped_ptr<uint8[]> pixels; |
| 196 |
| 197 private: |
| 198 DISALLOW_COPY_AND_ASSIGN(Buffer); |
| 199 }; |
| 200 ScopedPtrHashMap<unsigned, Buffer> buffers_; |
| 201 unsigned bound_buffer_; |
| 166 }; | 202 }; |
| 167 | 203 |
| 168 } // namespace cc | 204 } // namespace cc |
| 169 | 205 |
| 170 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ | 206 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ |
| OLD | NEW |