Changeset View
Changeset View
Standalone View
Standalone View
effects/backgroundcontrast/contrast.cpp
Show First 20 Lines • Show All 410 Lines • ▼ Show 20 Line(s) | 409 | { | |||
---|---|---|---|---|---|
411 | effects->paintEffectFrame(frame, region, opacity, frameOpacity); | 411 | effects->paintEffectFrame(frame, region, opacity, frameOpacity); | ||
412 | } | 412 | } | ||
413 | 413 | | |||
414 | void ContrastEffect::doContrast(const QRegion& shape, const QRect& screen, const float opacity, const QMatrix4x4 &screenProjection) | 414 | void ContrastEffect::doContrast(const QRegion& shape, const QRect& screen, const float opacity, const QMatrix4x4 &screenProjection) | ||
415 | { | 415 | { | ||
416 | const QRegion actualShape = shape & screen; | 416 | const QRegion actualShape = shape & screen; | ||
417 | const QRect r = actualShape.boundingRect(); | 417 | const QRect r = actualShape.boundingRect(); | ||
418 | 418 | | |||
419 | qreal scale = GLRenderTarget::virtualScreenScale(); | ||||
420 | | ||||
419 | // Upload geometry for the horizontal and vertical passes | 421 | // Upload geometry for the horizontal and vertical passes | ||
420 | GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); | 422 | GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); | ||
421 | uploadGeometry(vbo, actualShape); | 423 | uploadGeometry(vbo, actualShape); | ||
422 | vbo->bindArrays(); | 424 | vbo->bindArrays(); | ||
423 | 425 | | |||
424 | // Create a scratch texture and copy the area in the back buffer that we're | 426 | // Create a scratch texture and copy the area in the back buffer that we're | ||
425 | // going to blur into it | 427 | // going to blur into it | ||
426 | GLTexture scratch(GL_RGBA8, r.width(), r.height()); | 428 | GLTexture scratch(GL_RGBA8, r.width() * scale, r.height() * scale); | ||
427 | scratch.setFilter(GL_LINEAR); | 429 | scratch.setFilter(GL_LINEAR); | ||
428 | scratch.setWrapMode(GL_CLAMP_TO_EDGE); | 430 | scratch.setWrapMode(GL_CLAMP_TO_EDGE); | ||
429 | scratch.bind(); | 431 | scratch.bind(); | ||
430 | 432 | | |||
431 | const QRect sg = GLRenderTarget::virtualScreenGeometry(); | 433 | const QRect sg = GLRenderTarget::virtualScreenGeometry(); | ||
432 | glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, r.x() - sg.x(), sg.height() - sg.y() - r.y() - r.height(), | 434 | glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, (r.x() - sg.x()) * scale, (sg.height() - sg.y() - r.y() - r.height()) * scale, | ||
433 | r.width(), r.height()); | 435 | scratch.width(), scratch.height()); | ||
434 | 436 | | |||
435 | // Draw the texture on the offscreen framebuffer object, while blurring it horizontally | 437 | // Draw the texture on the offscreen framebuffer object, while blurring it horizontally | ||
436 | 438 | | |||
437 | shader->bind(); | 439 | shader->bind(); | ||
438 | 440 | | |||
439 | 441 | | |||
440 | shader->setOpacity(opacity); | 442 | shader->setOpacity(opacity); | ||
441 | // Set up the texture matrix to transform from screen coordinates | 443 | // Set up the texture matrix to transform from screen coordinates | ||
442 | // to texture coordinates. | 444 | // to texture coordinates. | ||
443 | QMatrix4x4 textureMatrix; | 445 | QMatrix4x4 textureMatrix; | ||
444 | textureMatrix.scale(1.0 / scratch.width(), -1.0 / scratch.height(), 1); | 446 | textureMatrix.scale(1.0 / r.width(), -1.0 / r.height(), 1); | ||
445 | textureMatrix.translate(-r.x(), -scratch.height() - r.y(), 0); | 447 | textureMatrix.translate(-r.x(), -r.height() - r.y(), 0); | ||
446 | shader->setTextureMatrix(textureMatrix); | 448 | shader->setTextureMatrix(textureMatrix); | ||
447 | shader->setModelViewProjectionMatrix(screenProjection); | 449 | shader->setModelViewProjectionMatrix(screenProjection); | ||
448 | 450 | | |||
449 | vbo->draw(GL_TRIANGLES, 0, actualShape.rectCount() * 6); | 451 | vbo->draw(GL_TRIANGLES, 0, actualShape.rectCount() * 6); | ||
450 | 452 | | |||
451 | scratch.unbind(); | 453 | scratch.unbind(); | ||
452 | scratch.discard(); | 454 | scratch.discard(); | ||
453 | 455 | | |||
Show All 11 Lines |