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 #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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 weak_ptr_factory_(this) { | 84 weak_ptr_factory_(this) { |
85 CreateNamespace(); | 85 CreateNamespace(); |
86 } | 86 } |
87 | 87 |
88 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { | 88 TestWebGraphicsContext3D::~TestWebGraphicsContext3D() { |
89 base::AutoLock lock(g_shared_namespace_lock.Get()); | 89 base::AutoLock lock(g_shared_namespace_lock.Get()); |
90 namespace_ = NULL; | 90 namespace_ = NULL; |
91 } | 91 } |
92 | 92 |
93 void TestWebGraphicsContext3D::CreateNamespace() { | 93 void TestWebGraphicsContext3D::CreateNamespace() { |
94 if (attributes_.shareResources) { | 94 base::AutoLock lock(g_shared_namespace_lock.Get()); |
95 base::AutoLock lock(g_shared_namespace_lock.Get()); | 95 if (shared_namespace_) { |
96 if (shared_namespace_) { | 96 namespace_ = shared_namespace_; |
97 namespace_ = shared_namespace_; | |
98 } else { | |
99 namespace_ = new Namespace; | |
100 shared_namespace_ = namespace_.get(); | |
101 } | |
102 } else { | 97 } else { |
103 namespace_ = new Namespace; | 98 namespace_ = new Namespace; |
| 99 shared_namespace_ = namespace_.get(); |
104 } | 100 } |
105 } | 101 } |
106 | 102 |
107 void TestWebGraphicsContext3D::reshapeWithScaleFactor( | 103 void TestWebGraphicsContext3D::reshapeWithScaleFactor( |
108 int width, int height, float scale_factor) { | 104 int width, int height, float scale_factor) { |
109 reshape_called_ = true; | 105 reshape_called_ = true; |
110 width_ = width; | 106 width_ = width; |
111 height_ = height; | 107 height_ = height; |
112 scale_factor_ = scale_factor; | 108 scale_factor_ = scale_factor; |
113 } | 109 } |
114 | 110 |
115 bool TestWebGraphicsContext3D::isContextLost() { | 111 bool TestWebGraphicsContext3D::isContextLost() { |
116 return context_lost_; | 112 return context_lost_; |
117 } | 113 } |
118 | 114 |
119 WGC3Denum TestWebGraphicsContext3D::checkFramebufferStatus( | 115 WGC3Denum TestWebGraphicsContext3D::checkFramebufferStatus( |
120 WGC3Denum target) { | 116 WGC3Denum target) { |
121 if (context_lost_) | 117 if (context_lost_) |
122 return GL_FRAMEBUFFER_UNDEFINED_OES; | 118 return GL_FRAMEBUFFER_UNDEFINED_OES; |
123 return GL_FRAMEBUFFER_COMPLETE; | 119 return GL_FRAMEBUFFER_COMPLETE; |
124 } | 120 } |
125 | 121 |
126 WebGraphicsContext3D::Attributes | |
127 TestWebGraphicsContext3D::getContextAttributes() { | |
128 return attributes_; | |
129 } | |
130 | |
131 blink::WebString TestWebGraphicsContext3D::getString(WGC3Denum name) { | 122 blink::WebString TestWebGraphicsContext3D::getString(WGC3Denum name) { |
132 return blink::WebString(); | 123 return blink::WebString(); |
133 } | 124 } |
134 | 125 |
135 WGC3Dint TestWebGraphicsContext3D::getUniformLocation( | 126 WGC3Dint TestWebGraphicsContext3D::getUniformLocation( |
136 WebGLId program, | 127 WebGLId program, |
137 const WGC3Dchar* name) { | 128 const WGC3Dchar* name) { |
138 return 0; | 129 return 0; |
139 } | 130 } |
140 | 131 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 mailbox[0] = mailbox_name1; | 402 mailbox[0] = mailbox_name1; |
412 mailbox[1] = mailbox_name2; | 403 mailbox[1] = mailbox_name2; |
413 mailbox[2] = '\0'; | 404 mailbox[2] = '\0'; |
414 if (++mailbox_name1 == 0) { | 405 if (++mailbox_name1 == 0) { |
415 mailbox_name1 = '1'; | 406 mailbox_name1 = '1'; |
416 ++mailbox_name2; | 407 ++mailbox_name2; |
417 } | 408 } |
418 } | 409 } |
419 | 410 |
420 void TestWebGraphicsContext3D::setContextLostCallback( | 411 void TestWebGraphicsContext3D::setContextLostCallback( |
421 WebGraphicsContextLostCallback* callback) { | 412 blink::WebGraphicsContext3D::WebGraphicsContextLostCallback* callback) { |
422 context_lost_callback_ = callback; | 413 context_lost_callback_ = callback; |
423 } | 414 } |
424 | 415 |
425 void TestWebGraphicsContext3D::loseContextCHROMIUM(WGC3Denum current, | 416 void TestWebGraphicsContext3D::loseContextCHROMIUM(WGC3Denum current, |
426 WGC3Denum other) { | 417 WGC3Denum other) { |
427 if (context_lost_) | 418 if (context_lost_) |
428 return; | 419 return; |
429 context_lost_ = true; | 420 context_lost_ = true; |
430 if (context_lost_callback_) | 421 if (context_lost_callback_) |
431 context_lost_callback_->onContextLost(); | 422 context_lost_callback_->onContextLost(); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 | 700 |
710 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} | 701 TestWebGraphicsContext3D::Buffer::Buffer() : target(0), size(0) {} |
711 | 702 |
712 TestWebGraphicsContext3D::Buffer::~Buffer() {} | 703 TestWebGraphicsContext3D::Buffer::~Buffer() {} |
713 | 704 |
714 TestWebGraphicsContext3D::Image::Image() {} | 705 TestWebGraphicsContext3D::Image::Image() {} |
715 | 706 |
716 TestWebGraphicsContext3D::Image::~Image() {} | 707 TestWebGraphicsContext3D::Image::~Image() {} |
717 | 708 |
718 } // namespace cc | 709 } // namespace cc |
OLD | NEW |