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

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

Issue 1412223009: Reland: GpuMemoryBuffer interface change: Map(**) to Map() and memory(plane); stride(plane) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Win X64 compile fix Created 5 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/logging.h" 7 #include "base/logging.h"
8 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h" 8 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h"
9 #include "content/common/mac/io_surface_manager.h" 9 #include "content/common/mac/io_surface_manager.h"
10 #include "ui/gfx/buffer_format_util.h" 10 #include "ui/gfx/buffer_format_util.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 DCHECK(io_surface); 82 DCHECK(io_surface);
83 gfx::GpuMemoryBufferId kBufferId(1); 83 gfx::GpuMemoryBufferId kBufferId(1);
84 bool rv = IOSurfaceManager::GetInstance()->RegisterIOSurface(kBufferId, 0, 84 bool rv = IOSurfaceManager::GetInstance()->RegisterIOSurface(kBufferId, 0,
85 io_surface); 85 io_surface);
86 DCHECK(rv); 86 DCHECK(rv);
87 handle->type = gfx::IO_SURFACE_BUFFER; 87 handle->type = gfx::IO_SURFACE_BUFFER;
88 handle->id = kBufferId; 88 handle->id = kBufferId;
89 return base::Bind(&FreeIOSurfaceForTesting, kBufferId); 89 return base::Bind(&FreeIOSurfaceForTesting, kBufferId);
90 } 90 }
91 91
92 bool GpuMemoryBufferImplIOSurface::Map(void** data) { 92 bool GpuMemoryBufferImplIOSurface::Map() {
93 DCHECK(!mapped_); 93 DCHECK(!mapped_);
94 IOReturn status = IOSurfaceLock(io_surface_, lock_flags_, NULL); 94 IOReturn status = IOSurfaceLock(io_surface_, lock_flags_, NULL);
95 DCHECK_NE(status, kIOReturnCannotLock); 95 DCHECK_NE(status, kIOReturnCannotLock);
96 mapped_ = true; 96 mapped_ = true;
97 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(GetFormat());
98 for (size_t plane = 0; plane < num_planes; ++plane)
99 data[plane] = IOSurfaceGetBaseAddressOfPlane(io_surface_, plane);
100 return true; 97 return true;
101 } 98 }
102 99
100 void* GpuMemoryBufferImplIOSurface::memory(size_t plane) {
101 DCHECK(mapped_);
102 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
103 return IOSurfaceGetBaseAddressOfPlane(io_surface_, plane);
104 }
105
103 void GpuMemoryBufferImplIOSurface::Unmap() { 106 void GpuMemoryBufferImplIOSurface::Unmap() {
104 DCHECK(mapped_); 107 DCHECK(mapped_);
105 IOSurfaceUnlock(io_surface_, lock_flags_, NULL); 108 IOSurfaceUnlock(io_surface_, lock_flags_, NULL);
106 mapped_ = false; 109 mapped_ = false;
107 } 110 }
108 111
109 void GpuMemoryBufferImplIOSurface::GetStride(int* strides) const { 112 int GpuMemoryBufferImplIOSurface::stride(size_t plane) const {
110 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(GetFormat()); 113 DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
111 for (size_t plane = 0; plane < num_planes; ++plane) 114 return IOSurfaceGetBytesPerRowOfPlane(io_surface_, plane);
112 strides[plane] = IOSurfaceGetBytesPerRowOfPlane(io_surface_, plane);
113 } 115 }
114 116
115 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { 117 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const {
116 gfx::GpuMemoryBufferHandle handle; 118 gfx::GpuMemoryBufferHandle handle;
117 handle.type = gfx::IO_SURFACE_BUFFER; 119 handle.type = gfx::IO_SURFACE_BUFFER;
118 handle.id = id_; 120 handle.id = id_;
119 return handle; 121 return handle;
120 } 122 }
121 123
122 } // namespace content 124 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698