| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/services/gles2/command_buffer_impl.h" | 5 #include "mojo/services/gles2/command_buffer_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 | 9 |
| 10 #include "gpu/command_buffer/common/constants.h" | 10 #include "gpu/command_buffer/common/constants.h" |
| 11 #include "gpu/command_buffer/service/command_buffer_service.h" | 11 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 12 #include "gpu/command_buffer/service/context_group.h" | 12 #include "gpu/command_buffer/service/context_group.h" |
| 13 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 13 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 14 #include "gpu/command_buffer/service/gpu_control_service.h" | |
| 15 #include "gpu/command_buffer/service/gpu_scheduler.h" | 14 #include "gpu/command_buffer/service/gpu_scheduler.h" |
| 16 #include "gpu/command_buffer/service/image_manager.h" | 15 #include "gpu/command_buffer/service/image_manager.h" |
| 17 #include "gpu/command_buffer/service/mailbox_manager.h" | 16 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 18 #include "gpu/command_buffer/service/memory_tracking.h" | 17 #include "gpu/command_buffer/service/memory_tracking.h" |
| 19 #include "mojo/services/gles2/command_buffer_type_conversions.h" | 18 #include "mojo/services/gles2/command_buffer_type_conversions.h" |
| 20 #include "mojo/services/gles2/mojo_buffer_backing.h" | 19 #include "mojo/services/gles2/mojo_buffer_backing.h" |
| 21 #include "ui/gl/gl_context.h" | 20 #include "ui/gl/gl_context.h" |
| 22 #include "ui/gl/gl_surface.h" | 21 #include "ui/gl/gl_surface.h" |
| 23 | 22 |
| 24 namespace mojo { | 23 namespace mojo { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (!context.get()) | 82 if (!context.get()) |
| 84 return false; | 83 return false; |
| 85 | 84 |
| 86 if (!context->MakeCurrent(surface_.get())) | 85 if (!context->MakeCurrent(surface_.get())) |
| 87 return false; | 86 return false; |
| 88 | 87 |
| 89 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but | 88 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but |
| 90 // only needs to be per-thread. | 89 // only needs to be per-thread. |
| 91 scoped_refptr<gpu::gles2::ContextGroup> context_group = | 90 scoped_refptr<gpu::gles2::ContextGroup> context_group = |
| 92 new gpu::gles2::ContextGroup(NULL, | 91 new gpu::gles2::ContextGroup(NULL, |
| 93 NULL, | |
| 94 new MemoryTrackerStub, | 92 new MemoryTrackerStub, |
| 95 new gpu::gles2::ShaderTranslatorCache, | 93 new gpu::gles2::ShaderTranslatorCache, |
| 96 NULL, | 94 NULL, |
| 97 true); | 95 true); |
| 98 | 96 |
| 99 command_buffer_.reset( | 97 command_buffer_.reset( |
| 100 new gpu::CommandBufferService(context_group->transfer_buffer_manager())); | 98 new gpu::CommandBufferService(context_group->transfer_buffer_manager())); |
| 101 bool result = command_buffer_->Initialize(); | 99 bool result = command_buffer_->Initialize(); |
| 102 DCHECK(result); | 100 DCHECK(result); |
| 103 | 101 |
| 104 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get())); | 102 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get())); |
| 105 scheduler_.reset(new gpu::GpuScheduler( | 103 scheduler_.reset(new gpu::GpuScheduler( |
| 106 command_buffer_.get(), decoder_.get(), decoder_.get())); | 104 command_buffer_.get(), decoder_.get(), decoder_.get())); |
| 107 decoder_->set_engine(scheduler_.get()); | 105 decoder_->set_engine(scheduler_.get()); |
| 108 decoder_->SetResizeCallback( | 106 decoder_->SetResizeCallback( |
| 109 base::Bind(&CommandBufferImpl::OnResize, base::Unretained(this))); | 107 base::Bind(&CommandBufferImpl::OnResize, base::Unretained(this))); |
| 110 | 108 |
| 111 gpu::gles2::DisallowedFeatures disallowed_features; | 109 gpu::gles2::DisallowedFeatures disallowed_features; |
| 112 | 110 |
| 113 // TODO(piman): attributes. | 111 // TODO(piman): attributes. |
| 114 std::vector<int32> attrib_vector; | 112 std::vector<int32> attrib_vector; |
| 115 if (!decoder_->Initialize(surface_, | 113 if (!decoder_->Initialize(surface_, |
| 116 context, | 114 context, |
| 117 false /* offscreen */, | 115 false /* offscreen */, |
| 118 size_, | 116 size_, |
| 119 disallowed_features, | 117 disallowed_features, |
| 120 attrib_vector)) | 118 attrib_vector)) |
| 121 return false; | 119 return false; |
| 122 | 120 |
| 123 gpu_control_.reset( | |
| 124 new gpu::GpuControlService(context_group->image_manager(), NULL)); | |
| 125 | |
| 126 command_buffer_->SetPutOffsetChangeCallback(base::Bind( | 121 command_buffer_->SetPutOffsetChangeCallback(base::Bind( |
| 127 &gpu::GpuScheduler::PutChanged, base::Unretained(scheduler_.get()))); | 122 &gpu::GpuScheduler::PutChanged, base::Unretained(scheduler_.get()))); |
| 128 command_buffer_->SetGetBufferChangeCallback(base::Bind( | 123 command_buffer_->SetGetBufferChangeCallback(base::Bind( |
| 129 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get()))); | 124 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get()))); |
| 130 command_buffer_->SetParseErrorCallback( | 125 command_buffer_->SetParseErrorCallback( |
| 131 base::Bind(&CommandBufferImpl::OnParseError, base::Unretained(this))); | 126 base::Bind(&CommandBufferImpl::OnParseError, base::Unretained(this))); |
| 132 | 127 |
| 133 // TODO(piman): other callbacks | 128 // TODO(piman): other callbacks |
| 134 | 129 |
| 135 const size_t kSize = sizeof(gpu::CommandBufferSharedState); | 130 const size_t kSize = sizeof(gpu::CommandBufferSharedState); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 189 } |
| 195 | 190 |
| 196 void CommandBufferImpl::DrawAnimationFrame() { client()->DrawAnimationFrame(); } | 191 void CommandBufferImpl::DrawAnimationFrame() { client()->DrawAnimationFrame(); } |
| 197 | 192 |
| 198 void CommandBufferImpl::OnResize(gfx::Size size, float scale_factor) { | 193 void CommandBufferImpl::OnResize(gfx::Size size, float scale_factor) { |
| 199 surface_->Resize(size); | 194 surface_->Resize(size); |
| 200 } | 195 } |
| 201 | 196 |
| 202 } // namespace services | 197 } // namespace services |
| 203 } // namespace mojo | 198 } // namespace mojo |
| OLD | NEW |