03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

finished. When the BeginRedraw()function is executed by the window server, it has two<br />

effects:<br />

� The window server sets a clipping region to the intersection of the invalid region, the<br />

region specified by BeginRedraw(), and the region of the window that is visible on the<br />

screen.<br />

� The window server then marks the region specified by BeginRe-draw() as valid (or,<br />

more accurately, it subtracts the begin-redraw region from its current invalid region).<br />

The application's draw code must then cover every pixel of the region specified by<br />

BeginRedraw(). If the application's draw code includes an explicit call to<br />

SetClippingRegion(), the region so specified is intersected with the clipping region<br />

calculated at BeginRedraw() time.<br />

When the application has finished redrawing, it calls EndRedraw(). This enables the<br />

window server to delete the region object that it allocated during BeginRedraw()<br />

processing.<br />

Concurrency<br />

You're probably wondering why the window server marks the region as valid at begin redraw<br />

time rather than end redraw. The reason is that Symbian OS is a multitasking operating<br />

system. The following theoretical sequence of events shows why this protocol is needed:<br />

� Application A issues begin-redraw. The affected region is marked valid on A's window.<br />

� A starts drawing.<br />

� Application B comes to the foreground, and its window overwrites A's.<br />

� B is terminated, so that A's window is again exposed.<br />

� Clearly, A's window is now invalid. The window server marks it as such.<br />

� A continues redrawing, and issues end-redraw.<br />

At the end of this sequence, the region of the screen covered by the reexposed region of A's<br />

window is in an arbitrary state. If the window server had marked A's window as valid at endredraw<br />

time, the window server would not know that it still needs to be redrawn. Instead, the<br />

window server marks A's window as valid at begin-redraw time so that, by the end of a<br />

sequence like this, the window is correctly marked invalid and can be redrawn.<br />

You might think this sequence of events would be rare, but it is possible, so the system has<br />

to address it properly.<br />

Redrawing<br />

You should now find it pretty easy to understand how redrawing works. When the window<br />

server knows that a region of a window is invalid, it sends a redraw message to the window's<br />

owning application, specifying the bounding rectangle of the invalid region. This is picked up<br />

by CONE and handled using the following code:<br />

EXPORT_C void CCoeControl::HandleRedrawEvent(const TRect& aRect)<br />

const<br />

{<br />

ActivateGc();<br />

Window().BeginRedraw(aRect);<br />

Draw(aRect);<br />

DrawComponents(aRect);<br />

Window().EndRedraw();

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!