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

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

Issue 2825853002: Improvements to uses of base::SmallMap (Closed)
Patch Set: Code review Created 3 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
« cc/tiles/picture_layer_tiling.cc ('K') | « ui/latency/latency_info.h ('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 <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/small_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/util/edid_parser.h" 18 #include "ui/display/util/edid_parser.h"
19 19
20 namespace ui { 20 namespace ui {
21 21
22 namespace { 22 namespace {
23 23
24 static const size_t kDefaultCursorWidth = 64; 24 static const size_t kDefaultCursorWidth = 64;
25 static const size_t kDefaultCursorHeight = 64; 25 static const size_t kDefaultCursorHeight = 64;
26 26
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 gfx::Size GetMaximumCursorSize(int fd) { 201 gfx::Size GetMaximumCursorSize(int fd) {
202 uint64_t width = 0, height = 0; 202 uint64_t width = 0, height = 0;
203 // Querying cursor dimensions is optional and is unsupported on older Chrome 203 // Querying cursor dimensions is optional and is unsupported on older Chrome
204 // OS kernels. 204 // OS kernels.
205 if (drmGetCap(fd, DRM_CAP_CURSOR_WIDTH, &width) != 0 || 205 if (drmGetCap(fd, DRM_CAP_CURSOR_WIDTH, &width) != 0 ||
206 drmGetCap(fd, DRM_CAP_CURSOR_HEIGHT, &height) != 0) { 206 drmGetCap(fd, DRM_CAP_CURSOR_HEIGHT, &height) != 0) {
207 return gfx::Size(kDefaultCursorWidth, kDefaultCursorHeight); 207 return gfx::Size(kDefaultCursorWidth, kDefaultCursorHeight);
208 } 208 }
209 return gfx::Size(width, height); 209 return gfx::Size(width, height);
210 } 210 }
211
212 HardwareDisplayControllerInfo::HardwareDisplayControllerInfo( 211 HardwareDisplayControllerInfo::HardwareDisplayControllerInfo(
213 ScopedDrmConnectorPtr connector, 212 ScopedDrmConnectorPtr connector,
214 ScopedDrmCrtcPtr crtc, 213 ScopedDrmCrtcPtr crtc,
215 size_t index) 214 size_t index)
216 : connector_(std::move(connector)), crtc_(std::move(crtc)), index_(index) {} 215 : connector_(std::move(connector)), crtc_(std::move(crtc)), index_(index) {}
217 216
218 HardwareDisplayControllerInfo::~HardwareDisplayControllerInfo() { 217 HardwareDisplayControllerInfo::~HardwareDisplayControllerInfo() {
219 } 218 }
220 219
221 std::vector<std::unique_ptr<HardwareDisplayControllerInfo>> 220 std::vector<std::unique_ptr<HardwareDisplayControllerInfo>>
222 GetAvailableDisplayControllerInfos(int fd) { 221 GetAvailableDisplayControllerInfos(int fd) {
223 ScopedDrmResourcesPtr resources(drmModeGetResources(fd)); 222 ScopedDrmResourcesPtr resources(drmModeGetResources(fd));
224 DCHECK(resources) << "Failed to get DRM resources"; 223 DCHECK(resources) << "Failed to get DRM resources";
225 std::vector<std::unique_ptr<HardwareDisplayControllerInfo>> displays; 224 std::vector<std::unique_ptr<HardwareDisplayControllerInfo>> displays;
226 225
227 std::vector<ScopedDrmConnectorPtr> available_connectors; 226 std::vector<ScopedDrmConnectorPtr> available_connectors;
228 std::vector<ScopedDrmConnectorPtr::element_type*> connectors; 227 std::vector<ScopedDrmConnectorPtr::element_type*> connectors;
229 for (int i = 0; i < resources->count_connectors; ++i) { 228 for (int i = 0; i < resources->count_connectors; ++i) {
230 ScopedDrmConnectorPtr connector( 229 ScopedDrmConnectorPtr connector(
231 drmModeGetConnector(fd, resources->connectors[i])); 230 drmModeGetConnector(fd, resources->connectors[i]));
232 connectors.push_back(connector.get()); 231 connectors.push_back(connector.get());
233 232
234 if (connector && connector->connection == DRM_MODE_CONNECTED && 233 if (connector && connector->connection == DRM_MODE_CONNECTED &&
235 connector->count_modes != 0) 234 connector->count_modes != 0)
236 available_connectors.push_back(std::move(connector)); 235 available_connectors.push_back(std::move(connector));
237 } 236 }
238 237
239 base::SmallMap<std::map<ScopedDrmConnectorPtr::element_type*, int>> 238 base::flat_map<ScopedDrmConnectorPtr::element_type*, int> connector_crtcs;
240 connector_crtcs;
241 for (auto& c : available_connectors) { 239 for (auto& c : available_connectors) {
242 uint32_t possible_crtcs = 0; 240 uint32_t possible_crtcs = 0;
243 for (int i = 0; i < c->count_encoders; ++i) { 241 for (int i = 0; i < c->count_encoders; ++i) {
244 ScopedDrmEncoderPtr encoder(drmModeGetEncoder(fd, c->encoders[i])); 242 ScopedDrmEncoderPtr encoder(drmModeGetEncoder(fd, c->encoders[i]));
245 if (!encoder) 243 if (!encoder)
246 continue; 244 continue;
247 possible_crtcs |= encoder->possible_crtcs; 245 possible_crtcs |= encoder->possible_crtcs;
248 } 246 }
249 connector_crtcs[c.get()] = possible_crtcs; 247 connector_crtcs[c.get()] = possible_crtcs;
250 } 248 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 case gfx::BufferFormat::YUV_420_BIPLANAR: 432 case gfx::BufferFormat::YUV_420_BIPLANAR:
435 return DRM_FORMAT_NV12; 433 return DRM_FORMAT_NV12;
436 case gfx::BufferFormat::YVU_420: 434 case gfx::BufferFormat::YVU_420:
437 return DRM_FORMAT_YVU420; 435 return DRM_FORMAT_YVU420;
438 default: 436 default:
439 NOTREACHED(); 437 NOTREACHED();
440 return 0; 438 return 0;
441 } 439 }
442 } 440 }
443 } // namespace ui 441 } // namespace ui
OLDNEW
« cc/tiles/picture_layer_tiling.cc ('K') | « ui/latency/latency_info.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698