Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: ui/ozone/platform/drm/common/drm_util.cc

Issue 1869793002: Ozone GBM: support R_8 format to GpuMemoryBuffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to ToT Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // TODO(dshwang): after most linux and libdrm has this definition, remove it.
21 #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ')
dnicoara 2016/04/07 15:57:16 Surround it with #if-defs to avoid warnings when i
dshwang 2016/04/07 17:35:55 Done. guard by #ifndef DRM_FORMAT_R8
22
20 namespace ui { 23 namespace ui {
21 24
22 namespace { 25 namespace {
23 26
24 bool IsCrtcInUse(uint32_t crtc, 27 bool IsCrtcInUse(uint32_t crtc,
25 const ScopedVector<HardwareDisplayControllerInfo>& displays) { 28 const ScopedVector<HardwareDisplayControllerInfo>& displays) {
26 for (size_t i = 0; i < displays.size(); ++i) { 29 for (size_t i = 0; i < displays.size(); ++i) {
27 if (crtc == displays[i]->crtc()->crtc_id) 30 if (crtc == displays[i]->crtc()->crtc_id)
28 return true; 31 return true;
29 } 32 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 if (!params.has_native_mode && !params.modes.empty()) { 287 if (!params.has_native_mode && !params.modes.empty()) {
285 params.has_native_mode = true; 288 params.has_native_mode = true;
286 params.native_mode = params.modes.front(); 289 params.native_mode = params.modes.front();
287 } 290 }
288 291
289 return params; 292 return params;
290 } 293 }
291 294
292 int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) { 295 int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) {
293 switch (format) { 296 switch (format) {
297 case gfx::BufferFormat::R_8:
298 return DRM_FORMAT_R8;
294 case gfx::BufferFormat::RGBA_8888: 299 case gfx::BufferFormat::RGBA_8888:
295 return DRM_FORMAT_ABGR8888; 300 return DRM_FORMAT_ABGR8888;
296 case gfx::BufferFormat::RGBX_8888: 301 case gfx::BufferFormat::RGBX_8888:
297 return DRM_FORMAT_XBGR8888; 302 return DRM_FORMAT_XBGR8888;
298 case gfx::BufferFormat::BGRA_8888: 303 case gfx::BufferFormat::BGRA_8888:
299 return DRM_FORMAT_ARGB8888; 304 return DRM_FORMAT_ARGB8888;
300 case gfx::BufferFormat::BGRX_8888: 305 case gfx::BufferFormat::BGRX_8888:
301 return DRM_FORMAT_XRGB8888; 306 return DRM_FORMAT_XRGB8888;
302 case gfx::BufferFormat::UYVY_422: 307 case gfx::BufferFormat::UYVY_422:
303 return DRM_FORMAT_UYVY; 308 return DRM_FORMAT_UYVY;
304 default: 309 default:
305 NOTREACHED(); 310 NOTREACHED();
306 return 0; 311 return 0;
307 } 312 }
308 } 313 }
309 314
310 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { 315 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) {
311 switch (format) { 316 switch (format) {
317 case DRM_FORMAT_R8:
318 return gfx::BufferFormat::R_8;
312 case DRM_FORMAT_ABGR8888: 319 case DRM_FORMAT_ABGR8888:
313 return gfx::BufferFormat::RGBA_8888; 320 return gfx::BufferFormat::RGBA_8888;
314 case DRM_FORMAT_XBGR8888: 321 case DRM_FORMAT_XBGR8888:
315 return gfx::BufferFormat::RGBX_8888; 322 return gfx::BufferFormat::RGBX_8888;
316 case DRM_FORMAT_ARGB8888: 323 case DRM_FORMAT_ARGB8888:
317 return gfx::BufferFormat::BGRA_8888; 324 return gfx::BufferFormat::BGRA_8888;
318 case DRM_FORMAT_XRGB8888: 325 case DRM_FORMAT_XRGB8888:
319 return gfx::BufferFormat::BGRX_8888; 326 return gfx::BufferFormat::BGRX_8888;
320 case DRM_FORMAT_UYVY: 327 case DRM_FORMAT_UYVY:
321 return gfx::BufferFormat::UYVY_422; 328 return gfx::BufferFormat::UYVY_422;
322 default: 329 default:
323 NOTREACHED(); 330 NOTREACHED();
324 return gfx::BufferFormat::BGRA_8888; 331 return gfx::BufferFormat::BGRA_8888;
325 } 332 }
326 } 333 }
327 334
328 int GetFourCCFormatForFramebuffer(gfx::BufferFormat format) { 335 int GetFourCCFormatForFramebuffer(gfx::BufferFormat format) {
dnicoara 2016/04/07 15:57:16 Shouldn't you add the format in here as well?
dshwang 2016/04/07 17:35:55 This function is for scanout buffer, which is used
329 // Currently, drm supports 24 bitcolordepth for hardware overlay. 336 // Currently, drm supports 24 bitcolordepth for hardware overlay.
330 switch (format) { 337 switch (format) {
331 case gfx::BufferFormat::RGBA_8888: 338 case gfx::BufferFormat::RGBA_8888:
332 case gfx::BufferFormat::RGBX_8888: 339 case gfx::BufferFormat::RGBX_8888:
333 return DRM_FORMAT_XBGR8888; 340 return DRM_FORMAT_XBGR8888;
334 case gfx::BufferFormat::BGRA_8888: 341 case gfx::BufferFormat::BGRA_8888:
335 case gfx::BufferFormat::BGRX_8888: 342 case gfx::BufferFormat::BGRX_8888:
336 return DRM_FORMAT_XRGB8888; 343 return DRM_FORMAT_XRGB8888;
337 case gfx::BufferFormat::UYVY_422: 344 case gfx::BufferFormat::UYVY_422:
338 return DRM_FORMAT_UYVY; 345 return DRM_FORMAT_UYVY;
339 default: 346 default:
340 NOTREACHED(); 347 NOTREACHED();
341 return 0; 348 return 0;
342 } 349 }
343 } 350 }
344 } // namespace ui 351 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/client_native_pixmap_factory_gbm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698