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

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

Issue 1857243005: Scan-out capable buffers (aka ui::NativePixmap) for Mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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/mus/gles2/command_buffer_driver.h" 5 #include "components/mus/gles2/command_buffer_driver.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 17 matching lines...) Expand all
28 #include "gpu/command_buffer/service/valuebuffer_manager.h" 28 #include "gpu/command_buffer/service/valuebuffer_manager.h"
29 #include "mojo/converters/geometry/geometry_type_converters.h" 29 #include "mojo/converters/geometry/geometry_type_converters.h"
30 #include "mojo/platform_handle/platform_handle_functions.h" 30 #include "mojo/platform_handle/platform_handle_functions.h"
31 #include "ui/gfx/buffer_format_util.h" 31 #include "ui/gfx/buffer_format_util.h"
32 #include "ui/gfx/gpu_memory_buffer.h" 32 #include "ui/gfx/gpu_memory_buffer.h"
33 #include "ui/gfx/vsync_provider.h" 33 #include "ui/gfx/vsync_provider.h"
34 #include "ui/gl/gl_context.h" 34 #include "ui/gl/gl_context.h"
35 #include "ui/gl/gl_image_shared_memory.h" 35 #include "ui/gl/gl_image_shared_memory.h"
36 #include "ui/gl/gl_surface.h" 36 #include "ui/gl/gl_surface.h"
37 37
38 #if defined(USE_OZONE)
39 #include "ui/gl/gl_image_ozone_native_pixmap.h"
40 #endif
41
38 namespace mus { 42 namespace mus {
39 43
40 namespace { 44 namespace {
41 45
42 // The first time polling a fence, delay some extra time to allow other 46 // The first time polling a fence, delay some extra time to allow other
43 // stubs to process some work, or else the timing of the fences could 47 // stubs to process some work, or else the timing of the fences could
44 // allow a pattern of alternating fast and slow frames to occur. 48 // allow a pattern of alternating fast and slow frames to occur.
45 const int64_t kHandleMoreWorkPeriodMs = 2; 49 const int64_t kHandleMoreWorkPeriodMs = 2;
46 const int64_t kHandleMoreWorkPeriodBusyMs = 1; 50 const int64_t kHandleMoreWorkPeriodBusyMs = 1;
47 51
(...skipping 29 matching lines...) Expand all
77 mojo::ScopedSharedBufferHandle shared_state, 81 mojo::ScopedSharedBufferHandle shared_state,
78 mojo::Array<int32_t> attribs) { 82 mojo::Array<int32_t> attribs) {
79 DCHECK(CalledOnValidThread()); 83 DCHECK(CalledOnValidThread());
80 gpu::gles2::ContextCreationAttribHelper attrib_helper; 84 gpu::gles2::ContextCreationAttribHelper attrib_helper;
81 if (!attrib_helper.Parse(attribs.storage())) 85 if (!attrib_helper.Parse(attribs.storage()))
82 return false; 86 return false;
83 87
84 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget; 88 const bool offscreen = widget_ == gfx::kNullAcceleratedWidget;
85 static scoped_refptr<gfx::GLSurface> underlying_surface; 89 static scoped_refptr<gfx::GLSurface> underlying_surface;
86 if (offscreen) { 90 if (offscreen) {
87 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); 91 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(0, 0));
88 } else { 92 } else {
93 #if defined(USE_OZONE)
94 scoped_refptr<gfx::GLSurface> underlying_surface =
95 gfx::GLSurface::CreateSurfacelessViewGLSurface(widget_);
96 if (!underlying_surface) {
Fady Samuel 2016/04/06 22:02:02 nit: unnecessary braces.
rjkroege 2016/04/06 22:45:44 Done.
97 underlying_surface = gfx::GLSurface::CreateViewGLSurface(widget_);
98 }
99 #else
100 scoped_refptr<gfx::GLSurface> underlying_surface =
101 gfx::GLSurface::CreateViewGLSurface(widget_);
102 #endif
89 scoped_refptr<GLSurfaceAdapterMus> surface_adapter = 103 scoped_refptr<GLSurfaceAdapterMus> surface_adapter =
90 new GLSurfaceAdapterMus(gfx::GLSurface::CreateViewGLSurface(widget_)); 104 new GLSurfaceAdapterMus(underlying_surface);
91 surface_adapter->SetGpuCompletedSwapBuffersCallback( 105 surface_adapter->SetGpuCompletedSwapBuffersCallback(
92 base::Bind(&CommandBufferDriver::OnGpuCompletedSwapBuffers, 106 base::Bind(&CommandBufferDriver::OnGpuCompletedSwapBuffers,
93 weak_factory_.GetWeakPtr())); 107 weak_factory_.GetWeakPtr()));
94 surface_ = surface_adapter; 108 surface_ = surface_adapter;
95 109
96 gfx::VSyncProvider* vsync_provider = 110 gfx::VSyncProvider* vsync_provider =
97 surface_ ? surface_->GetVSyncProvider() : nullptr; 111 surface_ ? surface_->GetVSyncProvider() : nullptr;
98 if (vsync_provider) { 112 if (vsync_provider) {
99 vsync_provider->GetVSyncParameters( 113 vsync_provider->GetVSyncParameters(
100 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, 114 base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 if (!image->Initialize( 280 if (!image->Initialize(
267 handle, gfx::GpuMemoryBufferId(id), gpu_format, 0, 281 handle, gfx::GpuMemoryBufferId(id), gpu_format, 0,
268 gfx::RowSizeForBufferFormat(gfx_size.width(), gpu_format, 0))) { 282 gfx::RowSizeForBufferFormat(gfx_size.width(), gpu_format, 0))) {
269 NOTREACHED(); 283 NOTREACHED();
270 return; 284 return;
271 } 285 }
272 286
273 image_manager->AddImage(image.get(), id); 287 image_manager->AddImage(image.get(), id);
274 } 288 }
275 289
290 #if defined(USE_OZONE)
291 // TODO(rjkroege): It is conceivable that this code belongs in
292 // ozone_gpu_memory_buffer.cc
293 void CommandBufferDriver::CreateImageNativeOzone(int32_t id,
294 int32_t type,
295 gfx::Size size,
296 gfx::BufferFormat format,
297 uint32_t internal_format,
298 ui::NativePixmap* pixmap) {
299 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
300 if (image_manager->LookupImage(id)) {
301 LOG(ERROR) << "Image already exists with same ID.";
302 return;
303 }
304
305 scoped_refptr<gfx::GLImageOzoneNativePixmap> image =
306 new gfx::GLImageOzoneNativePixmap(size, internal_format);
307 if (!image->Initialize(pixmap, format)) {
308 NOTREACHED();
309 return;
310 }
311
312 image_manager->AddImage(image.get(), id);
313 }
314 #endif
315
276 void CommandBufferDriver::DestroyImage(int32_t id) { 316 void CommandBufferDriver::DestroyImage(int32_t id) {
277 DCHECK(CalledOnValidThread()); 317 DCHECK(CalledOnValidThread());
278 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); 318 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager();
279 if (!image_manager->LookupImage(id)) { 319 if (!image_manager->LookupImage(id)) {
280 LOG(ERROR) << "Image with ID doesn't exist."; 320 LOG(ERROR) << "Image with ID doesn't exist.";
281 return; 321 return;
282 } 322 }
283 if (!MakeCurrent()) 323 if (!MakeCurrent())
284 return; 324 return;
285 image_manager->RemoveImage(id); 325 image_manager->RemoveImage(id);
286 } 326 }
287 327
288 bool CommandBufferDriver::IsScheduled() const { 328 bool CommandBufferDriver::IsScheduled() const {
289 DCHECK(CalledOnValidThread()); 329 DCHECK(CalledOnValidThread());
330 DCHECK(executor_);
290 return executor_->scheduled(); 331 return executor_->scheduled();
291 } 332 }
292 333
293 bool CommandBufferDriver::HasUnprocessedCommands() const { 334 bool CommandBufferDriver::HasUnprocessedCommands() const {
294 DCHECK(CalledOnValidThread()); 335 DCHECK(CalledOnValidThread());
295 if (command_buffer_) { 336 if (command_buffer_) {
296 gpu::CommandBuffer::State state = GetLastState(); 337 gpu::CommandBuffer::State state = GetLastState();
297 return command_buffer_->GetPutOffset() != state.get_offset && 338 return command_buffer_->GetPutOffset() != state.get_offset &&
298 !gpu::error::IsError(state.error); 339 !gpu::error::IsError(state.error);
299 } 340 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 546 }
506 547
507 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) { 548 void CommandBufferDriver::OnGpuCompletedSwapBuffers(gfx::SwapResult result) {
508 DCHECK(CalledOnValidThread()); 549 DCHECK(CalledOnValidThread());
509 if (client_) { 550 if (client_) {
510 client_->OnGpuCompletedSwapBuffers(result); 551 client_->OnGpuCompletedSwapBuffers(result);
511 } 552 }
512 } 553 }
513 554
514 } // namespace mus 555 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698