| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 if (!context.get()) | 83 if (!context.get()) |
| 85 return false; | 84 return false; |
| 86 | 85 |
| 87 if (!context->MakeCurrent(surface.get())) | 86 if (!context->MakeCurrent(surface.get())) |
| 88 return false; | 87 return false; |
| 89 | 88 |
| 90 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but | 89 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but |
| 91 // only needs to be per-thread. | 90 // only needs to be per-thread. |
| 92 scoped_refptr<gpu::gles2::ContextGroup> context_group = | 91 scoped_refptr<gpu::gles2::ContextGroup> context_group = |
| 93 new gpu::gles2::ContextGroup(NULL, | 92 new gpu::gles2::ContextGroup(NULL, |
| 94 NULL, | |
| 95 new MemoryTrackerStub, | 93 new MemoryTrackerStub, |
| 96 new gpu::gles2::ShaderTranslatorCache, | 94 new gpu::gles2::ShaderTranslatorCache, |
| 97 NULL, | 95 NULL, |
| 98 true); | 96 true); |
| 99 | 97 |
| 100 command_buffer_.reset( | 98 command_buffer_.reset( |
| 101 new gpu::CommandBufferService(context_group->transfer_buffer_manager())); | 99 new gpu::CommandBufferService(context_group->transfer_buffer_manager())); |
| 102 bool result = command_buffer_->Initialize(); | 100 bool result = command_buffer_->Initialize(); |
| 103 DCHECK(result); | 101 DCHECK(result); |
| 104 | 102 |
| 105 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get())); | 103 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get())); |
| 106 scheduler_.reset(new gpu::GpuScheduler( | 104 scheduler_.reset(new gpu::GpuScheduler( |
| 107 command_buffer_.get(), decoder_.get(), decoder_.get())); | 105 command_buffer_.get(), decoder_.get(), decoder_.get())); |
| 108 decoder_->set_engine(scheduler_.get()); | 106 decoder_->set_engine(scheduler_.get()); |
| 109 | 107 |
| 110 gpu::gles2::DisallowedFeatures disallowed_features; | 108 gpu::gles2::DisallowedFeatures disallowed_features; |
| 111 | 109 |
| 112 // TODO(piman): attributes. | 110 // TODO(piman): attributes. |
| 113 std::vector<int32> attrib_vector; | 111 std::vector<int32> attrib_vector; |
| 114 if (!decoder_->Initialize(surface, | 112 if (!decoder_->Initialize(surface, |
| 115 context, | 113 context, |
| 116 false /* offscreen */, | 114 false /* offscreen */, |
| 117 size_, | 115 size_, |
| 118 disallowed_features, | 116 disallowed_features, |
| 119 attrib_vector)) | 117 attrib_vector)) |
| 120 return false; | 118 return false; |
| 121 | 119 |
| 122 gpu_control_.reset( | |
| 123 new gpu::GpuControlService(context_group->image_manager(), NULL)); | |
| 124 | |
| 125 command_buffer_->SetPutOffsetChangeCallback(base::Bind( | 120 command_buffer_->SetPutOffsetChangeCallback(base::Bind( |
| 126 &gpu::GpuScheduler::PutChanged, base::Unretained(scheduler_.get()))); | 121 &gpu::GpuScheduler::PutChanged, base::Unretained(scheduler_.get()))); |
| 127 command_buffer_->SetGetBufferChangeCallback(base::Bind( | 122 command_buffer_->SetGetBufferChangeCallback(base::Bind( |
| 128 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get()))); | 123 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get()))); |
| 129 command_buffer_->SetParseErrorCallback( | 124 command_buffer_->SetParseErrorCallback( |
| 130 base::Bind(&CommandBufferImpl::OnParseError, base::Unretained(this))); | 125 base::Bind(&CommandBufferImpl::OnParseError, base::Unretained(this))); |
| 131 | 126 |
| 132 // TODO(piman): other callbacks | 127 // TODO(piman): other callbacks |
| 133 | 128 |
| 134 const size_t kSize = sizeof(gpu::CommandBufferSharedState); | 129 const size_t kSize = sizeof(gpu::CommandBufferSharedState); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 184 |
| 190 void CommandBufferImpl::OnParseError() { | 185 void CommandBufferImpl::OnParseError() { |
| 191 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 186 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
| 192 client()->LostContext(state.context_lost_reason); | 187 client()->LostContext(state.context_lost_reason); |
| 193 } | 188 } |
| 194 | 189 |
| 195 void CommandBufferImpl::DrawAnimationFrame() { client()->DrawAnimationFrame(); } | 190 void CommandBufferImpl::DrawAnimationFrame() { client()->DrawAnimationFrame(); } |
| 196 | 191 |
| 197 } // namespace services | 192 } // namespace services |
| 198 } // namespace mojo | 193 } // namespace mojo |
| OLD | NEW |