Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: components/mus/surfaces/surfaces_context_provider.cc

Issue 1900993002: Move SharedMemoryLimits out of WebGraphicsContext3DCommandBufferImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@limits
Patch Set: move-limits: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "components/mus/gles2/command_buffer_driver.h" 12 #include "components/mus/gles2/command_buffer_driver.h"
13 #include "components/mus/gles2/command_buffer_impl.h" 13 #include "components/mus/gles2/command_buffer_impl.h"
14 #include "components/mus/gles2/command_buffer_local.h" 14 #include "components/mus/gles2/command_buffer_local.h"
15 #include "components/mus/gles2/gpu_state.h" 15 #include "components/mus/gles2/gpu_state.h"
16 #include "components/mus/surfaces/surfaces_context_provider_delegate.h" 16 #include "components/mus/surfaces/surfaces_context_provider_delegate.h"
17 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 17 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
18 #include "gpu/command_buffer/client/gles2_implementation.h" 18 #include "gpu/command_buffer/client/gles2_implementation.h"
19 #include "gpu/command_buffer/client/shared_memory_limits.h"
19 #include "gpu/command_buffer/client/transfer_buffer.h" 20 #include "gpu/command_buffer/client/transfer_buffer.h"
20 21
21 namespace mus { 22 namespace mus {
22 23
23 namespace {
24 const size_t kDefaultCommandBufferSize = 1024 * 1024;
25 const size_t kDefaultStartTransferBufferSize = 1 * 1024 * 1024;
26 const size_t kDefaultMinTransferBufferSize = 1 * 256 * 1024;
27 const size_t kDefaultMaxTransferBufferSize = 16 * 1024 * 1024;
28 }
29
30 SurfacesContextProvider::SurfacesContextProvider( 24 SurfacesContextProvider::SurfacesContextProvider(
31 gfx::AcceleratedWidget widget, 25 gfx::AcceleratedWidget widget,
32 const scoped_refptr<GpuState>& state) 26 const scoped_refptr<GpuState>& state)
33 : delegate_(nullptr), widget_(widget), command_buffer_local_(nullptr) { 27 : delegate_(nullptr), widget_(widget), command_buffer_local_(nullptr) {
34 capabilities_.gpu.image = true; 28 // TODO(danakj): Wat. We override this in BindToCurrentThread.
danakj 2016/04/19 02:02:11 I'm going to try just removing this on TOT and see
danakj 2016/04/20 00:01:53 This is gone now.
29 capabilities_.image = true;
35 command_buffer_local_ = new CommandBufferLocal(this, widget_, state); 30 command_buffer_local_ = new CommandBufferLocal(this, widget_, state);
36 } 31 }
37 32
38 void SurfacesContextProvider::SetDelegate( 33 void SurfacesContextProvider::SetDelegate(
39 SurfacesContextProviderDelegate* delegate) { 34 SurfacesContextProviderDelegate* delegate) {
40 DCHECK(!delegate_); 35 DCHECK(!delegate_);
41 delegate_ = delegate; 36 delegate_ = delegate;
42 } 37 }
43 38
44 // This routine needs to be safe to call more than once. 39 // This routine needs to be safe to call more than once.
45 // This is called when we have an accelerated widget. 40 // This is called when we have an accelerated widget.
46 bool SurfacesContextProvider::BindToCurrentThread() { 41 bool SurfacesContextProvider::BindToCurrentThread() {
47 if (implementation_) 42 if (implementation_)
48 return true; 43 return true;
49 44
50 // SurfacesContextProvider should always live on the same thread as the 45 // SurfacesContextProvider should always live on the same thread as the
51 // Window Manager. 46 // Window Manager.
52 DCHECK(CalledOnValidThread()); 47 DCHECK(CalledOnValidThread());
53 if (!command_buffer_local_->Initialize()) 48 if (!command_buffer_local_->Initialize())
54 return false; 49 return false;
50
51 constexpr gpu::SharedMemoryLimits default_limits;
55 gles2_helper_.reset( 52 gles2_helper_.reset(
56 new gpu::gles2::GLES2CmdHelper(command_buffer_local_)); 53 new gpu::gles2::GLES2CmdHelper(command_buffer_local_));
57 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize)) 54 if (!gles2_helper_->Initialize(default_limits.command_buffer_size))
58 return false; 55 return false;
59 gles2_helper_->SetAutomaticFlushes(false); 56 gles2_helper_->SetAutomaticFlushes(false);
60 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); 57 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get()));
61 capabilities_.gpu = command_buffer_local_->GetCapabilities(); 58 capabilities_ = command_buffer_local_->GetCapabilities();
62 bool bind_generates_resource = 59 bool bind_generates_resource =
63 !!capabilities_.gpu.bind_generates_resource_chromium; 60 !!capabilities_.bind_generates_resource_chromium;
64 // TODO(piman): Some contexts (such as compositor) want this to be true, so 61 // TODO(piman): Some contexts (such as compositor) want this to be true, so
65 // this needs to be a public parameter. 62 // this needs to be a public parameter.
66 bool lose_context_when_out_of_memory = false; 63 bool lose_context_when_out_of_memory = false;
67 bool support_client_side_arrays = false; 64 bool support_client_side_arrays = false;
68 implementation_.reset(new gpu::gles2::GLES2Implementation( 65 implementation_.reset(new gpu::gles2::GLES2Implementation(
69 gles2_helper_.get(), NULL, transfer_buffer_.get(), 66 gles2_helper_.get(), NULL, transfer_buffer_.get(),
70 bind_generates_resource, lose_context_when_out_of_memory, 67 bind_generates_resource, lose_context_when_out_of_memory,
71 support_client_side_arrays, command_buffer_local_)); 68 support_client_side_arrays, command_buffer_local_));
72 return implementation_->Initialize( 69 return implementation_->Initialize(
73 kDefaultStartTransferBufferSize, kDefaultMinTransferBufferSize, 70 default_limits.start_transfer_buffer_size,
74 kDefaultMaxTransferBufferSize, gpu::gles2::GLES2Implementation::kNoLimit); 71 default_limits.min_transfer_buffer_size,
72 default_limits.max_transfer_buffer_size,
73 default_limits.mapped_memory_reclaim_limit);
75 } 74 }
76 75
77 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() { 76 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() {
78 DCHECK(implementation_); 77 DCHECK(implementation_);
79 return implementation_.get(); 78 return implementation_.get();
80 } 79 }
81 80
82 gpu::ContextSupport* SurfacesContextProvider::ContextSupport() { 81 gpu::ContextSupport* SurfacesContextProvider::ContextSupport() {
83 return implementation_.get(); 82 return implementation_.get();
84 } 83 }
85 84
86 class GrContext* SurfacesContextProvider::GrContext() { 85 class GrContext* SurfacesContextProvider::GrContext() {
87 return NULL; 86 return NULL;
88 } 87 }
89 88
90 void SurfacesContextProvider::InvalidateGrContext(uint32_t state) {} 89 void SurfacesContextProvider::InvalidateGrContext(uint32_t state) {}
91 90
92 cc::ContextProvider::Capabilities 91 gpu::Capabilities SurfacesContextProvider::ContextCapabilities() {
93 SurfacesContextProvider::ContextCapabilities() {
94 return capabilities_; 92 return capabilities_;
95 } 93 }
96 94
97 void SurfacesContextProvider::SetupLock() {} 95 void SurfacesContextProvider::SetupLock() {}
98 96
99 base::Lock* SurfacesContextProvider::GetLock() { 97 base::Lock* SurfacesContextProvider::GetLock() {
100 return &context_lock_; 98 return &context_lock_;
101 } 99 }
102 100
103 void SurfacesContextProvider::SetLostContextCallback( 101 void SurfacesContextProvider::SetLostContextCallback(
(...skipping 21 matching lines...) Expand all
125 swap_buffers_completion_callback_.Run(result); 123 swap_buffers_completion_callback_.Run(result);
126 } 124 }
127 } 125 }
128 126
129 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( 127 void SurfacesContextProvider::SetSwapBuffersCompletionCallback(
130 gfx::GLSurface::SwapCompletionCallback callback) { 128 gfx::GLSurface::SwapCompletionCallback callback) {
131 swap_buffers_completion_callback_ = callback; 129 swap_buffers_completion_callback_ = callback;
132 } 130 }
133 131
134 } // namespace mus 132 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698