| 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 | |
| 271 visible_ = true; | 267 visible_ = true; |
| 272 initialized_ = true; | 268 initialized_ = true; |
| 273 return true; | 269 return true; |
| 274 } | 270 } |
| 275 | 271 |
| 276 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( | 272 bool WebGraphicsContext3DCommandBufferImpl::InitializeCommandBuffer( |
| 277 bool onscreen, | 273 bool onscreen, |
| 278 const char* allowed_extensions) { | 274 const char* allowed_extensions) { |
| 279 if (!host_) | 275 if (!host_) |
| 280 return false; | 276 return false; |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 | 669 |
| 674 void WebGraphicsContext3DCommandBufferImpl::ensureFramebufferCHROMIUM() { | 670 void WebGraphicsContext3DCommandBufferImpl::ensureFramebufferCHROMIUM() { |
| 675 gl_->Flush(); | 671 gl_->Flush(); |
| 676 command_buffer_->EnsureBackbuffer(); | 672 command_buffer_->EnsureBackbuffer(); |
| 677 } | 673 } |
| 678 | 674 |
| 679 void WebGraphicsContext3DCommandBufferImpl:: | 675 void WebGraphicsContext3DCommandBufferImpl:: |
| 680 setMemoryAllocationChangedCallbackCHROMIUM( | 676 setMemoryAllocationChangedCallbackCHROMIUM( |
| 681 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { | 677 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { |
| 682 memory_allocation_changed_callback_ = callback; | 678 memory_allocation_changed_callback_ = callback; |
| 679 |
| 680 if (!command_buffer_) |
| 681 return; |
| 682 |
| 683 if (callback) |
| 684 command_buffer_->SetMemoryAllocationChangedCallback(base::Bind( |
| 685 &WebGraphicsContext3DCommandBufferImpl::OnMemoryAllocationChanged, |
| 686 weak_ptr_factory_.GetWeakPtr())); |
| 687 else |
| 688 command_buffer_->SetMemoryAllocationChangedCallback( |
| 689 base::Callback<void(const GpuMemoryAllocationForRenderer&)>()); |
| 683 } | 690 } |
| 684 | 691 |
| 685 | 692 |
| 686 void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM( | 693 void WebGraphicsContext3DCommandBufferImpl::copyTextureToParentTextureCHROMIUM( |
| 687 WebGLId texture, WebGLId parentTexture) { | 694 WebGLId texture, WebGLId parentTexture) { |
| 688 NOTIMPLEMENTED(); | 695 NOTIMPLEMENTED(); |
| 689 } | 696 } |
| 690 | 697 |
| 691 void WebGraphicsContext3DCommandBufferImpl:: | 698 void WebGraphicsContext3DCommandBufferImpl:: |
| 692 rateLimitOffscreenContextCHROMIUM() { | 699 rateLimitOffscreenContextCHROMIUM() { |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 } | 1517 } |
| 1511 | 1518 |
| 1512 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1519 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
| 1513 const std::string& message, int id) { | 1520 const std::string& message, int id) { |
| 1514 if (error_message_callback_) { | 1521 if (error_message_callback_) { |
| 1515 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); | 1522 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); |
| 1516 error_message_callback_->onErrorMessage(str, id); | 1523 error_message_callback_->onErrorMessage(str, id); |
| 1517 } | 1524 } |
| 1518 } | 1525 } |
| 1519 | 1526 |
| OLD | NEW |