HardwareRenderer: Make sure preserve_buffer Swap is set properly

Change-Id: I322c6bad79fa56b10488ef14fd02d12eaed52a76
Merge branch 'ics' of github.com:CyanogenMod/ninjas_frameworks_base into HEAD
Hold a reference to the allocated buffers in GraphicBufferAlloc

Store the allocated GraphicBuffers in a vector list. This list is
cleared only when SurfaceTextures requests that the buffers be freed.
Premature deletion of GraphicBuffers and therefore deallocation of
gralloc handles are prevented.

This change partially reverts:
commit 5f05f99aaedaba18c426fac287bcb18d56dbe881
Author: Mathias Agopian <mathias@google.com>
Date:   Fri Apr 8 19:10:43 2011 -0700

    Fix a GraphicBuffer leak in SurfaceTexture

    This leak was intentional, it was there to deal with the fact that
    some gralloc implementations don't track buffer handles with
    file-descriptors so buffers needed to stay alive until there were
    registered, which is not guaranteed by binder transactions.

Change-Id: Ia732806bf8d8d15b66944569e8aa2120641d9812
CRs-fixed: 327655
SurfaceFlinger: Remove the old GraphicBuffer reference

Whenever we are allocating a new buffer, we delete the reference to
the previous buffer at that buffer slot. The newly allocated Graphic
Buffer is also added at the correct buffer slot in the
GraphicBufferAllocator.

Change-Id: Ie91e61e39b18759893c773ebda9ce7d7654d4144
Remove double qcom ifdef

Change-Id: Ia3957c3a841d051207faa41113c53911af431cb6
SurfaceTexture: Avoid binding texture if format not supported in GPU HW

Certain formats may not be supported in GPU HW. For them, avoid binding
textures. When the textures created from surface flinger, they may not
be needed if we are not using GPU composition.

Change-Id: I3eda6aa419dcef3d19f844d620d4c89236a6a714
Fix 'Avoid Binding Texture' logic in SurfaceTexture & SurfaceFlinger

Change-Id: I32de5ddb77e339b3749379804233c0772d29c983
DisplayHardware: Set MDP composition flag correctly

Change-Id: Id0c7172fe8578f3eb26bbe10a448a96fee1d72cd
Select texture target based on pixel format

Adreno is not optimized for GL_TEXTURE_EXTERNAL_OES, making GPU
utilization (and power), high with GL_TEXTURE_EXTERNAL_OES for
RGB formats.

Change texture target from GL_EXTERNAL_TEXTURE_OES to dynamically
select between GL_EXTERNAL_TEXTURE_OES, and GL_TEXTURE_2D based
on the pixel format.

This change is done to reduce the composition time for 8x55

ifdef Layer for QCOM_HARDWARE

Change-Id: I89ab1d60b23eef55442a9fd338b2a05b3304ce61
CRs-fixed: 328074
libs/rs: Fix parameter swap in rsAllocation

This change swaps index and size parameter in rsAllocation calls as
Google's comment suggests
libRS: release last surface reference when shutting down GL
SurfaceFlinger: Set the buffer size in the GraphicBufferAlloc

When setting the buffer size, store the required size, and allocate
the buffer of the required size in GraphicBufferAlloc, instead of
SurfaceTexture. We do this because SurfaceTexture does not always
run in the server process space. GraphicBufferAlloc always runs in the
server process.

Change-Id: I53661d8a9a27f9974837f2ed2fe13facf8dd8d9c
Remove opaque check in GLRenderer when preparing dirty region.

Since preserved swap is enabled, we need to clear the color buffer
when the scissor rect is prepared for a new process. This prevents
garbage to be present from the previous process in the color buffer

Change-Id: I72b7154c52affecfd6bf50889062b1769042d5d9
CRs-Fixed: 320345
SurfaceFlinger: Fix surfaceflinger crash when showing screen update

With selecting 'show screen update' option under Setting/Developer
options, there's crash in getYUVBufferCount() in Hwcomposer.cpp.
This occurs because the handles of hwc_layer_list have invalid
values that are passed from HWComposer:createWorkList().
Initialized hwc_layer_list after it is allocated.
Surfaceflinger: Compose UI in S3D format

The new member of LayerBase takes care of identifying layer for 3d
composition. When 3D composition is required the Layer takes care
of drawing in 3D format

Change-Id: I55c99a3cb612c6dd7a22d346a5b9a88c056c835d
SurfaceFlinger: Return error on invalid buffer creation

When a buffer is re-allocated on reconfiguration, return NULL
if there is an error in re-allocation.

Also, remove warnings during compilation.

Change-Id: Ie01bfcfbb469a106ef99bf1725376e2753206708
CRs-Fixed: 337660
SurfaceFlinger: Skip composition when rotation is not completed

When rotating, each layer's buffer is already changed to
new orientation before SurfaceFlinger gets the signal from
Window Manager. If the orientations of all the buffers are
changed to new orientation, then that's fine. But, sometimes,
only one buffer is changed and others remain the same.
In this case, skip composition.

Change-Id: I850fe8ee6d806e21833e6811f95878fcfb6f7c40
CRs-fixed: 338034
SurfaceFlinger: Prevent screencap command from failure

For secure windows, screen capture fails, and the screencap command
falls back to reading from the framebuffer directly.

Instead, draw a black screen on the framebuffer object if there is a
secure session, so that secure layers cannot be captured.

Change-Id: Ic14ee3f119f622b41f1af3861237204805fb3ca2
CRs-Fixed: 338570
SurfaceFlinger: notify HWC when layer is in asynchronous mode

When the layer is in asynchronous mode the HWC may choose a
different composition method.

CRs-Fixed: 335498
Change-Id: Ifa4658338e98e80e9a673bdf10ae388f0ad3ae9f
libRS: Correct the screen freezing issue

This fixes a timing issue where it could calculate a delay of 0
(indicating wait forever) when it has no pending commands to actually
execute. In such cases, it should just break out of the playback loop.
This also fixes a small issue with returning whether or not to redraw.
(Provided by Stephen Hines <srhines@google.com>)

CRs-Fixed: 330352

Change-Id: If3c880e1546105279d286ae76cc41e8b8f193ec1