| 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 case gfx::BufferFormat::RGBX_8888: | 396 case gfx::BufferFormat::RGBX_8888: |
| 397 return DRM_FORMAT_XBGR8888; | 397 return DRM_FORMAT_XBGR8888; |
| 398 case gfx::BufferFormat::BGRA_8888: | 398 case gfx::BufferFormat::BGRA_8888: |
| 399 return DRM_FORMAT_ARGB8888; | 399 return DRM_FORMAT_ARGB8888; |
| 400 case gfx::BufferFormat::BGRX_8888: | 400 case gfx::BufferFormat::BGRX_8888: |
| 401 return DRM_FORMAT_XRGB8888; | 401 return DRM_FORMAT_XRGB8888; |
| 402 case gfx::BufferFormat::BGR_565: | 402 case gfx::BufferFormat::BGR_565: |
| 403 return DRM_FORMAT_RGB565; | 403 return DRM_FORMAT_RGB565; |
| 404 case gfx::BufferFormat::UYVY_422: | 404 case gfx::BufferFormat::UYVY_422: |
| 405 return DRM_FORMAT_UYVY; | 405 return DRM_FORMAT_UYVY; |
| 406 case gfx::BufferFormat::YUYV_422: |
| 407 return DRM_FORMAT_YUYV; |
| 406 case gfx::BufferFormat::YVU_420: | 408 case gfx::BufferFormat::YVU_420: |
| 407 return DRM_FORMAT_YVU420; | 409 return DRM_FORMAT_YVU420; |
| 408 case gfx::BufferFormat::YUV_420_BIPLANAR: | 410 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 409 return DRM_FORMAT_NV12; | 411 return DRM_FORMAT_NV12; |
| 410 default: | 412 default: |
| 411 NOTREACHED(); | 413 NOTREACHED(); |
| 412 return 0; | 414 return 0; |
| 413 } | 415 } |
| 414 } | 416 } |
| 415 | 417 |
| 416 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { | 418 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { |
| 417 switch (format) { | 419 switch (format) { |
| 418 case DRM_FORMAT_R8: | 420 case DRM_FORMAT_R8: |
| 419 return gfx::BufferFormat::R_8; | 421 return gfx::BufferFormat::R_8; |
| 420 case DRM_FORMAT_GR88: | 422 case DRM_FORMAT_GR88: |
| 421 return gfx::BufferFormat::RG_88; | 423 return gfx::BufferFormat::RG_88; |
| 422 case DRM_FORMAT_ABGR8888: | 424 case DRM_FORMAT_ABGR8888: |
| 423 return gfx::BufferFormat::RGBA_8888; | 425 return gfx::BufferFormat::RGBA_8888; |
| 424 case DRM_FORMAT_XBGR8888: | 426 case DRM_FORMAT_XBGR8888: |
| 425 return gfx::BufferFormat::RGBX_8888; | 427 return gfx::BufferFormat::RGBX_8888; |
| 426 case DRM_FORMAT_ARGB8888: | 428 case DRM_FORMAT_ARGB8888: |
| 427 return gfx::BufferFormat::BGRA_8888; | 429 return gfx::BufferFormat::BGRA_8888; |
| 428 case DRM_FORMAT_XRGB8888: | 430 case DRM_FORMAT_XRGB8888: |
| 429 return gfx::BufferFormat::BGRX_8888; | 431 return gfx::BufferFormat::BGRX_8888; |
| 430 case DRM_FORMAT_RGB565: | 432 case DRM_FORMAT_RGB565: |
| 431 return gfx::BufferFormat::BGR_565; | 433 return gfx::BufferFormat::BGR_565; |
| 432 case DRM_FORMAT_UYVY: | 434 case DRM_FORMAT_UYVY: |
| 433 return gfx::BufferFormat::UYVY_422; | 435 return gfx::BufferFormat::UYVY_422; |
| 436 case DRM_FORMAT_YUYV: |
| 437 return gfx::BufferFormat::YUYV_422; |
| 434 case DRM_FORMAT_NV12: | 438 case DRM_FORMAT_NV12: |
| 435 return gfx::BufferFormat::YUV_420_BIPLANAR; | 439 return gfx::BufferFormat::YUV_420_BIPLANAR; |
| 436 case DRM_FORMAT_YVU420: | 440 case DRM_FORMAT_YVU420: |
| 437 return gfx::BufferFormat::YVU_420; | 441 return gfx::BufferFormat::YVU_420; |
| 438 default: | 442 default: |
| 439 NOTREACHED(); | 443 NOTREACHED(); |
| 440 return gfx::BufferFormat::BGRA_8888; | 444 return gfx::BufferFormat::BGRA_8888; |
| 441 } | 445 } |
| 442 } | 446 } |
| 443 | 447 |
| 444 int GetFourCCFormatForOpaqueFramebuffer(gfx::BufferFormat format) { | 448 int GetFourCCFormatForOpaqueFramebuffer(gfx::BufferFormat format) { |
| 445 // DRM atomic interface doesn't currently support specifying an alpha | 449 // DRM atomic interface doesn't currently support specifying an alpha |
| 446 // blending. We can simulate disabling alpha bleding creating an fb | 450 // blending. We can simulate disabling alpha bleding creating an fb |
| 447 // with a format without the alpha channel. | 451 // with a format without the alpha channel. |
| 448 switch (format) { | 452 switch (format) { |
| 449 case gfx::BufferFormat::RGBA_8888: | 453 case gfx::BufferFormat::RGBA_8888: |
| 450 case gfx::BufferFormat::RGBX_8888: | 454 case gfx::BufferFormat::RGBX_8888: |
| 451 return DRM_FORMAT_XBGR8888; | 455 return DRM_FORMAT_XBGR8888; |
| 452 case gfx::BufferFormat::BGRA_8888: | 456 case gfx::BufferFormat::BGRA_8888: |
| 453 case gfx::BufferFormat::BGRX_8888: | 457 case gfx::BufferFormat::BGRX_8888: |
| 454 return DRM_FORMAT_XRGB8888; | 458 return DRM_FORMAT_XRGB8888; |
| 455 case gfx::BufferFormat::BGR_565: | 459 case gfx::BufferFormat::BGR_565: |
| 456 return DRM_FORMAT_RGB565; | 460 return DRM_FORMAT_RGB565; |
| 457 case gfx::BufferFormat::UYVY_422: | 461 case gfx::BufferFormat::UYVY_422: |
| 458 return DRM_FORMAT_UYVY; | 462 return DRM_FORMAT_UYVY; |
| 459 case gfx::BufferFormat::YUV_420_BIPLANAR: | 463 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 460 return DRM_FORMAT_NV12; | 464 return DRM_FORMAT_NV12; |
| 461 case gfx::BufferFormat::YVU_420: | 465 case gfx::BufferFormat::YVU_420: |
| 462 return DRM_FORMAT_YVU420; | 466 return DRM_FORMAT_YVU420; |
| 467 case gfx::BufferFormat::YUYV_422: |
| 468 return DRM_FORMAT_YUYV; |
| 463 default: | 469 default: |
| 464 NOTREACHED(); | 470 NOTREACHED(); |
| 465 return 0; | 471 return 0; |
| 466 } | 472 } |
| 467 } | 473 } |
| 468 } // namespace ui | 474 } // namespace ui |
| OLD | NEW |