Code review comment for lp://qastaging/~mc-return/compiz/compiz.merge-fix1182794-screenshot-not-compatible-with-unityshell.0

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Hmm, I'm not really a fan of that approach as it causes spurious redraws due to the repaint-rescheduling happening every time a draw function is called (eg, all the time). Overdraw will certainly be the cause of flickering in some cases though.

The other option is to grab the current damage region and clip drawing to that so there is no overdraw. For example:

bool scissoringEnabled = glIsEnabled (GL_SCISSOR_TEST);
GLint lastScissorBox[4];

glGetIntegerv (GL_SCISSOR_BOX, lastScissorBox);

glEnable (GL_SCISSOR_TEST);

CompRect::vector rects = region.rects ();

foreach (const CompRect &rect, rects)
{
    glScissor (rect.x1 (),
               screen->height () - rect.y2 (),
               rect.width (),
               rect.height ());

    streamingBuffer->render ();
}

/* Reset scissor state */
if (!scissoringEnabled)
    glDisable (GL_SCISSOR_TEST);

/* Reset scissor box to old value */
glScissor (lastScissorBox[0],
           lastScissorBox[1],
           lastScissorBox[2],
           lastScissorBox[3]);

This reminds me that GLVertexBuffer could probably use a clip () or renderClipped () method so that we don't have to repeat this everywhere.

« Back to merge proposal