1.1.1 Handlepageflip
Pageflip can be understood as "paging". From this point of view, it should be related to the layer buffer-because it is a multiple buffering mechanism, at the appropriate time, we need to do "flip" action.
void Surfaceflinger::handlepageflip ()
{...
Const DISPLAYHARDWARE&HW = Graphicplane (0). Displayhardware ()//display with number 0
Const regionscreenregion (Hw.bounds ());//Entire screen area
Const layervector¤tlayers (MDRAWINGSTATE.LAYERSSORTEDBYZ);/* Current All layers*/
const BOOL Visibleregions = Lockpageflip (currentlayers); The following is a detailed analysis of this function, noting its return
Value is a bool type variable. */
if (Visibleregions | | Mvisibleregionsdirty) {//visible area changed
regionopaqueregion;//Opaque Area
Computevisibleregions (Currentlayers, Mdirtyregion, opaqueregion)/*step2. Calculate Visible Area * *
/*step3. Reconstruct the Mvisiblelayerssortedbyz, that is, the sort of all visible layers * *
Const size_t count= currentlayers.size ();
Mvisiblelayerssortedbyz.clear ()/Empty
Mvisiblelayerssortedbyz.setcapacity (count);//capacity
for (size_t i=0; i<count; i++) {
if (!currentlayers[i]->visibleregionscreen.isempty ())//Current layer has visible area
Mvisiblelayerssortedbyz.add (Currentlayers[i]);
}
Mwormholeregion = Screenregion.subtract (opaqueregion);/*step4. Worm Hole Calculation * *
Mvisibleregionsdirty = false;
Invalidatehwcgeometry ();
}
Unlockpageflip (currentlayers);/*step5 with Lockpageflip.
...
Mdirtyregion.andself (screenregion);//Excluding areas outside the screen range
}