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

Side by Side Diff: gpu/ipc/service/gpu_memory_buffer_factory_io_surface.cc

Issue 2061743004: Implement native GMB backbuffers in the GLES2 Command Decoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile error on Windows. Created 4 years, 5 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 "gpu/ipc/service/gpu_memory_buffer_factory_io_surface.h" 5 #include "gpu/ipc/service/gpu_memory_buffer_factory_io_surface.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/gfx/buffer_format_util.h" 10 #include "ui/gfx/buffer_format_util.h"
(...skipping 14 matching lines...) Expand all
25 const gfx::Size& size, 25 const gfx::Size& size,
26 gfx::BufferFormat format, 26 gfx::BufferFormat format,
27 gfx::BufferUsage usage, 27 gfx::BufferUsage usage,
28 int client_id, 28 int client_id,
29 SurfaceHandle surface_handle) { 29 SurfaceHandle surface_handle) {
30 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( 30 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(
31 gfx::CreateIOSurface(size, format)); 31 gfx::CreateIOSurface(size, format));
32 if (!io_surface) 32 if (!io_surface)
33 return gfx::GpuMemoryBufferHandle(); 33 return gfx::GpuMemoryBufferHandle();
34 34
35 { 35 // A GpuMemoryBuffer with client_id = 0 behaves like anonymous shared memory.
36 if (client_id != 0) {
36 base::AutoLock lock(io_surfaces_lock_); 37 base::AutoLock lock(io_surfaces_lock_);
37 38
38 IOSurfaceMapKey key(id, client_id); 39 IOSurfaceMapKey key(id, client_id);
39 DCHECK(io_surfaces_.find(key) == io_surfaces_.end()); 40 DCHECK(io_surfaces_.find(key) == io_surfaces_.end());
40 io_surfaces_[key] = io_surface; 41 io_surfaces_[key] = io_surface;
41 } 42 }
42 43
43 gfx::GpuMemoryBufferHandle handle; 44 gfx::GpuMemoryBufferHandle handle;
44 handle.type = gfx::IO_SURFACE_BUFFER; 45 handle.type = gfx::IO_SURFACE_BUFFER;
45 handle.id = id; 46 handle.id = id;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return scoped_refptr<gl::GLImage>(); 80 return scoped_refptr<gl::GLImage>();
80 81
81 scoped_refptr<gl::GLImageIOSurface> image( 82 scoped_refptr<gl::GLImageIOSurface> image(
82 new gl::GLImageIOSurface(size, internalformat)); 83 new gl::GLImageIOSurface(size, internalformat));
83 if (!image->Initialize(it->second.get(), handle.id, format)) 84 if (!image->Initialize(it->second.get(), handle.id, format))
84 return scoped_refptr<gl::GLImage>(); 85 return scoped_refptr<gl::GLImage>();
85 86
86 return image; 87 return image;
87 } 88 }
88 89
90 scoped_refptr<gl::GLImage>
91 GpuMemoryBufferFactoryIOSurface::CreateAnonymousImage(const gfx::Size& size,
92 gfx::BufferFormat format,
93 unsigned internalformat) {
94 // Note that the GpuMemoryBufferId and child id don't matter since the texture
95 // will never be directly exposed to other processes, only via a mailbox.
96 int gmb_id = 0;
97 int client_id = 0;
98 gfx::GpuMemoryBufferHandle handle = CreateGpuMemoryBuffer(
99 gfx::GpuMemoryBufferId(gmb_id), size, format, gfx::BufferUsage::SCANOUT,
100 client_id, gpu::kNullSurfaceHandle);
101
102 base::ScopedCFTypeRef<IOSurfaceRef> io_surface;
103 io_surface.reset(IOSurfaceLookupFromMachPort(handle.mach_port.get()));
104 DCHECK_NE(nullptr, io_surface.get());
105 scoped_refptr<gl::GLImageIOSurface> image(
106 new gl::GLImageIOSurface(size, internalformat));
107 if (!image->Initialize(io_surface.get(), handle.id, format))
108 return scoped_refptr<gl::GLImage>();
109 return image;
110 }
111
89 } // namespace gpu 112 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698