OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gpu_memory_buffer_factory_io_surface.h" | 5 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/gfx/buffer_format_util.h" | 10 #include "ui/gfx/buffer_format_util.h" |
11 #include "ui/gfx/mac/io_surface.h" | 11 #include "ui/gfx/mac/io_surface.h" |
12 #include "ui/gl/gl_image_io_surface.h" | 12 #include "ui/gl/gl_image_io_surface.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 GpuMemoryBufferFactoryIOSurface::GpuMemoryBufferFactoryIOSurface() { | 16 GpuMemoryBufferFactoryIOSurface::GpuMemoryBufferFactoryIOSurface() { |
17 } | 17 } |
18 | 18 |
19 GpuMemoryBufferFactoryIOSurface::~GpuMemoryBufferFactoryIOSurface() { | 19 GpuMemoryBufferFactoryIOSurface::~GpuMemoryBufferFactoryIOSurface() { |
20 } | 20 } |
21 | 21 |
22 // static | |
23 bool GpuMemoryBufferFactoryIOSurface::IsGpuMemoryBufferConfigurationSupported( | |
24 gfx::BufferFormat format, | |
25 gfx::BufferUsage usage) { | |
26 switch (usage) { | |
27 case gfx::BufferUsage::GPU_READ: | |
28 case gfx::BufferUsage::SCANOUT: | |
29 return format == gfx::BufferFormat::BGRA_8888 || | |
30 format == gfx::BufferFormat::RGBA_8888; | |
31 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | |
32 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | |
33 return format == gfx::BufferFormat::R_8 || | |
34 format == gfx::BufferFormat::BGRA_8888 || | |
35 format == gfx::BufferFormat::UYVY_422 || | |
36 format == gfx::BufferFormat::YUV_420_BIPLANAR; | |
37 } | |
38 NOTREACHED(); | |
39 return false; | |
40 } | |
41 | |
42 gfx::GpuMemoryBufferHandle | 22 gfx::GpuMemoryBufferHandle |
43 GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer( | 23 GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer( |
44 gfx::GpuMemoryBufferId id, | 24 gfx::GpuMemoryBufferId id, |
45 const gfx::Size& size, | 25 const gfx::Size& size, |
46 gfx::BufferFormat format, | 26 gfx::BufferFormat format, |
47 gfx::BufferUsage usage, | 27 gfx::BufferUsage usage, |
48 int client_id, | 28 int client_id, |
49 gpu::SurfaceHandle surface_handle) { | 29 gpu::SurfaceHandle surface_handle) { |
50 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( | 30 base::ScopedCFTypeRef<IOSurfaceRef> io_surface( |
51 gfx::CreateIOSurface(size, format)); | 31 gfx::CreateIOSurface(size, format)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 91 |
112 scoped_refptr<gl::GLImageIOSurface> image( | 92 scoped_refptr<gl::GLImageIOSurface> image( |
113 new gl::GLImageIOSurface(size, internalformat)); | 93 new gl::GLImageIOSurface(size, internalformat)); |
114 if (!image->Initialize(it->second.get(), handle.id, format)) | 94 if (!image->Initialize(it->second.get(), handle.id, format)) |
115 return scoped_refptr<gl::GLImage>(); | 95 return scoped_refptr<gl::GLImage>(); |
116 | 96 |
117 return image; | 97 return image; |
118 } | 98 } |
119 | 99 |
120 } // namespace content | 100 } // namespace content |
OLD | NEW |