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

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

Issue 1344573002: Mandoline: Rename components/view_manager to components/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 3 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/view_manager/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/view_manager/gles2/command_buffer_driver.h" 10 #include "components/mus/gles2/command_buffer_driver.h"
11 #include "components/view_manager/gles2/command_buffer_impl.h" 11 #include "components/mus/gles2/command_buffer_impl.h"
12 #include "components/view_manager/gles2/command_buffer_local.h" 12 #include "components/mus/gles2/command_buffer_local.h"
13 #include "components/view_manager/gles2/gpu_state.h" 13 #include "components/mus/gles2/gpu_state.h"
14 #include "components/view_manager/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 surfaces {
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
27 } 26 }
28 27
29 SurfacesContextProvider::SurfacesContextProvider( 28 SurfacesContextProvider::SurfacesContextProvider(
30 SurfacesContextProviderDelegate* delegate, 29 SurfacesContextProviderDelegate* delegate,
31 gfx::AcceleratedWidget widget, 30 gfx::AcceleratedWidget widget,
32 const scoped_refptr<gles2::GpuState>& state) 31 const scoped_refptr<gles2::GpuState>& state)
33 : delegate_(delegate), 32 : delegate_(delegate), state_(state), widget_(widget) {
34 state_(state),
35 widget_(widget) {
36 capabilities_.gpu.image = true; 33 capabilities_.gpu.image = true;
37 command_buffer_local_.reset( 34 command_buffer_local_.reset(
38 new gles2::CommandBufferLocal(this, widget_, state_)); 35 new gles2::CommandBufferLocal(this, widget_, state_));
39 } 36 }
40 37
41 // This is called when we have an accelerated widget. 38 // This is called when we have an accelerated widget.
42 bool SurfacesContextProvider::BindToCurrentThread() { 39 bool SurfacesContextProvider::BindToCurrentThread() {
43 // SurfacesContextProvider should always live on the same thread as the 40 // SurfacesContextProvider should always live on the same thread as the
44 // View Manager. 41 // View Manager.
45 DCHECK(CalledOnValidThread()); 42 DCHECK(CalledOnValidThread());
46 if (!command_buffer_local_->Initialize()) 43 if (!command_buffer_local_->Initialize())
47 return false; 44 return false;
48 gles2_helper_.reset( 45 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(
49 new gpu::gles2::GLES2CmdHelper( 46 command_buffer_local_->GetCommandBuffer()));
50 command_buffer_local_->GetCommandBuffer()));
51 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize)) 47 if (!gles2_helper_->Initialize(kDefaultCommandBufferSize))
52 return false; 48 return false;
53 gles2_helper_->SetAutomaticFlushes(false); 49 gles2_helper_->SetAutomaticFlushes(false);
54 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); 50 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get()));
55 gpu::Capabilities capabilities = command_buffer_local_->GetCapabilities(); 51 gpu::Capabilities capabilities = command_buffer_local_->GetCapabilities();
56 bool bind_generates_resource = 52 bool bind_generates_resource =
57 !!capabilities.bind_generates_resource_chromium; 53 !!capabilities.bind_generates_resource_chromium;
58 // TODO(piman): Some contexts (such as compositor) want this to be true, so 54 // TODO(piman): Some contexts (such as compositor) want this to be true, so
59 // this needs to be a public parameter. 55 // this needs to be a public parameter.
60 bool lose_context_when_out_of_memory = false; 56 bool lose_context_when_out_of_memory = false;
61 bool support_client_side_arrays = false; 57 bool support_client_side_arrays = false;
62 implementation_.reset( 58 implementation_.reset(new gpu::gles2::GLES2Implementation(
63 new gpu::gles2::GLES2Implementation(gles2_helper_.get(), 59 gles2_helper_.get(), NULL, transfer_buffer_.get(),
64 NULL, 60 bind_generates_resource, lose_context_when_out_of_memory,
65 transfer_buffer_.get(), 61 support_client_side_arrays, command_buffer_local_.get()));
66 bind_generates_resource, 62 return implementation_->Initialize(
67 lose_context_when_out_of_memory, 63 kDefaultStartTransferBufferSize, kDefaultMinTransferBufferSize,
68 support_client_side_arrays, 64 kDefaultMaxTransferBufferSize, gpu::gles2::GLES2Implementation::kNoLimit);
69 command_buffer_local_.get()));
70 return implementation_->Initialize(kDefaultStartTransferBufferSize,
71 kDefaultMinTransferBufferSize,
72 kDefaultMaxTransferBufferSize,
73 gpu::gles2::GLES2Implementation::kNoLimit);
74 } 65 }
75 66
76 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() { 67 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() {
77 return implementation_.get(); 68 return implementation_.get();
78 } 69 }
79 70
80 gpu::ContextSupport* SurfacesContextProvider::ContextSupport() { 71 gpu::ContextSupport* SurfacesContextProvider::ContextSupport() {
81 return implementation_.get(); 72 return implementation_.get();
82 } 73 }
83 74
84 class GrContext* SurfacesContextProvider::GrContext() { 75 class GrContext* SurfacesContextProvider::GrContext() {
85 return NULL; 76 return NULL;
86 } 77 }
87 78
88 void SurfacesContextProvider::InvalidateGrContext(uint32_t state) { 79 void SurfacesContextProvider::InvalidateGrContext(uint32_t state) {}
89 }
90 80
91 cc::ContextProvider::Capabilities 81 cc::ContextProvider::Capabilities
92 SurfacesContextProvider::ContextCapabilities() { 82 SurfacesContextProvider::ContextCapabilities() {
93 return capabilities_; 83 return capabilities_;
94 } 84 }
95 85
96 void SurfacesContextProvider::SetupLock() { 86 void SurfacesContextProvider::SetupLock() {}
97 }
98 87
99 base::Lock* SurfacesContextProvider::GetLock() { 88 base::Lock* SurfacesContextProvider::GetLock() {
100 return &context_lock_; 89 return &context_lock_;
101 } 90 }
102 91
103 bool SurfacesContextProvider::DestroyedOnMainThread() { 92 bool SurfacesContextProvider::DestroyedOnMainThread() {
104 return !command_buffer_local_; 93 return !command_buffer_local_;
105 } 94 }
106 95
107 void SurfacesContextProvider::SetLostContextCallback( 96 void SurfacesContextProvider::SetLostContextCallback(
(...skipping 13 matching lines...) Expand all
121 int64_t interval) { 110 int64_t interval) {
122 if (delegate_) 111 if (delegate_)
123 delegate_->OnVSyncParametersUpdated(timebase, interval); 112 delegate_->OnVSyncParametersUpdated(timebase, interval);
124 } 113 }
125 114
126 void SurfacesContextProvider::DidLoseContext() { 115 void SurfacesContextProvider::DidLoseContext() {
127 lost_context_callback_.Run(); 116 lost_context_callback_.Run();
128 } 117 }
129 118
130 } // namespace surfaces 119 } // namespace surfaces
OLDNEW
« no previous file with comments | « components/mus/surfaces/surfaces_context_provider.h ('k') | components/mus/surfaces/surfaces_context_provider_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698