GPU canvas optimizations

[webkit] HTML5 canvas recording rendering optimization.

Currently, the canvas is being rendered on the WebCore thread into a
buffer that uses the default screen dimensions for calculating its
size. The reason is that the true screen dimensions aren't known
until we reach the UI thread in preparation for rendering
to the screen. To avoid creating canvas buffers that are larger than
necessary and require scaling before being composited, we convert the
canvas buffer into a SkPicture that gets played back on the UI thread.
We only enable the recording canvas for animations and we convert back
to a bitmap when necessary (pixel readbacks, etc)

Allows for turning on/off recording canvas through a property

Conflicts:

	Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
	Source/WebCore/platform/graphics/android/PlatformGraphicsContext.cpp
	Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h

HTML5 canvas gpu acceleration optimization

Extends recording canvas optimization to allow animated canvases
that use only bitmap sourced operations to render using opengl.
Bitmap draw calls within the canvas get translated to primitive
draw calls in opengl with appropriate texture coordinates

Conflicts:

	Source/WebCore/Android.mk
	Source/WebCore/platform/graphics/android/GLWebViewState.cpp
	Source/WebCore/platform/graphics/android/ShaderProgram.h
	Source/WebCore/platform/graphics/android/layers/LayerAndroid.h

Convert only canvas to compositing

Fix bug which was causing all elements to be compositing layers
Only canvas elements are converted to compositing layers

More aggressive collection of GL resources

Add aggressive collection of GL resources and rework code to use
non-failing texture creation to handle OOM error

Conflicts:

	Source/WebCore/platform/graphics/android/CanvasLayerShader.h
	Source/WebCore/platform/graphics/android/rendering/GLUtils.cpp

Fix transformation bug in accelerated canvas

Fix transformation bug due to differing coordinate systems between
source and destination.

Conflicts:

	Source/WebCore/platform/graphics/android/CanvasLayerShader.cpp

Disable gpu canvas for nonGL rendering

Disable gpu canvas for nonGL rendering and add code to fall back from
gpu accelerated canvas to non-gpu or non-recording state

Conflicts:

	Source/WebKit/android/nav/WebView.cpp

Fix z-index issue with adding a new layer

Fix z-index positioning of new layers for elements that originally
didn't have a separate layer.

Change Skpicture xfer mechanism for gpu canvas

Change the mechanism of transfer of SkPictures from layers to directly
using maps. In the old mechanism, the layers would get queued up and
dropped if the texture generation thread could not update its rendering
fast enough. This would lead to jerky visuals due to dropped frames
despite high rendering fps. In the new mechanism, through
synchronization between the webcore and the UI thread, the latest frame
for a canvas will get displayed regardless of the layer being used.

A fix for MR1 change for tablet UIs as the titleBar doesn't need to be
handled by layers anymore.

Conflicts:

	Source/WebCore/platform/graphics/android/CanvasLayerAndroid.cpp
	Source/WebCore/platform/graphics/android/CanvasLayerShader.cpp

Add clipping to prevent out of bounds rendering

Adding clipping based on canvas element size to clip any out of bounds
rendering.

Conflicts:

	Source/WebCore/platform/graphics/android/CanvasLayerAndroid.cpp

(cherry-picked from commit 97655b971225b5ff009906dfeb936edc89e22fdd)

Conflicts:

	Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
	Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h
	Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp
	Source/WebKit/android/nav/WebView.cpp

Change-Id: I302ce62f63657bca2698c14ef4099b7b3a271721
GpuCanvas re-arch

Changes in platform graphics and composition layers require these
modifications to the code. Change hooks and locations to match
updated architecture of canvas.

(cherry-picked from commit 2ef8784b06a1ec4ac4e7b9c87e72fadcd934ea9e)

Change-Id: I942f9d9df8b7fbd4177d4906a9a468a83b9f741b
Fix canvas double rendering issue.

CRs-fixed: 383199

(cherry-picked from commit 282af06af0737b09e90840e513d7319e187811a5)

Change-Id: Ib06255e172fde5eb005a6f1a11ba763c68e73d24
Bug fixes for gpu canvas

Revert changes for guimark3 fps banner
Fix bug due to incorret lifecycles of the gpu canvas object, where it
was getting deleted in the webcore thread and could potentially get
accessed in the UI thread for a couple of frames before the swap could
clear out old layer. This could cause UI thread to block while trying
to lock a non-existing object or potentially cause corruption.
Changed the creation and destruction of the gpu canvas object to the
canvas layer itself so that the lifecycle can be handled better and
protected using mutexes.

