| 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.h" | 5 #include "ui/gfx/mac/io_surface.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 CFDictionaryAddValue(dictionary, key, number.get()); | 25 CFDictionaryAddValue(dictionary, key, number.get()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 int32_t BytesPerElement(gfx::BufferFormat format, int plane) { | 28 int32_t BytesPerElement(gfx::BufferFormat format, int plane) { |
| 29 switch (format) { | 29 switch (format) { |
| 30 case gfx::BufferFormat::R_8: | 30 case gfx::BufferFormat::R_8: |
| 31 DCHECK_EQ(plane, 0); | 31 DCHECK_EQ(plane, 0); |
| 32 return 1; | 32 return 1; |
| 33 case gfx::BufferFormat::BGRA_8888: | 33 case gfx::BufferFormat::BGRA_8888: |
| 34 case gfx::BufferFormat::RGBA_8888: | 34 case gfx::BufferFormat::RGBA_8888: |
| 35 case gfx::BufferFormat::BGRX_8888: |
| 35 DCHECK_EQ(plane, 0); | 36 DCHECK_EQ(plane, 0); |
| 36 return 4; | 37 return 4; |
| 37 case gfx::BufferFormat::YUV_420_BIPLANAR: | 38 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 38 static int32_t bytes_per_element[] = {1, 2}; | 39 static int32_t bytes_per_element[] = {1, 2}; |
| 39 DCHECK_LT(static_cast<size_t>(plane), arraysize(bytes_per_element)); | 40 DCHECK_LT(static_cast<size_t>(plane), arraysize(bytes_per_element)); |
| 40 return bytes_per_element[plane]; | 41 return bytes_per_element[plane]; |
| 41 case gfx::BufferFormat::UYVY_422: | 42 case gfx::BufferFormat::UYVY_422: |
| 42 DCHECK_EQ(plane, 0); | 43 DCHECK_EQ(plane, 0); |
| 43 return 2; | 44 return 2; |
| 44 case gfx::BufferFormat::ATC: | 45 case gfx::BufferFormat::ATC: |
| 45 case gfx::BufferFormat::ATCIA: | 46 case gfx::BufferFormat::ATCIA: |
| 46 case gfx::BufferFormat::DXT1: | 47 case gfx::BufferFormat::DXT1: |
| 47 case gfx::BufferFormat::DXT5: | 48 case gfx::BufferFormat::DXT5: |
| 48 case gfx::BufferFormat::ETC1: | 49 case gfx::BufferFormat::ETC1: |
| 49 case gfx::BufferFormat::RGBA_4444: | 50 case gfx::BufferFormat::RGBA_4444: |
| 50 case gfx::BufferFormat::RGBX_8888: | 51 case gfx::BufferFormat::RGBX_8888: |
| 51 case gfx::BufferFormat::BGRX_8888: | |
| 52 case gfx::BufferFormat::YUV_420: | 52 case gfx::BufferFormat::YUV_420: |
| 53 NOTREACHED(); | 53 NOTREACHED(); |
| 54 return 0; | 54 return 0; |
| 55 } | 55 } |
| 56 | 56 |
| 57 NOTREACHED(); | 57 NOTREACHED(); |
| 58 return 0; | 58 return 0; |
| 59 } | 59 } |
| 60 | 60 |
| 61 int32_t PixelFormat(gfx::BufferFormat format) { | 61 int32_t PixelFormat(gfx::BufferFormat format) { |
| 62 switch (format) { | 62 switch (format) { |
| 63 case gfx::BufferFormat::R_8: | 63 case gfx::BufferFormat::R_8: |
| 64 return 'L008'; | 64 return 'L008'; |
| 65 case gfx::BufferFormat::BGRA_8888: | 65 case gfx::BufferFormat::BGRA_8888: |
| 66 case gfx::BufferFormat::RGBA_8888: | 66 case gfx::BufferFormat::RGBA_8888: |
| 67 case gfx::BufferFormat::BGRX_8888: |
| 67 return 'BGRA'; | 68 return 'BGRA'; |
| 68 case gfx::BufferFormat::YUV_420_BIPLANAR: | 69 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 69 return '420v'; | 70 return '420v'; |
| 70 case gfx::BufferFormat::UYVY_422: | 71 case gfx::BufferFormat::UYVY_422: |
| 71 return '2vuy'; | 72 return '2vuy'; |
| 72 case gfx::BufferFormat::ATC: | 73 case gfx::BufferFormat::ATC: |
| 73 case gfx::BufferFormat::ATCIA: | 74 case gfx::BufferFormat::ATCIA: |
| 74 case gfx::BufferFormat::DXT1: | 75 case gfx::BufferFormat::DXT1: |
| 75 case gfx::BufferFormat::DXT5: | 76 case gfx::BufferFormat::DXT5: |
| 76 case gfx::BufferFormat::ETC1: | 77 case gfx::BufferFormat::ETC1: |
| 77 case gfx::BufferFormat::RGBA_4444: | 78 case gfx::BufferFormat::RGBA_4444: |
| 78 case gfx::BufferFormat::RGBX_8888: | 79 case gfx::BufferFormat::RGBX_8888: |
| 79 case gfx::BufferFormat::BGRX_8888: | |
| 80 case gfx::BufferFormat::YUV_420: | 80 case gfx::BufferFormat::YUV_420: |
| 81 NOTREACHED(); | 81 NOTREACHED(); |
| 82 return 0; | 82 return 0; |
| 83 } | 83 } |
| 84 | 84 |
| 85 NOTREACHED(); | 85 NOTREACHED(); |
| 86 return 0; | 86 return 0; |
| 87 } | 87 } |
| 88 | 88 |
| 89 } // namespace | 89 } // namespace |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 IOReturn r = IOSurfaceLock(surface, 0, nullptr); | 161 IOReturn r = IOSurfaceLock(surface, 0, nullptr); |
| 162 DCHECK_EQ(kIOReturnSuccess, r); | 162 DCHECK_EQ(kIOReturnSuccess, r); |
| 163 r = IOSurfaceUnlock(surface, 0, nullptr); | 163 r = IOSurfaceUnlock(surface, 0, nullptr); |
| 164 DCHECK_EQ(kIOReturnSuccess, r); | 164 DCHECK_EQ(kIOReturnSuccess, r); |
| 165 } | 165 } |
| 166 | 166 |
| 167 return surface; | 167 return surface; |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace gfx | 170 } // namespace gfx |
| OLD | NEW |