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

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

Issue 2930163002: Convert ozone/drm DisplaySnapshot_Param to DisplaySnapshotMojo (Closed)
Patch Set: review nits Created 3 years, 6 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
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 <xf86drm.h> 11 #include <xf86drm.h>
12 #include <xf86drmMode.h> 12 #include <xf86drmMode.h>
13 #include <algorithm> 13 #include <algorithm>
14 #include <utility> 14 #include <utility>
15 15
16 #include "base/containers/flat_map.h" 16 #include "base/containers/flat_map.h"
17 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "ui/display/types/display_mode.h"
19 #include "ui/display/types/display_snapshot_mojo.h"
18 #include "ui/display/util/edid_parser.h" 20 #include "ui/display/util/edid_parser.h"
21 #include "ui/ozone/common/display_snapshot_proxy.h"
19 22
20 namespace ui { 23 namespace ui {
21 24
22 namespace { 25 namespace {
23 26
24 static const size_t kDefaultCursorWidth = 64; 27 static const size_t kDefaultCursorWidth = 64;
25 static const size_t kDefaultCursorHeight = 64; 28 static const size_t kDefaultCursorHeight = 64;
26 29
27 bool IsCrtcInUse( 30 bool IsCrtcInUse(
28 uint32_t crtc, 31 uint32_t crtc,
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 lhs.vsync_start == rhs.vsync_start && lhs.vsync_end == rhs.vsync_end && 313 lhs.vsync_start == rhs.vsync_start && lhs.vsync_end == rhs.vsync_end &&
311 lhs.vtotal == rhs.vtotal && lhs.vscan == rhs.vscan && 314 lhs.vtotal == rhs.vtotal && lhs.vscan == rhs.vscan &&
312 lhs.flags == rhs.flags && strcmp(lhs.name, rhs.name) == 0; 315 lhs.flags == rhs.flags && strcmp(lhs.name, rhs.name) == 0;
313 } 316 }
314 317
315 DisplayMode_Params CreateDisplayModeParams(const drmModeModeInfo& mode) { 318 DisplayMode_Params CreateDisplayModeParams(const drmModeModeInfo& mode) {
316 DisplayMode_Params params; 319 DisplayMode_Params params;
317 params.size = gfx::Size(mode.hdisplay, mode.vdisplay); 320 params.size = gfx::Size(mode.hdisplay, mode.vdisplay);
318 params.is_interlaced = mode.flags & DRM_MODE_FLAG_INTERLACE; 321 params.is_interlaced = mode.flags & DRM_MODE_FLAG_INTERLACE;
319 params.refresh_rate = GetRefreshRate(mode); 322 params.refresh_rate = GetRefreshRate(mode);
320
321 return params; 323 return params;
322 } 324 }
323 325
324 DisplaySnapshot_Params CreateDisplaySnapshotParams( 326 DisplaySnapshot_Params CreateDisplaySnapshotParams(
325 HardwareDisplayControllerInfo* info, 327 HardwareDisplayControllerInfo* info,
326 int fd, 328 int fd,
327 const base::FilePath& sys_path, 329 const base::FilePath& sys_path,
328 size_t device_index, 330 size_t device_index,
329 const gfx::Point& origin) { 331 const gfx::Point& origin) {
330 DisplaySnapshot_Params params; 332 DisplaySnapshot_Params params;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // If no preferred mode is found then use the first one. Using the first one 380 // If no preferred mode is found then use the first one. Using the first one
379 // since it should be the best mode. 381 // since it should be the best mode.
380 if (!params.has_native_mode && !params.modes.empty()) { 382 if (!params.has_native_mode && !params.modes.empty()) {
381 params.has_native_mode = true; 383 params.has_native_mode = true;
382 params.native_mode = params.modes.front(); 384 params.native_mode = params.modes.front();
383 } 385 }
384 386
385 return params; 387 return params;
386 } 388 }
387 389
390 // TODO(rjkroege): Remove in a subsequent CL once Mojo IPC is used everywhere.
391 std::vector<DisplaySnapshot_Params> CreateParamsFromSnapshot(
392 const MovableDisplaySnapshots& displays) {
393 std::vector<DisplaySnapshot_Params> params;
394 for (auto& d : displays) {
395 DisplaySnapshot_Params p;
396
397 p.display_id = d->display_id();
398 p.origin = d->origin();
399 p.physical_size = d->physical_size();
400 p.type = d->type();
401 p.is_aspect_preserving_scaling = d->is_aspect_preserving_scaling();
402 p.has_overscan = d->has_overscan();
403 p.has_color_correction_matrix = d->has_color_correction_matrix();
404 p.display_name = d->display_name();
405 p.sys_path = d->sys_path();
406
407 std::vector<DisplayMode_Params> mode_params;
408 for (const auto& m : d->modes()) {
409 mode_params.push_back(GetDisplayModeParams(*m));
410 }
411 p.modes = mode_params;
412 p.edid = d->edid();
413
414 if (d->current_mode()) {
415 p.has_current_mode = true;
416 p.current_mode = GetDisplayModeParams(*d->current_mode());
417 }
418
419 if (d->native_mode()) {
420 p.has_native_mode = true;
421 p.native_mode = GetDisplayModeParams(*d->native_mode());
422 }
423
424 p.product_id = d->product_id();
425 p.string_representation = d->ToString();
426 p.maximum_cursor_size = d->maximum_cursor_size();
427
428 params.push_back(p);
429 }
430 return params;
431 }
432
388 int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) { 433 int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) {
389 switch (format) { 434 switch (format) {
390 case gfx::BufferFormat::R_8: 435 case gfx::BufferFormat::R_8:
391 return DRM_FORMAT_R8; 436 return DRM_FORMAT_R8;
392 case gfx::BufferFormat::RG_88: 437 case gfx::BufferFormat::RG_88:
393 return DRM_FORMAT_GR88; 438 return DRM_FORMAT_GR88;
394 case gfx::BufferFormat::RGBA_8888: 439 case gfx::BufferFormat::RGBA_8888:
395 return DRM_FORMAT_ABGR8888; 440 return DRM_FORMAT_ABGR8888;
396 case gfx::BufferFormat::RGBX_8888: 441 case gfx::BufferFormat::RGBX_8888:
397 return DRM_FORMAT_XBGR8888; 442 return DRM_FORMAT_XBGR8888;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 return DRM_FORMAT_UYVY; 503 return DRM_FORMAT_UYVY;
459 case gfx::BufferFormat::YUV_420_BIPLANAR: 504 case gfx::BufferFormat::YUV_420_BIPLANAR:
460 return DRM_FORMAT_NV12; 505 return DRM_FORMAT_NV12;
461 case gfx::BufferFormat::YVU_420: 506 case gfx::BufferFormat::YVU_420:
462 return DRM_FORMAT_YVU420; 507 return DRM_FORMAT_YVU420;
463 default: 508 default:
464 NOTREACHED(); 509 NOTREACHED();
465 return 0; 510 return 0;
466 } 511 }
467 } 512 }
513
514 MovableDisplaySnapshots CreateMovableDisplaySnapshotsFromParams(
515 const std::vector<DisplaySnapshot_Params>& displays) {
516 MovableDisplaySnapshots snapshots;
517 for (const auto& d : displays)
518 snapshots.push_back(base::MakeUnique<DisplaySnapshotProxy>(d));
519 return snapshots;
520 }
521
468 } // namespace ui 522 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/common/drm_util.h ('k') | ui/ozone/platform/drm/common/drm_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698