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

Side by Side Diff: components/view_manager/gles2/command_buffer_driver.cc

Issue 1189833005: Revert of Support impl-side painting in Mandoline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_driver.h" 5 #include "components/view_manager/gles2/command_buffer_driver.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "components/view_manager/gles2/command_buffer_type_conversions.h" 10 #include "components/view_manager/gles2/command_buffer_type_conversions.h"
11 #include "components/view_manager/gles2/mojo_buffer_backing.h" 11 #include "components/view_manager/gles2/mojo_buffer_backing.h"
12 #include "gpu/command_buffer/common/constants.h" 12 #include "gpu/command_buffer/common/constants.h"
13 #include "gpu/command_buffer/common/value_state.h" 13 #include "gpu/command_buffer/common/value_state.h"
14 #include "gpu/command_buffer/service/command_buffer_service.h" 14 #include "gpu/command_buffer/service/command_buffer_service.h"
15 #include "gpu/command_buffer/service/context_group.h" 15 #include "gpu/command_buffer/service/context_group.h"
16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
17 #include "gpu/command_buffer/service/gpu_scheduler.h" 17 #include "gpu/command_buffer/service/gpu_scheduler.h"
18 #include "gpu/command_buffer/service/image_factory.h"
19 #include "gpu/command_buffer/service/image_manager.h" 18 #include "gpu/command_buffer/service/image_manager.h"
20 #include "gpu/command_buffer/service/mailbox_manager.h" 19 #include "gpu/command_buffer/service/mailbox_manager.h"
21 #include "gpu/command_buffer/service/memory_tracking.h" 20 #include "gpu/command_buffer/service/memory_tracking.h"
22 #include "gpu/command_buffer/service/sync_point_manager.h" 21 #include "gpu/command_buffer/service/sync_point_manager.h"
23 #include "gpu/command_buffer/service/valuebuffer_manager.h" 22 #include "gpu/command_buffer/service/valuebuffer_manager.h"
24 #include "mojo/converters/geometry/geometry_type_converters.h"
25 #include "mojo/platform_handle/platform_handle_functions.h"
26 #include "ui/gfx/gpu_memory_buffer.h"
27 #include "ui/gfx/vsync_provider.h" 23 #include "ui/gfx/vsync_provider.h"
28 #include "ui/gl/gl_context.h" 24 #include "ui/gl/gl_context.h"
29 #include "ui/gl/gl_image_shared_memory.h"
30 #include "ui/gl/gl_surface.h" 25 #include "ui/gl/gl_surface.h"
31 26
32 namespace gles2 { 27 namespace gles2 {
33 28
34 namespace { 29 namespace {
35 30
36 class MemoryTrackerStub : public gpu::gles2::MemoryTracker { 31 class MemoryTrackerStub : public gpu::gles2::MemoryTracker {
37 public: 32 public:
38 MemoryTrackerStub() {} 33 MemoryTrackerStub() {}
39 34
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 215 }
221 216
222 void CommandBufferDriver::DestroyTransferBuffer(int32_t id) { 217 void CommandBufferDriver::DestroyTransferBuffer(int32_t id) {
223 command_buffer_->DestroyTransferBuffer(id); 218 command_buffer_->DestroyTransferBuffer(id);
224 } 219 }
225 220
226 void CommandBufferDriver::Echo(const mojo::Callback<void()>& callback) { 221 void CommandBufferDriver::Echo(const mojo::Callback<void()>& callback) {
227 callback.Run(); 222 callback.Run();
228 } 223 }
229 224
230 void CommandBufferDriver::CreateImage(int32_t id,
231 mojo::ScopedHandle memory_handle,
232 int32 type,
233 mojo::SizePtr size,
234 int32_t format,
235 int32_t internal_format) {
236 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
237 if (image_manager->LookupImage(id)) {
238 LOG(ERROR) << "Image already exists with same ID.";
239 return;
240 }
241
242 gfx::GpuMemoryBuffer::Format gpu_format =
243 static_cast<gfx::GpuMemoryBuffer::Format>(format);
244 if (!gpu::ImageFactory::IsGpuMemoryBufferFormatSupported(
245 gpu_format, decoder_->GetCapabilities())) {
246 LOG(ERROR) << "Format is not supported.";
247 return;
248 }
249
250 gfx::Size gfx_size = size.To<gfx::Size>();
251 if (!gpu::ImageFactory::IsImageSizeValidForGpuMemoryBufferFormat(
252 gfx_size, gpu_format)) {
253 LOG(ERROR) << "Invalid image size for format.";
254 return;
255 }
256
257 if (!gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat(
258 internal_format, gpu_format)) {
259 LOG(ERROR) << "Incompatible image format.";
260 return;
261 }
262
263 if (type != gfx::SHARED_MEMORY_BUFFER) {
264 NOTIMPLEMENTED();
265 return;
266 }
267
268 gfx::GpuMemoryBufferHandle gfx_handle;
269 // TODO(jam): create mojo enum for this and converter
270 gfx_handle.type = static_cast<gfx::GpuMemoryBufferType>(type);
271 gfx_handle.id = id;
272
273 MojoPlatformHandle platform_handle;
274 MojoResult extract_result = MojoExtractPlatformHandle(
275 memory_handle.release().value(),
276 &platform_handle);
277 if (extract_result != MOJO_RESULT_OK) {
278 NOTREACHED();
279 return;
280 }
281
282 #if defined(OS_WIN)
283 gfx_handle.handle = platform_handle;
284 #else
285 gfx_handle.handle = base::FileDescriptor(platform_handle, false);
286 #endif
287
288 scoped_refptr<gfx::GLImageSharedMemory> image =
289 new gfx::GLImageSharedMemory(gfx_size, internal_format);
290 // TODO(jam): also need a mojo enum for this enum
291 if (!image->Initialize(gfx_handle, gpu_format)) {
292 NOTREACHED();
293 return;
294 }
295
296 image_manager->AddImage(image.get(), id);
297 }
298
299 void CommandBufferDriver::DestroyImage(int32_t id) {
300 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
301 if (!image_manager->LookupImage(id)) {
302 LOG(ERROR) << "Image with ID doesn't exist.";
303 return;
304 }
305 image_manager->RemoveImage(id);
306 }
307
308 void CommandBufferDriver::OnParseError() { 225 void CommandBufferDriver::OnParseError() {
309 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 226 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
310 OnContextLost(state.context_lost_reason); 227 OnContextLost(state.context_lost_reason);
311 } 228 }
312 229
313 void CommandBufferDriver::OnResize(gfx::Size size, float scale_factor) { 230 void CommandBufferDriver::OnResize(gfx::Size size, float scale_factor) {
314 surface_->Resize(size); 231 surface_->Resize(size);
315 } 232 }
316 233
317 bool CommandBufferDriver::OnWaitSyncPoint(uint32_t sync_point) { 234 bool CommandBufferDriver::OnWaitSyncPoint(uint32_t sync_point) {
(...skipping 25 matching lines...) Expand all
343 260
344 void CommandBufferDriver::DestroyDecoder() { 261 void CommandBufferDriver::DestroyDecoder() {
345 if (decoder_) { 262 if (decoder_) {
346 bool have_context = decoder_->MakeCurrent(); 263 bool have_context = decoder_->MakeCurrent();
347 decoder_->Destroy(have_context); 264 decoder_->Destroy(have_context);
348 decoder_.reset(); 265 decoder_.reset();
349 } 266 }
350 } 267 }
351 268
352 } // namespace gles2 269 } // namespace gles2
OLDNEW
« no previous file with comments | « components/view_manager/gles2/command_buffer_driver.h ('k') | components/view_manager/gles2/command_buffer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698