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 #include "cc/test/test_web_graphics_context_3d.h" | 5 #include "cc/test/test_web_graphics_context_3d.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 static unsigned s_context_id = 1; | 34 static unsigned s_context_id = 1; |
35 | 35 |
36 const WebGLId TestWebGraphicsContext3D::kExternalTextureId = 1337; | 36 const WebGLId TestWebGraphicsContext3D::kExternalTextureId = 1337; |
37 | 37 |
38 TestWebGraphicsContext3D::TestWebGraphicsContext3D() | 38 TestWebGraphicsContext3D::TestWebGraphicsContext3D() |
39 : FakeWebGraphicsContext3D(), | 39 : FakeWebGraphicsContext3D(), |
40 context_id_(s_context_id++), | 40 context_id_(s_context_id++), |
41 next_buffer_id_(1), | 41 next_buffer_id_(1), |
42 next_image_id_(1), | 42 next_image_id_(1), |
43 next_texture_id_(1), | 43 next_texture_id_(1), |
| 44 support_swapbuffers_complete_callback_(true), |
44 have_extension_io_surface_(false), | 45 have_extension_io_surface_(false), |
45 have_extension_egl_image_(false), | 46 have_extension_egl_image_(false), |
46 times_make_current_succeeds_(-1), | 47 times_make_current_succeeds_(-1), |
47 times_bind_texture_succeeds_(-1), | 48 times_bind_texture_succeeds_(-1), |
48 times_end_query_succeeds_(-1), | 49 times_end_query_succeeds_(-1), |
49 context_lost_(false), | 50 context_lost_(false), |
50 context_lost_callback_(NULL), | 51 context_lost_callback_(NULL), |
51 swap_buffers_callback_(NULL), | 52 swap_buffers_callback_(NULL), |
52 max_texture_size_(1024), | 53 max_texture_size_(1024), |
53 width_(0), | 54 width_(0), |
54 height_(0), | 55 height_(0), |
55 bound_buffer_(0), | 56 bound_buffer_(0), |
56 weak_ptr_factory_(this) { | 57 weak_ptr_factory_(this) { |
57 } | 58 } |
58 | 59 |
59 TestWebGraphicsContext3D::TestWebGraphicsContext3D( | 60 TestWebGraphicsContext3D::TestWebGraphicsContext3D( |
60 const WebGraphicsContext3D::Attributes& attributes) | 61 const WebGraphicsContext3D::Attributes& attributes) |
61 : FakeWebGraphicsContext3D(), | 62 : FakeWebGraphicsContext3D(), |
62 context_id_(s_context_id++), | 63 context_id_(s_context_id++), |
63 next_buffer_id_(1), | 64 next_buffer_id_(1), |
64 next_image_id_(1), | 65 next_image_id_(1), |
65 next_texture_id_(1), | 66 next_texture_id_(1), |
66 attributes_(attributes), | 67 attributes_(attributes), |
| 68 support_swapbuffers_complete_callback_(true), |
67 have_extension_io_surface_(false), | 69 have_extension_io_surface_(false), |
68 have_extension_egl_image_(false), | 70 have_extension_egl_image_(false), |
69 times_make_current_succeeds_(-1), | 71 times_make_current_succeeds_(-1), |
70 times_bind_texture_succeeds_(-1), | 72 times_bind_texture_succeeds_(-1), |
71 times_end_query_succeeds_(-1), | 73 times_end_query_succeeds_(-1), |
72 context_lost_(false), | 74 context_lost_(false), |
73 context_lost_callback_(NULL), | 75 context_lost_callback_(NULL), |
74 swap_buffers_callback_(NULL), | 76 swap_buffers_callback_(NULL), |
75 max_texture_size_(1024), | 77 max_texture_size_(1024), |
76 width_(0), | 78 width_(0), |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return GL_FRAMEBUFFER_UNDEFINED_OES; | 127 return GL_FRAMEBUFFER_UNDEFINED_OES; |
126 return GL_FRAMEBUFFER_COMPLETE; | 128 return GL_FRAMEBUFFER_COMPLETE; |
127 } | 129 } |
128 | 130 |
129 WebGraphicsContext3D::Attributes | 131 WebGraphicsContext3D::Attributes |
130 TestWebGraphicsContext3D::getContextAttributes() { | 132 TestWebGraphicsContext3D::getContextAttributes() { |
131 return attributes_; | 133 return attributes_; |
132 } | 134 } |
133 | 135 |
134 WebKit::WebString TestWebGraphicsContext3D::getString(WGC3Denum name) { | 136 WebKit::WebString TestWebGraphicsContext3D::getString(WGC3Denum name) { |
135 std::string string("GL_CHROMIUM_swapbuffers_complete_callback"); | 137 std::string string; |
| 138 |
| 139 if (support_swapbuffers_complete_callback_) |
| 140 string += "GL_CHROMIUM_swapbuffers_complete_callback"; |
136 | 141 |
137 if (name == GL_EXTENSIONS) { | 142 if (name == GL_EXTENSIONS) { |
138 if (have_extension_io_surface_) | 143 if (have_extension_io_surface_) |
139 string += " GL_CHROMIUM_iosurface GL_ARB_texture_rectangle"; | 144 string += " GL_CHROMIUM_iosurface GL_ARB_texture_rectangle"; |
140 if (have_extension_egl_image_) | 145 if (have_extension_egl_image_) |
141 string += " GL_OES_EGL_image_external"; | 146 string += " GL_OES_EGL_image_external"; |
142 } | 147 } |
143 | 148 |
144 return WebKit::WebString::fromUTF8(string.c_str()); | 149 return WebKit::WebString::fromUTF8(string.c_str()); |
145 } | 150 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 } | 353 } |
349 | 354 |
350 void TestWebGraphicsContext3D::signalSyncPoint( | 355 void TestWebGraphicsContext3D::signalSyncPoint( |
351 unsigned sync_point, | 356 unsigned sync_point, |
352 WebGraphicsSyncPointCallback* callback) { | 357 WebGraphicsSyncPointCallback* callback) { |
353 sync_point_callbacks_.push_back(callback); | 358 sync_point_callbacks_.push_back(callback); |
354 } | 359 } |
355 | 360 |
356 void TestWebGraphicsContext3D::setSwapBuffersCompleteCallbackCHROMIUM( | 361 void TestWebGraphicsContext3D::setSwapBuffersCompleteCallbackCHROMIUM( |
357 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) { | 362 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM* callback) { |
358 swap_buffers_callback_ = callback; | 363 if (support_swapbuffers_complete_callback_) |
| 364 swap_buffers_callback_ = callback; |
359 } | 365 } |
360 | 366 |
361 void TestWebGraphicsContext3D::prepareTexture() { | 367 void TestWebGraphicsContext3D::prepareTexture() { |
362 if (swap_buffers_callback_) { | 368 if (swap_buffers_callback_) { |
363 base::MessageLoop::current()->PostTask( | 369 base::MessageLoop::current()->PostTask( |
364 FROM_HERE, base::Bind(&TestWebGraphicsContext3D::SwapBuffersComplete, | 370 FROM_HERE, base::Bind(&TestWebGraphicsContext3D::SwapBuffersComplete, |
365 weak_ptr_factory_.GetWeakPtr())); | 371 weak_ptr_factory_.GetWeakPtr())); |
366 } | 372 } |
367 CallAllSyncPointCallbacks(); | 373 CallAllSyncPointCallbacks(); |
368 } | 374 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 | 517 |
512 TestWebGraphicsContext3D::Buffer::Buffer() : target(0) {} | 518 TestWebGraphicsContext3D::Buffer::Buffer() : target(0) {} |
513 | 519 |
514 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 520 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
515 | 521 |
516 TestWebGraphicsContext3D::Image::Image() {} | 522 TestWebGraphicsContext3D::Image::Image() {} |
517 | 523 |
518 TestWebGraphicsContext3D::Image::~Image() {} | 524 TestWebGraphicsContext3D::Image::~Image() {} |
519 | 525 |
520 } // namespace cc | 526 } // namespace cc |
OLD | NEW |