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 } | |
Ken Russell (switch to Gerrit)
2011/07/12 00:22:07
This doesn't look like it's part of this CL.
apatrick_chromium
2011/07/12 01:00:42
Done.
| |
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_ = GpuScheduler::Create(command_buffer_.get(), |
585 NULL, | |
586 NULL); | |
581 | 587 |
582 if (onscreen) { | 588 if (onscreen) { |
583 if (render_surface == gfx::kNullPluginWindow) { | 589 if (render_surface == gfx::kNullPluginWindow) { |
584 LOG(ERROR) << "Invalid surface handle for onscreen context."; | 590 LOG(ERROR) << "Invalid surface handle for onscreen context."; |
585 command_buffer_.reset(); | 591 command_buffer_.reset(); |
586 } else { | 592 } else { |
587 if (!gpu_scheduler_->Initialize(render_surface, | 593 if (!gpu_scheduler_->Initialize(render_surface, |
588 gfx::Size(), | 594 gfx::Size(), |
589 ::gpu::gles2::DisallowedExtensions(), | 595 ::gpu::gles2::DisallowedExtensions(), |
590 allowed_extensions, | 596 allowed_extensions, |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1063 if (!context_->GetChildToParentLatch(latch_id)) { | 1069 if (!context_->GetChildToParentLatch(latch_id)) { |
1064 LOG(ERROR) << "getLatch must only be called on child context"; | 1070 LOG(ERROR) << "getLatch must only be called on child context"; |
1065 synthesizeGLError(GL_INVALID_OPERATION); | 1071 synthesizeGLError(GL_INVALID_OPERATION); |
1066 *latch_id = ::gpu::kInvalidLatchId; | 1072 *latch_id = ::gpu::kInvalidLatchId; |
1067 } | 1073 } |
1068 } | 1074 } |
1069 | 1075 |
1070 void WebGraphicsContext3DInProcessCommandBufferImpl::waitLatchCHROMIUM( | 1076 void WebGraphicsContext3DInProcessCommandBufferImpl::waitLatchCHROMIUM( |
1071 WGC3Duint latch_id) | 1077 WGC3Duint latch_id) |
1072 { | 1078 { |
1073 // TODO(gmam): See if we can comment this in. | |
1074 // ClearContext(); | |
1075 gl_->WaitLatchCHROMIUM(latch_id); | |
1076 } | 1079 } |
1077 | 1080 |
1078 void WebGraphicsContext3DInProcessCommandBufferImpl::setLatchCHROMIUM( | 1081 void WebGraphicsContext3DInProcessCommandBufferImpl::setLatchCHROMIUM( |
1079 WGC3Duint latch_id) | 1082 WGC3Duint latch_id) |
1080 { | 1083 { |
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 } | 1084 } |
1087 | 1085 |
1088 void WebGraphicsContext3DInProcessCommandBufferImpl:: | 1086 void WebGraphicsContext3DInProcessCommandBufferImpl:: |
1089 rateLimitOffscreenContextCHROMIUM() { | 1087 rateLimitOffscreenContextCHROMIUM() { |
1090 // TODO(gmam): See if we can comment this in. | 1088 // TODO(gmam): See if we can comment this in. |
1091 // ClearContext(); | 1089 // ClearContext(); |
1092 gl_->RateLimitOffscreenContextCHROMIUM(); | 1090 gl_->RateLimitOffscreenContextCHROMIUM(); |
1093 } | 1091 } |
1094 | 1092 |
1095 WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: | 1093 WebKit::WebString WebGraphicsContext3DInProcessCommandBufferImpl:: |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1792 if (context_lost_callback_) { | 1790 if (context_lost_callback_) { |
1793 context_lost_callback_->onContextLost(); | 1791 context_lost_callback_->onContextLost(); |
1794 } | 1792 } |
1795 } | 1793 } |
1796 | 1794 |
1797 } // namespace gpu | 1795 } // namespace gpu |
1798 } // namespace webkit | 1796 } // namespace webkit |
1799 | 1797 |
1800 #endif // defined(ENABLE_GPU) | 1798 #endif // defined(ENABLE_GPU) |
1801 | 1799 |
OLD | NEW |