SurfaceFlinger: Add NULL check for buffer handling

Add buffer handling NULL check in dequeueBuffer and
verify whether the output data from binder is not NULL
in queueBuffer and connect api's to avoid SF crash

CRs-Fixed: 573088
CRs-Fixed: 572315

Change-Id: I41cebbc0cbcbbb0fd5ecb38db7ec7b0c91cdffe9
libs/ui: Fix crash issue because of null pointer access

- handle NULL check is required while flatten GraphicsBuffer

CRs-fixed: 579102

Change-Id: I292b4b25dc1f5320378cc9e4affbad326e1fdaed
SurfaceFlinger: Change to support framebuffer flip for 2D blitters

- Surfaceflinger does not flip framebuffers when there are
  no layers marked for HWC_FRAMEBUFFER
- This change checks for the HWC_BLIT flag and will request a flip
  to a new FB_TARGET buffer even if there are no FRAMEBUFFER layers

Change-Id: Ib045e562481c6447d2064fc9693057652b417479
surfaceflinger: Apply bugfixes to the correct hwc code paths

Changes I2deaf2ed101e8ea76708862a6bb67751b6078794 and
I1cb44389a05c9ec049d7f0d39c288feccb11a91c, both meant to deal
with corner-case layer states, were mistakenly merged into
the pre-1.0-hwc code paths. Move them to their intended locations

Change-Id: Idd6b3513cc36dda21b552eee97f9ea91793df18f
SurfaceFlinger: Enable Vsync trace for SF Composition

Enable traces to show s/w vsync which is used for composition
by surfaceflinger, this helps in identifying the start of
composition cycle in systrace

Change-Id: Id892ca03bacd9f0cfe5ca2c3f8bb5aa892b37231
frameworks/native: Add support for Secure Display

- Add secure UI layers to primary and remove other layers from
  internal and external list for Secure Display usecase.
- Dont let secure UI layers to be captured on screen

Change-Id: Iebdad5c56247308604ee90928f6d6460a1f69279
SF: Block gpu rendering for virtual display widevine level3

In MPD3 we are using the widevine level3 for secure content
display. And this should applicable only for primary display
not for screen shot or screen recording.

CRs-Fixed: 595469
Change-Id: I99be2d81287ab746d5c4a2375c3106c59e61a8fc
SF: Fix Klockwork errors.

Resolve klockwork errors in frameworks/native
to avoid buffer overflow and memory leaks.

Change-Id: I7af17047538e621c872377090cea5b96f0924883
sf:  Add dirtyRect information to SF dumpsys

Display dirtyRect information generated for each layer in
SurfaceFlinger Dumpsys.

Change-Id: Ie60f4bf67bc28af0fcce006c166d8ae4ed4985e8
sf: Use Dirty Rect optimization in "Show Surface Updates" setting

When "Show Surface Updates" setting is ON in developer options, flash the
updating part (union dirty rect) instead of full layers when
GPU Tiled DR optimization is ON.

Change-Id: Id280cc2a22d46cc6539316d6dd0856e328c14c9e
CRs-Fixed: 679386
SF: Modify logic to handle "transparent Region" for displayFrame

sourceCrop and displayFrame calculations according to "transparent Region"
are not synchronized. Because of this mismatch scaling is introduced,
causing corruption in UI. To avoid this scaling, map displayFrame to
sourceCrop, apply reduce and remap result to displayFrame.

CRs-Fixed: 660699

Change-Id: I1e7ad5b1c8932413f53bb94a2e62895661b97057
Init display orientation according to panel orientation

   - Initialize the display default orientation to panel orientation.
   - honor the panel orientation only after the end of boot animation
     or the new orientation is as same as panel orientation.

Change-Id: Ieece097ff7c3710e379f47028900aed59a96c8d5
SF: Ensure boot animation always appears in panel orientation

Ensure that boot animation is always shown in panel
orientation.

Change-Id: I36a75ba5aea803a7b7cace3335a0d7f730612c5d
CRs-Fixed: 604934
sf: Set view frame of each display using binder

Set the view frame of a display using binder when set projection
for that display changes

Change-Id: Ib85ce80e88b207a4cf2559b2cc0e74e60ab3d4d4
surfaceflinger: Track the last surfaceview frame for latency dumps

When measuring GL latency with dumpsys, it's possible to hit a
race condition if the hardware is fast enough to complete rendering
the test cycle before the latency dump is requested, since it only
matches the latency for live layers (unless it's an animation. See
change I8bded1ea08a4cddefef0aa955401052bb9107c90)

So always save a reference to the last rendered SurfaceView frame,
and dump its values if there isn't an active one.

Change-Id: I740e9830161396ea955b5a53322bd8576b5136bc
Merge remote-tracking branch 'slim/kk4.4-caf' into ose

Conflicts:
	services/surfaceflinger/SurfaceFlinger.cpp