Changeset View
Changeset View
Standalone View
Standalone View
plugins/scenes/opengl/scene_opengl.cpp
Show First 20 Lines • Show All 1375 Lines • ▼ Show 20 Line(s) | |||||
1376 | { | 1376 | { | ||
1377 | if (!beginRenderWindow(mask, region, data)) | 1377 | if (!beginRenderWindow(mask, region, data)) | ||
1378 | return; | 1378 | return; | ||
1379 | 1379 | | |||
1380 | QMatrix4x4 windowMatrix = transformation(mask, data); | 1380 | QMatrix4x4 windowMatrix = transformation(mask, data); | ||
1381 | const QMatrix4x4 modelViewProjection = modelViewProjectionMatrix(mask, data); | 1381 | const QMatrix4x4 modelViewProjection = modelViewProjectionMatrix(mask, data); | ||
1382 | const QMatrix4x4 mvpMatrix = modelViewProjection * windowMatrix; | 1382 | const QMatrix4x4 mvpMatrix = modelViewProjection * windowMatrix; | ||
1383 | 1383 | | |||
1384 | | ||||
1385 | bool useX11TextureClamp = false; | ||||
1386 | | ||||
1384 | GLShader *shader = data.shader; | 1387 | GLShader *shader = data.shader; | ||
1385 | if (!shader) { | 1388 | if (!shader) { | ||
1386 | ShaderTraits traits = ShaderTrait::MapTexture; | 1389 | ShaderTraits traits = ShaderTrait::MapTexture; | ||
1390 | if (kwinApp()->operationMode() == Application::OperationModeX11) { | ||||
1391 | useX11TextureClamp = true; | ||||
1392 | traits |= ShaderTrait::ClampTexture; | ||||
zzag: stray semicolon | |||||
1393 | }; | ||||
1387 | 1394 | | |||
1388 | if (data.opacity() != 1.0 || data.brightness() != 1.0 || data.crossFadeProgress() != 1.0) | 1395 | if (data.opacity() != 1.0 || data.brightness() != 1.0 || data.crossFadeProgress() != 1.0) | ||
1389 | traits |= ShaderTrait::Modulate; | 1396 | traits |= ShaderTrait::Modulate; | ||
1390 | 1397 | | |||
1391 | if (data.saturation() != 1.0) | 1398 | if (data.saturation() != 1.0) | ||
1392 | traits |= ShaderTrait::AdjustSaturation; | 1399 | traits |= ShaderTrait::AdjustSaturation; | ||
1393 | 1400 | | |||
1394 | shader = ShaderManager::instance()->pushShader(traits); | 1401 | shader = ShaderManager::instance()->pushShader(traits); | ||
1395 | } | 1402 | } | ||
1396 | shader->setUniform(GLShader::ModelViewProjectionMatrix, mvpMatrix); | 1403 | shader->setUniform(GLShader::ModelViewProjectionMatrix, mvpMatrix); | ||
1397 | 1404 | | |||
1398 | shader->setUniform(GLShader::Saturation, data.saturation()); | 1405 | shader->setUniform(GLShader::Saturation, data.saturation()); | ||
1399 | 1406 | | |||
1400 | GLenum filter; | 1407 | GLenum filter; | ||
1401 | if (waylandServer()) { | 1408 | if (waylandServer()) { | ||
1402 | filter = GL_LINEAR; | 1409 | filter = GL_LINEAR; | ||
1403 | } else { | 1410 | } else { | ||
1404 | const bool isTransformed = mask & (Effect::PAINT_WINDOW_TRANSFORMED | | 1411 | const bool isTransformed = mask & (Effect::PAINT_WINDOW_TRANSFORMED | | ||
1405 | Effect::PAINT_SCREEN_TRANSFORMED); | 1412 | Effect::PAINT_SCREEN_TRANSFORMED); | ||
1406 | if (isTransformed && options->glSmoothScale() != 0) { | 1413 | if (isTransformed && options->glSmoothScale() != 0) { | ||
1407 | filter = GL_LINEAR; | 1414 | filter = GL_LINEAR; | ||
1408 | } else { | 1415 | } else { | ||
1409 | filter = GL_NEAREST; | 1416 | filter = GL_NEAREST; | ||
1410 | } | 1417 | } | ||
1411 | } | 1418 | } | ||
zzag: stray whitespace | |||||
1412 | 1419 | | |||
1413 | WindowQuadList quads[LeafCount]; | 1420 | WindowQuadList quads[LeafCount]; | ||
1414 | 1421 | | |||
1415 | // Split the quads into separate lists for each type | 1422 | // Split the quads into separate lists for each type | ||
1416 | foreach (const WindowQuad &quad, data.quads) { | 1423 | foreach (const WindowQuad &quad, data.quads) { | ||
1417 | switch (quad.type()) { | 1424 | switch (quad.type()) { | ||
1418 | case WindowQuadDecoration: | 1425 | case WindowQuadDecoration: | ||
1419 | quads[DecorationLeaf].append(quad); | 1426 | quads[DecorationLeaf].append(quad); | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 1507 | shader->setUniform(GLShader::ModulationConstant, | |||
1501 | modulate(nodes[i].opacity, data.brightness())); | 1508 | modulate(nodes[i].opacity, data.brightness())); | ||
1502 | opacity = nodes[i].opacity; | 1509 | opacity = nodes[i].opacity; | ||
1503 | } | 1510 | } | ||
1504 | 1511 | | |||
1505 | nodes[i].texture->setFilter(filter); | 1512 | nodes[i].texture->setFilter(filter); | ||
1506 | nodes[i].texture->setWrapMode(GL_CLAMP_TO_EDGE); | 1513 | nodes[i].texture->setWrapMode(GL_CLAMP_TO_EDGE); | ||
1507 | nodes[i].texture->bind(); | 1514 | nodes[i].texture->bind(); | ||
1508 | 1515 | | |||
1516 | if (i == ContentLeaf && useX11TextureClamp) { | ||||
1517 | // X11 windows are reparented to have their buffer in the middle of a larger texture | ||||
1518 | // holding the frame window. | ||||
1519 | // This code passes the texture geometry to the fragment shader | ||||
1520 | // any samples near the edge of the texture will be constrained to be | ||||
1521 | // at least half a pixel in bounds, meaning we don't bleed the transparent border | ||||
1522 | QRectF bufferContentRect = clientShape().boundingRect(); | ||||
1523 | bufferContentRect.adjust(0.5, 0.5, -0.5, -0.5); | ||||
1524 | const QRect bufferGeometry = toplevel->bufferGeometry(); | ||||
1525 | | ||||
1526 | float leftClamp = bufferContentRect.left() / bufferGeometry.width(); | ||||
1527 | float topClamp = bufferContentRect.top() / bufferGeometry.height(); | ||||
1528 | float rightClamp = bufferContentRect.right() / bufferGeometry.width(); | ||||
1529 | float bottomClamp = bufferContentRect.bottom() / bufferGeometry.height(); | ||||
1530 | shader->setUniform(GLShader::TextureClamp, QVector4D({leftClamp, topClamp, rightClamp, bottomClamp})); | ||||
1531 | } else { | ||||
1532 | shader->setUniform(GLShader::TextureClamp, QVector4D({0, 0, 1, 1})); | ||||
1533 | } | ||||
1534 | | ||||
1509 | vbo->draw(region, primitiveType, nodes[i].firstVertex, nodes[i].vertexCount, m_hardwareClipping); | 1535 | vbo->draw(region, primitiveType, nodes[i].firstVertex, nodes[i].vertexCount, m_hardwareClipping); | ||
1510 | } | 1536 | } | ||
1511 | 1537 | | |||
1512 | vbo->unbindArrays(); | 1538 | vbo->unbindArrays(); | ||
1513 | 1539 | | |||
1514 | // render sub-surfaces | 1540 | // render sub-surfaces | ||
1515 | auto wp = windowPixmap<OpenGLWindowPixmap>(); | 1541 | auto wp = windowPixmap<OpenGLWindowPixmap>(); | ||
1516 | const auto &children = wp ? wp->children() : QVector<WindowPixmap*>(); | 1542 | const auto &children = wp ? wp->children() : QVector<WindowPixmap*>(); | ||
▲ Show 20 Lines • Show All 1117 Lines • Show Last 20 Lines |
stray semicolon