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

Side by Side Diff: components/mus/gles2/command_buffer_local.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/gles2/command_buffer_local.h" 5 #include "components/mus/gles2/command_buffer_local.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "components/view_manager/gles2/command_buffer_local_client.h" 8 #include "components/mus/gles2/command_buffer_local_client.h"
9 #include "components/view_manager/gles2/gpu_memory_tracker.h" 9 #include "components/mus/gles2/gpu_memory_tracker.h"
10 #include "components/view_manager/gles2/mojo_gpu_memory_buffer.h" 10 #include "components/mus/gles2/mojo_gpu_memory_buffer.h"
11 #include "gpu/command_buffer/service/command_buffer_service.h" 11 #include "gpu/command_buffer/service/command_buffer_service.h"
12 #include "gpu/command_buffer/service/context_group.h" 12 #include "gpu/command_buffer/service/context_group.h"
13 #include "gpu/command_buffer/service/gpu_scheduler.h" 13 #include "gpu/command_buffer/service/gpu_scheduler.h"
14 #include "gpu/command_buffer/service/image_factory.h" 14 #include "gpu/command_buffer/service/image_factory.h"
15 #include "gpu/command_buffer/service/image_manager.h" 15 #include "gpu/command_buffer/service/image_manager.h"
16 #include "gpu/command_buffer/service/memory_tracking.h" 16 #include "gpu/command_buffer/service/memory_tracking.h"
17 #include "gpu/command_buffer/service/shader_translator_cache.h" 17 #include "gpu/command_buffer/service/shader_translator_cache.h"
18 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 18 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
19 #include "gpu/command_buffer/service/valuebuffer_manager.h" 19 #include "gpu/command_buffer/service/valuebuffer_manager.h"
20 #include "ui/gfx/vsync_provider.h" 20 #include "ui/gfx/vsync_provider.h"
21 #include "ui/gl/gl_context.h" 21 #include "ui/gl/gl_context.h"
22 #include "ui/gl/gl_image_memory.h" 22 #include "ui/gl/gl_image_memory.h"
23 #include "ui/gl/gl_surface.h" 23 #include "ui/gl/gl_surface.h"
24 24
25 namespace gles2 { 25 namespace gles2 {
26 26
27 const unsigned int GL_MAP_CHROMIUM = 0x78F1; 27 const unsigned int GL_MAP_CHROMIUM = 0x78F1;
28 28
29 CommandBufferLocal::CommandBufferLocal( 29 CommandBufferLocal::CommandBufferLocal(
30 CommandBufferLocalClient* client, 30 CommandBufferLocalClient* client,
31 gfx::AcceleratedWidget widget, 31 gfx::AcceleratedWidget widget,
32 const scoped_refptr<gles2::GpuState>& gpu_state) 32 const scoped_refptr<gles2::GpuState>& gpu_state)
33 : widget_(widget), 33 : widget_(widget),
34 gpu_state_(gpu_state), 34 gpu_state_(gpu_state),
35 client_(client), 35 client_(client),
36 weak_factory_(this) { 36 weak_factory_(this) {}
37 }
38 37
39 CommandBufferLocal::~CommandBufferLocal() { 38 CommandBufferLocal::~CommandBufferLocal() {
40 command_buffer_.reset(); 39 command_buffer_.reset();
41 if (decoder_.get()) { 40 if (decoder_.get()) {
42 bool have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); 41 bool have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get());
43 decoder_->Destroy(have_context); 42 decoder_->Destroy(have_context);
44 decoder_.reset(); 43 decoder_.reset();
45 } 44 }
46 } 45 }
47 46
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 new gpu::CommandBufferService(context_group->transfer_buffer_manager())); 84 new gpu::CommandBufferService(context_group->transfer_buffer_manager()));
86 bool result = command_buffer_->Initialize(); 85 bool result = command_buffer_->Initialize();
87 DCHECK(result); 86 DCHECK(result);
88 87
89 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get())); 88 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get()));
90 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), decoder_.get(), 89 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), decoder_.get(),
91 decoder_.get())); 90 decoder_.get()));
92 decoder_->set_engine(scheduler_.get()); 91 decoder_->set_engine(scheduler_.get());
93 decoder_->SetResizeCallback( 92 decoder_->SetResizeCallback(
94 base::Bind(&CommandBufferLocal::OnResize, base::Unretained(this))); 93 base::Bind(&CommandBufferLocal::OnResize, base::Unretained(this)));
95 decoder_->SetWaitSyncPointCallback(base::Bind( 94 decoder_->SetWaitSyncPointCallback(
96 &CommandBufferLocal::OnWaitSyncPoint, base::Unretained(this))); 95 base::Bind(&CommandBufferLocal::OnWaitSyncPoint, base::Unretained(this)));
97 96
98 gpu::gles2::DisallowedFeatures disallowed_features; 97 gpu::gles2::DisallowedFeatures disallowed_features;
99 98
100 // TODO(piman): attributes. 99 // TODO(piman): attributes.
101 std::vector<int32> attrib_vector; 100 std::vector<int32> attrib_vector;
102 if (!decoder_->Initialize(surface_, context_, false /* offscreen */, 101 if (!decoder_->Initialize(surface_, context_, false /* offscreen */,
103 gfx::Size(1, 1), disallowed_features, 102 gfx::Size(1, 1), disallowed_features,
104 attrib_vector)) 103 attrib_vector))
105 return false; 104 return false;
106 105
107 command_buffer_->SetPutOffsetChangeCallback(base::Bind( 106 command_buffer_->SetPutOffsetChangeCallback(
108 &CommandBufferLocal::PumpCommands, base::Unretained(this))); 107 base::Bind(&CommandBufferLocal::PumpCommands, base::Unretained(this)));
109 command_buffer_->SetGetBufferChangeCallback(base::Bind( 108 command_buffer_->SetGetBufferChangeCallback(base::Bind(
110 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get()))); 109 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get())));
111 command_buffer_->SetParseErrorCallback( 110 command_buffer_->SetParseErrorCallback(
112 base::Bind(&CommandBufferLocal::OnParseError, base::Unretained(this))); 111 base::Bind(&CommandBufferLocal::OnParseError, base::Unretained(this)));
113 return true; 112 return true;
114 } 113 }
115 114
116 gpu::CommandBuffer* CommandBufferLocal::GetCommandBuffer() { 115 gpu::CommandBuffer* CommandBufferLocal::GetCommandBuffer() {
117 return command_buffer_.get(); 116 return command_buffer_.get();
118 } 117 }
(...skipping 30 matching lines...) Expand all
149 image_manager->AddImage(image.get(), new_id); 148 image_manager->AddImage(image.get(), new_id);
150 return new_id; 149 return new_id;
151 } 150 }
152 151
153 void CommandBufferLocal::DestroyImage(int32 id) { 152 void CommandBufferLocal::DestroyImage(int32 id) {
154 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 153 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
155 DCHECK(image_manager); 154 DCHECK(image_manager);
156 image_manager->RemoveImage(id); 155 image_manager->RemoveImage(id);
157 } 156 }
158 157
159 int32_t CommandBufferLocal::CreateGpuMemoryBufferImage( 158 int32_t CommandBufferLocal::CreateGpuMemoryBufferImage(size_t width,
160 size_t width, 159 size_t height,
161 size_t height, 160 unsigned internalformat,
162 unsigned internalformat, 161 unsigned usage) {
163 unsigned usage) {
164 DCHECK_EQ(usage, static_cast<unsigned>(GL_MAP_CHROMIUM)); 162 DCHECK_EQ(usage, static_cast<unsigned>(GL_MAP_CHROMIUM));
165 scoped_ptr<gfx::GpuMemoryBuffer> buffer( 163 scoped_ptr<gfx::GpuMemoryBuffer> buffer(
166 gles2::MojoGpuMemoryBufferImpl::Create( 164 gles2::MojoGpuMemoryBufferImpl::Create(
167 gfx::Size(static_cast<int>(width), static_cast<int>(height)), 165 gfx::Size(static_cast<int>(width), static_cast<int>(height)),
168 gpu::ImageFactory::DefaultBufferFormatForImageFormat(internalformat), 166 gpu::ImageFactory::DefaultBufferFormatForImageFormat(internalformat),
169 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); 167 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage)));
170 if (!buffer) 168 if (!buffer)
171 return -1; 169 return -1;
172 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); 170 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat);
173 } 171 }
174 172
175 uint32_t CommandBufferLocal::InsertSyncPoint() { 173 uint32_t CommandBufferLocal::InsertSyncPoint() {
176 return 0; 174 return 0;
177 } 175 }
178 176
179 uint32_t CommandBufferLocal::InsertFutureSyncPoint() { 177 uint32_t CommandBufferLocal::InsertFutureSyncPoint() {
180 NOTIMPLEMENTED(); 178 NOTIMPLEMENTED();
181 return 0; 179 return 0;
182 } 180 }
183 181
184 void CommandBufferLocal::RetireSyncPoint(uint32_t sync_point) { 182 void CommandBufferLocal::RetireSyncPoint(uint32_t sync_point) {
185 NOTIMPLEMENTED(); 183 NOTIMPLEMENTED();
186 } 184 }
187 185
188 void CommandBufferLocal::SignalSyncPoint(uint32_t sync_point, 186 void CommandBufferLocal::SignalSyncPoint(uint32_t sync_point,
189 const base::Closure& callback) { 187 const base::Closure& callback) {}
190 }
191 188
192 void CommandBufferLocal::SignalQuery(uint32_t query, 189 void CommandBufferLocal::SignalQuery(uint32_t query,
193 const base::Closure& callback) { 190 const base::Closure& callback) {
194 // TODO(piman) 191 // TODO(piman)
195 NOTIMPLEMENTED(); 192 NOTIMPLEMENTED();
196 } 193 }
197 194
198 void CommandBufferLocal::SetSurfaceVisible(bool visible) { 195 void CommandBufferLocal::SetSurfaceVisible(bool visible) {
199 // TODO(piman) 196 // TODO(piman)
200 NOTIMPLEMENTED(); 197 NOTIMPLEMENTED();
(...skipping 26 matching lines...) Expand all
227 void CommandBufferLocal::OnResize(gfx::Size size, float scale_factor) { 224 void CommandBufferLocal::OnResize(gfx::Size size, float scale_factor) {
228 surface_->Resize(size); 225 surface_->Resize(size);
229 } 226 }
230 227
231 void CommandBufferLocal::OnUpdateVSyncParameters( 228 void CommandBufferLocal::OnUpdateVSyncParameters(
232 const base::TimeTicks timebase, 229 const base::TimeTicks timebase,
233 const base::TimeDelta interval) { 230 const base::TimeDelta interval) {
234 if (client_) 231 if (client_)
235 client_->UpdateVSyncParameters(timebase.ToInternalValue(), 232 client_->UpdateVSyncParameters(timebase.ToInternalValue(),
236 interval.ToInternalValue()); 233 interval.ToInternalValue());
237
238 } 234 }
239 235
240 bool CommandBufferLocal::OnWaitSyncPoint(uint32_t sync_point) { 236 bool CommandBufferLocal::OnWaitSyncPoint(uint32_t sync_point) {
241 if (!sync_point) 237 if (!sync_point)
242 return true; 238 return true;
243 if (gpu_state_->sync_point_manager()->IsSyncPointRetired(sync_point)) 239 if (gpu_state_->sync_point_manager()->IsSyncPointRetired(sync_point))
244 return true; 240 return true;
245 scheduler_->SetScheduled(false); 241 scheduler_->SetScheduled(false);
246 gpu_state_->sync_point_manager()->AddSyncPointCallback( 242 gpu_state_->sync_point_manager()->AddSyncPointCallback(
247 sync_point, base::Bind(&CommandBufferLocal::OnSyncPointRetired, 243 sync_point, base::Bind(&CommandBufferLocal::OnSyncPointRetired,
248 weak_factory_.GetWeakPtr())); 244 weak_factory_.GetWeakPtr()));
249 return scheduler_->IsScheduled(); 245 return scheduler_->IsScheduled();
250 } 246 }
251 247
252 void CommandBufferLocal::OnParseError() { 248 void CommandBufferLocal::OnParseError() {
253 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 249 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
254 OnContextLost(state.context_lost_reason); 250 OnContextLost(state.context_lost_reason);
255 } 251 }
256 252
257 void CommandBufferLocal::OnContextLost(uint32_t reason) { 253 void CommandBufferLocal::OnContextLost(uint32_t reason) {
258 if (client_) 254 if (client_)
259 client_->DidLoseContext(); 255 client_->DidLoseContext();
260 } 256 }
261 257
262 void CommandBufferLocal::OnSyncPointRetired() { 258 void CommandBufferLocal::OnSyncPointRetired() {
263 scheduler_->SetScheduled(true); 259 scheduler_->SetScheduled(true);
264 } 260 }
265 261
266 } // namespace gles2 262 } // namespace gles2
OLDNEW
« no previous file with comments | « components/mus/gles2/command_buffer_local.h ('k') | components/mus/gles2/command_buffer_local_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698