surfaceflinger: Set max acquired buffer count

If triple framebuffers are enabled, the number of acquired
buffers isn't increased by default. Set the count to one less
than the max buffers to make sure all three buffers come into
play.

Change-Id: I65054ed4004607f5be68c893f6f621e821cfbf1c
SF: Fix invalid reduction of transparent region from a layer.

Reduce transparent region from a layer only if the transparent
region has valid intersection with the layer. Otherwise, reducing
a transparent region lying completely outside of the layer leads to
invalid sourcecrop values for the layer.

Change-Id: Iee9ba53a8072c21c9ba8a6d58cb14ca30f8600ba
CRs-Fixed: 620973
GlES2: Add NULL check

Check for NULL before calling thread specific glGetString.

CRs-fixed: 569609

Change-Id: Ifee8257152ba7ca7a05df5d7b113171b71d16c82
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: Allow gpu to render widevine level3

Allow gpu to render widevine level3 but keep
blocking screen shots.

CRs-fixed: 428647,424769,421767
Change-Id: I914232a062acbb7b17901dbf2b414973230e59d9
sf: Fix incorrect state reporting in dumpsys

Dumpsys utility access layer compositionType variable
with out proper protection. These variables are modified
during hwc_prepare call. Existing HAL lock protection is not
sufficient to address this issue. Failure to do this will
result in incorrect state reporting in dumpsys.

A new drawLock mutex in HWComposer that will be used in both
dumpsys and draw calls to ensure correct state is accessed.

Change-Id: I6289e0a3d1f5bbf35a18ddcd0538c9cda3e96c27
SF: Check ViewFrame validity before sending to hwc

Check if ViewFrame is valid before sending to hwc to make sure
composition produces valid values.

A ViewFrame can get invalid values when the framework is disconnected
which is a step necessary for some testing scenarios.

Change-Id: I2ad76061b6664dbb7d2aa3d66acaf99b880aedfe
sf: Determine if virtual display can use HWC for composition

For HWC virtual display using V4L2 approach:
1. HWC virtual display implementation doesn't send output buffer
   back to Surface Flinger.
2. For non-wfd virtual displays(e.g. Simulated Secondary Displays,
   Screen Record, CTS etc..), configure VDS to use GPU for
   composition on output/sink buffer.
3. For wfd virtual display (a.k.a hybrid wfd), use
   Framebuffer surface (similar to external display mechanism).

For HWC virtual display using VDS approach:
1. HWC is allocated for first virtual display connection.
2. Subsequent virtual display sessions will be composed by GLES driver.
ToDo: Modify VDS component to allocate hwcDisplayId based on
mForceHwcCopy (which is based on Usage Flags)

Change-Id: Ib7d2c00ca5fa07908b2eac8085654f8d2cd9af0b
sf: vds: Allocate display ID for displays composed/copied by HWC

We make VDS responsible for deciding if a display will be composed
by HWC. This is primarily based on the usage flags on the sink
buffer, as well as on the requested display resolution.

With this approach, there are two possible scenarios in which we
make a decision that applies while the display is connected:

1. The display will be composed by HWC, and we use WB to produce
   the final output.
2. The display will be composed by GLES/GPU and HWC has no knowledge
   of this display.

For case 1) we will have a valid display ID and for case 2) we will
have NO_MEMORY as the display ID.

Change-Id: I92b1e8b5973fea1a894caa7588dd95a1e551dd8e
sf: vds: Add support for secure virtual displays

1. Propagate secure flag on display creation

In SurfaceFlinger we have information that tells us whether a
display is secure or not. We need to propagate this information
when creating the corresponding virtual display, allowing us to
configure output buffers with the correct (secure) usage flags.

2. Use secure heap only for sessions that need HW level protection

Use MM heap only if the secure session needs hardware level
protection. At the present moment we are assuming that only displays
with the GRALLOC_USAGE_HW_ENCODER need hardware level protection.

Change-Id: I7e0d42ba3a81d1f5c42b1074e3018826b38b7a8d
frameworks/native: Modify dirtyRect only on GPU pre-rotation

Modify layer dirtyRect only when the buffers are pre-rotated by
GPU, not when the buffers are scheduled to be rotated during
composition.

Conflicts:
        services/surfaceflinger/Layer.cpp

Change-Id: I283833b9989be3032ce03fd955cea500b9bc4ae4
Add Digital Pen hovering cursor support

Add digital pen hovering cursor support so
that whenever the digital pen is enabled,
the hovering cursor will be shown.

Change-Id: I1b57448603486292ac501fd46b0e8d815b9eb232
SurfaceFlinger: Dont show Animation on External Display

- With this change the animation effect will not be shown on
  external display.
- It will change from portrait to landscape in one shot.
- Primary would still continue the animation effect
- set property sys.disable_ext_animation to disable animation

CRs-fixed: 453747

Conflicts:
	services/surfaceflinger/DisplayHardware/HWComposer.cpp
	services/surfaceflinger/DisplayHardware/HWComposer.h

Conflicts:
services/surfaceflinger/DisplayHardware/HWComposer.cpp
Change-Id: Ibd94bf166f08eeab1d504afe69230f7c6a617eb6
sf: Invalidate and Delay eDisplayProjectionChanged binder transaction

Invalidate and Delay the binder thread by 50 ms on
eDisplayProjectionChanged to trigger a draw cycle, so that it can fix
one incorrect frame on External, when we disable external animation.

Change-Id: I8d10aa8d943e9016f6ab81a5351d8286cdc4d2c6
SF: Fix Klockwork errors.

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

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

In MDP3 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: Allocate displayId based on usage flags for VD devices

Allocate hwcDisplayId for VirtualDisplayDevices based on
the usage flags set by the client.

Change-Id: I373a31e26709590301a7a83cf8b85853d8aa4c70
sf: vds: Queue Sink buffer during invalidate

commit id:f3c07d4f70f33c2fe5b14ca8fbcdfa4133cc72c7 didnt queue sink
buffer if there is no screen update on virtual displays.

This was required to support nested virtual displays. However,
this breaks Miracast WFD Sink initiated pause/resume functionality.

Allow Queueing sink buffers if mForceHwcCopy is true.

Change-Id: Id29c7ccedc0c10956b5af3a2d3e8b72966a4dfc0