| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
| 6 | 6 |
| 7 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" | 7 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" |
| 8 | 8 |
| 9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
| 10 #ifndef GL_GLEXT_PROTOTYPES | 10 #ifndef GL_GLEXT_PROTOTYPES |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "ui/gfx/gl/gl_share_group.h" | 33 #include "ui/gfx/gl/gl_share_group.h" |
| 34 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" | 34 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" |
| 35 | 35 |
| 36 using gpu::Buffer; | 36 using gpu::Buffer; |
| 37 using gpu::CommandBuffer; | 37 using gpu::CommandBuffer; |
| 38 using gpu::CommandBufferService; | 38 using gpu::CommandBufferService; |
| 39 using gpu::gles2::GLES2CmdHelper; | 39 using gpu::gles2::GLES2CmdHelper; |
| 40 using gpu::gles2::GLES2Implementation; | 40 using gpu::gles2::GLES2Implementation; |
| 41 using gpu::GpuScheduler; | 41 using gpu::GpuScheduler; |
| 42 | 42 |
| 43 namespace gpu { |
| 44 class SurfaceManager; |
| 45 } |
| 46 |
| 43 namespace webkit { | 47 namespace webkit { |
| 44 namespace gpu { | 48 namespace gpu { |
| 45 | 49 |
| 46 class GLInProcessContext : public base::SupportsWeakPtr<GLInProcessContext> { | 50 class GLInProcessContext : public base::SupportsWeakPtr<GLInProcessContext> { |
| 47 public: | 51 public: |
| 48 // These are the same error codes as used by EGL. | 52 // These are the same error codes as used by EGL. |
| 49 enum Error { | 53 enum Error { |
| 50 SUCCESS = 0x3000, | 54 SUCCESS = 0x3000, |
| 51 NOT_INITIALIZED = 0x3001, | 55 NOT_INITIALIZED = 0x3001, |
| 52 BAD_ATTRIBUTE = 0x3004, | 56 BAD_ATTRIBUTE = 0x3004, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 71 // Initialize the library. This must have completed before any other | 75 // Initialize the library. This must have completed before any other |
| 72 // functions are invoked. | 76 // functions are invoked. |
| 73 static bool Initialize(); | 77 static bool Initialize(); |
| 74 | 78 |
| 75 // Terminate the library. This must be called after any other functions | 79 // Terminate the library. This must be called after any other functions |
| 76 // have completed. | 80 // have completed. |
| 77 static bool Terminate(); | 81 static bool Terminate(); |
| 78 | 82 |
| 79 ~GLInProcessContext(); | 83 ~GLInProcessContext(); |
| 80 | 84 |
| 81 void PumpCommands(bool sync); | 85 void PumpCommands(); |
| 82 | 86 |
| 83 // Create a GLInProcessContext that renders directly to a view. The view and | 87 // Create a GLInProcessContext that renders directly to a view. The view and |
| 84 // the associated window must not be destroyed until the returned | 88 // the associated window must not be destroyed until the returned |
| 85 // GLInProcessContext has been destroyed, otherwise the GPU process might | 89 // GLInProcessContext has been destroyed, otherwise the GPU process might |
| 86 // attempt to render to an invalid window handle. | 90 // attempt to render to an invalid window handle. |
| 87 // | 91 // |
| 88 // NOTE: on Mac OS X, this entry point is only used to set up the | 92 // NOTE: on Mac OS X, this entry point is only used to set up the |
| 89 // accelerated compositor's output. On this platform, we actually pass | 93 // accelerated compositor's output. On this platform, we actually pass |
| 90 // a gfx::PluginWindowHandle in place of the gfx::NativeViewId, | 94 // a gfx::PluginWindowHandle in place of the gfx::NativeViewId, |
| 91 // because the facility to allocate a fake PluginWindowHandle is | 95 // because the facility to allocate a fake PluginWindowHandle is |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 void GLInProcessContext::ResizeOffscreen(const gfx::Size& size) { | 381 void GLInProcessContext::ResizeOffscreen(const gfx::Size& size) { |
| 378 DCHECK(size.width() > 0 && size.height() > 0); | 382 DCHECK(size.width() > 0 && size.height() > 0); |
| 379 if (size_ != size) { | 383 if (size_ != size) { |
| 380 gpu_scheduler_->ResizeOffscreenFrameBuffer(size); | 384 gpu_scheduler_->ResizeOffscreenFrameBuffer(size); |
| 381 // TODO(gman): See if the next line is needed. | 385 // TODO(gman): See if the next line is needed. |
| 382 gles2_implementation_->ResizeCHROMIUM(size.width(), size.height()); | 386 gles2_implementation_->ResizeCHROMIUM(size.width(), size.height()); |
| 383 size_ = size; | 387 size_ = size; |
| 384 } | 388 } |
| 385 } | 389 } |
| 386 | 390 |
| 387 void GLInProcessContext::PumpCommands(bool /* sync */) { | 391 void GLInProcessContext::PumpCommands() { |
| 388 ::gpu::CommandBuffer::State state; | 392 ::gpu::CommandBuffer::State state; |
| 389 do { | 393 do { |
| 390 gpu_scheduler_->PutChanged(true); | 394 gpu_scheduler_->PutChanged(); |
| 391 MessageLoop::current()->RunAllPending(); | 395 MessageLoop::current()->RunAllPending(); |
| 392 state = command_buffer_->GetState(); | 396 state = command_buffer_->GetState(); |
| 393 } while (state.get_offset != state.put_offset); | 397 } while (state.get_offset != state.put_offset); |
| 394 } | 398 } |
| 395 | 399 |
| 396 uint32 GLInProcessContext::GetParentTextureId() { | 400 uint32 GLInProcessContext::GetParentTextureId() { |
| 397 return parent_texture_id_; | 401 return parent_texture_id_; |
| 398 } | 402 } |
| 399 | 403 |
| 400 uint32 GLInProcessContext::CreateParentTexture(const gfx::Size& size) { | 404 uint32 GLInProcessContext::CreateParentTexture(const gfx::Size& size) { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 attribs.push_back(NONE); | 574 attribs.push_back(NONE); |
| 571 attrib_list = NULL; | 575 attrib_list = NULL; |
| 572 break; | 576 break; |
| 573 } | 577 } |
| 574 } | 578 } |
| 575 | 579 |
| 576 command_buffer_.reset(new CommandBufferService); | 580 command_buffer_.reset(new CommandBufferService); |
| 577 if (!command_buffer_->Initialize(kCommandBufferSize)) | 581 if (!command_buffer_->Initialize(kCommandBufferSize)) |
| 578 return false; | 582 return false; |
| 579 | 583 |
| 580 gpu_scheduler_ = new GpuScheduler(command_buffer_.get(), NULL, NULL); | 584 gpu_scheduler_ = new GpuScheduler( |
| 585 command_buffer_.get(), |
| 586 static_cast< ::gpu::SurfaceManager*>(NULL), |
| 587 NULL); |
| 581 | 588 |
| 582 if (onscreen) { | 589 if (onscreen) { |
| 583 if (render_surface == gfx::kNullPluginWindow) { | 590 if (render_surface == gfx::kNullPluginWindow) { |
| 584 LOG(ERROR) << "Invalid surface handle for onscreen context."; | 591 LOG(ERROR) << "Invalid surface handle for onscreen context."; |
| 585 command_buffer_.reset(); | 592 command_buffer_.reset(); |
| 586 } else { | 593 } else { |
| 587 if (!gpu_scheduler_->Initialize(render_surface, | 594 if (!gpu_scheduler_->Initialize(render_surface, |
| 588 gfx::Size(), | 595 gfx::Size(), |
| 589 ::gpu::gles2::DisallowedExtensions(), | 596 ::gpu::gles2::DisallowedExtensions(), |
| 590 allowed_extensions, | 597 allowed_extensions, |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 if (!context_->GetChildToParentLatch(latch_id)) { | 1070 if (!context_->GetChildToParentLatch(latch_id)) { |
| 1064 LOG(ERROR) << "getLatch must only be called on child context"; | 1071 LOG(ERROR) << "getLatch must only be called on child context"; |
| 1065 synthesizeGLError(GL_INVALID_OPERATION); | 1072 synthesizeGLError(GL_INVALID_OPERATION); |
| 1066 *latch_id = ::gpu::kInvalidLatchId; | 1073 *latch_id = ::gpu::kInvalidLatchId; |
| 1067 } | 1074 } |
| 1068 } | 1075 } |
| 1069 | 1076 |
| 1070 void WebGraphicsContext3DInProcessCommandBufferImpl::waitLatchCHROMIUM( | 1077 void WebGraphicsContext3DInProcessCommandBufferImpl::waitLatchCHROMIUM( |
| 1071 WGC3Duint latch_id) | 1078 WGC3Duint latch_id) |
| 1072 { | 1079 { |
| 1073 // TODO(gmam): See if we can comment this in. | |
| 1074 // ClearContext(); | |
| 1075 gl_->WaitLatchCHROMIUM(latch_id); | |
| 1076 } | 1080 } |
| 1077 | 1081 |
| 1078 void WebGraphicsContext3DInProcessCommandBufferImpl::setLatchCHROMIUM( | 1082 void WebGraphicsContext3DInProcessCommandBufferImpl::setLatchCHROMIUM( |
| 1079 WGC3Duint latch_id) | 1083 WGC3Duint latch_id) |
| 1080 { | 1084 { |
| 1081 // TODO(gmam): See if we can comment this in. | |
| 1082 // ClearContext(); | |
| 1083 gl_->SetLatchCHROMIUM(latch_id); | |
| 1084 // required to ensure set command is sent to GPU process | |
| 1085 gl_->Flush(); | |
| 1086 } | 1085 } |
| 1087 | 1086 |
| 1088 void WebGraphicsContext3DInProcessCommandBufferImpl:: | 1087 void WebGraphicsContext3DInProcessCommandBufferImpl:: |
| 1089 rateLimitOffscreenContextCHROMIUM() { | 1088 rateLimitOffscreenContextCHROMIUM() { |
| 1090 // TODO(gmam): See if we can comment this in. | 1089 // TODO(gmam): See if we can comment this in. |
| 1091 // ClearContext(); | 1090 // ClearContext(); |
| 1092 gl_->RateLimitOffscreenContextCHROMIUM(); | 1091 gl_->RateLimitOffscreenContextCHROMIUM(); |
| 1093 } | 1092 } |
| 1094 | 1093 |
| 1095 WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: | 1094 WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1792 if (context_lost_callback_) { | 1791 if (context_lost_callback_) { |
| 1793 context_lost_callback_->onContextLost(); | 1792 context_lost_callback_->onContextLost(); |
| 1794 } | 1793 } |
| 1795 } | 1794 } |
| 1796 | 1795 |
| 1797 } // namespace gpu | 1796 } // namespace gpu |
| 1798 } // namespace webkit | 1797 } // namespace webkit |
| 1799 | 1798 |
| 1800 #endif // defined(ENABLE_GPU) | 1799 #endif // defined(ENABLE_GPU) |
| 1801 | 1800 |
| OLD | NEW |