| 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 "ui/ozone/platform/drm/common/drm_util.h" | 5 #include "ui/ozone/platform/drm/common/drm_util.h" |
| 6 | 6 |
| 7 #include <drm_fourcc.h> | 7 #include <drm_fourcc.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 case gfx::BufferFormat::RGBX_8888: | 320 case gfx::BufferFormat::RGBX_8888: |
| 321 return DRM_FORMAT_XBGR8888; | 321 return DRM_FORMAT_XBGR8888; |
| 322 case gfx::BufferFormat::BGRA_8888: | 322 case gfx::BufferFormat::BGRA_8888: |
| 323 return DRM_FORMAT_ARGB8888; | 323 return DRM_FORMAT_ARGB8888; |
| 324 case gfx::BufferFormat::BGRX_8888: | 324 case gfx::BufferFormat::BGRX_8888: |
| 325 return DRM_FORMAT_XRGB8888; | 325 return DRM_FORMAT_XRGB8888; |
| 326 case gfx::BufferFormat::BGR_565: | 326 case gfx::BufferFormat::BGR_565: |
| 327 return DRM_FORMAT_RGB565; | 327 return DRM_FORMAT_RGB565; |
| 328 case gfx::BufferFormat::UYVY_422: | 328 case gfx::BufferFormat::UYVY_422: |
| 329 return DRM_FORMAT_UYVY; | 329 return DRM_FORMAT_UYVY; |
| 330 case gfx::BufferFormat::YUYV_422: |
| 331 return DRM_FORMAT_YUYV; |
| 330 case gfx::BufferFormat::YVU_420: | 332 case gfx::BufferFormat::YVU_420: |
| 331 return DRM_FORMAT_YV12; | 333 return DRM_FORMAT_YV12; |
| 332 case gfx::BufferFormat::YUV_420_BIPLANAR: | 334 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 333 return DRM_FORMAT_NV12; | 335 return DRM_FORMAT_NV12; |
| 334 default: | 336 default: |
| 335 NOTREACHED(); | 337 NOTREACHED(); |
| 336 return 0; | 338 return 0; |
| 337 } | 339 } |
| 338 } | 340 } |
| 339 | 341 |
| 340 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { | 342 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { |
| 341 switch (format) { | 343 switch (format) { |
| 342 case DRM_FORMAT_R8: | 344 case DRM_FORMAT_R8: |
| 343 return gfx::BufferFormat::R_8; | 345 return gfx::BufferFormat::R_8; |
| 344 case DRM_FORMAT_GR88: | 346 case DRM_FORMAT_GR88: |
| 345 return gfx::BufferFormat::RG_88; | 347 return gfx::BufferFormat::RG_88; |
| 346 case DRM_FORMAT_ABGR8888: | 348 case DRM_FORMAT_ABGR8888: |
| 347 return gfx::BufferFormat::RGBA_8888; | 349 return gfx::BufferFormat::RGBA_8888; |
| 348 case DRM_FORMAT_XBGR8888: | 350 case DRM_FORMAT_XBGR8888: |
| 349 return gfx::BufferFormat::RGBX_8888; | 351 return gfx::BufferFormat::RGBX_8888; |
| 350 case DRM_FORMAT_ARGB8888: | 352 case DRM_FORMAT_ARGB8888: |
| 351 return gfx::BufferFormat::BGRA_8888; | 353 return gfx::BufferFormat::BGRA_8888; |
| 352 case DRM_FORMAT_XRGB8888: | 354 case DRM_FORMAT_XRGB8888: |
| 353 return gfx::BufferFormat::BGRX_8888; | 355 return gfx::BufferFormat::BGRX_8888; |
| 354 case DRM_FORMAT_RGB565: | 356 case DRM_FORMAT_RGB565: |
| 355 return gfx::BufferFormat::BGR_565; | 357 return gfx::BufferFormat::BGR_565; |
| 356 case DRM_FORMAT_UYVY: | 358 case DRM_FORMAT_UYVY: |
| 357 return gfx::BufferFormat::UYVY_422; | 359 return gfx::BufferFormat::UYVY_422; |
| 360 case DRM_FORMAT_YUYV: |
| 361 return gfx::BufferFormat::YUYV_422; |
| 358 case DRM_FORMAT_NV12: | 362 case DRM_FORMAT_NV12: |
| 359 return gfx::BufferFormat::YUV_420_BIPLANAR; | 363 return gfx::BufferFormat::YUV_420_BIPLANAR; |
| 360 case DRM_FORMAT_YV12: | 364 case DRM_FORMAT_YV12: |
| 361 return gfx::BufferFormat::YVU_420; | 365 return gfx::BufferFormat::YVU_420; |
| 362 default: | 366 default: |
| 363 NOTREACHED(); | 367 NOTREACHED(); |
| 364 return gfx::BufferFormat::BGRA_8888; | 368 return gfx::BufferFormat::BGRA_8888; |
| 365 } | 369 } |
| 366 } | 370 } |
| 367 | 371 |
| 368 int GetFourCCFormatForFramebuffer(gfx::BufferFormat format) { | 372 int GetFourCCFormatForFramebuffer(gfx::BufferFormat format) { |
| 369 // Currently, drm supports 24 bitcolordepth for hardware overlay. | 373 // Currently, drm supports 24 bitcolordepth for hardware overlay. |
| 370 switch (format) { | 374 switch (format) { |
| 371 case gfx::BufferFormat::RGBA_8888: | 375 case gfx::BufferFormat::RGBA_8888: |
| 372 case gfx::BufferFormat::RGBX_8888: | 376 case gfx::BufferFormat::RGBX_8888: |
| 373 return DRM_FORMAT_XBGR8888; | 377 return DRM_FORMAT_XBGR8888; |
| 374 case gfx::BufferFormat::BGRA_8888: | 378 case gfx::BufferFormat::BGRA_8888: |
| 375 case gfx::BufferFormat::BGRX_8888: | 379 case gfx::BufferFormat::BGRX_8888: |
| 376 return DRM_FORMAT_XRGB8888; | 380 return DRM_FORMAT_XRGB8888; |
| 377 case gfx::BufferFormat::BGR_565: | 381 case gfx::BufferFormat::BGR_565: |
| 378 return DRM_FORMAT_RGB565; | 382 return DRM_FORMAT_RGB565; |
| 379 case gfx::BufferFormat::UYVY_422: | 383 case gfx::BufferFormat::UYVY_422: |
| 380 return DRM_FORMAT_UYVY; | 384 return DRM_FORMAT_UYVY; |
| 385 case gfx::BufferFormat::YUYV_422: |
| 386 return DRM_FORMAT_YUYV; |
| 381 default: | 387 default: |
| 382 NOTREACHED(); | 388 NOTREACHED(); |
| 383 return 0; | 389 return 0; |
| 384 } | 390 } |
| 385 } | 391 } |
| 386 } // namespace ui | 392 } // namespace ui |
| OLD | NEW |