Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_object_plane.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 40 | { | |||
---|---|---|---|---|---|
55 | } | 55 | } | ||
56 | 56 | | |||
57 | if (!initProps()) { | 57 | if (!initProps()) { | ||
58 | return false; | 58 | return false; | ||
59 | } | 59 | } | ||
60 | return true; | 60 | return true; | ||
61 | } | 61 | } | ||
62 | 62 | | |||
63 | bool DrmPlane::atomicPopulate(drmModeAtomicReq *req) const | ||||
64 | { | ||||
65 | return doAtomicPopulate(req, 1); | ||||
66 | } | ||||
67 | | ||||
63 | bool DrmPlane::initProps() | 68 | bool DrmPlane::initProps() | ||
64 | { | 69 | { | ||
65 | setPropertyNames( { | 70 | setPropertyNames( { | ||
66 | QByteArrayLiteral("type"), | 71 | QByteArrayLiteral("type"), | ||
67 | QByteArrayLiteral("SRC_X"), | 72 | QByteArrayLiteral("SRC_X"), | ||
68 | QByteArrayLiteral("SRC_Y"), | 73 | QByteArrayLiteral("SRC_Y"), | ||
69 | QByteArrayLiteral("SRC_W"), | 74 | QByteArrayLiteral("SRC_W"), | ||
70 | QByteArrayLiteral("SRC_H"), | 75 | QByteArrayLiteral("SRC_H"), | ||
Show All 30 Lines | |||||
101 | 106 | | |||
102 | int propCount = int(PropertyIndex::Count); | 107 | int propCount = int(PropertyIndex::Count); | ||
103 | for (int j = 0; j < propCount; ++j) { | 108 | for (int j = 0; j < propCount; ++j) { | ||
104 | if (j == int(PropertyIndex::Type)) { | 109 | if (j == int(PropertyIndex::Type)) { | ||
105 | initProp(j, properties.data(), typeNames); | 110 | initProp(j, properties.data(), typeNames); | ||
106 | } else if (j == int(PropertyIndex::Rotation)) { | 111 | } else if (j == int(PropertyIndex::Rotation)) { | ||
107 | initProp(j, properties.data(), rotationNames); | 112 | initProp(j, properties.data(), rotationNames); | ||
108 | m_supportedTransformations = Transformations(); | 113 | m_supportedTransformations = Transformations(); | ||
109 | auto testTransform = [j, this] (uint64_t value, Transformation t, const QString &name) { | 114 | | ||
115 | auto checkSupport = [j, this] (uint64_t value, Transformation t, const QString &name) { | ||||
110 | if (propHasEnum(j, value)) { | 116 | if (propHasEnum(j, value)) { | ||
111 | qCDebug(KWIN_DRM) << name; | 117 | qCDebug(KWIN_DRM) << name; | ||
112 | m_supportedTransformations |= t; | 118 | m_supportedTransformations |= t; | ||
113 | } | 119 | } | ||
114 | }; | 120 | }; | ||
115 | qCDebug(KWIN_DRM).nospace() << "Supported Transformations on plane " << m_id << ":"; | 121 | qCDebug(KWIN_DRM).nospace() << "Supported Transformations on plane " << m_id << ":"; | ||
116 | testTransform(0, Transformation::Rotate0, "rotate-0"); | 122 | checkSupport(0, Transformation::Rotate0, "rotate-0"); | ||
117 | testTransform(1, Transformation::Rotate90, "rotate-90"); | 123 | checkSupport(1, Transformation::Rotate90, "rotate-90"); | ||
118 | testTransform(2, Transformation::Rotate180, "rotate-180"); | 124 | checkSupport(2, Transformation::Rotate180, "rotate-180"); | ||
119 | testTransform(3, Transformation::Rotate270, "rotate-270"); | 125 | checkSupport(3, Transformation::Rotate270, "rotate-270"); | ||
120 | testTransform(4, Transformation::ReflectX, "reflect-x-axis"); | 126 | checkSupport(4, Transformation::ReflectX, "reflect-x"); | ||
121 | testTransform(5, Transformation::ReflectY, "reflect-y-axis"); | 127 | checkSupport(5, Transformation::ReflectY, "reflect-y"); | ||
122 | qCDebug(KWIN_DRM) << ""; | 128 | qCDebug(KWIN_DRM) << ""; | ||
129 | | ||||
123 | } else { | 130 | } else { | ||
124 | initProp(j, properties.data()); | 131 | initProp(j, properties.data()); | ||
125 | } | 132 | } | ||
126 | } | 133 | } | ||
127 | 134 | | |||
128 | return true; | 135 | return true; | ||
129 | } | 136 | } | ||
130 | 137 | | |||
Show All 17 Lines | 154 | { | |||
148 | if (auto property = m_props.at(int(PropertyIndex::FbId))) { | 155 | if (auto property = m_props.at(int(PropertyIndex::FbId))) { | ||
149 | property->setValue(b ? b->bufferId() : 0); | 156 | property->setValue(b ? b->bufferId() : 0); | ||
150 | } | 157 | } | ||
151 | m_next = b; | 158 | m_next = b; | ||
152 | } | 159 | } | ||
153 | 160 | | |||
154 | void DrmPlane::setTransformation(Transformations t) | 161 | void DrmPlane::setTransformation(Transformations t) | ||
155 | { | 162 | { | ||
163 | // TODO: When being pedantic, this should go through the enum mapping. Just remember | ||||
164 | // that these are the shift distance, not the shifted value. | ||||
156 | if (auto property = m_props.at(int(PropertyIndex::Rotation))) { | 165 | if (auto property = m_props.at(int(PropertyIndex::Rotation))) { | ||
157 | property->setValue(int(t)); | 166 | property->setValue(int(t)); | ||
158 | } | 167 | } | ||
159 | } | 168 | } | ||
160 | 169 | | |||
161 | DrmPlane::Transformations DrmPlane::transformation() | 170 | DrmPlane::Transformations DrmPlane::transformation() | ||
162 | { | 171 | { | ||
163 | if (auto property = m_props.at(int(PropertyIndex::Rotation))) { | 172 | if (auto property = m_props.at(int(PropertyIndex::Rotation))) { | ||
164 | return Transformations(int(property->value())); | 173 | return Transformations(int(property->value())); | ||
165 | } | 174 | } | ||
166 | return Transformations(Transformation::Rotate0); | 175 | return Transformations(Transformation::Rotate0); | ||
167 | } | 176 | } | ||
168 | 177 | | |||
169 | bool DrmPlane::atomicPopulate(drmModeAtomicReq *req) | | |||
170 | { | | |||
171 | bool ret = true; | | |||
172 | | ||||
173 | for (int i = 1; i < m_props.size(); i++) { | | |||
romangg: This `1` is a problem. | |||||
174 | auto property = m_props.at(i); | | |||
175 | if (!property) { | | |||
176 | continue; | | |||
177 | } | | |||
178 | ret &= atomicAddProperty(req, property); | | |||
179 | } | | |||
180 | | ||||
181 | if (!ret) { | | |||
182 | qCWarning(KWIN_DRM) << "Failed to populate atomic plane" << m_id; | | |||
183 | return false; | | |||
184 | } | | |||
185 | return true; | | |||
186 | } | | |||
187 | | ||||
188 | void DrmPlane::flipBuffer() | 178 | void DrmPlane::flipBuffer() | ||
189 | { | 179 | { | ||
190 | m_current = m_next; | 180 | m_current = m_next; | ||
191 | m_next = nullptr; | 181 | m_next = nullptr; | ||
192 | } | 182 | } | ||
193 | 183 | | |||
194 | void DrmPlane::flipBufferWithDelete() | 184 | void DrmPlane::flipBufferWithDelete() | ||
195 | { | 185 | { | ||
196 | if (m_current != m_next) { | 186 | if (m_current != m_next) { | ||
197 | delete m_current; | 187 | delete m_current; | ||
198 | } | 188 | } | ||
199 | flipBuffer(); | 189 | flipBuffer(); | ||
200 | } | 190 | } | ||
201 | 191 | | |||
202 | } | 192 | } |
This 1 is a problem.