sf: Use DirtyRect to optimize Full GPU composition

Use layer DirtyRect information in optimizing full GPU composition by
using startTile and endTile GL calls.

Change-Id: Iec0f9de2ce667438bbcc00d02e500055068df05a
sf: Validate display device id and disable dirtyrect composition

1. Add validation check for display device id to prevent out of bound
   array access.
2. Disable Dirty rect composition feature for GPU by default

Change-Id: I4976468bb156fff197c8c38fe680e10512b4feb5
frameworks/native:  Reset dirtyRect after every queuebuffer call.

Sometimes HWR does not generate dirtyRect even when it updates the
buffer. To avoid incorrect DR calculation in such cases reset
cached dirtyRect after every queueBuffer call.

Change-Id: Iad9a2b1ecb4cf2a3789f2734a2d0e928dc56c9f0
MemoryHeapBase: ifdef for gingerbread/froyo compatibility

Allow to "revert" by a board config flag the offset member addon
see commit f24c4cd0f20 (aosp change id Ie618fb5c0718e)

This change is required to use overlay based proprietary camera libs
coming from gingerbread and froyo builds.

This change also requires a global cflag named BINDER_COMPAT
because a lot of modules use the MemoryHeap includes

Add this in your BoardConfig.mk :
COMMON_GLOBAL_CFLAGS += -DBINDER_COMPAT

Backported from /#/c/13317/

Change-Id: Ic8e18bc60a7310b0fa90ad251381e9f7d9e58d5e
Overlay support for legacy camera libs

Move http://review.cyanogenmod.com/#/c/13285/ to proper place for jellybean.

1. Rename OverlayHtc to Overlay in file names
2. Use BOARD_USES_LEGACY_OVERLAY to enable

Signed-off-by: Evan McClain <aeroevan@gmail.com>
Change-Id: Ib6afd1b610b1d3e263fcaa38585e7a1116baaf58

Conflicts:
	libs/ui/Android.mk
sensorservice: Add legacy sensors fusion.

This change allows devices with accelerometer & magnetometer but
without gyroscope to still get virtual sensors such as Gravity,
Linear Acceleration and Rotation Vector.

Ported from: http://review.cyanogenmod.org/#/c/31329/

Change-Id: Ifa702cb0383ea1fd84511539fb67ec69ce9a558a
native: add flag to disable legacy sensors fusion
Causes problems on all p31xx devices.
http://pastebin.com/PabjFVWP

Change-Id: I12df77c5bca2c67447ced1e3d32b405009d9e3aa