| 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 12 matching lines...) Expand all Loading... |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 #if !defined(DRM_CAP_CURSOR_HEIGHT) | 25 #if !defined(DRM_CAP_CURSOR_HEIGHT) |
| 26 #define DRM_CAP_CURSOR_HEIGHT 0x9 | 26 #define DRM_CAP_CURSOR_HEIGHT 0x9 |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 #if !defined(DRM_FORMAT_R8) | 29 #if !defined(DRM_FORMAT_R8) |
| 30 // TODO(dshwang): after most linux and libdrm has this definition, remove it. | 30 // TODO(dshwang): after most linux and libdrm has this definition, remove it. |
| 31 #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') | 31 #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') |
| 32 #endif | 32 #endif |
| 33 #if !defined(DRM_FORMAT_GR88) |
| 34 // TODO(dshwang): after most linux and libdrm has this definition, remove it. |
| 35 #define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') |
| 36 #endif |
| 33 #if !defined(DRM_FORMAT_YV12) | 37 #if !defined(DRM_FORMAT_YV12) |
| 34 // TODO(dcastagna): after libdrm has this definition, remove it. | 38 // TODO(dcastagna): after libdrm has this definition, remove it. |
| 35 #define DRM_FORMAT_YV12 fourcc_code('Y', 'V', '1', '2') | 39 #define DRM_FORMAT_YV12 fourcc_code('Y', 'V', '1', '2') |
| 36 #endif | 40 #endif |
| 37 | 41 |
| 38 namespace ui { | 42 namespace ui { |
| 39 | 43 |
| 40 namespace { | 44 namespace { |
| 41 | 45 |
| 42 static const size_t kDefaultCursorWidth = 64; | 46 static const size_t kDefaultCursorWidth = 64; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 params.native_mode = params.modes.front(); | 326 params.native_mode = params.modes.front(); |
| 323 } | 327 } |
| 324 | 328 |
| 325 return params; | 329 return params; |
| 326 } | 330 } |
| 327 | 331 |
| 328 int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) { | 332 int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) { |
| 329 switch (format) { | 333 switch (format) { |
| 330 case gfx::BufferFormat::R_8: | 334 case gfx::BufferFormat::R_8: |
| 331 return DRM_FORMAT_R8; | 335 return DRM_FORMAT_R8; |
| 336 case gfx::BufferFormat::RG_88: |
| 337 return DRM_FORMAT_GR88; |
| 332 case gfx::BufferFormat::RGBA_8888: | 338 case gfx::BufferFormat::RGBA_8888: |
| 333 return DRM_FORMAT_ABGR8888; | 339 return DRM_FORMAT_ABGR8888; |
| 334 case gfx::BufferFormat::RGBX_8888: | 340 case gfx::BufferFormat::RGBX_8888: |
| 335 return DRM_FORMAT_XBGR8888; | 341 return DRM_FORMAT_XBGR8888; |
| 336 case gfx::BufferFormat::BGRA_8888: | 342 case gfx::BufferFormat::BGRA_8888: |
| 337 return DRM_FORMAT_ARGB8888; | 343 return DRM_FORMAT_ARGB8888; |
| 338 case gfx::BufferFormat::BGRX_8888: | 344 case gfx::BufferFormat::BGRX_8888: |
| 339 return DRM_FORMAT_XRGB8888; | 345 return DRM_FORMAT_XRGB8888; |
| 340 case gfx::BufferFormat::BGR_565: | 346 case gfx::BufferFormat::BGR_565: |
| 341 return DRM_FORMAT_RGB565; | 347 return DRM_FORMAT_RGB565; |
| 342 case gfx::BufferFormat::UYVY_422: | 348 case gfx::BufferFormat::UYVY_422: |
| 343 return DRM_FORMAT_UYVY; | 349 return DRM_FORMAT_UYVY; |
| 344 case gfx::BufferFormat::YVU_420: | 350 case gfx::BufferFormat::YVU_420: |
| 345 return DRM_FORMAT_YV12; | 351 return DRM_FORMAT_YV12; |
| 346 default: | 352 default: |
| 347 NOTREACHED(); | 353 NOTREACHED(); |
| 348 return 0; | 354 return 0; |
| 349 } | 355 } |
| 350 } | 356 } |
| 351 | 357 |
| 352 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { | 358 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { |
| 353 switch (format) { | 359 switch (format) { |
| 354 case DRM_FORMAT_R8: | 360 case DRM_FORMAT_R8: |
| 355 return gfx::BufferFormat::R_8; | 361 return gfx::BufferFormat::R_8; |
| 362 case DRM_FORMAT_GR88: |
| 363 return gfx::BufferFormat::RG_88; |
| 356 case DRM_FORMAT_ABGR8888: | 364 case DRM_FORMAT_ABGR8888: |
| 357 return gfx::BufferFormat::RGBA_8888; | 365 return gfx::BufferFormat::RGBA_8888; |
| 358 case DRM_FORMAT_XBGR8888: | 366 case DRM_FORMAT_XBGR8888: |
| 359 return gfx::BufferFormat::RGBX_8888; | 367 return gfx::BufferFormat::RGBX_8888; |
| 360 case DRM_FORMAT_ARGB8888: | 368 case DRM_FORMAT_ARGB8888: |
| 361 return gfx::BufferFormat::BGRA_8888; | 369 return gfx::BufferFormat::BGRA_8888; |
| 362 case DRM_FORMAT_XRGB8888: | 370 case DRM_FORMAT_XRGB8888: |
| 363 return gfx::BufferFormat::BGRX_8888; | 371 return gfx::BufferFormat::BGRX_8888; |
| 364 case DRM_FORMAT_RGB565: | 372 case DRM_FORMAT_RGB565: |
| 365 return gfx::BufferFormat::BGR_565; | 373 return gfx::BufferFormat::BGR_565; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 385 case gfx::BufferFormat::BGR_565: | 393 case gfx::BufferFormat::BGR_565: |
| 386 return DRM_FORMAT_RGB565; | 394 return DRM_FORMAT_RGB565; |
| 387 case gfx::BufferFormat::UYVY_422: | 395 case gfx::BufferFormat::UYVY_422: |
| 388 return DRM_FORMAT_UYVY; | 396 return DRM_FORMAT_UYVY; |
| 389 default: | 397 default: |
| 390 NOTREACHED(); | 398 NOTREACHED(); |
| 391 return 0; | 399 return 0; |
| 392 } | 400 } |
| 393 } | 401 } |
| 394 } // namespace ui | 402 } // namespace ui |
| OLD | NEW |