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

Side by Side Diff: ui/ozone/platform/dri/hardware_display_plane.cc

Issue 383193002: Start plumbing drm atomic swap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform/dri/hardware_display_plane.h"
6
7 #include <drm.h>
8 #include <errno.h>
9 #include <xf86drm.h>
10
11 #include "base/logging.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/ozone/platform/dri/dri_wrapper.h"
14
15 namespace ui {
16
17 namespace {
18 const char* kCrtcPropName = "CRTC_ID";
19 const char* kFbPropName = "FB_ID";
20 const char* kCrtcXPropName = "CRTC_X";
21 const char* kCrtcYPropName = "CRTC_Y";
22 const char* kCrtcWPropName = "CRTC_W";
23 const char* kCrtcHPropName = "CRTC_H";
24 const char* kSrcXPropName = "SRC_X";
25 const char* kSrcYPropName = "SRC_Y";
26 const char* kSrcWPropName = "SRC_W";
27 const char* kSrcHPropName = "SRC_H";
28 }
29
30 HardwareDisplayPlane::Property::Property() : id_(0) {
31 }
32
33 bool HardwareDisplayPlane::Property::Initialize(
34 DriWrapper* drm,
35 const char* name,
36 const ScopedDrmObjectPropertyPtr& plane_props) {
37 for (uint32_t i = 0; i < plane_props->count_props; i++) {
38 ScopedDrmPropertyPtr property(
39 drmModeGetProperty(drm->get_fd(), plane_props->props[i]));
40 if (!strcmp(property->name, name)) {
41 id_ = property->prop_id;
42 break;
43 }
44 }
45 if (!id_) {
46 LOG(ERROR) << "Could not find property " << name;
47 return false;
48 }
49 return true;
50 }
51
52 HardwareDisplayPlane::HardwareDisplayPlane(
53 DriWrapper* drm,
54 drmModePropertySetPtr atomic_property_set,
55 ScopedDrmPlanePtr plane)
56 : drm_(drm),
57 property_set_(atomic_property_set),
58 plane_(plane.Pass()),
59 plane_id_(plane_->plane_id) {
60 }
61
62 HardwareDisplayPlane::~HardwareDisplayPlane() {
63 }
64
65 bool HardwareDisplayPlane::SetPlaneData(uint32_t crtc_id,
66 uint32_t framebuffer,
67 const gfx::Rect& crtc_rect,
68 const gfx::Rect& src_rect) {
69 int plane_set_error =
70 drmModePropertySetAdd(
71 property_set_, plane_id_, crtc_prop_.id_, crtc_id) ||
72 drmModePropertySetAdd(
73 property_set_, plane_id_, fb_prop_.id_, framebuffer) ||
74 drmModePropertySetAdd(
75 property_set_, plane_id_, crtc_x_prop_.id_, crtc_rect.x()) ||
76 drmModePropertySetAdd(
77 property_set_, plane_id_, crtc_y_prop_.id_, crtc_rect.y()) ||
78 drmModePropertySetAdd(
79 property_set_, plane_id_, crtc_w_prop_.id_, crtc_rect.width()) ||
80 drmModePropertySetAdd(
81 property_set_, plane_id_, crtc_h_prop_.id_, crtc_rect.height()) ||
82 drmModePropertySetAdd(
83 property_set_, plane_id_, src_x_prop_.id_, src_rect.x()) ||
84 drmModePropertySetAdd(
85 property_set_, plane_id_, src_y_prop_.id_, src_rect.x()) ||
86 drmModePropertySetAdd(
87 property_set_, plane_id_, src_w_prop_.id_, src_rect.width()) ||
88 drmModePropertySetAdd(
89 property_set_, plane_id_, src_h_prop_.id_, src_rect.height());
90
91 if (plane_set_error) {
92 LOG(ERROR) << "Failed to set plane data";
93 return false;
94 }
95 return true;
96 }
97
98 bool HardwareDisplayPlane::Initialize() {
99 ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties(
100 drm_->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE));
101
102 if (!plane_props) {
103 LOG(ERROR) << "Unable to get plane properties.";
104 return false;
105 }
106
107 bool props_init =
108 crtc_prop_.Initialize(drm_, kCrtcPropName, plane_props) &&
109 fb_prop_.Initialize(drm_, kFbPropName, plane_props) &&
110 crtc_x_prop_.Initialize(drm_, kCrtcXPropName, plane_props) &&
111 crtc_y_prop_.Initialize(drm_, kCrtcYPropName, plane_props) &&
112 crtc_w_prop_.Initialize(drm_, kCrtcWPropName, plane_props) &&
113 crtc_h_prop_.Initialize(drm_, kCrtcHPropName, plane_props) &&
114 src_x_prop_.Initialize(drm_, kSrcXPropName, plane_props) &&
115 src_y_prop_.Initialize(drm_, kSrcYPropName, plane_props) &&
116 src_w_prop_.Initialize(drm_, kSrcWPropName, plane_props) &&
117 src_h_prop_.Initialize(drm_, kSrcHPropName, plane_props);
118
119 if (!props_init) {
120 LOG(ERROR) << "Unable to get plane properties.";
121 return false;
122 }
123 return true;
124 }
125
126 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/hardware_display_plane.h ('k') | ui/ozone/platform/dri/scoped_drm_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698