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

Side by Side Diff: content/common/gpu/client/gpu_memory_buffer_impl_io_surface.cc

Issue 604903005: content: Move IOSurface backed GpuMemoryBuffer allocation to GPU process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include CoreFoundation.h Created 6 years, 2 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 "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h" 5 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h"
6 6
7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h"
9 #include "base/logging.h"
10 #include "content/common/gpu/client/gpu_memory_buffer_factory_host.h"
7 #include "ui/gl/gl_bindings.h" 11 #include "ui/gl/gl_bindings.h"
8 12
9 namespace content { 13 namespace content {
14 namespace {
15
16 base::StaticAtomicSequenceNumber g_next_buffer_id;
17
18 void Noop() {
19 }
20
21 void GpuMemoryBufferCreated(
22 const gfx::Size& size,
23 unsigned internalformat,
24 const GpuMemoryBufferImpl::CreationCallback& callback,
25 const gfx::GpuMemoryBufferHandle& handle) {
26 DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type);
27
28 callback.Run(GpuMemoryBufferImplIOSurface::CreateFromHandle(
29 handle, size, internalformat, base::Bind(&Noop)));
30 }
31
32 void GpuMemoryBufferCreatedForChildProcess(
33 const GpuMemoryBufferImpl::AllocationCallback& callback,
34 const gfx::GpuMemoryBufferHandle& handle) {
35 DCHECK_EQ(gfx::IO_SURFACE_BUFFER, handle.type);
36
37 callback.Run(handle);
38 }
39
40 } // namespace
10 41
11 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface( 42 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface(
12 const gfx::Size& size, 43 const gfx::Size& size,
13 unsigned internalformat, 44 unsigned internalformat,
14 const DestructionCallback& callback, 45 const DestructionCallback& callback,
15 IOSurfaceRef io_surface) 46 IOSurfaceRef io_surface)
16 : GpuMemoryBufferImpl(size, internalformat, callback), 47 : GpuMemoryBufferImpl(size, internalformat, callback),
17 io_surface_(io_surface) { 48 io_surface_(io_surface) {
18 } 49 }
19 50
20 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() { 51 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() {
21 } 52 }
22 53
23 // static 54 // static
55 void GpuMemoryBufferImplIOSurface::Create(const gfx::Size& size,
56 unsigned internalformat,
57 unsigned usage,
58 int client_id,
59 const CreationCallback& callback) {
60 gfx::GpuMemoryBufferHandle handle;
61 handle.type = gfx::IO_SURFACE_BUFFER;
62 handle.global_id.primary_id = g_next_buffer_id.GetNext();
63 handle.global_id.secondary_id = client_id;
64 GpuMemoryBufferFactoryHost::GetInstance()->CreateGpuMemoryBuffer(
65 handle,
66 size,
67 internalformat,
68 usage,
69 base::Bind(&GpuMemoryBufferCreated, size, internalformat, callback));
70 }
71
72 // static
73 void GpuMemoryBufferImplIOSurface::AllocateForChildProcess(
74 const gfx::Size& size,
75 unsigned internalformat,
76 unsigned usage,
77 int child_client_id,
78 const AllocationCallback& callback) {
79 gfx::GpuMemoryBufferHandle handle;
80 handle.type = gfx::IO_SURFACE_BUFFER;
81 handle.global_id.primary_id = g_next_buffer_id.GetNext();
82 handle.global_id.secondary_id = child_client_id;
83 GpuMemoryBufferFactoryHost::GetInstance()->CreateGpuMemoryBuffer(
84 handle,
85 size,
86 internalformat,
87 usage,
88 base::Bind(&GpuMemoryBufferCreatedForChildProcess, callback));
89 }
90
91 // static
24 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImplIOSurface::CreateFromHandle( 92 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImplIOSurface::CreateFromHandle(
25 const gfx::GpuMemoryBufferHandle& handle, 93 const gfx::GpuMemoryBufferHandle& handle,
26 const gfx::Size& size, 94 const gfx::Size& size,
27 unsigned internalformat, 95 unsigned internalformat,
28 const DestructionCallback& callback) { 96 const DestructionCallback& callback) {
29 DCHECK(IsFormatSupported(internalformat)); 97 DCHECK(IsFormatSupported(internalformat));
30 98
31 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( 99 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(
32 IOSurfaceLookup(handle.io_surface_id)); 100 IOSurfaceLookup(handle.io_surface_id));
33 if (!io_surface) 101 if (!io_surface)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 161 }
94 162
95 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { 163 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const {
96 gfx::GpuMemoryBufferHandle handle; 164 gfx::GpuMemoryBufferHandle handle;
97 handle.type = gfx::IO_SURFACE_BUFFER; 165 handle.type = gfx::IO_SURFACE_BUFFER;
98 handle.io_surface_id = IOSurfaceGetID(io_surface_); 166 handle.io_surface_id = IOSurfaceGetID(io_surface_);
99 return handle; 167 return handle;
100 } 168 }
101 169
102 } // namespace content 170 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h ('k') | content/common/gpu/client/gpu_memory_buffer_impl_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698