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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // Initialize the library. This must have completed before any other | 71 // Initialize the library. This must have completed before any other |
72 // functions are invoked. | 72 // functions are invoked. |
73 static bool Initialize(); | 73 static bool Initialize(); |
74 | 74 |
75 // Terminate the library. This must be called after any other functions | 75 // Terminate the library. This must be called after any other functions |
76 // have completed. | 76 // have completed. |
77 static bool Terminate(); | 77 static bool Terminate(); |
78 | 78 |
79 ~GLInProcessContext(); | 79 ~GLInProcessContext(); |
80 | 80 |
81 void PumpCommands(bool sync); | 81 void PumpCommands(); |
82 | 82 |
83 // Create a GLInProcessContext that renders directly to a view. The view and | 83 // Create a GLInProcessContext that renders directly to a view. The view and |
84 // the associated window must not be destroyed until the returned | 84 // the associated window must not be destroyed until the returned |
85 // GLInProcessContext has been destroyed, otherwise the GPU process might | 85 // GLInProcessContext has been destroyed, otherwise the GPU process might |
86 // attempt to render to an invalid window handle. | 86 // attempt to render to an invalid window handle. |
87 // | 87 // |
88 // NOTE: on Mac OS X, this entry point is only used to set up the | 88 // 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 | 89 // accelerated compositor's output. On this platform, we actually pass |
90 // a gfx::PluginWindowHandle in place of the gfx::NativeViewId, | 90 // a gfx::PluginWindowHandle in place of the gfx::NativeViewId, |
91 // because the facility to allocate a fake PluginWindowHandle is | 91 // 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) { | 377 void GLInProcessContext::ResizeOffscreen(const gfx::Size& size) { |
378 DCHECK(size.width() > 0 && size.height() > 0); | 378 DCHECK(size.width() > 0 && size.height() > 0); |
379 if (size_ != size) { | 379 if (size_ != size) { |
380 gpu_scheduler_->ResizeOffscreenFrameBuffer(size); | 380 gpu_scheduler_->ResizeOffscreenFrameBuffer(size); |
381 // TODO(gman): See if the next line is needed. | 381 // TODO(gman): See if the next line is needed. |
382 gles2_implementation_->ResizeCHROMIUM(size.width(), size.height()); | 382 gles2_implementation_->ResizeCHROMIUM(size.width(), size.height()); |
383 size_ = size; | 383 size_ = size; |
384 } | 384 } |
385 } | 385 } |
386 | 386 |
387 void GLInProcessContext::PumpCommands(bool /* sync */) { | 387 void GLInProcessContext::PumpCommands() { |
388 ::gpu::CommandBuffer::State state; | 388 ::gpu::CommandBuffer::State state; |
389 do { | 389 do { |
390 gpu_scheduler_->PutChanged(true); | 390 gpu_scheduler_->PutChanged(); |
391 MessageLoop::current()->RunAllPending(); | 391 MessageLoop::current()->RunAllPending(); |
392 state = command_buffer_->GetState(); | 392 state = command_buffer_->GetState(); |
393 } while (state.get_offset != state.put_offset); | 393 } while (state.get_offset != state.put_offset); |
394 } | 394 } |
395 | 395 |
396 uint32 GLInProcessContext::GetParentTextureId() { | 396 uint32 GLInProcessContext::GetParentTextureId() { |
397 return parent_texture_id_; | 397 return parent_texture_id_; |
398 } | 398 } |
399 | 399 |
400 uint32 GLInProcessContext::CreateParentTexture(const gfx::Size& size) { | 400 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); | 570 attribs.push_back(NONE); |
571 attrib_list = NULL; | 571 attrib_list = NULL; |
572 break; | 572 break; |
573 } | 573 } |
574 } | 574 } |
575 | 575 |
576 command_buffer_.reset(new CommandBufferService); | 576 command_buffer_.reset(new CommandBufferService); |
577 if (!command_buffer_->Initialize(kCommandBufferSize)) | 577 if (!command_buffer_->Initialize(kCommandBufferSize)) |
578 return false; | 578 return false; |
579 | 579 |
580 gpu_scheduler_ = new GpuScheduler(command_buffer_.get(), NULL, NULL); | 580 gpu_scheduler_ = GpuScheduler::Create(command_buffer_.get(), |
| 581 NULL, |
| 582 NULL); |
581 | 583 |
582 if (onscreen) { | 584 if (onscreen) { |
583 if (render_surface == gfx::kNullPluginWindow) { | 585 if (render_surface == gfx::kNullPluginWindow) { |
584 LOG(ERROR) << "Invalid surface handle for onscreen context."; | 586 LOG(ERROR) << "Invalid surface handle for onscreen context."; |
585 command_buffer_.reset(); | 587 command_buffer_.reset(); |
586 } else { | 588 } else { |
587 if (!gpu_scheduler_->Initialize(render_surface, | 589 if (!gpu_scheduler_->Initialize(render_surface, |
588 gfx::Size(), | 590 gfx::Size(), |
589 ::gpu::gles2::DisallowedExtensions(), | 591 ::gpu::gles2::DisallowedExtensions(), |
590 allowed_extensions, | 592 allowed_extensions, |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 if (!context_->GetChildToParentLatch(latch_id)) { | 1066 if (!context_->GetChildToParentLatch(latch_id)) { |
1065 LOG(ERROR) << "getLatch must only be called on child context"; | 1067 LOG(ERROR) << "getLatch must only be called on child context"; |
1066 synthesizeGLError(GL_INVALID_OPERATION); | 1068 synthesizeGLError(GL_INVALID_OPERATION); |
1067 *latch_id = ::gpu::kInvalidLatchId; | 1069 *latch_id = ::gpu::kInvalidLatchId; |
1068 } | 1070 } |
1069 } | 1071 } |
1070 | 1072 |
1071 void WebGraphicsContext3DInProcessCommandBufferImpl::waitLatchCHROMIUM( | 1073 void WebGraphicsContext3DInProcessCommandBufferImpl::waitLatchCHROMIUM( |
1072 WGC3Duint latch_id) | 1074 WGC3Duint latch_id) |
1073 { | 1075 { |
1074 // TODO(gmam): See if we can comment this in. | |
1075 // ClearContext(); | |
1076 gl_->WaitLatchCHROMIUM(latch_id); | |
1077 } | 1076 } |
1078 | 1077 |
1079 void WebGraphicsContext3DInProcessCommandBufferImpl::setLatchCHROMIUM( | 1078 void WebGraphicsContext3DInProcessCommandBufferImpl::setLatchCHROMIUM( |
1080 WGC3Duint latch_id) | 1079 WGC3Duint latch_id) |
1081 { | 1080 { |
1082 // TODO(gmam): See if we can comment this in. | |
1083 // ClearContext(); | |
1084 gl_->SetLatchCHROMIUM(latch_id); | |
1085 // required to ensure set command is sent to GPU process | |
1086 gl_->Flush(); | |
1087 } | 1081 } |
1088 | 1082 |
1089 void WebGraphicsContext3DInProcessCommandBufferImpl:: | 1083 void WebGraphicsContext3DInProcessCommandBufferImpl:: |
1090 rateLimitOffscreenContextCHROMIUM() { | 1084 rateLimitOffscreenContextCHROMIUM() { |
1091 // TODO(gmam): See if we can comment this in. | 1085 // TODO(gmam): See if we can comment this in. |
1092 // ClearContext(); | 1086 // ClearContext(); |
1093 gl_->RateLimitOffscreenContextCHROMIUM(); | 1087 gl_->RateLimitOffscreenContextCHROMIUM(); |
1094 } | 1088 } |
1095 | 1089 |
1096 WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: | 1090 WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 if (context_lost_callback_) { | 1794 if (context_lost_callback_) { |
1801 context_lost_callback_->onContextLost(); | 1795 context_lost_callback_->onContextLost(); |
1802 } | 1796 } |
1803 } | 1797 } |
1804 | 1798 |
1805 } // namespace gpu | 1799 } // namespace gpu |
1806 } // namespace webkit | 1800 } // namespace webkit |
1807 | 1801 |
1808 #endif // defined(ENABLE_GPU) | 1802 #endif // defined(ENABLE_GPU) |
1809 | 1803 |
OLD | NEW |