Android GUI system Surfaceflinger (handletransaction)

Source: Internet
Author: User

1.1.1 Handletransaction

There are two similar functions, handletransaction need to acquire Mstatelock locks, perform handletransactionlocked, and finally place Mhwworklistdirty to true.

The last handletransactionlocked is the place to really deal with the business. From our previous explanation of transactionflags, it is inferred that its specific work should be divided into two parts, namely traversal (corresponding etraversalneeded) and transaction (corresponding to etransactionneeded).

void surfaceflinger::handletransactionlocked (Uint32_ttransactionflags)

{

Const layervector&currentlayers (MCURRENTSTATE.LAYERSSORTEDBYZ);

Const size_t Count =currentlayers.size ();

/* First part, traversal all layer*/

Const Boollayersneedtransaction = transactionflags & etraversalneeded;

if (layersneedtransaction) {//if required traversal

For (size_t i=0 i<count; i++) {//layer to process one by one

constsp<layerbase>& layer = Currentlayers[i];

uint32_t trflags = Layer->gettransactionflags (etransactionneeded);/* This layer whether

Need dotransaction*/

if (!trflags) continue;//if not required, go directly to the next

Const UINT32_TFLAGS = layer->dotransaction (0),//by each layer to do the internal processing, the following will do a detailed analysis

if (flags &layer::evisibleregion)//Each Layer calculates whether the visible region changes

Mvisibleregionsdirty = true;//Visible area changed

}

}

/* Part II, Surfaceflinger executive transaction*/

if (Transactionflags &etransactionneeded) {

if (mcurrentstate.orientation!= mdrawingstate.orientation) {

/* angle changes, you need to recalculate all the visible areas, and redraw */

const int DPY = 0;//First display

Const Intorientation = mcurrentstate.orientation; The new orientation

Graphicplane&plane (Graphicplane (dpy));

Plane.setorientation (orientation);//Set the changed rotation angle to the bottom manager

Update theshared control block

constdisplayhardware& HW (Plane.displayhardware ());

/* The following dcblk is a "service provider" for the application to query the current display properties, and therefore needs to be updated synchronously.

volatiledisplay_cblk_t* dcblk = mservercblk->displays + dpy;

Dcblk->orientation = orientation;

Dcblk->w =plane.getwidth ();

Dcblk->h =plane.getheight ();

mvisibleregionsdirty= true; Rotation angle changes, of course, the visible area will also change

Mdirtyregion.set (Hw.bounds ());//The entire screen area is "dirty."

}

if (Currentlayers.size () > MDrawingState.layersSortedByZ.size ()) {//New layer added

Mvisibleregionsdirty = true;//visible area needs recalculation

}

if (mlayersremoved) {/* may also have layers removed, the visible area will also change.

For example, the part of the original cover may be exposed.

Mlayersremoved =false; //

Mvisibleregionsdirty = true;

constlayervector& previouslayers (Mdrawingstate.layerssortedbyz);

Const size_t count= previouslayers.size ();

for (size_t i=0; i<count; i++) {

constsp<layerbase>& layer (previouslayers[i]);

if (Currentlayers.indexof (layer) < 0) {/* is present in the previous state and cannot be found in the existing state.

means it's been removed.

Mdirtyregionremovedlayer.orself (Layer->visibleregionscreen);/* Removed from layer visible

Area * *

}

}

}

}

CommitTransaction ()//And Layer::d otransaction () The practice is basically the same, a few more steps

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.