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

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

Issue 1282313002: Add YUV_420_BIPLANAR to gfx::BufferFormat. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gmb-planes
Patch Set: Rebase Created 5 years, 4 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 #include "content/common/mac/io_surface_manager.h" 8 #include "content/common/mac/io_surface_manager.h"
9 #include "ui/gfx/buffer_format_util.h"
9 10
10 namespace content { 11 namespace content {
11 namespace { 12 namespace {
12 13
13 uint32_t LockFlags(gfx::BufferUsage usage) { 14 uint32_t LockFlags(gfx::BufferUsage usage) {
14 switch (usage) { 15 switch (usage) {
15 case gfx::BufferUsage::MAP: 16 case gfx::BufferUsage::MAP:
16 return kIOSurfaceLockAvoidSync; 17 return kIOSurfaceLockAvoidSync;
17 case gfx::BufferUsage::PERSISTENT_MAP: 18 case gfx::BufferUsage::PERSISTENT_MAP:
18 return 0; 19 return 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return make_scoped_ptr<GpuMemoryBufferImpl>( 55 return make_scoped_ptr<GpuMemoryBufferImpl>(
55 new GpuMemoryBufferImplIOSurface(handle.id, size, format, callback, 56 new GpuMemoryBufferImplIOSurface(handle.id, size, format, callback,
56 io_surface.release(), LockFlags(usage))); 57 io_surface.release(), LockFlags(usage)));
57 } 58 }
58 59
59 bool GpuMemoryBufferImplIOSurface::Map(void** data) { 60 bool GpuMemoryBufferImplIOSurface::Map(void** data) {
60 DCHECK(!mapped_); 61 DCHECK(!mapped_);
61 IOReturn status = IOSurfaceLock(io_surface_, lock_flags_, NULL); 62 IOReturn status = IOSurfaceLock(io_surface_, lock_flags_, NULL);
62 DCHECK_NE(status, kIOReturnCannotLock); 63 DCHECK_NE(status, kIOReturnCannotLock);
63 mapped_ = true; 64 mapped_ = true;
64 *data = IOSurfaceGetBaseAddress(io_surface_); 65 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(GetFormat());
66 for (size_t plane = 0; plane < num_planes; ++plane)
67 data[plane] = IOSurfaceGetBaseAddressOfPlane(io_surface_, plane);
65 return true; 68 return true;
66 } 69 }
67 70
68 void GpuMemoryBufferImplIOSurface::Unmap() { 71 void GpuMemoryBufferImplIOSurface::Unmap() {
69 DCHECK(mapped_); 72 DCHECK(mapped_);
70 IOSurfaceUnlock(io_surface_, lock_flags_, NULL); 73 IOSurfaceUnlock(io_surface_, lock_flags_, NULL);
71 mapped_ = false; 74 mapped_ = false;
72 } 75 }
73 76
74 void GpuMemoryBufferImplIOSurface::GetStride(int* stride) const { 77 void GpuMemoryBufferImplIOSurface::GetStride(int* strides) const {
75 *stride = IOSurfaceGetBytesPerRow(io_surface_); 78 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(GetFormat());
79 for (size_t plane = 0; plane < num_planes; ++plane)
80 strides[plane] = IOSurfaceGetBytesPerRowOfPlane(io_surface_, plane);
76 } 81 }
77 82
78 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { 83 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const {
79 gfx::GpuMemoryBufferHandle handle; 84 gfx::GpuMemoryBufferHandle handle;
80 handle.type = gfx::IO_SURFACE_BUFFER; 85 handle.type = gfx::IO_SURFACE_BUFFER;
81 handle.id = id_; 86 handle.id = id_;
82 return handle; 87 return handle;
83 } 88 }
84 89
85 } // namespace content 90 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl.cc ('k') | content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698