| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 case gfx::BufferFormat::RGBX_8888: | 371 case gfx::BufferFormat::RGBX_8888: |
| 372 return DRM_FORMAT_XBGR8888; | 372 return DRM_FORMAT_XBGR8888; |
| 373 case gfx::BufferFormat::BGRA_8888: | 373 case gfx::BufferFormat::BGRA_8888: |
| 374 return DRM_FORMAT_ARGB8888; | 374 return DRM_FORMAT_ARGB8888; |
| 375 case gfx::BufferFormat::BGRX_8888: | 375 case gfx::BufferFormat::BGRX_8888: |
| 376 return DRM_FORMAT_XRGB8888; | 376 return DRM_FORMAT_XRGB8888; |
| 377 case gfx::BufferFormat::BGR_565: | 377 case gfx::BufferFormat::BGR_565: |
| 378 return DRM_FORMAT_RGB565; | 378 return DRM_FORMAT_RGB565; |
| 379 case gfx::BufferFormat::UYVY_422: | 379 case gfx::BufferFormat::UYVY_422: |
| 380 return DRM_FORMAT_UYVY; | 380 return DRM_FORMAT_UYVY; |
| 381 case gfx::BufferFormat::YUYV_422: |
| 382 return DRM_FORMAT_YUYV; |
| 381 case gfx::BufferFormat::YVU_420: | 383 case gfx::BufferFormat::YVU_420: |
| 382 return DRM_FORMAT_YVU420; | 384 return DRM_FORMAT_YVU420; |
| 383 case gfx::BufferFormat::YUV_420_BIPLANAR: | 385 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 384 return DRM_FORMAT_NV12; | 386 return DRM_FORMAT_NV12; |
| 385 default: | 387 default: |
| 386 NOTREACHED(); | 388 NOTREACHED(); |
| 387 return 0; | 389 return 0; |
| 388 } | 390 } |
| 389 } | 391 } |
| 390 | 392 |
| 391 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { | 393 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { |
| 392 switch (format) { | 394 switch (format) { |
| 393 case DRM_FORMAT_R8: | 395 case DRM_FORMAT_R8: |
| 394 return gfx::BufferFormat::R_8; | 396 return gfx::BufferFormat::R_8; |
| 395 case DRM_FORMAT_GR88: | 397 case DRM_FORMAT_GR88: |
| 396 return gfx::BufferFormat::RG_88; | 398 return gfx::BufferFormat::RG_88; |
| 397 case DRM_FORMAT_ABGR8888: | 399 case DRM_FORMAT_ABGR8888: |
| 398 return gfx::BufferFormat::RGBA_8888; | 400 return gfx::BufferFormat::RGBA_8888; |
| 399 case DRM_FORMAT_XBGR8888: | 401 case DRM_FORMAT_XBGR8888: |
| 400 return gfx::BufferFormat::RGBX_8888; | 402 return gfx::BufferFormat::RGBX_8888; |
| 401 case DRM_FORMAT_ARGB8888: | 403 case DRM_FORMAT_ARGB8888: |
| 402 return gfx::BufferFormat::BGRA_8888; | 404 return gfx::BufferFormat::BGRA_8888; |
| 403 case DRM_FORMAT_XRGB8888: | 405 case DRM_FORMAT_XRGB8888: |
| 404 return gfx::BufferFormat::BGRX_8888; | 406 return gfx::BufferFormat::BGRX_8888; |
| 405 case DRM_FORMAT_RGB565: | 407 case DRM_FORMAT_RGB565: |
| 406 return gfx::BufferFormat::BGR_565; | 408 return gfx::BufferFormat::BGR_565; |
| 407 case DRM_FORMAT_UYVY: | 409 case DRM_FORMAT_UYVY: |
| 408 return gfx::BufferFormat::UYVY_422; | 410 return gfx::BufferFormat::UYVY_422; |
| 411 case DRM_FORMAT_YUYV: |
| 412 return gfx::BufferFormat::YUYV_422; |
| 409 case DRM_FORMAT_NV12: | 413 case DRM_FORMAT_NV12: |
| 410 return gfx::BufferFormat::YUV_420_BIPLANAR; | 414 return gfx::BufferFormat::YUV_420_BIPLANAR; |
| 411 case DRM_FORMAT_YVU420: | 415 case DRM_FORMAT_YVU420: |
| 412 return gfx::BufferFormat::YVU_420; | 416 return gfx::BufferFormat::YVU_420; |
| 413 default: | 417 default: |
| 414 NOTREACHED(); | 418 NOTREACHED(); |
| 415 return gfx::BufferFormat::BGRA_8888; | 419 return gfx::BufferFormat::BGRA_8888; |
| 416 } | 420 } |
| 417 } | 421 } |
| 418 | 422 |
| 419 int GetFourCCFormatForOpaqueFramebuffer(gfx::BufferFormat format) { | 423 int GetFourCCFormatForOpaqueFramebuffer(gfx::BufferFormat format) { |
| 420 // DRM atomic interface doesn't currently support specifying an alpha | 424 // DRM atomic interface doesn't currently support specifying an alpha |
| 421 // blending. We can simulate disabling alpha bleding creating an fb | 425 // blending. We can simulate disabling alpha bleding creating an fb |
| 422 // with a format without the alpha channel. | 426 // with a format without the alpha channel. |
| 423 switch (format) { | 427 switch (format) { |
| 424 case gfx::BufferFormat::RGBA_8888: | 428 case gfx::BufferFormat::RGBA_8888: |
| 425 case gfx::BufferFormat::RGBX_8888: | 429 case gfx::BufferFormat::RGBX_8888: |
| 426 return DRM_FORMAT_XBGR8888; | 430 return DRM_FORMAT_XBGR8888; |
| 427 case gfx::BufferFormat::BGRA_8888: | 431 case gfx::BufferFormat::BGRA_8888: |
| 428 case gfx::BufferFormat::BGRX_8888: | 432 case gfx::BufferFormat::BGRX_8888: |
| 429 return DRM_FORMAT_XRGB8888; | 433 return DRM_FORMAT_XRGB8888; |
| 430 case gfx::BufferFormat::BGR_565: | 434 case gfx::BufferFormat::BGR_565: |
| 431 return DRM_FORMAT_RGB565; | 435 return DRM_FORMAT_RGB565; |
| 432 case gfx::BufferFormat::UYVY_422: | 436 case gfx::BufferFormat::UYVY_422: |
| 433 return DRM_FORMAT_UYVY; | 437 return DRM_FORMAT_UYVY; |
| 434 case gfx::BufferFormat::YUV_420_BIPLANAR: | 438 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 435 return DRM_FORMAT_NV12; | 439 return DRM_FORMAT_NV12; |
| 436 case gfx::BufferFormat::YVU_420: | 440 case gfx::BufferFormat::YVU_420: |
| 437 return DRM_FORMAT_YVU420; | 441 return DRM_FORMAT_YVU420; |
| 442 case gfx::BufferFormat::YUYV_422: |
| 443 return DRM_FORMAT_YUYV; |
| 438 default: | 444 default: |
| 439 NOTREACHED(); | 445 NOTREACHED(); |
| 440 return 0; | 446 return 0; |
| 441 } | 447 } |
| 442 } | 448 } |
| 443 } // namespace ui | 449 } // namespace ui |
| OLD | NEW |