Changeset View
Changeset View
Standalone View
Standalone View
plugins/scenes/opengl/scene_opengl.cpp
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
42 | #include "lanczosfilter.h" | 42 | #include "lanczosfilter.h" | ||
43 | #include "main.h" | 43 | #include "main.h" | ||
44 | #include "overlaywindow.h" | 44 | #include "overlaywindow.h" | ||
45 | #include "screens.h" | 45 | #include "screens.h" | ||
46 | #include "cursor.h" | 46 | #include "cursor.h" | ||
47 | #include "decorations/decoratedclient.h" | 47 | #include "decorations/decoratedclient.h" | ||
48 | #include <logging.h> | 48 | #include <logging.h> | ||
49 | 49 | | |||
50 | #include <KWayland/Server/buffer_interface.h> | ||||
50 | #include <KWayland/Server/subcompositor_interface.h> | 51 | #include <KWayland/Server/subcompositor_interface.h> | ||
51 | #include <KWayland/Server/surface_interface.h> | 52 | #include <KWayland/Server/surface_interface.h> | ||
52 | 53 | | |||
53 | #include <array> | 54 | #include <array> | ||
54 | #include <cmath> | 55 | #include <cmath> | ||
55 | #include <unistd.h> | 56 | #include <unistd.h> | ||
56 | #include <stddef.h> | 57 | #include <stddef.h> | ||
57 | 58 | | |||
▲ Show 20 Lines • Show All 1295 Lines • ▼ Show 20 Line(s) | 1339 | { | |||
1353 | // with the default projection matrix. If the effect hasn't specified a | 1354 | // with the default projection matrix. If the effect hasn't specified a | ||
1354 | // model-view matrix, mvMatrix will be the identity matrix. | 1355 | // model-view matrix, mvMatrix will be the identity matrix. | ||
1355 | if (mask & Scene::PAINT_SCREEN_TRANSFORMED) | 1356 | if (mask & Scene::PAINT_SCREEN_TRANSFORMED) | ||
1356 | return scene->screenProjectionMatrix() * mvMatrix; | 1357 | return scene->screenProjectionMatrix() * mvMatrix; | ||
1357 | 1358 | | |||
1358 | return scene->projectionMatrix() * mvMatrix; | 1359 | return scene->projectionMatrix() * mvMatrix; | ||
1359 | } | 1360 | } | ||
1360 | 1361 | | |||
1361 | static void renderSubSurface(GLShader *shader, const QMatrix4x4 &mvp, const QMatrix4x4 &windowMatrix, OpenGLWindowPixmap *pixmap, const QRegion ®ion, bool hardwareClipping) | 1362 | void SceneOpenGL2Window::renderSubSurface(GLShader *shader, const QMatrix4x4 &mvp, const QMatrix4x4 &windowMatrix, OpenGLWindowPixmap *pixmap, const QRegion ®ion, bool hardwareClipping) | ||
1362 | { | 1363 | { | ||
1363 | QMatrix4x4 newWindowMatrix = windowMatrix; | 1364 | QMatrix4x4 newWindowMatrix = windowMatrix; | ||
1364 | newWindowMatrix.translate(pixmap->subSurface()->position().x(), pixmap->subSurface()->position().y()); | 1365 | newWindowMatrix.translate(pixmap->subSurface()->position().x(), pixmap->subSurface()->position().y()); | ||
1365 | 1366 | | |||
1366 | qreal scale = 1.0; | 1367 | qreal scale = 1.0; | ||
1367 | if (pixmap->surface()) { | 1368 | if (pixmap->surface()) { | ||
1368 | scale = pixmap->surface()->scale(); | 1369 | scale = pixmap->surface()->scale(); | ||
1369 | } | 1370 | } | ||
1370 | 1371 | | |||
1371 | if (!pixmap->texture()->isNull()) { | 1372 | if (!pixmap->texture()->isNull()) { | ||
1373 | setBlendEnabled(pixmap->buffer() && pixmap->buffer()->hasAlphaChannel()); | ||||
1372 | // render this texture | 1374 | // render this texture | ||
1373 | shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp * newWindowMatrix); | 1375 | shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp * newWindowMatrix); | ||
1374 | auto texture = pixmap->texture(); | 1376 | auto texture = pixmap->texture(); | ||
1375 | texture->bind(); | 1377 | texture->bind(); | ||
1376 | texture->render(region, QRect(0, 0, texture->width() / scale, texture->height() / scale), hardwareClipping); | 1378 | texture->render(region, QRect(0, 0, texture->width() / scale, texture->height() / scale), hardwareClipping); | ||
1377 | texture->unbind(); | 1379 | texture->unbind(); | ||
romangg: Disable blend again in case it was enabled for this subsurface but following ones have no alpha? | |||||
1378 | } | 1380 | } | ||
1379 | 1381 | | |||
1380 | const auto &children = pixmap->children(); | 1382 | const auto &children = pixmap->children(); | ||
1381 | for (auto pixmap : children) { | 1383 | for (auto pixmap : children) { | ||
1382 | if (pixmap->subSurface().isNull() || pixmap->subSurface()->surface().isNull() || !pixmap->subSurface()->surface()->isMapped()) { | 1384 | if (pixmap->subSurface().isNull() || pixmap->subSurface()->surface().isNull() || !pixmap->subSurface()->surface()->isMapped()) { | ||
1383 | continue; | 1385 | continue; | ||
1384 | } | 1386 | } | ||
1385 | renderSubSurface(shader, mvp, newWindowMatrix, static_cast<OpenGLWindowPixmap*>(pixmap), region, hardwareClipping); | 1387 | renderSubSurface(shader, mvp, newWindowMatrix, static_cast<OpenGLWindowPixmap*>(pixmap), region, hardwareClipping); | ||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | 1499 | for (int i = 0; i < LeafCount; i++) { | |||
1510 | nodes[i].texture->setWrapMode(GL_CLAMP_TO_EDGE); | 1512 | nodes[i].texture->setWrapMode(GL_CLAMP_TO_EDGE); | ||
1511 | nodes[i].texture->bind(); | 1513 | nodes[i].texture->bind(); | ||
1512 | 1514 | | |||
1513 | vbo->draw(region, primitiveType, nodes[i].firstVertex, nodes[i].vertexCount, m_hardwareClipping); | 1515 | vbo->draw(region, primitiveType, nodes[i].firstVertex, nodes[i].vertexCount, m_hardwareClipping); | ||
1514 | } | 1516 | } | ||
1515 | 1517 | | |||
1516 | vbo->unbindArrays(); | 1518 | vbo->unbindArrays(); | ||
1517 | 1519 | | |||
1518 | setBlendEnabled(false); | | |||
Wouldn't you like to leave this here? Otherwise blend might be enabled depending on the last node through romangg: Wouldn't you like to leave this here? Otherwise blend might be enabled depending on the last… | |||||
1519 | | ||||
1520 | // render sub-surfaces | 1520 | // render sub-surfaces | ||
1521 | auto wp = windowPixmap<OpenGLWindowPixmap>(); | 1521 | auto wp = windowPixmap<OpenGLWindowPixmap>(); | ||
1522 | const auto &children = wp ? wp->children() : QVector<WindowPixmap*>(); | 1522 | const auto &children = wp ? wp->children() : QVector<WindowPixmap*>(); | ||
1523 | windowMatrix.translate(toplevel->clientPos().x(), toplevel->clientPos().y()); | 1523 | windowMatrix.translate(toplevel->clientPos().x(), toplevel->clientPos().y()); | ||
1524 | for (auto pixmap : children) { | 1524 | for (auto pixmap : children) { | ||
1525 | if (pixmap->subSurface().isNull() || pixmap->subSurface()->surface().isNull() || !pixmap->subSurface()->surface()->isMapped()) { | 1525 | if (pixmap->subSurface().isNull() || pixmap->subSurface()->surface().isNull() || !pixmap->subSurface()->surface()->isMapped()) { | ||
1526 | continue; | 1526 | continue; | ||
1527 | } | 1527 | } | ||
1528 | renderSubSurface(shader, modelViewProjection, windowMatrix, static_cast<OpenGLWindowPixmap*>(pixmap), region, m_hardwareClipping); | 1528 | renderSubSurface(shader, modelViewProjection, windowMatrix, static_cast<OpenGLWindowPixmap*>(pixmap), region, m_hardwareClipping); | ||
1529 | } | 1529 | } | ||
1530 | 1530 | | |||
1531 | setBlendEnabled(false); | ||||
1532 | | ||||
1531 | if (!data.shader) | 1533 | if (!data.shader) | ||
1532 | ShaderManager::instance()->popShader(); | 1534 | ShaderManager::instance()->popShader(); | ||
1533 | 1535 | | |||
1534 | endRenderWindow(); | 1536 | endRenderWindow(); | ||
1535 | } | 1537 | } | ||
1536 | 1538 | | |||
1537 | 1539 | | |||
1538 | //**************************************** | 1540 | //**************************************** | ||
▲ Show 20 Lines • Show All 926 Lines • Show Last 20 Lines |
Disable blend again in case it was enabled for this subsurface but following ones have no alpha?