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

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

Issue 1024113003: Add multi-planar functions to GpuMemoryBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reveman@ comments. Created 5 years, 9 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/logging.h" 7 #include "base/logging.h"
8 8
9 namespace content { 9 namespace content {
10 10
(...skipping 17 matching lines...) Expand all
28 const DestructionCallback& callback) { 28 const DestructionCallback& callback) {
29 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( 29 base::ScopedCFTypeRef<IOSurfaceRef> io_surface(
30 IOSurfaceLookup(handle.io_surface_id)); 30 IOSurfaceLookup(handle.io_surface_id));
31 if (!io_surface) 31 if (!io_surface)
32 return scoped_ptr<GpuMemoryBufferImpl>(); 32 return scoped_ptr<GpuMemoryBufferImpl>();
33 33
34 return make_scoped_ptr<GpuMemoryBufferImpl>(new GpuMemoryBufferImplIOSurface( 34 return make_scoped_ptr<GpuMemoryBufferImpl>(new GpuMemoryBufferImplIOSurface(
35 handle.id, size, format, callback, io_surface.release())); 35 handle.id, size, format, callback, io_surface.release()));
36 } 36 }
37 37
38 void* GpuMemoryBufferImplIOSurface::Map() { 38 bool GpuMemoryBufferImplIOSurface::Map(void** data) {
39 DCHECK(!mapped_); 39 DCHECK(!mapped_);
40 IOSurfaceLock(io_surface_, 0, NULL); 40 IOSurfaceLock(io_surface_, 0, NULL);
41 mapped_ = true; 41 mapped_ = true;
42 return IOSurfaceGetBaseAddress(io_surface_); 42 *data = IOSurfaceGetBaseAddress(io_surface_);
43 return true;
43 } 44 }
44 45
46
reveman 2015/03/24 22:16:53 nit: no need for a new line here
emircan 2015/03/24 22:45:16 Done.
45 void GpuMemoryBufferImplIOSurface::Unmap() { 47 void GpuMemoryBufferImplIOSurface::Unmap() {
46 DCHECK(mapped_); 48 DCHECK(mapped_);
47 IOSurfaceUnlock(io_surface_, 0, NULL); 49 IOSurfaceUnlock(io_surface_, 0, NULL);
48 mapped_ = false; 50 mapped_ = false;
49 } 51 }
50 52
51 uint32 GpuMemoryBufferImplIOSurface::GetStride() const { 53 void GpuMemoryBufferImplIOSurface::GetStride(uint32* stride) const {
52 return IOSurfaceGetBytesPerRow(io_surface_); 54 *stride = IOSurfaceGetBytesPerRow(io_surface_);
53 } 55 }
54 56
55 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { 57 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const {
56 gfx::GpuMemoryBufferHandle handle; 58 gfx::GpuMemoryBufferHandle handle;
57 handle.type = gfx::IO_SURFACE_BUFFER; 59 handle.type = gfx::IO_SURFACE_BUFFER;
58 handle.id = id_; 60 handle.id = id_;
59 handle.io_surface_id = IOSurfaceGetID(io_surface_); 61 handle.io_surface_id = IOSurfaceGetID(io_surface_);
60 return handle; 62 return handle;
61 } 63 }
62 64
63 } // namespace content 65 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698