Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To build the smallest rectangle that contains all the areas that need to be repainted:</p> <ul> <li>Start with a blank area (perhaps a rectangle set to 0,0,0,0 - something you can detect as 'no update required')</li> </ul> <p>For each dirty area added:</p> <ul> <li>Normalize the new area (i.e. ensure that left is less than right, top less than bottom)</li> <li>If the dirty rectangle is currently empty, set it to the supplied area</li> <li>Otherwise, set the left and top co-ordinates of the dirty rectangle to the smallest of {dirty,new}, and the right and bottom co-ordinates to the largest of {dirty,new}.</li> </ul> <p>Windows, at least, maintains an <em>update region</em> of the changes that it's been informed of, and any repainting that needs to be done due to the window being obscured and revealed. A <em>region</em> is an object that is made up of many possibly discontinuous rectangles, polygons and ellipses. You tell Windows about a part of the screen that needs to be repainted by calling InvalidateRect - there is also an InvalidateRgn function for more complicated areas. If you choose to do some painting before the next WM_PAINT message arrives, and you want to exclude that from the dirty area, there are ValidateRect and ValidateRgn functions.</p> <p>When you start painting with BeginPaint, you supply a PAINTSTRUCT that Windows fills with information about what needs to be painted. One of the members is the smallest rectangle that contains the invalid region. You can get the region itself using GetUpdateRgn (you must call this before BeginPaint, because BeginPaint marks the whole window as valid) if you want to minimize drawing when there are multiple small invalid areas.</p> <p>I would assume that, as minimizing drawing was important on the Mac and on X when those environments were originally written, there are equivalent mechanisms for maintaining an update region.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload