You misread the code (although I admit it is confusing). There are 2 different "sequence" variables.
One is LayerBase::sequence, used for disambiguate the ordering of layers, as you guessed. The other one is LayerBase::State::sequence, which is entirely different and is used during transaction as a way to detect that the state has changed. Additionally, none of this would explain z-fighting, since SurfaceFlinger doesn't use the depth buffer at all -- it justs draws the layers in order. The depth buffer of each layer is not used at all during composition. -- pixelflinger On Tue, Jun 19, 2012 at 10:23 AM, Inan Top <[email protected]> wrote: > Hi all, > > I've been trying to track down a rendering issue in our application, > and I'm considering z-fighting as a potential root cause. I've tracked > the z-ordering logic from SurfaceFlinger.h down to LayerBase.cpp. Here > are my findings, please correct me if I'm wrong: > > SurfaceFlinger.h composites the layers in z-order, which is determined > by the ViewParent classes. In the case that two elements have the same > z-value their *sequence* is used as the comparison for ordering > purposes. Sequence appears to be an attempt at a UID for each > LayerBase instance. > > Sequence is initialized to an incremented sSequence, which is a static > member of the LayerBase class. This guarantees that no two instances > of LayerBase begin with the same sequence. So far so good. > > However each of the transformation operations within LayerBase, i.e. > setAlpha, setPosition, etc. increment this sequence value. This means > (as far as I understand) that I can create two LayerBase objects A and > B, with sequence 1 and 2 respectively to begin with, and then do some > sort of transformation onto A causing it to increment its sequence to > 2 also. > > This could potentially result in a situation where A and B share the > same z-order AND the same sequence, in which case ordering is not sane > and z-fighting issues can occur. > > Am I correct in that assessment or am I completely misunderstanding > this system? I'm completely new to Android so don't worry about > hurting my feelings if I'm completely wrong. > > -- > unsubscribe: [email protected] > website: http://groups.google.com/group/android-porting -- unsubscribe: [email protected] website: http://groups.google.com/group/android-porting
