| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 12 #include "base/containers/scoped_ptr_hash_map.h" | 12 #include "base/containers/scoped_ptr_hash_map.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "cc/output/context_provider.h" | 18 #include "cc/output/context_provider.h" |
| 19 #include "cc/test/fake_web_graphics_context_3d.h" | 19 #include "cc/test/fake_web_graphics_context_3d.h" |
| 20 #include "cc/test/ordered_texture_map.h" | 20 #include "cc/test/ordered_texture_map.h" |
| 21 #include "cc/test/test_texture.h" | 21 #include "cc/test/test_texture.h" |
| 22 #include "third_party/khronos/GLES2/gl2.h" | 22 #include "third_party/khronos/GLES2/gl2.h" |
| 23 #include "ui/gfx/rect.h" |
| 23 | 24 |
| 24 namespace cc { | 25 namespace cc { |
| 25 class TestContextSupport; | 26 class TestContextSupport; |
| 26 | 27 |
| 27 class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { | 28 class TestWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
| 28 public: | 29 public: |
| 29 static scoped_ptr<TestWebGraphicsContext3D> Create(); | 30 static scoped_ptr<TestWebGraphicsContext3D> Create(); |
| 30 | 31 |
| 31 virtual ~TestWebGraphicsContext3D(); | 32 virtual ~TestWebGraphicsContext3D(); |
| 32 | 33 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 117 |
| 117 virtual void setContextLostCallback( | 118 virtual void setContextLostCallback( |
| 118 WebGraphicsContextLostCallback* callback); | 119 WebGraphicsContextLostCallback* callback); |
| 119 | 120 |
| 120 virtual void loseContextCHROMIUM(WebKit::WGC3Denum current, | 121 virtual void loseContextCHROMIUM(WebKit::WGC3Denum current, |
| 121 WebKit::WGC3Denum other); | 122 WebKit::WGC3Denum other); |
| 122 | 123 |
| 123 virtual void setSwapBuffersCompleteCallbackCHROMIUM( | 124 virtual void setSwapBuffersCompleteCallbackCHROMIUM( |
| 124 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback); | 125 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback); |
| 125 | 126 |
| 127 virtual void enable(GLenum cap); |
| 128 virtual void disable(GLenum cap); |
| 129 |
| 126 virtual void prepareTexture(); | 130 virtual void prepareTexture(); |
| 131 virtual void postSubBufferCHROMIUM(int x, int y, int width, int height); |
| 127 virtual void finish(); | 132 virtual void finish(); |
| 128 virtual void flush(); | 133 virtual void flush(); |
| 129 | 134 |
| 130 virtual void bindBuffer(WebKit::WGC3Denum target, WebKit::WebGLId buffer); | 135 virtual void bindBuffer(WebKit::WGC3Denum target, WebKit::WebGLId buffer); |
| 131 virtual void bufferData(WebKit::WGC3Denum target, | 136 virtual void bufferData(WebKit::WGC3Denum target, |
| 132 WebKit::WGC3Dsizeiptr size, | 137 WebKit::WGC3Dsizeiptr size, |
| 133 const void* data, | 138 const void* data, |
| 134 WebKit::WGC3Denum usage); | 139 WebKit::WGC3Denum usage); |
| 135 virtual void* mapBufferCHROMIUM(WebKit::WGC3Denum target, | 140 virtual void* mapBufferCHROMIUM(WebKit::WGC3Denum target, |
| 136 WebKit::WGC3Denum access); | 141 WebKit::WGC3Denum access); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 225 |
| 221 virtual WebKit::WebGLId NextImageId(); | 226 virtual WebKit::WebGLId NextImageId(); |
| 222 | 227 |
| 223 size_t GetTransferBufferMemoryUsedBytes() const; | 228 size_t GetTransferBufferMemoryUsedBytes() const; |
| 224 void SetMaxTransferBufferUsageBytes(size_t max_transfer_buffer_usage_bytes); | 229 void SetMaxTransferBufferUsageBytes(size_t max_transfer_buffer_usage_bytes); |
| 225 | 230 |
| 226 void set_test_support(TestContextSupport* test_support) { | 231 void set_test_support(TestContextSupport* test_support) { |
| 227 test_support_ = test_support; | 232 test_support_ = test_support; |
| 228 } | 233 } |
| 229 | 234 |
| 235 int width() const { return width_; } |
| 236 int height() const { return height_; } |
| 237 bool reshape_called() const { return reshape_called_; } |
| 238 void clear_reshape_called() { reshape_called_ = false; } |
| 239 float scale_factor() const { return scale_factor_; } |
| 240 |
| 241 enum UpdateType { |
| 242 NoUpdate = 0, |
| 243 PrepareTexture, |
| 244 PostSubBuffer |
| 245 }; |
| 246 |
| 247 gfx::Rect update_rect() const { return update_rect_; } |
| 248 |
| 249 UpdateType last_update_type() { |
| 250 return last_update_type_; |
| 251 } |
| 252 |
| 230 protected: | 253 protected: |
| 231 struct TextureTargets { | 254 struct TextureTargets { |
| 232 TextureTargets(); | 255 TextureTargets(); |
| 233 ~TextureTargets(); | 256 ~TextureTargets(); |
| 234 | 257 |
| 235 void BindTexture(WebKit::WGC3Denum target, WebKit::WebGLId id); | 258 void BindTexture(WebKit::WGC3Denum target, WebKit::WebGLId id); |
| 236 void UnbindTexture(WebKit::WebGLId id); | 259 void UnbindTexture(WebKit::WebGLId id); |
| 237 | 260 |
| 238 WebKit::WebGLId BoundTexture(WebKit::WGC3Denum target); | 261 WebKit::WebGLId BoundTexture(WebKit::WGC3Denum target); |
| 239 | 262 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 ContextProvider::Capabilities test_capabilities_; | 317 ContextProvider::Capabilities test_capabilities_; |
| 295 int times_make_current_succeeds_; | 318 int times_make_current_succeeds_; |
| 296 int times_bind_texture_succeeds_; | 319 int times_bind_texture_succeeds_; |
| 297 int times_end_query_succeeds_; | 320 int times_end_query_succeeds_; |
| 298 int times_gen_mailbox_succeeds_; | 321 int times_gen_mailbox_succeeds_; |
| 299 bool context_lost_; | 322 bool context_lost_; |
| 300 int times_map_image_chromium_succeeds_; | 323 int times_map_image_chromium_succeeds_; |
| 301 int times_map_buffer_chromium_succeeds_; | 324 int times_map_buffer_chromium_succeeds_; |
| 302 WebGraphicsContextLostCallback* context_lost_callback_; | 325 WebGraphicsContextLostCallback* context_lost_callback_; |
| 303 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* swap_buffers_callback_; | 326 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* swap_buffers_callback_; |
| 304 base::hash_set<WebKit::WebGLId> used_textures_; | 327 base::hash_set<unsigned> used_textures_; |
| 328 unsigned next_program_id_; |
| 329 base::hash_set<unsigned> program_set_; |
| 330 unsigned next_shader_id_; |
| 331 base::hash_set<unsigned> shader_set_; |
| 305 std::vector<WebKit::WebGraphicsContext3D*> shared_contexts_; | 332 std::vector<WebKit::WebGraphicsContext3D*> shared_contexts_; |
| 306 int max_texture_size_; | 333 int max_texture_size_; |
| 334 bool reshape_called_; |
| 307 int width_; | 335 int width_; |
| 308 int height_; | 336 int height_; |
| 337 float scale_factor_; |
| 309 TestContextSupport* test_support_; | 338 TestContextSupport* test_support_; |
| 339 gfx::Rect update_rect_; |
| 340 UpdateType last_update_type_; |
| 310 | 341 |
| 311 unsigned bound_buffer_; | 342 unsigned bound_buffer_; |
| 312 TextureTargets texture_targets_; | 343 TextureTargets texture_targets_; |
| 313 | 344 |
| 314 scoped_refptr<Namespace> namespace_; | 345 scoped_refptr<Namespace> namespace_; |
| 315 static Namespace* shared_namespace_; | 346 static Namespace* shared_namespace_; |
| 316 | 347 |
| 317 base::WeakPtrFactory<TestWebGraphicsContext3D> weak_ptr_factory_; | 348 base::WeakPtrFactory<TestWebGraphicsContext3D> weak_ptr_factory_; |
| 318 }; | 349 }; |
| 319 | 350 |
| 320 } // namespace cc | 351 } // namespace cc |
| 321 | 352 |
| 322 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ | 353 #endif // CC_TEST_TEST_WEB_GRAPHICS_CONTEXT_3D_H_ |
| OLD | NEW |