Changeset View
Changeset View
Standalone View
Standalone View
src/client/shm_pool.cpp
Show First 20 Lines • Show All 164 Lines • ▼ Show 20 Line(s) | 152 | { | |||
---|---|---|---|---|---|
165 | emit q->poolResized(); | 165 | emit q->poolResized(); | ||
166 | return true; | 166 | return true; | ||
167 | } | 167 | } | ||
168 | 168 | | |||
169 | namespace { | 169 | namespace { | ||
170 | static Buffer::Format toBufferFormat(const QImage &image) | 170 | static Buffer::Format toBufferFormat(const QImage &image) | ||
171 | { | 171 | { | ||
172 | switch (image.format()) { | 172 | switch (image.format()) { | ||
173 | case QImage::Format_ARGB32: | | |||
174 | case QImage::Format_ARGB32_Premultiplied: | 173 | case QImage::Format_ARGB32_Premultiplied: | ||
175 | return Buffer::Format::ARGB32; | 174 | return Buffer::Format::ARGB32; | ||
176 | case QImage::Format_RGB32: | 175 | case QImage::Format_RGB32: | ||
177 | return Buffer::Format::RGB32; | 176 | return Buffer::Format::RGB32; | ||
177 | case QImage::Format_ARGB32: | ||||
178 | qCWarning(KWAYLAND_CLIENT) << "Unsupported image format: " << image.format() << ". expect slow performance. Use QImage::Format_ARGB32_Premultiplied"; | ||||
179 | return Buffer::Format::ARGB32; | ||||
178 | default: | 180 | default: | ||
179 | qCWarning(KWAYLAND_CLIENT) << "Unsupported image format: " << image.format() << "going to use ARGB32, expect rendering errors"; | 181 | qCWarning(KWAYLAND_CLIENT) << "Unsupported image format: " << image.format() << ". expect slow performance."; | ||
180 | return Buffer::Format::ARGB32; | 182 | return Buffer::Format::ARGB32; | ||
181 | } | 183 | } | ||
182 | } | 184 | } | ||
183 | } | 185 | } | ||
184 | 186 | | |||
185 | Buffer::Ptr ShmPool::createBuffer(const QImage& image) | 187 | Buffer::Ptr ShmPool::createBuffer(const QImage& image) | ||
186 | { | 188 | { | ||
187 | if (image.isNull() || !d->valid) { | 189 | if (image.isNull() || !d->valid) { | ||
188 | return QWeakPointer<Buffer>(); | 190 | return QWeakPointer<Buffer>(); | ||
189 | } | 191 | } | ||
190 | auto it = d->getBuffer(image.size(), image.bytesPerLine(), toBufferFormat(image)); | 192 | auto format = toBufferFormat(image); | ||
193 | auto it = d->getBuffer(image.size(), image.bytesPerLine(), format); | ||||
191 | if (it == d->buffers.end()) { | 194 | if (it == d->buffers.end()) { | ||
192 | return QWeakPointer<Buffer>(); | 195 | return QWeakPointer<Buffer>(); | ||
193 | } | 196 | } | ||
197 | if (format == Buffer::Format::ARGB32 && image.format() != QImage::Format_ARGB32_Premultiplied) { | ||||
198 | auto imageCopy = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); | ||||
199 | (*it)->copy(imageCopy.bits()); | ||||
200 | } else { | ||||
194 | (*it)->copy(image.bits()); | 201 | (*it)->copy(image.bits()); | ||
202 | } | ||||
195 | return QWeakPointer<Buffer>(*it); | 203 | return QWeakPointer<Buffer>(*it); | ||
196 | } | 204 | } | ||
197 | 205 | | |||
198 | Buffer::Ptr ShmPool::createBuffer(const QSize &size, int32_t stride, const void *src, Buffer::Format format) | 206 | Buffer::Ptr ShmPool::createBuffer(const QSize &size, int32_t stride, const void *src, Buffer::Format format) | ||
199 | { | 207 | { | ||
200 | if (size.isEmpty() || !d->valid) { | 208 | if (size.isEmpty() || !d->valid) { | ||
201 | return QWeakPointer<Buffer>(); | 209 | return QWeakPointer<Buffer>(); | ||
202 | } | 210 | } | ||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |