Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_surface.cpp
Show First 20 Lines • Show All 258 Lines • ▼ Show 20 Line(s) | 201 | { | |||
---|---|---|---|---|---|
259 | QVERIFY(!KWayland::Server::SurfaceInterface::get(1, nullptr)); | 259 | QVERIFY(!KWayland::Server::SurfaceInterface::get(1, nullptr)); | ||
260 | } | 260 | } | ||
261 | 261 | | |||
262 | void TestWaylandSurface::testDamage() | 262 | void TestWaylandSurface::testDamage() | ||
263 | { | 263 | { | ||
264 | QSignalSpy serverSurfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWayland::Server::SurfaceInterface*))); | 264 | QSignalSpy serverSurfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWayland::Server::SurfaceInterface*))); | ||
265 | QVERIFY(serverSurfaceCreated.isValid()); | 265 | QVERIFY(serverSurfaceCreated.isValid()); | ||
266 | KWayland::Client::Surface *s = m_compositor->createSurface(); | 266 | KWayland::Client::Surface *s = m_compositor->createSurface(); | ||
267 | s->setScale(2); | ||||
267 | QVERIFY(serverSurfaceCreated.wait()); | 268 | QVERIFY(serverSurfaceCreated.wait()); | ||
268 | KWayland::Server::SurfaceInterface *serverSurface = serverSurfaceCreated.first().first().value<KWayland::Server::SurfaceInterface*>(); | 269 | KWayland::Server::SurfaceInterface *serverSurface = serverSurfaceCreated.first().first().value<KWayland::Server::SurfaceInterface*>(); | ||
269 | QVERIFY(serverSurface); | 270 | QVERIFY(serverSurface); | ||
270 | QCOMPARE(serverSurface->damage(), QRegion()); | 271 | QCOMPARE(serverSurface->damage(), QRegion()); | ||
271 | QVERIFY(serverSurface->parentResource()); | 272 | QVERIFY(serverSurface->parentResource()); | ||
272 | QVERIFY(!serverSurface->isMapped()); | 273 | QVERIFY(!serverSurface->isMapped()); | ||
273 | 274 | | |||
274 | QSignalSpy damageSpy(serverSurface, SIGNAL(damaged(QRegion))); | 275 | QSignalSpy damageSpy(serverSurface, SIGNAL(damaged(QRegion))); | ||
Show All 10 Lines | |||||
285 | 286 | | |||
286 | QImage img(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); | 287 | QImage img(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); | ||
287 | img.fill(Qt::black); | 288 | img.fill(Qt::black); | ||
288 | auto b = m_shm->createBuffer(img); | 289 | auto b = m_shm->createBuffer(img); | ||
289 | s->attachBuffer(b); | 290 | s->attachBuffer(b); | ||
290 | s->damage(QRect(0, 0, 10, 10)); | 291 | s->damage(QRect(0, 0, 10, 10)); | ||
291 | s->commit(KWayland::Client::Surface::CommitFlag::None); | 292 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||
292 | QVERIFY(damageSpy.wait()); | 293 | QVERIFY(damageSpy.wait()); | ||
293 | QCOMPARE(serverSurface->damage(), QRegion(0, 0, 10, 10)); | 294 | QCOMPARE(serverSurface->damage(), QRegion(0, 0, 5, 5)); // scale is 2 | ||
294 | QCOMPARE(damageSpy.first().first().value<QRegion>(), QRegion(0, 0, 10, 10)); | 295 | QCOMPARE(damageSpy.first().first().value<QRegion>(), QRegion(0, 0, 5, 5)); | ||
295 | QVERIFY(serverSurface->isMapped()); | 296 | QVERIFY(serverSurface->isMapped()); | ||
296 | 297 | | |||
297 | // damage multiple times | 298 | // damage multiple times | ||
298 | QRegion testRegion(5, 8, 3, 6); | 299 | QRegion testRegion(5, 8, 3, 6); | ||
299 | testRegion = testRegion.united(QRect(10, 20, 30, 15)); | 300 | testRegion = testRegion.united(QRect(10, 11, 6, 1)); | ||
300 | img = QImage(QSize(40, 35), QImage::Format_ARGB32_Premultiplied); | 301 | img = QImage(QSize(40, 35), QImage::Format_ARGB32_Premultiplied); | ||
301 | img.fill(Qt::black); | 302 | img.fill(Qt::black); | ||
302 | b = m_shm->createBuffer(img); | 303 | b = m_shm->createBuffer(img); | ||
303 | s->attachBuffer(b); | 304 | s->attachBuffer(b); | ||
304 | s->damage(testRegion); | 305 | s->damage(testRegion); | ||
305 | damageSpy.clear(); | 306 | damageSpy.clear(); | ||
306 | s->commit(KWayland::Client::Surface::CommitFlag::None); | 307 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||
307 | QVERIFY(damageSpy.wait()); | 308 | QVERIFY(damageSpy.wait()); | ||
308 | QCOMPARE(serverSurface->damage(), testRegion); | 309 | QCOMPARE(serverSurface->damage(), testRegion); | ||
309 | QCOMPARE(damageSpy.first().first().value<QRegion>(), testRegion); | 310 | QCOMPARE(damageSpy.first().first().value<QRegion>(), testRegion); | ||
310 | QVERIFY(serverSurface->isMapped()); | 311 | QVERIFY(serverSurface->isMapped()); | ||
312 | | ||||
313 | // damage buffer | ||||
314 | const QRegion testRegion2(30, 40, 22, 4); | ||||
315 | const QRegion cmpRegion2(15, 20, 11, 2); // divided by scale factor | ||||
316 | img = QImage(QSize(80, 70), QImage::Format_ARGB32_Premultiplied); | ||||
317 | img.fill(Qt::black); | ||||
318 | b = m_shm->createBuffer(img); | ||||
319 | s->attachBuffer(b); | ||||
320 | s->damageBuffer(testRegion2); | ||||
321 | damageSpy.clear(); | ||||
322 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||||
323 | QVERIFY(damageSpy.wait()); | ||||
324 | QCOMPARE(serverSurface->damage(), cmpRegion2); | ||||
325 | QCOMPARE(damageSpy.first().first().value<QRegion>(), cmpRegion2); | ||||
326 | QVERIFY(serverSurface->isMapped()); | ||||
327 | | ||||
328 | // combined regular damage and damaged buffer | ||||
329 | const QRegion testRegion3 = testRegion.united(cmpRegion2); | ||||
330 | img = QImage(QSize(80, 70), QImage::Format_ARGB32_Premultiplied); | ||||
331 | img.fill(Qt::black); | ||||
332 | b = m_shm->createBuffer(img); | ||||
333 | s->attachBuffer(b); | ||||
334 | s->damage(testRegion); | ||||
335 | s->damageBuffer(testRegion2); | ||||
336 | damageSpy.clear(); | ||||
337 | s->commit(KWayland::Client::Surface::CommitFlag::None); | ||||
338 | QVERIFY(damageSpy.wait()); | ||||
339 | QVERIFY(serverSurface->damage() != testRegion); | ||||
340 | QVERIFY(serverSurface->damage() != testRegion2); | ||||
341 | QVERIFY(serverSurface->damage() != cmpRegion2); | ||||
342 | QCOMPARE(serverSurface->damage(), testRegion3); | ||||
343 | QCOMPARE(damageSpy.first().first().value<QRegion>(), testRegion3); | ||||
344 | QVERIFY(serverSurface->isMapped()); | ||||
311 | } | 345 | } | ||
312 | 346 | | |||
313 | void TestWaylandSurface::testFrameCallback() | 347 | void TestWaylandSurface::testFrameCallback() | ||
314 | { | 348 | { | ||
315 | QSignalSpy serverSurfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWayland::Server::SurfaceInterface*))); | 349 | QSignalSpy serverSurfaceCreated(m_compositorInterface, SIGNAL(surfaceCreated(KWayland::Server::SurfaceInterface*))); | ||
316 | QVERIFY(serverSurfaceCreated.isValid()); | 350 | QVERIFY(serverSurfaceCreated.isValid()); | ||
317 | KWayland::Client::Surface *s = m_compositor->createSurface(); | 351 | KWayland::Client::Surface *s = m_compositor->createSurface(); | ||
318 | QVERIFY(serverSurfaceCreated.wait()); | 352 | QVERIFY(serverSurfaceCreated.wait()); | ||
▲ Show 20 Lines • Show All 854 Lines • Show Last 20 Lines |