Chromium Code Reviews| 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 <gbm.h> | |
| 8 #include <stdint.h> | 9 #include <stdint.h> |
| 9 #include <stdlib.h> | 10 #include <stdlib.h> |
| 10 #include <sys/mman.h> | 11 #include <sys/mman.h> |
| 11 #include <xf86drm.h> | 12 #include <xf86drm.h> |
| 12 #include <xf86drmMode.h> | 13 #include <xf86drmMode.h> |
| 13 #include <algorithm> | 14 #include <algorithm> |
| 14 #include <utility> | 15 #include <utility> |
| 15 | 16 |
| 16 #include "base/containers/flat_map.h" | 17 #include "base/containers/flat_map.h" |
| 17 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 case gfx::BufferFormat::YUV_420_BIPLANAR: | 512 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 512 return DRM_FORMAT_NV12; | 513 return DRM_FORMAT_NV12; |
| 513 case gfx::BufferFormat::YVU_420: | 514 case gfx::BufferFormat::YVU_420: |
| 514 return DRM_FORMAT_YVU420; | 515 return DRM_FORMAT_YVU420; |
| 515 default: | 516 default: |
| 516 NOTREACHED(); | 517 NOTREACHED(); |
| 517 return 0; | 518 return 0; |
| 518 } | 519 } |
| 519 } | 520 } |
| 520 | 521 |
| 522 uint32_t GetGbmFlagsFromBufferUsage(gfx::BufferUsage usage) { | |
| 523 switch (usage) { | |
| 524 case gfx::BufferUsage::GPU_READ: | |
| 525 return GBM_BO_USE_TEXTURING; | |
| 526 case gfx::BufferUsage::SCANOUT: | |
| 527 return GBM_BO_USE_SCANOUT; | |
| 528 case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE: | |
| 529 return GBM_BO_USE_SCANOUT | GBM_BO_USE_LINEAR; | |
| 530 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | |
| 531 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | |
| 532 return GBM_BO_USE_TEXTURING | GBM_BO_USE_LINEAR; | |
| 533 } | |
| 534 } | |
| 535 | |
| 536 gfx::BufferUsage GetBufferUsageFromGbmFlags(int flags) { | |
| 537 switch (flags) { | |
| 538 case GBM_BO_USE_TEXTURING: | |
|
gurchetansingh
2017/06/28 20:59:18
After the gbm.h change lands, you still have to ro
| |
| 539 return gfx::BufferUsage::GPU_READ; | |
| 540 case GBM_BO_USE_SCANOUT: | |
| 541 return gfx::BufferUsage::SCANOUT; | |
| 542 case GBM_BO_USE_SCANOUT | GBM_BO_USE_LINEAR: | |
| 543 return gfx::BufferUsage::SCANOUT_CPU_READ_WRITE; | |
| 544 case GBM_BO_USE_TEXTURING | GBM_BO_USE_LINEAR: | |
| 545 return gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; | |
| 546 default: | |
| 547 NOTREACHED(); | |
| 548 return gfx::BufferUsage::SCANOUT; | |
| 549 } | |
| 550 } | |
| 551 | |
| 521 MovableDisplaySnapshots CreateMovableDisplaySnapshotsFromParams( | 552 MovableDisplaySnapshots CreateMovableDisplaySnapshotsFromParams( |
| 522 const std::vector<DisplaySnapshot_Params>& displays) { | 553 const std::vector<DisplaySnapshot_Params>& displays) { |
| 523 MovableDisplaySnapshots snapshots; | 554 MovableDisplaySnapshots snapshots; |
| 524 for (const auto& d : displays) | 555 for (const auto& d : displays) |
| 525 snapshots.push_back(base::MakeUnique<DisplaySnapshotProxy>(d)); | 556 snapshots.push_back(base::MakeUnique<DisplaySnapshotProxy>(d)); |
| 526 return snapshots; | 557 return snapshots; |
| 527 } | 558 } |
| 528 | 559 |
| 529 } // namespace ui | 560 } // namespace ui |
| OLD | NEW |