summaryrefslogtreecommitdiffstats
path: root/Source/WebCore
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore')
-rw-r--r--Source/WebCore/Android.derived.jscbindings.mk1
-rw-r--r--Source/WebCore/Android.derived.v8bindings.mk1
-rw-r--r--Source/WebCore/Android.jscbindings.mk1
-rw-r--r--Source/WebCore/Android.mk5
-rw-r--r--Source/WebCore/Android.v8bindings.mk1
-rw-r--r--Source/WebCore/DerivedSources.cpp1
-rw-r--r--Source/WebCore/bindings/js/JSBindingsAllInOne.cpp1
-rw-r--r--Source/WebCore/bindings/js/JSDOMWindowCustom.cpp6
-rw-r--r--Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp61
-rw-r--r--Source/WebCore/bindings/v8/V8DOMWindowShell.cpp12
-rw-r--r--Source/WebCore/bindings/v8/V8Proxy.cpp34
-rw-r--r--Source/WebCore/bindings/v8/V8Proxy.h8
-rw-r--r--Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp61
-rw-r--r--Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp43
-rw-r--r--Source/WebCore/bridge/jni/v8/JavaValueV8.h13
-rw-r--r--Source/WebCore/css/AndroidCSSPropertyNames.in11
-rw-r--r--Source/WebCore/css/CSSComputedStyleDeclaration.cpp35
-rw-r--r--Source/WebCore/css/CSSImportRule.cpp22
-rw-r--r--Source/WebCore/css/CSSImportRule.h8
-rw-r--r--Source/WebCore/css/CSSMutableStyleDeclaration.cpp14
-rw-r--r--Source/WebCore/css/CSSParser.cpp85
-rw-r--r--Source/WebCore/css/CSSStyleDeclaration.cpp1
-rw-r--r--Source/WebCore/css/CSSStyleSelector.cpp132
-rw-r--r--Source/WebCore/css/StyleBase.cpp33
-rw-r--r--Source/WebCore/css/StyleBase.h12
-rw-r--r--Source/WebCore/css/mediaControlsAndroid.css5
-rw-r--r--Source/WebCore/dom/Document.cpp14
-rw-r--r--Source/WebCore/dom/Node.cpp33
-rw-r--r--Source/WebCore/dom/Node.h12
-rw-r--r--Source/WebCore/dom/ProcessingInstruction.cpp22
-rw-r--r--Source/WebCore/dom/ProcessingInstruction.h8
-rw-r--r--Source/WebCore/dom/Text.cpp2
-rw-r--r--Source/WebCore/editing/SelectionController.cpp4
-rw-r--r--Source/WebCore/html/HTMLCanvasElement.h16
-rw-r--r--Source/WebCore/html/HTMLDocument.cpp22
-rw-r--r--Source/WebCore/html/HTMLDocument.h8
-rw-r--r--Source/WebCore/html/HTMLLinkElement.cpp22
-rw-r--r--Source/WebCore/html/HTMLLinkElement.h8
-rw-r--r--Source/WebCore/html/HTMLMediaElement.cpp39
-rw-r--r--Source/WebCore/html/HTMLMediaElement.h4
-rw-r--r--Source/WebCore/html/canvas/ArrayBufferView.h1
-rw-r--r--Source/WebCore/html/canvas/Float64Array.cpp62
-rw-r--r--Source/WebCore/html/canvas/Float64Array.h75
-rw-r--r--Source/WebCore/html/canvas/Float64Array.idl48
-rw-r--r--Source/WebCore/html/parser/HTMLDocumentParser.cpp14
-rw-r--r--Source/WebCore/loader/FrameLoader.cpp19
-rw-r--r--Source/WebCore/loader/archive/android/WebArchiveAndroid.cpp61
-rw-r--r--Source/WebCore/loader/cache/MemoryCache.h6
-rw-r--r--Source/WebCore/loader/icon/IconDatabase.cpp26
-rw-r--r--Source/WebCore/page/DOMWindow.idl1
-rw-r--r--Source/WebCore/page/Frame.cpp4
-rw-r--r--Source/WebCore/page/FrameView.cpp14
-rw-r--r--Source/WebCore/platform/Arena.cpp12
-rw-r--r--Source/WebCore/platform/Arena.h4
-rw-r--r--Source/WebCore/platform/NotImplemented.h16
-rw-r--r--Source/WebCore/platform/android/RenderThemeAndroid.cpp232
-rw-r--r--Source/WebCore/platform/android/RenderThemeAndroid.h4
-rw-r--r--Source/WebCore/platform/android/SharedTimerAndroid.cpp2
-rw-r--r--Source/WebCore/platform/graphics/Color.h9
-rw-r--r--Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp9
-rw-r--r--Source/WebCore/platform/graphics/android/BaseRenderer.cpp20
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.cpp186
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.h6
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.cpp157
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTileTexture.h54
-rw-r--r--Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp217
-rw-r--r--Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h74
-rw-r--r--Source/WebCore/platform/graphics/android/FontAndroid.cpp91
-rw-r--r--Source/WebCore/platform/graphics/android/FontPlatformData.h2
-rw-r--r--Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp50
-rw-r--r--Source/WebCore/platform/graphics/android/GLExtras.cpp87
-rw-r--r--Source/WebCore/platform/graphics/android/GLExtras.h23
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.cpp202
-rw-r--r--Source/WebCore/platform/graphics/android/GLUtils.h13
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp136
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.h11
-rw-r--r--Source/WebCore/platform/graphics/android/GaneshContext.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/GaneshRenderer.cpp40
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp30
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h4
-rw-r--r--Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/ImageTexture.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/InspectorCanvas.cpp149
-rw-r--r--Source/WebCore/platform/graphics/android/InspectorCanvas.h102
-rw-r--r--Source/WebCore/platform/graphics/android/Layer.cpp8
-rw-r--r--Source/WebCore/platform/graphics/android/Layer.h8
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.cpp106
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.h8
-rw-r--r--Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h1
-rw-r--r--Source/WebCore/platform/graphics/android/MediaTexture.cpp1
-rw-r--r--Source/WebCore/platform/graphics/android/PaintedSurface.cpp12
-rw-r--r--Source/WebCore/platform/graphics/android/PaintedSurface.h2
-rw-r--r--Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h1
-rw-r--r--Source/WebCore/platform/graphics/android/RasterRenderer.cpp10
-rw-r--r--Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp29
-rw-r--r--Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h3
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.cpp384
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.h138
-rw-r--r--Source/WebCore/platform/graphics/android/SharedTexture.cpp248
-rw-r--r--Source/WebCore/platform/graphics/android/SharedTexture.h118
-rw-r--r--Source/WebCore/platform/graphics/android/TextureInfo.cpp3
-rw-r--r--Source/WebCore/platform/graphics/android/TextureInfo.h16
-rw-r--r--Source/WebCore/platform/graphics/android/TiledPage.cpp10
-rw-r--r--Source/WebCore/platform/graphics/android/TiledTexture.cpp35
-rw-r--r--Source/WebCore/platform/graphics/android/TiledTexture.h10
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp57
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.h33
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.cpp237
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.h35
-rw-r--r--Source/WebCore/platform/graphics/android/TreeManager.cpp51
-rw-r--r--Source/WebCore/platform/graphics/android/TreeManager.h7
-rw-r--r--Source/WebCore/platform/graphics/android/VerticalTextMap.cpp37
-rw-r--r--Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp165
-rw-r--r--Source/WebCore/platform/graphics/android/VideoLayerAndroid.h8
-rw-r--r--Source/WebCore/platform/graphics/android/VideoLayerManager.cpp59
-rw-r--r--Source/WebCore/platform/graphics/android/VideoLayerManager.h20
-rw-r--r--Source/WebCore/platform/graphics/android/android_graphics.cpp73
-rw-r--r--Source/WebCore/platform/graphics/android/android_graphics.h6
-rw-r--r--Source/WebCore/rendering/InlineTextBox.cpp1
-rw-r--r--Source/WebCore/rendering/RenderArena.cpp7
-rw-r--r--Source/WebCore/rendering/RenderArena.h4
-rw-r--r--Source/WebCore/rendering/RenderLayer.cpp3
-rw-r--r--Source/WebCore/rendering/RenderLayerCompositor.cpp14
-rw-r--r--Source/WebCore/rendering/style/RenderStyle.h39
-rw-r--r--Source/WebCore/rendering/style/StyleRareInheritedData.cpp34
-rw-r--r--Source/WebCore/rendering/style/StyleRareInheritedData.h11
-rw-r--r--Source/WebCore/storage/AbstractDatabase.h4
-rw-r--r--Source/WebCore/storage/DatabaseTask.cpp16
-rw-r--r--Source/WebCore/storage/DatabaseTask.h10
-rw-r--r--Source/WebCore/storage/SQLTransaction.cpp2
-rw-r--r--Source/WebCore/storage/SQLTransaction.h2
-rw-r--r--Source/WebCore/svg/SVGFontFaceUriElement.h16
-rw-r--r--Source/WebCore/workers/WorkerContext.idl1
-rw-r--r--Source/WebCore/xml/XSLImportRule.h16
134 files changed, 2466 insertions, 2763 deletions
diff --git a/Source/WebCore/Android.derived.jscbindings.mk b/Source/WebCore/Android.derived.jscbindings.mk
index d859b15..f48fc6a 100644
--- a/Source/WebCore/Android.derived.jscbindings.mk
+++ b/Source/WebCore/Android.derived.jscbindings.mk
@@ -316,6 +316,7 @@ GEN := \
$(intermediates)/html/canvas/JSCanvasRenderingContext2D.h \
$(intermediates)/html/canvas/JSDataView.h \
$(intermediates)/html/canvas/JSFloat32Array.h \
+ $(intermediates)/html/canvas/JSFloat64Array.h \
$(intermediates)/html/canvas/JSInt8Array.h \
$(intermediates)/html/canvas/JSInt16Array.h \
$(intermediates)/html/canvas/JSInt32Array.h \
diff --git a/Source/WebCore/Android.derived.v8bindings.mk b/Source/WebCore/Android.derived.v8bindings.mk
index 992cc40..546cefe 100644
--- a/Source/WebCore/Android.derived.v8bindings.mk
+++ b/Source/WebCore/Android.derived.v8bindings.mk
@@ -301,6 +301,7 @@ GEN := \
$(intermediates)/bindings/V8CanvasRenderingContext2D.h \
$(intermediates)/bindings/V8DataView.h \
$(intermediates)/bindings/V8Float32Array.h \
+ $(intermediates)/bindings/V8Float64Array.h \
$(intermediates)/bindings/V8Int8Array.h \
$(intermediates)/bindings/V8Int16Array.h \
$(intermediates)/bindings/V8Int32Array.h \
diff --git a/Source/WebCore/Android.jscbindings.mk b/Source/WebCore/Android.jscbindings.mk
index bdd6d92..09ea61c 100644
--- a/Source/WebCore/Android.jscbindings.mk
+++ b/Source/WebCore/Android.jscbindings.mk
@@ -121,6 +121,7 @@ LOCAL_SRC_FILES += \
bindings/js/JSEventTarget.cpp \
bindings/js/JSExceptionBase.cpp \
bindings/js/JSFloat32ArrayCustom.cpp \
+ bindings/js/JSFloat64ArrayCustom.cpp \
bindings/js/JSFileReaderCustom.cpp \
bindings/js/JSGeolocationCustom.cpp \
bindings/js/JSHTMLAllCollectionCustom.cpp \
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk
index 6542931..bdf6410 100644
--- a/Source/WebCore/Android.mk
+++ b/Source/WebCore/Android.mk
@@ -378,6 +378,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
html/canvas/CanvasStyle.cpp \
html/canvas/DataView.cpp \
html/canvas/Float32Array.cpp \
+ html/canvas/Float64Array.cpp \
html/canvas/Int16Array.cpp \
html/canvas/Int32Array.cpp \
html/canvas/Int8Array.cpp \
@@ -638,7 +639,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/BaseTileTexture.cpp \
platform/graphics/android/BitmapAllocatorAndroid.cpp \
platform/graphics/android/ClassTracker.cpp \
- platform/graphics/android/DoubleBufferedTexture.cpp \
platform/graphics/android/FontAndroid.cpp \
platform/graphics/android/FontCacheAndroid.cpp \
platform/graphics/android/FontCustomPlatformData.cpp \
@@ -658,6 +658,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/ImageSourceAndroid.cpp \
platform/graphics/android/ImagesManager.cpp \
platform/graphics/android/ImageTexture.cpp \
+ platform/graphics/android/InspectorCanvas.cpp \
platform/graphics/android/Layer.cpp \
platform/graphics/android/LayerAndroid.cpp \
platform/graphics/android/MediaLayer.cpp \
@@ -672,7 +673,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/ScrollableLayerAndroid.cpp \
platform/graphics/android/SharedBufferStream.cpp \
platform/graphics/android/ShaderProgram.cpp \
- platform/graphics/android/SharedTexture.cpp \
platform/graphics/android/TextureInfo.cpp \
platform/graphics/android/TexturesGenerator.cpp \
platform/graphics/android/TilesManager.cpp \
@@ -811,6 +811,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
plugins/DOMPluginArray.cpp \
plugins/PluginData.cpp \
plugins/PluginDatabase.cpp \
+ plugins/PluginDebug.cpp \
plugins/PluginMainThreadScheduler.cpp \
plugins/PluginPackage.cpp \
plugins/PluginStream.cpp \
diff --git a/Source/WebCore/Android.v8bindings.mk b/Source/WebCore/Android.v8bindings.mk
index 283a212..7858ef3 100644
--- a/Source/WebCore/Android.v8bindings.mk
+++ b/Source/WebCore/Android.v8bindings.mk
@@ -130,6 +130,7 @@ LOCAL_SRC_FILES += \
bindings/v8/custom/V8EventSourceConstructor.cpp \
bindings/v8/custom/V8FileReaderCustom.cpp \
bindings/v8/custom/V8Float32ArrayCustom.cpp \
+ bindings/v8/custom/V8Float64ArrayCustom.cpp \
bindings/v8/custom/V8GeolocationCustom.cpp \
bindings/v8/custom/V8HistoryCustom.cpp \
bindings/v8/custom/V8HTMLAllCollectionCustom.cpp \
diff --git a/Source/WebCore/DerivedSources.cpp b/Source/WebCore/DerivedSources.cpp
index 3bba78c..45a425c 100644
--- a/Source/WebCore/DerivedSources.cpp
+++ b/Source/WebCore/DerivedSources.cpp
@@ -130,6 +130,7 @@
#include "JSFileWriterSync.cpp"
#include "JSWebKitFlags.cpp"
#include "JSFloat32Array.cpp"
+#include "JSFloat64Array.cpp"
#include "JSGeolocation.cpp"
#include "JSGeoposition.cpp"
#include "JSHashChangeEvent.cpp"
diff --git a/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp b/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
index a457ce8..82367b2 100644
--- a/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
+++ b/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
@@ -81,6 +81,7 @@
#include "JSEventTarget.cpp"
#include "JSExceptionBase.cpp"
#include "JSFloat32ArrayCustom.cpp"
+#include "JSFloat64ArrayCustom.cpp"
#include "JSGeolocationCustom.cpp"
#include "JSHTMLAllCollectionCustom.cpp"
#include "JSHTMLAppletElementCustom.cpp"
diff --git a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
index 4bde9e5..938be96 100644
--- a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -31,6 +31,7 @@
#include "JSEventListener.h"
#include "JSEventSource.h"
#include "JSFloat32Array.h"
+#include "JSFloat64Array.h"
#include "JSHTMLCollection.h"
#include "JSHistory.h"
#include "JSImageConstructor.h"
@@ -569,6 +570,11 @@ JSValue JSDOMWindow::float32Array(ExecState* exec) const
return getDOMConstructor<JSFloat32ArrayConstructor>(exec, this);
}
+JSValue JSDOMWindow::float64Array(ExecState* exec) const
+{
+ return getDOMConstructor<JSFloat64ArrayConstructor>(exec, this);
+}
+
JSValue JSDOMWindow::dataView(ExecState* exec) const
{
return getDOMConstructor<JSDataViewConstructor>(exec, this);
diff --git a/Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp b/Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp
new file mode 100644
index 0000000..446b0ec
--- /dev/null
+++ b/Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSFloat64Array.h"
+
+#include "Float64Array.h"
+#include "JSArrayBufferViewHelper.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+void JSFloat64Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)
+{
+ impl()->set(index, value.toNumber(exec));
+}
+
+JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Float64Array* object)
+{
+ return toJSArrayBufferView<JSFloat64Array>(exec, globalObject, object);
+}
+
+JSC::JSValue JSFloat64Array::set(JSC::ExecState* exec)
+{
+ return setWebGLArrayHelper(exec, impl(), toFloat64Array);
+}
+
+EncodedJSValue JSC_HOST_CALL JSFloat64ArrayConstructor::constructJSFloat64Array(ExecState* exec)
+{
+ JSFloat64ArrayConstructor* jsConstructor = static_cast<JSFloat64ArrayConstructor*>(exec->callee());
+ RefPtr<Float64Array> array = constructArrayBufferView<Float64Array, double>(exec);
+ if (!array.get())
+ // Exception has already been thrown.
+ return JSValue::encode(JSValue());
+ return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
index e025008..c3a0cbb 100644
--- a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
+++ b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp
@@ -76,10 +76,6 @@
#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
namespace WebCore {
static void handleFatalErrorInV8()
@@ -283,10 +279,6 @@ bool V8DOMWindowShell::initContextIfNeeded()
if (!m_context.IsEmpty())
return false;
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::JavaScriptInitTimeCounter);
-#endif
-
// Create a handle scope for all local handles.
v8::HandleScope handleScope;
@@ -352,10 +344,6 @@ bool V8DOMWindowShell::initContextIfNeeded()
// we do isolated worlds the WebCore way.
m_frame->loader()->dispatchDidClearWindowObjectInWorld(0);
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::JavaScriptInitTimeCounter, __FUNCTION__);
-#endif
-
return true;
}
diff --git a/Source/WebCore/bindings/v8/V8Proxy.cpp b/Source/WebCore/bindings/v8/V8Proxy.cpp
index ca57fa8..d90cf1c 100644
--- a/Source/WebCore/bindings/v8/V8Proxy.cpp
+++ b/Source/WebCore/bindings/v8/V8Proxy.cpp
@@ -83,14 +83,6 @@
#include <wtf/UnusedParam.h>
#include <wtf/text/StringConcatenate.h>
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
-#if PLATFORM(ANDROID)
-#include <wtf/text/CString.h>
-#endif
-
namespace WebCore {
// Static list of registered extensions
@@ -209,16 +201,6 @@ V8Proxy::~V8Proxy()
}
v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, const TextPosition0& scriptStartPosition, v8::ScriptData* scriptData)
-#ifdef ANDROID_INSTRUMENT
-{
- android::TimeCounter::start(android::TimeCounter::JavaScriptParseTimeCounter);
- v8::Handle<v8::Script> script = compileScriptInternal(code, fileName, scriptStartPosition, scriptData);
- android::TimeCounter::record(android::TimeCounter::JavaScriptParseTimeCounter, __FUNCTION__);
- return script;
-}
-
-v8::Handle<v8::Script> V8Proxy::compileScriptInternal(v8::Handle<v8::String> code, const String& fileName, const TextPosition0& scriptStartPosition, v8::ScriptData* scriptData)
-#endif
{
const uint16_t* fileNameString = fromWebCoreString(fileName);
v8::Handle<v8::String> name = v8::String::New(fileNameString, fileName.length());
@@ -398,16 +380,6 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* nod
}
v8::Local<v8::Value> V8Proxy::runScript(v8::Handle<v8::Script> script, bool isInlineCode)
-#ifdef ANDROID_INSTRUMENT
-{
- android::TimeCounter::start(android::TimeCounter::JavaScriptExecuteTimeCounter);
- v8::Local<v8::Value> result = runScriptInternal(script, isInlineCode);
- android::TimeCounter::record(android::TimeCounter::JavaScriptExecuteTimeCounter, __FUNCTION__);
- return result;
-}
-
-v8::Local<v8::Value> V8Proxy::runScriptInternal(v8::Handle<v8::Script> script, bool isInlineCode)
-#endif
{
if (script.IsEmpty())
return notHandledByInterceptor();
@@ -472,9 +444,6 @@ v8::Local<v8::Value> V8Proxy::runScriptInternal(v8::Handle<v8::Script> script, b
v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::JavaScriptExecuteTimeCounter);
-#endif
V8GCController::checkMemoryUsage();
v8::Local<v8::Value> result;
{
@@ -521,9 +490,6 @@ v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8
if (v8::V8::IsDead())
handleFatalErrorInV8();
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::JavaScriptExecuteTimeCounter, __FUNCTION__);
-#endif
return result;
}
diff --git a/Source/WebCore/bindings/v8/V8Proxy.h b/Source/WebCore/bindings/v8/V8Proxy.h
index fc52b19..777815b 100644
--- a/Source/WebCore/bindings/v8/V8Proxy.h
+++ b/Source/WebCore/bindings/v8/V8Proxy.h
@@ -171,10 +171,6 @@ namespace WebCore {
// Run an already compiled script.
v8::Local<v8::Value> runScript(v8::Handle<v8::Script>, bool isInlineCode);
-#ifdef ANDROID_INSTRUMENT
- v8::Local<v8::Value> runScriptInternal(v8::Handle<v8::Script> script, bool inline_code);
-#endif
-
// Call the function with the given receiver and arguments.
v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]);
@@ -244,10 +240,6 @@ namespace WebCore {
static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, const TextPosition0& scriptStartPosition, v8::ScriptData* = 0);
-#ifdef ANDROID_INSTRUMENT
- static v8::Handle<v8::Script> compileScriptInternal(v8::Handle<v8::String> code, const String& fileName, int baseLine, v8::ScriptData* scriptData);
-#endif
-
// If the exception code is different from zero, a DOM exception is
// schedule to be thrown.
static void setDOMException(int exceptionCode);
diff --git a/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp
new file mode 100644
index 0000000..429e962
--- /dev/null
+++ b/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Float64Array.h"
+
+#include "ArrayBuffer.h"
+#include "V8ArrayBuffer.h"
+#include "V8ArrayBufferViewCustom.h"
+#include "V8Binding.h"
+#include "V8Float64Array.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> V8Float64Array::constructorCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.Float64Array.Contructor");
+
+ return constructWebGLArray<Float64Array, double>(args, &info, v8::kExternalDoubleArray);
+}
+
+v8::Handle<v8::Value> V8Float64Array::setCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.Float64Array.set()");
+ return setWebGLArrayHelper<Float64Array, V8Float64Array>(args);
+}
+
+v8::Handle<v8::Value> toV8(Float64Array* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8Float64Array::wrap(impl);
+ if (!wrapper.IsEmpty())
+ wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalDoubleArray, impl->length());
+ return wrapper;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
index 42efaac..15b4bda 100644
--- a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
+++ b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
@@ -72,11 +72,16 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
break;
}
- jsize length = 0;
- if (NPVARIANT_IS_INT32(npvLength))
- length = static_cast<jsize>(NPVARIANT_TO_INT32(npvLength));
- else if (NPVARIANT_IS_DOUBLE(npvLength))
- length = static_cast<jsize>(NPVARIANT_TO_DOUBLE(npvLength));
+ // Convert to null if the length property is not a number.
+ if (!NPVARIANT_IS_INT32(npvLength) && !NPVARIANT_IS_DOUBLE(npvLength))
+ break;
+
+ // Convert to null if the length property is out of bounds.
+ double doubleLength = NPVARIANT_IS_INT32(npvLength) ? NPVARIANT_TO_INT32(npvLength) : NPVARIANT_TO_DOUBLE(npvLength);
+ if (doubleLength < 0.0 || doubleLength > INT32_MAX)
+ break;
+
+ jsize length = static_cast<jsize>(doubleLength);
if (!strcmp(javaClassName.data(), "[Ljava.lang.String;")) {
// Match JSC behavior by only allowing Object arrays if they are Strings.
@@ -85,7 +90,7 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
for (jsize i = 0; i < length; i++) {
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
- if(NPVARIANT_IS_STRING(npvValue)) {
+ if (NPVARIANT_IS_STRING(npvValue)) {
NPString str = NPVARIANT_TO_STRING(npvValue);
env->SetObjectArrayElement(static_cast<jobjectArray>(javaArray), i, env->NewStringUTF(str.UTF8Characters));
}
@@ -100,11 +105,10 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
jbyte bVal = 0;
- if (NPVARIANT_IS_INT32(npvValue)) {
+ if (NPVARIANT_IS_INT32(npvValue))
bVal = static_cast<jbyte>(NPVARIANT_TO_INT32(npvValue));
- } else if (NPVARIANT_IS_DOUBLE(npvValue)) {
+ else if (NPVARIANT_IS_DOUBLE(npvValue))
bVal = static_cast<jbyte>(NPVARIANT_TO_DOUBLE(npvValue));
- }
env->SetByteArrayRegion(static_cast<jbyteArray>(javaArray), i, 1, &bVal);
}
} else if (!strcmp(javaClassName.data(), "[C")) {
@@ -115,12 +119,8 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
jchar cVal = 0;
- if (NPVARIANT_IS_INT32(npvValue)) {
+ if (NPVARIANT_IS_INT32(npvValue))
cVal = static_cast<jchar>(NPVARIANT_TO_INT32(npvValue));
- } else if (NPVARIANT_IS_STRING(npvValue)) {
- NPString str = NPVARIANT_TO_STRING(npvValue);
- cVal = str.UTF8Characters[0];
- }
env->SetCharArrayRegion(static_cast<jcharArray>(javaArray), i, 1, &cVal);
}
} else if (!strcmp(javaClassName.data(), "[D")) {
@@ -155,11 +155,10 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
jint iVal = 0;
- if (NPVARIANT_IS_INT32(npvValue)) {
+ if (NPVARIANT_IS_INT32(npvValue))
iVal = NPVARIANT_TO_INT32(npvValue);
- } else if (NPVARIANT_IS_DOUBLE(npvValue)) {
+ else if (NPVARIANT_IS_DOUBLE(npvValue))
iVal = static_cast<jint>(NPVARIANT_TO_DOUBLE(npvValue));
- }
env->SetIntArrayRegion(static_cast<jintArray>(javaArray), i, 1, &iVal);
}
} else if (!strcmp(javaClassName.data(), "[J")) {
@@ -170,11 +169,10 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
jlong jVal = 0;
- if (NPVARIANT_IS_INT32(npvValue)) {
+ if (NPVARIANT_IS_INT32(npvValue))
jVal = static_cast<jlong>(NPVARIANT_TO_INT32(npvValue));
- } else if (NPVARIANT_IS_DOUBLE(npvValue)) {
+ else if (NPVARIANT_IS_DOUBLE(npvValue))
jVal = static_cast<jlong>(NPVARIANT_TO_DOUBLE(npvValue));
- }
env->SetLongArrayRegion(static_cast<jlongArray>(javaArray), i, 1, &jVal);
}
} else if (!strcmp(javaClassName.data(), "[S")) {
@@ -185,11 +183,10 @@ JavaValue convertNPVariantToJavaValue(NPVariant value, const String& javaClass)
NPVariant npvValue;
_NPN_GetProperty(0, object, _NPN_GetIntIdentifier(i), &npvValue);
jshort sVal = 0;
- if (NPVARIANT_IS_INT32(npvValue)) {
+ if (NPVARIANT_IS_INT32(npvValue))
sVal = static_cast<jshort>(NPVARIANT_TO_INT32(npvValue));
- } else if (NPVARIANT_IS_DOUBLE(npvValue)) {
+ else if (NPVARIANT_IS_DOUBLE(npvValue))
sVal = static_cast<jshort>(NPVARIANT_TO_DOUBLE(npvValue));
- }
env->SetShortArrayRegion(static_cast<jshortArray>(javaArray), i, 1, &sVal);
}
} else if (!strcmp(javaClassName.data(), "[Z")) {
diff --git a/Source/WebCore/bridge/jni/v8/JavaValueV8.h b/Source/WebCore/bridge/jni/v8/JavaValueV8.h
index 3e1c623..c6ff315 100644
--- a/Source/WebCore/bridge/jni/v8/JavaValueV8.h
+++ b/Source/WebCore/bridge/jni/v8/JavaValueV8.h
@@ -49,7 +49,18 @@ class JavaInstance;
// currently used only with V8.
// See https://bugs.webkit.org/show_bug.cgi?id=57023.
struct JavaValue {
- JavaValue() : m_type(JavaTypeInvalid) {}
+// ANDROID
+ JavaValue()
+ : m_type(JavaTypeInvalid)
+ , m_booleanValue(false)
+ , m_byteValue(0)
+ , m_charValue(0)
+ , m_shortValue(0)
+ , m_intValue(0)
+ , m_longValue(0)
+ , m_floatValue(0.0)
+ , m_doubleValue(0.0) {}
+// ANDROID
JavaType m_type;
// We don't use a union because we want to be able to ref-count some of the
diff --git a/Source/WebCore/css/AndroidCSSPropertyNames.in b/Source/WebCore/css/AndroidCSSPropertyNames.in
index ef67d6b..be751da 100644
--- a/Source/WebCore/css/AndroidCSSPropertyNames.in
+++ b/Source/WebCore/css/AndroidCSSPropertyNames.in
@@ -21,14 +21,5 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
--webkit-ring
--webkit-ring-fill-color
--webkit-ring-inner-width
--webkit-ring-outer-width
--webkit-ring-outset
--webkit-ring-pressed-inner-color
--webkit-ring-pressed-outer-color
--webkit-ring-radius
--webkit-ring-selected-inner-color
--webkit-ring-selected-outer-color
+
-webkit-tap-highlight-color
diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
index 4c0571d..4922109 100644
--- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
+++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
@@ -291,18 +291,6 @@ static const int computedProperties[] = {
CSSPropertyWebkitSvgShadow,
CSSPropertyVectorEffect
#endif
-#ifdef ANDROID_CSS_RING
- ,
- CSSPropertyWebkitRingFillColor,
- CSSPropertyWebkitRingInnerWidth,
- CSSPropertyWebkitRingOuterWidth,
- CSSPropertyWebkitRingOutset,
- CSSPropertyWebkitRingPressedInnerColor,
- CSSPropertyWebkitRingPressedOuterColor,
- CSSPropertyWebkitRingRadius,
- CSSPropertyWebkitRingSelectedInnerColor,
- CSSPropertyWebkitRingSelectedOuterColor
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
,
CSSPropertyWebkitTapHighlightColor
@@ -1818,29 +1806,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
case CSSPropertyWebkitTransformOriginZ:
case CSSPropertyWebkitTransition:
break;
-#ifdef ANDROID_CSS_RING
- case CSSPropertyWebkitRing:
- // shorthand property currently not supported see bug 13658
- break;
- case CSSPropertyWebkitRingFillColor:
- return primitiveValueCache->createColorValue(style->ringFillColor().rgb());
- case CSSPropertyWebkitRingInnerWidth:
- return primitiveValueCache->createValue(style->ringInnerWidth());
- case CSSPropertyWebkitRingOuterWidth:
- return primitiveValueCache->createValue(style->ringOuterWidth());
- case CSSPropertyWebkitRingOutset:
- return primitiveValueCache->createValue(style->ringOutset());
- case CSSPropertyWebkitRingPressedInnerColor:
- return primitiveValueCache->createColorValue(style->ringPressedInnerColor().rgb());
- case CSSPropertyWebkitRingPressedOuterColor:
- return primitiveValueCache->createColorValue(style->ringPressedOuterColor().rgb());
- case CSSPropertyWebkitRingRadius:
- return primitiveValueCache->createValue(style->ringRadius());
- case CSSPropertyWebkitRingSelectedInnerColor:
- return primitiveValueCache->createColorValue(style->ringSelectedInnerColor().rgb());
- case CSSPropertyWebkitRingSelectedOuterColor:
- return primitiveValueCache->createColorValue(style->ringSelectedOuterColor().rgb());
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
case CSSPropertyWebkitTapHighlightColor:
return primitiveValueCache->createColorValue(style->tapHighlightColor().rgb());
diff --git a/Source/WebCore/css/CSSImportRule.cpp b/Source/WebCore/css/CSSImportRule.cpp
index 09e313e..81ade39 100644
--- a/Source/WebCore/css/CSSImportRule.cpp
+++ b/Source/WebCore/css/CSSImportRule.cpp
@@ -170,26 +170,4 @@ void CSSImportRule::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
addSubresourceURL(urls, m_styleSheet->baseURL());
}
-#ifdef ANDROID_INSTRUMENT
-void* CSSImportRule::operator new(size_t size)
-{
- return StyleBase::operator new(size);
-}
-
-void* CSSImportRule::operator new[](size_t size)
-{
- return StyleBase::operator new[](size);
-}
-
-void CSSImportRule::operator delete(void* p, size_t size)
-{
- StyleBase::operator delete(p, size);
-}
-
-void CSSImportRule::operator delete[](void* p, size_t size)
-{
- StyleBase::operator delete[](p, size);
-}
-#endif
-
} // namespace WebCore
diff --git a/Source/WebCore/css/CSSImportRule.h b/Source/WebCore/css/CSSImportRule.h
index 3f44f5b..ad4e97d 100644
--- a/Source/WebCore/css/CSSImportRule.h
+++ b/Source/WebCore/css/CSSImportRule.h
@@ -66,14 +66,6 @@ private:
// from CachedResourceClient
virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
-#ifdef ANDROID_INSTRUMENT
- // Overridden to resolve the ambiguous
- void* operator new(size_t size);
- void* operator new[](size_t size);
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-#endif
-
String m_strHref;
RefPtr<MediaList> m_lstMedia;
RefPtr<CSSStyleSheet> m_styleSheet;
diff --git a/Source/WebCore/css/CSSMutableStyleDeclaration.cpp b/Source/WebCore/css/CSSMutableStyleDeclaration.cpp
index ba3332d..ece418a 100644
--- a/Source/WebCore/css/CSSMutableStyleDeclaration.cpp
+++ b/Source/WebCore/css/CSSMutableStyleDeclaration.cpp
@@ -261,20 +261,6 @@ String CSSMutableStyleDeclaration::getPropertyValue(int propertyID) const
return value->cssText();
}
#endif
-#ifdef ANDROID_CSS_RING
- case CSSPropertyWebkitRing: {
- const int properties[9] = { CSSPropertyWebkitRingFillColor,
- CSSPropertyWebkitRingInnerWidth,
- CSSPropertyWebkitRingOuterWidth,
- CSSPropertyWebkitRingOutset,
- CSSPropertyWebkitRingPressedInnerColor,
- CSSPropertyWebkitRingPressedOuterColor,
- CSSPropertyWebkitRingRadius,
- CSSPropertyWebkitRingSelectedInnerColor,
- CSSPropertyWebkitRingSelectedOuterColor };
- return getLayeredShorthandValue(properties, 9);
- }
-#endif
}
return String();
}
diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp
index 831e438..b78a6d0 100644
--- a/Source/WebCore/css/CSSParser.cpp
+++ b/Source/WebCore/css/CSSParser.cpp
@@ -92,10 +92,6 @@ extern int cssyyparse(void* parser);
using namespace std;
using namespace WTF;
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
namespace WebCore {
static const unsigned INVALID_NUM_PARSED_PROPERTIES = UINT_MAX;
@@ -230,9 +226,6 @@ void CSSParser::setupParser(const char* prefix, const String& string, const char
void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string, int startLineNumber, StyleRuleRangeMap* ruleRangeMap)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
setStyleSheet(sheet);
m_defaultNamespace = starAtom; // Reset the default namespace.
m_ruleRangeMap = ruleRangeMap;
@@ -247,37 +240,22 @@ void CSSParser::parseSheet(CSSStyleSheet* sheet, const String& string, int start
m_ruleRangeMap = 0;
m_currentRuleData = 0;
m_rule = 0;
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
}
PassRefPtr<CSSRule> CSSParser::parseRule(CSSStyleSheet* sheet, const String& string)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
setStyleSheet(sheet);
m_allowNamespaceDeclarations = false;
setupParser("@-webkit-rule{", string, "} ");
cssyyparse(this);
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return m_rule.release();
}
PassRefPtr<CSSRule> CSSParser::parseKeyframeRule(CSSStyleSheet *sheet, const String &string)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
setStyleSheet(sheet);
setupParser("@-webkit-keyframe-rule{ ", string, "} ");
cssyyparse(this);
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return m_keyframe.release();
}
@@ -440,9 +418,6 @@ bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int property
bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int propertyId, const String& string, bool important)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
setStyleSheet(static_cast<CSSStyleSheet*>(declaration->stylesheet()));
@@ -464,9 +439,6 @@ bool CSSParser::parseValue(CSSMutableStyleDeclaration* declaration, int property
clearProperties();
}
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return ok;
}
@@ -499,9 +471,6 @@ bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict)
bool CSSParser::parseColor(CSSMutableStyleDeclaration* declaration, const String& string)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
ASSERT(!declaration->stylesheet() || declaration->stylesheet()->isCSSStyleSheet());
setStyleSheet(static_cast<CSSStyleSheet*>(declaration->stylesheet()));
@@ -509,9 +478,6 @@ bool CSSParser::parseColor(CSSMutableStyleDeclaration* declaration, const String
cssyyparse(this);
m_rule = 0;
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return (m_numParsedProperties && m_parsedProperties[0]->m_id == CSSPropertyColor);
}
@@ -533,9 +499,6 @@ bool CSSParser::parseSystemColor(RGBA32& color, const String& string, Document*
void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorList& selectorList)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
RefPtr<CSSStyleSheet> dummyStyleSheet = CSSStyleSheet::create(doc);
setStyleSheet(dummyStyleSheet.get());
@@ -549,18 +512,10 @@ void CSSParser::parseSelector(const String& string, Document* doc, CSSSelectorLi
// The style sheet will be deleted right away, so it won't outlive the document.
ASSERT(dummyStyleSheet->hasOneRef());
-
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
}
bool CSSParser::parseDeclaration(CSSMutableStyleDeclaration* declaration, const String& string, RefPtr<CSSStyleSourceData>* styleSourceData)
{
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
-
// Length of the "@-webkit-decls{" prefix.
static const unsigned prefixLength = 15;
@@ -599,9 +554,6 @@ bool CSSParser::parseDeclaration(CSSMutableStyleDeclaration* declaration, const
m_currentRuleData = 0;
m_inStyleRuleOrDeclaration = false;
}
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return ok;
}
@@ -610,9 +562,6 @@ bool CSSParser::parseMediaQuery(MediaList* queries, const String& string)
if (string.isEmpty())
return true;
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CSSParseTimeCounter);
-#endif
ASSERT(!m_mediaQuery);
// can't use { because tokenizer state switches from mediaquery to initial state when it sees { token.
@@ -626,9 +575,6 @@ bool CSSParser::parseMediaQuery(MediaList* queries, const String& string)
queries->appendMediaQuery(m_mediaQuery.release());
}
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CSSParseTimeCounter, __FUNCTION__);
-#endif
return ok;
}
@@ -2016,7 +1962,6 @@ bool CSSParser::parseValue(int propId, bool important)
case CSSPropertyTextOverline:
case CSSPropertyTextUnderline:
return false;
-
#if ENABLE(WCSS)
case CSSPropertyWapInputFormat:
validPrimitive = true;
@@ -2063,36 +2008,6 @@ bool CSSParser::parseValue(int propId, bool important)
return parseLineBoxContain(important);
break;
-#ifdef ANDROID_CSS_RING
- case CSSPropertyWebkitRing:
- {
- const int properties[9] = { CSSPropertyWebkitRingFillColor,
- CSSPropertyWebkitRingInnerWidth,
- CSSPropertyWebkitRingOuterWidth,
- CSSPropertyWebkitRingOutset,
- CSSPropertyWebkitRingPressedInnerColor,
- CSSPropertyWebkitRingPressedOuterColor,
- CSSPropertyWebkitRingRadius,
- CSSPropertyWebkitRingSelectedInnerColor,
- CSSPropertyWebkitRingSelectedOuterColor };
- return parseShorthand(propId, properties, 9, important);
- }
- case CSSPropertyWebkitRingFillColor:
- case CSSPropertyWebkitRingPressedInnerColor:
- case CSSPropertyWebkitRingPressedOuterColor:
- case CSSPropertyWebkitRingSelectedInnerColor:
- case CSSPropertyWebkitRingSelectedOuterColor:
- parsedValue = parseColor();
- if (parsedValue)
- m_valueList->next();
- break;
- case CSSPropertyWebkitRingInnerWidth:
- case CSSPropertyWebkitRingOuterWidth:
- case CSSPropertyWebkitRingOutset:
- case CSSPropertyWebkitRingRadius:
- validPrimitive = validUnit(value, FLength | FNonNeg, m_strict);
- break;
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
case CSSPropertyWebkitTapHighlightColor:
parsedValue = parseColor();
diff --git a/Source/WebCore/css/CSSStyleDeclaration.cpp b/Source/WebCore/css/CSSStyleDeclaration.cpp
index 1c465e5..d4acc2a 100644
--- a/Source/WebCore/css/CSSStyleDeclaration.cpp
+++ b/Source/WebCore/css/CSSStyleDeclaration.cpp
@@ -27,6 +27,7 @@
#include "CSSPropertyNames.h"
#include "CSSRule.h"
#include <wtf/ASCIICType.h>
+#include <wtf/text/CString.h>
using namespace WTF;
diff --git a/Source/WebCore/css/CSSStyleSelector.cpp b/Source/WebCore/css/CSSStyleSelector.cpp
index b79f2dc..0b6fd35 100644
--- a/Source/WebCore/css/CSSStyleSelector.cpp
+++ b/Source/WebCore/css/CSSStyleSelector.cpp
@@ -6054,138 +6054,6 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
ASSERT_NOT_REACHED();
return;
-#ifdef ANDROID_CSS_RING
- case CSSPropertyWebkitRing:
- if (valueType != CSSValue::CSS_INHERIT || !m_parentNode) return;
- m_style->setRingFillColor(m_parentStyle->ringFillColor());
- m_style->setRingInnerWidth(m_parentStyle->ringInnerWidth());
- m_style->setRingOuterWidth(m_parentStyle->ringOuterWidth());
- m_style->setRingOutset(m_parentStyle->ringOutset());
- m_style->setRingPressedInnerColor(m_parentStyle->ringPressedInnerColor());
- m_style->setRingPressedOuterColor(m_parentStyle->ringPressedOuterColor());
- m_style->setRingRadius(m_parentStyle->ringRadius());
- m_style->setRingSelectedInnerColor(m_parentStyle->ringSelectedInnerColor());
- m_style->setRingSelectedOuterColor(m_parentStyle->ringSelectedOuterColor());
- return;
- case CSSPropertyWebkitRingFillColor: {
- HANDLE_INHERIT_AND_INITIAL(ringFillColor, RingFillColor);
- if (!primitiveValue)
- break;
- Color col = getColorFromPrimitiveValue(primitiveValue).blendWithWhite();
- m_style->setRingFillColor(col);
- return;
- }
- case CSSPropertyWebkitRingInnerWidth: {
- HANDLE_INHERIT_AND_INITIAL(ringInnerWidth, RingInnerWidth)
- if (!primitiveValue)
- break;
- Length l;
- int type = primitiveValue->primitiveType();
- if (CSSPrimitiveValue::isUnitTypeLength(type)) {
- // width can be specified with fractional px
- // scale by 16 here (and unscale in android_graphics) to keep
- // 4 bits of fraction
- RefPtr<CSSPrimitiveValue> scaledValue = CSSPrimitiveValue::create(
- primitiveValue->getFloatValue() * 16,
- (CSSPrimitiveValue::UnitTypes) type);
- l = Length(scaledValue->computeLengthIntForLength(style(),
- m_rootElementStyle, zoomFactor), Fixed);
- scaledValue.release();
- } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
- l = Length(primitiveValue->getDoubleValue(), Percent);
- else
- return;
- m_style->setRingInnerWidth(l);
- return;
- }
- case CSSPropertyWebkitRingOuterWidth: {
- HANDLE_INHERIT_AND_INITIAL(ringOuterWidth, RingOuterWidth)
- if (!primitiveValue)
- break;
- Length l;
- int type = primitiveValue->primitiveType();
- if (CSSPrimitiveValue::isUnitTypeLength(type)) {
- // width can be specified with fractional px
- // scale by 16 here (and unscale in android_graphics) to keep
- // 4 bits of fraction
- RefPtr<CSSPrimitiveValue> scaledValue = CSSPrimitiveValue::create(
- primitiveValue->getFloatValue() * 16,
- (CSSPrimitiveValue::UnitTypes) type);
- l = Length(scaledValue->computeLengthIntForLength(style(),
- m_rootElementStyle, zoomFactor), Fixed);
- scaledValue.release();
- } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
- l = Length(primitiveValue->getDoubleValue(), Percent);
- else
- return;
- m_style->setRingOuterWidth(l);
- return;
- }
- case CSSPropertyWebkitRingOutset: {
- HANDLE_INHERIT_AND_INITIAL(ringOutset, RingOutset)
- if (!primitiveValue)
- break;
- Length l;
- int type = primitiveValue->primitiveType();
- if (CSSPrimitiveValue::isUnitTypeLength(type))
- l = Length(primitiveValue->computeLengthIntForLength(style(),
- m_rootElementStyle, zoomFactor), Fixed);
- else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
- l = Length(primitiveValue->getDoubleValue(), Percent);
- else
- return;
- m_style->setRingOutset(l);
- return;
- }
- case CSSPropertyWebkitRingPressedInnerColor: {
- HANDLE_INHERIT_AND_INITIAL(ringPressedInnerColor, RingPressedInnerColor);
- if (!primitiveValue)
- break;
- Color col = getColorFromPrimitiveValue(primitiveValue).blendWithWhite();
- m_style->setRingPressedInnerColor(col);
- return;
- }
- case CSSPropertyWebkitRingPressedOuterColor: {
- HANDLE_INHERIT_AND_INITIAL(ringPressedOuterColor, RingPressedOuterColor);
- if (!primitiveValue)
- break;
- Color col = getColorFromPrimitiveValue(primitiveValue).blendWithWhite();
- m_style->setRingPressedOuterColor(col);
- return;
- }
- case CSSPropertyWebkitRingRadius: {
- HANDLE_INHERIT_AND_INITIAL(ringRadius, RingRadius)
- if (!primitiveValue)
- break;
- Length l;
- int type = primitiveValue->primitiveType();
- if (CSSPrimitiveValue::isUnitTypeLength(type))
- l = Length(primitiveValue->computeLengthIntForLength(style(),
- m_rootElementStyle, zoomFactor), Fixed);
- else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
- l = Length(primitiveValue->getDoubleValue(), Percent);
- else
- return;
- m_style->setRingRadius(l);
- return;
- }
- case CSSPropertyWebkitRingSelectedInnerColor: {
- HANDLE_INHERIT_AND_INITIAL(ringSelectedInnerColor, RingSelectedInnerColor);
- if (!primitiveValue)
- break;
- Color col = getColorFromPrimitiveValue(primitiveValue).blendWithWhite();
- m_style->setRingSelectedInnerColor(col);
- return;
- }
- case CSSPropertyWebkitRingSelectedOuterColor: {
- HANDLE_INHERIT_AND_INITIAL(ringSelectedOuterColor, RingSelectedOuterColor);
- if (!primitiveValue)
- break;
- Color col = getColorFromPrimitiveValue(primitiveValue).blendWithWhite();
- m_style->setRingSelectedOuterColor(col);
- return;
- }
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
case CSSPropertyWebkitTapHighlightColor: {
HANDLE_INHERIT_AND_INITIAL(tapHighlightColor, TapHighlightColor);
diff --git a/Source/WebCore/css/StyleBase.cpp b/Source/WebCore/css/StyleBase.cpp
index 5d9d79d..93dbda0 100644
--- a/Source/WebCore/css/StyleBase.cpp
+++ b/Source/WebCore/css/StyleBase.cpp
@@ -65,37 +65,4 @@ KURL StyleBase::baseURL() const
return sheet->ownerNode()->document()->baseURL();
}
-#ifdef ANDROID_INSTRUMENT
-static size_t styleSize = 0;
-
-void* StyleBase::operator new(size_t size)
-{
- styleSize += size;
- return ::operator new(size);
-}
-
-void* StyleBase::operator new[](size_t size)
-{
- styleSize += size;
- return ::operator new[](size);
-}
-
-void StyleBase::operator delete(void* p, size_t size)
-{
- styleSize -= size;
- ::operator delete(p);
-}
-
-void StyleBase::operator delete[](void* p, size_t size)
-{
- styleSize -= size;
- ::operator delete[](p);
-}
-
-size_t StyleBase::reportStyleSize()
-{
- return styleSize;
-}
-#endif
-
}
diff --git a/Source/WebCore/css/StyleBase.h b/Source/WebCore/css/StyleBase.h
index 94efa01..63c671e 100644
--- a/Source/WebCore/css/StyleBase.h
+++ b/Source/WebCore/css/StyleBase.h
@@ -72,18 +72,6 @@ namespace WebCore {
StyleSheet* stylesheet();
-#ifdef ANDROID_INSTRUMENT
- // Overridden to prevent the normal new from being called.
- void* operator new(size_t size);
- void* operator new[](size_t size);
-
- // Overridden to prevent the normal delete from being called.
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-
- static size_t reportStyleSize();
-#endif
-
protected:
StyleBase(StyleBase* parent)
: m_parent(parent)
diff --git a/Source/WebCore/css/mediaControlsAndroid.css b/Source/WebCore/css/mediaControlsAndroid.css
index 77f8b08..614c92f 100644
--- a/Source/WebCore/css/mediaControlsAndroid.css
+++ b/Source/WebCore/css/mediaControlsAndroid.css
@@ -49,10 +49,7 @@ video:-webkit-full-page-media::-webkit-media-controls-panel {
}
audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button {
- -webkit-appearance: media-mute-button;
- display: -webkit-box;
- width: 48px;
- height: 48px;
+ display: none;
}
audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button {
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index 6e21dc3..20dad55 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -194,10 +194,6 @@
#include "HTMLTextAreaElement.h"
#endif
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
#if ENABLE(TOUCH_EVENTS)
#if USE(V8)
#include "RuntimeEnabledFeatures.h"
@@ -1475,10 +1471,6 @@ void Document::recalcStyle(StyleChange change)
frameView->beginDeferredRepaints();
}
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::CalculateStyleTimeCounter);
-#endif
-
ASSERT(!renderer() || renderArena());
if (!renderer() || !renderArena())
goto bail_out;
@@ -1500,10 +1492,6 @@ void Document::recalcStyle(StyleChange change)
if (change >= Inherit || n->childNeedsStyleRecalc() || n->needsStyleRecalc())
n->recalcStyle(change);
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::CalculateStyleTimeCounter, __FUNCTION__);
-#endif
-
#if USE(ACCELERATED_COMPOSITING)
if (view()) {
bool layoutPending = view()->layoutPending() || renderer()->needsLayout();
@@ -2729,8 +2717,8 @@ void Document::processArguments(const String& features, void* data, ArgumentsCal
#ifdef ANDROID_META_SUPPORT
if (frame())
frame()->settings()->setMetadataSettings(keyString, valueString);
-#endif
if (callback && data)
+#endif
callback(keyString, valueString, this, data);
}
}
diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp
index 1fd4b92..0967ef5 100644
--- a/Source/WebCore/dom/Node.cpp
+++ b/Source/WebCore/dom/Node.cpp
@@ -2498,39 +2498,6 @@ Node* Node::enclosingLinkEventParentOrSelf()
return 0;
}
-#ifdef ANDROID_INSTRUMENT
-static size_t nodeSize = 0;
-
-void* Node::operator new(size_t size)
-{
- nodeSize += size;
- return ::operator new(size);
-}
-
-void* Node::operator new[](size_t size)
-{
- nodeSize += size;
- return ::operator new[](size);
-}
-
-void Node::operator delete(void* p, size_t size)
-{
- nodeSize -= size;
- ::operator delete(p);
-}
-
-void Node::operator delete[](void* p, size_t size)
-{
- nodeSize -= size;
- ::operator delete[](p);
-}
-
-size_t Node::reportDOMNodesSize()
-{
- return nodeSize;
-}
-#endif
-
// --------
ScriptExecutionContext* Node::scriptExecutionContext() const
diff --git a/Source/WebCore/dom/Node.h b/Source/WebCore/dom/Node.h
index 1fe30ad..08b1921 100644
--- a/Source/WebCore/dom/Node.h
+++ b/Source/WebCore/dom/Node.h
@@ -528,18 +528,6 @@ public:
unsigned short compareDocumentPosition(Node*);
-#ifdef ANDROID_INSTRUMENT
- // Overridden to prevent the normal new from being called.
- void* operator new(size_t size);
- void* operator new[](size_t size);
-
- // Overridden to prevent the normal delete from being called.
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-
- static size_t reportDOMNodesSize();
-#endif
-
virtual Node* toNode() { return this; }
virtual InputElement* toInputElement();
diff --git a/Source/WebCore/dom/ProcessingInstruction.cpp b/Source/WebCore/dom/ProcessingInstruction.cpp
index 7135644..30111d8 100644
--- a/Source/WebCore/dom/ProcessingInstruction.cpp
+++ b/Source/WebCore/dom/ProcessingInstruction.cpp
@@ -297,26 +297,4 @@ void ProcessingInstruction::finishParsingChildren()
ContainerNode::finishParsingChildren();
}
-#ifdef ANDROID_INSTRUMENT
-void* ProcessingInstruction::operator new(size_t size)
-{
- return Node::operator new(size);
-}
-
-void* ProcessingInstruction::operator new[](size_t size)
-{
- return Node::operator new[](size);
-}
-
-void ProcessingInstruction::operator delete(void* p, size_t size)
-{
- Node::operator delete(p, size);
-}
-
-void ProcessingInstruction::operator delete[](void* p, size_t size)
-{
- Node::operator delete[](p, size);
-}
-#endif
-
} // namespace
diff --git a/Source/WebCore/dom/ProcessingInstruction.h b/Source/WebCore/dom/ProcessingInstruction.h
index fd98566..1be8710 100644
--- a/Source/WebCore/dom/ProcessingInstruction.h
+++ b/Source/WebCore/dom/ProcessingInstruction.h
@@ -56,14 +56,6 @@ public:
private:
ProcessingInstruction(Document*, const String& target, const String& data);
-#ifdef ANDROID_INSTRUMENT
- // Overridden to resolve the ambiguous
- void* operator new(size_t size);
- void* operator new[](size_t size);
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-#endif
-
virtual String nodeName() const;
virtual NodeType nodeType() const;
virtual String nodeValue() const;
diff --git a/Source/WebCore/dom/Text.cpp b/Source/WebCore/dom/Text.cpp
index 906e421..c4ea0a6 100644
--- a/Source/WebCore/dom/Text.cpp
+++ b/Source/WebCore/dom/Text.cpp
@@ -31,6 +31,8 @@
#include "SVGNames.h"
#endif
+#include <wtf/text/CString.h>
+
#if ENABLE(WML)
#include "WMLDocument.h"
#include "WMLVariables.h"
diff --git a/Source/WebCore/editing/SelectionController.cpp b/Source/WebCore/editing/SelectionController.cpp
index c5a33d3..e9bdd6a 100644
--- a/Source/WebCore/editing/SelectionController.cpp
+++ b/Source/WebCore/editing/SelectionController.cpp
@@ -1592,6 +1592,10 @@ void SelectionController::updateAppearance()
// We need to update style in case the node containing the selection is made display:none.
m_frame->document()->updateStyleIfNeeded();
+#if PLATFORM(ANDROID)
+ return;
+#endif
+
RenderView* view = m_frame->contentRenderer();
if (!view)
return;
diff --git a/Source/WebCore/html/HTMLCanvasElement.h b/Source/WebCore/html/HTMLCanvasElement.h
index 9eab209..207c384 100644
--- a/Source/WebCore/html/HTMLCanvasElement.h
+++ b/Source/WebCore/html/HTMLCanvasElement.h
@@ -128,22 +128,6 @@ public:
void makeRenderingResultsAvailable();
-#ifdef ANDROID_INSTRUMENT
- void* operator new(size_t size) {
- return HTMLElement::operator new(size);
- }
- void* operator new[](size_t size) {
- return HTMLElement::operator new[](size);
- }
-
- void operator delete(void* p, size_t size) {
- HTMLElement::operator delete(p, size);
- }
- void operator delete[](void* p, size_t size) {
- HTMLElement::operator delete[](p, size);
- }
-#endif
-
private:
HTMLCanvasElement(const QualifiedName&, Document*);
diff --git a/Source/WebCore/html/HTMLDocument.cpp b/Source/WebCore/html/HTMLDocument.cpp
index dd41514..a1be93d 100644
--- a/Source/WebCore/html/HTMLDocument.cpp
+++ b/Source/WebCore/html/HTMLDocument.cpp
@@ -438,26 +438,4 @@ bool HTMLDocument::isFrameSet() const
return bodyElement && bodyElement->hasTagName(framesetTag);
}
-#ifdef ANDROID_INSTRUMENT
-void* HTMLDocument::operator new(size_t size)
-{
- return Node::operator new(size);
-}
-
-void* HTMLDocument::operator new[](size_t size)
-{
- return Node::operator new[](size);
-}
-
-void HTMLDocument::operator delete(void* p, size_t size)
-{
- Node::operator delete(p, size);
-}
-
-void HTMLDocument::operator delete[](void* p, size_t size)
-{
- Node::operator delete[](p, size);
-}
-#endif
-
}
diff --git a/Source/WebCore/html/HTMLDocument.h b/Source/WebCore/html/HTMLDocument.h
index 3310b71..d39f392 100644
--- a/Source/WebCore/html/HTMLDocument.h
+++ b/Source/WebCore/html/HTMLDocument.h
@@ -82,14 +82,6 @@ public:
protected:
HTMLDocument(Frame*, const KURL&);
-#ifdef ANDROID_INSTRUMENT
- // Overridden to resolve the ambiguous
- void* operator new(size_t size);
- void* operator new[](size_t size);
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-#endif
-
private:
virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
diff --git a/Source/WebCore/html/HTMLLinkElement.cpp b/Source/WebCore/html/HTMLLinkElement.cpp
index 7cbf38b..4673109 100644
--- a/Source/WebCore/html/HTMLLinkElement.cpp
+++ b/Source/WebCore/html/HTMLLinkElement.cpp
@@ -504,28 +504,6 @@ void HTMLLinkElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
styleSheet->addSubresourceStyleURLs(urls);
}
-#ifdef ANDROID_INSTRUMENT
-void* HTMLLinkElement::operator new(size_t size)
-{
- return Node::operator new(size);
-}
-
-void* HTMLLinkElement::operator new[](size_t size)
-{
- return Node::operator new[](size);
-}
-
-void HTMLLinkElement::operator delete(void* p, size_t size)
-{
- Node::operator delete(p, size);
-}
-
-void HTMLLinkElement::operator delete[](void* p, size_t size)
-{
- Node::operator delete[](p, size);
-}
-#endif
-
void HTMLLinkElement::addPendingSheet(PendingSheetType type)
{
if (type <= m_pendingSheetType)
diff --git a/Source/WebCore/html/HTMLLinkElement.h b/Source/WebCore/html/HTMLLinkElement.h
index f602d38..1a6eba9 100644
--- a/Source/WebCore/html/HTMLLinkElement.h
+++ b/Source/WebCore/html/HTMLLinkElement.h
@@ -120,14 +120,6 @@ private:
void addPendingSheet(PendingSheetType);
void removePendingSheet();
-#ifdef ANDROID_INSTRUMENT
- // Overridden to resolve the ambiguous
- void* operator new(size_t size);
- void* operator new[](size_t size);
- void operator delete(void* p, size_t size);
- void operator delete[](void* p, size_t size);
-#endif
-
private:
HTMLLinkElement(const QualifiedName&, Document*, bool createdByParser);
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp
index 023e8d2..5cd2ddd 100644
--- a/Source/WebCore/html/HTMLMediaElement.cpp
+++ b/Source/WebCore/html/HTMLMediaElement.cpp
@@ -178,6 +178,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum
, m_completelyLoaded(false)
#if PLATFORM(ANDROID)
, m_lastTouch(0)
+ , m_userGestureInitiated(false)
#endif
{
LOG(Media, "HTMLMediaElement::HTMLMediaElement");
@@ -187,8 +188,8 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum
#if PLATFORM(ANDROID) && ENABLE(TOUCH_EVENTS)
// Enable the Media Element to listen to all the touch events
document->addListenerTypeIfNeeded(eventNames().touchstartEvent);
+ m_restrictions |= RequireUserGestureForRateChangeRestriction;
#endif
-
}
HTMLMediaElement::~HTMLMediaElement()
@@ -515,6 +516,9 @@ void HTMLMediaElement::load(bool isUserGesture, ExceptionCode& ec)
ec = INVALID_STATE_ERR;
else {
m_loadInitiatedByUserGesture = isUserGesture;
+#if PLATFORM(ANDROID)
+ m_userGestureInitiated |= isUserGesture;
+#endif
prepareForLoad();
loadInternal();
}
@@ -1417,9 +1421,19 @@ void HTMLMediaElement::play(bool isUserGesture)
{
LOG(Media, "HTMLMediaElement::play(isUserGesture : %s)", boolString(isUserGesture));
- if (m_restrictions & RequireUserGestureForRateChangeRestriction && !isUserGesture)
+ if (m_restrictions & RequireUserGestureForRateChangeRestriction && !isUserGesture
+#if PLATFORM(ANDROID)
+ && !m_userGestureInitiated
+#endif
+ )
return;
+#if PLATFORM(ANDROID)
+ // B/c we set the restriction to require gesture for rate change for
+ // Android, when we don't early return, we can safely set this to true.
+ m_userGestureInitiated = true;
+#endif
+
Document* doc = document();
Settings* settings = doc->settings();
if (settings && settings->needsSiteSpecificQuirks() && m_dispatchingCanPlayEvent && !m_loadInitiatedByUserGesture) {
@@ -1466,9 +1480,17 @@ void HTMLMediaElement::pause(bool isUserGesture)
{
LOG(Media, "HTMLMediaElement::pause(isUserGesture : %s)", boolString(isUserGesture));
- if (m_restrictions & RequireUserGestureForRateChangeRestriction && !isUserGesture)
+ if (m_restrictions & RequireUserGestureForRateChangeRestriction && !isUserGesture
+#if PLATFORM(ANDROID)
+ && !m_userGestureInitiated
+#endif
+ )
return;
-
+#if PLATFORM(ANDROID)
+ // B/c we set the restriction to require gesture for rate change for
+ // Android, when we don't early return, we can safely set this to true.
+ m_userGestureInitiated = true;
+#endif
pauseInternal();
}
@@ -2402,6 +2424,15 @@ void HTMLMediaElement::defaultEventHandler(Event* event)
}
#endif
+#if PLATFORM(ANDROID)
+ // It is really hard to hit the play/pause button on mobile devices.
+ // This allows user to click the video area to toggle play/pause state.
+ if (event->type() == eventNames().clickEvent
+ && !hasEventListeners(eventNames().clickEvent)) {
+ m_userGestureInitiated = processingUserGesture();
+ togglePlayState();
+ }
+#endif
HTMLElement::defaultEventHandler(event);
#endif
}
diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h
index 987cf87..2144ea1 100644
--- a/Source/WebCore/html/HTMLMediaElement.h
+++ b/Source/WebCore/html/HTMLMediaElement.h
@@ -420,6 +420,10 @@ private:
#if PLATFORM(ANDROID)
double m_lastTouch;
+ // When user gesture invoke load, play or pause, this turns to be true.
+ // After this becomes true, we ignore the user gesture requirement for play
+ // and pause.
+ bool m_userGestureInitiated;
#endif
};
diff --git a/Source/WebCore/html/canvas/ArrayBufferView.h b/Source/WebCore/html/canvas/ArrayBufferView.h
index 701abbc..d06fc8d 100644
--- a/Source/WebCore/html/canvas/ArrayBufferView.h
+++ b/Source/WebCore/html/canvas/ArrayBufferView.h
@@ -46,6 +46,7 @@ class ArrayBufferView : public RefCounted<ArrayBufferView> {
virtual bool isIntArray() const { return false; }
virtual bool isUnsignedIntArray() const { return false; }
virtual bool isFloatArray() const { return false; }
+ virtual bool isDoubleArray() const { return false; }
virtual bool isDataView() const { return false; }
PassRefPtr<ArrayBuffer> buffer() const
diff --git a/Source/WebCore/html/canvas/Float64Array.cpp b/Source/WebCore/html/canvas/Float64Array.cpp
new file mode 100644
index 0000000..2dcb373
--- /dev/null
+++ b/Source/WebCore/html/canvas/Float64Array.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Float64Array.h"
+
+namespace WebCore {
+
+PassRefPtr<Float64Array> Float64Array::create(unsigned length)
+{
+ return TypedArrayBase<double>::create<Float64Array>(length);
+}
+
+PassRefPtr<Float64Array> Float64Array::create(const double* array, unsigned length)
+{
+ return TypedArrayBase<double>::create<Float64Array>(array, length);
+}
+
+PassRefPtr<Float64Array> Float64Array::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+{
+ return TypedArrayBase<double>::create<Float64Array>(buffer, byteOffset, length);
+}
+
+Float64Array::Float64Array(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned length)
+ : TypedArrayBase<double>(buffer, byteOffset, length)
+{
+}
+
+PassRefPtr<Float64Array> Float64Array::subarray(int start) const
+{
+ return subarray(start, length());
+}
+
+PassRefPtr<Float64Array> Float64Array::subarray(int start, int end) const
+{
+ return subarrayImpl<Float64Array>(start, end);
+}
+
+}
diff --git a/Source/WebCore/html/canvas/Float64Array.h b/Source/WebCore/html/canvas/Float64Array.h
new file mode 100644
index 0000000..f45a21c
--- /dev/null
+++ b/Source/WebCore/html/canvas/Float64Array.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef Float64Array_h
+#define Float64Array_h
+
+#include "TypedArrayBase.h"
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+class Float64Array : public TypedArrayBase<double> {
+public:
+ static PassRefPtr<Float64Array> create(unsigned length);
+ static PassRefPtr<Float64Array> create(const double* array, unsigned length);
+ static PassRefPtr<Float64Array> create(PassRefPtr<ArrayBuffer>, unsigned byteOffset, unsigned length);
+
+ using TypedArrayBase<double>::set;
+
+ void set(unsigned index, double value)
+ {
+ if (index >= TypedArrayBase<double>::m_length)
+ return;
+ TypedArrayBase<double>::data()[index] = static_cast<double>(value);
+ }
+
+ // Invoked by the indexed getter. Does not perform range checks; caller
+ // is responsible for doing so and returning undefined as necessary.
+ double item(unsigned index) const
+ {
+ ASSERT(index < TypedArrayBase<double>::m_length);
+ double result = TypedArrayBase<double>::data()[index];
+ return result;
+ }
+
+ PassRefPtr<Float64Array> subarray(int start) const;
+ PassRefPtr<Float64Array> subarray(int start, int end) const;
+
+private:
+ Float64Array(PassRefPtr<ArrayBuffer>,
+ unsigned byteOffset,
+ unsigned length);
+ // Make constructor visible to superclass.
+ friend class TypedArrayBase<double>;
+
+ // Overridden from ArrayBufferView.
+ virtual bool isDoubleArray() const { return true; }
+};
+
+} // namespace WebCore
+
+#endif // Float64Array_h
diff --git a/Source/WebCore/html/canvas/Float64Array.idl b/Source/WebCore/html/canvas/Float64Array.idl
new file mode 100644
index 0000000..6057253
--- /dev/null
+++ b/Source/WebCore/html/canvas/Float64Array.idl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+ interface [
+ CanBeConstructed,
+ CustomConstructFunction,
+ V8CustomConstructor,
+ HasNumericIndexGetter,
+ HasCustomIndexSetter,
+ GenerateNativeConverter,
+ NoStaticTables,
+ CustomToJS,
+ DontCheckEnums
+ ] Float64Array : ArrayBufferView {
+ const unsigned int BYTES_PER_ELEMENT = 8;
+
+ readonly attribute unsigned long length;
+ Float64Array subarray(in long start, in [Optional] long end);
+
+ // void set(in Float64Array array, [Optional] in unsigned long offset);
+ // void set(in sequence<long> array, [Optional] in unsigned long offset);
+ [Custom] void set();
+ };
+}
diff --git a/Source/WebCore/html/parser/HTMLDocumentParser.cpp b/Source/WebCore/html/parser/HTMLDocumentParser.cpp
index 8f95cc5..46dddf0 100644
--- a/Source/WebCore/html/parser/HTMLDocumentParser.cpp
+++ b/Source/WebCore/html/parser/HTMLDocumentParser.cpp
@@ -41,10 +41,6 @@
#include "NestingLevelIncrementer.h"
#include "Settings.h"
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#endif
-
namespace WebCore {
using namespace HTMLNames;
@@ -318,10 +314,6 @@ void HTMLDocumentParser::insert(const SegmentedString& source)
if (isStopped())
return;
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::start(android::TimeCounter::ParsingTimeCounter);
-#endif
-
// pumpTokenizer can cause this parser to be detached from the Document,
// but we need to ensure it isn't deleted yet.
RefPtr<HTMLDocumentParser> protect(this);
@@ -369,18 +361,12 @@ void HTMLDocumentParser::append(const SegmentedString& source)
// We've gotten data off the network in a nested write.
// We don't want to consume any more of the input stream now. Do
// not worry. We'll consume this data in a less-nested write().
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::ParsingTimeCounter, __FUNCTION__);
-#endif
return;
}
pumpTokenizerIfPossible(AllowYield);
endIfDelayed();
-#ifdef ANDROID_INSTRUMENT
- android::TimeCounter::record(android::TimeCounter::ParsingTimeCounter, __FUNCTION__);
-#endif
}
void HTMLDocumentParser::end()
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index 85b1541..f999fdb 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -119,11 +119,6 @@
#include "ArchiveFactory.h"
#endif
-#ifdef ANDROID_INSTRUMENT
-#include "TimeCounter.h"
-#include "RenderArena.h"
-#endif
-
namespace WebCore {
using namespace HTMLNames;
@@ -1114,11 +1109,7 @@ void FrameLoader::handleFallbackContent()
}
void FrameLoader::provisionalLoadStarted()
-{
-#ifdef ANDROID_INSTRUMENT
- if (!m_frame->tree()->parent())
- android::TimeCounter::reset();
-#endif
+{
if (m_stateMachine.firstLayoutDone())
m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad);
m_frame->navigationScheduler()->cancel(true);
@@ -2308,7 +2299,7 @@ void FrameLoader::finishedLoadingDocument(DocumentLoader* loader)
if (m_stateMachine.creatingInitialEmptyDocument())
return;
#endif
-
+
#if !ENABLE(WEB_ARCHIVE)
m_client->finishedLoading(loader);
#else
@@ -2499,12 +2490,6 @@ void FrameLoader::checkLoadCompleteForThisFrame()
if (Page* page = m_frame->page())
page->progress()->progressCompleted(m_frame);
-
-#ifdef ANDROID_INSTRUMENT
- if (!m_frame->tree()->parent() && m_frame->document()->renderArena())
- android::TimeCounter::report(m_URL, cache()->getLiveSize(), cache()->getDeadSize(),
- m_frame->document()->renderArena()->reportPoolSize());
-#endif
return;
}
diff --git a/Source/WebCore/loader/archive/android/WebArchiveAndroid.cpp b/Source/WebCore/loader/archive/android/WebArchiveAndroid.cpp
index 55d7cec..5f60163 100644
--- a/Source/WebCore/loader/archive/android/WebArchiveAndroid.cpp
+++ b/Source/WebCore/loader/archive/android/WebArchiveAndroid.cpp
@@ -36,6 +36,7 @@
#include <libxml/tree.h>
#include <libxml/xmlstring.h>
#include <libxml/xmlwriter.h>
+#include <utils/Log.h>
#include <wtf/text/CString.h>
namespace WebCore {
@@ -117,7 +118,7 @@ static bool loadArchiveResourceField(xmlNodePtr resourceNode, const xmlChar* fie
}
}
if (!base64Data) {
- LOGD("loadArchiveResourceField: Failed to load field.");
+ ALOGD("loadArchiveResourceField: Failed to load field.");
return false;
}
@@ -125,7 +126,7 @@ static bool loadArchiveResourceField(xmlNodePtr resourceNode, const xmlChar* fie
const int result = base64Decode(base64Data, base64Size, *outputData);
if (!result) {
- LOGD("loadArchiveResourceField: Failed to decode field.");
+ ALOGD("loadArchiveResourceField: Failed to decode field.");
return false;
}
@@ -165,37 +166,37 @@ static KURL loadArchiveResourceFieldURL(xmlNodePtr resourceNode, const xmlChar*
static PassRefPtr<ArchiveResource> loadArchiveResource(xmlNodePtr resourceNode)
{
if (!xmlStrEqual(resourceNode->name, archiveResourceTag)) {
- LOGD("loadArchiveResource: Malformed resource.");
+ ALOGD("loadArchiveResource: Malformed resource.");
return 0;
}
KURL url = loadArchiveResourceFieldURL(resourceNode, urlFieldTag);
if (url.isNull()) {
- LOGD("loadArchiveResource: Failed to load resource.");
+ ALOGD("loadArchiveResource: Failed to load resource.");
return 0;
}
String mimeType = loadArchiveResourceFieldString(resourceNode, mimeFieldTag);
if (mimeType.isNull()) {
- LOGD("loadArchiveResource: Failed to load resource.");
+ ALOGD("loadArchiveResource: Failed to load resource.");
return 0;
}
String textEncoding = loadArchiveResourceFieldString(resourceNode, encodingFieldTag);
if (textEncoding.isNull()) {
- LOGD("loadArchiveResource: Failed to load resource.");
+ ALOGD("loadArchiveResource: Failed to load resource.");
return 0;
}
String frameName = loadArchiveResourceFieldString(resourceNode, frameFieldTag);
if (frameName.isNull()) {
- LOGD("loadArchiveResource: Failed to load resource.");
+ ALOGD("loadArchiveResource: Failed to load resource.");
return 0;
}
PassRefPtr<SharedBuffer> data = loadArchiveResourceFieldBuffer(resourceNode, dataFieldTag);
if (!data) {
- LOGD("loadArchiveResource: Failed to load resource.");
+ ALOGD("loadArchiveResource: Failed to load resource.");
return 0;
}
@@ -211,7 +212,7 @@ static PassRefPtr<WebArchiveAndroid> loadArchive(xmlNodePtr archiveNode)
Vector<PassRefPtr<Archive> > subframes;
if (!xmlStrEqual(archiveNode->name, archiveTag)) {
- LOGD("loadArchive: Malformed archive.");
+ ALOGD("loadArchive: Malformed archive.");
return 0;
}
@@ -227,7 +228,7 @@ static PassRefPtr<WebArchiveAndroid> loadArchive(xmlNodePtr archiveNode)
}
}
if (!mainResource) {
- LOGD("loadArchive: Failed to load main resource.");
+ ALOGD("loadArchive: Failed to load main resource.");
return 0;
}
@@ -240,7 +241,7 @@ static PassRefPtr<WebArchiveAndroid> loadArchive(xmlNodePtr archiveNode)
resourceNode = resourceNode->next) {
PassRefPtr<ArchiveResource> subresource = loadArchiveResource(resourceNode);
if (!subresource) {
- LOGD("loadArchive: Failed to load subresource.");
+ ALOGD("loadArchive: Failed to load subresource.");
break;
}
subresources.append(subresource);
@@ -258,7 +259,7 @@ static PassRefPtr<WebArchiveAndroid> loadArchive(xmlNodePtr archiveNode)
resourceNode = resourceNode->next) {
PassRefPtr<WebArchiveAndroid> subframe = loadArchive(resourceNode);
if (!subframe) {
- LOGD("loadArchive: Failed to load subframe.");
+ ALOGD("loadArchive: Failed to load subframe.");
break;
}
subframes.append(subframe);
@@ -290,20 +291,20 @@ PassRefPtr<WebArchiveAndroid> WebArchiveAndroid::create(SharedBuffer* buffer)
xmlDocPtr doc = xmlReadMemory(buffer->data(), buffer->size(), noBaseUrl, defaultEncoding, noParserOptions);
if (!doc) {
- LOGD("create: Failed to parse document.");
+ ALOGD("create: Failed to parse document.");
return createArchiveForError();
}
xmlNodePtr root = xmlDocGetRootElement(doc);
if (!root) {
- LOGD("create: Empty document.");
+ ALOGD("create: Empty document.");
xmlFreeDoc(doc);
return createArchiveForError();
}
RefPtr<WebArchiveAndroid> archive = loadArchive(root);
if (!archive) {
- LOGD("create: Failed to load archive.");
+ ALOGD("create: Failed to load archive.");
xmlFreeDoc(doc);
return createArchiveForError();
}
@@ -316,7 +317,7 @@ static bool saveArchiveResourceField(xmlTextWriterPtr writer, const xmlChar* tag
{
int result = xmlTextWriterStartElement(writer, tag);
if (result < 0) {
- LOGD("saveArchiveResourceField: Failed to start element.");
+ ALOGD("saveArchiveResourceField: Failed to start element.");
return false;
}
@@ -324,20 +325,20 @@ static bool saveArchiveResourceField(xmlTextWriterPtr writer, const xmlChar* tag
Vector<char> base64Data;
base64Encode(data, size, base64Data, false);
if (base64Data.isEmpty()) {
- LOGD("saveArchiveResourceField: Failed to base64 encode data.");
+ ALOGD("saveArchiveResourceField: Failed to base64 encode data.");
return false;
}
result = xmlTextWriterWriteRawLen(writer, BAD_CAST base64Data.data(), base64Data.size());
if (result < 0) {
- LOGD("saveArchiveResourceField: Failed to write data.");
+ ALOGD("saveArchiveResourceField: Failed to write data.");
return false;
}
}
result = xmlTextWriterEndElement(writer);
if (result < 0) {
- LOGD("saveArchiveResourceField: Failed to end element.");
+ ALOGD("saveArchiveResourceField: Failed to end element.");
return false;
}
@@ -360,7 +361,7 @@ static bool saveArchiveResource(xmlTextWriterPtr writer, PassRefPtr<ArchiveResou
{
int result = xmlTextWriterStartElement(writer, archiveResourceTag);
if (result < 0) {
- LOGD("saveArchiveResource: Failed to start element.");
+ ALOGD("saveArchiveResource: Failed to start element.");
return false;
}
@@ -373,7 +374,7 @@ static bool saveArchiveResource(xmlTextWriterPtr writer, PassRefPtr<ArchiveResou
result = xmlTextWriterEndElement(writer);
if (result < 0) {
- LOGD("saveArchiveResource: Failed to end element.");
+ ALOGD("saveArchiveResource: Failed to end element.");
return false;
}
@@ -384,13 +385,13 @@ static bool saveArchive(xmlTextWriterPtr writer, PassRefPtr<Archive> archive)
{
int result = xmlTextWriterStartElement(writer, archiveTag);
if (result < 0) {
- LOGD("saveArchive: Failed to start element.");
+ ALOGD("saveArchive: Failed to start element.");
return false;
}
result = xmlTextWriterStartElement(writer, mainResourceTag);
if (result < 0) {
- LOGD("saveArchive: Failed to start element.");
+ ALOGD("saveArchive: Failed to start element.");
return false;
}
@@ -399,13 +400,13 @@ static bool saveArchive(xmlTextWriterPtr writer, PassRefPtr<Archive> archive)
result = xmlTextWriterEndElement(writer);
if (result < 0) {
- LOGD("saveArchive: Failed to end element.");
+ ALOGD("saveArchive: Failed to end element.");
return false;
}
result = xmlTextWriterStartElement(writer, subresourcesTag);
if (result < 0) {
- LOGD("saveArchive: Failed to start element.");
+ ALOGD("saveArchive: Failed to start element.");
return false;
}
@@ -418,13 +419,13 @@ static bool saveArchive(xmlTextWriterPtr writer, PassRefPtr<Archive> archive)
result = xmlTextWriterEndElement(writer);
if (result < 0) {
- LOGD("saveArchive: Failed to end element.");
+ ALOGD("saveArchive: Failed to end element.");
return false;
}
result = xmlTextWriterStartElement(writer, subframesTag);
if (result < 0) {
- LOGD("saveArchive: Failed to start element.");
+ ALOGD("saveArchive: Failed to start element.");
return false;
}
@@ -437,7 +438,7 @@ static bool saveArchive(xmlTextWriterPtr writer, PassRefPtr<Archive> archive)
result = xmlTextWriterEndElement(writer);
if (result < 0) {
- LOGD("saveArchive: Failed to end element.");
+ ALOGD("saveArchive: Failed to end element.");
return true;
}
@@ -452,7 +453,7 @@ bool WebArchiveAndroid::saveWebArchive(xmlTextWriterPtr writer)
int result = xmlTextWriterStartDocument(writer, defaultXmlVersion, defaultEncoding, defaultStandalone);
if (result < 0) {
- LOGD("saveWebArchive: Failed to start document.");
+ ALOGD("saveWebArchive: Failed to start document.");
return false;
}
@@ -461,7 +462,7 @@ bool WebArchiveAndroid::saveWebArchive(xmlTextWriterPtr writer)
result = xmlTextWriterEndDocument(writer);
if (result< 0) {
- LOGD("saveWebArchive: Failed to end document.");
+ ALOGD("saveWebArchive: Failed to end document.");
return false;
}
diff --git a/Source/WebCore/loader/cache/MemoryCache.h b/Source/WebCore/loader/cache/MemoryCache.h
index a092eac..c9b91f9 100644
--- a/Source/WebCore/loader/cache/MemoryCache.h
+++ b/Source/WebCore/loader/cache/MemoryCache.h
@@ -171,12 +171,6 @@ public:
void removeResourcesWithOrigin(SecurityOrigin*);
void getOriginsWithCache(SecurityOriginSet& origins);
-#ifdef ANDROID_INSTRUMENT
- unsigned getLiveSize() { return m_liveSize; }
- unsigned getDeadSize() { return m_deadSize; }
-#endif
-
-
private:
MemoryCache();
~MemoryCache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons.
diff --git a/Source/WebCore/loader/icon/IconDatabase.cpp b/Source/WebCore/loader/icon/IconDatabase.cpp
index 3cefea7..2bb22ec 100644
--- a/Source/WebCore/loader/icon/IconDatabase.cpp
+++ b/Source/WebCore/loader/icon/IconDatabase.cpp
@@ -73,7 +73,7 @@ static const int updateTimerDelay = 5;
static bool checkIntegrityOnOpen = false;
-#ifndef NDEBUG
+#if !LOG_DISABLED || !ERROR_DISABLED
static String urlForLogging(const String& url)
{
static unsigned urlTruncationLength = 120;
@@ -967,7 +967,7 @@ void* IconDatabase::iconDatabaseSyncThread()
LOG(IconDatabase, "(THREAD) IconDatabase sync thread started");
-#ifndef NDEBUG
+#if !LOG_DISABLED
double startTime = currentTime();
#endif
@@ -993,7 +993,7 @@ void* IconDatabase::iconDatabaseSyncThread()
if (shouldStopThreadActivity())
return syncThreadMainLoop();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double timeStamp = currentTime();
LOG(IconDatabase, "(THREAD) Open took %.4f seconds", timeStamp - startTime);
#endif
@@ -1002,7 +1002,7 @@ void* IconDatabase::iconDatabaseSyncThread()
if (shouldStopThreadActivity())
return syncThreadMainLoop();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double newStamp = currentTime();
LOG(IconDatabase, "(THREAD) performOpenInitialization() took %.4f seconds, now %.4f seconds from thread start", newStamp - timeStamp, newStamp - startTime);
timeStamp = newStamp;
@@ -1025,7 +1025,7 @@ void* IconDatabase::iconDatabaseSyncThread()
if (shouldStopThreadActivity())
return syncThreadMainLoop();
-#ifndef NDEBUG
+#if !LOG_DISABLED
newStamp = currentTime();
LOG(IconDatabase, "(THREAD) performImport() took %.4f seconds, now %.4f seconds from thread start", newStamp - timeStamp, newStamp - startTime);
timeStamp = newStamp;
@@ -1042,7 +1042,7 @@ void* IconDatabase::iconDatabaseSyncThread()
if (shouldStopThreadActivity())
return syncThreadMainLoop();
-#ifndef NDEBUG
+#if !LOG_DISABLED
newStamp = currentTime();
LOG(IconDatabase, "(THREAD) performURLImport() took %.4f seconds. Entering main loop %.4f seconds from thread start", newStamp - timeStamp, newStamp - startTime);
#endif
@@ -1358,7 +1358,7 @@ void* IconDatabase::syncThreadMainLoop()
while (!m_threadTerminationRequested) {
m_syncLock.unlock();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double timeStamp = currentTime();
#endif
LOG(IconDatabase, "(THREAD) Main work loop starting");
@@ -1391,7 +1391,7 @@ void* IconDatabase::syncThreadMainLoop()
// has asked to delay pruning
static bool prunedUnretainedIcons = false;
if (didWrite && !m_privateBrowsingEnabled && !prunedUnretainedIcons && !databaseCleanupCounter) {
-#ifndef NDEBUG
+#if !LOG_DISABLED
double time = currentTime();
#endif
LOG(IconDatabase, "(THREAD) Starting pruneUnretainedIcons()");
@@ -1410,7 +1410,7 @@ void* IconDatabase::syncThreadMainLoop()
break;
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
double newstamp = currentTime();
LOG(IconDatabase, "(THREAD) Main work loop ran for %.4f seconds, %s requested to terminate", newstamp - timeStamp, shouldStopThreadActivity() ? "was" : "was not");
#endif
@@ -1458,7 +1458,7 @@ bool IconDatabase::readFromDatabase()
{
ASSERT_ICON_SYNC_THREAD();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double timeStamp = currentTime();
#endif
@@ -1567,7 +1567,7 @@ bool IconDatabase::writeToDatabase()
{
ASSERT_ICON_SYNC_THREAD();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double timeStamp = currentTime();
#endif
@@ -1772,7 +1772,7 @@ void* IconDatabase::cleanupSyncThread()
{
ASSERT_ICON_SYNC_THREAD();
-#ifndef NDEBUG
+#if !LOG_DISABLED
double timeStamp = currentTime();
#endif
@@ -1792,7 +1792,7 @@ void* IconDatabase::cleanupSyncThread()
deleteAllPreparedStatements();
m_syncDB.close();
-#ifndef NDEBUG
+#if !LOG_DISABLED
LOG(IconDatabase, "(THREAD) Final closure took %.4f seconds", currentTime() - timeStamp);
#endif
diff --git a/Source/WebCore/page/DOMWindow.idl b/Source/WebCore/page/DOMWindow.idl
index 9f7313c..d5d3413 100644
--- a/Source/WebCore/page/DOMWindow.idl
+++ b/Source/WebCore/page/DOMWindow.idl
@@ -510,6 +510,7 @@ module window {
attribute [JSCCustomGetter] Int32ArrayConstructor Int32Array; // Usable with new operator
attribute [JSCCustomGetter] Uint32ArrayConstructor Uint32Array; // Usable with new operator
attribute [JSCCustomGetter] Float32ArrayConstructor Float32Array; // Usable with new operator
+ attribute [JSCCustomGetter] Float64ArrayConstructor Float64Array; // Usable with new operator
attribute [JSCCustomGetter] DataViewConstructor DataView; // Usable with new operator
attribute [JSCCustomGetter,Conditional=WEB_AUDIO,EnabledAtRuntime] AudioContextConstructor webkitAudioContext; // Usable with new operator
diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp
index 8a1ad69..049f08b 100644
--- a/Source/WebCore/page/Frame.cpp
+++ b/Source/WebCore/page/Frame.cpp
@@ -113,10 +113,6 @@
#include "WMLNames.h"
#endif
-#if PLATFORM(ANDROID)
-#include "WebViewCore.h"
-#endif
-
using namespace std;
namespace WebCore {
diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp
index 49a7d0c..a79910b 100644
--- a/Source/WebCore/page/FrameView.cpp
+++ b/Source/WebCore/page/FrameView.cpp
@@ -62,11 +62,6 @@
#include "TextResourceDecoder.h"
#include <wtf/CurrentTime.h>
-#ifdef ANDROID_INSTRUMENT
-#include "FrameTree.h"
-#include "TimeCounter.h"
-#endif
-
#if USE(ACCELERATED_COMPOSITING)
#include "RenderLayerCompositor.h"
#endif
@@ -872,11 +867,6 @@ void FrameView::layout(bool allowSubtree)
return;
}
-#ifdef ANDROID_INSTRUMENT
- if (!m_frame->tree() || !m_frame->tree()->parent())
- android::TimeCounter::start(android::TimeCounter::LayoutTimeCounter);
-#endif
-
m_nestedLayoutCount++;
if (!m_layoutRoot) {
@@ -1014,10 +1004,6 @@ void FrameView::layout(bool allowSubtree)
updateDashboardRegions();
#endif
-#ifdef ANDROID_INSTRUMENT
- if (!m_frame->tree()->parent())
- android::TimeCounter::record(android::TimeCounter::LayoutTimeCounter, __FUNCTION__);
-#endif
ASSERT(!root->needsLayout());
updateCanBlitOnScrollRecursively();
diff --git a/Source/WebCore/platform/Arena.cpp b/Source/WebCore/platform/Arena.cpp
index 231e1b6..33980ed 100644
--- a/Source/WebCore/platform/Arena.cpp
+++ b/Source/WebCore/platform/Arena.cpp
@@ -255,16 +255,4 @@ void FinishArenaPool(ArenaPool *pool)
FreeArenaList(pool, &pool->first, true);
}
-#ifdef ANDROID_INSTRUMENT
-size_t ReportPoolSize(const ArenaPool* pool)
-{
- size_t total = 0;
- for (const Arena *a = &pool->first; a; a = a->next)
- total += (a->limit - a->base);
- for (const Arena *fa = arena_freelist; fa; fa = fa->next )
- total += (fa->limit - fa->base);
- return total;
-}
-#endif
-
}
diff --git a/Source/WebCore/platform/Arena.h b/Source/WebCore/platform/Arena.h
index e937955..06e09f2 100644
--- a/Source/WebCore/platform/Arena.h
+++ b/Source/WebCore/platform/Arena.h
@@ -134,10 +134,6 @@ void* ArenaAllocate(ArenaPool *pool, unsigned int nb);
fastFree(a); \
(a) = 0;
-#ifdef ANDROID_INSTRUMENT
-size_t ReportPoolSize(const ArenaPool* pool);
-#endif
-
}
#endif
diff --git a/Source/WebCore/platform/NotImplemented.h b/Source/WebCore/platform/NotImplemented.h
index a71e99c..e9758b0 100644
--- a/Source/WebCore/platform/NotImplemented.h
+++ b/Source/WebCore/platform/NotImplemented.h
@@ -38,21 +38,7 @@
#define supressNotImplementedWarning() false
#endif
-#if OS(ANDROID)
-
-#include <cutils/log.h>
-#ifndef LOG_TAG
-#define LOG_TAG "WebCore"
-#endif
-#define notImplemented() do { \
- static bool havePrinted = false; \
- if (!havePrinted && !supressNotImplementedWarning()) { \
- LOGV("%s: notImplemented", __PRETTY_FUNCTION__); \
- havePrinted = true; \
- } \
- } while (0)
-
-#elif defined(NDEBUG)
+#if defined(NDEBUG)
#define notImplemented() ((void)0)
#else
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.cpp b/Source/WebCore/platform/android/RenderThemeAndroid.cpp
index 93c99a4..d579003 100644
--- a/Source/WebCore/platform/android/RenderThemeAndroid.cpp
+++ b/Source/WebCore/platform/android/RenderThemeAndroid.cpp
@@ -38,10 +38,8 @@
#include "RenderMediaControls.h"
#endif
#include "RenderSkinAndroid.h"
-#include "RenderSkinButton.h"
-#include "RenderSkinCombo.h"
#include "RenderSkinMediaButton.h"
-#include "RenderSkinRadio.h"
+#include "RoundedIntRect.h"
#include "SkCanvas.h"
#include "UserAgentStyleSheets.h"
#include "WebCoreFrameBridge.h"
@@ -63,6 +61,31 @@ const int listboxPadding = 5;
const RGBA32 selectionColor = makeRGB(181, 224, 136);
+// Colors copied from the holo resources
+const RGBA32 defaultBgColor = makeRGBA(204, 204, 204, 197);
+const RGBA32 defaultBgBright = makeRGBA(213, 213, 213, 221);
+const RGBA32 defaultBgDark = makeRGBA(92, 92, 92, 160);
+const RGBA32 defaultBgMedium = makeRGBA(132, 132, 132, 111);
+const RGBA32 defaultFgColor = makeRGBA(101, 101, 101, 225);
+const RGBA32 defaultCheckColor = makeRGBA(154, 204, 2, 255);
+
+const RGBA32 disabledBgColor = makeRGBA(205, 205, 205, 107);
+const RGBA32 disabledBgBright = makeRGBA(213, 213, 213, 133);
+const RGBA32 disabledBgDark = makeRGBA(92, 92, 92, 96);
+const RGBA32 disabledBgMedium = makeRGBA(132, 132, 132, 111);
+const RGBA32 disabledFgColor = makeRGBA(148, 148, 148, 137);
+
+const int paddingButton = 2;
+const int cornerButton = 2;
+
+// scale factors for various resolutions
+const float scaleFactor[RenderSkinAndroid::ResolutionCount] = {
+ 1.0f, // medium res
+ 1.5f, // high res
+ 2.0f // extra high res
+};
+
+
static SkCanvas* getCanvasFromInfo(const PaintInfo& info)
{
return info.context->platformContext()->mCanvas;
@@ -166,7 +189,7 @@ int RenderThemeAndroid::baselinePosition(const RenderObject* obj) const
// controls that need to do this.
//
// Our checkboxes and radio buttons need to be offset to line up properly.
- return RenderTheme::baselinePosition(obj) - 2;
+ return RenderTheme::baselinePosition(obj) - 8;
}
void RenderThemeAndroid::addIntrinsicMargins(RenderStyle* style) const
@@ -174,10 +197,10 @@ void RenderThemeAndroid::addIntrinsicMargins(RenderStyle* style) const
// Cut out the intrinsic margins completely if we end up using a small font size
if (style->fontSize() < 11)
return;
-
+
// Intrinsic margin value.
const int m = 2;
-
+
// FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed.
if (style->width().isIntrinsicOrAuto()) {
if (style->marginLeft().quirk())
@@ -210,22 +233,11 @@ bool RenderThemeAndroid::supportsFocus(ControlPart appearance)
void RenderThemeAndroid::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, WebCore::Element*) const
{
- // Code is taken from RenderThemeSafari.cpp
- // It makes sure we have enough space for the button text.
- const int paddingHoriz = 12;
- const int paddingVert = 8;
- style->setPaddingLeft(Length(paddingHoriz, Fixed));
- style->setPaddingRight(Length(paddingHoriz, Fixed));
- style->setPaddingTop(Length(paddingVert, Fixed));
- style->setPaddingBottom(Length(paddingVert, Fixed));
-
- // Set a min-height so that we can't get smaller than the mini button.
- style->setMinHeight(Length(15, Fixed));
}
bool RenderThemeAndroid::paintCheckbox(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
{
- RenderSkinRadio::Draw(getCanvasFromInfo(info), obj->node(), rect, true);
+ paintRadio(obj, info, rect);
return false;
}
@@ -237,16 +249,50 @@ bool RenderThemeAndroid::paintButton(RenderObject* obj, const PaintInfo& info, c
if (formControlElement) {
android::WebFrame* webFrame = getWebFrame(node);
if (webFrame) {
- RenderSkinAndroid* skins = webFrame->renderSkins();
- if (skins) {
- RenderSkinAndroid::State state = RenderSkinAndroid::kNormal;
- if (!formControlElement->isEnabledFormControl())
- state = RenderSkinAndroid::kDisabled;
- skins->renderSkinButton()->draw(getCanvasFromInfo(info), rect, state);
+ GraphicsContext *context = info.context;
+ IntRect innerrect = IntRect(rect.x() + paddingButton, rect.y() + paddingButton,
+ rect.width() - 2 * paddingButton, rect.height() - 2 * paddingButton);
+ IntSize cornerrect = IntSize(cornerButton, cornerButton);
+ Color bg, bright, dark, medium;
+ if (formControlElement->isEnabledFormControl()) {
+ bg = Color(defaultBgColor);
+ bright = Color(defaultBgBright);
+ dark = Color(defaultBgDark);
+ medium = Color(defaultBgMedium);
+ } else {
+ bg = Color(disabledBgColor);
+ bright = Color(disabledBgBright);
+ dark = Color(disabledBgDark);
+ medium = Color(disabledBgMedium);
}
+ context->save();
+ context->clip(
+ IntRect(innerrect.x(), innerrect.y(), innerrect.width(), 1));
+ context->fillRoundedRect(innerrect, cornerrect, cornerrect,
+ cornerrect, cornerrect, bright, context->fillColorSpace());
+ context->restore();
+ context->save();
+ context->clip(IntRect(innerrect.x(), innerrect.y() + innerrect.height() - 1,
+ innerrect.width(), 1));
+ context->fillRoundedRect(innerrect, cornerrect, cornerrect,
+ cornerrect, cornerrect, dark, context->fillColorSpace());
+ context->restore();
+ context->save();
+ context->clip(IntRect(innerrect.x(), innerrect.y() + 1, innerrect.width(),
+ innerrect.height() - 2));
+ context->fillRoundedRect(innerrect, cornerrect, cornerrect,
+ cornerrect, cornerrect, bg, context->fillColorSpace());
+ context->restore();
+ context->setStrokeColor(medium, context->strokeColorSpace());
+ context->setStrokeThickness(1.0f);
+ context->drawLine(IntPoint(innerrect.x(), innerrect.y() + cornerButton),
+ IntPoint(innerrect.x(), innerrect.y() + innerrect.height() - cornerButton));
+ context->drawLine(IntPoint(innerrect.x() + innerrect.width(), innerrect.y() + cornerButton),
+ IntPoint(innerrect.x() + innerrect.width(), innerrect.y() + innerrect.height() - cornerButton));
}
}
+
// We always return false so we do not request to be redrawn.
return false;
}
@@ -336,7 +382,9 @@ bool RenderThemeAndroid::paintMediaControlsBackground(RenderObject* o, const Pai
bool translucent = false;
if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag))
translucent = true;
- RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::BACKGROUND_SLIDER, translucent);
+ RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect,
+ RenderSkinMediaButton::BACKGROUND_SLIDER,
+ translucent, 0, false);
return false;
}
@@ -355,7 +403,9 @@ bool RenderThemeAndroid::paintMediaSliderThumb(RenderObject* o, const PaintInfo&
bool translucent = false;
if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag))
translucent = true;
- RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::SLIDER_THUMB, translucent);
+ RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect,
+ RenderSkinMediaButton::SLIDER_THUMB,
+ translucent, 0, false);
return false;
}
@@ -373,7 +423,49 @@ void RenderThemeAndroid::adjustSliderThumbSize(RenderObject* o) const
bool RenderThemeAndroid::paintRadio(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
{
- RenderSkinRadio::Draw(getCanvasFromInfo(info), obj->node(), rect, false);
+ Node* node = obj->node();
+ Element* element = static_cast<Element*>(node);
+ if (element) {
+ InputElement* input = element->toInputElement();
+ GraphicsContext* context = info.context;
+ if (!element->isEnabledFormControl()) {
+ context->setAlpha(0.5f);
+ }
+ const IntRect inner = IntRect(rect.x() - 2, rect.y() - 2, rect.width() - 4, rect.height() - 4);
+ context->setFillColor(Color(defaultBgBright), context->fillColorSpace());
+ context->setStrokeColor(Color(defaultBgBright), context->strokeColorSpace());
+ context->setStrokeThickness(1.0f);
+ if (input->isCheckbox()) {
+ context->drawRect(inner);
+ } else {
+ context->drawEllipse(inner);
+ }
+ context->setStrokeColor(Color(defaultFgColor), context->strokeColorSpace());
+ if (input->isCheckbox()) {
+ context->drawRect(IntRect(inner.x() + 2, inner.y() + 2, inner.width() -4, inner.height() - 4));
+ } else {
+ context->drawEllipse(IntRect(inner.x() + 2, inner.y() + 2, inner.width() -4, inner.height() - 4));
+ }
+ if (input->isChecked()) {
+ context->setFillColor(Color(defaultCheckColor), context->fillColorSpace());
+ context->setStrokeColor(Color(defaultCheckColor), context->strokeColorSpace());
+ if (input->isCheckbox()) {
+ const float w2 = ((float) rect.width() / 2);
+ const float cx = ((float) rect.x());
+ const float cy = ((float) rect.y());
+ context->save();
+ // magic numbers due to weird scale in context
+ context->translate(cx + w2 / 2.2f, cy + w2 / 1.2f);
+ context->rotate(3.93f); // 225 degrees
+ context->drawRect(IntRect(0, 0, rect.width() / 4, 2));
+ context->rotate(1.57f); // 90 degrees
+ context->drawRect(IntRect(0, 0, rect.width() / 2, 2));
+ context->restore();
+ } else {
+ context->drawEllipse(IntRect(inner.x() + 5, inner.y() + 5, inner.width() - 10, inner.height() - 10));
+ }
+ }
+ }
return false;
}
@@ -396,7 +488,7 @@ void RenderThemeAndroid::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* st
bool RenderThemeAndroid::paintTextField(RenderObject*, const PaintInfo&, const IntRect&)
{
- return true;
+ return true;
}
void RenderThemeAndroid::adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* style, WebCore::Element*) const
@@ -418,25 +510,29 @@ void RenderThemeAndroid::adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*
bool RenderThemeAndroid::paintSearchField(RenderObject*, const PaintInfo&, const IntRect&)
{
- return true;
+ return true;
}
static void adjustMenuListStyleCommon(RenderStyle* style)
{
// Added to make room for our arrow and make the touch target less cramped.
- style->setPaddingLeft(Length(RenderSkinCombo::padding(), Fixed));
- style->setPaddingTop(Length(RenderSkinCombo::padding(), Fixed));
- style->setPaddingBottom(Length(RenderSkinCombo::padding(), Fixed));
- style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed));
- style->setMinHeight(Length(RenderSkinCombo::minHeight(), Fixed));
+ const int padding = (int)(scaleFactor[RenderSkinAndroid::DrawableResolution()] + 0.5f);
+ style->setPaddingLeft(Length(padding,Fixed));
+ style->setPaddingTop(Length(padding, Fixed));
+ style->setPaddingBottom(Length(padding, Fixed));
+ // allocate height as arrow size
+ int arrow = std::max(18, style->fontMetrics().height() + 2 * padding);
+ style->setPaddingRight(Length(arrow, Fixed));
+ style->setMinHeight(Length(arrow, Fixed));
+ style->setHeight(Length(arrow, Fixed));
}
-void RenderThemeAndroid::adjustListboxStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
+void RenderThemeAndroid::adjustListboxStyle(CSSStyleSelector*, RenderStyle* style, Element* e) const
{
adjustMenuListButtonStyle(0, style, 0);
}
-void RenderThemeAndroid::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element* e) const
+void RenderThemeAndroid::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
{
adjustMenuListStyleCommon(style);
addIntrinsicMargins(style);
@@ -446,11 +542,55 @@ bool RenderThemeAndroid::paintCombo(RenderObject* obj, const PaintInfo& info, c
{
if (obj->style() && !obj->style()->visitedDependentColor(CSSPropertyBackgroundColor).alpha())
return true;
- return RenderSkinCombo::Draw(getCanvasFromInfo(info), obj->node(), rect.x(), rect.y(), rect.width(), rect.height());
+ Node* node = obj->node();
+ Element* element = static_cast<Element*>(node);
+ if (element) {
+ InputElement* input = element->toInputElement();
+ GraphicsContext* context = info.context;
+ if (!element->isEnabledFormControl()) {
+ context->setAlpha(0.5f);
+ }
+ IntRect bounds = IntRect(rect.x(), rect.y(), rect.width(), rect.height());
+ // paint bg color
+ RenderStyle* style = obj->style();
+ context->setFillColor(style->visitedDependentColor(CSSPropertyBackgroundColor),
+ context->fillColorSpace());
+ context->fillRect(FloatRect(bounds));
+ // copied form the original RenderSkinCombo:
+ // If this is an appearance where RenderTheme::paint returns true
+ // without doing anything, this means that
+ // RenderBox::PaintBoxDecorationWithSize will end up painting the
+ // border, so we shouldn't paint a border here.
+ if (style->appearance() != MenulistButtonPart &&
+ style->appearance() != ListboxPart &&
+ style->appearance() != TextFieldPart &&
+ style->appearance() != TextAreaPart) {
+ const int arrowSize = bounds.height();
+ // dropdown button bg
+ context->setFillColor(Color(defaultBgColor), context->fillColorSpace());
+ context->fillRect(FloatRect(bounds.maxX() - arrowSize + 0.5f, bounds.y() + .5f,
+ arrowSize - 1, bounds.height() - 1));
+ // outline
+ context->setStrokeThickness(1.0f);
+ context->setStrokeColor(Color(defaultBgDark), context->strokeColorSpace());
+ context->strokeRect(bounds, 1.0f);
+ // arrow
+ context->setFillColor(Color(defaultFgColor), context->fillColorSpace());
+ Path tri = Path();
+ tri.clear();
+ const float aw = arrowSize - 10;
+ FloatPoint br = FloatPoint(bounds.maxX() - 4, bounds.maxY() - 4);
+ tri.moveTo(br);
+ tri.addLineTo(FloatPoint(br.x() - aw, br.y()));
+ tri.addLineTo(FloatPoint(br.x(), br.y() - aw));
+ context->fillPath(tri);
+ }
+ }
+ return false;
}
-bool RenderThemeAndroid::paintMenuList(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
-{
+bool RenderThemeAndroid::paintMenuList(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
+{
return paintCombo(obj, info, rect);
}
@@ -461,13 +601,13 @@ void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector*,
const float baseFontSize = 11.0f;
const int baseBorderRadius = 5;
float fontScale = style->fontSize() / baseFontSize;
-
+
style->resetPadding();
style->setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(baseBorderRadius + fontScale - 1))); // FIXME: Round up?
const int minHeight = 15;
style->setMinHeight(Length(minHeight, Fixed));
-
+
style->setLineHeight(RenderStyle::initialLineHeight());
// Found these padding numbers by trial and error.
const int padding = 4;
@@ -476,7 +616,7 @@ void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector*,
adjustMenuListStyleCommon(style);
}
-bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
+bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
{
return paintCombo(obj, info, rect);
}
@@ -484,10 +624,10 @@ bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo&
bool RenderThemeAndroid::supportsFocusRing(const RenderStyle* style) const
{
return style->opacity() > 0
- && style->hasAppearance()
- && style->appearance() != TextFieldPart
- && style->appearance() != SearchFieldPart
- && style->appearance() != TextAreaPart
+ && style->hasAppearance()
+ && style->appearance() != TextFieldPart
+ && style->appearance() != SearchFieldPart
+ && style->appearance() != TextAreaPart
&& style->appearance() != CheckboxPart
&& style->appearance() != RadioPart
&& style->appearance() != PushButtonPart
diff --git a/Source/WebCore/platform/android/RenderThemeAndroid.h b/Source/WebCore/platform/android/RenderThemeAndroid.h
index e3922a1..89a6d46 100644
--- a/Source/WebCore/platform/android/RenderThemeAndroid.h
+++ b/Source/WebCore/platform/android/RenderThemeAndroid.h
@@ -31,10 +31,6 @@
namespace WebCore {
-class RenderSkinButton;
-class RenderSkinRadio;
-class RenderSkinCombo;
-
struct ThemeData {
ThemeData()
: m_part(0)
diff --git a/Source/WebCore/platform/android/SharedTimerAndroid.cpp b/Source/WebCore/platform/android/SharedTimerAndroid.cpp
index e4f3b36..a3f3db5 100644
--- a/Source/WebCore/platform/android/SharedTimerAndroid.cpp
+++ b/Source/WebCore/platform/android/SharedTimerAndroid.cpp
@@ -51,7 +51,7 @@ void setSharedTimerFireTime(double fireTime)
{
long long timeInMs = static_cast<long long>((fireTime - WTF::currentTime()) * 1000);
- LOGV("setSharedTimerFireTime: in %ld millisec", timeInMs);
+ ALOGV("setSharedTimerFireTime: in %ld millisec", timeInMs);
if (JavaSharedClient::GetTimerClient())
JavaSharedClient::GetTimerClient()->setSharedTimer(timeInMs);
}
diff --git a/Source/WebCore/platform/graphics/Color.h b/Source/WebCore/platform/graphics/Color.h
index 02ec005..0fb355b 100644
--- a/Source/WebCore/platform/graphics/Color.h
+++ b/Source/WebCore/platform/graphics/Color.h
@@ -162,15 +162,8 @@ public:
static const RGBA32 lightGray = 0xFFC0C0C0;
static const RGBA32 transparent = 0x00000000;
-#ifdef ANDROID_CSS_RING
- static const RGBA32 ringFill = 0x666699FF;
- static const RGBA32 ringPressedInner = 0x006699FF;
- static const RGBA32 ringPressedOuter = 0x336699FF;
- static const RGBA32 ringSelectedInner = 0xAA6699FF;
- static const RGBA32 ringSelectedOuter = 0x336699FF;
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
- static const RGBA32 tap = 0x4D1A1A1A;
+ static const RGBA32 tap = 0x6633B5E5;
#endif
private:
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index 9c7716c..a3c92cd 100644
--- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -131,7 +131,7 @@ void BaseLayerAndroid::prefetchBasePicture(SkRect& viewport, float currentScale,
viewport.fTop,
viewport.fRight,
viewport.fBottom,
- scale);
+ currentScale);
bounds.fLeft = static_cast<int>(floorf(viewport.fLeft * invTileWidth)) - PREFETCH_X_DIST;
bounds.fTop = static_cast<int>(floorf(viewport.fTop * invTileHeight)) - PREFETCH_Y_DIST;
@@ -141,7 +141,7 @@ void BaseLayerAndroid::prefetchBasePicture(SkRect& viewport, float currentScale,
XLOG("prefetch rect %d %d %d %d, scale %f, preparing page %p",
bounds.fLeft, bounds.fTop,
bounds.fRight, bounds.fBottom,
- scale * PREFETCH_SCALE,
+ prefetchScale,
prefetchTiledPage);
prefetchTiledPage->setScale(prefetchScale);
@@ -290,8 +290,8 @@ bool BaseLayerAndroid::prepareBasePictureInGL(SkRect& viewport, float scale,
tiledPage->prepare(goingDown, goingLeft, preZoomBounds,
TiledPage::ExpandedBounds);
- XLOG("scrolling %d, zooming %d, needsRedraw %d",
- scrolling, zooming, needsRedraw);
+ XLOG("scrollState %d, zooming %d, needsRedraw %d",
+ m_scrollState, zooming, needsRedraw);
// prefetch in the nextTiledPage if unused by zooming (even if not scrolling
// since we want the tiles to be ready before they're needed)
@@ -361,6 +361,7 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
// TODO: consider moving drawBackground outside of prepare (into tree manager)
m_state->drawBackground(m_color);
drawBasePictureInGL();
+ m_state->glExtras()->drawGL(0);
bool needsRedraw = false;
diff --git a/Source/WebCore/platform/graphics/android/BaseRenderer.cpp b/Source/WebCore/platform/graphics/android/BaseRenderer.cpp
index 57baee8..b708ad1 100644
--- a/Source/WebCore/platform/graphics/android/BaseRenderer.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseRenderer.cpp
@@ -141,7 +141,13 @@ int BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo)
// only color the invalidated area
SkPaint invalPaint;
invalPaint.setARGB(color, 0, 255, 0);
- canvas.drawIRect(*renderInfo.invalRect, invalPaint);
+ if (renderInfo.invalRect)
+ canvas.drawIRect(*renderInfo.invalRect, invalPaint);
+ else {
+ SkIRect rect;
+ rect.set(0, 0, tileSize.width(), tileSize.height());
+ canvas.drawIRect(rect, invalPaint);
+ }
// paint the tile boundaries
SkPaint paint;
@@ -154,6 +160,18 @@ int BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo)
canvas.drawLine(0, 0, tileSize.width(), 0, paint);
canvas.drawLine(tileSize.width(), 0, tileSize.width(), tileSize.height(), paint);
+ if (renderInfo.invalRect) {
+ // if partial inval...
+ int x = renderInfo.invalRect->fLeft;
+ int y = renderInfo.invalRect->fTop;
+ int w = renderInfo.invalRect->width();
+ int h = renderInfo.invalRect->height();
+
+ paint.setARGB(128, 255, 255, 0);
+ canvas.drawLine(x, y, x + w, y + h, paint);
+ canvas.drawLine(x, y + h, x + w, y, paint);
+ }
+
if (renderInfo.measurePerf)
drawTileInfo(&canvas, renderInfo, pictureCount);
}
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp
index 27bd482..42d02a5 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp
@@ -54,6 +54,13 @@
#endif // DEBUG
+// If the dirty portion of a tile exceeds this ratio, fully repaint.
+// Lower values give fewer partial repaints, thus fewer front-to-back
+// texture copies (cost will vary by device). It's a tradeoff between
+// the rasterization cost and the FBO texture recopy cost when using
+// GPU for the transfer queue.
+#define MAX_INVAL_AREA 0.6
+
namespace WebCore {
BaseTile::BaseTile(bool isLayerTile)
@@ -68,6 +75,7 @@ BaseTile::BaseTile(bool isLayerTile)
, m_dirty(true)
, m_repaintPending(false)
, m_lastDirtyPicture(0)
+ , m_fullRepaint(true)
, m_isTexturePainted(false)
, m_isLayerTile(isLayerTile)
, m_drawCount(0)
@@ -76,20 +84,6 @@ BaseTile::BaseTile(bool isLayerTile)
#ifdef DEBUG_COUNT
ClassTracker::instance()->increment("BaseTile");
#endif
- m_currentDirtyAreaIndex = 0;
-
- // For EglImage Mode, the internal buffer should be 2.
- // For Surface Texture mode, we only need one.
- if (TilesManager::instance()->getSharedTextureMode() == EglImageMode)
- m_maxBufferNumber = 2;
- else
- m_maxBufferNumber = 1;
-
- m_dirtyArea = new SkRegion[m_maxBufferNumber];
- m_fullRepaint = new bool[m_maxBufferNumber];
- for (int i = 0; i < m_maxBufferNumber; i++)
- m_fullRepaint[i] = true;
-
m_renderer = BaseRenderer::createRenderer();
}
@@ -101,8 +95,6 @@ BaseTile::~BaseTile()
m_frontTexture->release(this);
delete m_renderer;
- delete[] m_dirtyArea;
- delete[] m_fullRepaint;
#ifdef DEBUG_COUNT
ClassTracker::instance()->decrement("BaseTile");
@@ -181,8 +173,7 @@ void BaseTile::markAsDirty(int unsigned pictureCount,
return;
android::AutoMutex lock(m_atomicSync);
m_lastDirtyPicture = pictureCount;
- for (int i = 0; i < m_maxBufferNumber; i++)
- m_dirtyArea[i].op(dirtyArea, SkRegion::kUnion_Op);
+ m_dirtyArea.op(dirtyArea, SkRegion::kUnion_Op);
// Check if we actually intersect with the area
bool intersect = false;
@@ -262,25 +253,11 @@ void BaseTile::draw(float transparency, SkRect& rect, float scale)
if (!isTexturePainted)
return;
- TextureInfo* textureInfo = m_frontTexture->consumerLock();
- if (!textureInfo) {
- m_frontTexture->consumerRelease();
- return;
- }
-
- if (m_frontTexture->readyFor(this)) {
- if (isLayerTile() && m_painter && m_painter->transform())
- TilesManager::instance()->shader()->drawLayerQuad(*m_painter->transform(),
- rect, m_frontTexture->m_ownTextureId,
- transparency, true);
- else
- TilesManager::instance()->shader()->drawQuad(rect, m_frontTexture->m_ownTextureId,
- transparency);
- } else {
+ if (m_frontTexture->readyFor(this))
+ m_frontTexture->draw(isLayerTile(), m_painter, rect, transparency);
+ else {
XLOG("tile %p at %d, %d not readyfor (at draw),", this, m_x, m_y);
}
-
- m_frontTexture->consumerRelease();
}
bool BaseTile::isTileReady()
@@ -301,9 +278,7 @@ bool BaseTile::isTileReady()
if (m_state != ReadyToSwap && m_state != UpToDate)
return false;
- texture->consumerLock();
bool ready = texture->readyFor(this);
- texture->consumerRelease();
if (ready)
return true;
@@ -350,7 +325,7 @@ void BaseTile::paintBitmap()
m_atomicSync.lock();
bool dirty = m_dirty;
BaseTileTexture* texture = m_backTexture;
- SkRegion dirtyArea = m_dirtyArea[m_currentDirtyAreaIndex];
+ SkRegion dirtyArea = m_dirtyArea;
float scale = m_scale;
const int x = m_x;
const int y = m_y;
@@ -365,15 +340,12 @@ void BaseTile::paintBitmap()
this, m_state, m_frontTexture, m_backTexture);
}
m_state = PaintingStarted;
-
- texture->producerAcquireContext();
- TextureInfo* textureInfo = texture->producerLock();
+ TextureInfo* textureInfo = texture->getTextureInfo();
m_atomicSync.unlock();
// at this point we can safely check the ownership (if the texture got
// transferred to another BaseTile under us)
if (texture->owner() != this) {
- texture->producerRelease();
return;
}
@@ -381,7 +353,6 @@ void BaseTile::paintBitmap()
// swap out the renderer if necessary
BaseRenderer::swapRendererIfNeeded(m_renderer);
-
// setup the common renderInfo fields;
TileRenderInfo renderInfo;
renderInfo.x = x;
@@ -399,82 +370,81 @@ void BaseTile::paintBitmap()
bool fullRepaint = false;
- if (m_fullRepaint[m_currentDirtyAreaIndex]
+ if (m_fullRepaint
|| textureInfo->m_width != tileWidth
|| textureInfo->m_height != tileHeight) {
fullRepaint = true;
}
- bool surfaceTextureMode = textureInfo->getSharedTextureMode() == SurfaceTextureMode;
-
- if (surfaceTextureMode)
- fullRepaint = true;
-
- while (!fullRepaint && !cliperator.done()) {
- SkRect realTileRect;
- SkRect dirtyRect;
- dirtyRect.set(cliperator.rect());
- bool intersect = intersectWithRect(x, y, tileWidth, tileHeight,
- scale, dirtyRect, realTileRect);
-
- // With SurfaceTexture, just repaint the entire tile if we intersect
- // TODO: Implement the partial invalidate in Surface Texture Mode
- if (intersect && surfaceTextureMode) {
- fullRepaint = true;
- break;
- }
-
- if (intersect && !surfaceTextureMode) {
- // initialize finalRealRect to the rounded values of realTileRect
- SkIRect finalRealRect;
- realTileRect.roundOut(&finalRealRect);
-
- // stash the int values of the current width and height
- const int iWidth = finalRealRect.width();
- const int iHeight = finalRealRect.height();
-
- if (iWidth == tileWidth || iHeight == tileHeight) {
- fullRepaint = true;
- break;
+ // For now, only do full repaint
+ fullRepaint = true;
+
+ if (!fullRepaint) {
+ // compute the partial inval area
+ SkIRect totalRect;
+ totalRect.set(0, 0, 0, 0);
+ float tileSurface = tileWidth * tileHeight;
+ float tileSurfaceCap = MAX_INVAL_AREA * tileSurface;
+
+ // We join all the invals in the same tile for now
+ while (!fullRepaint && !cliperator.done()) {
+ SkRect realTileRect;
+ SkRect dirtyRect;
+ dirtyRect.set(cliperator.rect());
+ bool intersect = intersectWithRect(x, y, tileWidth, tileHeight,
+ scale, dirtyRect, realTileRect);
+ if (intersect) {
+ // initialize finalRealRect to the rounded values of realTileRect
+ SkIRect finalRealRect;
+ realTileRect.roundOut(&finalRealRect);
+
+ // stash the int values of the current width and height
+ const int iWidth = finalRealRect.width();
+ const int iHeight = finalRealRect.height();
+
+ if (iWidth == tileWidth || iHeight == tileHeight) {
+ fullRepaint = true;
+ break;
+ }
+
+ // translate the rect into tile space coordinates
+ finalRealRect.fLeft = finalRealRect.fLeft % static_cast<int>(tileWidth);
+ finalRealRect.fTop = finalRealRect.fTop % static_cast<int>(tileHeight);
+ finalRealRect.fRight = finalRealRect.fLeft + iWidth;
+ finalRealRect.fBottom = finalRealRect.fTop + iHeight;
+ totalRect.join(finalRealRect);
+ float repaintSurface = totalRect.width() * totalRect.height();
+
+ if (repaintSurface > tileSurfaceCap) {
+ fullRepaint = true;
+ break;
+ }
}
- // translate the rect into tile space coordinates
- finalRealRect.fLeft = finalRealRect.fLeft % static_cast<int>(tileWidth);
- finalRealRect.fTop = finalRealRect.fTop % static_cast<int>(tileHeight);
- finalRealRect.fRight = finalRealRect.fLeft + iWidth;
- finalRealRect.fBottom = finalRealRect.fTop + iHeight;
+ cliperator.next();
+ }
- renderInfo.invalRect = &finalRealRect;
+ if (!fullRepaint) {
+ renderInfo.invalRect = &totalRect;
renderInfo.measurePerf = false;
-
pictureCount = m_renderer->renderTiledContent(renderInfo);
}
-
- cliperator.next();
}
// Do a full repaint if needed
if (fullRepaint) {
- SkIRect rect;
- rect.set(0, 0, tileWidth, tileHeight);
-
- renderInfo.invalRect = &rect;
+ renderInfo.invalRect = 0;
renderInfo.measurePerf = TilesManager::instance()->getShowVisualIndicator();
-
pictureCount = m_renderer->renderTiledContent(renderInfo);
}
m_atomicSync.lock();
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- texture->setTile(textureInfo, x, y, scale, painter, pictureCount);
-#endif
- texture->producerReleaseAndSwap();
if (texture == m_backTexture) {
m_isTexturePainted = true;
// set the fullrepaint flags
- m_fullRepaint[m_currentDirtyAreaIndex] = false;
+ m_fullRepaint = false;
// The various checks to see if we are still dirty...
@@ -484,19 +454,11 @@ void BaseTile::paintBitmap()
m_dirty = true;
if (fullRepaint)
- m_dirtyArea[m_currentDirtyAreaIndex].setEmpty();
+ m_dirtyArea.setEmpty();
else
- m_dirtyArea[m_currentDirtyAreaIndex].op(dirtyArea, SkRegion::kDifference_Op);
-
- if (!m_dirtyArea[m_currentDirtyAreaIndex].isEmpty())
- m_dirty = true;
-
- // Now we can swap the dirty areas
- // TODO: For surface texture in Async mode, the index will be updated
- // according to the current buffer just dequeued.
- m_currentDirtyAreaIndex = (m_currentDirtyAreaIndex+1) % m_maxBufferNumber;
+ m_dirtyArea.op(dirtyArea, SkRegion::kDifference_Op);
- if (!m_dirtyArea[m_currentDirtyAreaIndex].isEmpty())
+ if (!m_dirtyArea.isEmpty())
m_dirty = true;
XLOG("painted tile %p (%d, %d), texture %p, dirty=%d", this, x, y, texture, m_dirty);
@@ -522,10 +484,9 @@ void BaseTile::discardTextures() {
m_backTexture->release(this);
m_backTexture = 0;
}
- for (int i = 0; i < m_maxBufferNumber; i++) {
- m_dirtyArea[i].setEmpty();
- m_fullRepaint[i] = true;
- }
+ m_dirtyArea.setEmpty();
+ m_fullRepaint = true;
+
m_dirty = true;
m_state = Unpainted;
}
@@ -589,9 +550,12 @@ void BaseTile::validatePaint() {
// when both have happened, mark as 'ReadyToSwap'
if (m_state == PaintingStarted)
m_state = ValidatedUntransferred;
- else if (m_state == TransferredUnvalidated)
+ else if (m_state == TransferredUnvalidated) {
+ // When the backTexture has been marked pureColor, we will skip the
+ // transfer and marked as ReadyToSwap, in this case, we don't want
+ // to reset m_dirty bit to true.
m_state = ReadyToSwap;
- else {
+ } else {
XLOG("Note: validated tile %p at %d %d, state wasn't paintingstarted or transferred %d",
this, m_x, m_y, m_state);
// failed transferring, in which case mark dirty (since
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h
index 685ca43..ed06332 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.h
+++ b/Source/WebCore/platform/graphics/android/BaseTile.h
@@ -172,10 +172,8 @@ private:
unsigned int m_lastDirtyPicture;
// store the dirty region
- SkRegion* m_dirtyArea;
- bool* m_fullRepaint;
- int m_maxBufferNumber;
- int m_currentDirtyAreaIndex;
+ SkRegion m_dirtyArea;
+ bool m_fullRepaint;
// flag used to know if we have a texture that was painted at least once
bool m_isTexturePainted;
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
index caaf116..04d0fc9 100644
--- a/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.cpp
@@ -53,17 +53,12 @@
namespace WebCore {
BaseTileTexture::BaseTileTexture(uint32_t w, uint32_t h)
- : DoubleBufferedTexture(eglGetCurrentContext(),
- TilesManager::instance()->getSharedTextureMode())
- , m_owner(0)
- , m_busy(false)
+ : m_owner(0)
+ , m_isPureColor(false)
{
m_size.set(w, h);
m_ownTextureId = 0;
- // Make sure they are created on the UI thread.
- TilesManager::instance()->transferQueue()->initSharedSurfaceTextures(w, h);
-
#ifdef DEBUG_COUNT
ClassTracker::instance()->increment("BaseTileTexture");
#endif
@@ -71,10 +66,6 @@ BaseTileTexture::BaseTileTexture(uint32_t w, uint32_t h)
BaseTileTexture::~BaseTileTexture()
{
- if (m_sharedTextureMode == EglImageMode) {
- SharedTexture* textures[3] = { m_textureA, m_textureB, 0 };
- destroyTextures(textures);
- }
#ifdef DEBUG_COUNT
ClassTracker::instance()->decrement("BaseTileTexture");
#endif
@@ -98,71 +89,6 @@ void BaseTileTexture::discardGLTexture()
}
}
-void BaseTileTexture::destroyTextures(SharedTexture** textures)
-{
- int x = 0;
- while (textures[x]) {
- // We need to delete the source texture and EGLImage in the texture
- // generation thread. In theory we should be able to delete the EGLImage
- // from either thread, but it currently throws an error if not deleted
- // in the same EGLContext from which it was created.
- textures[x]->lock();
- DeleteTextureOperation* operation = new DeleteTextureOperation(
- textures[x]->getSourceTextureId(), textures[x]->getEGLImage());
- textures[x]->unlock();
- TilesManager::instance()->scheduleOperation(operation);
- x++;
- }
-}
-
-TextureInfo* BaseTileTexture::producerLock()
-{
- m_busyLock.lock();
- m_busy = true;
- m_busyLock.unlock();
- return DoubleBufferedTexture::producerLock();
-}
-
-void BaseTileTexture::producerRelease()
-{
- DoubleBufferedTexture::producerRelease();
- setNotBusy();
-}
-
-void BaseTileTexture::producerReleaseAndSwap()
-{
- DoubleBufferedTexture::producerReleaseAndSwap();
- setNotBusy();
-}
-
-void BaseTileTexture::setNotBusy()
-{
- android::Mutex::Autolock lock(m_busyLock);
- m_busy = false;
- m_busyCond.signal();
-}
-
-bool BaseTileTexture::busy()
-{
- android::Mutex::Autolock lock(m_busyLock);
- return m_busy;
-}
-
-void BaseTileTexture::producerUpdate(TextureInfo* textureInfo, const SkBitmap& bitmap)
-{
- // no need to upload a texture since the bitmap is empty
- if (!bitmap.width() && !bitmap.height()) {
- producerRelease();
- return;
- }
-
- // After the tiled layer checked in, this is not called anyway.
- // TODO: cleanup the old code path for layer painting
- // GLUtils::paintTextureWithBitmap(info, m_size, bitmap, 0, 0);
-
- producerReleaseAndSwap();
-}
-
bool BaseTileTexture::acquire(TextureOwner* owner, bool force)
{
if (m_owner == owner)
@@ -173,39 +99,21 @@ bool BaseTileTexture::acquire(TextureOwner* owner, bool force)
bool BaseTileTexture::setOwner(TextureOwner* owner, bool force)
{
- // if the writable texture is busy (i.e. currently being written to) then we
- // can't change the owner out from underneath that texture
- m_busyLock.lock();
- while (m_busy && force)
- m_busyCond.wait(m_busyLock);
- bool busy = m_busy;
- m_busyLock.unlock();
-
- if (!busy) {
- // if we are not busy we can try to remove the texture from the layer;
- // LayerAndroid::removeTexture() is protected by the same lock as
- // LayerAndroid::paintBitmapGL(), so either we execute removeTexture()
- // first and paintBitmapGL() will bail out, or we execute it after,
- // and paintBitmapGL() will mark the texture as busy before
- // relinquishing the lock. LayerAndroid::removeTexture() will call
- // BaseTileTexture::release(), which will then do nothing
- // if the texture is busy and we then don't return true.
- bool proceed = true;
- if (m_owner && m_owner != owner)
- proceed = m_owner->removeTexture(this);
-
- if (proceed) {
- m_owner = owner;
- return true;
- }
+ bool proceed = true;
+ if (m_owner && m_owner != owner)
+ proceed = m_owner->removeTexture(this);
+
+ if (proceed) {
+ m_owner = owner;
+ return true;
}
+
return false;
}
bool BaseTileTexture::release(TextureOwner* owner)
{
- android::Mutex::Autolock lock(m_busyLock);
- XLOG("texture %p releasing tile %p, m_owner %p, m_busy %d", this, owner, m_owner, m_busy);
+ XLOG("texture %p releasing tile %p, m_owner %p", this, owner, m_owner);
if (m_owner != owner)
return false;
@@ -213,22 +121,6 @@ bool BaseTileTexture::release(TextureOwner* owner)
return true;
}
-void BaseTileTexture::setTile(TextureInfo* info, int x, int y,
- float scale, TilePainter* painter,
- unsigned int pictureCount)
-{
- TextureTileInfo* textureInfo = m_texturesInfo.get(getWriteableTexture());
- if (!textureInfo) {
- textureInfo = new TextureTileInfo();
- }
- textureInfo->m_x = x;
- textureInfo->m_y = y;
- textureInfo->m_scale = scale;
- textureInfo->m_painter = painter;
- textureInfo->m_picture = pictureCount;
- m_texturesInfo.set(getWriteableTexture(), textureInfo);
-}
-
float BaseTileTexture::scale()
{
TextureTileInfo* textureInfo = &m_ownTextureTileInfo;
@@ -255,6 +147,13 @@ void BaseTileTexture::setOwnTextureTileInfoFromQueue(const TextureTileInfo* info
bool BaseTileTexture::readyFor(BaseTile* baseTile)
{
const TextureTileInfo* info = &m_ownTextureTileInfo;
+
+ if (isPureColor() && info->m_painter == baseTile->painter()) {
+ XLOG("ReadyFor saw a pureColor tile (%p) at (%d, %d), rgb %x",
+ this, baseTile->x(), baseTile->y(), pureColor().rgb());
+ return true;
+ }
+
if (info &&
(info->m_x == baseTile->x()) &&
(info->m_y == baseTile->y()) &&
@@ -270,4 +169,24 @@ bool BaseTileTexture::readyFor(BaseTile* baseTile)
return false;
}
+void BaseTileTexture::draw(bool isLayer, TilePainter* painter,
+ SkRect& rect, float transparency)
+{
+ ShaderProgram* shader = TilesManager::instance()->shader();
+ if (isLayer && painter && painter->transform()) {
+ if (isPureColor()) {
+ shader->drawLayerQuad(*painter->transform(), rect, 0, transparency,
+ true, GL_TEXTURE_2D, pureColor());
+ } else {
+ shader->drawLayerQuad(*painter->transform(), rect, m_ownTextureId,
+ transparency, true);
+ }
+ } else {
+ if (isPureColor())
+ shader->drawQuad(rect, 0,transparency, pureColor());
+ else
+ shader->drawQuad(rect, m_ownTextureId, transparency);
+ }
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/BaseTileTexture.h b/Source/WebCore/platform/graphics/android/BaseTileTexture.h
index cd8e78b..67eeeb9 100644
--- a/Source/WebCore/platform/graphics/android/BaseTileTexture.h
+++ b/Source/WebCore/platform/graphics/android/BaseTileTexture.h
@@ -26,10 +26,11 @@
#ifndef BaseTileTexture_h
#define BaseTileTexture_h
-#include "DoubleBufferedTexture.h"
#include "GLWebViewState.h"
+#include "TextureInfo.h"
#include "TextureOwner.h"
#include "TilePainter.h"
+#include <GLES2/gl2.h>
#include <SkBitmap.h>
class SkCanvas;
@@ -59,46 +60,29 @@ public:
TilePainter* m_painter;
unsigned int m_picture;
bool m_inverted;
+ IntRect m_inval;
};
-// DoubleBufferedTexture using a SkBitmap as backing mechanism
-class BaseTileTexture : public DoubleBufferedTexture {
+class BaseTileTexture {
public:
// This object is to be constructed on the consumer's thread and must have
// a width and height greater than 0.
BaseTileTexture(uint32_t w, uint32_t h);
virtual ~BaseTileTexture();
- // these functions override their parent
- virtual TextureInfo* producerLock();
- virtual void producerRelease();
- virtual void producerReleaseAndSwap();
-
- // updates the texture with current bitmap and releases (and if needed also
- // swaps) the texture.
- virtual void producerUpdate(TextureInfo* textureInfo, const SkBitmap& bitmap);
-
// allows consumer thread to assign ownership of the texture to the tile. It
// returns false if ownership cannot be transferred because the tile is busy
bool acquire(TextureOwner* owner, bool force = false);
bool release(TextureOwner* owner);
- // removes Tile->Texture, and Texture->Tile links to fully discard the texture
- void releaseAndRemoveFromTile();
-
// set the texture owner if not busy. Return false if busy, true otherwise.
bool setOwner(TextureOwner* owner, bool force = false);
// private member accessor functions
TextureOwner* owner() { return m_owner; } // only used by the consumer thread
- bool busy();
- void setNotBusy();
-
const SkSize& getSize() const { return m_size; }
- void setTile(TextureInfo* info, int x, int y, float scale,
- TilePainter* painter, unsigned int pictureCount);
bool readyFor(BaseTile* baseTile);
float scale();
@@ -110,29 +94,31 @@ public:
void setOwnTextureTileInfoFromQueue(const TextureTileInfo* info);
-protected:
- HashMap<SharedTexture*, TextureTileInfo*> m_texturesInfo;
+ TextureInfo* getTextureInfo() { return &m_ownTextureInfo; }
+
+ // Make sure the following pureColor getter/setter are only read/written
+ // in UI thread. Therefore no need for a lock.
+ void setPure(bool pure) { m_isPureColor = pure; }
+ bool isPureColor() {return m_isPureColor; }
+ void setPureColor(const Color& color) { m_pureColor = color; setPure(true); }
+ Color pureColor() { return m_pureColor; }
+ void draw(bool isLayer, TilePainter* painter, SkRect& rect,
+ float transparency);
private:
- void destroyTextures(SharedTexture** textures);
TextureTileInfo m_ownTextureTileInfo;
-
+ // TODO: Merge this info into the TextureTileInfo.
+ TextureInfo m_ownTextureInfo;
SkSize m_size;
SkBitmap::Config m_config;
// BaseTile owning the texture, only modified by UI thread
TextureOwner* m_owner;
- // This values signals that the texture is currently in use by the consumer.
- // This allows us to prevent the owner of the texture from changing while the
- // consumer is holding a lock on the texture.
- bool m_busy;
- // We mutex protect the reads/writes of m_busy to ensure that we are reading
- // the most up-to-date value even across processors in an SMP system.
- android::Mutex m_busyLock;
- // We use this condition variable to signal that the texture
- // is not busy anymore
- android::Condition m_busyCond;
+ // When the whole tile is single color, skip the transfer queue and draw
+ // it directly through shader.
+ bool m_isPureColor;
+ Color m_pureColor;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp b/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp
deleted file mode 100644
index 4c5af9e..0000000
--- a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DoubleBufferedTexture.h"
-
-#include "ClassTracker.h"
-#include "GLUtils.h"
-
-#define LOG_NDEBUG 1
-#define LOG_TAG "DoubleBufferedTexture.cpp"
-#include <utils/Log.h>
-
-namespace WebCore {
-
-DoubleBufferedTexture::DoubleBufferedTexture(EGLContext sharedContext, SharedTextureMode mode)
-{
- m_sharedTextureMode = mode;
-
- m_textureA = new SharedTexture(m_sharedTextureMode);
- if (m_sharedTextureMode == EglImageMode)
- m_textureB = new SharedTexture(m_sharedTextureMode);
- else
- m_textureB = 0;
-
- m_display = eglGetCurrentDisplay();
- m_pContext = EGL_NO_CONTEXT;
- m_cContext = sharedContext;
- m_writeableTexture = m_textureA;
- m_lockedConsumerTexture = GL_NO_TEXTURE;
- m_supportsEGLImage = GLUtils::isEGLImageSupported();
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->increment("DoubleBufferedTexture");
-#endif
-}
-
-DoubleBufferedTexture::~DoubleBufferedTexture()
-{
-#ifdef DEBUG_COUNT
- ClassTracker::instance()->decrement("DoubleBufferedTexture");
-#endif
- delete m_textureA;
- delete m_textureB;
-}
-
-SharedTexture* DoubleBufferedTexture::getWriteableTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return m_textureA;
- return reinterpret_cast<SharedTexture*>(
- android_atomic_release_load((int32_t*)&m_writeableTexture));
-}
-
-SharedTexture* DoubleBufferedTexture::getReadableTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return m_textureA;
- return (getWriteableTexture() != m_textureA) ? m_textureA : m_textureB;
-}
-
-EGLContext DoubleBufferedTexture::producerAcquireContext()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return EGL_NO_CONTEXT;
-
- if (m_pContext != EGL_NO_CONTEXT) {
- LOGV("AquireContext has previously generated a context.\n");
- return m_pContext;
- }
-
- // check to see if a context already exists on this thread
- EGLContext context = eglGetCurrentContext();
-
- // if no context exists then create one
- if (context == EGL_NO_CONTEXT) {
- EGLContext sharedContext = m_supportsEGLImage ? EGL_NO_CONTEXT : m_cContext;
- context = GLUtils::createBackgroundContext(sharedContext);
- }
-
- if (context == EGL_NO_CONTEXT) {
- LOGE("eglCreateContext failed");
- return EGL_NO_CONTEXT;
- }
-
- // initialize the producer's textures
- m_textureA->lock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->lock();
-
- m_textureA->initSourceTexture();
- LOGV("Initialized Textures A (%d)", m_textureA->getSourceTextureId());
- if (m_sharedTextureMode == EglImageMode) {
- m_textureB->initSourceTexture();
- LOGV("Initialized Textures B (%d)", m_textureB->getSourceTextureId());
- }
-
- m_textureA->unlock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->unlock();
-
- m_pContext = context;
- return context;
-}
-
-// For MediaTexture only
-void DoubleBufferedTexture::producerDeleteTextures()
-{
- m_textureA->lock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->lock();
-
- LOGV("Deleting Producer Textures A (%d)", m_textureA->getSourceTextureId());
- m_textureA->deleteSourceTexture();
- if (m_sharedTextureMode == EglImageMode){
- LOGV("Deleting Producer Textures B (%d)", m_textureB->getSourceTextureId());
- m_textureB->deleteSourceTexture();
- }
-
- m_textureA->unlock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->unlock();
-}
-
-// For MediaTexture only
-void DoubleBufferedTexture::consumerDeleteTextures()
-{
- m_textureA->lock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->lock();
-
- LOGV("Deleting Consumer Textures A (%d)", m_textureA->getTargetTextureId());
- m_textureA->deleteTargetTexture();
- if (m_sharedTextureMode == EglImageMode) {
- LOGV("Deleting Consumer Textures B (%d)", m_textureB->getTargetTextureId());
- m_textureB->deleteTargetTexture();
- }
-
- m_textureA->unlock();
- if (m_sharedTextureMode == EglImageMode)
- m_textureB->unlock();
-}
-
-TextureInfo* DoubleBufferedTexture::producerLock()
-{
- SharedTexture* sharedTex = getWriteableTexture();
- LOGV("Acquiring P Lock (%d)", sharedTex->getSourceTextureId());
- TextureInfo* texInfo = sharedTex->lockSource();
- LOGV("Acquired P Lock");
-
- return texInfo;
-}
-
-void DoubleBufferedTexture::producerRelease()
-{
- // get the writable texture and unlock it
- SharedTexture* sharedTex = getWriteableTexture();
- LOGV("Releasing P Lock (%d)", sharedTex->getSourceTextureId());
- sharedTex->releaseSource();
- LOGV("Released P Lock (%d)", sharedTex->getSourceTextureId());
-}
-
-void DoubleBufferedTexture::producerReleaseAndSwap()
-{
- producerRelease();
- if (m_sharedTextureMode == EglImageMode) {
- // swap the front and back buffers using an atomic op for the memory barrier
- android_atomic_acquire_store((int32_t)getReadableTexture(), (int32_t*)&m_writeableTexture);
- }
-}
-
-TextureInfo* DoubleBufferedTexture::consumerLock()
-{
- SharedTexture* sharedTex = getReadableTexture();
- LOGV("Acquiring C Lock (%d)", sharedTex->getSourceTextureId());
- m_lockedConsumerTexture = sharedTex;
-
- TextureInfo* texInfo = sharedTex->lockTarget();
- LOGV("Acquired C Lock");
-
- if (!texInfo)
- LOGV("Released C Lock (Empty)");
-
- return texInfo;
-}
-
-void DoubleBufferedTexture::consumerRelease()
-{
- // we must check to see what texture the consumer had locked since the
- // producer may have swapped out the readable buffer
- SharedTexture* sharedTex = m_lockedConsumerTexture;
- sharedTex->releaseTarget();
- LOGV("Released C Lock (%d)", sharedTex->getSourceTextureId());
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h b/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h
deleted file mode 100644
index 821b79b..0000000
--- a/Source/WebCore/platform/graphics/android/DoubleBufferedTexture.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DoubleBufferedTexture_h
-#define DoubleBufferedTexture_h
-
-#include "SharedTexture.h"
-#include <EGL/egl.h>
-
-namespace WebCore {
-
-class DoubleBufferedTexture {
-public:
- // consumer thread functions
- DoubleBufferedTexture(EGLContext sharedContext, SharedTextureMode mode);
- virtual ~DoubleBufferedTexture();
-
- // provider thread functions
- virtual TextureInfo* producerLock();
- virtual void producerRelease();
- virtual void producerReleaseAndSwap();
- EGLContext producerAcquireContext();
- void producerDeleteTextures();
-
- // consumer thread functions
- TextureInfo* consumerLock();
- void consumerRelease();
- void consumerDeleteTextures();
-
-protected:
- SharedTexture* getReadableTexture();
- SharedTexture* getWriteableTexture();
-
- SharedTexture* m_textureA;
- SharedTexture* m_textureB;
-
- SharedTextureMode m_sharedTextureMode;
-private:
-
- SharedTexture* m_writeableTexture;
- SharedTexture* m_lockedConsumerTexture; // only used by the consumer
-
- EGLDisplay m_display;
- EGLContext m_pContext;
- EGLContext m_cContext;
-
- bool m_supportsEGLImage;
-};
-
-} // namespace WebCore
-
-#endif // DoubleBufferedTexture_h
diff --git a/Source/WebCore/platform/graphics/android/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/FontAndroid.cpp
index 0a8c0c1..ef7740c 100644
--- a/Source/WebCore/platform/graphics/android/FontAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/FontAndroid.cpp
@@ -52,6 +52,7 @@
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnArrayPtr.h>
#include <wtf/PassOwnPtr.h>
+#include <wtf/unicode/CharacterNames.h>
#include <wtf/unicode/Unicode.h>
#endif
@@ -379,7 +380,7 @@ static int truncateFixedPointToInteger(HB_Fixed value)
// can call |reset| to start over again.
class TextRunWalker {
public:
- TextRunWalker(const TextRun&, unsigned, const Font*);
+ TextRunWalker(const TextRun&, int, int, const Font*);
~TextRunWalker();
bool isWordBreak(unsigned, bool);
@@ -425,10 +426,10 @@ public:
// Return the length of the array returned by |glyphs|
unsigned length() const { return m_item.num_glyphs; }
- // Return the x offset for each of the glyphs. Note that this is translated
+ // Return the offset for each of the glyphs. Note that this is translated
// by the current x offset and that the x offset is updated for each script
// run.
- const SkScalar* xPositions() const { return m_xPositions; }
+ const SkPoint* positions() const { return m_positions; }
// Get the advances (widths) for each glyph.
const HB_Fixed* advances() const { return m_item.advances; }
@@ -472,7 +473,7 @@ private:
void createGlyphArrays(int);
void resetGlyphArrays();
void shapeGlyphs();
- void setGlyphXPositions(bool);
+ void setGlyphPositions(bool);
static void normalizeSpacesAndMirrorChars(const UChar* source, bool rtl,
UChar* destination, int length);
@@ -485,10 +486,11 @@ private:
const Font* const m_font;
HB_ShaperItem m_item;
uint16_t* m_glyphs16; // A vector of 16-bit glyph ids.
- SkScalar* m_xPositions; // A vector of x positions for each glyph.
+ SkPoint* m_positions; // A vector of positions for each glyph.
ssize_t m_indexOfNextScriptRun; // Indexes the script run in |m_run|.
- const unsigned m_startingX; // Offset in pixels of the first script run.
- unsigned m_offsetX; // Offset in pixels to the start of the next script run.
+ const int m_startingX; // Offset in pixels of the first script run.
+ const int m_startingY; // Offset in pixels of the first script run.
+ int m_offsetX; // Offset in pixels to the start of the next script run.
unsigned m_pixelWidth; // Width (in px) of the current script run.
unsigned m_numCodePoints; // Code points in current script run.
unsigned m_glyphsArrayCapacity; // Current size of all the Harfbuzz arrays.
@@ -519,9 +521,10 @@ const char* TextRunWalker::paths[] = {
"/system/fonts/DroidSansThai.ttf"
};
-TextRunWalker::TextRunWalker(const TextRun& run, unsigned startingX, const Font* font)
+TextRunWalker::TextRunWalker(const TextRun& run, int startingX, int startingY, const Font* font)
: m_font(font)
, m_startingX(startingX)
+ , m_startingY(startingY)
, m_offsetX(m_startingX)
, m_run(getNormalizedTextRun(run, m_normalizedRun, m_normalizedBuffer))
, m_iterateBackwards(m_run.rtl())
@@ -650,7 +653,7 @@ bool TextRunWalker::nextScriptRun()
setupFontForScriptRun();
shapeGlyphs();
- setGlyphXPositions(rtl());
+ setGlyphPositions(rtl());
return true;
}
@@ -737,6 +740,16 @@ void TextRunWalker::setupFontForScriptRun()
}
m_item.face = complexPlatformData->harfbuzzFace();
m_item.font->userData = const_cast<FontPlatformData*>(complexPlatformData);
+
+ int size = complexPlatformData->size();
+ m_item.font->x_ppem = size;
+ m_item.font->y_ppem = size;
+ // x_ and y_scale are the conversion factors from font design space (fEmSize) to 1/64th of device pixels in 16.16 format.
+ const int devicePixelFraction = 64;
+ const int multiplyFor16Dot16 = 1 << 16;
+ int scale = devicePixelFraction * size * multiplyFor16Dot16 / complexPlatformData->emSizeInFontUnits();
+ m_item.font->x_scale = scale;
+ m_item.font->y_scale = scale;
}
HB_FontRec* TextRunWalker::allocHarfbuzzFont()
@@ -745,13 +758,6 @@ HB_FontRec* TextRunWalker::allocHarfbuzzFont()
memset(font, 0, sizeof(HB_FontRec));
font->klass = &harfbuzzSkiaClass;
font->userData = 0;
- // The values which harfbuzzSkiaClass returns are already scaled to
- // pixel units, so we just set all these to one to disable further
- // scaling.
- font->x_ppem = 1;
- font->y_ppem = 1;
- font->x_scale = 1;
- font->y_scale = 1;
return font;
}
@@ -763,7 +769,7 @@ void TextRunWalker::deleteGlyphArrays()
delete[] m_item.advances;
delete[] m_item.offsets;
delete[] m_glyphs16;
- delete[] m_xPositions;
+ delete[] m_positions;
}
void TextRunWalker::createGlyphArrays(int size)
@@ -774,7 +780,7 @@ void TextRunWalker::createGlyphArrays(int size)
m_item.offsets = new HB_FixedPoint[size];
m_glyphs16 = new uint16_t[size];
- m_xPositions = new SkScalar[size];
+ m_positions = new SkPoint[size];
m_item.num_glyphs = size;
m_glyphsArrayCapacity = size; // Save the GlyphArrays size.
@@ -790,7 +796,7 @@ void TextRunWalker::resetGlyphArrays()
memset(m_item.advances, 0, size * sizeof(m_item.advances[0]));
memset(m_item.offsets, 0, size * sizeof(m_item.offsets[0]));
memset(m_glyphs16, 0, size * sizeof(m_glyphs16[0]));
- memset(m_xPositions, 0, size * sizeof(m_xPositions[0]));
+ memset(m_positions, 0, size * sizeof(m_positions[0]));
}
void TextRunWalker::shapeGlyphs()
@@ -810,7 +816,7 @@ void TextRunWalker::shapeGlyphs()
}
}
-void TextRunWalker::setGlyphXPositions(bool isRTL)
+void TextRunWalker::setGlyphPositions(bool isRTL)
{
int position = 0;
// logClustersIndex indexes logClusters for the first (or last when
@@ -825,7 +831,9 @@ void TextRunWalker::setGlyphXPositions(bool isRTL)
int i = isRTL ? m_item.num_glyphs - iter - 1 : iter;
m_glyphs16[i] = m_item.glyphs[i];
- m_xPositions[i] = SkIntToScalar(m_offsetX + position);
+ int offsetX = truncateFixedPointToInteger(m_item.offsets[i].x);
+ int offsetY = truncateFixedPointToInteger(m_item.offsets[i].y);
+ m_positions[i].set(SkIntToScalar(m_offsetX + position) + offsetX, m_startingY + offsetY);
int advance = truncateFixedPointToInteger(m_item.advances[i]);
// The first half of the conjunction works around the case where
@@ -846,6 +854,21 @@ void TextRunWalker::setGlyphXPositions(bool isRTL)
}
}
+ // ZeroWidthJoiners and ZeroWidthNonJoiners should be stripped by
+ // Harfbuzz, but aren't. Check for zwj and zwnj and replace with a
+ // zero width space. We get the glyph data for space instead of
+ // zeroWidthSpace because the latter was seen to render with an
+ // unexpected code point (the symbol for a cloud). Since the standard
+ // space is in page zero and since we've also confirmed that there is
+ // no advance on this glyph, that should be ok.
+ if (0 == m_item.advances[i]) {
+ const HB_UChar16 c = m_item.string[m_item.item.pos + logClustersIndex];
+ if ((c == zeroWidthJoiner) || (c == zeroWidthNonJoiner)) {
+ static Glyph spaceGlyph = m_font->glyphDataForCharacter(space, false).glyph;
+ m_glyphs16[i] = spaceGlyph;
+ }
+ }
+
// TODO We would like to add m_letterSpacing after each cluster, but I
// don't know where the cluster information is. This is typically
// fine for Roman languages, but breaks more complex languages
@@ -878,10 +901,14 @@ void TextRunWalker::normalizeSpacesAndMirrorChars(const UChar* source, bool rtl,
UChar32 character;
int nextPosition = position;
U16_NEXT(source, nextPosition, length, character);
+
if (Font::treatAsSpace(character))
- character = ' ';
+ character = space;
+ else if (Font::treatAsZeroWidthSpaceInComplexScript(character))
+ character = zeroWidthSpace;
else if (rtl)
character = u_charMirror(character);
+
U16_APPEND(destination, position, length, character, error);
ASSERT(!error);
position = nextPosition;
@@ -947,7 +974,7 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run,
{
int fromX = -1, toX = -1, fromAdvance = -1, toAdvance = -1;
- TextRunWalker walker(run, 0, this);
+ TextRunWalker walker(run, 0, 0, this);
walker.setWordAndLetterSpacing(wordSpacing(), letterSpacing());
// Base will point to the x offset for the current script run. Note that, in
@@ -974,14 +1001,14 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run,
// find which glyph this code-point contributed to and find its x
// position.
int glyph = walker.logClusters()[from];
- fromX = base + walker.xPositions()[glyph];
+ fromX = base + walker.positions()[glyph].x();
fromAdvance = walker.advances()[glyph];
} else
from -= numCodePoints;
if (toX == -1 && to < numCodePoints) {
int glyph = walker.logClusters()[to];
- toX = base + walker.xPositions()[glyph];
+ toX = base + walker.positions()[glyph].x();
toAdvance = walker.advances()[glyph];
} else
to -= numCodePoints;
@@ -1028,7 +1055,7 @@ void Font::drawComplexText(GraphicsContext* gc, TextRun const& run,
SkCanvas* canvas = gc->platformContext()->mCanvas;
bool haveMultipleLayers = isCanvasMultiLayered(canvas);
- TextRunWalker walker(run, point.x(), this);
+ TextRunWalker walker(run, point.x(), point.y(), this);
walker.setWordAndLetterSpacing(wordSpacing(), letterSpacing());
walker.setPadding(run.expansion());
@@ -1036,14 +1063,14 @@ void Font::drawComplexText(GraphicsContext* gc, TextRun const& run,
if (fill) {
walker.fontPlatformDataForScriptRun()->setupPaint(&fillPaint);
adjustTextRenderMode(&fillPaint, haveMultipleLayers);
- canvas->drawPosTextH(walker.glyphs(), walker.length() << 1,
- walker.xPositions(), point.y(), fillPaint);
+ canvas->drawPosText(walker.glyphs(), walker.length() << 1,
+ walker.positions(), fillPaint);
}
if (stroke) {
walker.fontPlatformDataForScriptRun()->setupPaint(&strokePaint);
adjustTextRenderMode(&strokePaint, haveMultipleLayers);
- canvas->drawPosTextH(walker.glyphs(), walker.length() << 1,
- walker.xPositions(), point.y(), strokePaint);
+ canvas->drawPosText(walker.glyphs(), walker.length() << 1,
+ walker.positions(), strokePaint);
}
}
}
@@ -1051,7 +1078,7 @@ void Font::drawComplexText(GraphicsContext* gc, TextRun const& run,
float Font::floatWidthForComplexText(const TextRun& run,
HashSet<const SimpleFontData*>*, GlyphOverflow*) const
{
- TextRunWalker walker(run, 0, this);
+ TextRunWalker walker(run, 0, 0, this);
walker.setWordAndLetterSpacing(wordSpacing(), letterSpacing());
return walker.widthOfFullRun();
}
@@ -1083,7 +1110,7 @@ int Font::offsetForPositionForComplexText(const TextRun& run, float x,
{
// (Mac code ignores includePartialGlyphs, and they don't know what it's
// supposed to do, so we just ignore it as well.)
- TextRunWalker walker(run, 0, this);
+ TextRunWalker walker(run, 0, 0, this);
walker.setWordAndLetterSpacing(wordSpacing(), letterSpacing());
// If this is RTL text, the first glyph from the left is actually the last
diff --git a/Source/WebCore/platform/graphics/android/FontPlatformData.h b/Source/WebCore/platform/graphics/android/FontPlatformData.h
index 5c3313e..1e46971 100644
--- a/Source/WebCore/platform/graphics/android/FontPlatformData.h
+++ b/Source/WebCore/platform/graphics/android/FontPlatformData.h
@@ -82,6 +82,7 @@ public:
float size() const { return mTextSize; }
unsigned hash() const;
+ int emSizeInFontUnits() const;
bool isFixedPitch() const;
#ifndef NDEBUG
@@ -113,6 +114,7 @@ private:
SkTypeface* mTypeface;
float mTextSize;
+ mutable int mEmSizeInFontUnits;
bool mFakeBold;
bool mFakeItalic;
FontOrientation mOrientation;
diff --git a/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp b/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp
index 3c90246..fc254c0 100644
--- a/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp
@@ -33,6 +33,7 @@
#ifdef SUPPORT_COMPLEX_SCRIPTS
#include "HarfbuzzSkia.h"
#endif
+#include "SkAdvancedTypefaceMetrics.h"
#include "SkPaint.h"
#include "SkTypeface.h"
@@ -74,7 +75,7 @@ FontPlatformData::RefCountedHarfbuzzFace::~RefCountedHarfbuzzFace()
}
FontPlatformData::FontPlatformData()
- : mTypeface(NULL), mTextSize(0), mFakeBold(false), mFakeItalic(false),
+ : mTypeface(NULL), mTextSize(0), mEmSizeInFontUnits(0), mFakeBold(false), mFakeItalic(false),
mOrientation(Horizontal), mTextOrientation(TextOrientationVerticalRight)
{
inc_count();
@@ -87,10 +88,10 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src)
SkSafeRef(src.mTypeface);
}
- mTypeface = src.mTypeface;
-
- mTextSize = src.mTextSize;
- mFakeBold = src.mFakeBold;
+ mTypeface = src.mTypeface;
+ mTextSize = src.mTextSize;
+ mEmSizeInFontUnits = src.mEmSizeInFontUnits;
+ mFakeBold = src.mFakeBold;
mFakeItalic = src.mFakeItalic;
m_harfbuzzFace = src.m_harfbuzzFace;
mOrientation = src.mOrientation;
@@ -102,7 +103,7 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src)
FontPlatformData::FontPlatformData(SkTypeface* tf, float textSize, bool fakeBold, bool fakeItalic,
FontOrientation orientation, TextOrientation textOrientation)
- : mTypeface(tf), mTextSize(textSize), mFakeBold(fakeBold), mFakeItalic(fakeItalic),
+ : mTypeface(tf), mTextSize(textSize), mEmSizeInFontUnits(0), mFakeBold(fakeBold), mFakeItalic(fakeItalic),
mOrientation(orientation), mTextOrientation(textOrientation)
{
if (hashTableDeletedFontValue() != mTypeface) {
@@ -114,8 +115,8 @@ FontPlatformData::FontPlatformData(SkTypeface* tf, float textSize, bool fakeBold
}
FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
- : mTypeface(src.mTypeface), mTextSize(textSize), mFakeBold(src.mFakeBold), mFakeItalic(src.mFakeItalic),
- m_harfbuzzFace(src.m_harfbuzzFace), mOrientation(src.mOrientation), mTextOrientation(src.mTextOrientation)
+ : mTypeface(src.mTypeface), mTextSize(textSize), mEmSizeInFontUnits(src.mEmSizeInFontUnits), mFakeBold(src.mFakeBold), mFakeItalic(src.mFakeItalic),
+ mOrientation(src.mOrientation), mTextOrientation(src.mTextOrientation), m_harfbuzzFace(src.m_harfbuzzFace)
{
if (hashTableDeletedFontValue() != mTypeface) {
SkSafeRef(mTypeface);
@@ -126,7 +127,7 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
}
FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
- : mTypeface(NULL), mTextSize(size), mFakeBold(bold), mFakeItalic(oblique),
+ : mTypeface(NULL), mTextSize(size), mEmSizeInFontUnits(0), mFakeBold(bold), mFakeItalic(oblique),
mOrientation(Horizontal), mTextOrientation(TextOrientationVerticalRight)
{
inc_count();
@@ -134,7 +135,7 @@ FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
}
FontPlatformData::FontPlatformData(const FontPlatformData& src, SkTypeface* tf)
- : mTypeface(tf), mTextSize(src.mTextSize), mFakeBold(src.mFakeBold),
+ : mTypeface(tf), mTextSize(src.mTextSize), mEmSizeInFontUnits(0), mFakeBold(src.mFakeBold),
mFakeItalic(src.mFakeItalic), mOrientation(src.mOrientation),
mTextOrientation(src.mTextOrientation)
{
@@ -158,6 +159,22 @@ FontPlatformData::~FontPlatformData()
}
}
+int FontPlatformData::emSizeInFontUnits() const
+{
+ if (mEmSizeInFontUnits)
+ return mEmSizeInFontUnits;
+
+ SkAdvancedTypefaceMetrics* metrics = 0;
+ if (mTypeface)
+ metrics = mTypeface->getAdvancedTypefaceMetrics(SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo);
+ if (metrics) {
+ mEmSizeInFontUnits = metrics->fEmSize;
+ metrics->unref();
+ } else
+ mEmSizeInFontUnits = 1000; // default value copied from Skia.
+ return mEmSizeInFontUnits;
+}
+
FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
{
if (hashTableDeletedFontValue() != src.mTypeface) {
@@ -167,9 +184,10 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
SkSafeUnref(mTypeface);
}
- mTypeface = src.mTypeface;
- mTextSize = src.mTextSize;
- mFakeBold = src.mFakeBold;
+ mTypeface = src.mTypeface;
+ mEmSizeInFontUnits = src.mEmSizeInFontUnits;
+ mTextSize = src.mTextSize;
+ mFakeBold = src.mFakeBold;
mFakeItalic = src.mFakeItalic;
m_harfbuzzFace = src.m_harfbuzzFace;
mOrientation = src.mOrientation;
@@ -180,10 +198,6 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
void FontPlatformData::setupPaint(SkPaint* paint) const
{
- float ts = mTextSize;
- if (!(ts > 0))
- ts = 12;
-
if (hashTableDeletedFontValue() == mTypeface)
paint->setTypeface(0);
else
@@ -192,7 +206,7 @@ void FontPlatformData::setupPaint(SkPaint* paint) const
paint->setAntiAlias(true);
paint->setSubpixelText(true);
paint->setHinting(SkPaint::kSlight_Hinting);
- paint->setTextSize(SkFloatToScalar(ts));
+ paint->setTextSize(SkFloatToScalar(mTextSize));
paint->setFakeBoldText(mFakeBold);
paint->setTextSkewX(mFakeItalic ? -SK_Scalar1/4 : 0);
#ifndef SUPPORT_COMPLEX_SCRIPTS
diff --git a/Source/WebCore/platform/graphics/android/GLExtras.cpp b/Source/WebCore/platform/graphics/android/GLExtras.cpp
index 873ea33..b872951 100644
--- a/Source/WebCore/platform/graphics/android/GLExtras.cpp
+++ b/Source/WebCore/platform/graphics/android/GLExtras.cpp
@@ -52,10 +52,6 @@
// Touch ring border width. This is doubled if the ring is not pressed
#define RING_BORDER_WIDTH 1
-// Color of the ring is 0x6633b5e5 (copied from framework's holo_light)
-#define COLOR_HOLO_LIGHT &m_lightRingTexture, 0x33, 0xb5, 0xe5, 0.4f
-// Color of the ring is 0x660099cc (copied from framework's holo_dark)
-#define COLOR_HOLO_DARK &m_darkRingTexture, 0x00, 0x99, 0xcc, 0.6f
// Put a cap on the number of matches to draw. If the current page has more
// matches than this, only draw the focused match. This both prevents clutter
// on the page and keeps the performance happy
@@ -65,8 +61,7 @@ GLExtras::GLExtras()
: m_findOnPage(0)
, m_ring(0)
, m_drawExtra(0)
- , m_lightRingTexture(-1)
- , m_darkRingTexture(-1)
+ , m_viewport()
{
}
@@ -74,22 +69,28 @@ GLExtras::~GLExtras()
{
}
-void GLExtras::drawRing(SkRect& srcRect, int* texture, int r, int g, int b, float a)
+void GLExtras::drawRing(SkRect& srcRect, Color color, const TransformationMatrix* drawMat)
{
- if (*texture == -1)
- *texture = GLUtils::createSampleColorTexture(r, g, b);
-
if (srcRect.fRight <= srcRect.fLeft || srcRect.fBottom <= srcRect.fTop) {
// Invalid rect, reject it
return;
}
XLOG("drawQuad [%fx%f, %f, %f]", srcRect.fLeft, srcRect.fTop,
srcRect.width(), srcRect.height());
- TilesManager::instance()->shader()->drawQuad(srcRect, *texture, a);
+ // Pull the alpha out of the color so that the shader applies it correctly.
+ // Otherwise we either don't have blending enabled, or the alpha will get
+ // double applied
+ Color colorWithoutAlpha(0xFF000000 | color.rgb());
+ float alpha = color.alpha() / (float) 255;
+ if (drawMat) {
+ TilesManager::instance()->shader()->drawLayerQuad(*drawMat, srcRect, 0,
+ alpha, false, 0, colorWithoutAlpha);
+ } else
+ TilesManager::instance()->shader()->drawQuad(srcRect, 0, alpha, colorWithoutAlpha);
}
-void GLExtras::drawRegion(const SkRegion& region, bool fill,
- bool drawBorder, bool useDark)
+void GLExtras::drawRegion(const SkRegion& region, bool fill, bool drawBorder,
+ const TransformationMatrix* drawMat, Color color)
{
if (region.isEmpty())
return;
@@ -99,10 +100,7 @@ void GLExtras::drawRegion(const SkRegion& region, bool fill,
const SkIRect& ir = rgnIter.rect();
SkRect r;
r.set(ir.fLeft, ir.fTop, ir.fRight, ir.fBottom);
- if (useDark)
- drawRing(r, COLOR_HOLO_DARK);
- else
- drawRing(r, COLOR_HOLO_LIGHT);
+ drawRing(r, color, drawMat);
rgnIter.next();
}
}
@@ -143,10 +141,7 @@ void GLExtras::drawRegion(const SkRegion& region, bool fill,
clip.setRect(line);
}
r.set(line.fLeft, line.fTop, line.fRight, line.fBottom);
- if (useDark)
- drawRing(r, COLOR_HOLO_DARK);
- else
- drawRing(r, COLOR_HOLO_LIGHT);
+ drawRing(r, color, drawMat);
if (startRect.isEmpty()) {
startRect.set(line.fLeft, line.fTop, line.fRight, line.fBottom);
}
@@ -157,8 +152,12 @@ void GLExtras::drawRegion(const SkRegion& region, bool fill,
}
}
-void GLExtras::drawCursorRings()
+void GLExtras::drawCursorRings(const LayerAndroid* layer)
{
+ int layerId = layer ? layer->uniqueId() : -1;
+ if (layerId != m_ring->layerId())
+ return;
+
SkRegion region;
for (size_t i = 0; i < m_ring->rings().size(); i++) {
IntRect rect = m_ring->rings().at(i);
@@ -167,26 +166,41 @@ void GLExtras::drawCursorRings()
else
region.op(rect, SkRegion::kUnion_Op);
}
- drawRegion(region, m_ring->m_isPressed, !m_ring->m_isButton, false);
+ drawRegion(region, m_ring->m_isPressed, !m_ring->m_isButton,
+ layer ? layer->drawTransform() : 0);
}
-void GLExtras::drawFindOnPage(SkRect& viewport)
+void GLExtras::drawFindOnPage(const LayerAndroid* layer)
{
WTF::Vector<MatchInfo>* matches = m_findOnPage->matches();
XLOG("drawFindOnPage, matches: %p", matches);
if (!matches || !m_findOnPage->isCurrentLocationValid())
return;
+ std::pair<unsigned, unsigned> matchRange =
+ m_findOnPage->getLayerMatchRange(layer ? layer->uniqueId() : -1);
+ if (matchRange.first >= matchRange.second)
+ return;
+
int count = matches->size();
- int current = m_findOnPage->currentMatchIndex();
+ unsigned current = m_findOnPage->currentMatchIndex();
XLOG("match count: %d", count);
+ const TransformationMatrix* drawTransform =
+ layer ? layer->drawTransform() : 0;
if (count < MAX_NUMBER_OF_MATCHES_TO_DRAW)
- for (int i = 0; i < count; i++) {
+ for (unsigned i = matchRange.first; i < matchRange.second; i++) {
MatchInfo& info = matches->at(i);
const SkRegion& region = info.getLocation();
SkIRect rect = region.getBounds();
- if (rect.intersect(viewport.fLeft, viewport.fTop,
- viewport.fRight, viewport.fBottom))
- drawRegion(region, i == current, false, true);
+ if (drawTransform) {
+ IntRect intRect(rect.fLeft, rect.fTop, rect.width(),
+ rect.height());
+ IntRect transformedRect = drawTransform->mapRect(intRect);
+ rect.setXYWH(transformedRect.x(), transformedRect.y(),
+ transformedRect.width(), transformedRect.height());
+ }
+ if (rect.intersect(m_viewport.fLeft, m_viewport.fTop,
+ m_viewport.fRight, m_viewport.fBottom))
+ drawRegion(region, i == current, false, drawTransform, COLOR_HOLO_DARK);
#ifdef DEBUG
else
XLOG("Quick rejecting [%dx%d, %d, %d", rect.fLeft, rect.fTop,
@@ -194,20 +208,21 @@ void GLExtras::drawFindOnPage(SkRect& viewport)
#endif // DEBUG
}
else {
- MatchInfo& info = matches->at(current);
- drawRegion(info.getLocation(), true, false, true);
+ if (matchRange.first <= current && current < matchRange.second) {
+ MatchInfo& info = matches->at(current);
+ drawRegion(info.getLocation(), true, false, drawTransform, COLOR_HOLO_DARK);
+ }
}
}
-void GLExtras::drawGL(IntRect& webViewRect, SkRect& viewport, int titleBarHeight)
+void GLExtras::drawGL(const LayerAndroid* layer)
{
if (m_drawExtra) {
if (m_drawExtra == m_ring)
- drawCursorRings();
+ drawCursorRings(layer);
else if (m_drawExtra == m_findOnPage)
- drawFindOnPage(viewport);
+ drawFindOnPage(layer);
else
- XLOGC("m_drawExtra %p is unknown! (cursor: %p, find: %p",
- m_drawExtra, m_ring, m_findOnPage);
+ m_drawExtra->drawGL(this, layer);
}
}
diff --git a/Source/WebCore/platform/graphics/android/GLExtras.h b/Source/WebCore/platform/graphics/android/GLExtras.h
index c52e951..51ad8d8 100644
--- a/Source/WebCore/platform/graphics/android/GLExtras.h
+++ b/Source/WebCore/platform/graphics/android/GLExtras.h
@@ -26,41 +26,46 @@
#ifndef GLExtras_h
#define GLExtras_h
+#include "Color.h"
+#include "DrawExtra.h"
#include "SkRect.h"
#include "SkRegion.h"
namespace android {
class FindOnPage;
class CursorRing;
- class DrawExtra;
}
namespace WebCore {
+class LayerAndroid;
+class TransformationMatrix;
+
class GLExtras {
public:
GLExtras();
virtual ~GLExtras();
- void drawGL(IntRect& webViewRect, SkRect& viewport, int titleBarHeight);
+ void drawGL(const LayerAndroid* layer);
void setFindOnPageExtra(android::FindOnPage* findOnPage) {
m_findOnPage = findOnPage;
}
void setCursorRingExtra(android::CursorRing* ring) { m_ring = ring; }
void setDrawExtra(android::DrawExtra* extra) { m_drawExtra = extra; }
+ void setViewport(const SkRect & viewport) { m_viewport = viewport; }
-private:
- void drawRing(SkRect& srcRect, int* texture, int r, int g, int b, float a);
void drawRegion(const SkRegion& region, bool fill, bool drawBorder,
- bool useDark = false);
- void drawCursorRings();
- void drawFindOnPage(SkRect& viewport);
+ const TransformationMatrix* drawMat, Color color = COLOR_HOLO_LIGHT);
+
+private:
+ void drawRing(SkRect& srcRect, Color color, const TransformationMatrix* drawMat);
+ void drawCursorRings(const LayerAndroid* layer);
+ void drawFindOnPage(const LayerAndroid* layer);
android::FindOnPage* m_findOnPage;
android::CursorRing* m_ring;
android::DrawExtra* m_drawExtra;
- int m_lightRingTexture;
- int m_darkRingTexture;
+ SkRect m_viewport;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.cpp b/Source/WebCore/platform/graphics/android/GLUtils.cpp
index 97a53fe..39d8755 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.cpp
+++ b/Source/WebCore/platform/graphics/android/GLUtils.cpp
@@ -36,12 +36,14 @@
#include <wtf/CurrentTime.h>
#include <wtf/text/CString.h>
-
-#ifdef DEBUG
-
#include <cutils/log.h>
#include <wtf/text/CString.h>
+#undef XLOGC
+#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "GLUtils", __VA_ARGS__)
+
+#ifdef DEBUG
+
#undef XLOG
#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "GLUtils", __VA_ARGS__)
@@ -237,7 +239,7 @@ static EGLConfig defaultPbufferConfig(EGLDisplay display)
eglChooseConfig(display, configAttribs, &config, 1, &numConfigs);
GLUtils::checkEglError("eglPbufferConfig");
if (numConfigs != 1)
- LOGI("eglPbufferConfig failed (%d)\n", numConfigs);
+ ALOGI("eglPbufferConfig failed (%d)\n", numConfigs);
return config;
}
@@ -370,126 +372,120 @@ GLuint GLUtils::createBaseTileGLTexture(int width, int height)
GLUtils::checkGlError("glTexImage2D");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+#ifdef DEBUG
+ delete pixels;
+#endif
return texture;
}
+bool GLUtils::isPureColorBitmap(const SkBitmap& bitmap, Color& pureColor)
+{
+ // If the bitmap is the pure color, skip the transfer step, and update the BaseTile Info.
+ // This check is taking < 1ms if we do full bitmap check per tile.
+ // TODO: use the SkPicture to determine whether or not a tile is single color.
+ pureColor = Color(Color::transparent);
+ bitmap.lockPixels();
+ bool sameColor = true;
+ int bitmapWidth = bitmap.width();
+
+ // Create a row of pure color using the first pixel.
+ // TODO: improve the perf here, by either picking a random pixel, or
+ // creating an array of rows with pre-defined commonly used color, add
+ // smart LUT to speed things up if possible.
+ int* firstPixelPtr = static_cast<int*> (bitmap.getPixels());
+ int* pixelsRow = new int[bitmapWidth];
+ for (int i = 0; i < bitmapWidth; i++)
+ pixelsRow[i] = (*firstPixelPtr);
+
+ // Then compare the pure color row with each row of the bitmap.
+ for (int j = 0; j < bitmap.height(); j++) {
+ if (memcmp(pixelsRow, &firstPixelPtr[bitmapWidth * j], 4 * bitmapWidth)) {
+ sameColor = false;
+ break;
+ }
+ }
+ delete pixelsRow;
+ pixelsRow = 0;
+
+ if (sameColor) {
+ char* rgbaPtr = static_cast<char*>(bitmap.getPixels());
+ pureColor = Color(rgbaPtr[0], rgbaPtr[1], rgbaPtr[2], rgbaPtr[3]);
+ XLOG("sameColor tile found , %x at (%d, %d, %d, %d)",
+ *firstPixelPtr, rgbaPtr[0], rgbaPtr[1], rgbaPtr[2], rgbaPtr[3]);
+ }
+ bitmap.unlockPixels();
+
+ return sameColor;
+}
+
+// Return true when the tile is pure color.
+bool GLUtils::skipTransferForPureColor(const TileRenderInfo* renderInfo,
+ const SkBitmap& bitmap)
+{
+ bool skipTransfer = false;
+ BaseTile* tilePtr = renderInfo->baseTile;
+
+ // TODO: use pure color for partial invals as well
+ if (renderInfo->invalRect)
+ return false;
+
+ if (tilePtr) {
+ BaseTileTexture* tileTexture = tilePtr->backTexture();
+ // Check the bitmap, and make everything ready here.
+ Color pureColor;
+ if (tileTexture && isPureColorBitmap(bitmap, pureColor)) {
+ // update basetile's info
+ // Note that we are skipping the whole TransferQueue.
+ renderInfo->textureInfo->m_width = bitmap.width();
+ renderInfo->textureInfo->m_height = bitmap.height();
+ renderInfo->textureInfo->m_internalFormat = GL_RGBA;
+
+ TilesManager::instance()->transferQueue()->addItemInPureColorQueue(renderInfo,
+ pureColor);
+
+ skipTransfer = true;
+ }
+ }
+ return skipTransfer;
+}
+
void GLUtils::paintTextureWithBitmap(const TileRenderInfo* renderInfo,
const SkBitmap& bitmap)
{
if (!renderInfo)
return;
- const int x = renderInfo->invalRect->fLeft;
- const int y = renderInfo->invalRect->fTop;
const SkSize& requiredSize = renderInfo->tileSize;
TextureInfo* textureInfo = renderInfo->textureInfo;
- SharedTextureMode mode = textureInfo->getSharedTextureMode();
- if (requiredSize.equals(textureInfo->m_width, textureInfo->m_height)) {
- if (mode == EglImageMode)
- GLUtils::updateTextureWithBitmap(textureInfo->m_textureId, x, y, bitmap);
- else if (mode == SurfaceTextureMode)
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- GLUtils::updateSurfaceTextureWithBitmap(renderInfo, x, y, bitmap);
-#else
- GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, x, y, bitmap);
-#endif
- } else {
+ if (skipTransferForPureColor(renderInfo, bitmap))
+ return;
+
+ if (requiredSize.equals(textureInfo->m_width, textureInfo->m_height))
+ GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, bitmap);
+ else {
if (!requiredSize.equals(bitmap.width(), bitmap.height())) {
XLOG("The bitmap size (%d,%d) does not equal the texture size (%d,%d)",
bitmap.width(), bitmap.height(),
requiredSize.width(), requiredSize.height());
}
+ GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, bitmap);
- if (mode == EglImageMode)
- GLUtils::createTextureWithBitmap(textureInfo->m_textureId, bitmap);
- else if (mode == SurfaceTextureMode)
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- GLUtils::createSurfaceTextureWithBitmap(renderInfo, bitmap);
-#else
- GLUtils::updateSharedSurfaceTextureWithBitmap(renderInfo, 0, 0, bitmap);
-#endif
textureInfo->m_width = bitmap.width();
textureInfo->m_height = bitmap.height();
textureInfo->m_internalFormat = GL_RGBA;
}
}
-#if DEPRECATED_SURFACE_TEXTURE_MODE
-void GLUtils::createSurfaceTextureWithBitmap(const TileRenderInfo* renderInfo, const SkBitmap& bitmap, GLint filter)
-{
-
- TextureInfo* texture = renderInfo->textureInfo;
-
- texture->m_width = bitmap.width();
- texture->m_height = bitmap.height();
- texture->m_internalFormat = GL_RGBA;
-
- sp<android::SurfaceTexture> surfaceTexture = texture->m_surfaceTexture;
- sp<ANativeWindow> ANW = texture->m_ANW;
-
- int result;
- result = native_window_set_buffers_geometry(ANW.get(),
- texture->m_width, texture->m_height, HAL_PIXEL_FORMAT_RGBA_8888);
- checkSurfaceTextureError("native_window_set_buffers_geometry", result);
- result = native_window_set_usage(ANW.get(),
- GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
- checkSurfaceTextureError("native_window_set_usage", result);
-
- updateSurfaceTextureWithBitmap(renderInfo, 0, 0, bitmap, filter);
-}
-
-void GLUtils::updateSurfaceTextureWithBitmap(const TileRenderInfo* renderInfo, int x, int y, const SkBitmap& bitmap, GLint filter)
-{
- TextureInfo* texture = renderInfo->textureInfo;
- sp<android::SurfaceTexture> surfaceTexture = texture->m_surfaceTexture;
- sp<ANativeWindow> ANW = texture->m_ANW;
-
- ANativeWindowBuffer* anb;
- int status = ANW->dequeueBuffer(ANW.get(), &anb);
- checkSurfaceTextureError("dequeueBuffer", status);
-
- if (status != NO_ERROR) { // FIXME: add proper error handling!
- native_window_set_buffer_count(ANW.get(), 3);
- return;
- }
-
- sp<android::GraphicBuffer> buf(new android::GraphicBuffer(anb, false));
- status |= ANW->lockBuffer(ANW.get(), buf->getNativeBuffer());
- checkSurfaceTextureError("lockBuffer", status);
-
- // Fill the buffer with the content of the bitmap
- uint8_t* img = 0;
- status |= buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
- checkSurfaceTextureError("lock", status);
-
- if (status == NO_ERROR) {
- int row, col;
- int bpp = 4; // Now only deal with RGBA8888 format.
-
- bitmap.lockPixels();
- uint8_t* bitmapOrigin = static_cast<uint8_t*>(bitmap.getPixels());
- // Copied line by line since we need to handle the offsets and stride.
- for (row = 0 ; row < bitmap.height(); row ++) {
- uint8_t* dst = &(img[(buf->getStride() * (row + x) + y) * bpp]);
- uint8_t* src = &(bitmapOrigin[bitmap.width() * row * bpp]);
- memcpy(dst, src, bpp * bitmap.width());
- }
- bitmap.unlockPixels();
- }
- buf->unlock();
- status = ANW->queueBuffer(ANW.get(), buf->getNativeBuffer());
- checkSurfaceTextureError("queueBuffer", status);
-}
-#endif
-
-void GLUtils::updateSharedSurfaceTextureWithBitmap(const TileRenderInfo* renderInfo, int x, int y, const SkBitmap& bitmap)
+void GLUtils::updateSharedSurfaceTextureWithBitmap(const TileRenderInfo* renderInfo, const SkBitmap& bitmap)
{
if (!renderInfo
|| !renderInfo->textureInfo
|| !renderInfo->baseTile)
return;
- TilesManager::instance()->transferQueue()->updateQueueWithBitmap(renderInfo, x, y, bitmap);
+ TilesManager::instance()->transferQueue()->updateQueueWithBitmap(renderInfo, bitmap);
}
void GLUtils::createTextureWithBitmap(GLuint texture, const SkBitmap& bitmap, GLint filter)
@@ -523,7 +519,8 @@ void GLUtils::createTextureWithBitmap(GLuint texture, const SkBitmap& bitmap, GL
glDeleteFramebuffers(1, &fboID);
}
-void GLUtils::updateTextureWithBitmap(GLuint texture, int x, int y, const SkBitmap& bitmap, GLint filter)
+void GLUtils::updateTextureWithBitmap(GLuint texture, const SkBitmap& bitmap,
+ const IntRect& inval, GLint filter)
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, texture);
@@ -532,13 +529,18 @@ void GLUtils::updateTextureWithBitmap(GLuint texture, int x, int y, const SkBitm
int internalformat = getInternalFormat(config);
int type = getType(config);
bitmap.lockPixels();
- glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, bitmap.width(), bitmap.height(),
- internalformat, type, bitmap.getPixels());
+ if (inval.isEmpty()) {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bitmap.width(), bitmap.height(),
+ internalformat, type, bitmap.getPixels());
+ } else {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, inval.x(), inval.y(), inval.width(), inval.height(),
+ internalformat, type, bitmap.getPixels());
+ }
bitmap.unlockPixels();
if (GLUtils::checkGlError("glTexSubImage2D")) {
XLOG("GL ERROR: glTexSubImage2D parameters are : bitmap.width() %d, bitmap.height() %d,"
- " x %d, y %d, internalformat 0x%x, type 0x%x, bitmap.getPixels() %p",
- bitmap.width(), bitmap.height(), x, y, internalformat, type, bitmap.getPixels());
+ " internalformat 0x%x, type 0x%x, bitmap.getPixels() %p",
+ bitmap.width(), bitmap.height(), internalformat, type, bitmap.getPixels());
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
diff --git a/Source/WebCore/platform/graphics/android/GLUtils.h b/Source/WebCore/platform/graphics/android/GLUtils.h
index 68acbab..b198d35 100644
--- a/Source/WebCore/platform/graphics/android/GLUtils.h
+++ b/Source/WebCore/platform/graphics/android/GLUtils.h
@@ -28,6 +28,7 @@
#if USE(ACCELERATED_COMPOSITING)
+#include "Color.h"
#include "SkBitmap.h"
#include "SkMatrix.h"
#include "SkSize.h"
@@ -73,17 +74,17 @@ public:
static GLuint createBaseTileGLTexture(int width, int height);
static void createTextureWithBitmap(GLuint texture, const SkBitmap& bitmap, GLint filter = GL_LINEAR);
- static void updateTextureWithBitmap(GLuint texture, int x, int y, const SkBitmap& bitmap, GLint filter = GL_LINEAR);
+ static void updateTextureWithBitmap(GLuint texture, const SkBitmap& bitmap, const IntRect&, GLint filter = GL_LINEAR);
static void createEGLImageFromTexture(GLuint texture, EGLImageKHR* image);
static void createTextureFromEGLImage(GLuint texture, EGLImageKHR image, GLint filter = GL_LINEAR);
static void paintTextureWithBitmap(const TileRenderInfo* renderInfo, const SkBitmap& bitmap);
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- static void createSurfaceTextureWithBitmap(const TileRenderInfo* , const SkBitmap& bitmap, GLint filter = GL_LINEAR);
- static void updateSurfaceTextureWithBitmap(const TileRenderInfo* , int x, int y, const SkBitmap& bitmap, GLint filter = GL_LINEAR);
-#endif
- static void updateSharedSurfaceTextureWithBitmap(const TileRenderInfo* , int x, int y, const SkBitmap& bitmap);
+ static void updateSharedSurfaceTextureWithBitmap(const TileRenderInfo* , const SkBitmap& bitmap);
static void convertToTransformationMatrix(const float* matrix, TransformationMatrix& transformMatrix);
+
+ static bool isPureColorBitmap(const SkBitmap& bitmap, Color& pureColor);
+ static bool skipTransferForPureColor(const TileRenderInfo* renderInfo,
+ const SkBitmap& bitmap);
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index 3bcda9a..c96f5ea 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -69,6 +69,13 @@
#define MIN_SCALE_WARNING 0.1
#define MAX_SCALE_WARNING 10
+// fps indicator is FPS_INDICATOR_HEIGHT pixels high.
+// The max width is equal to MAX_FPS_VALUE fps.
+#define FPS_INDICATOR_HEIGHT 10
+#define MAX_FPS_VALUE 60
+
+#define TREE_SWAPPED_COUNTER_MODULE 10
+
namespace WebCore {
using namespace android;
@@ -80,13 +87,14 @@ GLWebViewState::GLWebViewState()
, m_frameworkInval(0, 0, 0, 0)
, m_frameworkLayersInval(0, 0, 0, 0)
, m_isScrolling(false)
+ , m_isViewportScrolling(false)
, m_goingDown(true)
, m_goingLeft(false)
, m_expandedTileBoundsX(0)
, m_expandedTileBoundsY(0)
- , m_highEndGfx(false)
, m_scale(1)
, m_layersRenderingMode(kAllTextures)
+ , m_treeManager(this)
{
m_viewport.setEmpty();
m_futureViewportTileBounds.setEmpty();
@@ -108,9 +116,6 @@ GLWebViewState::GLWebViewState()
GLWebViewState::~GLWebViewState()
{
- // Take care of the transfer queue such that Tex Gen thread will not stuck
- TilesManager::instance()->unregisterGLWebViewState(this);
-
// We have to destroy the two tiled pages first as their destructor
// may depend on the existence of this GLWebViewState and some of its
// instance variables in order to complete.
@@ -125,8 +130,8 @@ GLWebViewState::~GLWebViewState()
}
-void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval,
- bool showVisualIndicator, bool isPictureAfterFirstLayout)
+bool GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, bool showVisualIndicator,
+ bool isPictureAfterFirstLayout)
{
if (!layer || isPictureAfterFirstLayout) {
// TODO: move this into TreeManager
@@ -138,9 +143,8 @@ void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval
if (layer) {
XLOG("new base layer %p, (inval region empty %d) with child %p", layer, inval.isEmpty(), layer->getChild(0));
layer->setState(this);
- layer->markAsDirty(inval); // TODO: set in webview.cpp
}
- m_treeManager.updateWithTree(layer, isPictureAfterFirstLayout);
+ bool queueFull = m_treeManager.updateWithTree(layer, isPictureAfterFirstLayout);
m_glExtras.setDrawExtra(0);
#ifdef MEASURES_PERF
@@ -150,6 +154,7 @@ void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval
#endif
TilesManager::instance()->setShowVisualIndicator(showVisualIndicator);
+ return queueFull;
}
void GLWebViewState::scrollLayer(int layerId, int x, int y)
@@ -240,12 +245,33 @@ int GLWebViewState::baseContentHeight()
void GLWebViewState::setViewport(SkRect& viewport, float scale)
{
+ // allocate max possible number of tiles visible with this viewport / expandedTileBounds
+ const float invTileContentWidth = scale / TilesManager::tileWidth();
+ const float invTileContentHeight = scale / TilesManager::tileHeight();
+
+ int viewMaxTileX = static_cast<int>(ceilf((viewport.width()-1) * invTileContentWidth)) + 1;
+ int viewMaxTileY = static_cast<int>(ceilf((viewport.height()-1) * invTileContentHeight)) + 1;
+
+ TilesManager* manager = TilesManager::instance();
+ int maxTextureCount = (viewMaxTileX + m_expandedTileBoundsX * 2) *
+ (viewMaxTileY + m_expandedTileBoundsY * 2) * (manager->highEndGfx() ? 4 : 2);
+
+ manager->setMaxTextureCount(maxTextureCount);
+ m_tiledPageA->updateBaseTileSize();
+ m_tiledPageB->updateBaseTileSize();
+
if ((m_viewport == viewport) &&
- (zoomManager()->futureScale() == scale))
+ (zoomManager()->futureScale() == scale)) {
+ // everything below will stay the same, early return.
+ m_isViewportScrolling = false;
return;
+ }
m_goingDown = m_viewport.fTop - viewport.fTop <= 0;
m_goingLeft = m_viewport.fLeft - viewport.fLeft >= 0;
+
+ // detect viewport scrolling from short programmatic scrolls/jumps
+ m_isViewportScrolling = m_viewport != viewport && SkRect::Intersects(m_viewport, viewport);
m_viewport = viewport;
XLOG("New VIEWPORT %.2f - %.2f %.2f - %.2f (w: %2.f h: %.2f scale: %.2f currentScale: %.2f futureScale: %.2f)",
@@ -253,25 +279,11 @@ void GLWebViewState::setViewport(SkRect& viewport, float scale)
m_viewport.width(), m_viewport.height(), scale,
zoomManager()->currentScale(), zoomManager()->futureScale());
- const float invTileContentWidth = scale / TilesManager::tileWidth();
- const float invTileContentHeight = scale / TilesManager::tileHeight();
-
m_viewportTileBounds.set(
static_cast<int>(floorf(viewport.fLeft * invTileContentWidth)),
static_cast<int>(floorf(viewport.fTop * invTileContentHeight)),
static_cast<int>(ceilf(viewport.fRight * invTileContentWidth)),
static_cast<int>(ceilf(viewport.fBottom * invTileContentHeight)));
-
- // allocate max possible number of tiles visible with this viewport
- int viewMaxTileX = static_cast<int>(ceilf((viewport.width()-1) * invTileContentWidth)) + 1;
- int viewMaxTileY = static_cast<int>(ceilf((viewport.height()-1) * invTileContentHeight)) + 1;
-
- int maxTextureCount = (viewMaxTileX + m_expandedTileBoundsX * 2) *
- (viewMaxTileY + m_expandedTileBoundsY * 2) * (m_highEndGfx ? 4 : 2);
-
- TilesManager::instance()->setMaxTextureCount(maxTextureCount);
- m_tiledPageA->updateBaseTileSize();
- m_tiledPageB->updateBaseTileSize();
}
#ifdef MEASURES_PERF
@@ -340,11 +352,18 @@ double GLWebViewState::setupDrawing(IntRect& viewRect, SkRect& visibleRect,
int width = viewRect.width();
int height = viewRect.height();
+ // Make sure GL resources are created on the UI thread.
ShaderProgram* shader = TilesManager::instance()->shader();
- if (shader->program() == -1) {
+ if (shader->needsInit()) {
XLOG("Reinit shader");
shader->init();
}
+ TransferQueue* transferQueue = TilesManager::instance()->transferQueue();
+ if (transferQueue->needsInit()) {
+ transferQueue->initGLResources(TilesManager::tileWidth(),
+ TilesManager::tileHeight());
+ }
+
shader->setViewport(visibleRect, scale);
shader->setViewRect(viewRect);
shader->setWebViewRect(webViewRect);
@@ -491,8 +510,10 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
// TODO: upload as many textures as possible within a certain time limit
bool ret = ImagesManager::instance()->prepareTextures(this);
- if (scale < MIN_SCALE_WARNING || scale > MAX_SCALE_WARNING)
+ if (scale < MIN_SCALE_WARNING || scale > MAX_SCALE_WARNING) {
XLOGC("WARNING, scale seems corrupted after update: %e", scale);
+ CRASH();
+ }
// gather the textures we can use
TilesManager::instance()->gatherLayerTextures();
@@ -502,6 +523,7 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
TexturesResult nbTexturesNeeded;
bool fastSwap = isScrolling() || m_layersRenderingMode == kSingleSurfaceRendering;
+ m_glExtras.setViewport(viewport);
ret |= m_treeManager.drawGL(currentTime, rect, viewport,
scale, fastSwap,
treesSwappedPtr, newTreeHasAnimPtr,
@@ -518,11 +540,6 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
nbTexturesNeeded.clipped += nbTexturesForImages;
ret |= setLayersRenderingMode(nbTexturesNeeded);
- FloatRect extrasclip(0, 0, rect.width(), rect.height());
- TilesManager::instance()->shader()->clip(extrasclip);
-
- m_glExtras.drawGL(webViewRect, viewport, titleBarHeight);
-
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Clean up GL textures for video layer.
@@ -574,6 +591,30 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
resetFrameworkInval();
}
+ showFrameInfo(rect, *treesSwappedPtr);
+
+#ifdef DEBUG
+ TilesManager::instance()->getTilesTracker()->showTrackTextures();
+#endif
+
+ return ret;
+}
+
+void GLWebViewState::showFrameInfo(const IntRect& rect, bool treesSwapped)
+{
+ bool showVisualIndicator = TilesManager::instance()->getShowVisualIndicator();
+
+ bool drawOrDumpFrameInfo = showVisualIndicator;
+#ifdef MEASURES_PERF
+ drawOrDumpFrameInfo |= m_measurePerfs;
+#endif
+ if (!drawOrDumpFrameInfo)
+ return;
+
+ double currentDrawTime = WTF::currentTime();
+ double delta = currentDrawTime - m_prevDrawTime;
+ m_prevDrawTime = currentDrawTime;
+
#ifdef MEASURES_PERF
if (m_measurePerfs) {
m_delayTimes[m_timeCounter++] = delta;
@@ -582,12 +623,37 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect,
}
#endif
-#ifdef DEBUG
- TilesManager::instance()->getTilesTracker()->showTrackTextures();
- ImagesManager::instance()->showImages();
-#endif
+ IntRect frameInfoRect = rect;
+ frameInfoRect.setHeight(FPS_INDICATOR_HEIGHT);
+ double ratio = (1.0 / delta) / MAX_FPS_VALUE;
- return ret;
+ clearRectWithColor(frameInfoRect, 1, 1, 1, 1);
+ frameInfoRect.setWidth(frameInfoRect.width() * ratio);
+ clearRectWithColor(frameInfoRect, 1, 0, 0, 1);
+
+ // Draw the tree swap counter as a circling progress bar.
+ // This will basically show how fast we are updating the tree.
+ static int swappedCounter = 0;
+ if (treesSwapped)
+ swappedCounter = (swappedCounter + 1) % TREE_SWAPPED_COUNTER_MODULE;
+
+ frameInfoRect = rect;
+ frameInfoRect.setHeight(FPS_INDICATOR_HEIGHT);
+ frameInfoRect.move(0, FPS_INDICATOR_HEIGHT);
+
+ clearRectWithColor(frameInfoRect, 1, 1, 1, 1);
+ ratio = (swappedCounter + 1.0) / TREE_SWAPPED_COUNTER_MODULE;
+
+ frameInfoRect.setWidth(frameInfoRect.width() * ratio);
+ clearRectWithColor(frameInfoRect, 0, 1, 0, 1);
+}
+
+void GLWebViewState::clearRectWithColor(const IntRect& rect, float r, float g,
+ float b, float a)
+{
+ glScissor(rect.x(), rect.y(), rect.width(), rect.height());
+ glClearColor(r, g, b, a);
+ glClear(GL_COLOR_BUFFER_BIT);
}
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.h b/Source/WebCore/platform/graphics/android/GLWebViewState.h
index 8d89704..cc0c56b 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.h
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.h
@@ -176,7 +176,7 @@ public:
void setFutureViewport(const SkIRect& viewport) { m_futureViewportTileBounds = viewport; }
unsigned int paintBaseLayerContent(SkCanvas* canvas);
- void setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval, bool showVisualIndicator,
+ bool setBaseLayer(BaseLayerAndroid* layer, bool showVisualIndicator,
bool isPictureAfterFirstLayout);
void paintExtras();
@@ -202,7 +202,7 @@ public:
unsigned int currentPictureCounter() const { return m_currentPictureCounter; }
void setIsScrolling(bool isScrolling) { m_isScrolling = isScrolling; }
- bool isScrolling() { return m_isScrolling; }
+ bool isScrolling() { return m_isScrolling || m_isViewportScrolling; }
void drawBackground(Color& backgroundColor);
double setupDrawing(IntRect& viewRect, SkRect& visibleRect,
@@ -234,7 +234,6 @@ public:
int expandedTileBoundsX() { return m_expandedTileBoundsX; }
int expandedTileBoundsY() { return m_expandedTileBoundsY; }
- void setHighEndGfx(bool highEnd) { m_highEndGfx = highEnd; }
float scale() { return m_scale; }
@@ -254,6 +253,10 @@ public:
private:
void inval(const IntRect& rect);
+ void showFrameInfo(const IntRect& rect, bool treesSwapped);
+ void clearRectWithColor(const IntRect& rect, float r, float g,
+ float b, float a);
+ double m_prevDrawTime;
ZoomManager m_zoomManager;
android::Mutex m_tiledPageLock;
@@ -279,12 +282,12 @@ private:
GLExtras m_glExtras;
bool m_isScrolling;
+ bool m_isViewportScrolling;
bool m_goingDown;
bool m_goingLeft;
int m_expandedTileBoundsX;
int m_expandedTileBoundsY;
- bool m_highEndGfx;
float m_scale;
diff --git a/Source/WebCore/platform/graphics/android/GaneshContext.cpp b/Source/WebCore/platform/graphics/android/GaneshContext.cpp
index e67bcd4..1a5ce5e 100644
--- a/Source/WebCore/platform/graphics/android/GaneshContext.cpp
+++ b/Source/WebCore/platform/graphics/android/GaneshContext.cpp
@@ -95,11 +95,7 @@ SkDevice* GaneshContext::getDeviceForBaseTile(const TileRenderInfo& renderInfo)
contextNeedsReset = true;
}
- SkDevice* device = 0;
- if (renderInfo.textureInfo->getSharedTextureMode() == SurfaceTextureMode)
- device = getDeviceForBaseTileSurface(renderInfo);
- else if (renderInfo.textureInfo->getSharedTextureMode() == EglImageMode)
- device = getDeviceForBaseTileFBO(renderInfo);
+ SkDevice* device = getDeviceForBaseTileSurface(renderInfo);
// We must reset the Ganesh context only after we are sure we have
// re-established our EGLContext as the current context.
diff --git a/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
index 29acb2b..c90ddb3 100644
--- a/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
+++ b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp
@@ -84,20 +84,16 @@ void GaneshRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* can
GaneshContext* ganesh = GaneshContext::instance();
-#if !DEPRECATED_SURFACE_TEXTURE_MODE
- if (renderInfo.textureInfo->getSharedTextureMode() == SurfaceTextureMode) {
- TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
-
- tileQueue->lockQueue();
-
- bool ready = tileQueue->readyForUpdate();
- if (!ready) {
- XLOG("!ready");
- tileQueue->unlockQueue();
- return;
- }
+ TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
+
+ tileQueue->lockQueue();
+
+ bool ready = tileQueue->readyForUpdate();
+ if (!ready) {
+ XLOG("!ready");
+ tileQueue->unlockQueue();
+ return;
}
-#endif
SkDevice* device = NULL;
if (renderInfo.tileSize.width() == TilesManager::tileWidth()
@@ -117,12 +113,6 @@ void GaneshRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* can
// set the GPU device to the canvas
canvas->setDevice(device);
-
- // invert canvas contents
- if (renderInfo.textureInfo->getSharedTextureMode() == EglImageMode) {
- canvas->scale(SK_Scalar1, -SK_Scalar1);
- canvas->translate(0, -renderInfo.tileSize.height());
- }
}
void GaneshRenderer::setupPartialInval(const TileRenderInfo& renderInfo, SkCanvas* canvas)
@@ -148,14 +138,10 @@ void GaneshRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanva
// In SurfaceTextureMode we must call swapBuffers to unlock and post the
// tile's ANativeWindow (i.e. SurfaceTexture) buffer
- if (renderInfo.textureInfo->getSharedTextureMode() == SurfaceTextureMode) {
-#if !DEPRECATED_SURFACE_TEXTURE_MODE
- TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
- eglSwapBuffers(eglGetCurrentDisplay(), tileQueue->m_eglSurface);
- tileQueue->addItemInTransferQueue(&renderInfo, GpuUpload, 0);
- tileQueue->unlockQueue();
-#endif
- }
+ TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
+ eglSwapBuffers(eglGetCurrentDisplay(), tileQueue->m_eglSurface);
+ tileQueue->addItemInTransferQueue(&renderInfo, GpuUpload, 0);
+ tileQueue->unlockQueue();
if (renderInfo.measurePerf)
m_perfMon.stop(TAG_UPDATE_TEXTURE);
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 567b54b..779eb36 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -555,6 +555,15 @@ void GraphicsLayerAndroid::updateScrollingLayers()
#endif
}
+void GraphicsLayerAndroid::updateScrollOffset() {
+ RenderLayer* layer = renderLayerFromClient(m_client);
+ if (!layer || !m_foregroundLayer)
+ return;
+ IntSize scroll = layer->scrolledContentOffset();
+ m_foregroundLayer->setScrollOffset(IntPoint(scroll.width(), scroll.height()));
+ askForSync();
+}
+
bool GraphicsLayerAndroid::repaint()
{
LOG("(%x) repaint(), gPaused(%d) m_needsRepaint(%d) m_haveContents(%d) ",
@@ -573,14 +582,16 @@ bool GraphicsLayerAndroid::repaint()
phase.set(GraphicsLayerPaintBackground);
if (!paintContext(m_contentLayer->recordContext(), layerBounds))
return false;
- m_contentLayer->checkTextPresence();
+ m_contentLayer->checkForPictureOptimizations();
// Construct the foreground layer and draw.
RenderBox* box = layer->renderBox();
int outline = box->view()->maximalOutlineSize();
IntRect contentsRect(0, 0,
- box->borderLeft() + box->borderRight() + layer->scrollWidth(),
- box->borderTop() + box->borderBottom() + layer->scrollHeight());
+ box->borderLeft() + box->borderRight() + layer->scrollWidth()
+ + layer->verticalScrollbarWidth(),
+ box->borderTop() + box->borderBottom() + layer->scrollHeight()
+ + layer->horizontalScrollbarHeight());
contentsRect.inflate(outline);
// Update the foreground layer size.
m_foregroundLayer->setSize(contentsRect.width(), contentsRect.height());
@@ -592,7 +603,7 @@ bool GraphicsLayerAndroid::repaint()
layer->scrollToOffset(0, 0);
// At this point, it doesn't matter if painting failed.
(void) paintContext(m_foregroundLayer->recordContext(), contentsRect);
- m_foregroundLayer->checkTextPresence();
+ m_foregroundLayer->checkForPictureOptimizations();
layer->scrollToOffset(scroll.width(), scroll.height());
// Construct the clip layer for masking the contents.
@@ -606,6 +617,11 @@ bool GraphicsLayerAndroid::repaint()
m_foregroundClipLayer->setPosition(x, y);
m_foregroundClipLayer->setSize(width, height);
+ int rtlOffset = 0; // LTR uses no offset.
+ if (!layer->renderer()->style()->isLeftToRightDirection())
+ rtlOffset = layer->scrollWidth() - width; // Scroll all the way right.
+ m_foregroundLayer->setScrollOffset(IntPoint(scroll.width() + rtlOffset,
+ scroll.height()));
// Need to offset the foreground layer by the clip layer in order
// for the contents to be in the correct position.
m_foregroundLayer->setPosition(-x, -y);
@@ -625,7 +641,7 @@ bool GraphicsLayerAndroid::repaint()
// picture.
if (!paintContext(m_contentLayer->recordContext(), layerBounds))
return false;
- m_contentLayer->checkTextPresence();
+ m_contentLayer->checkForPictureOptimizations();
// Check for a scrollable iframe and report the scrolling
// limits based on the view size.
if (m_contentLayer->contentIsScrollable()) {
@@ -749,7 +765,7 @@ bool GraphicsLayerAndroid::createAnimationFromKeyframes(const KeyframeValueList&
KeyframeValueList* operationsList = new KeyframeValueList(AnimatedPropertyOpacity);
for (unsigned int i = 0; i < valueList.size(); i++) {
FloatAnimationValue* originalValue = (FloatAnimationValue*)valueList.at(i);
- PassRefPtr<TimingFunction> timingFunction(const_cast<TimingFunction*>(originalValue->timingFunction()));
+ RefPtr<TimingFunction> timingFunction(const_cast<TimingFunction*>(originalValue->timingFunction()));
FloatAnimationValue* value = new FloatAnimationValue(originalValue->keyTime(),
originalValue->value(),
timingFunction);
@@ -791,7 +807,7 @@ bool GraphicsLayerAndroid::createTransformAnimationsFromKeyframes(const Keyframe
KeyframeValueList* operationsList = new KeyframeValueList(AnimatedPropertyWebkitTransform);
for (unsigned int i = 0; i < valueList.size(); i++) {
TransformAnimationValue* originalValue = (TransformAnimationValue*)valueList.at(i);
- PassRefPtr<TimingFunction> timingFunction(const_cast<TimingFunction*>(originalValue->timingFunction()));
+ RefPtr<TimingFunction> timingFunction(const_cast<TimingFunction*>(originalValue->timingFunction()));
TransformAnimationValue* value = new TransformAnimationValue(originalValue->keyTime(),
originalValue->value(),
timingFunction);
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
index e6d75b0..4c049cd 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
@@ -25,6 +25,7 @@
#include "GraphicsLayerClient.h"
#include "LayerAndroid.h"
#include "RefPtr.h"
+#include "ScrollableLayerAndroid.h"
#include "SkBitmapRef.h"
#include "Vector.h"
@@ -122,9 +123,12 @@ public:
void notifyClientAnimationStarted();
LayerAndroid* contentLayer() { return m_contentLayer; }
+ ScrollableLayerAndroid* foregroundLayer() { return m_foregroundLayer; }
static int instancesCount();
+ virtual void updateScrollOffset();
+
private:
void askForSync();
diff --git a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
index 751a08f..f148881 100644
--- a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
@@ -196,7 +196,7 @@ void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sou
ASSERT(destx >= 0);
ASSERT(destx < m_size.width());
ASSERT(originx >= 0);
- ASSERT(originx <= sourceRect.right());
+ ASSERT(originx <= sourceRect.maxX());
int endx = destPoint.x() + sourceRect.maxX();
ASSERT(endx <= m_size.width());
@@ -208,7 +208,7 @@ void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sou
ASSERT(desty >= 0);
ASSERT(desty < m_size.height());
ASSERT(originy >= 0);
- ASSERT(originy <= sourceRect.bottom());
+ ASSERT(originy <= sourceRect.maxY());
int endy = destPoint.y() + sourceRect.maxY();
ASSERT(endy <= m_size.height());
diff --git a/Source/WebCore/platform/graphics/android/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
index 577e7f0..0ca8ee7 100644
--- a/Source/WebCore/platform/graphics/android/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/ImageTexture.cpp
@@ -240,8 +240,10 @@ void ImageTexture::drawGL(LayerAndroid* layer)
// TiledTexture::draw() will call us back to know the
// transform and opacity, so we need to set m_layer
m_layer = layer;
- if (m_texture)
- m_texture->draw();
+ if (m_texture) {
+ IntRect visibleArea = m_layer->visibleArea();
+ m_texture->draw(visibleArea);
+ }
m_layer = 0;
}
diff --git a/Source/WebCore/platform/graphics/android/InspectorCanvas.cpp b/Source/WebCore/platform/graphics/android/InspectorCanvas.cpp
new file mode 100644
index 0000000..0137cec
--- /dev/null
+++ b/Source/WebCore/platform/graphics/android/InspectorCanvas.cpp
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2011, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InspectorCanvas.h"
+
+#include "SkPicture.h"
+
+#include <cutils/log.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/text/CString.h>
+
+#undef XLOGC
+#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "InspectorCanvas", __VA_ARGS__)
+
+#ifdef DEBUG
+
+#undef XLOG
+#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "InspectorCanvas", __VA_ARGS__)
+
+#else
+
+#undef XLOG
+#define XLOG(...)
+
+#endif // DEBUG
+
+
+namespace WebCore {
+
+
+void InspectorCanvas::setHasText()
+{
+ m_hasText = true;
+ setHasContent();
+}
+
+void InspectorCanvas::setHasContent()
+{
+ m_hasContent = true;
+ if (m_hasText) {
+ // has text. Have to paint properly, so no further
+ // information is useful
+ m_picture->abortPlayback();
+ }
+}
+
+void InspectorCanvas::setIsBackground(const SkPaint& paint)
+{
+ // TODO: if the paint is a solid color, opaque, and the last instruction in
+ // the picture, replace the picture with simple draw rect info
+ setHasContent();
+}
+
+void InspectorCanvas::commonDrawBitmap(const SkBitmap& bitmap,
+ const SkIRect* rect,
+ const SkMatrix&,
+ const SkPaint&)
+{
+ setHasContent();
+}
+
+void InspectorCanvas::drawPaint(const SkPaint& paint)
+{
+ setHasContent();
+}
+
+void InspectorCanvas::drawPath(const SkPath&, const SkPaint& paint)
+{
+ setHasContent();
+}
+void InspectorCanvas::drawPoints(PointMode, size_t,
+ const SkPoint [], const SkPaint& paint)
+{
+ setHasContent();
+}
+
+void InspectorCanvas::drawRect(const SkRect& rect, const SkPaint& paint)
+{
+ if (rect.fLeft == 0
+ && rect.fTop == 0
+ && rect.width() >= m_picture->width()
+ && rect.height() >= m_picture->height()) {
+ // rect same size as canvas, treat layer as a single color rect until
+ // more content is drawn
+ setIsBackground(paint);
+ } else {
+ // regular rect drawing path
+ setHasContent();
+ }
+ XLOG("draw rect at %f %f, size %f %f, picture size %d %d",
+ rect.fLeft, rect.fTop, rect.width(), rect.height(),
+ m_picture->width(), m_picture->height());
+}
+void InspectorCanvas::drawSprite(const SkBitmap& , int , int ,
+ const SkPaint* paint)
+{
+ setHasContent();
+}
+
+void InspectorCanvas::drawText(const void*, size_t byteLength, SkScalar,
+ SkScalar, const SkPaint& paint)
+{
+ setHasText();
+}
+
+void InspectorCanvas::drawPosText(const void* , size_t byteLength,
+ const SkPoint [], const SkPaint& paint)
+{
+ setHasText();
+}
+
+void InspectorCanvas::drawPosTextH(const void*, size_t byteLength,
+ const SkScalar [], SkScalar,
+ const SkPaint& paint)
+{
+ setHasText();
+}
+
+void InspectorCanvas::drawTextOnPath(const void*, size_t byteLength,
+ const SkPath&, const SkMatrix*,
+ const SkPaint& paint)
+{
+ setHasText();
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/InspectorCanvas.h b/Source/WebCore/platform/graphics/android/InspectorCanvas.h
new file mode 100644
index 0000000..415a579
--- /dev/null
+++ b/Source/WebCore/platform/graphics/android/InspectorCanvas.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2011, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InspectorCanvas_h
+#define InspectorCanvas_h
+
+#include "SkBounder.h"
+#include "SkCanvas.h"
+
+namespace WebCore {
+
+class InspectorBounder : public SkBounder {
+ virtual bool onIRect(const SkIRect& rect)
+ {
+ return false;
+ }
+};
+
+class InspectorCanvas : public SkCanvas {
+public:
+ InspectorCanvas(SkBounder* bounder, SkPicture* picture)
+ : m_picture(picture)
+ , m_hasText(false)
+ , m_hasContent(false)
+ {
+ setBounder(bounder);
+ }
+
+ bool hasText() {return m_hasText;}
+ bool hasContent() {return m_hasContent;}
+
+ virtual bool clipPath(const SkPath&, SkRegion::Op) {
+ return true;
+ }
+
+ virtual void commonDrawBitmap(const SkBitmap& bitmap,
+ const SkIRect* rect,
+ const SkMatrix&,
+ const SkPaint&);
+
+ virtual void drawPaint(const SkPaint& paint);
+ virtual void drawPath(const SkPath&, const SkPaint& paint);
+ virtual void drawPoints(PointMode, size_t,
+ const SkPoint [], const SkPaint& paint);
+
+ virtual void drawRect(const SkRect& , const SkPaint& paint);
+ virtual void drawSprite(const SkBitmap& , int , int ,
+ const SkPaint* paint = NULL);
+
+ virtual void drawText(const void*, size_t byteLength, SkScalar,
+ SkScalar, const SkPaint& paint);
+ virtual void drawPosText(const void* , size_t byteLength,
+ const SkPoint [], const SkPaint& paint);
+ virtual void drawPosTextH(const void*, size_t byteLength,
+ const SkScalar [], SkScalar,
+ const SkPaint& paint);
+ virtual void drawTextOnPath(const void*, size_t byteLength,
+ const SkPath&, const SkMatrix*,
+ const SkPaint& paint);
+
+private:
+
+ // vector instructions exist, must repaint at any scale
+ void setHasText();
+
+ // painting is required
+ void setHasContent();
+
+ // rect covering entire content, don't need to use a texture if nothing else
+ // is painted
+ void setIsBackground(const SkPaint& paint);
+
+ SkPicture* m_picture;
+ bool m_hasText;
+ bool m_hasContent;
+};
+
+} // namespace WebCore
+
+#endif // InspectorCanvas_h
diff --git a/Source/WebCore/platform/graphics/android/Layer.cpp b/Source/WebCore/platform/graphics/android/Layer.cpp
index 9280461..f58d648 100644
--- a/Source/WebCore/platform/graphics/android/Layer.cpp
+++ b/Source/WebCore/platform/graphics/android/Layer.cpp
@@ -158,13 +158,13 @@ void Layer::localToAncestor(const Layer* ancestor, SkMatrix* matrix) const {
///////////////////////////////////////////////////////////////////////////////
-void Layer::onDraw(SkCanvas*, SkScalar opacity) {
+void Layer::onDraw(SkCanvas*, SkScalar opacity, android::DrawExtra* extra) {
// SkDebugf("----- no onDraw for %p\n", this);
}
#include "SkString.h"
-void Layer::draw(SkCanvas* canvas, SkScalar opacity) {
+void Layer::draw(SkCanvas* canvas, android::DrawExtra* extra, SkScalar opacity) {
#if 0
SkString str1, str2;
// getMatrix().toDumpString(&str1);
@@ -193,7 +193,7 @@ void Layer::draw(SkCanvas* canvas, SkScalar opacity) {
canvas->concat(tmp);
}
- onDraw(canvas, opacity);
+ onDraw(canvas, opacity, extra);
#ifdef DEBUG_DRAW_LAYER_BOUNDS
{
@@ -213,7 +213,7 @@ void Layer::draw(SkCanvas* canvas, SkScalar opacity) {
if (count > 0) {
canvas->concat(getChildrenMatrix());
for (int i = 0; i < count; i++) {
- getChild(i)->draw(canvas, opacity);
+ getChild(i)->draw(canvas, extra, opacity);
}
}
}
diff --git a/Source/WebCore/platform/graphics/android/Layer.h b/Source/WebCore/platform/graphics/android/Layer.h
index 5200a3d..876ca24 100644
--- a/Source/WebCore/platform/graphics/android/Layer.h
+++ b/Source/WebCore/platform/graphics/android/Layer.h
@@ -17,6 +17,7 @@
#ifndef Layer_DEFINED
#define Layer_DEFINED
+#include "DrawExtra.h"
#include "TestExport.h"
#include "SkRefCnt.h"
#include "SkTDArray.h"
@@ -165,17 +166,14 @@ public:
// paint method
virtual bool drawCanvas(SkCanvas*) { return false; }
- void draw(SkCanvas*, SkScalar opacity);
- void draw(SkCanvas* canvas) {
- this->draw(canvas, SK_Scalar1);
- }
+ void draw(SkCanvas*, android::DrawExtra* extra, SkScalar opacity = SK_Scalar1);
void setHasOverflowChildren(bool value) { m_hasOverflowChildren = value; }
virtual bool contentIsScrollable() const { return false; }
protected:
- virtual void onDraw(SkCanvas*, SkScalar opacity);
+ virtual void onDraw(SkCanvas*, SkScalar opacity, android::DrawExtra* extra);
bool m_hasOverflowChildren;
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
index 962bcdf..79c02eb 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -8,11 +8,11 @@
#include "DrawExtra.h"
#include "GLUtils.h"
#include "ImagesManager.h"
+#include "InspectorCanvas.h"
#include "MediaLayer.h"
#include "PaintedSurface.h"
#include "ParseCanvas.h"
#include "SkBitmapRef.h"
-#include "SkBounder.h"
#include "SkDrawFilter.h"
#include "SkPaint.h"
#include "SkPicture.h"
@@ -55,87 +55,6 @@ private:
int m_opacity;
};
-class HasTextBounder : public SkBounder {
- virtual bool onIRect(const SkIRect& rect)
- {
- return false;
- }
-};
-
-class HasTextCanvas : public SkCanvas {
-public:
- HasTextCanvas(SkBounder* bounder, SkPicture* picture)
- : m_picture(picture)
- , m_hasText(false)
- {
- setBounder(bounder);
- }
-
- void setHasText()
- {
- m_hasText = true;
- m_picture->abortPlayback();
- }
-
- bool hasText()
- {
- return m_hasText;
- }
-
- virtual bool clipPath(const SkPath&, SkRegion::Op) {
- return true;
- }
-
- virtual void commonDrawBitmap(const SkBitmap& bitmap,
- const SkIRect* rect,
- const SkMatrix&,
- const SkPaint&) {}
-
- virtual void drawPaint(const SkPaint& paint) {}
- virtual void drawPath(const SkPath&, const SkPaint& paint) {}
- virtual void drawPoints(PointMode, size_t,
- const SkPoint [], const SkPaint& paint) {}
-
- virtual void drawRect(const SkRect& , const SkPaint& paint) {}
- virtual void drawSprite(const SkBitmap& , int , int ,
- const SkPaint* paint = NULL) {}
-
- virtual void drawText(const void*, size_t byteLength, SkScalar,
- SkScalar, const SkPaint& paint)
- {
- setHasText();
- }
-
- virtual void drawPosText(const void* , size_t byteLength,
- const SkPoint [], const SkPaint& paint)
- {
- setHasText();
- }
-
- virtual void drawPosTextH(const void*, size_t byteLength,
- const SkScalar [], SkScalar,
- const SkPaint& paint)
- {
- setHasText();
- }
-
- virtual void drawTextOnPath(const void*, size_t byteLength,
- const SkPath&, const SkMatrix*,
- const SkPaint& paint)
- {
- setHasText();
- }
-
- virtual void drawPicture(SkPicture& picture) {
- SkCanvas::drawPicture(picture);
- }
-
-private:
-
- SkPicture* m_picture;
- bool m_hasText;
-};
-
///////////////////////////////////////////////////////////////////////////////
LayerAndroid::LayerAndroid(RenderLayer* owner) : Layer(),
@@ -198,6 +117,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
m_fixedMarginBottom = layer.m_fixedMarginBottom;
m_fixedRect = layer.m_fixedRect;
m_iframeOffset = layer.m_iframeOffset;
+ m_offset = layer.m_offset;
m_recordingPicture = layer.m_recordingPicture;
SkSafeRef(m_recordingPicture);
@@ -226,13 +146,13 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer),
#endif
}
-void LayerAndroid::checkTextPresence()
+void LayerAndroid::checkForPictureOptimizations()
{
if (m_recordingPicture) {
// Let's check if we have text or not. If we don't, we can limit
// ourselves to scale 1!
- HasTextBounder hasTextBounder;
- HasTextCanvas checker(&hasTextBounder, m_recordingPicture);
+ InspectorBounder inspectorBounder;
+ InspectorCanvas checker(&inspectorBounder, m_recordingPicture);
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config,
m_recordingPicture->width(),
@@ -240,6 +160,12 @@ void LayerAndroid::checkTextPresence()
checker.setBitmapDevice(bitmap);
checker.drawPicture(*m_recordingPicture);
m_hasText = checker.hasText();
+ if (!checker.hasContent()) {
+ // no content to draw, discard picture so UI / tile generation
+ // doesn't bother with it
+ SkSafeUnref(m_recordingPicture);
+ m_recordingPicture = 0;
+ }
}
}
@@ -685,7 +611,7 @@ void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentM
m_atomicSync.lock();
IntSize layerSize(getSize().width(), getSize().height());
FloatPoint anchorPoint(getAnchorPoint().fX, getAnchorPoint().fY);
- FloatPoint position(getPosition().fX, getPosition().fY);
+ FloatPoint position(getPosition().fX - m_offset.x(), getPosition().fY - m_offset.y());
float centerOffsetX = (0.5f - anchorPoint.x()) * layerSize.width();
float centerOffsetY = (0.5f - anchorPoint.y()) * layerSize.height();
float originX = anchorPoint.x() * layerSize.width();
@@ -1096,7 +1022,7 @@ bool LayerAndroid::drawCanvas(SkCanvas* canvas)
layerRect.fTop = 0;
layerRect.fRight = getWidth();
layerRect.fBottom = getHeight();
- onDraw(canvas, m_drawOpacity);
+ onDraw(canvas, m_drawOpacity, 0);
}
// When the layer is dirty, the UI thread should be notified to redraw.
@@ -1129,6 +1055,8 @@ bool LayerAndroid::drawGL()
}
}
+ m_state->glExtras()->drawGL(this);
+
// When the layer is dirty, the UI thread should be notified to redraw.
askScreenUpdate |= drawChildrenGL();
m_atomicSync.lock();
@@ -1205,7 +1133,7 @@ void LayerAndroid::contentDraw(SkCanvas* canvas)
}
}
-void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity)
+void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity, android::DrawExtra* extra)
{
if (m_haveClip) {
SkRect r;
@@ -1235,6 +1163,8 @@ void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity)
ImagesManager::instance()->releaseImage(m_imageCRC);
}
contentDraw(canvas);
+ if (extra)
+ extra->draw(canvas, this);
}
SkPicture* LayerAndroid::recordContext()
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h
index c1f1bc9..d33eea1 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h
@@ -199,6 +199,8 @@ public:
setShouldInheritFromRootTransform(true);
}
+ const IntPoint& scrollOffset() const { return m_offset; }
+ void setScrollOffset(IntPoint offset) { m_offset = offset; }
void setBackgroundColor(SkColor color);
void setMaskLayer(LayerAndroid*);
void setMasksToBounds(bool masksToBounds)
@@ -302,7 +304,7 @@ public:
int type() { return m_type; }
bool hasText() { return m_hasText; }
- void checkTextPresence();
+ void checkForPictureOptimizations();
void copyAnimationStartTimesRecursive(LayerAndroid* oldTree);
@@ -314,8 +316,8 @@ public:
bool isReady();
protected:
- virtual void onDraw(SkCanvas*, SkScalar opacity);
-
+ virtual void onDraw(SkCanvas*, SkScalar opacity, android::DrawExtra* extra);
+ IntPoint m_offset;
TransformationMatrix m_drawTransform;
private:
diff --git a/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h b/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h
index 404ef08..535e7ae 100644
--- a/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h
+++ b/Source/WebCore/platform/graphics/android/MediaPlayerPrivateAndroid.h
@@ -95,6 +95,7 @@ public:
virtual void onPosterFetched(SkBitmap*) { }
void onBuffering(int percent);
void onTimeupdate(int position);
+ void onRestoreState();
// These following two functions are used to turn on inline video support
bool supportsAcceleratedRendering() const { return true; }
diff --git a/Source/WebCore/platform/graphics/android/MediaTexture.cpp b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
index 1676186..f3d1756 100644
--- a/Source/WebCore/platform/graphics/android/MediaTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/MediaTexture.cpp
@@ -283,7 +283,6 @@ void MediaTexture::setDimensions(const ANativeWindow* window,
void MediaTexture::setFramerateCallback(const ANativeWindow* window,
FramerateCallbackProc callback)
{
- XLOG("Release ANW %p (%p):(%p)", this, m_surfaceTexture.get(), m_surfaceTextureClient.get());
android::Mutex::Autolock lock(m_mediaLock);
for (unsigned int i = 0; i < m_videoTextures.size(); i++) {
if (m_videoTextures[i]->nativeWindow.get() == window) {
diff --git a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
index 45c7579..b65c64a 100644
--- a/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
+++ b/Source/WebCore/platform/graphics/android/PaintedSurface.cpp
@@ -99,7 +99,7 @@ void PaintedSurface::prepare(GLWebViewState* state)
paintingLayer->uniqueId(), paintingLayer,
paintingLayer->getScale());
- IntRect visibleArea = computeVisibleArea(paintingLayer);
+ IntRect prepareArea = computePrepareArea(paintingLayer);
m_scale = state->scale();
@@ -109,7 +109,7 @@ void PaintedSurface::prepare(GLWebViewState* state)
m_scale = 1;
m_tiledTexture->prepare(state, m_scale, m_pictureUsed != paintingLayer->pictureUsed(),
- startFastSwap, visibleArea);
+ startFastSwap, prepareArea);
}
bool PaintedSurface::draw()
@@ -118,8 +118,10 @@ bool PaintedSurface::draw()
return false;
bool askRedraw = false;
- if (m_tiledTexture)
- askRedraw = m_tiledTexture->draw();
+ if (m_tiledTexture) {
+ IntRect visibleArea = m_drawingLayer->visibleArea();
+ askRedraw = m_tiledTexture->draw(visibleArea);
+ }
return askRedraw;
}
@@ -196,7 +198,7 @@ void PaintedSurface::computeTexturesAmount(TexturesResult* result)
result->full += nbTexturesUnclipped;
}
-IntRect PaintedSurface::computeVisibleArea(LayerAndroid* layer) {
+IntRect PaintedSurface::computePrepareArea(LayerAndroid* layer) {
IntRect area;
if (!layer)
return area;
diff --git a/Source/WebCore/platform/graphics/android/PaintedSurface.h b/Source/WebCore/platform/graphics/android/PaintedSurface.h
index b8ab7b8..0f201a7 100644
--- a/Source/WebCore/platform/graphics/android/PaintedSurface.h
+++ b/Source/WebCore/platform/graphics/android/PaintedSurface.h
@@ -67,7 +67,7 @@ public:
bool owns(BaseTileTexture* texture);
void computeTexturesAmount(TexturesResult*);
- IntRect computeVisibleArea(LayerAndroid*);
+ IntRect computePrepareArea(LayerAndroid*);
// TilePainter methods for TiledTexture
virtual const TransformationMatrix* transform();
diff --git a/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h b/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h
index d22dbd8..80ea5d6 100644
--- a/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h
+++ b/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h
@@ -28,7 +28,6 @@
#include "IntRect.h"
#include "RenderSkinAndroid.h"
-#include "RenderSkinButton.h"
#include "SkCanvas.h"
#include "SkPicture.h"
#include "SkTDArray.h"
diff --git a/Source/WebCore/platform/graphics/android/RasterRenderer.cpp b/Source/WebCore/platform/graphics/android/RasterRenderer.cpp
index 9991fbd..f52af60 100644
--- a/Source/WebCore/platform/graphics/android/RasterRenderer.cpp
+++ b/Source/WebCore/platform/graphics/android/RasterRenderer.cpp
@@ -112,8 +112,14 @@ void RasterRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* can
device->unref();
- // ensure the canvas origin is translated to the coordinates of our inval rect
- canvas->translate(-renderInfo.invalRect->fLeft, -renderInfo.invalRect->fTop);
+ // If we have a partially painted bitmap
+ if (renderInfo.invalRect) {
+ SkRect clipRect = SkRect::MakeWH(renderInfo.invalRect->width(),
+ renderInfo.invalRect->height());
+ // ensure the canvas origin is translated to the coordinates of our inval rect
+ canvas->clipRect(clipRect);
+ canvas->translate(-renderInfo.invalRect->fLeft, -renderInfo.invalRect->fTop);
+ }
}
void RasterRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas)
diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
index 3c2ced5..55692be 100644
--- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp
@@ -9,27 +9,34 @@ namespace WebCore {
bool ScrollableLayerAndroid::scrollTo(int x, int y)
{
- SkIRect scrollBounds;
- getScrollRect(&scrollBounds);
- if (!scrollBounds.fRight && !scrollBounds.fBottom)
+ IntRect scrollBounds;
+ getScrollBounds(&scrollBounds);
+ if (!scrollBounds.width() && !scrollBounds.height())
return false;
-
- SkScalar newX = SkScalarPin(x, 0, scrollBounds.fRight);
- SkScalar newY = SkScalarPin(y, 0, scrollBounds.fBottom);
+ SkScalar newX = SkScalarPin(x, scrollBounds.x(), scrollBounds.width());
+ SkScalar newY = SkScalarPin(y, scrollBounds.y(), scrollBounds.height());
// Check for no change.
- if (newX == scrollBounds.fLeft && newY == scrollBounds.fTop)
+ if (newX == m_offset.x() && newY == m_offset.y())
return false;
+ setScrollOffset(IntPoint(newX, newY));
+ return true;
+}
- setPosition(m_scrollLimits.fLeft - newX, m_scrollLimits.fTop - newY);
+void ScrollableLayerAndroid::getScrollBounds(IntRect* out) const
+{
+ const SkPoint& pos = getPosition();
+ out->setX(m_scrollLimits.fLeft - pos.fX);
+ out->setY(m_scrollLimits.fTop - pos.fY);
+ out->setWidth(getSize().width() - m_scrollLimits.width());
+ out->setHeight(getSize().height() - m_scrollLimits.height());
- return true;
}
void ScrollableLayerAndroid::getScrollRect(SkIRect* out) const
{
const SkPoint& pos = getPosition();
- out->fLeft = m_scrollLimits.fLeft - pos.fX;
- out->fTop = m_scrollLimits.fTop - pos.fY;
+ out->fLeft = m_scrollLimits.fLeft - pos.fX + m_offset.x();
+ out->fTop = m_scrollLimits.fTop - pos.fY + m_offset.y();
out->fRight = getSize().width() - m_scrollLimits.width();
out->fBottom = getSize().height() - m_scrollLimits.height();
}
diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
index 5cba5d9..b8ff299 100644
--- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h
@@ -71,6 +71,9 @@ public:
friend LayerAndroid* android::deserializeLayer(SkStream* stream);
private:
+
+ void getScrollBounds(IntRect*) const;
+
// The position of the visible area of the layer, relative to the parent
// layer. This is fixed during scrolling. We acheive scrolling by modifying
// the position of the layer.
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
index 2a6a488..a4af713 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
@@ -62,6 +62,26 @@ static const char gFragmentShader[] =
" gl_FragColor *= alpha; "
"}\n";
+// We could pass the pureColor into either Vertex or Frag Shader.
+// The reason we passed the color into the Vertex Shader is that some driver
+// might create redundant copy when uniforms in fragment shader changed.
+static const char gPureColorVertexShader[] =
+ "attribute vec4 vPosition;\n"
+ "uniform mat4 projectionMatrix;\n"
+ "uniform vec4 inputColor;\n"
+ "varying vec4 v_color;\n"
+ "void main() {\n"
+ " gl_Position = projectionMatrix * vPosition;\n"
+ " v_color = inputColor;\n"
+ "}\n";
+
+static const char gPureColorFragmentShader[] =
+ "precision mediump float;\n"
+ "varying vec4 v_color;\n"
+ "void main() {\n"
+ " gl_FragColor = v_color;\n"
+ "}\n";
+
static const char gFragmentShaderInverted[] =
"precision mediump float;\n"
"varying vec2 v_texCoord; \n"
@@ -151,7 +171,7 @@ GLuint ShaderProgram::loadShader(GLenum shaderType, const char* pSource)
return shader;
}
-GLuint ShaderProgram::createProgram(const char* pVertexSource, const char* pFragmentSource)
+GLint ShaderProgram::createProgram(const char* pVertexSource, const char* pFragmentSource)
{
GLuint vertexShader = loadShader(GL_VERTEX_SHADER, pVertexSource);
if (!vertexShader) {
@@ -197,57 +217,83 @@ ShaderProgram::ShaderProgram()
, m_contrast(1)
, m_alphaLayer(false)
, m_currentScale(1.0f)
+ , m_needsInit(true)
{
- init();
}
void ShaderProgram::init()
{
- m_program = createProgram(gVertexShader, gFragmentShader);
- m_programInverted = createProgram(gVertexShader, gFragmentShaderInverted);
- m_videoProgram = createProgram(gVideoVertexShader, gVideoFragmentShader);
- m_surfTexOESProgram =
+ // To detect whether or not resources for ShaderProgram allocated
+ // successfully, we clean up pre-existing errors here and will check for
+ // new errors at the end of this function.
+ GLUtils::checkGlError("before init");
+
+ GLint tex2DProgram = createProgram(gVertexShader, gFragmentShader);
+ GLint pureColorProgram = createProgram(gPureColorVertexShader, gPureColorFragmentShader);
+ GLint tex2DInvProgram = createProgram(gVertexShader, gFragmentShaderInverted);
+ GLint videoProgram = createProgram(gVideoVertexShader, gVideoFragmentShader);
+ GLint texOESProgram =
createProgram(gVertexShader, gSurfaceTextureOESFragmentShader);
- m_surfTexOESProgramInverted =
+ GLint texOESInvProgram =
createProgram(gVertexShader, gSurfaceTextureOESFragmentShaderInverted);
- if (m_program == -1
- || m_programInverted == -1
- || m_videoProgram == -1
- || m_surfTexOESProgram == -1
- || m_surfTexOESProgramInverted == -1)
+ if (tex2DProgram == -1
+ || pureColorProgram == -1
+ || tex2DInvProgram == -1
+ || videoProgram == -1
+ || texOESProgram == -1
+ || texOESInvProgram == -1) {
+ m_needsInit = true;
return;
+ }
- m_hProjectionMatrix = glGetUniformLocation(m_program, "projectionMatrix");
- m_hAlpha = glGetUniformLocation(m_program, "alpha");
- m_hTexSampler = glGetUniformLocation(m_program, "s_texture");
- m_hPosition = glGetAttribLocation(m_program, "vPosition");
-
- m_hProjectionMatrixInverted = glGetUniformLocation(m_programInverted, "projectionMatrix");
- m_hAlphaInverted = glGetUniformLocation(m_programInverted, "alpha");
- m_hContrastInverted = glGetUniformLocation(m_surfTexOESProgramInverted, "contrast");
- m_hTexSamplerInverted = glGetUniformLocation(m_programInverted, "s_texture");
- m_hPositionInverted = glGetAttribLocation(m_programInverted, "vPosition");
-
- m_hVideoProjectionMatrix =
- glGetUniformLocation(m_videoProgram, "projectionMatrix");
- m_hVideoTextureMatrix = glGetUniformLocation(m_videoProgram, "textureMatrix");
- m_hVideoTexSampler = glGetUniformLocation(m_videoProgram, "s_yuvTexture");
- m_hVideoPosition = glGetAttribLocation(m_program, "vPosition");
-
- m_hSTOESProjectionMatrix =
- glGetUniformLocation(m_surfTexOESProgram, "projectionMatrix");
- m_hSTOESAlpha = glGetUniformLocation(m_surfTexOESProgram, "alpha");
- m_hSTOESTexSampler = glGetUniformLocation(m_surfTexOESProgram, "s_texture");
- m_hSTOESPosition = glGetAttribLocation(m_surfTexOESProgram, "vPosition");
-
- m_hSTOESProjectionMatrixInverted =
- glGetUniformLocation(m_surfTexOESProgramInverted, "projectionMatrix");
- m_hSTOESAlphaInverted = glGetUniformLocation(m_surfTexOESProgramInverted, "alpha");
- m_hSTOESContrastInverted = glGetUniformLocation(m_surfTexOESProgramInverted, "contrast");
- m_hSTOESTexSamplerInverted = glGetUniformLocation(m_surfTexOESProgramInverted, "s_texture");
- m_hSTOESPositionInverted = glGetAttribLocation(m_surfTexOESProgramInverted, "vPosition");
-
+ GLint pureColorPosition = glGetAttribLocation(pureColorProgram, "vPosition");
+ GLint pureColorProjMtx = glGetUniformLocation(pureColorProgram, "projectionMatrix");
+ GLint pureColorValue = glGetUniformLocation(pureColorProgram, "inputColor");
+ m_handleArray[PureColor].init(-1, -1, pureColorPosition, pureColorProgram,
+ pureColorProjMtx, pureColorValue, -1, -1);
+
+ GLint tex2DAlpha = glGetUniformLocation(tex2DProgram, "alpha");
+ GLint tex2DPosition = glGetAttribLocation(tex2DProgram, "vPosition");
+ GLint tex2DProjMtx = glGetUniformLocation(tex2DProgram, "projectionMatrix");
+ GLint tex2DTexSampler = glGetUniformLocation(tex2DProgram, "s_texture");
+ m_handleArray[Tex2D].init(tex2DAlpha, -1, tex2DPosition, tex2DProgram,
+ tex2DProjMtx, -1, tex2DTexSampler, -1);
+
+ GLint tex2DInvAlpha = glGetUniformLocation(tex2DInvProgram, "alpha");
+ GLint tex2DInvContrast = glGetUniformLocation(tex2DInvProgram, "contrast");
+ GLint tex2DInvPosition = glGetAttribLocation(tex2DInvProgram, "vPosition");
+ GLint tex2DInvProjMtx = glGetUniformLocation(tex2DInvProgram, "projectionMatrix");
+ GLint tex2DInvTexSampler = glGetUniformLocation(tex2DInvProgram, "s_texture");
+ m_handleArray[Tex2DInv].init(tex2DInvAlpha, tex2DInvContrast,
+ tex2DInvPosition, tex2DInvProgram,
+ tex2DInvProjMtx, -1,
+ tex2DInvTexSampler, -1);
+
+ GLint texOESAlpha = glGetUniformLocation(texOESProgram, "alpha");
+ GLint texOESPosition = glGetAttribLocation(texOESProgram, "vPosition");
+ GLint texOESProjMtx = glGetUniformLocation(texOESProgram, "projectionMatrix");
+ GLint texOESTexSampler = glGetUniformLocation(texOESProgram, "s_texture");
+ m_handleArray[TexOES].init(texOESAlpha, -1, texOESPosition, texOESProgram,
+ texOESProjMtx, -1, texOESTexSampler, -1);
+
+ GLint texOESInvAlpha = glGetUniformLocation(texOESInvProgram, "alpha");
+ GLint texOESInvContrast = glGetUniformLocation(texOESInvProgram, "contrast");
+ GLint texOESInvPosition = glGetAttribLocation(texOESInvProgram, "vPosition");
+ GLint texOESInvProjMtx = glGetUniformLocation(texOESInvProgram, "projectionMatrix");
+ GLint texOESInvTexSampler = glGetUniformLocation(texOESInvProgram, "s_texture");
+ m_handleArray[TexOESInv].init(texOESInvAlpha, texOESInvContrast,
+ texOESInvPosition, texOESInvProgram,
+ texOESInvProjMtx, -1,
+ texOESInvTexSampler, -1);
+
+ GLint videoPosition = glGetAttribLocation(videoProgram, "vPosition");
+ GLint videoProjMtx = glGetUniformLocation(videoProgram, "projectionMatrix");
+ GLint videoTexSampler = glGetUniformLocation(videoProgram, "s_yuvTexture");
+ GLint videoTexMtx = glGetUniformLocation(videoProgram, "textureMatrix");
+ m_handleArray[Video].init(-1, -1, videoPosition, videoProgram,
+ videoProjMtx, -1, videoTexSampler,
+ videoTexMtx);
const GLfloat coord[] = {
0.0f, 0.0f, // C
@@ -260,7 +306,18 @@ void ShaderProgram::init()
glBindBuffer(GL_ARRAY_BUFFER, m_textureBuffer[0]);
glBufferData(GL_ARRAY_BUFFER, 2 * 4 * sizeof(GLfloat), coord, GL_STATIC_DRAW);
- GLUtils::checkGlError("init");
+ TransformationMatrix matrix;
+ // Map x,y from (0,1) to (-1, 1)
+ matrix.scale3d(2, 2, 1);
+ matrix.translate3d(-0.5, -0.5, 0);
+ GLUtils::toGLMatrix(m_transferProjMtx, matrix);
+
+ if (GLUtils::checkGlError("init"))
+ m_needsInit = true;
+ else
+ m_needsInit = false;
+
+ return;
}
void ShaderProgram::resetBlending()
@@ -298,7 +355,8 @@ void ShaderProgram::setViewport(SkRect& viewport, float scale)
m_currentScale = scale;
}
-void ShaderProgram::setProjectionMatrix(SkRect& geometry, GLint projectionMatrixHandle)
+// Calculate the matrix given the geometry.
+void ShaderProgram::setProjectionMatrix(const SkRect& geometry, GLfloat* mtxPtr)
{
TransformationMatrix translate;
translate.translate3d(geometry.fLeft, geometry.fTop, 0.0);
@@ -312,89 +370,73 @@ void ShaderProgram::setProjectionMatrix(SkRect& geometry, GLint projectionMatrix
else
total = m_projectionMatrix * translate * scale;
- GLfloat projectionMatrix[16];
- GLUtils::toGLMatrix(projectionMatrix, total);
- glUniformMatrix4fv(projectionMatrixHandle, 1, GL_FALSE, projectionMatrix);
+ GLUtils::toGLMatrix(mtxPtr, total);
}
-void ShaderProgram::drawQuadInternal(SkRect& geometry,
- GLint textureId,
- float opacity,
- GLint program,
- GLint projectionMatrixHandle,
- GLint texSampler,
- GLenum textureTarget,
- GLint position,
- GLint alpha,
- GLint texFilter,
- GLint contrast)
+// Calculate the right color value sent into the shader considering the (0,1)
+// clamp and alpha blending.
+Color ShaderProgram::shaderColor(Color pureColor, float opacity)
{
- glUseProgram(program);
-
- if (!geometry.isEmpty())
- setProjectionMatrix(geometry, projectionMatrixHandle);
- else {
- TransformationMatrix matrix;
- // Map x,y from (0,1) to (-1, 1)
- matrix.scale3d(2, 2, 1);
- matrix.translate3d(-0.5, -0.5, 0);
- GLfloat projectionMatrix[16];
- GLUtils::toGLMatrix(projectionMatrix, matrix);
- glUniformMatrix4fv(projectionMatrixHandle, 1, GL_FALSE, projectionMatrix);
+ float r = pureColor.red() / 255.0;
+ float g = pureColor.green() / 255.0;
+ float b = pureColor.blue() / 255.0;
+ float a = pureColor.alpha() / 255.0;
+
+ if (TilesManager::instance()->invertedScreen()) {
+ float intensity = a - (0.2989 * r + 0.5866 * g + 0.1145 * b);
+ intensity = ((intensity - a / 2.0) * m_contrast) + a / 2.0;
+ intensity *= opacity;
+ return Color(intensity, intensity, intensity, a * opacity);
}
-
- glActiveTexture(GL_TEXTURE0);
- glUniform1i(texSampler, 0);
- glBindTexture(textureTarget, textureId);
- glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, texFilter);
- glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, texFilter);
- glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- glBindBuffer(GL_ARRAY_BUFFER, m_textureBuffer[0]);
- glEnableVertexAttribArray(position);
- glVertexAttribPointer(position, 2, GL_FLOAT, GL_FALSE, 0, 0);
- glUniform1f(alpha, opacity);
- if (contrast != -1)
- glUniform1f(contrast, m_contrast);
-
- setBlendingState(opacity < 1.0);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ return Color(r * opacity, g * opacity, b * opacity, a * opacity);
}
-void ShaderProgram::drawQuad(SkRect& geometry, int textureId, float opacity,
- GLenum textureTarget, GLint texFilter)
+// For shaders using texture, it is easy to get the type from the textureTarget.
+ShaderType ShaderProgram::getTextureShaderType(GLenum textureTarget)
{
+ ShaderType type = UndefinedShader;
if (textureTarget == GL_TEXTURE_2D) {
- if (!TilesManager::instance()->invertedScreen()) {
- drawQuadInternal(geometry, textureId, opacity, m_program,
- m_hProjectionMatrix,
- m_hTexSampler, GL_TEXTURE_2D,
- m_hPosition, m_hAlpha, texFilter);
- } else {
+ if (!TilesManager::instance()->invertedScreen())
+ type = Tex2D;
+ else {
// With the new GPU texture upload path, we do not use an FBO
// to blit the texture we receive from the TexturesGenerator thread.
// To implement inverted rendering, we thus have to do the rendering
// live, by using a different shader.
- drawQuadInternal(geometry, textureId, opacity, m_programInverted,
- m_hProjectionMatrixInverted,
- m_hTexSamplerInverted, GL_TEXTURE_2D,
- m_hPositionInverted, m_hAlphaInverted, texFilter,
- m_hContrastInverted);
+ type = Tex2DInv;
}
- } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES
- && !TilesManager::instance()->invertedScreen()) {
- drawQuadInternal(geometry, textureId, opacity, m_surfTexOESProgram,
- m_hSTOESProjectionMatrix,
- m_hSTOESTexSampler, GL_TEXTURE_EXTERNAL_OES,
- m_hSTOESPosition, m_hSTOESAlpha, texFilter);
- } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES
- && TilesManager::instance()->invertedScreen()) {
- drawQuadInternal(geometry, textureId, opacity, m_surfTexOESProgramInverted,
- m_hSTOESProjectionMatrixInverted,
- m_hSTOESTexSamplerInverted, GL_TEXTURE_EXTERNAL_OES,
- m_hSTOESPositionInverted, m_hSTOESAlphaInverted,
- texFilter, m_hSTOESContrastInverted);
+ } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES) {
+ if (!TilesManager::instance()->invertedScreen())
+ type = TexOES;
+ else
+ type = TexOESInv;
+ }
+ return type;
+}
+
+void ShaderProgram::drawQuad(SkRect& geometry, int textureId, float opacity,
+ Color pureColor, GLenum textureTarget, GLint texFilter)
+{
+ ShaderType type = UndefinedShader;
+ if (!textureId) {
+ pureColor = shaderColor(pureColor, opacity);
+ if (pureColor.rgb() == Color::transparent && opacity < 1.0)
+ return;
+ type = PureColor;
+ } else
+ type = getTextureShaderType(textureTarget);
+
+ if (type != UndefinedShader) {
+ // The matrix is either for the transfer queue or the tiles
+ GLfloat* finalMatrix = m_transferProjMtx;
+ GLfloat projectionMatrix[16];
+ if (!geometry.isEmpty()) {
+ setProjectionMatrix(geometry, projectionMatrix);
+ finalMatrix = projectionMatrix;
+ }
+ setBlendingState(opacity < 1.0);
+ drawQuadInternal(type, finalMatrix, textureId, opacity, textureTarget,
+ texFilter, pureColor);
}
GLUtils::checkGlError("drawQuad");
}
@@ -530,40 +572,45 @@ float ShaderProgram::zValue(const TransformationMatrix& drawMatrix, float w, flo
return result.z();
}
-void ShaderProgram::drawLayerQuadInternal(const GLfloat* projectionMatrix,
- int textureId, float opacity,
- GLenum textureTarget, GLint program,
- GLint matrix, GLint texSample,
- GLint position, GLint alpha,
- GLint contrast)
+void ShaderProgram::drawQuadInternal(ShaderType type, const GLfloat* matrix,
+ int textureId, float opacity,
+ GLenum textureTarget, GLenum filter,
+ const Color& pureColor)
{
- glUseProgram(program);
- glUniformMatrix4fv(matrix, 1, GL_FALSE, projectionMatrix);
-
- glActiveTexture(GL_TEXTURE0);
- glUniform1i(texSample, 0);
- glBindTexture(textureTarget, textureId);
- glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
+ glUseProgram(m_handleArray[type].programHandle);
+ glUniformMatrix4fv(m_handleArray[type].projMtxHandle, 1, GL_FALSE, matrix);
+
+ if (type != PureColor) {
+ glActiveTexture(GL_TEXTURE0);
+ glUniform1i(m_handleArray[type].texSamplerHandle, 0);
+ glBindTexture(textureTarget, textureId);
+ glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, filter);
+ glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, filter);
+ glUniform1f(m_handleArray[type].alphaHandle, opacity);
+
+ GLint contrastHandle = m_handleArray[type].contrastHandle;
+ if (contrastHandle != -1)
+ glUniform1f(contrastHandle, m_contrast);
+ } else {
+ glUniform4f(m_handleArray[type].pureColorHandle,
+ pureColor.red() / 255.0, pureColor.green() / 255.0,
+ pureColor.blue() / 255.0, pureColor.alpha() / 255.0);
+ }
+ GLint positionHandle = m_handleArray[type].positionHandle;
glBindBuffer(GL_ARRAY_BUFFER, m_textureBuffer[0]);
- glEnableVertexAttribArray(position);
- glVertexAttribPointer(position, 2, GL_FLOAT, GL_FALSE, 0, 0);
- glUniform1f(alpha, opacity);
- if (contrast != -1)
- glUniform1f(contrast, m_contrast);
-}
+ glEnableVertexAttribArray(positionHandle);
+ glVertexAttribPointer(positionHandle, 2, GL_FLOAT, GL_FALSE, 0, 0);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+}
void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
const SkRect& geometry, int textureId,
float opacity, bool forceBlending,
- GLenum textureTarget)
+ GLenum textureTarget,
+ Color pureColor)
{
-
TransformationMatrix modifiedDrawMatrix = drawMatrix;
// move the drawing depending on where the texture is on the layer
modifiedDrawMatrix.translate(geometry.fLeft, geometry.fTop);
@@ -578,37 +625,23 @@ void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
GLfloat projectionMatrix[16];
GLUtils::toGLMatrix(projectionMatrix, renderMatrix);
- if (textureTarget == GL_TEXTURE_2D) {
- if (!TilesManager::instance()->invertedScreen()) {
- drawLayerQuadInternal(projectionMatrix, textureId, opacity,
- GL_TEXTURE_2D, m_program,
- m_hProjectionMatrix, m_hTexSampler,
- m_hPosition, m_hAlpha);
- } else {
- drawLayerQuadInternal(projectionMatrix, textureId, opacity,
- GL_TEXTURE_2D, m_programInverted,
- m_hProjectionMatrixInverted, m_hTexSamplerInverted,
- m_hPositionInverted, m_hAlphaInverted,
- m_hContrastInverted);
- }
- } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES
- && !TilesManager::instance()->invertedScreen()) {
- drawLayerQuadInternal(projectionMatrix, textureId, opacity,
- GL_TEXTURE_EXTERNAL_OES, m_surfTexOESProgram,
- m_hSTOESProjectionMatrix, m_hSTOESTexSampler,
- m_hSTOESPosition, m_hSTOESAlpha);
- } else if (textureTarget == GL_TEXTURE_EXTERNAL_OES
- && TilesManager::instance()->invertedScreen()) {
- drawLayerQuadInternal(projectionMatrix, textureId, opacity,
- GL_TEXTURE_EXTERNAL_OES, m_surfTexOESProgramInverted,
- m_hSTOESProjectionMatrixInverted, m_hSTOESTexSamplerInverted,
- m_hSTOESPositionInverted, m_hSTOESAlphaInverted,
- m_hSTOESContrastInverted);
+ bool enableBlending = forceBlending || opacity < 1.0;
+
+ ShaderType type = UndefinedShader;
+ if (!textureId) {
+ pureColor = shaderColor(pureColor, opacity);
+ if (pureColor.rgb() == Color::transparent && enableBlending)
+ return;
+ type = PureColor;
+ } else
+ type = getTextureShaderType(textureTarget);
+
+ if (type != UndefinedShader) {
+ setBlendingState(enableBlending);
+ drawQuadInternal(type, projectionMatrix, textureId, opacity,
+ textureTarget, GL_LINEAR, pureColor);
}
- setBlendingState(forceBlending || opacity < 1.0);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
GLUtils::checkGlError("drawLayerQuad");
}
@@ -617,7 +650,7 @@ void ShaderProgram::drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
int textureId)
{
// switch to our custom yuv video rendering program
- glUseProgram(m_videoProgram);
+ glUseProgram(m_handleArray[Video].programHandle);
TransformationMatrix modifiedDrawMatrix = drawMatrix;
modifiedDrawMatrix.translate(geometry.fLeft, geometry.fTop);
@@ -626,16 +659,19 @@ void ShaderProgram::drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
GLfloat projectionMatrix[16];
GLUtils::toGLMatrix(projectionMatrix, renderMatrix);
- glUniformMatrix4fv(m_hVideoProjectionMatrix, 1, GL_FALSE, projectionMatrix);
- glUniformMatrix4fv(m_hVideoTextureMatrix, 1, GL_FALSE, textureMatrix);
+ glUniformMatrix4fv(m_handleArray[Video].projMtxHandle, 1, GL_FALSE,
+ projectionMatrix);
+ glUniformMatrix4fv(m_handleArray[Video].videoMtxHandle, 1, GL_FALSE,
+ textureMatrix);
glActiveTexture(GL_TEXTURE0);
- glUniform1i(m_hVideoTexSampler, 0);
+ glUniform1i(m_handleArray[Video].texSamplerHandle, 0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, textureId);
+ GLint videoPosition = m_handleArray[Video].positionHandle;
glBindBuffer(GL_ARRAY_BUFFER, m_textureBuffer[0]);
- glEnableVertexAttribArray(m_hVideoPosition);
- glVertexAttribPointer(m_hVideoPosition, 2, GL_FLOAT, GL_FALSE, 0, 0);
+ glEnableVertexAttribArray(videoPosition);
+ glVertexAttribPointer(videoPosition, 2, GL_FLOAT, GL_FALSE, 0, 0);
setBlendingState(false);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.h b/Source/WebCore/platform/graphics/android/ShaderProgram.h
index 9ab7a46..3d7aab5 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.h
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.h
@@ -19,6 +19,7 @@
#if USE(ACCELERATED_COMPOSITING)
+#include "Color.h"
#include "FloatRect.h"
#include "IntRect.h"
#include "SkRect.h"
@@ -29,11 +30,60 @@
namespace WebCore {
+enum ShaderType {
+ UndefinedShader = -1,
+ PureColor,
+ Tex2D,
+ Tex2DInv,
+ TexOES,
+ TexOESInv,
+ Video,
+ // When growing this enum list, make sure to insert before the
+ // MaxShaderNumber and init the m_handleArray accordingly.
+ MaxShaderNumber
+};
+
+struct ShaderHandles {
+ ShaderHandles()
+ : alphaHandle(-1)
+ , contrastHandle(-1)
+ , positionHandle(-1)
+ , programHandle(-1)
+ , projMtxHandle(-1)
+ , pureColorHandle(-1)
+ , texSamplerHandle(-1)
+ , videoMtxHandle(-1)
+ {
+ }
+
+ void init(GLint alphaHdl, GLint contrastHdl, GLint posHdl, GLint pgmHdl,
+ GLint projMtxHdl, GLint colorHdl, GLint texSamplerHdl,
+ GLint videoMtxHdl)
+ {
+ alphaHandle = alphaHdl;
+ contrastHandle = contrastHdl;
+ positionHandle = posHdl;
+ programHandle = pgmHdl;
+ projMtxHandle = projMtxHdl;
+ pureColorHandle = colorHdl;
+ texSamplerHandle = texSamplerHdl;
+ videoMtxHandle = videoMtxHdl;
+ }
+
+ GLint alphaHandle;
+ GLint contrastHandle;
+ GLint positionHandle;
+ GLint programHandle;
+ GLint projMtxHandle;
+ GLint pureColorHandle;
+ GLint texSamplerHandle;
+ GLint videoMtxHandle;
+};
+
class ShaderProgram {
public:
ShaderProgram();
void init();
- int program() { return m_program; }
// Drawing
void setViewport(SkRect& viewport, float scale);
@@ -44,19 +94,16 @@ public:
// Normal texture in GL_TEXTURE_2D target.
// 2) textureTarget == GL_TEXTURE_EXTERNAL_OES
// Surface texture in GL_TEXTURE_EXTERNAL_OES target.
- // 3) textureTarget == 0 (Will be deprecated soon)
- // Surface texture in GL_TEXTURE_2D target.
- //
- // TODO: Shrink the support modes into 2 (1 and 2) after media framework
- // support Surface texture in GL_TEXTURE_EXTERNAL_OES target on all
- // platforms.
- void drawQuad(SkRect& geometry, int textureId, float opacity,
+ // 3) textureId == 0
+ // No texture needed, just a pureColor quad.
+ void drawQuad(SkRect& geometry, int textureId, float opacity, Color pureColor = Color(),
GLenum textureTarget = GL_TEXTURE_2D,
GLint texFilter = GL_LINEAR);
void drawLayerQuad(const TransformationMatrix& drawMatrix,
const SkRect& geometry, int textureId, float opacity,
bool forceBlending = false,
- GLenum textureTarget = GL_TEXTURE_2D);
+ GLenum textureTarget = GL_TEXTURE_2D,
+ Color pureColor = Color());
void drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
float* textureMatrix, SkRect& geometry, int textureId);
void setViewRect(const IntRect& viewRect);
@@ -100,33 +147,21 @@ public:
void calculateAnimationDelta();
int getAnimationDeltaX() { return m_animationDelta.x(); }
int getAnimationDeltaY() { return m_animationDelta.y(); }
+ bool needsInit() { return m_needsInit; }
private:
GLuint loadShader(GLenum shaderType, const char* pSource);
- GLuint createProgram(const char* vertexSource, const char* fragmentSource);
- void setProjectionMatrix(SkRect& geometry, GLint projectionMatrixHandle);
-
+ GLint createProgram(const char* vertexSource, const char* fragmentSource);
+ void setProjectionMatrix(const SkRect& geometry, GLfloat* mtxPtr);
void setBlendingState(bool enableBlending);
-
- void drawQuadInternal(SkRect& geometry, GLint textureId, float opacity,
- GLint program, GLint projectionMatrixHandle,
- GLint texSampler, GLenum textureTarget,
- GLint position, GLint alpha,
- GLint texFilter, GLint contrast = -1);
-
- void drawLayerQuadInternal(const GLfloat* projectionMatrix, int textureId,
- float opacity, GLenum textureTarget, GLint program,
- GLint matrix, GLint texSample,
- GLint position, GLint alpha, GLint contrast = -1);
+ void drawQuadInternal(ShaderType type, const GLfloat* matrix, int textureId,
+ float opacity, GLenum textureTarget, GLenum filter,
+ const Color& pureColor);
+ Color shaderColor(Color pureColor, float opacity);
+ ShaderType getTextureShaderType(GLenum textureTarget);
bool m_blendingEnabled;
- int m_program;
- int m_programInverted;
- int m_videoProgram;
- int m_surfTexOESProgram;
- int m_surfTexOESProgramInverted;
-
TransformationMatrix m_projectionMatrix;
GLuint m_textureBuffer[1];
@@ -141,37 +176,9 @@ private:
FloatRect m_documentViewport;
- // uniforms
- GLint m_hProjectionMatrix;
- GLint m_hAlpha;
- GLint m_hTexSampler;
- GLint m_hProjectionMatrixInverted;
- GLint m_hAlphaInverted;
- GLint m_hContrastInverted;
- GLint m_hTexSamplerInverted;
- GLint m_hVideoProjectionMatrix;
- GLint m_hVideoTextureMatrix;
- GLint m_hVideoTexSampler;
-
- GLint m_hSTOESProjectionMatrix;
- GLint m_hSTOESAlpha;
- GLint m_hSTOESTexSampler;
- GLint m_hSTOESPosition;
-
- GLint m_hSTOESProjectionMatrixInverted;
- GLint m_hSTOESAlphaInverted;
- GLint m_hSTOESContrastInverted;
- GLint m_hSTOESTexSamplerInverted;
- GLint m_hSTOESPositionInverted;
-
float m_contrast;
- // attribs
- GLint m_hPosition;
- GLint m_hPositionInverted;
- GLint m_hVideoPosition;
-
- bool m_alphaLayer;
+ bool m_alphaLayer;
TransformationMatrix m_webViewMatrix;
float m_currentScale;
@@ -184,8 +191,21 @@ private:
// TODO: Given that m_webViewMatrix contains most of the tranformation
// information, we should be able to get rid of some parameter we got from
// Java side and simplify our code.
- TransformationMatrix m_repositionMatrix;
+ TransformationMatrix m_repositionMatrix;
IntPoint m_animationDelta;
+
+ // Put all the uniform location (handle) info into an array, and group them
+ // by the shader's type, this can help to clean up the interface.
+ // TODO: use the type and data comparison to skip GL call if possible.
+ ShaderHandles m_handleArray[MaxShaderNumber];
+
+ // If there is any GL error happens such that the Shaders are not initialized
+ // successfully at the first time, then we need to init again when we draw.
+ bool m_needsInit;
+
+ // For transfer queue blitting, we need a special matrix map from (0,1) to
+ // (-1,1)
+ GLfloat m_transferProjMtx[16];
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/SharedTexture.cpp b/Source/WebCore/platform/graphics/android/SharedTexture.cpp
deleted file mode 100644
index 74cd2c6..0000000
--- a/Source/WebCore/platform/graphics/android/SharedTexture.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SharedTexture.h"
-
-#include "GLUtils.h"
-#include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
-#include <gui/SurfaceTextureClient.h>
-
-#define LOG_NDEBUG 1
-#define LOG_TAG "SharedTexture.cpp"
-#include <utils/Log.h>
-
-namespace WebCore {
-
-SharedTexture::SharedTexture(SharedTextureMode mode)
-{
- m_sharedTextureMode = mode;
-
- m_sourceTexture = new TextureInfo(m_sharedTextureMode);
- m_targetTexture = 0;
-
- if (m_sharedTextureMode == EglImageMode) {
- m_targetTexture = new TextureInfo(m_sharedTextureMode);
- m_eglImage = EGL_NO_IMAGE_KHR;
- m_isNewImage = true;
- m_syncObject = EGL_NO_SYNC_KHR;
-
- // Defer initialization of these values until we initialize the source
- // texture. This ensures that this initialization happens in the appropriate
- // thread.
- m_display = 0;
- m_supportsEGLImage = false;
- m_supportsEGLFenceSyncKHR = false;
- } else if (m_sharedTextureMode == SurfaceTextureMode) {
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- glGenTextures(1, &m_sourceTexture->m_textureId);
-
- m_sourceTexture->m_surfaceTexture =
- new android::SurfaceTexture(m_sourceTexture->m_textureId, false);
- m_sourceTexture->m_ANW =
- new android::SurfaceTextureClient(m_sourceTexture->m_surfaceTexture);
-#endif
- }
-}
-
-// called by the consumer when it no longer wants to consume and after it has
-// terminated all providers. If EGLImages are used, the deletion of the
-// source texture and EGLImage is the responsibility of the caller.
-SharedTexture::~SharedTexture()
-{
- if (m_sharedTextureMode == EglImageMode)
- deleteTargetTexture();
- else if (m_sharedTextureMode == SurfaceTextureMode) {
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- m_sourceTexture->m_surfaceTexture.clear();
- m_sourceTexture->m_ANW.clear();
- GLUtils::deleteTexture(&m_sourceTexture->m_textureId);
-#endif
- }
- delete m_sourceTexture;
- delete m_targetTexture;
-}
-
-
-void SharedTexture::initSourceTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- m_display = eglGetCurrentDisplay();
- m_supportsEGLImage = GLUtils::isEGLImageSupported();
- m_supportsEGLFenceSyncKHR = GLUtils::isEGLFenceSyncSupported();
-
- // TODO temporarily disable fence sync until the EGL framework fixes
- // performance issues that result from consistently adding/removing fences.
- m_supportsEGLFenceSyncKHR = false;
-
- LOGI("imageEGL: %d syncKHR: %d", m_supportsEGLImage, m_supportsEGLFenceSyncKHR);
-
- glGenTextures(1, &m_sourceTexture->m_textureId);
-
-}
-
-// For MediaTexture only
-void SharedTexture::deleteSourceTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
- // We need to delete the source texture and EGLImage in the thread in which
- // it was created. In theory we should be able to delete the EGLImage
- // from either thread, but it currently throws an error if not deleted
- // in the same EGLContext from which it was created.
- if (m_supportsEGLImage) {
- GLUtils::deleteTexture(&m_sourceTexture->m_textureId);
- if (m_eglImage != EGL_NO_IMAGE_KHR) {
- eglDestroyImageKHR(eglGetCurrentDisplay(), m_eglImage);
- m_eglImage = EGL_NO_IMAGE_KHR;
- m_isNewImage = true;
- }
- LOGI("Deleted Source Texture and EGLImage");
- }
-}
-
-// For MediaTexture only
-void SharedTexture::deleteTargetTexture()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- if (m_supportsEGLImage)
- GLUtils::deleteTexture(&m_targetTexture->m_textureId);
- else
- GLUtils::deleteTexture(&m_sourceTexture->m_textureId);
-}
-
-TextureInfo* SharedTexture::lockSource()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return m_sourceTexture;
-
- m_lock.lock();
-
- if (m_supportsEGLFenceSyncKHR && m_syncObject != EGL_NO_SYNC_KHR) {
-
- EGLint status = eglClientWaitSyncKHR(m_display, m_syncObject, 0, 1000000);
-
- if (status == EGL_TIMEOUT_EXPIRED_KHR)
- LOGE("Sync timeout for shared texture (%d)", m_sourceTexture->m_textureId);
-
- eglDestroySyncKHR(m_display, m_syncObject);
- m_syncObject = EGL_NO_SYNC_KHR;
- }
- return m_sourceTexture;
-}
-
-void SharedTexture::releaseSource()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- if (m_supportsEGLImage) {
- // delete the existing image if needed
- if (!m_sourceTexture->equalsAttributes(m_targetTexture)) {
- if (m_eglImage != EGL_NO_IMAGE_KHR) {
- eglDestroyImageKHR(m_display, m_eglImage);
- m_eglImage = EGL_NO_IMAGE_KHR;
- m_isNewImage = true;
- }
- m_targetTexture->copyAttributes(m_sourceTexture);
- }
-
- // create an image from the texture, only when the texture is valid
- if (m_eglImage == EGL_NO_IMAGE_KHR && m_sourceTexture->m_width
- && m_sourceTexture->m_height) {
- GLUtils::createEGLImageFromTexture(m_sourceTexture->m_textureId, &m_eglImage);
- LOGV("Generating Image (%d) 0x%x", m_sourceTexture->m_textureId, m_eglImage);
-
- glFinish(); // ensures the texture is ready to be used by the consumer
- }
-
- } else {
-
- m_targetTexture = m_sourceTexture;
-
- // in the case of shared contexts we must flush the texture edits to the
- // GPU. This ensures the edits complete prior to allowing the texture to
- // be bound on the producers context.
- glFlush();
- }
-
- m_lock.unlock();
-}
-
-TextureInfo* SharedTexture::lockTarget()
-{
- // Note that the source and targe are the same when using Surface Texture.
- if (m_sharedTextureMode == SurfaceTextureMode) {
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- m_sourceTexture->m_surfaceTexture->updateTexImage();
-#endif
- return m_sourceTexture;
- }
-
- m_lock.lock();
-
- if ((!m_supportsEGLImage && m_targetTexture->m_textureId == GL_NO_TEXTURE)
- || (m_supportsEGLImage && m_eglImage == EGL_NO_IMAGE_KHR)) {
- m_lock.unlock();
- return 0;
- }
-
- if (m_supportsEGLImage && (m_isNewImage || m_targetTexture->m_textureId == GL_NO_TEXTURE)) {
- if (m_targetTexture->m_textureId == GL_NO_TEXTURE)
- glGenTextures(1, &m_targetTexture->m_textureId);
-
- GLUtils::createTextureFromEGLImage(m_targetTexture->m_textureId, m_eglImage);
- LOGV("Generating Consumer Texture from 0x%x", m_eglImage);
- m_isNewImage = false;
- }
- return m_targetTexture;
-}
-
-void SharedTexture::releaseTarget()
-{
- if (m_sharedTextureMode == SurfaceTextureMode)
- return;
-
- if (m_supportsEGLFenceSyncKHR) {
- if (m_syncObject != EGL_NO_SYNC_KHR)
- eglDestroySyncKHR(m_display, m_syncObject);
- m_syncObject = eglCreateSyncKHR(m_display, EGL_SYNC_FENCE_KHR, 0);
- } else {
- // TODO the flush currently prevents the screen from getting partial
- // updates but the only way to guarantee this is to call glFinish. Until
- // we support an EGL sync we will leave flush enable in order to test
- // with modest performance.
- glFlush();
- }
-
- m_lock.unlock();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/SharedTexture.h b/Source/WebCore/platform/graphics/android/SharedTexture.h
deleted file mode 100644
index 305a442..0000000
--- a/Source/WebCore/platform/graphics/android/SharedTexture.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SharedTexture_h
-#define SharedTexture_h
-
-#include "TextureInfo.h"
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include <utils/threads.h>
-
-namespace WebCore {
-
-/**
- * SharedTexture is a class that encapsulates all the necessary variables
- * needed to share a single texture across threads. In the case that threads
- * communicate using EGL's sharedContext mechanism or do not support the proper
- * EGLImage extensions the targetTexture, eglImage, and isNewImage variables are
- * not used.
- */
-class SharedTexture {
-public:
- // consumer thread functions
- SharedTexture(SharedTextureMode mode);
- ~SharedTexture();
-
- TextureInfo* lockSource();
- void releaseSource();
-
- TextureInfo* lockTarget();
- void releaseTarget();
-
- // these locks are only used for the methods below
- void lock() { m_lock.lock(); }
- void unlock() { m_lock.unlock(); }
-
- void initSourceTexture(); // producer thread only
- void deleteSourceTexture(); // producer thread only
- void deleteTargetTexture(); // consumer thread only
- GLuint getSourceTextureId() { return m_sourceTexture->m_textureId; }
- GLuint getTargetTextureId() { return m_targetTexture->m_textureId; }
- EGLImageKHR getEGLImage() { return m_eglImage; }
-
-private:
- /**
- * The mutex is used to ensure that the contents of the struct are current across
- * threads and that only one thread is manipulating the texture at a given time.
- */
- android::Mutex m_lock;
- /**
- * The texture and its associated metadata that is used by the producer. The
- * texture is created in the producer's thread and can only be read by the
- * consumer when the consumer shares the same context as the producer. The
- * metadata is used to track changes to the texture that would orphan the
- * target texture and require a new EGLImage to be constructed.
- */
- TextureInfo* m_sourceTexture;
- /**
- * The target texture stores the id and metadata of the texture that is to be
- * used by the consumer. In the case where EGLImages are supported this hold
- * the current eglImage target.
- */
- TextureInfo* m_targetTexture;
- /**
- * The EGLImage is used to share the texture between EGLContexts on two
- * different threads. This serves as an alternative to sharing the contexts
- * but is only used if GL and EGL support the required extensions.
- */
- EGLImageKHR m_eglImage;
- /**
- * This flag is used to determine if the eglImage has been updated. This
- * signals the consumer thread to rebind the targetTexture to the new image.
- */
- bool m_isNewImage;
- /**
- * The sync allows the consumer to release the lock prior to the commands
- * executing on the GPU. Prior to releasing the lock the consumer creates
- * a sync object and stores it here. After locking the texture the client
- * must check that the sync has completed prior to manipulating the texture.
- * This value is only used if the proper EGL extensions are supported.
- */
- EGLSyncKHR m_syncObject;
-
- EGLDisplay m_display;
-
- bool m_supportsEGLImage;
- bool m_supportsEGLFenceSyncKHR;
-
- SharedTextureMode m_sharedTextureMode;
-};
-
-} // namespace WebCore
-
-#endif // SharedTexture_h
diff --git a/Source/WebCore/platform/graphics/android/TextureInfo.cpp b/Source/WebCore/platform/graphics/android/TextureInfo.cpp
index 5356dcb..3c4dde2 100644
--- a/Source/WebCore/platform/graphics/android/TextureInfo.cpp
+++ b/Source/WebCore/platform/graphics/android/TextureInfo.cpp
@@ -35,13 +35,12 @@
namespace WebCore {
-TextureInfo::TextureInfo(SharedTextureMode mode)
+TextureInfo::TextureInfo()
{
m_textureId = GL_NO_TEXTURE;
m_width = 0;
m_height = 0;
m_internalFormat = 0;
- m_sharedTextureMode = mode;
m_eglSurface = EGL_NO_SURFACE;
m_pictureCount = 0;
}
diff --git a/Source/WebCore/platform/graphics/android/TextureInfo.h b/Source/WebCore/platform/graphics/android/TextureInfo.h
index 1c48937..8549365 100644
--- a/Source/WebCore/platform/graphics/android/TextureInfo.h
+++ b/Source/WebCore/platform/graphics/android/TextureInfo.h
@@ -34,8 +34,6 @@
#include "BaseTile.h"
using android::sp;
-#define DEPRECATED_SURFACE_TEXTURE_MODE 0
-
namespace android {
class SurfaceTexture;
}
@@ -47,20 +45,14 @@ static const GLuint GL_NO_TEXTURE = 0;
* TextureInfo is a class that stores both the texture and metadata about the
* texture.
*/
-enum SharedTextureMode {
- EglImageMode,
- SurfaceTextureMode
-};
class TextureInfo {
public:
-
- TextureInfo(SharedTextureMode mode);
+ TextureInfo();
bool equalsAttributes(const TextureInfo* otherTexture);
void copyAttributes(const TextureInfo* sourceTexture);
- SharedTextureMode getSharedTextureMode() { return m_sharedTextureMode; }
bool operator==(const TextureInfo& otherTexture);
GLuint m_textureId;
@@ -68,18 +60,12 @@ public:
int32_t m_height;
GLenum m_internalFormat;
- // Surface Texture specific data
-#if DEPRECATED_SURFACE_TEXTURE_MODE
- sp<android::SurfaceTexture> m_surfaceTexture;
-#endif
// TODO: Delete this after the Ganesh code path get fixed.
sp<ANativeWindow> m_ANW;
// The EGLSurface wraps the m_ANW to enable direct OpenGL rendering (e.g. Ganesh)
EGLSurface m_eglSurface;
int m_pictureCount;
-private:
- SharedTextureMode m_sharedTextureMode;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp
index 31a0593..8c43fc4 100644
--- a/Source/WebCore/platform/graphics/android/TiledPage.cpp
+++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp
@@ -93,9 +93,13 @@ void TiledPage::updateBaseTileSize()
TiledPage::~TiledPage()
{
+ TilesManager* tilesManager = TilesManager::instance();
// In order to delete the page we must ensure that none of its BaseTiles are
// currently painting or scheduled to be painted by the TextureGenerator
- TilesManager::instance()->removeOperationsForPage(this);
+ tilesManager->removeOperationsForPage(this);
+ // Discard the transfer queue after the removal operation to make sure
+ // no tiles for this page will be left in the transfer queue.
+ tilesManager->transferQueue()->setPendingDiscardWithLock();
delete[] m_baseTiles;
#ifdef DEBUG_COUNT
ClassTracker::instance()->decrement("TiledPage");
@@ -276,8 +280,8 @@ void TiledPage::prepare(bool goingDown, bool goingLeft, const SkIRect& tileBound
nbTilesHeight += firstTileY;
firstTileY = 0;
}
- nbTilesWidth = std::min(nbTilesWidth, maxX - firstTileX);
- nbTilesHeight = std::min(nbTilesHeight, maxY - firstTileY);
+ nbTilesWidth = std::min(nbTilesWidth, maxX - firstTileX + 1);
+ nbTilesHeight = std::min(nbTilesHeight, maxY - firstTileY + 1);
// check against corrupted scale values giving bad height/width (use float to avoid overflow)
float numTiles = static_cast<float>(nbTilesHeight) * static_cast<float>(nbTilesWidth);
diff --git a/Source/WebCore/platform/graphics/android/TiledTexture.cpp b/Source/WebCore/platform/graphics/android/TiledTexture.cpp
index d538416..3696b4a 100644
--- a/Source/WebCore/platform/graphics/android/TiledTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/TiledTexture.cpp
@@ -99,13 +99,13 @@ void TiledTexture::swapTiles()
XLOG("TT %p swapping, swaps = %d", this, swaps);
}
-IntRect TiledTexture::computeTilesArea(IntRect& visibleArea, float scale)
+IntRect TiledTexture::computeTilesArea(IntRect& contentArea, float scale)
{
IntRect computedArea;
- IntRect area(visibleArea.x() * scale,
- visibleArea.y() * scale,
- ceilf(visibleArea.width() * scale),
- ceilf(visibleArea.height() * scale));
+ IntRect area(contentArea.x() * scale,
+ contentArea.y() * scale,
+ ceilf(contentArea.width() * scale),
+ ceilf(contentArea.height() * scale));
XLOG("TT %p prepare, scale %f, area %d x %d", this, scale, area.width(), area.height());
@@ -128,21 +128,21 @@ IntRect TiledTexture::computeTilesArea(IntRect& visibleArea, float scale)
}
void TiledTexture::prepare(GLWebViewState* state, float scale, bool repaint,
- bool startFastSwap, IntRect& visibleArea)
+ bool startFastSwap, IntRect& prepareArea)
{
if (!m_surface)
return;
// first, how many tiles do we need
- m_area = computeTilesArea(visibleArea, scale);
+ m_area = computeTilesArea(prepareArea, scale);
if (m_area.isEmpty())
return;
- XLOG("for TiledTexture %p, we prepare with scale %.2f, have a visible area of "
+ XLOG("for TiledTexture %p, we prepare with scale %.2f, have a prepare area of "
" %d, %d - %d x %d, corresponding to %d, %d x - %d x %d tiles",
this, scale,
- visibleArea.x(), visibleArea.y(),
- visibleArea.width(), visibleArea.height(),
+ prepareArea.x(), prepareArea.y(),
+ prepareArea.width(), prepareArea.height(),
m_area.x(), m_area.y(),
m_area.width(), m_area.height());
@@ -239,7 +239,7 @@ int TiledTexture::nbTextures(IntRect& area, float scale)
return numberTextures;
}
-bool TiledTexture::draw()
+bool TiledTexture::draw(IntRect& visibleArea)
{
if (!m_surface)
return true;
@@ -250,6 +250,7 @@ bool TiledTexture::draw()
TilesManager::instance()->getTilesTracker()->trackLayer();
#endif
+ m_area = computeTilesArea(visibleArea, m_scale);
if (m_area.width() == 0 || m_area.height() == 0)
return false;
@@ -358,12 +359,12 @@ DualTiledTexture::~DualTiledTexture()
}
void DualTiledTexture::prepare(GLWebViewState* state, float scale, bool repaint,
- bool startFastSwap, IntRect& visibleArea)
+ bool startFastSwap, IntRect& prepareArea)
{
// If we are zooming, we will use the previously used area, to prevent the
// frontTexture to try to allocate more tiles than what it has already
if (!m_zooming)
- m_preZoomVisibleArea = visibleArea;
+ m_preZoomPrepareArea = prepareArea;
if (m_futureScale != scale) {
m_futureScale = scale;
@@ -375,11 +376,11 @@ void DualTiledTexture::prepare(GLWebViewState* state, float scale, bool repaint,
this, scale, m_scale, m_futureScale, m_zooming);
if (m_scale > 0)
- m_frontTexture->prepare(state, m_scale, repaint, startFastSwap, m_preZoomVisibleArea);
+ m_frontTexture->prepare(state, m_scale, repaint, startFastSwap, m_preZoomPrepareArea);
// If we had a scheduled update
if (m_zooming && m_zoomUpdateTime < WTF::currentTime()) {
- m_backTexture->prepare(state, m_futureScale, repaint, startFastSwap, visibleArea);
+ m_backTexture->prepare(state, m_futureScale, repaint, startFastSwap, prepareArea);
if (m_backTexture->ready()) {
m_backTexture->swapTiles();
swap();
@@ -396,9 +397,9 @@ void DualTiledTexture::swap()
m_backTexture->discardTextures();
}
-bool DualTiledTexture::draw()
+bool DualTiledTexture::draw(IntRect& visibleArea)
{
- bool needsRepaint = m_frontTexture->draw();
+ bool needsRepaint = m_frontTexture->draw(visibleArea);
needsRepaint |= m_zooming;
needsRepaint |= (m_scale <= 0);
return needsRepaint;
diff --git a/Source/WebCore/platform/graphics/android/TiledTexture.h b/Source/WebCore/platform/graphics/android/TiledTexture.h
index 444ab14..971a99f 100644
--- a/Source/WebCore/platform/graphics/android/TiledTexture.h
+++ b/Source/WebCore/platform/graphics/android/TiledTexture.h
@@ -57,12 +57,12 @@ public:
virtual ~TiledTexture();
- IntRect computeTilesArea(IntRect& visibleArea, float scale);
+ IntRect computeTilesArea(IntRect& contentArea, float scale);
void prepare(GLWebViewState* state, float scale, bool repaint,
- bool startFastSwap, IntRect& visibleArea);
+ bool startFastSwap, IntRect& prepareArea);
void swapTiles();
- bool draw();
+ bool draw(IntRect& visibleArea);
void prepareTile(bool repaint, int x, int y);
void update(const SkRegion& dirtyArea, SkPicture* picture);
@@ -114,7 +114,7 @@ public:
bool startFastSwap, IntRect& area);
void swapTiles();
void swap();
- bool draw();
+ bool draw(IntRect& visibleArea);
void update(const SkRegion& dirtyArea, SkPicture* picture);
bool owns(BaseTileTexture* texture);
bool isReady()
@@ -142,7 +142,7 @@ private:
float m_futureScale;
double m_zoomUpdateTime;
bool m_zooming;
- IntRect m_preZoomVisibleArea;
+ IntRect m_preZoomPrepareArea;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp
index 62324d7..082f0bc 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp
@@ -96,6 +96,7 @@ int TilesManager::getMaxTextureAllocation()
TilesManager::TilesManager()
: m_layerTexturesRemain(true)
+ , m_highEndGfx(false)
, m_maxTextureCount(0)
, m_maxLayerTextureCount(0)
, m_generatorReady(false)
@@ -103,6 +104,8 @@ TilesManager::TilesManager()
, m_invertedScreen(false)
, m_invertedScreenSwitch(false)
, m_useMinimalMemory(true)
+ , m_useDoubleBuffering(true)
+ , m_treeUpdates(0)
, m_drawGLCount(1)
, m_lastTimeLayersUsed(0)
, m_hasLayerTextures(false)
@@ -155,7 +158,7 @@ void TilesManager::allocateTiles()
m_tilesTextures.size() * LAYER_TILE_WIDTH * LAYER_TILE_HEIGHT * 4 / 1024 / 1024);
}
-void TilesManager::deallocateTextures(bool allTextures)
+void TilesManager::discardTextures(bool allTextures, bool glTextures)
{
const unsigned int max = m_textures.size();
@@ -169,24 +172,32 @@ void TilesManager::deallocateTextures(bool allTextures)
sparedDrawCount = std::max(sparedDrawCount, owner->drawCount());
}
}
- deallocateTexturesVector(sparedDrawCount, m_textures);
- deallocateTexturesVector(sparedDrawCount, m_tilesTextures);
+ discardTexturesVector(sparedDrawCount, m_textures, glTextures);
+ discardTexturesVector(sparedDrawCount, m_tilesTextures, glTextures);
}
-void TilesManager::deallocateTexturesVector(unsigned long long sparedDrawCount,
- WTF::Vector<BaseTileTexture*>& textures)
+void TilesManager::discardTexturesVector(unsigned long long sparedDrawCount,
+ WTF::Vector<BaseTileTexture*>& textures,
+ bool deallocateGLTextures)
{
const unsigned int max = textures.size();
int dealloc = 0;
for (unsigned int i = 0; i < max; i++) {
TextureOwner* owner = textures[i]->owner();
if (!owner || owner->drawCount() < sparedDrawCount) {
- textures[i]->discardGLTexture();
+ if (deallocateGLTextures) {
+ // deallocate textures' gl memory
+ textures[i]->discardGLTexture();
+ } else if (owner) {
+ // simply detach textures from owner
+ static_cast<BaseTile*>(owner)->discardTextures();
+ }
dealloc++;
}
}
- XLOG("Deallocated %d gl textures (out of %d base tiles and %d layer tiles)",
- dealloc, max, maxLayer);
+ XLOG("Discarded %d %s textures (out of %d %s tiles)",
+ dealloc, (deallocateGLTextures ? "gl" : ""),
+ max, (textures == m_textures) ? "base" : "layer");
}
void TilesManager::gatherTexturesNumbers(int* nbTextures, int* nbAllocatedTextures,
@@ -221,9 +232,9 @@ void TilesManager::printTextures()
x = o->x();
y = o->y();
}
- XLOG("[%d] texture %x busy: %d owner: %x (%d, %d) page: %x scale: %.2f",
+ XLOG("[%d] texture %x owner: %x (%d, %d) page: %x scale: %.2f",
i, texture,
- texture->busy(), o, x, y, o ? o->page() : 0, o ? o->scale() : 0);
+ o, x, y, o ? o->page() : 0, o ? o->scale() : 0);
}
XLOG("------");
#endif // DEBUG
@@ -285,12 +296,6 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner)
for (unsigned int i = 0; i < max; i++) {
BaseTileTexture* texture = (*availableTexturePool)[i];
BaseTile* currentOwner = static_cast<BaseTile*>(texture->owner());
-
- if (texture->busy()) {
- // don't bother, since the acquire() will likely fail
- continue;
- }
-
if (!currentOwner) {
// unused texture! take it!
farthestTexture = texture;
@@ -352,6 +357,16 @@ BaseTileTexture* TilesManager::getAvailableTexture(BaseTile* owner)
return 0;
}
+void TilesManager::setHighEndGfx(bool highEnd)
+{
+ m_highEndGfx = highEnd;
+}
+
+bool TilesManager::highEndGfx()
+{
+ return m_highEndGfx;
+}
+
int TilesManager::maxTextureCount()
{
android::Mutex::Autolock lock(m_texturesLock);
@@ -390,7 +405,8 @@ void TilesManager::setMaxLayerTextureCount(int max)
double secondsSinceLayersUsed = WTF::currentTime() - m_lastTimeLayersUsed;
if (secondsSinceLayersUsed > LAYER_TEXTURES_DESTROY_TIMEOUT) {
unsigned long long sparedDrawCount = ~0; // by default, spare no textures
- deallocateTexturesVector(sparedDrawCount, m_tilesTextures);
+ bool deleteGLTextures = true;
+ discardTexturesVector(sparedDrawCount, m_tilesTextures, deleteGLTextures);
m_hasLayerTextures = false;
}
return;
@@ -476,13 +492,6 @@ void TilesManager::paintedSurfacesCleanup(GLWebViewState* state)
}
}
-void TilesManager::unregisterGLWebViewState(GLWebViewState* state)
-{
- // Discard the whole queue b/c we lost GL context already.
- // Note the real updateTexImage will still wait for the next draw.
- transferQueue()->discardQueue();
-}
-
TilesManager* TilesManager::instance()
{
if (!gInstance) {
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.h b/Source/WebCore/platform/graphics/android/TilesManager.h
index 9782fbb..855994d 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.h
+++ b/Source/WebCore/platform/graphics/android/TilesManager.h
@@ -106,6 +106,10 @@ public:
void resetTextureUsage(TiledPage* page);
+ // m_highEndGfx is written/read only on UI thread, no need for a lock.
+ void setHighEndGfx(bool highEnd);
+ bool highEndGfx();
+
int maxTextureCount();
int maxLayerTextureCount();
void setMaxTextureCount(int max);
@@ -115,12 +119,11 @@ public:
static float layerTileWidth();
static float layerTileHeight();
void paintedSurfacesCleanup(GLWebViewState* state = 0);
- void unregisterGLWebViewState(GLWebViewState* state);
void allocateTiles();
- // Called when webview is hidden to discard graphics memory
- void deallocateTextures(bool allTextures);
+ // remove all tiles from textures (and optionally deallocate gl memory)
+ void discardTextures(bool allTextures, bool glTextures);
bool getShowVisualIndicator()
{
@@ -132,11 +135,6 @@ public:
m_showVisualIndicator = showVisualIndicator;
}
- SharedTextureMode getSharedTextureMode()
- {
- return SurfaceTextureMode;
- }
-
TilesProfiler* getProfiler()
{
return &m_profiler;
@@ -184,6 +182,16 @@ public:
return m_useMinimalMemory;
}
+ void setUseDoubleBuffering(bool useDoubleBuffering)
+ {
+ m_useDoubleBuffering = useDoubleBuffering;
+ }
+ bool useDoubleBuffering() { return m_useDoubleBuffering; }
+
+ void incTreeUpdates() { m_treeUpdates++; }
+ unsigned int getTreeUpdates() { return m_treeUpdates; }
+ void clearTreeUpdates() { m_treeUpdates = 0; }
+
void incDrawGLCount()
{
m_drawGLCount++;
@@ -209,8 +217,9 @@ private:
m_generatorReadyCond.wait(m_generatorLock);
}
- void deallocateTexturesVector(unsigned long long sparedDrawCount,
- WTF::Vector<BaseTileTexture*>& textures);
+ void discardTexturesVector(unsigned long long sparedDrawCount,
+ WTF::Vector<BaseTileTexture*>& textures,
+ bool deallocateGLTextures);
Vector<BaseTileTexture*> m_textures;
Vector<BaseTileTexture*> m_availableTextures;
@@ -221,6 +230,7 @@ private:
Vector<PaintedSurface*> m_paintedSurfaces;
+ bool m_highEndGfx;
int m_maxTextureCount;
int m_maxLayerTextureCount;
@@ -232,6 +242,9 @@ private:
bool m_useMinimalMemory;
+ bool m_useDoubleBuffering;
+ unsigned int m_treeUpdates;
+
sp<TexturesGenerator> m_pixmapsGenerationThread;
android::Mutex m_texturesLock;
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
index b20ec7a..00f851b 100644
--- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp
+++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
@@ -77,27 +77,48 @@ TransferQueue::TransferQueue()
TransferQueue::~TransferQueue()
{
- glDeleteFramebuffers(1, &m_fboID);
- m_fboID = 0;
- glDeleteTextures(1, &m_sharedSurfaceTextureId);
- m_sharedSurfaceTextureId = 0;
-
+ android::Mutex::Autolock lock(m_transferQueueItemLocks);
+ cleanupGLResources();
delete[] m_transferQueue;
}
-void TransferQueue::initSharedSurfaceTextures(int width, int height)
+// This should be called within the m_transferQueueItemLocks.
+// Now only called by emptyQueue() and destructor.
+void TransferQueue::cleanupGLResources()
{
+ if (m_sharedSurfaceTexture.get()) {
+ m_sharedSurfaceTexture->abandon();
+ m_sharedSurfaceTexture.clear();
+ }
+ if (m_fboID) {
+ glDeleteFramebuffers(1, &m_fboID);
+ m_fboID = 0;
+ }
+ if (m_sharedSurfaceTextureId) {
+ glDeleteTextures(1, &m_sharedSurfaceTextureId);
+ m_sharedSurfaceTextureId = 0;
+ }
+}
+
+void TransferQueue::initGLResources(int width, int height)
+{
+ android::Mutex::Autolock lock(m_transferQueueItemLocks);
if (!m_sharedSurfaceTextureId) {
glGenTextures(1, &m_sharedSurfaceTextureId);
m_sharedSurfaceTexture =
#if GPU_UPLOAD_WITHOUT_DRAW
- new android::SurfaceTexture(m_sharedSurfaceTextureId, true, GL_TEXTURE_2D);
+ new android::SurfaceTexture(m_sharedSurfaceTextureId, true,
+ GL_TEXTURE_2D, false);
#else
new android::SurfaceTexture(m_sharedSurfaceTextureId);
#endif
m_ANW = new android::SurfaceTextureClient(m_sharedSurfaceTexture);
m_sharedSurfaceTexture->setSynchronousMode(true);
- m_sharedSurfaceTexture->setBufferCount(ST_BUFFER_NUMBER+1);
+
+ int extraBuffersNeeded = 0;
+ m_ANW->query(m_ANW.get(), NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
+ &extraBuffersNeeded);
+ m_sharedSurfaceTexture->setBufferCount(ST_BUFFER_NUMBER + extraBuffersNeeded);
int result = native_window_set_buffers_geometry(m_ANW.get(),
width, height, HAL_PIXEL_FORMAT_RGBA_8888);
@@ -114,9 +135,9 @@ void TransferQueue::initSharedSurfaceTextures(int width, int height)
// When bliting, if the item from the transfer queue is mismatching b/t the
// BaseTile and the content, then the item is considered as obsolete, and
// the content is discarded.
-bool TransferQueue::checkObsolete(int index)
+bool TransferQueue::checkObsolete(const TileTransferData* data)
{
- BaseTile* baseTilePtr = m_transferQueue[index].savedBaseTilePtr;
+ BaseTile* baseTilePtr = data->savedBaseTilePtr;
if (!baseTilePtr) {
XLOG("Invalid savedBaseTilePtr , such that the tile is obsolete");
return true;
@@ -128,7 +149,7 @@ bool TransferQueue::checkObsolete(int index)
return true;
}
- const TextureTileInfo* tileInfo = &m_transferQueue[index].tileInfo;
+ const TextureTileInfo* tileInfo = &(data->tileInfo);
if (tileInfo->m_x != baseTilePtr->x()
|| tileInfo->m_y != baseTilePtr->y()
@@ -142,20 +163,46 @@ bool TransferQueue::checkObsolete(int index)
}
void TransferQueue::blitTileFromQueue(GLuint fboID, BaseTileTexture* destTex,
+ BaseTileTexture* frontTex,
GLuint srcTexId, GLenum srcTexTarget,
int index)
{
#if GPU_UPLOAD_WITHOUT_DRAW
glBindFramebuffer(GL_FRAMEBUFFER, fboID);
+ glBindTexture(GL_TEXTURE_2D, destTex->m_ownTextureId);
+
+ int textureWidth = destTex->getSize().width();
+ int textureHeight = destTex->getSize().height();
+
+ IntRect inval = m_transferQueue[index].tileInfo.m_inval;
+ bool partialInval = !inval.isEmpty();
+
+ if (partialInval && frontTex) {
+ // recopy the previous texture to the new one, as
+ // the partial update will not cover the entire texture
+ glFramebufferTexture2D(GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D,
+ frontTex->m_ownTextureId,
+ 0);
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0,
+ textureWidth, textureHeight);
+ }
+
glFramebufferTexture2D(GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D,
srcTexId,
0);
- glBindTexture(GL_TEXTURE_2D, destTex->m_ownTextureId);
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0,
- destTex->getSize().width(),
- destTex->getSize().height());
+
+ if (!partialInval) {
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0,
+ textureWidth, textureHeight);
+ } else {
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, inval.x(), inval.y(), 0, 0,
+ inval.width(), inval.height());
+ }
+
#else
// Then set up the FBO and copy the SurfTex content in.
glBindFramebuffer(GL_FRAMEBUFFER, fboID);
@@ -256,15 +303,33 @@ void TransferQueue::setHasGLContext(bool hasContext)
m_hasGLContext = hasContext;
}
-// Only called when WebView is destroyed or switching the uploadType.
-void TransferQueue::discardQueue()
+void TransferQueue::setPendingDiscardWithLock()
{
android::Mutex::Autolock lock(m_transferQueueItemLocks);
+ setPendingDiscard();
+}
+
+void TransferQueue::emptyQueue()
+{
+ android::Mutex::Autolock lock(m_transferQueueItemLocks);
+ setPendingDiscard();
+ cleanupPendingDiscard();
+ cleanupGLResources();
+}
+// Set all the content in the queue to pendingDiscard, after this, there will
+// be nothing added to the queue, and this can be called in any thread.
+// However, in order to discard the content in the Surface Texture using
+// updateTexImage, cleanupPendingDiscard need to be called on the UI thread.
+// Must be called within a m_transferQueueItemLocks.
+void TransferQueue::setPendingDiscard()
+{
for (int i = 0 ; i < ST_BUFFER_NUMBER; i++)
if (m_transferQueue[i].status == pendingBlit)
m_transferQueue[i].status = pendingDiscard;
+ m_pureColorTileQueue.clear();
+
bool GLContextExisted = getHasGLContext();
// Unblock the Tex Gen thread first before Tile Page deletion.
// Otherwise, there will be a deadlock while removing operations.
@@ -275,15 +340,38 @@ void TransferQueue::discardQueue()
m_transferQueueItemCond.signal();
}
+void TransferQueue::updatePureColorTiles()
+{
+ for (unsigned int i = 0 ; i < m_pureColorTileQueue.size(); i++) {
+ TileTransferData* data = &m_pureColorTileQueue[i];
+ if (data->status == pendingBlit) {
+ BaseTileTexture* destTexture = 0;
+ bool obsoleteBaseTile = checkObsolete(data);
+ if (!obsoleteBaseTile) {
+ destTexture = data->savedBaseTilePtr->backTexture();
+ destTexture->setPureColor(data->pureColor);
+ destTexture->setOwnTextureTileInfoFromQueue(&data->tileInfo);
+ }
+ } else if (data->status == emptyItem || data->status == pendingDiscard) {
+ // The queue should be clear instead of setting to different status.
+ XLOG("Warning: Don't expect an emptyItem here.");
+ }
+ }
+ m_pureColorTileQueue.clear();
+}
+
// Call on UI thread to copy from the shared Surface Texture to the BaseTile's texture.
void TransferQueue::updateDirtyBaseTiles()
{
android::Mutex::Autolock lock(m_transferQueueItemLocks);
- cleanupTransportQueue();
+ cleanupPendingDiscard();
if (!getHasGLContext())
setHasGLContext(true);
+ // Check the pure color tile first, since it is simpler.
+ updatePureColorTiles();
+
// Start from the oldest item, we call the updateTexImage to retrive
// the texture and blit that into each BaseTile's texture.
const int nextItemIndex = getNextTransferQueueIndex();
@@ -291,12 +379,18 @@ void TransferQueue::updateDirtyBaseTiles()
bool usedFboForUpload = false;
for (int k = 0; k < ST_BUFFER_NUMBER ; k++) {
if (m_transferQueue[index].status == pendingBlit) {
- bool obsoleteBaseTile = checkObsolete(index);
+ bool obsoleteBaseTile = checkObsolete(&m_transferQueue[index]);
// Save the needed info, update the Surf Tex, clean up the item in
// the queue. Then either move on to next item or copy the content.
BaseTileTexture* destTexture = 0;
- if (!obsoleteBaseTile)
+ BaseTileTexture* frontTexture = 0;
+ if (!obsoleteBaseTile) {
destTexture = m_transferQueue[index].savedBaseTilePtr->backTexture();
+ // while destTexture is guaranteed to not be null, frontTexture
+ // might be (first transfer)
+ frontTexture = m_transferQueue[index].savedBaseTilePtr->frontTexture();
+ }
+
if (m_transferQueue[index].uploadType == GpuUpload) {
status_t result = m_sharedSurfaceTexture->updateTexImage();
if (result != OK)
@@ -315,14 +409,15 @@ void TransferQueue::updateDirtyBaseTiles()
if (m_transferQueue[index].uploadType == CpuUpload) {
// Here we just need to upload the bitmap content to the GL Texture
- GLUtils::updateTextureWithBitmap(destTexture->m_ownTextureId, 0, 0,
- *m_transferQueue[index].bitmap);
+ GLUtils::updateTextureWithBitmap(destTexture->m_ownTextureId,
+ *m_transferQueue[index].bitmap,
+ m_transferQueue[index].tileInfo.m_inval);
} else {
if (!usedFboForUpload) {
saveGLState();
usedFboForUpload = true;
}
- blitTileFromQueue(m_fboID, destTexture,
+ blitTileFromQueue(m_fboID, destTexture, frontTexture,
m_sharedSurfaceTextureId,
m_sharedSurfaceTexture->getCurrentTextureTarget(),
index);
@@ -333,6 +428,7 @@ void TransferQueue::updateDirtyBaseTiles()
// will find the latest texture's info
// We don't need a map any more, each texture contains its own
// texturesTileInfo.
+ destTexture->setPure(false);
destTexture->setOwnTextureTileInfoFromQueue(&m_transferQueue[index].tileInfo);
XLOG("Blit tile x, y %d %d with dest texture %p to destTexture->m_ownTextureId %d",
@@ -358,9 +454,9 @@ void TransferQueue::updateDirtyBaseTiles()
}
void TransferQueue::updateQueueWithBitmap(const TileRenderInfo* renderInfo,
- int x, int y, const SkBitmap& bitmap)
+ const SkBitmap& bitmap)
{
- if (!tryUpdateQueueWithBitmap(renderInfo, x, y, bitmap)) {
+ if (!tryUpdateQueueWithBitmap(renderInfo, bitmap)) {
// failed placing bitmap in queue, discard tile's texture so it will be
// re-enqueued (and repainted)
BaseTile* tile = renderInfo->baseTile;
@@ -370,12 +466,15 @@ void TransferQueue::updateQueueWithBitmap(const TileRenderInfo* renderInfo,
}
bool TransferQueue::tryUpdateQueueWithBitmap(const TileRenderInfo* renderInfo,
- int x, int y, const SkBitmap& bitmap)
+ const SkBitmap& bitmap)
{
- m_transferQueueItemLocks.lock();
+ // This lock need to cover the full update since it is possible that queue
+ // will be cleaned up in the middle of this update without the lock.
+ // The Surface Texture will not block us since the readyForUpdate will check
+ // availability of the slots in the queue first.
+ android::Mutex::Autolock lock(m_transferQueueItemLocks);
bool ready = readyForUpdate();
TextureUploadType currentUploadType = m_currentUploadType;
- m_transferQueueItemLocks.unlock();
if (!ready) {
XLOG("Quit bitmap update: not ready! for tile x y %d %d",
renderInfo->x, renderInfo->y);
@@ -397,9 +496,10 @@ bool TransferQueue::tryUpdateQueueWithBitmap(const TileRenderInfo* renderInfo,
int bpp = 4; // Now we only deal with RGBA8888 format.
int width = TilesManager::instance()->tileWidth();
int height = TilesManager::instance()->tileHeight();
- if (!x && !y && bitmap.width() == width && bitmap.height() == height) {
+ if (bitmap.width() == width && bitmap.height() == height) {
bitmap.lockPixels();
uint8_t* bitmapOrigin = static_cast<uint8_t*>(bitmap.getPixels());
+
if (buffer.stride != bitmap.width())
// Copied line by line since we need to handle the offsets and stride.
for (row = 0 ; row < bitmap.height(); row ++) {
@@ -411,24 +511,61 @@ bool TransferQueue::tryUpdateQueueWithBitmap(const TileRenderInfo* renderInfo,
memcpy(img, bitmapOrigin, bpp * bitmap.width() * bitmap.height());
bitmap.unlockPixels();
- } else {
- // TODO: implement the partial invalidate here!
- XLOG("ERROR: don't expect to get here yet before we support partial inval");
}
ANativeWindow_unlockAndPost(m_ANW.get());
}
- m_transferQueueItemLocks.lock();
// b) After update the Surface Texture, now udpate the transfer queue info.
addItemInTransferQueue(renderInfo, currentUploadType, &bitmap);
- m_transferQueueItemLocks.unlock();
XLOG("Bitmap updated x, y %d %d, baseTile %p",
renderInfo->x, renderInfo->y, renderInfo->baseTile);
return true;
}
+void TransferQueue::addItemInPureColorQueue(const TileRenderInfo* renderInfo, Color color)
+{
+ // The pure color tiles' queue will be read from UI thread and written in
+ // Tex Gen thread, thus we need to have a lock here.
+ android::Mutex::Autolock lock(m_transferQueueItemLocks);
+ TileTransferData data;
+ addItemCommon(renderInfo, GpuUpload, &data);
+ data.pureColor = color;
+ m_pureColorTileQueue.append(data);
+}
+
+// Translates the info from TileRenderInfo and others to TileTransferData.
+// This is used by pure color tiles and normal tiles.
+void TransferQueue::addItemCommon(const TileRenderInfo* renderInfo,
+ TextureUploadType type,
+ TileTransferData* data)
+{
+ data->savedBaseTileTexturePtr = renderInfo->baseTile->backTexture();
+ data->savedBaseTilePtr = renderInfo->baseTile;
+ data->status = pendingBlit;
+ data->uploadType = type;
+
+ // Now fill the tileInfo.
+ TextureTileInfo* textureInfo = &(data->tileInfo);
+
+ IntRect inval(0, 0, 0, 0);
+ if (renderInfo->invalRect) {
+ inval.setX(renderInfo->invalRect->fLeft);
+ inval.setY(renderInfo->invalRect->fTop);
+ inval.setWidth(renderInfo->invalRect->width());
+ inval.setHeight(renderInfo->invalRect->height());
+ }
+ textureInfo->m_inval = inval;
+
+ textureInfo->m_x = renderInfo->x;
+ textureInfo->m_y = renderInfo->y;
+ textureInfo->m_scale = renderInfo->scale;
+ textureInfo->m_painter = renderInfo->tilePainter;
+
+ textureInfo->m_picture = renderInfo->textureInfo->m_pictureCount;
+}
+
// Note that there should be lock/unlock around this function call.
// Currently only called by GLUtils::updateSharedSurfaceTextureWithBitmap.
void TransferQueue::addItemInTransferQueue(const TileRenderInfo* renderInfo,
@@ -443,10 +580,8 @@ void TransferQueue::addItemInTransferQueue(const TileRenderInfo* renderInfo,
XLOG("ERROR update a tile which is dirty already @ index %d", index);
}
- m_transferQueue[index].savedBaseTileTexturePtr = renderInfo->baseTile->backTexture();
- m_transferQueue[index].savedBaseTilePtr = renderInfo->baseTile;
- m_transferQueue[index].status = pendingBlit;
- m_transferQueue[index].uploadType = type;
+ TileTransferData* data = &m_transferQueue[index];
+ addItemCommon(renderInfo, type, data);
if (type == CpuUpload && bitmap) {
// Lazily create the bitmap
if (!m_transferQueue[index].bitmap) {
@@ -458,34 +593,24 @@ void TransferQueue::addItemInTransferQueue(const TileRenderInfo* renderInfo,
bitmap->copyTo(m_transferQueue[index].bitmap, bitmap->config());
}
- // Now fill the tileInfo.
- TextureTileInfo* textureInfo = &m_transferQueue[index].tileInfo;
-
- textureInfo->m_x = renderInfo->x;
- textureInfo->m_y = renderInfo->y;
- textureInfo->m_scale = renderInfo->scale;
- textureInfo->m_painter = renderInfo->tilePainter;
-
- textureInfo->m_picture = renderInfo->textureInfo->m_pictureCount;
-
m_emptyItemCount--;
}
void TransferQueue::setTextureUploadType(TextureUploadType type)
{
+ android::Mutex::Autolock lock(m_transferQueueItemLocks);
if (m_currentUploadType == type)
return;
- discardQueue();
+ setPendingDiscard();
- android::Mutex::Autolock lock(m_transferQueueItemLocks);
m_currentUploadType = type;
XLOGC("Now we set the upload to %s", m_currentUploadType == GpuUpload ? "GpuUpload" : "CpuUpload");
}
-// Note: this need to be called within th lock.
-// Only called by updateDirtyBaseTiles() for now
-void TransferQueue::cleanupTransportQueue()
+// Note: this need to be called within the lock and on the UI thread.
+// Only called by updateDirtyBaseTiles() and emptyQueue() for now
+void TransferQueue::cleanupPendingDiscard()
{
int index = getNextTransferQueueIndex();
@@ -524,7 +649,7 @@ void TransferQueue::saveGLState()
glGetIntegerv(GL_VIEWPORT, m_GLStateBeforeBlit.viewport);
glGetBooleanv(GL_SCISSOR_TEST, m_GLStateBeforeBlit.scissor);
glGetBooleanv(GL_DEPTH_TEST, m_GLStateBeforeBlit.depth);
-#if DEBUG
+#ifdef DEBUG
glGetFloatv(GL_COLOR_CLEAR_VALUE, m_GLStateBeforeBlit.clearColor);
#endif
}
@@ -536,7 +661,7 @@ void TransferQueue::setGLStateForCopy(int width, int height)
glDisable(GL_SCISSOR_TEST);
glDisable(GL_DEPTH_TEST);
// Clear the content is only for debug purpose.
-#if DEBUG
+#ifdef DEBUG
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
#endif
@@ -554,7 +679,7 @@ void TransferQueue::restoreGLState()
if (m_GLStateBeforeBlit.depth[0])
glEnable(GL_DEPTH_TEST);
-#if DEBUG
+#ifdef DEBUG
glClearColor(m_GLStateBeforeBlit.clearColor[0],
m_GLStateBeforeBlit.clearColor[1],
m_GLStateBeforeBlit.clearColor[2],
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.h b/Source/WebCore/platform/graphics/android/TransferQueue.h
index 63455de..ec3e5e2 100644
--- a/Source/WebCore/platform/graphics/android/TransferQueue.h
+++ b/Source/WebCore/platform/graphics/android/TransferQueue.h
@@ -32,6 +32,7 @@
#include "BaseTileTexture.h"
#include "ShaderProgram.h"
#include "TiledPage.h"
+#include <EGL/eglext.h>
namespace WebCore {
@@ -92,6 +93,9 @@ public:
// lazily allocated.
SkBitmap* bitmap;
+ // Specific data to the pure color tiles' queue.
+ Color pureColor;
+
// Sync object for GPU fence, this is the only the info passed from UI
// thread to Tex Gen thread. The reason of having this is due to the
// missing sync mechanism on Surface Texture on some vendor. b/5122031.
@@ -109,17 +113,15 @@ public:
// This will be called by the browser through nativeSetProperty
void setTextureUploadType(TextureUploadType type);
-
+ void cleanupGLResources();
void updateDirtyBaseTiles();
- void initSharedSurfaceTextures(int width, int height);
+ void initGLResources(int width, int height);
// insert the bitmap into the queue, mark the tile dirty if failing
- void updateQueueWithBitmap(const TileRenderInfo* renderInfo, int x, int y,
+ void updateQueueWithBitmap(const TileRenderInfo* renderInfo,
const SkBitmap& bitmap);
- void discardQueue();
-
void addItemInTransferQueue(const TileRenderInfo* info,
TextureUploadType type,
const SkBitmap* bitmap);
@@ -132,6 +134,12 @@ public:
void lockQueue() { m_transferQueueItemLocks.lock(); }
void unlockQueue() { m_transferQueueItemLocks.unlock(); }
+ void addItemInPureColorQueue(const TileRenderInfo* renderInfo, Color color);
+
+ void setPendingDiscardWithLock();
+ void emptyQueue();
+
+ bool needsInit() { return !m_sharedSurfaceTextureId; }
// This queue can be accessed from UI and TexGen thread, therefore, we need
// a lock to protect its access
TileTransferData* m_transferQueue;
@@ -143,7 +151,7 @@ public:
private:
// return true if successfully inserted into queue
- bool tryUpdateQueueWithBitmap(const TileRenderInfo* renderInfo, int x, int y,
+ bool tryUpdateQueueWithBitmap(const TileRenderInfo* renderInfo,
const SkBitmap& bitmap);
bool getHasGLContext();
void setHasGLContext(bool hasContext);
@@ -156,16 +164,22 @@ private:
void restoreGLState();
// Check the current transfer queue item is obsolete or not.
- bool checkObsolete(int index);
+ bool checkObsolete(const TileTransferData* data);
+ void setPendingDiscard();
// Before each draw call and the blit operation, clean up all the
// pendingDiscard items.
- void cleanupTransportQueue();
+ void cleanupPendingDiscard();
void blitTileFromQueue(GLuint fboID, BaseTileTexture* destTex,
+ BaseTileTexture* frontTex,
GLuint srcTexId, GLenum srcTexTarget,
int index);
+ void addItemCommon(const TileRenderInfo* renderInfo,
+ TextureUploadType type, TileTransferData* data);
+
+ void updatePureColorTiles();
// Note that the m_transferQueueIndex only changed in the TexGen thread
// where we are going to move on to update the next item in the queue.
int m_transferQueueIndex;
@@ -201,6 +215,11 @@ private:
// This should be GpuUpload for production, but for debug purpose or working
// around driver/HW issue, we can set it to CpuUpload.
TextureUploadType m_currentUploadType;
+
+ // The non-pure-color tile are 1 to 1 mapping with Surface Texture which is
+ // resource limited. To get better performance, it is better to separate
+ // the pure color tile into another queue.
+ WTF::Vector<TileTransferData> m_pureColorTileQueue;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/TreeManager.cpp b/Source/WebCore/platform/graphics/android/TreeManager.cpp
index b7eaacf..fd5e525 100644
--- a/Source/WebCore/platform/graphics/android/TreeManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TreeManager.cpp
@@ -52,8 +52,9 @@
namespace WebCore {
-TreeManager::TreeManager()
- : m_drawingTree(0)
+TreeManager::TreeManager(GLWebViewState* state)
+ : m_state(state)
+ , m_drawingTree(0)
, m_paintingTree(0)
, m_queuedTree(0)
, m_fastSwapMode(false)
@@ -110,18 +111,13 @@ void TreeManager::clearTrees()
{
// remove painted surfaces from any tree in this view, and set trees as no
// longer drawing, to clear ptrs from surfaces to layers
- GLWebViewState* oldState = 0;
- if (m_drawingTree) {
- oldState = m_drawingTree->state();
+ if (m_drawingTree)
m_drawingTree->setIsDrawing(false);
- }
- if (m_paintingTree) {
- oldState = m_paintingTree->state();
+ if (m_paintingTree)
m_paintingTree->setIsDrawing(false);
- }
- XLOG("TreeManager %p removing PS from state %p", this, oldState);
- TilesManager::instance()->paintedSurfacesCleanup(oldState);
+ XLOG("TreeManager %p removing PS from state %p", this, m_state);
+ TilesManager::instance()->paintedSurfacesCleanup(m_state);
SkSafeUnref(m_drawingTree);
m_drawingTree = 0;
@@ -132,8 +128,9 @@ void TreeManager::clearTrees()
}
// a new layer tree has arrived, queue it if we're painting something already,
-// or start painting it if we aren't
-void TreeManager::updateWithTree(Layer* newTree, bool brandNew)
+// or start painting it if we aren't. Returns true if the manager has two trees
+// already queued.
+bool TreeManager::updateWithTree(Layer* newTree, bool brandNew)
{
XLOG("updateWithTree - %p, has children %d, has animations %d",
newTree, newTree && newTree->countChildren(),
@@ -153,16 +150,21 @@ void TreeManager::updateWithTree(Layer* newTree, bool brandNew)
m_paintingTree = newTree;
m_paintingTree->setIsPainting(m_drawingTree);
}
- return;
+ return false;
}
if (m_queuedTree || m_paintingTree) {
// currently painting, so defer this new tree
if (m_queuedTree) {
- // have a queued tree, copy over invals so the regions are
- // eventually repainted
+ // already have a queued tree, copy over invals so the regions are
+ // eventually repainted and let the old queued tree be discarded
m_queuedTree->mergeInvalsInto(newTree);
+ if (!TilesManager::instance()->useDoubleBuffering()) {
+ // not double buffering, count discarded tree/webkit paint as an update
+ TilesManager::instance()->incTreeUpdates();
+ }
+
XLOG("DISCARDING tree - %p, has children %d, has animations %d",
newTree, newTree && newTree->countChildren(),
newTree && newTree->countChildren()
@@ -170,12 +172,12 @@ void TreeManager::updateWithTree(Layer* newTree, bool brandNew)
}
SkSafeUnref(m_queuedTree);
m_queuedTree = newTree;
- return;
+ } else {
+ // don't have painting tree, paint this one!
+ m_paintingTree = newTree;
+ m_paintingTree->setIsPainting(m_drawingTree);
}
-
- // don't have painting tree, paint this one!
- m_paintingTree = newTree;
- m_paintingTree->setIsPainting(m_drawingTree);
+ return m_drawingTree && TilesManager::instance()->useDoubleBuffering();
}
void TreeManager::updateScrollableLayerInTree(Layer* tree, int layerId, int x, int y)
@@ -222,9 +224,10 @@ bool TreeManager::drawGL(double currentTime, IntRect& viewRect,
if (laTree)
laTree->computeTexturesAmount(texturesResultPtr);
- if (/*!m_fastSwapMode && */ m_paintingTree->isReady()) {
+ if (!TilesManager::instance()->useDoubleBuffering() || m_paintingTree->isReady()) {
XLOG("have painting tree %p ready, swapping!", m_paintingTree);
didTreeSwap = true;
+ TilesManager::instance()->incTreeUpdates();
swap();
if (treesSwappedPtr)
*treesSwappedPtr = true;
@@ -245,6 +248,10 @@ bool TreeManager::drawGL(double currentTime, IntRect& viewRect,
if (m_drawingTree) {
bool drawingReady = didTreeSwap || m_drawingTree->isReady();
+ // call the page swap callback if registration happened without more trees enqueued
+ if (treesSwappedPtr && drawingReady && !m_paintingTree)
+ *treesSwappedPtr = true;
+
if (didTreeSwap || m_fastSwapMode || (drawingReady && !m_paintingTree))
m_drawingTree->swapTiles();
diff --git a/Source/WebCore/platform/graphics/android/TreeManager.h b/Source/WebCore/platform/graphics/android/TreeManager.h
index 83d5300..a571d1a 100644
--- a/Source/WebCore/platform/graphics/android/TreeManager.h
+++ b/Source/WebCore/platform/graphics/android/TreeManager.h
@@ -36,16 +36,17 @@ class SkCanvas;
namespace WebCore {
+class GLWebViewState;
class IntRect;
class TexturesResult;
class TEST_EXPORT TreeManager {
public:
- TreeManager();
+ TreeManager(GLWebViewState* state);
~TreeManager();
- void updateWithTree(Layer* tree, bool brandNew);
+ bool updateWithTree(Layer* tree, bool brandNew);
void updateScrollableLayer(int layerId, int x, int y);
@@ -70,6 +71,8 @@ private:
android::Mutex m_paintSwapLock;
+ GLWebViewState* m_state;
+
Layer* m_drawingTree;
Layer* m_paintingTree;
Layer* m_queuedTree;
diff --git a/Source/WebCore/platform/graphics/android/VerticalTextMap.cpp b/Source/WebCore/platform/graphics/android/VerticalTextMap.cpp
index 6e715e2..42aa385 100644
--- a/Source/WebCore/platform/graphics/android/VerticalTextMap.cpp
+++ b/Source/WebCore/platform/graphics/android/VerticalTextMap.cpp
@@ -33,28 +33,29 @@
#include <wtf/RefPtr.h>
static const UChar vTextCnvTable[][2] = {
- // TODO: uncomment mappings once we add glyphs for vertical forms.
- // {0x0021, 0xfe15}, // exclamation mark
+ {0x0021, 0xfe15}, // exclamation mark
{0x0028, 0xfe35}, // left paren
{0x0029, 0xfe36}, // right paren
- // {0x002c, 0xfe10}, // comma
+ {0x002c, 0xfe10}, // comma
+ {0x002d, 0xfe32}, // hyphen
{0x003a, 0xfe30}, // colon
- {0x003b, 0x007c}, // hyphen
- // {0x003f, 0xfe16}, // question mark
- // {0x005b, 0xfe14}, // semicolon
- {0x005d, 0xfe47}, // left square bracket
- {0x005f, 0xfe48}, // right square bracket
+ {0x003b, 0xfe14}, // semicolon
+ {0x003f, 0xfe16}, // question mark
+ {0x005b, 0xfe47}, // left square bracket
+ {0x005d, 0xfe48}, // right square bracket
{0x007b, 0xfe37}, // left curly bracket
{0x007d, 0xfe38}, // right curly bracket
{0x007e, 0x007c}, // tilde to vertical line
+ {0x00ab, 0xfe3d}, // left pointing double angle quotation mark
+ {0x00bb, 0xfe3e}, // right pointing double angle quotation mark
+ {0x2010, 0xfe32}, // hyphen
{0x2013, 0xfe32}, // en dash
{0x2014, 0xfe31}, // em dash
{0x2015, 0xfe31}, // horizontal bar
{0x2025, 0xfe30}, // two dot leader
- // TODO: change the mapping 0x2026 -> 0xFE19 once Android has the glyph for 0xFE19.
- {0x2026, 0xfe30}, // three dot leader
- // {0x3001, 0xfe11}, // Ideographic comma
- // {0x3002, 0xfe12}, // Ideographic full stop
+ {0x2026, 0xfe19}, // three dot leader
+ {0x3001, 0xfe11}, // Ideographic comma
+ {0x3002, 0xfe12}, // Ideographic full stop
{0x3008, 0xfe3f}, // left angle bracket
{0x3009, 0xfe40}, // right angle bracket
{0x300a, 0xfe3d}, // left double angle bracket
@@ -67,19 +68,21 @@ static const UChar vTextCnvTable[][2] = {
{0x3011, 0xfe3c}, // right black lenticular bracket
{0x3014, 0xfe39}, // left black lenticular bracket
{0x3015, 0xfe3a}, // right tortise shell bracket
- // {0x3016, 0xfe17}, // left white lenticular bracket
- // {0x3017, 0xfe18}, // right white lenticular bracket
- // {0x3019, 0xfe19}, // horizontal ellipses
+ {0x3016, 0xfe17}, // left white lenticular bracket
+ {0x3017, 0xfe18}, // right white lenticular bracket
{0x30fc, 0x3021}, // prolonged sound
{0xfe4f, 0xfe34}, // wavy low line
{0xff08, 0xfe35}, // full width left paren
{0xff09, 0xfe36}, // full width right paren
+ {0xff0c, 0xfe10}, // full width comma
{0xff3b, 0xfe47}, // full width left square bracket
{0xff3d, 0xfe48}, // full width right square bracket
{0xff5b, 0xfe37}, // full width left curly bracket
+ {0xff5c, 0xfe31}, // fullwidth vertical line
{0xff5d, 0xfe38}, // full width right curly bracket
- // {0xff64, 0xfe11}, // halfwidth ideo comma
- // {0xff61, 0xfe12}, // halfwidth ideo full stop
+ {0xff5e, 0x007c}, // tilde to vertical line
+ {0xff64, 0xfe11}, // halfwidth ideo comma
+ {0xff61, 0xfe12}, // halfwidth ideo full stop
};
namespace WebCore {
diff --git a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp
index 482d711..a527e6a 100644
--- a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.cpp
@@ -53,6 +53,8 @@ GLuint VideoLayerAndroid::m_spinnerOuterTextureId = 0;
GLuint VideoLayerAndroid::m_spinnerInnerTextureId = 0;
GLuint VideoLayerAndroid::m_posterTextureId = 0;
GLuint VideoLayerAndroid::m_backgroundTextureId = 0;
+GLuint VideoLayerAndroid::m_playTextureId = 0;
+GLuint VideoLayerAndroid::m_pauseTextureId = 0;
bool VideoLayerAndroid::m_createdTexture = false;
double VideoLayerAndroid::m_rotateDegree = 0;
@@ -102,6 +104,16 @@ GLuint VideoLayerAndroid::createPosterTexture()
return createTextureFromImage(RenderSkinMediaButton::VIDEO);
}
+GLuint VideoLayerAndroid::createPlayTexture()
+{
+ return createTextureFromImage(RenderSkinMediaButton::PLAY);
+}
+
+GLuint VideoLayerAndroid::createPauseTexture()
+{
+ return createTextureFromImage(RenderSkinMediaButton::PAUSE);
+}
+
GLuint VideoLayerAndroid::createTextureFromImage(int buttonType)
{
SkRect rect = SkRect(buttonRect);
@@ -112,7 +124,8 @@ GLuint VideoLayerAndroid::createTextureFromImage(int buttonType)
SkCanvas canvas(bitmap);
canvas.drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);
- RenderSkinMediaButton::Draw(&canvas, buttonRect, buttonType, true);
+ RenderSkinMediaButton::Draw(&canvas, buttonRect, buttonType, true, 0,
+ false);
GLuint texture;
glGenTextures(1, &texture);
@@ -142,6 +155,47 @@ GLuint VideoLayerAndroid::createBackgroundTexture()
return texture;
}
+void VideoLayerAndroid::showPreparingAnimation(const SkRect& rect,
+ const SkRect innerRect)
+{
+ ShaderProgram* shader = TilesManager::instance()->shader();
+ shader->drawLayerQuad(m_drawTransform, rect, m_backgroundTextureId, 1, true);
+
+ TransformationMatrix addReverseRotation;
+ TransformationMatrix addRotation = m_drawTransform;
+ addRotation.translate(innerRect.fLeft, innerRect.fTop);
+ addRotation.translate(IMAGESIZE / 2, IMAGESIZE / 2);
+ addReverseRotation = addRotation;
+ addRotation.rotate(m_rotateDegree);
+ addRotation.translate(-IMAGESIZE / 2, -IMAGESIZE / 2);
+
+ SkRect size = SkRect::MakeWH(innerRect.width(), innerRect.height());
+ shader->drawLayerQuad(addRotation, size, m_spinnerOuterTextureId, 1, true);
+
+ addReverseRotation.rotate(-m_rotateDegree);
+ addReverseRotation.translate(-IMAGESIZE / 2, -IMAGESIZE / 2);
+
+ shader->drawLayerQuad(addReverseRotation, size, m_spinnerInnerTextureId, 1, true);
+
+ m_rotateDegree += ROTATESTEP;
+}
+
+SkRect VideoLayerAndroid::calVideoRect(const SkRect& rect)
+{
+ SkRect videoRect = rect;
+ VideoLayerManager* manager = TilesManager::instance()->videoLayerManager();
+ float aspectRatio = manager->getAspectRatio(uniqueId());
+ float deltaY = rect.height() - rect.width() / aspectRatio;
+ if (deltaY >= 0)
+ videoRect.inset(0, deltaY / 2);
+ else {
+ float deltaX = rect.width() - rect.height() * aspectRatio;
+ if (deltaX >= 0)
+ videoRect.inset(deltaX / 2, 0);
+ }
+ return videoRect;
+}
+
bool VideoLayerAndroid::drawGL()
{
// Lazily allocated the textures.
@@ -150,81 +204,88 @@ bool VideoLayerAndroid::drawGL()
m_spinnerOuterTextureId = createSpinnerOuterTexture();
m_spinnerInnerTextureId = createSpinnerInnerTexture();
m_posterTextureId = createPosterTexture();
+ m_playTextureId = createPlayTexture();
+ m_pauseTextureId = createPauseTexture();
m_createdTexture = true;
}
+ ShaderProgram* shader = TilesManager::instance()->shader();
+
SkRect rect = SkRect::MakeSize(getSize());
GLfloat surfaceMatrix[16];
+ // Calculate the video rect based on the aspect ratio and the element rect.
+ SkRect videoRect = calVideoRect(rect);
+ if (videoRect != rect) {
+ // Paint the whole video element with black color when video content
+ // can't cover the whole area.
+ shader->drawLayerQuad(m_drawTransform, rect, 0, 1, true, GL_TEXTURE_2D,
+ Color(0, 0, 0, 255));
+ }
+
+ // Inner rect is for the progressing / play / pause animation.
SkRect innerRect = SkRect(buttonRect);
- if (innerRect.contains(rect))
- innerRect = rect;
+ if (innerRect.contains(videoRect))
+ innerRect = videoRect;
+ innerRect.offset(videoRect.fLeft + (videoRect.width() - IMAGESIZE) / 2,
+ videoRect.fTop + (videoRect.height() - IMAGESIZE) / 2);
- innerRect.offset((rect.width() - IMAGESIZE) / 2 , (rect.height() - IMAGESIZE) / 2);
+ // When we are drawing the animation of the play/pause button in the
+ // middle of the video, we need to ask for redraw.
+ bool needRedraw = false;
// Draw the poster image, the progressing image or the Video depending
// on the player's state.
+ VideoLayerManager* manager = TilesManager::instance()->videoLayerManager();
if (m_playerState == PREPARING) {
// Show the progressing animation, with two rotating circles
- TilesManager::instance()->shader()->drawLayerQuad(m_drawTransform, rect,
- m_backgroundTextureId,
- 1, true);
-
- TransformationMatrix addReverseRotation;
- TransformationMatrix addRotation = m_drawTransform;
- addRotation.translate(innerRect.fLeft, innerRect.fTop);
- addRotation.translate(IMAGESIZE / 2, IMAGESIZE / 2);
- addReverseRotation = addRotation;
- addRotation.rotate(m_rotateDegree);
- addRotation.translate(-IMAGESIZE / 2, -IMAGESIZE / 2);
-
- SkRect size = SkRect::MakeWH(innerRect.width(), innerRect.height());
- TilesManager::instance()->shader()->drawLayerQuad(addRotation, size,
- m_spinnerOuterTextureId,
- 1, true);
-
- addReverseRotation.rotate(-m_rotateDegree);
- addReverseRotation.translate(-IMAGESIZE / 2, -IMAGESIZE / 2);
-
- TilesManager::instance()->shader()->drawLayerQuad(addReverseRotation, size,
- m_spinnerInnerTextureId,
- 1, true);
-
- m_rotateDegree += ROTATESTEP;
-
+ showPreparingAnimation(videoRect, innerRect);
+ needRedraw = true;
} else if (m_playerState == PLAYING && m_surfaceTexture.get()) {
// Show the real video.
m_surfaceTexture->updateTexImage();
m_surfaceTexture->getTransformMatrix(surfaceMatrix);
- GLuint textureId =
- TilesManager::instance()->videoLayerManager()->getTextureId(uniqueId());
- TilesManager::instance()->shader()->drawVideoLayerQuad(m_drawTransform,
- surfaceMatrix,
- rect, textureId);
- TilesManager::instance()->videoLayerManager()->updateMatrix(uniqueId(),
- surfaceMatrix);
+ GLuint textureId = manager->getTextureId(uniqueId());
+ shader->drawVideoLayerQuad(m_drawTransform, surfaceMatrix,
+ videoRect, textureId);
+ manager->updateMatrix(uniqueId(), surfaceMatrix);
+
+ // Use the scale to control the fading the sizing during animation
+ double scale = manager->drawIcon(uniqueId(), PlayIcon);
+ if (scale) {
+ innerRect.inset(IMAGESIZE / 4 * scale, IMAGESIZE / 4 * scale);
+ shader->drawLayerQuad(m_drawTransform, innerRect,
+ m_playTextureId, scale, true);
+ needRedraw = true;
+ }
+
} else {
- GLuint textureId =
- TilesManager::instance()->videoLayerManager()->getTextureId(uniqueId());
- GLfloat* matrix =
- TilesManager::instance()->videoLayerManager()->getMatrix(uniqueId());
+ GLuint textureId = manager->getTextureId(uniqueId());
+ GLfloat* matrix = manager->getMatrix(uniqueId());
if (textureId && matrix) {
// Show the screen shot for each video.
- TilesManager::instance()->shader()->drawVideoLayerQuad(m_drawTransform,
- matrix,
- rect, textureId);
+ shader->drawVideoLayerQuad(m_drawTransform, matrix,
+ videoRect, textureId);
} else {
// Show the static poster b/c there is no screen shot available.
- TilesManager::instance()->shader()->drawLayerQuad(m_drawTransform, rect,
- m_backgroundTextureId,
- 1, true);
- TilesManager::instance()->shader()->drawLayerQuad(m_drawTransform, innerRect,
- m_posterTextureId,
- 1, true);
+ shader->drawLayerQuad(m_drawTransform, videoRect, m_backgroundTextureId,
+ 1, true);
+ shader->drawLayerQuad(m_drawTransform, innerRect, m_posterTextureId,
+ 1, true);
+ }
+
+ // Use the scale to control the fading and the sizing during animation.
+ double scale = manager->drawIcon(uniqueId(), PauseIcon);
+ if (scale) {
+ innerRect.inset(IMAGESIZE / 4 * scale, IMAGESIZE / 4 * scale);
+ shader->drawLayerQuad(m_drawTransform, innerRect,
+ m_pauseTextureId, scale, true);
+ needRedraw = true;
}
- }
- return drawChildrenGL();
+ }
+ // Don't short circuit here since we still want to draw the children.
+ return drawChildrenGL() || needRedraw;
}
}
diff --git a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h
index 8a064bb..6bd9fa1 100644
--- a/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/VideoLayerAndroid.h
@@ -30,6 +30,7 @@
#include "GLUtils.h"
#include "LayerAndroid.h"
+#include "ShaderProgram.h"
#include <jni.h>
namespace android {
@@ -62,10 +63,15 @@ public:
GLuint createSpinnerOuterTexture();
GLuint createSpinnerInnerTexture();
GLuint createPosterTexture();
+ GLuint createPlayTexture();
+ GLuint createPauseTexture();
private:
GLuint createTextureFromImage(int buttonType);
void init();
+ void showPreparingAnimation(const SkRect& rect,
+ const SkRect innerRect);
+ SkRect calVideoRect(const SkRect& rect);
// Surface texture for showing the video is actually allocated in Java side
// and passed into this native code.
sp<android::SurfaceTexture> m_surfaceTexture;
@@ -78,6 +84,8 @@ private:
static GLuint m_posterTextureId;
static GLuint m_spinnerOuterTextureId;
static GLuint m_spinnerInnerTextureId;
+ static GLuint m_playTextureId;
+ static GLuint m_pauseTextureId;
static double m_rotateDegree;
diff --git a/Source/WebCore/platform/graphics/android/VideoLayerManager.cpp b/Source/WebCore/platform/graphics/android/VideoLayerManager.cpp
index cec4d67..521b623 100644
--- a/Source/WebCore/platform/graphics/android/VideoLayerManager.cpp
+++ b/Source/WebCore/platform/graphics/android/VideoLayerManager.cpp
@@ -26,6 +26,8 @@
#include "config.h"
#include "VideoLayerManager.h"
+#include <wtf/CurrentTime.h>
+
#if USE(ACCELERATED_COMPOSITING)
#ifdef DEBUG
@@ -42,6 +44,10 @@
#endif // DEBUG
+// The animation of the play/pause icon will last for PLAY_PAUSE_ICON_SHOW_TIME
+// seconds.
+#define PLAY_PAUSE_ICON_SHOW_TIME 1
+
// Define the max sum of all the video's sizes.
// Note that video_size = width * height. If there is no compression, then the
// maximum memory consumption could be 4 * video_size.
@@ -49,6 +55,10 @@
// screenshots would not be above 8M.
#define MAX_VIDEOSIZE_SUM 2097152
+// We don't preload the video data, so we don't have the exact size yet.
+// Assuming 16:9 by default, this will be corrected after video prepared.
+#define DEFAULT_VIDEO_ASPECT_RATIO 1.78
+
namespace WebCore {
VideoLayerManager::VideoLayerManager()
@@ -66,6 +76,16 @@ GLuint VideoLayerManager::getTextureId(const int layerId)
return result;
}
+// Getting the aspect ratio for GL draw call, in the UI thread.
+float VideoLayerManager::getAspectRatio(const int layerId)
+{
+ android::Mutex::Autolock lock(m_videoLayerInfoMapLock);
+ float result = 0;
+ if (m_videoLayerInfoMap.contains(layerId))
+ result = m_videoLayerInfoMap.get(layerId)->aspectRatio;
+ return result;
+}
+
// Getting matrix for GL draw call, in the UI thread.
GLfloat* VideoLayerManager::getMatrix(const int layerId)
{
@@ -103,8 +123,11 @@ void VideoLayerManager::registerTexture(const int layerId, const GLuint textureI
pInfo->textureId = textureId;
memset(pInfo->surfaceMatrix, 0, sizeof(pInfo->surfaceMatrix));
pInfo->videoSize = 0;
+ pInfo->aspectRatio = DEFAULT_VIDEO_ASPECT_RATIO;
m_currentTimeStamp++;
pInfo->timeStamp = m_currentTimeStamp;
+ pInfo->lastIconShownTime = 0;
+ pInfo->iconState = Registered;
m_videoLayerInfoMap.add(layerId, pInfo);
XLOG("GL texture %d regisered for layerId %d", textureId, layerId);
@@ -115,13 +138,16 @@ void VideoLayerManager::registerTexture(const int layerId, const GLuint textureI
// Only when the video is prepared, we got the video size. So we should update
// the size for the video accordingly.
// This is called from webcore thread, from MediaPlayerPrivateAndroid.
-void VideoLayerManager::updateVideoLayerSize(const int layerId, const int size )
+void VideoLayerManager::updateVideoLayerSize(const int layerId, const int size,
+ const float ratio)
{
android::Mutex::Autolock lock(m_videoLayerInfoMapLock);
if (m_videoLayerInfoMap.contains(layerId)) {
VideoLayerInfo* pInfo = m_videoLayerInfoMap.get(layerId);
- if (pInfo)
+ if (pInfo) {
pInfo->videoSize = size;
+ pInfo->aspectRatio = ratio;
+ }
}
// If the memory usage is out of bound, then just delete the oldest ones.
@@ -238,5 +264,34 @@ void VideoLayerManager::removeLayerInternal(const int layerId)
return;
}
+double VideoLayerManager::drawIcon(const int layerId, IconType type)
+{
+ // When ratio 0 is returned, the Icon should not be drawn.
+ double ratio = 0;
+
+ android::Mutex::Autolock lock(m_videoLayerInfoMapLock);
+ if (m_videoLayerInfoMap.contains(layerId)) {
+ VideoLayerInfo* pInfo = m_videoLayerInfoMap.get(layerId);
+ // If this is state switching moment, reset the time and state
+ if ((type == PlayIcon && pInfo->iconState != PlayIconShown)
+ || (type == PauseIcon && pInfo->iconState != PauseIconShown)) {
+ pInfo->lastIconShownTime = WTF::currentTime();
+ pInfo->iconState = (type == PlayIcon) ? PlayIconShown : PauseIconShown;
+ }
+
+ // After switching the state, we calculate the ratio depending on the
+ // time interval.
+ if ((type == PlayIcon && pInfo->iconState == PlayIconShown)
+ || (type == PauseIcon && pInfo->iconState == PauseIconShown)) {
+ double delta = WTF::currentTime() - pInfo->lastIconShownTime;
+ ratio = 1.0 - (delta / PLAY_PAUSE_ICON_SHOW_TIME);
+ }
+ }
+
+ if (ratio > 1 || ratio < 0)
+ ratio = 0;
+ return ratio;
+}
+
}
#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/android/VideoLayerManager.h b/Source/WebCore/platform/graphics/android/VideoLayerManager.h
index de2dafc..d554362 100644
--- a/Source/WebCore/platform/graphics/android/VideoLayerManager.h
+++ b/Source/WebCore/platform/graphics/android/VideoLayerManager.h
@@ -34,13 +34,28 @@
namespace WebCore {
+enum IconState {
+ Registered,
+ PlayIconShown,
+ PauseIconShown
+};
+
+enum IconType {
+ PlayIcon,
+ PauseIcon
+};
+
// Every video layer can use its uniqueId to query VideoLayerManager about such
// info globally.
struct VideoLayerInfo {
GLuint textureId; // GL texture bound with the surface texture.
int videoSize; // The size of the video.
+ float aspectRatio; // The aspect ratio of the video.
int timeStamp; // Used to decide which VideoLayerInfo is the oldest one.
GLfloat surfaceMatrix[16];
+
+ double lastIconShownTime;
+ IconState iconState;
};
@@ -54,7 +69,7 @@ public:
// Register the texture when we got setSurfaceTexture call.
void registerTexture(const int layerId, const GLuint textureId);
// Update the size when the video is prepared.
- void updateVideoLayerSize(const int layerId, const int size);
+ void updateVideoLayerSize(const int layerId, const int size, const float ratio);
// At draw time, update the matrix for every video frame update.
void updateMatrix(const int layerId, const GLfloat* matrix);
// Remove the layer info from the mapping.
@@ -64,10 +79,13 @@ public:
GLuint getTextureId(const int layerId);
// Return the matrix for surface texture corresponding to the layerId
GLfloat* getMatrix(const int layerId);
+ // Return the aspect ratio for the video corresponding to the layerId
+ float getAspectRatio(const int layerId);
// Delete the GL textures
void deleteUnusedTextures();
+ double drawIcon(const int layerId, IconType type);
private:
// Get the sum of all the video size stored in m_videoLayerInfoMap.
int getTotalMemUsage();
diff --git a/Source/WebCore/platform/graphics/android/android_graphics.cpp b/Source/WebCore/platform/graphics/android/android_graphics.cpp
index e88c65d..d76d581 100644
--- a/Source/WebCore/platform/graphics/android/android_graphics.cpp
+++ b/Source/WebCore/platform/graphics/android/android_graphics.cpp
@@ -25,7 +25,6 @@
#include "CachedPrefix.h"
#include "android_graphics.h"
-#include "CachedColor.h"
#include "CachedRoot.h"
#include "IntRect.h"
#include "LayerAndroid.h"
@@ -37,10 +36,28 @@
namespace android {
+#define RING_OUTSET 3
+#define RING_RADIUS 1
+#define RING_INNER_WIDTH 16
+#define RING_OUTER_WIDTH 16
+
+static const RGBA32 ringFill = 0x666699FF;
+static const RGBA32 ringPressedInner = 0x006699FF;
+static const RGBA32 ringPressedOuter = 0x336699FF;
+static const RGBA32 ringSelectedInner = 0xAA6699FF;
+static const RGBA32 ringSelectedOuter = 0x336699FF;
+
+
+CursorRing::CursorRing(WebViewCore* core)
+ : m_viewImpl(core)
+ , m_layerId(-1)
+{
+}
+
// The CSS values for the inner and outer widths may be specified as fractions
#define WIDTH_SCALE 0.0625f // 1/16, to offset the scale in CSSStyleSelector
-void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer, IntRect* inval)
+void CursorRing::drawLegacy(SkCanvas* canvas, LayerAndroid* layer, IntRect* inval)
{
if (!m_lastBounds.isEmpty()) {
*inval = m_lastBounds;
@@ -48,7 +65,8 @@ void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer, IntRect* inval)
}
#if USE(ACCELERATED_COMPOSITING)
int layerId = m_node->isInLayer() ? m_frame->layer(m_node)->uniqueId() : -1;
- if (layer->uniqueId() != layerId)
+ int drawingLayerId = layer ? layer->uniqueId() : -1;
+ if (drawingLayerId != layerId)
return;
#endif
if (canvas->quickReject(m_bounds, SkCanvas::kAA_EdgeType)) {
@@ -57,7 +75,6 @@ void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer, IntRect* inval)
m_bounds.x(), m_bounds.y(), m_bounds.width(), m_bounds.height());
return;
}
- const CachedColor& colors = m_frame->color(m_node);
unsigned rectCount = m_rings.size();
SkRegion rgn;
SkPath path;
@@ -67,7 +84,7 @@ void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer, IntRect* inval)
SkIRect ir;
r.round(&ir);
- ir.inset(-colors.outset(), -colors.outset());
+ ir.inset(-RING_OUTSET, -RING_OUTSET);
rgn.op(ir, SkRegion::kUnion_Op);
}
rgn.getBoundaryPath(&path);
@@ -75,30 +92,30 @@ void CursorRing::draw(SkCanvas* canvas, LayerAndroid* layer, IntRect* inval)
SkPaint paint;
paint.setAntiAlias(true);
paint.setPathEffect(new SkCornerPathEffect(
- SkIntToScalar(colors.radius())))->unref();
+ SkIntToScalar(RING_RADIUS)))->unref();
SkColor outer;
SkColor inner;
if (m_isPressed) {
SkColor pressed;
- pressed = colors.fillColor();
+ pressed = ringFill;
paint.setColor(pressed);
canvas->drawPath(path, paint);
- outer = colors.pressedOuterColor();
- inner = colors.pressedInnerColor();
+ outer = ringPressedInner;
+ inner = ringPressedOuter;
} else {
- outer = colors.selectedOuterColor();
- inner = colors.selectedInnerColor();
+ outer = ringSelectedOuter;
+ inner = ringSelectedInner;
}
paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(colors.outerWidth() * WIDTH_SCALE);
+ paint.setStrokeWidth(RING_OUTER_WIDTH * WIDTH_SCALE);
paint.setColor(outer);
canvas->drawPath(path, paint);
- paint.setStrokeWidth(colors.innerWidth() * WIDTH_SCALE);
+ paint.setStrokeWidth(RING_INNER_WIDTH * WIDTH_SCALE);
paint.setColor(inner);
canvas->drawPath(path, paint);
SkRect localBounds, globalBounds;
localBounds = path.getBounds();
- float width = std::max(colors.innerWidth(), colors.outerWidth());
+ float width = std::max(RING_INNER_WIDTH, RING_OUTER_WIDTH);
width *= WIDTH_SCALE;
localBounds.inset(-width, -width);
const SkMatrix& matrix = canvas->getTotalMatrix();
@@ -116,12 +133,27 @@ void CursorRing::setIsButton(const CachedNode* node)
bool CursorRing::setup()
{
- m_node->cursorRings(m_frame, &m_rings);
+ m_layerId = -1;
+ if (m_frame && m_root) {
+ const CachedLayer* cachedLayer = m_frame->layer(m_node);
+ if (cachedLayer) {
+ const WebCore::LayerAndroid* rootLayer = m_root->rootLayer();
+ const LayerAndroid* aLayer = cachedLayer->layer(rootLayer);
+ if (aLayer)
+ m_layerId = aLayer->uniqueId();
+ }
+ }
+ if (m_layerId == -1)
+ m_node->cursorRings(m_frame, &m_rings);
+ else
+ m_node->localCursorRings(m_frame, &m_rings);
+
if (!m_rings.size()) {
DBG_NAV_LOG("!rings.size()");
m_viewImpl->m_hasCursorBounds = false;
return false;
}
+
setIsButton(m_node);
m_bounds = m_node->bounds(m_frame);
m_viewImpl->updateCursorBounds(m_root, m_frame, m_node);
@@ -134,9 +166,8 @@ bool CursorRing::setup()
m_rings.append(m_bounds);
}
m_absBounds = m_node->bounds(m_frame);
- const CachedColor& colors = m_frame->color(m_node);
- m_bounds.inflate(SkScalarCeil(colors.outerWidth()));
- m_absBounds.inflate(SkScalarCeil(colors.outerWidth()));
+ m_bounds.inflate(SkScalarCeil(RING_OUTER_WIDTH));
+ m_absBounds.inflate(SkScalarCeil(RING_OUTER_WIDTH));
if (!m_node->hasCursorRing() || (m_node->isPlugin() && m_node->isFocus()))
return false;
#if DEBUG_NAV_UI
@@ -147,12 +178,6 @@ bool CursorRing::setup()
m_isPressed ? "true" : "false",
m_rings.size(), ring.x(), ring.y(), ring.width(), ring.height(),
m_node->isPlugin() ? "true" : "false");
- DBG_NAV_LOGD("[%d] inner=%d outer=%d outset=%d radius=%d"
- " fill=0x%08x pin=0x%08x pout=0x%08x sin=0x%08x sout=0x%08x",
- m_node->colorIndex(), colors.innerWidth(), colors.outerWidth(),
- colors.outset(), colors.radius(), colors.fillColor(),
- colors.pressedInnerColor(), colors.pressedOuterColor(),
- colors.selectedInnerColor(), colors.selectedInnerColor());
#endif
return true;
}
diff --git a/Source/WebCore/platform/graphics/android/android_graphics.h b/Source/WebCore/platform/graphics/android/android_graphics.h
index 60ac115..68207d7 100644
--- a/Source/WebCore/platform/graphics/android/android_graphics.h
+++ b/Source/WebCore/platform/graphics/android/android_graphics.h
@@ -52,12 +52,13 @@ class WebViewCore;
class CursorRing : public DrawExtra {
public:
- CursorRing(WebViewCore* core) : m_viewImpl(core) {}
+ CursorRing(WebViewCore* core);
virtual ~CursorRing() {}
- virtual void draw(SkCanvas* , LayerAndroid* , IntRect* );
+ virtual void drawLegacy(SkCanvas* , LayerAndroid* , IntRect* );
void setIsButton(const CachedNode* );
bool setup();
WTF::Vector<IntRect>& rings() { return m_rings; }
+ int layerId() const { return m_layerId; }
private:
friend class WebView;
friend class WebCore::GLExtras;
@@ -71,6 +72,7 @@ private:
const CachedNode* m_node;
bool m_isButton;
bool m_isPressed;
+ int m_layerId;
};
}
diff --git a/Source/WebCore/rendering/InlineTextBox.cpp b/Source/WebCore/rendering/InlineTextBox.cpp
index 5815b8b..e8a9c7f 100644
--- a/Source/WebCore/rendering/InlineTextBox.cpp
+++ b/Source/WebCore/rendering/InlineTextBox.cpp
@@ -43,6 +43,7 @@
#include "Text.h"
#include "break_lines.h"
#include <wtf/AlwaysInline.h>
+#include <wtf/text/CString.h>
using namespace std;
diff --git a/Source/WebCore/rendering/RenderArena.cpp b/Source/WebCore/rendering/RenderArena.cpp
index 57ed978..e15101f 100644
--- a/Source/WebCore/rendering/RenderArena.cpp
+++ b/Source/WebCore/rendering/RenderArena.cpp
@@ -136,11 +136,4 @@ void RenderArena::free(size_t size, void* ptr)
#endif
}
-#ifdef ANDROID_INSTRUMENT
-size_t RenderArena::reportPoolSize() const
-{
- return ReportPoolSize(&m_pool);
-}
-#endif
-
} // namespace WebCore
diff --git a/Source/WebCore/rendering/RenderArena.h b/Source/WebCore/rendering/RenderArena.h
index 5d2559a..e1ff535 100644
--- a/Source/WebCore/rendering/RenderArena.h
+++ b/Source/WebCore/rendering/RenderArena.h
@@ -53,10 +53,6 @@ public:
void* allocate(size_t);
void free(size_t, void*);
-#ifdef ANDROID_INSTRUMENT
- size_t reportPoolSize() const;
-#endif
-
private:
// Underlying arena pool
ArenaPool m_pool;
diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp
index cdc4c05..0932224 100644
--- a/Source/WebCore/rendering/RenderLayer.cpp
+++ b/Source/WebCore/rendering/RenderLayer.cpp
@@ -64,6 +64,7 @@
#include "HTMLNames.h"
#if ENABLE(ANDROID_OVERFLOW_SCROLL)
#include "HTMLTextAreaElement.h"
+#include "GraphicsLayerAndroid.h"
#endif
#include "HitTestRequest.h"
#include "HitTestResult.h"
@@ -1424,6 +1425,8 @@ void RenderLayer::scrollTo(int x, int y)
// do not need to repaint simply because we are scrolling
if (view && !hasOverflowScroll())
renderer()->repaintUsingContainer(repaintContainer, rectForRepaint);
+ if (view && hasOverflowScroll() && backing() && backing()->graphicsLayer())
+ static_cast<GraphicsLayerAndroid*>(backing()->graphicsLayer())->updateScrollOffset();
#else
if (view)
renderer()->repaintUsingContainer(repaintContainer, rectForRepaint);
diff --git a/Source/WebCore/rendering/RenderLayerCompositor.cpp b/Source/WebCore/rendering/RenderLayerCompositor.cpp
index 33bf2f7..03f1e41 100644
--- a/Source/WebCore/rendering/RenderLayerCompositor.cpp
+++ b/Source/WebCore/rendering/RenderLayerCompositor.cpp
@@ -92,6 +92,10 @@ struct CompositingState {
RenderLayer* m_compositingAncestor;
bool m_subtreeIsCompositing;
+ // m_compositingBounds is only used in computeCompositingRequirements. It can be either the
+ // ancestor bounds or the bounds for the sibling layers which are above the composited layer.
+ // It is used to reject creating unnecesary layers.
+ IntRect m_compositingBounds;
#if ENABLE(COMPOSITED_FIXED_ELEMENTS)
bool m_fixedSibling;
bool m_hasFixedElement;
@@ -693,7 +697,10 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O
if (absBounds.isEmpty())
absBounds.setSize(IntSize(1, 1));
haveComputedBounds = true;
- mustOverlapCompositedLayers = overlapsCompositedLayers(*overlapMap, absBounds);
+ // If the current subtree is not compositing, and the layer is fully inside the current compositing bounnds,
+ // there is no need to do the overlap test. This reduces the total number of the composited layers.
+ if (compositingState.m_subtreeIsCompositing || !compositingState.m_compositingBounds.contains(absBounds))
+ mustOverlapCompositedLayers = overlapsCompositedLayers(*overlapMap, absBounds);
}
#if ENABLE(COMPOSITED_FIXED_ELEMENTS)
@@ -709,6 +716,10 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O
// a compositing layer among them, so start by inheriting the compositing
// ancestor with m_subtreeIsCompositing set to false.
CompositingState childState(compositingState.m_compositingAncestor);
+ if (compositingState.m_subtreeIsCompositing)
+ childState.m_compositingBounds = absBounds;
+ else
+ childState.m_compositingBounds = compositingState.m_compositingBounds;
#ifndef NDEBUG
++childState.m_depth;
#endif
@@ -729,6 +740,7 @@ void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* layer, O
compositingState.m_subtreeIsCompositing = true;
// This layer now acts as the ancestor for kids.
childState.m_compositingAncestor = layer;
+ childState.m_compositingBounds = absBounds;
if (overlapMap)
addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds);
}
diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h
index fad5a7b..ea01064 100644
--- a/Source/WebCore/rendering/style/RenderStyle.h
+++ b/Source/WebCore/rendering/style/RenderStyle.h
@@ -786,19 +786,6 @@ public:
ESpeak speak() { return static_cast<ESpeak>(rareInheritedData->speak); }
-#ifdef ANDROID_CSS_RING
- // called when building nav cache to determine if the ring data is unchanged
- const void* ringData() const { return reinterpret_cast<const void*>(rareInheritedData.get()); }
- Color ringFillColor() const { return rareInheritedData->ringFillColor; }
- Length ringInnerWidth() const { return rareInheritedData->ringInnerWidth; }
- Length ringOuterWidth() const { return rareInheritedData->ringOuterWidth; }
- Length ringOutset() const { return rareInheritedData->ringOutset; }
- Color ringPressedInnerColor() const { return rareInheritedData->ringPressedInnerColor; }
- Color ringPressedOuterColor() const { return rareInheritedData->ringPressedOuterColor; }
- Length ringRadius() const { return rareInheritedData->ringRadius; }
- Color ringSelectedInnerColor() const { return rareInheritedData->ringSelectedInnerColor; }
- Color ringSelectedOuterColor() const { return rareInheritedData->ringSelectedOuterColor; }
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; }
#endif
@@ -1142,21 +1129,6 @@ public:
void setTextSizeAdjust(bool b) { SET_VAR(rareInheritedData, textSizeAdjust, b); }
void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); }
-#ifdef ANDROID_CSS_RING
- void setRingFillColor(const Color& v) { SET_VAR(rareInheritedData, ringFillColor, v); }
- void setRingInnerWidth(Length v) { SET_VAR(rareInheritedData, ringInnerWidth, v); }
- void setRingOuterWidth(Length v) { SET_VAR(rareInheritedData, ringOuterWidth, v); }
- void setRingOutset(Length v) { SET_VAR(rareInheritedData, ringOutset, v); }
- void setRingPressedInnerColor(const Color& v) {
- SET_VAR(rareInheritedData, ringPressedInnerColor, v); }
- void setRingPressedOuterColor(const Color& v) {
- SET_VAR(rareInheritedData, ringPressedOuterColor, v); }
- void setRingRadius(Length v) { SET_VAR(rareInheritedData, ringRadius, v); }
- void setRingSelectedInnerColor(const Color& v) {
- SET_VAR(rareInheritedData, ringSelectedInnerColor, v); }
- void setRingSelectedOuterColor(const Color& v) {
- SET_VAR(rareInheritedData, ringSelectedOuterColor, v); }
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
void setTapHighlightColor(const Color& v) { SET_VAR(rareInheritedData, tapHighlightColor, v); }
#endif
@@ -1359,17 +1331,6 @@ public:
static const Vector<StyleDashboardRegion>& noneDashboardRegions();
#endif
-#ifdef ANDROID_CSS_RING
- static Color initialRingFillColor() { return Color::ringFill; }
- static Length initialRingInnerWidth() { return Length(16, Fixed); } // 1.0
- static Length initialRingOuterWidth() { return Length(40, Fixed); } // 2.5
- static Length initialRingOutset() { return Length(3, Fixed); }
- static Color initialRingSelectedInnerColor() { return Color::ringSelectedInner; }
- static Color initialRingSelectedOuterColor() { return Color::ringSelectedOuter; }
- static Color initialRingPressedInnerColor() { return Color::ringPressedInner; }
- static Color initialRingPressedOuterColor() { return Color::ringPressedOuter; }
- static Length initialRingRadius() { return Length(1, Fixed); }
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
static Color initialTapHighlightColor() { return Color::tap; }
#endif
diff --git a/Source/WebCore/rendering/style/StyleRareInheritedData.cpp b/Source/WebCore/rendering/style/StyleRareInheritedData.cpp
index 2253d1c..a7acc4a 100644
--- a/Source/WebCore/rendering/style/StyleRareInheritedData.cpp
+++ b/Source/WebCore/rendering/style/StyleRareInheritedData.cpp
@@ -32,17 +32,6 @@ namespace WebCore {
StyleRareInheritedData::StyleRareInheritedData()
: textStrokeWidth(RenderStyle::initialTextStrokeWidth())
-#ifdef ANDROID_CSS_RING
- , ringFillColor(RenderStyle::initialRingFillColor())
- , ringInnerWidth(RenderStyle::initialRingInnerWidth())
- , ringOuterWidth(RenderStyle::initialRingOuterWidth())
- , ringOutset(RenderStyle::initialRingOutset())
- , ringPressedInnerColor(RenderStyle::initialRingPressedInnerColor())
- , ringPressedOuterColor(RenderStyle::initialRingPressedOuterColor())
- , ringRadius(RenderStyle::initialRingRadius())
- , ringSelectedInnerColor(RenderStyle::initialRingSelectedInnerColor())
- , ringSelectedOuterColor(RenderStyle::initialRingSelectedOuterColor())
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
, tapHighlightColor(RenderStyle::initialTapHighlightColor())
#endif
@@ -77,18 +66,6 @@ StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
, textStrokeColor(o.textStrokeColor)
, textStrokeWidth(o.textStrokeWidth)
, textFillColor(o.textFillColor)
- , textEmphasisColor(o.textEmphasisColor)
-#ifdef ANDROID_CSS_RING
- , ringFillColor(o.ringFillColor)
- , ringInnerWidth(o.ringInnerWidth)
- , ringOuterWidth(o.ringOuterWidth)
- , ringOutset(o.ringOutset)
- , ringPressedInnerColor(o.ringPressedInnerColor)
- , ringPressedOuterColor(o.ringPressedOuterColor)
- , ringRadius(o.ringRadius)
- , ringSelectedInnerColor(o.ringSelectedInnerColor)
- , ringSelectedOuterColor(o.ringSelectedOuterColor)
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
, tapHighlightColor(o.tapHighlightColor)
#endif
@@ -157,17 +134,6 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
&& nbspMode == o.nbspMode
&& khtmlLineBreak == o.khtmlLineBreak
&& textSizeAdjust == o.textSizeAdjust
-#ifdef ANDROID_CSS_RING
- && ringFillColor == o.ringFillColor
- && ringInnerWidth == o.ringInnerWidth
- && ringOuterWidth == o.ringOuterWidth
- && ringOutset == o.ringOutset
- && ringPressedInnerColor == o.ringPressedInnerColor
- && ringPressedOuterColor == o.ringPressedOuterColor
- && ringRadius == o.ringRadius
- && ringSelectedInnerColor == o.ringSelectedInnerColor
- && ringSelectedOuterColor == o.ringSelectedOuterColor
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
&& tapHighlightColor == o.tapHighlightColor
#endif
diff --git a/Source/WebCore/rendering/style/StyleRareInheritedData.h b/Source/WebCore/rendering/style/StyleRareInheritedData.h
index 39cfe3c..16fcc5f 100644
--- a/Source/WebCore/rendering/style/StyleRareInheritedData.h
+++ b/Source/WebCore/rendering/style/StyleRareInheritedData.h
@@ -58,17 +58,6 @@ public:
Color textFillColor;
Color textEmphasisColor;
-#ifdef ANDROID_CSS_RING
- Color ringFillColor;
- Length ringInnerWidth;
- Length ringOuterWidth;
- Length ringOutset;
- Color ringPressedInnerColor;
- Color ringPressedOuterColor;
- Length ringRadius;
- Color ringSelectedInnerColor;
- Color ringSelectedOuterColor;
-#endif
#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
Color tapHighlightColor;
#endif
diff --git a/Source/WebCore/storage/AbstractDatabase.h b/Source/WebCore/storage/AbstractDatabase.h
index 9279adc..e0a277f 100644
--- a/Source/WebCore/storage/AbstractDatabase.h
+++ b/Source/WebCore/storage/AbstractDatabase.h
@@ -36,7 +36,7 @@
#include "SQLiteDatabase.h"
#include <wtf/Forward.h>
#include <wtf/ThreadSafeRefCounted.h>
-#ifndef NDEBUG
+#if !LOG_DISABLED || !ERROR_DISABLED
#include "SecurityOrigin.h"
#endif
@@ -109,7 +109,7 @@ protected:
unsigned long m_estimatedSize;
String m_filename;
-#ifndef NDEBUG
+#if !LOG_DISABLED || !ERROR_DISABLED
String databaseDebugName() const { return m_contextThreadSecurityOrigin->toString() + "::" + m_name; }
#endif
diff --git a/Source/WebCore/storage/DatabaseTask.cpp b/Source/WebCore/storage/DatabaseTask.cpp
index 343ae1e..ad744e5 100644
--- a/Source/WebCore/storage/DatabaseTask.cpp
+++ b/Source/WebCore/storage/DatabaseTask.cpp
@@ -62,7 +62,7 @@ void DatabaseTaskSynchronizer::taskCompleted()
DatabaseTask::DatabaseTask(Database* database, DatabaseTaskSynchronizer* synchronizer)
: m_database(database)
, m_synchronizer(synchronizer)
-#ifndef NDEBUG
+#if !LOG_DISABLED
, m_complete(false)
#endif
{
@@ -70,13 +70,17 @@ DatabaseTask::DatabaseTask(Database* database, DatabaseTaskSynchronizer* synchro
DatabaseTask::~DatabaseTask()
{
+#if !LOG_DISABLED
ASSERT(m_complete || !m_synchronizer);
+#endif
}
void DatabaseTask::performTask()
{
// Database tasks are meant to be used only once, so make sure this one hasn't been performed before.
+#if !LOG_DISABLED
ASSERT(!m_complete);
+#endif
LOG(StorageAPI, "Performing %s %p\n", debugTaskName(), this);
@@ -86,7 +90,7 @@ void DatabaseTask::performTask()
if (m_synchronizer)
m_synchronizer->taskCompleted();
-#ifndef NDEBUG
+#if !LOG_DISABLED
m_complete = true;
#endif
}
@@ -108,7 +112,7 @@ void Database::DatabaseOpenTask::doPerformTask()
m_success = database()->performOpenAndVerify(m_setVersionInNewDatabase, m_code);
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
const char* Database::DatabaseOpenTask::debugTaskName() const
{
return "DatabaseOpenTask";
@@ -128,7 +132,7 @@ void Database::DatabaseCloseTask::doPerformTask()
database()->close();
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
const char* Database::DatabaseCloseTask::debugTaskName() const
{
return "DatabaseCloseTask";
@@ -150,7 +154,7 @@ void Database::DatabaseTransactionTask::doPerformTask()
m_transaction->database()->inProgressTransactionCompleted();
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
const char* Database::DatabaseTransactionTask::debugTaskName() const
{
return "DatabaseTransactionTask";
@@ -172,7 +176,7 @@ void Database::DatabaseTableNamesTask::doPerformTask()
m_tableNames = database()->performGetTableNames();
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
const char* Database::DatabaseTableNamesTask::debugTaskName() const
{
return "DatabaseTableNamesTask";
diff --git a/Source/WebCore/storage/DatabaseTask.h b/Source/WebCore/storage/DatabaseTask.h
index e1df591..faadc69 100644
--- a/Source/WebCore/storage/DatabaseTask.h
+++ b/Source/WebCore/storage/DatabaseTask.h
@@ -90,7 +90,7 @@ private:
Database* m_database;
DatabaseTaskSynchronizer* m_synchronizer;
-#ifndef NDEBUG
+#if !LOG_DISABLED
virtual const char* debugTaskName() const = 0;
bool m_complete;
#endif
@@ -107,7 +107,7 @@ private:
DatabaseOpenTask(Database*, bool setVersionInNewDatabase, DatabaseTaskSynchronizer*, ExceptionCode&, bool& success);
virtual void doPerformTask();
-#ifndef NDEBUG
+#if !LOG_DISABLED
virtual const char* debugTaskName() const;
#endif
@@ -127,7 +127,7 @@ private:
DatabaseCloseTask(Database*, DatabaseTaskSynchronizer*);
virtual void doPerformTask();
-#ifndef NDEBUG
+#if !LOG_DISABLED
virtual const char* debugTaskName() const;
#endif
};
@@ -146,7 +146,7 @@ private:
DatabaseTransactionTask(PassRefPtr<SQLTransaction>);
virtual void doPerformTask();
-#ifndef NDEBUG
+#if !LOG_DISABLED
virtual const char* debugTaskName() const;
#endif
@@ -164,7 +164,7 @@ private:
DatabaseTableNamesTask(Database*, DatabaseTaskSynchronizer*, Vector<String>& names);
virtual void doPerformTask();
-#ifndef NDEBUG
+#if !LOG_DISABLED
virtual const char* debugTaskName() const;
#endif
diff --git a/Source/WebCore/storage/SQLTransaction.cpp b/Source/WebCore/storage/SQLTransaction.cpp
index dfcd568..0b1ad25 100644
--- a/Source/WebCore/storage/SQLTransaction.cpp
+++ b/Source/WebCore/storage/SQLTransaction.cpp
@@ -117,7 +117,7 @@ void SQLTransaction::enqueueStatement(PassRefPtr<SQLStatement> statement)
m_statementQueue.append(statement);
}
-#ifndef NDEBUG
+#if !LOG_DISABLED
const char* SQLTransaction::debugStepName(SQLTransaction::TransactionStepMethod step)
{
if (step == &SQLTransaction::acquireLock)
diff --git a/Source/WebCore/storage/SQLTransaction.h b/Source/WebCore/storage/SQLTransaction.h
index 4c84f91..a0a83ed 100644
--- a/Source/WebCore/storage/SQLTransaction.h
+++ b/Source/WebCore/storage/SQLTransaction.h
@@ -105,7 +105,7 @@ private:
void deliverTransactionErrorCallback();
void cleanupAfterTransactionErrorCallback();
-#ifndef NDEBUG
+#if !LOG_DISABLED
static const char* debugStepName(TransactionStepMethod);
#endif
diff --git a/Source/WebCore/svg/SVGFontFaceUriElement.h b/Source/WebCore/svg/SVGFontFaceUriElement.h
index ad9ba97..3806315 100644
--- a/Source/WebCore/svg/SVGFontFaceUriElement.h
+++ b/Source/WebCore/svg/SVGFontFaceUriElement.h
@@ -45,22 +45,6 @@ private:
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
virtual void insertedIntoDocument();
-#ifdef ANDROID_INSTRUMENT
- void* operator new(size_t size) {
- return SVGElement::operator new(size);
- }
- void* operator new[](size_t size) {
- return SVGElement::operator new[](size);
- }
-
- void operator delete(void* p, size_t size) {
- SVGElement::operator delete(p, size);
- }
- void operator delete[](void* p, size_t size) {
- SVGElement::operator delete[](p, size);
- }
-#endif
-
void loadFont();
CachedResourceHandle<CachedFont> m_cachedFont;
diff --git a/Source/WebCore/workers/WorkerContext.idl b/Source/WebCore/workers/WorkerContext.idl
index e31f5ad..5a6c407 100644
--- a/Source/WebCore/workers/WorkerContext.idl
+++ b/Source/WebCore/workers/WorkerContext.idl
@@ -126,6 +126,7 @@ module threads {
attribute Int32ArrayConstructor Int32Array; // Usable with new operator
attribute Uint32ArrayConstructor Uint32Array; // Usable with new operator
attribute Float32ArrayConstructor Float32Array; // Usable with new operator
+ attribute Float64ArrayConstructor Float64Array; // Usable with new operator
};
}
diff --git a/Source/WebCore/xml/XSLImportRule.h b/Source/WebCore/xml/XSLImportRule.h
index 3c5939d..5c0ca8a 100644
--- a/Source/WebCore/xml/XSLImportRule.h
+++ b/Source/WebCore/xml/XSLImportRule.h
@@ -52,22 +52,6 @@ public:
bool isLoading();
void loadSheet();
-#ifdef ANDROID_INSTRUMENT
- void* operator new(size_t size) {
- return StyleBase::operator new(size);
- }
- void* operator new[](size_t size) {
- return StyleBase::operator new[](size);
- }
-
- void operator delete(void* p, size_t size) {
- StyleBase::operator delete(p, size);
- }
- void operator delete[](void* p, size_t size) {
- StyleBase::operator delete[](p, size);
- }
-#endif
-
private:
XSLImportRule(XSLStyleSheet* parentSheet, const String& href);