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

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

Issue 701033005: content: Move type selection logic out of GpuMemoryBufferImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review feedback Created 6 years, 1 month 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/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/common/gpu/client/gpu_memory_buffer_factory_host.h" 9 #include "content/common/gpu/client/gpu_memory_buffer_factory_host.h"
10 #include "ui/gl/gl_bindings.h" 10 #include "ui/gl/gl_bindings.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 case MAP: 139 case MAP:
140 return true; 140 return true;
141 case SCANOUT: 141 case SCANOUT:
142 return false; 142 return false;
143 } 143 }
144 144
145 NOTREACHED(); 145 NOTREACHED();
146 return false; 146 return false;
147 } 147 }
148 148
149 // static
150 bool GpuMemoryBufferImplIOSurface::IsConfigurationSupported(Format format,
151 Usage usage) {
152 return IsFormatSupported(format) && IsUsageSupported(usage);
153 }
154
155 // static
156 uint32 GpuMemoryBufferImplIOSurface::PixelFormat(Format format) {
157 switch (format) {
158 case BGRA_8888:
159 return 'BGRA';
160 case RGBA_8888:
161 case RGBX_8888:
162 NOTREACHED();
163 return 0;
164 }
165
166 NOTREACHED();
167 return 0;
168 }
169
170 void* GpuMemoryBufferImplIOSurface::Map() { 149 void* GpuMemoryBufferImplIOSurface::Map() {
171 DCHECK(!mapped_); 150 DCHECK(!mapped_);
172 IOSurfaceLock(io_surface_, 0, NULL); 151 IOSurfaceLock(io_surface_, 0, NULL);
173 mapped_ = true; 152 mapped_ = true;
174 return IOSurfaceGetBaseAddress(io_surface_); 153 return IOSurfaceGetBaseAddress(io_surface_);
175 } 154 }
176 155
177 void GpuMemoryBufferImplIOSurface::Unmap() { 156 void GpuMemoryBufferImplIOSurface::Unmap() {
178 DCHECK(mapped_); 157 DCHECK(mapped_);
179 IOSurfaceUnlock(io_surface_, 0, NULL); 158 IOSurfaceUnlock(io_surface_, 0, NULL);
180 mapped_ = false; 159 mapped_ = false;
181 } 160 }
182 161
183 uint32 GpuMemoryBufferImplIOSurface::GetStride() const { 162 uint32 GpuMemoryBufferImplIOSurface::GetStride() const {
184 return IOSurfaceGetBytesPerRow(io_surface_); 163 return IOSurfaceGetBytesPerRow(io_surface_);
185 } 164 }
186 165
187 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { 166 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const {
188 gfx::GpuMemoryBufferHandle handle; 167 gfx::GpuMemoryBufferHandle handle;
189 handle.type = gfx::IO_SURFACE_BUFFER; 168 handle.type = gfx::IO_SURFACE_BUFFER;
190 handle.id = id_; 169 handle.id = id_;
191 handle.io_surface_id = IOSurfaceGetID(io_surface_); 170 handle.io_surface_id = IOSurfaceGetID(io_surface_);
192 return handle; 171 return handle;
193 } 172 }
194 173
195 } // namespace content 174 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698