OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/gfx/mac/io_surface_manager.h" | 5 #include "ui/gfx/mac/io_surface_manager.h" |
6 | 6 |
7 #include <IOSurface/IOSurface.h> | 7 #include <IOSurface/IOSurface.h> |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
8 | 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/mac/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
| 13 #include "base/macros.h" |
11 #include "ui/gfx/buffer_format_util.h" | 14 #include "ui/gfx/buffer_format_util.h" |
12 | 15 |
13 namespace gfx { | 16 namespace gfx { |
14 namespace { | 17 namespace { |
15 | 18 |
16 IOSurfaceManager* g_instance = NULL; | 19 IOSurfaceManager* g_instance = NULL; |
17 | 20 |
18 void AddIntegerValue(CFMutableDictionaryRef dictionary, | 21 void AddIntegerValue(CFMutableDictionaryRef dictionary, |
19 const CFStringRef key, | 22 const CFStringRef key, |
20 int32 value) { | 23 int32_t value) { |
21 base::ScopedCFTypeRef<CFNumberRef> number( | 24 base::ScopedCFTypeRef<CFNumberRef> number( |
22 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); | 25 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); |
23 CFDictionaryAddValue(dictionary, key, number.get()); | 26 CFDictionaryAddValue(dictionary, key, number.get()); |
24 } | 27 } |
25 | 28 |
26 int32 BytesPerElement(gfx::BufferFormat format, int plane) { | 29 int32_t BytesPerElement(gfx::BufferFormat format, int plane) { |
27 switch (format) { | 30 switch (format) { |
28 case gfx::BufferFormat::R_8: | 31 case gfx::BufferFormat::R_8: |
29 DCHECK_EQ(plane, 0); | 32 DCHECK_EQ(plane, 0); |
30 return 1; | 33 return 1; |
31 case gfx::BufferFormat::BGRA_8888: | 34 case gfx::BufferFormat::BGRA_8888: |
32 case gfx::BufferFormat::RGBA_8888: | 35 case gfx::BufferFormat::RGBA_8888: |
33 DCHECK_EQ(plane, 0); | 36 DCHECK_EQ(plane, 0); |
34 return 4; | 37 return 4; |
35 case gfx::BufferFormat::YUV_420_BIPLANAR: | 38 case gfx::BufferFormat::YUV_420_BIPLANAR: |
36 static int32 bytes_per_element[] = {1, 2}; | 39 static int32_t bytes_per_element[] = {1, 2}; |
37 DCHECK_LT(static_cast<size_t>(plane), arraysize(bytes_per_element)); | 40 DCHECK_LT(static_cast<size_t>(plane), arraysize(bytes_per_element)); |
38 return bytes_per_element[plane]; | 41 return bytes_per_element[plane]; |
39 case gfx::BufferFormat::UYVY_422: | 42 case gfx::BufferFormat::UYVY_422: |
40 DCHECK_EQ(plane, 0); | 43 DCHECK_EQ(plane, 0); |
41 return 2; | 44 return 2; |
42 case gfx::BufferFormat::ATC: | 45 case gfx::BufferFormat::ATC: |
43 case gfx::BufferFormat::ATCIA: | 46 case gfx::BufferFormat::ATCIA: |
44 case gfx::BufferFormat::DXT1: | 47 case gfx::BufferFormat::DXT1: |
45 case gfx::BufferFormat::DXT5: | 48 case gfx::BufferFormat::DXT5: |
46 case gfx::BufferFormat::ETC1: | 49 case gfx::BufferFormat::ETC1: |
47 case gfx::BufferFormat::RGBA_4444: | 50 case gfx::BufferFormat::RGBA_4444: |
48 case gfx::BufferFormat::RGBX_8888: | 51 case gfx::BufferFormat::RGBX_8888: |
49 case gfx::BufferFormat::BGRX_8888: | 52 case gfx::BufferFormat::BGRX_8888: |
50 case gfx::BufferFormat::YUV_420: | 53 case gfx::BufferFormat::YUV_420: |
51 NOTREACHED(); | 54 NOTREACHED(); |
52 return 0; | 55 return 0; |
53 } | 56 } |
54 | 57 |
55 NOTREACHED(); | 58 NOTREACHED(); |
56 return 0; | 59 return 0; |
57 } | 60 } |
58 | 61 |
59 int32 PixelFormat(gfx::BufferFormat format) { | 62 int32_t PixelFormat(gfx::BufferFormat format) { |
60 switch (format) { | 63 switch (format) { |
61 case gfx::BufferFormat::R_8: | 64 case gfx::BufferFormat::R_8: |
62 return 'L008'; | 65 return 'L008'; |
63 case gfx::BufferFormat::BGRA_8888: | 66 case gfx::BufferFormat::BGRA_8888: |
64 case gfx::BufferFormat::RGBA_8888: | 67 case gfx::BufferFormat::RGBA_8888: |
65 return 'BGRA'; | 68 return 'BGRA'; |
66 case gfx::BufferFormat::YUV_420_BIPLANAR: | 69 case gfx::BufferFormat::YUV_420_BIPLANAR: |
67 return '420v'; | 70 return '420v'; |
68 case gfx::BufferFormat::UYVY_422: | 71 case gfx::BufferFormat::UYVY_422: |
69 return '2vuy'; | 72 return '2vuy'; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 CFDictionaryAddValue(properties, kIOSurfacePlaneInfo, planes); | 140 CFDictionaryAddValue(properties, kIOSurfacePlaneInfo, planes); |
138 } else { | 141 } else { |
139 AddIntegerValue(properties, kIOSurfaceBytesPerElement, | 142 AddIntegerValue(properties, kIOSurfaceBytesPerElement, |
140 BytesPerElement(format, 0)); | 143 BytesPerElement(format, 0)); |
141 } | 144 } |
142 | 145 |
143 return IOSurfaceCreate(properties); | 146 return IOSurfaceCreate(properties); |
144 } | 147 } |
145 | 148 |
146 } // namespace content | 149 } // namespace content |
OLD | NEW |