+void wxWindowDCImpl::InitForWin(wxWindow *win, const wxRect *rect)
+{
+ wxCHECK_RET( win, "invalid window" );
+
+ m_window = win;
+
+ // obtain the surface used for painting:
+ wxPoint origin;
+ wxIDirectFBSurfacePtr surface;
+
+ wxRect rectOrig(rect ? *rect : wxRect(win->GetSize()));
+ wxRect r;
+
+ if ( !win->IsShownOnScreen() )
+ {
+ // leave 'r' rectangle empty to indicate the window is not visible,
+ // see below (below "create the surface:") for how is this case handled
+ }
+ else
+ {
+ // compute painting rectangle after clipping if we're in PaintWindow
+ // code, otherwise paint on the entire window:
+ r = rectOrig;
+
+ const wxRegion& updateRegion = win->GetUpdateRegion();
+ if ( win->GetTLW()->IsPainting() && !updateRegion.IsEmpty() )
+ {
+ r.Intersect(updateRegion.AsRect());
+ wxCHECK_RET( !r.IsEmpty(), "invalid painting rectangle" );
+
+ // parent TLW will flip the entire surface when painting is done
+ m_shouldFlip = false;
+ }
+ else
+ {
+ // One of two things happened:
+ // (1) the TLW is not being painted by PaintWindow() now; or
+ // (2) we're drawing on some window other than the one that is
+ // currently painted on by PaintWindow()
+ // In either case, we need to flip the surface when we're done
+ // painting and we don't have to use updateRegion for clipping.
+ // OTOH, if the window is (partially) hidden by being
+ // out of its parent's area, we must clip the surface accordingly.
+ r.Intersect(GetUncoveredWindowArea(win));
+ m_shouldFlip = true; // paint the results immediately
+ }
+ }