OLD | NEW |
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 "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
9 #include "ui/gl/io_surface_support_mac.h" | 9 #include "ui/gl/io_surface_support_mac.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface( | 13 GpuMemoryBufferImplIOSurface::GpuMemoryBufferImplIOSurface( |
14 gfx::Size size, | 14 const gfx::Size& size, |
15 unsigned internalformat) | 15 unsigned internalformat) |
16 : GpuMemoryBufferImpl(size, internalformat), | 16 : GpuMemoryBufferImpl(size, internalformat), |
17 io_surface_support_(IOSurfaceSupport::Initialize()) { | 17 io_surface_support_(IOSurfaceSupport::Initialize()) { |
18 CHECK(io_surface_support_); | 18 CHECK(io_surface_support_); |
19 } | 19 } |
20 | 20 |
21 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() {} | 21 GpuMemoryBufferImplIOSurface::~GpuMemoryBufferImplIOSurface() {} |
22 | 22 |
23 // static | 23 // static |
24 bool GpuMemoryBufferImplIOSurface::IsFormatSupported(unsigned internalformat) { | 24 bool GpuMemoryBufferImplIOSurface::IsFormatSupported(unsigned internalformat) { |
25 switch (internalformat) { | 25 switch (internalformat) { |
26 case GL_BGRA8_EXT: | 26 case GL_BGRA8_EXT: |
27 return true; | 27 return true; |
28 default: | 28 default: |
29 return false; | 29 return false; |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 // static | 33 // static |
34 uint32 GpuMemoryBufferImplIOSurface::PixelFormat(unsigned internalformat) { | 34 uint32 GpuMemoryBufferImplIOSurface::PixelFormat(unsigned internalformat) { |
35 switch (internalformat) { | 35 switch (internalformat) { |
36 case GL_BGRA8_EXT: | 36 case GL_BGRA8_EXT: |
37 return 'BGRA'; | 37 return 'BGRA'; |
38 default: | 38 default: |
39 NOTREACHED(); | 39 NOTREACHED(); |
40 return 0; | 40 return 0; |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 bool GpuMemoryBufferImplIOSurface::Initialize( | 44 bool GpuMemoryBufferImplIOSurface::InitializeFromHandle( |
45 gfx::GpuMemoryBufferHandle handle) { | 45 gfx::GpuMemoryBufferHandle handle) { |
46 io_surface_.reset(io_surface_support_->IOSurfaceLookup(handle.io_surface_id)); | 46 io_surface_.reset(io_surface_support_->IOSurfaceLookup(handle.io_surface_id)); |
47 if (!io_surface_) { | 47 if (!io_surface_) { |
48 VLOG(1) << "IOSurface lookup failed"; | 48 VLOG(1) << "IOSurface lookup failed"; |
49 return false; | 49 return false; |
50 } | 50 } |
51 | 51 |
52 return true; | 52 return true; |
53 } | 53 } |
54 | 54 |
(...skipping 15 matching lines...) Expand all Loading... |
70 } | 70 } |
71 | 71 |
72 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { | 72 gfx::GpuMemoryBufferHandle GpuMemoryBufferImplIOSurface::GetHandle() const { |
73 gfx::GpuMemoryBufferHandle handle; | 73 gfx::GpuMemoryBufferHandle handle; |
74 handle.type = gfx::IO_SURFACE_BUFFER; | 74 handle.type = gfx::IO_SURFACE_BUFFER; |
75 handle.io_surface_id = io_surface_support_->IOSurfaceGetID(io_surface_); | 75 handle.io_surface_id = io_surface_support_->IOSurfaceGetID(io_surface_); |
76 return handle; | 76 return handle; |
77 } | 77 } |
78 | 78 |
79 } // namespace content | 79 } // namespace content |
OLD | NEW |