OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
6 | 6 |
7 #include "third_party/khronos/GLES2/gl2.h" | 7 #include "third_party/khronos/GLES2/gl2.h" |
8 #ifndef GL_GLEXT_PROTOTYPES | 8 #ifndef GL_GLEXT_PROTOTYPES |
9 #define GL_GLEXT_PROTOTYPES 1 | 9 #define GL_GLEXT_PROTOTYPES 1 |
10 #endif | 10 #endif |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 GLint samples = 0; | 257 GLint samples = 0; |
258 getIntegerv(GL_SAMPLES, &samples); | 258 getIntegerv(GL_SAMPLES, &samples); |
259 attributes_.antialias = samples > 0; | 259 attributes_.antialias = samples > 0; |
260 } | 260 } |
261 | 261 |
262 if (attributes_.shareResources) { | 262 if (attributes_.shareResources) { |
263 base::AutoLock lock(g_all_shared_contexts_lock.Get()); | 263 base::AutoLock lock(g_all_shared_contexts_lock.Get()); |
264 g_all_shared_contexts.Pointer()->insert(this); | 264 g_all_shared_contexts.Pointer()->insert(this); |
265 } | 265 } |
266 | 266 |
| 267 command_buffer_->SetMemoryAllocationChangedCallback(base::Bind( |
| 268 &WebGraphicsContext3DCommandBufferImpl::OnMemoryAllocationChanged, |
| 269 weak_ptr_factory_.GetWeakPtr())); |
| 270 |
267 visible_ = true; | 271 visible_ = true; |
268 initialized_ = true; | 272 initialized_ = true; |
269 return true; | 273 return true; |
270 } | 274 } |
271 | 275 |
272 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( | 276 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( |
273 bool onscreen, | 277 bool onscreen, |
274 const char* allowed_extensions) { | 278 const char* allowed_extensions) { |
275 if (!host_) | 279 if (!host_) |
276 return false; | 280 return false; |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 | 673 |
670 void WebGraphicsContext3DCommandBufferImpl::ensureFramebufferCHROMIUM() { | 674 void WebGraphicsContext3DCommandBufferImpl::ensureFramebufferCHROMIUM() { |
671 gl_->Flush(); | 675 gl_->Flush(); |
672 command_buffer_->EnsureBackbuffer(); | 676 command_buffer_->EnsureBackbuffer(); |
673 } | 677 } |
674 | 678 |
675 void WebGraphicsContext3DCommandBufferImpl:: | 679 void WebGraphicsContext3DCommandBufferImpl:: |
676 setMemoryAllocationChangedCallbackCHROMIUM( | 680 setMemoryAllocationChangedCallbackCHROMIUM( |
677 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { | 681 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { |
678 memory_allocation_changed_callback_ = callback; | 682 memory_allocation_changed_callback_ = callback; |
679 | |
680 if (callback) | |
681 command_buffer_->SetMemoryAllocationChangedCallback(base::Bind( | |
682 &WebGraphicsContext3DCommandBufferImpl::OnMemoryAllocationChanged, | |
683 weak_ptr_factory_.GetWeakPtr())); | |
684 else | |
685 command_buffer_->SetMemoryAllocationChangedCallback( | |
686 base::Callback<void(const GpuMemoryAllocationForRenderer&)>()); | |
687 } | 683 } |
688 | 684 |
689 | 685 |
690 void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM( | 686 void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM( |
691 WebGLId texture, WebGLId parentTexture) { | 687 WebGLId texture, WebGLId parentTexture) { |
692 NOTIMPLEMENTED(); | 688 NOTIMPLEMENTED(); |
693 } | 689 } |
694 | 690 |
695 void WebGraphicsContext3DCommandBufferImpl:: | 691 void WebGraphicsContext3DCommandBufferImpl:: |
696 rateLimitOffscreenContextCHROMIUM() { | 692 rateLimitOffscreenContextCHROMIUM() { |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 } | 1510 } |
1515 | 1511 |
1516 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1512 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
1517 const std::string& message, int id) { | 1513 const std::string& message, int id) { |
1518 if (error_message_callback_) { | 1514 if (error_message_callback_) { |
1519 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); | 1515 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); |
1520 error_message_callback_->onErrorMessage(str, id); | 1516 error_message_callback_->onErrorMessage(str, id); |
1521 } | 1517 } |
1522 } | 1518 } |
1523 | 1519 |
OLD | NEW |