CRs-fixed: 399005
CRs-fixed: 400548

(cherry-picked from commit 332d4c233e5f2bacd4d027b63b3ae57eb6fb69a0)

Change-Id: I6a6376b6e362e3ad7ef9ec3d0964df0d72bf5ceb
Recording canvas bug fix

There is a bug due to which skpicture can be used at non frame boundaries.
The resulting skpicture that is converted to playback mode may be accessed by
javascript to record onto it, and causing a crash. The code using skpicture
now only accesses it at frame boundaries.

CRs-fixed: 404955

(cherry-picked from commit d610292ff51b273a3c1722df5fd2d863ffa950f8)

Change-Id: I7165a86acf69c206c166f79834ea70b15f9db14a
Add reset to default shader and states

Added reset to default shader in webkit to invalidate the cached program
and opacity as code there had been refactored to be initialized only
once as there is no other gl rendering by default. This forces the
default shader to re-index after the gpu canvas gl operation.

Fix memory leak for recording picture case of context

Change-Id: Idacd496471908f1d0800bb420d9c0a062c04aca7
CRs-fixed: 430575
webkit: Fix for memory corruption in computing css value of MediaQuery

RenderStyle object is not owned in MediaQueryEvaluator,
which is latter used in CSSPrimitiveValue::computeLengthFloat.
RenderStyle object is released as it goes out of scope and a memory
corruption is noticed. This patch ensures RenderStyle object
is owned in MediaQueryEvaluator.

Change-Id: I6bceb76d096c950f81bee039b92fa241c66f0a49
CRs-Fixed: 488574
Webkit: Fixed fuzzy word font issue in browser

the GL_LINEAR is more accurate wrt to texture mapping compared to
GL_NEAREST & usage of GL_LINEAR filtering is helping in fixing the
issue.

Change-Id: Ie13ad0fe419409f1a67cfb5b1089c925fe62ae99
CRs-fixed: 446916
Webkit: Null check in CanvasTexture::uploadImageBuffer

This patch adds preventive null check for imageBuffers in
CanvasTexture::uploadImageBuffer.

This code flow can hit when we are not using Gpu Rendering.

Change-Id: I1c6e68fa83ec87b4d4a2850c959c546e20292e5b
CRs-Fixed: 523517
Webkit: add to detect China phone number

Webkit only can detect US phone number,no support for China
phone number.US phone number is 10-digit but China phone number
is 11-digit,US country code is "1",webkit will fetch last 10 digits
as a valid US phone number and ignore "1",So China phone number is
not detected.

In order to detect China 11-digit phone number,we add one function
in webkit.And add some codes to fix an original bug that it can not
detect a valid US phone number(e.g. email content contains two phone
numbers, the first one is 02123456789, the second is 3987654321,
and then the second valid US phone number will never be detected).

CRs-Fixed: 500805

Change-Id: Ibc3a3ad9ac1a4e820e896081d98a70b8f6201ed5
Revert "Fix canvas double rendering issue"

This reverts commit e4effa7893df7170fac02014b7bb17cf06273f4a.
Bug does not seem to exist on newer release

Conflicts:
	Source/WebCore/html/HTMLCanvasElement.cpp

Change-Id: I4809f523abe746397fab809196c34fb73634085f
CRs-fixed: 494847
webkit : canvas bug fix. delay canvas paint till its context creation

some times HTMLCanvasElement::paint gets triggered before its
Context is created in JS. Due this GraphicsLayerAndroid assumes
that painting is done, whereas there is no buffer to paint since
the canvas context is not yet initialized.

This patch, don't allows canvas element paint until its context is
created. And once the context is created, we trigger style compute
to initiate paint on canvas element.

Change-Id: I4a985691f0e43f1dcba0c5de93720a5d9ec4e45f
CRs-fixed: 494847
webkit : canvas bug fix 2.exclusively setNeedsDisplay for canvas elements

delaying canvas paint till context creation, avoids painting canvas
elements that dont use context. Ex: empty canvas with background color.

Change-Id: I67af27b7fd84056b8fcac2b4def7a3623d02ded6
CRs-fixed: 553979