 Chromium Code Reviews
 Chromium Code Reviews Issue 1869793002:
  Ozone GBM: support R_8 format to GpuMemoryBuffers  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1869793002:
  Ozone GBM: support R_8 format to GpuMemoryBuffers  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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> | 
| 11 #include <xf86drmMode.h> | 11 #include <xf86drmMode.h> | 
| 12 #include <utility> | 12 #include <utility> | 
| 13 | 13 | 
| 14 #include "ui/display/util/edid_parser.h" | 14 #include "ui/display/util/edid_parser.h" | 
| 15 | 15 | 
| 16 #if !defined(DRM_MODE_CONNECTOR_DSI) | 16 #if !defined(DRM_MODE_CONNECTOR_DSI) | 
| 17 #define DRM_MODE_CONNECTOR_DSI 16 | 17 #define DRM_MODE_CONNECTOR_DSI 16 | 
| 18 #endif | 18 #endif | 
| 19 | 19 | 
| 20 #ifndef DRM_FORMAT_R8 | |
| 
dnicoara
2016/05/03 14:05:50
nit: #if !defined(DRM_FORMAT_R8)
 
dshwang
2016/05/04 07:28:36
Done.
 | |
| 21 // TODO(dshwang): after most linux and libdrm has this definition, remove it. | |
| 22 #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') | |
| 23 #endif | |
| 24 | |
| 20 namespace ui { | 25 namespace ui { | 
| 21 | 26 | 
| 22 namespace { | 27 namespace { | 
| 23 | 28 | 
| 24 bool IsCrtcInUse(uint32_t crtc, | 29 bool IsCrtcInUse(uint32_t crtc, | 
| 25 const ScopedVector<HardwareDisplayControllerInfo>& displays) { | 30 const ScopedVector<HardwareDisplayControllerInfo>& displays) { | 
| 26 for (size_t i = 0; i < displays.size(); ++i) { | 31 for (size_t i = 0; i < displays.size(); ++i) { | 
| 27 if (crtc == displays[i]->crtc()->crtc_id) | 32 if (crtc == displays[i]->crtc()->crtc_id) | 
| 28 return true; | 33 return true; | 
| 29 } | 34 } | 
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 if (!params.has_native_mode && !params.modes.empty()) { | 289 if (!params.has_native_mode && !params.modes.empty()) { | 
| 285 params.has_native_mode = true; | 290 params.has_native_mode = true; | 
| 286 params.native_mode = params.modes.front(); | 291 params.native_mode = params.modes.front(); | 
| 287 } | 292 } | 
| 288 | 293 | 
| 289 return params; | 294 return params; | 
| 290 } | 295 } | 
| 291 | 296 | 
| 292 int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) { | 297 int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) { | 
| 293 switch (format) { | 298 switch (format) { | 
| 299 case gfx::BufferFormat::R_8: | |
| 300 return DRM_FORMAT_R8; | |
| 294 case gfx::BufferFormat::RGBA_8888: | 301 case gfx::BufferFormat::RGBA_8888: | 
| 295 return DRM_FORMAT_ABGR8888; | 302 return DRM_FORMAT_ABGR8888; | 
| 296 case gfx::BufferFormat::RGBX_8888: | 303 case gfx::BufferFormat::RGBX_8888: | 
| 297 return DRM_FORMAT_XBGR8888; | 304 return DRM_FORMAT_XBGR8888; | 
| 298 case gfx::BufferFormat::BGRA_8888: | 305 case gfx::BufferFormat::BGRA_8888: | 
| 299 return DRM_FORMAT_ARGB8888; | 306 return DRM_FORMAT_ARGB8888; | 
| 300 case gfx::BufferFormat::BGRX_8888: | 307 case gfx::BufferFormat::BGRX_8888: | 
| 301 return DRM_FORMAT_XRGB8888; | 308 return DRM_FORMAT_XRGB8888; | 
| 302 case gfx::BufferFormat::UYVY_422: | 309 case gfx::BufferFormat::UYVY_422: | 
| 303 return DRM_FORMAT_UYVY; | 310 return DRM_FORMAT_UYVY; | 
| 304 default: | 311 default: | 
| 305 NOTREACHED(); | 312 NOTREACHED(); | 
| 306 return 0; | 313 return 0; | 
| 307 } | 314 } | 
| 308 } | 315 } | 
| 309 | 316 | 
| 310 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { | 317 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { | 
| 311 switch (format) { | 318 switch (format) { | 
| 319 case DRM_FORMAT_R8: | |
| 320 return gfx::BufferFormat::R_8; | |
| 312 case DRM_FORMAT_ABGR8888: | 321 case DRM_FORMAT_ABGR8888: | 
| 313 return gfx::BufferFormat::RGBA_8888; | 322 return gfx::BufferFormat::RGBA_8888; | 
| 314 case DRM_FORMAT_XBGR8888: | 323 case DRM_FORMAT_XBGR8888: | 
| 315 return gfx::BufferFormat::RGBX_8888; | 324 return gfx::BufferFormat::RGBX_8888; | 
| 316 case DRM_FORMAT_ARGB8888: | 325 case DRM_FORMAT_ARGB8888: | 
| 317 return gfx::BufferFormat::BGRA_8888; | 326 return gfx::BufferFormat::BGRA_8888; | 
| 318 case DRM_FORMAT_XRGB8888: | 327 case DRM_FORMAT_XRGB8888: | 
| 319 return gfx::BufferFormat::BGRX_8888; | 328 return gfx::BufferFormat::BGRX_8888; | 
| 320 case DRM_FORMAT_UYVY: | 329 case DRM_FORMAT_UYVY: | 
| 321 return gfx::BufferFormat::UYVY_422; | 330 return gfx::BufferFormat::UYVY_422; | 
| (...skipping 13 matching lines...) Expand all Loading... | |
| 335 case gfx::BufferFormat::BGRX_8888: | 344 case gfx::BufferFormat::BGRX_8888: | 
| 336 return DRM_FORMAT_XRGB8888; | 345 return DRM_FORMAT_XRGB8888; | 
| 337 case gfx::BufferFormat::UYVY_422: | 346 case gfx::BufferFormat::UYVY_422: | 
| 338 return DRM_FORMAT_UYVY; | 347 return DRM_FORMAT_UYVY; | 
| 339 default: | 348 default: | 
| 340 NOTREACHED(); | 349 NOTREACHED(); | 
| 341 return 0; | 350 return 0; | 
| 342 } | 351 } | 
| 343 } | 352 } | 
| 344 } // namespace ui | 353 } // namespace ui | 
| OLD | NEW |