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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace mus { | 21 namespace mus { |
22 | 22 |
23 namespace { | 23 namespace { |
24 const size_t kDefaultCommandBufferSize = 1024 * 1024; | 24 const size_t kDefaultCommandBufferSize = 1024 * 1024; |
25 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; | 25 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024; |
26 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; | 26 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024; |
27 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; | 27 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; |
28 } | 28 } |
29 | 29 |
30 SurfacesContextProvider::SurfacesContextProvider( | 30 SurfacesContextProvider::SurfacesContextProvider( |
31 SurfacesContextProviderDelegate* delegate, | |
32 gfx::AcceleratedWidget widget, | 31 gfx::AcceleratedWidget widget, |
33 const scoped_refptr<GpuState>& state) | 32 const scoped_refptr<GpuState>& state) |
34 : delegate_(delegate), widget_(widget), command_buffer_local_(nullptr) { | 33 : delegate_(nullptr), widget_(widget), command_buffer_local_(nullptr) { |
35 capabilities_.gpu.image = true; | 34 capabilities_.gpu.image = true; |
36 command_buffer_local_ = new CommandBufferLocal(this, widget_, state); | 35 command_buffer_local_ = new CommandBufferLocal(this, widget_, state); |
37 } | 36 } |
38 | 37 |
| 38 void SurfacesContextProvider::SetDelegate( |
| 39 SurfacesContextProviderDelegate* delegate) { |
| 40 DCHECK(!delegate_); |
| 41 delegate_ = delegate; |
| 42 } |
| 43 |
39 // This is called when we have an accelerated widget. | 44 // This is called when we have an accelerated widget. |
40 bool SurfacesContextProvider::BindToCurrentThread() { | 45 bool SurfacesContextProvider::BindToCurrentThread() { |
41 // SurfacesContextProvider should always live on the same thread as the | 46 // SurfacesContextProvider should always live on the same thread as the |
42 // Window Manager. | 47 // Window Manager. |
43 DCHECK(CalledOnValidThread()); | 48 DCHECK(CalledOnValidThread()); |
44 if (!command_buffer_local_->Initialize()) | 49 if (!command_buffer_local_->Initialize()) |
45 return false; | 50 return false; |
46 gles2_helper_.reset( | 51 gles2_helper_.reset( |
47 new gpu::gles2::GLES2CmdHelper(command_buffer_local_)); | 52 new gpu::gles2::GLES2CmdHelper(command_buffer_local_)); |
48 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize)) | 53 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize)) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 int64_t interval) { | 113 int64_t interval) { |
109 if (delegate_) | 114 if (delegate_) |
110 delegate_->OnVSyncParametersUpdated(timebase, interval); | 115 delegate_->OnVSyncParametersUpdated(timebase, interval); |
111 } | 116 } |
112 | 117 |
113 void SurfacesContextProvider::DidLoseContext() { | 118 void SurfacesContextProvider::DidLoseContext() { |
114 lost_context_callback_.Run(); | 119 lost_context_callback_.Run(); |
115 } | 120 } |
116 | 121 |
117 } // namespace mus | 122 } // namespace mus |
OLD | NEW |