OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/mus/surfaces/surfaces_context_provider.h" | 5 #include "components/mus/surfaces/surfaces_context_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "components/mus/gles2/command_buffer_driver.h" | 10 #include "components/mus/gles2/command_buffer_driver.h" |
11 #include "components/mus/gles2/command_buffer_impl.h" | 11 #include "components/mus/gles2/command_buffer_impl.h" |
12 #include "components/mus/gles2/command_buffer_local.h" | 12 #include "components/mus/gles2/command_buffer_local.h" |
13 #include "components/mus/gles2/gpu_state.h" | 13 #include "components/mus/gles2/gpu_state.h" |
14 #include "components/mus/surfaces/surfaces_context_provider_delegate.h" | 14 #include "components/mus/surfaces/surfaces_context_provider_delegate.h" |
15 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 15 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
16 #include "gpu/command_buffer/client/gles2_implementation.h" | 16 #include "gpu/command_buffer/client/gles2_implementation.h" |
17 #include "gpu/command_buffer/client/transfer_buffer.h" | 17 #include "gpu/command_buffer/client/transfer_buffer.h" |
18 | 18 |
19 namespace surfaces { | 19 namespace mus { |
20 | 20 |
21 namespace { | 21 namespace { |
22 const size_t kDefaultCommandBufferSize = 1024 * 1024; | 22 const size_t kDefaultCommandBufferSize = 1024 * 1024; |
23 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; | 23 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; |
24 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; | 24 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; |
25 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; | 25 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; |
26 } | 26 } |
27 | 27 |
28 SurfacesContextProvider::SurfacesContextProvider( | 28 SurfacesContextProvider::SurfacesContextProvider( |
29 SurfacesContextProviderDelegate* delegate, | 29 SurfacesContextProviderDelegate* delegate, |
30 gfx::AcceleratedWidget widget, | 30 gfx::AcceleratedWidget widget, |
31 const scoped_refptr<gles2::GpuState>& state) | 31 const scoped_refptr<GpuState>& state) |
32 : delegate_(delegate), widget_(widget) { | 32 : delegate_(delegate), widget_(widget) { |
33 capabilities_.gpu.image = true; | 33 capabilities_.gpu.image = true; |
34 command_buffer_local_.reset( | 34 command_buffer_local_.reset(new CommandBufferLocal(this, widget_, state)); |
35 new gles2::CommandBufferLocal(this, widget_, state)); | |
36 } | 35 } |
37 | 36 |
38 // This is called when we have an accelerated widget. | 37 // This is called when we have an accelerated widget. |
39 bool SurfacesContextProvider::BindToCurrentThread() { | 38 bool SurfacesContextProvider::BindToCurrentThread() { |
40 // SurfacesContextProvider should always live on the same thread as the | 39 // SurfacesContextProvider should always live on the same thread as the |
41 // View Manager. | 40 // View Manager. |
42 DCHECK(CalledOnValidThread()); | 41 DCHECK(CalledOnValidThread()); |
43 if (!command_buffer_local_->Initialize()) | 42 if (!command_buffer_local_->Initialize()) |
44 return false; | 43 return false; |
45 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper( | 44 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper( |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 void SurfacesContextProvider::UpdateVSyncParameters(int64_t timebase, | 108 void SurfacesContextProvider::UpdateVSyncParameters(int64_t timebase, |
110 int64_t interval) { | 109 int64_t interval) { |
111 if (delegate_) | 110 if (delegate_) |
112 delegate_->OnVSyncParametersUpdated(timebase, interval); | 111 delegate_->OnVSyncParametersUpdated(timebase, interval); |
113 } | 112 } |
114 | 113 |
115 void SurfacesContextProvider::DidLoseContext() { | 114 void SurfacesContextProvider::DidLoseContext() { |
116 lost_context_callback_.Run(); | 115 lost_context_callback_.Run(); |
117 } | 116 } |
118 | 117 |
119 } // namespace surfaces | 118 } // namespace mus |
OLD | NEW |