| 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" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 mojo::ScopedSharedBufferHandle shared_state) { | 84 mojo::ScopedSharedBufferHandle shared_state) { |
| 85 if (widget_ == gfx::kNullAcceleratedWidget) | 85 if (widget_ == gfx::kNullAcceleratedWidget) |
| 86 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(size_); | 86 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(size_); |
| 87 else | 87 else |
| 88 surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); | 88 surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); |
| 89 if (!surface_.get()) | 89 if (!surface_.get()) |
| 90 return false; | 90 return false; |
| 91 | 91 |
| 92 // TODO(piman): virtual contexts, gpu preference. | 92 // TODO(piman): virtual contexts, gpu preference. |
| 93 context_ = gfx::GLContext::CreateGLContext( | 93 context_ = gfx::GLContext::CreateGLContext( |
| 94 share_group_, surface_.get(), gfx::PreferIntegratedGpu); | 94 share_group_.get(), surface_.get(), gfx::PreferIntegratedGpu); |
| 95 if (!context_.get()) | 95 if (!context_.get()) |
| 96 return false; | 96 return false; |
| 97 | 97 |
| 98 if (!context_->MakeCurrent(surface_.get())) | 98 if (!context_->MakeCurrent(surface_.get())) |
| 99 return false; | 99 return false; |
| 100 | 100 |
| 101 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but | 101 // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but |
| 102 // only needs to be per-thread. | 102 // only needs to be per-thread. |
| 103 scoped_refptr<gpu::gles2::ContextGroup> context_group = | 103 scoped_refptr<gpu::gles2::ContextGroup> context_group = |
| 104 new gpu::gles2::ContextGroup(mailbox_manager_, | 104 new gpu::gles2::ContextGroup(mailbox_manager_.get(), |
| 105 new MemoryTrackerStub, | 105 new MemoryTrackerStub, |
| 106 new gpu::gles2::ShaderTranslatorCache, | 106 new gpu::gles2::ShaderTranslatorCache, |
| 107 NULL, | 107 NULL, |
| 108 true); | 108 true); |
| 109 | 109 |
| 110 command_buffer_.reset( | 110 command_buffer_.reset( |
| 111 new gpu::CommandBufferService(context_group->transfer_buffer_manager())); | 111 new gpu::CommandBufferService(context_group->transfer_buffer_manager())); |
| 112 bool result = command_buffer_->Initialize(); | 112 bool result = command_buffer_->Initialize(); |
| 113 DCHECK(result); | 113 DCHECK(result); |
| 114 | 114 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 void CommandBufferImpl::OnParseError() { | 195 void CommandBufferImpl::OnParseError() { |
| 196 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 196 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
| 197 client()->LostContext(state.context_lost_reason); | 197 client()->LostContext(state.context_lost_reason); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void CommandBufferImpl::OnResize(gfx::Size size, float scale_factor) { | 200 void CommandBufferImpl::OnResize(gfx::Size size, float scale_factor) { |
| 201 surface_->Resize(size); | 201 surface_->Resize(size); |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace mojo | 204 } // namespace mojo |
| OLD | NEW |