summaryrefslogtreecommitdiff
path: root/native
diff options
context:
space:
mode:
Diffstat (limited to 'native')
-rw-r--r--native/android/Android.bp1
-rw-r--r--native/android/OWNERS11
-rw-r--r--native/android/asset_manager.cpp28
-rw-r--r--native/android/configuration.cpp9
-rw-r--r--native/android/libandroid.map.txt10
-rw-r--r--native/android/net.c2
-rw-r--r--native/android/storage_manager.cpp2
-rw-r--r--native/android/surface_texture.cpp75
-rw-r--r--native/graphics/jni/Android.bp26
-rw-r--r--native/graphics/jni/Android.mk40
-rw-r--r--native/graphics/jni/bitmap.cpp3
-rw-r--r--native/webview/OWNERS3
-rw-r--r--native/webview/loader/loader.cpp27
-rw-r--r--native/webview/plat_support/Android.mk52
-rw-r--r--native/webview/plat_support/LICENSE27
-rw-r--r--native/webview/plat_support/draw_gl.h131
-rw-r--r--native/webview/plat_support/draw_gl_functor.cpp162
-rw-r--r--native/webview/plat_support/draw_sw.h66
-rw-r--r--native/webview/plat_support/graphic_buffer_impl.cpp113
-rw-r--r--native/webview/plat_support/graphic_buffer_impl.h53
-rw-r--r--native/webview/plat_support/graphics_utils.cpp112
-rw-r--r--native/webview/plat_support/jni_entry_point.cpp37
22 files changed, 904 insertions, 86 deletions
diff --git a/native/android/Android.bp b/native/android/Android.bp
index 00fe6382fc17..4fb5e748aaac 100644
--- a/native/android/Android.bp
+++ b/native/android/Android.bp
@@ -48,6 +48,7 @@ cc_library_shared {
"sensor.cpp",
"sharedmem.cpp",
"storage_manager.cpp",
+ "surface_texture.cpp",
"trace.cpp",
],
diff --git a/native/android/OWNERS b/native/android/OWNERS
new file mode 100644
index 000000000000..11d4be43571e
--- /dev/null
+++ b/native/android/OWNERS
@@ -0,0 +1,11 @@
+set noparent
+
+per-file libandroid_net.map.txt=ek@google.com
+per-file libandroid_net.map.txt=jchalard@google.com
+per-file libandroid_net.map.txt=lorenzo@google.com
+per-file libandroid_net.map.txt=satk@google.com
+
+per-file net.c=ek@google.com
+per-file net.c=jchalard@google.com
+per-file net.c=lorenzo@google.com
+per-file net.c=satk@google.com
diff --git a/native/android/asset_manager.cpp b/native/android/asset_manager.cpp
index 98e9a42d944d..e70d5ea0d566 100644
--- a/native/android/asset_manager.cpp
+++ b/native/android/asset_manager.cpp
@@ -18,9 +18,11 @@
#include <utils/Log.h>
#include <android/asset_manager_jni.h>
+#include <android_runtime/android_util_AssetManager.h>
#include <androidfw/Asset.h>
#include <androidfw/AssetDir.h>
#include <androidfw/AssetManager.h>
+#include <androidfw/AssetManager2.h>
#include <utils/threads.h>
#include "jni.h"
@@ -35,21 +37,20 @@ using namespace android;
// -----
struct AAssetDir {
- AssetDir* mAssetDir;
+ std::unique_ptr<AssetDir> mAssetDir;
size_t mCurFileIndex;
String8 mCachedFileName;
- explicit AAssetDir(AssetDir* dir) : mAssetDir(dir), mCurFileIndex(0) { }
- ~AAssetDir() { delete mAssetDir; }
+ explicit AAssetDir(std::unique_ptr<AssetDir> dir) :
+ mAssetDir(std::move(dir)), mCurFileIndex(0) { }
};
// -----
struct AAsset {
- Asset* mAsset;
+ std::unique_ptr<Asset> mAsset;
- explicit AAsset(Asset* asset) : mAsset(asset) { }
- ~AAsset() { delete mAsset; }
+ explicit AAsset(std::unique_ptr<Asset> asset) : mAsset(std::move(asset)) { }
};
// -------------------- Public native C API --------------------
@@ -104,19 +105,18 @@ AAsset* AAssetManager_open(AAssetManager* amgr, const char* filename, int mode)
return NULL;
}
- AssetManager* mgr = static_cast<AssetManager*>(amgr);
- Asset* asset = mgr->open(filename, amMode);
- if (asset == NULL) {
- return NULL;
+ ScopedLock<AssetManager2> locked_mgr(*AssetManagerForNdkAssetManager(amgr));
+ std::unique_ptr<Asset> asset = locked_mgr->Open(filename, amMode);
+ if (asset == nullptr) {
+ return nullptr;
}
-
- return new AAsset(asset);
+ return new AAsset(std::move(asset));
}
AAssetDir* AAssetManager_openDir(AAssetManager* amgr, const char* dirName)
{
- AssetManager* mgr = static_cast<AssetManager*>(amgr);
- return new AAssetDir(mgr->openDir(dirName));
+ ScopedLock<AssetManager2> locked_mgr(*AssetManagerForNdkAssetManager(amgr));
+ return new AAssetDir(locked_mgr->OpenDir(dirName));
}
/**
diff --git a/native/android/configuration.cpp b/native/android/configuration.cpp
index 77237ae97ff5..87fe9edb49c5 100644
--- a/native/android/configuration.cpp
+++ b/native/android/configuration.cpp
@@ -17,9 +17,10 @@
#define LOG_TAG "Configuration"
#include <utils/Log.h>
-#include <androidfw/AssetManager.h>
+#include <androidfw/AssetManager2.h>
#include <android_runtime/android_content_res_Configuration.h>
+#include <android_runtime/android_util_AssetManager.h>
using namespace android;
@@ -34,7 +35,11 @@ void AConfiguration_delete(AConfiguration* config) {
}
void AConfiguration_fromAssetManager(AConfiguration* out, AAssetManager* am) {
- ((AssetManager*)am)->getConfiguration(out);
+ ScopedLock<AssetManager2> locked_mgr(*AssetManagerForNdkAssetManager(am));
+ ResTable_config config = locked_mgr->GetConfiguration();
+
+ // AConfiguration is not a virtual subclass, so we can memcpy.
+ memcpy(out, &config, sizeof(config));
}
void AConfiguration_copy(AConfiguration* dest, AConfiguration* src) {
diff --git a/native/android/libandroid.map.txt b/native/android/libandroid.map.txt
index bbd27839d551..d6dcd723e721 100644
--- a/native/android/libandroid.map.txt
+++ b/native/android/libandroid.map.txt
@@ -205,14 +205,20 @@ LIBANDROID {
AStorageManager_mountObb;
AStorageManager_new;
AStorageManager_unmountObb;
+ ASurfaceTexture_acquireANativeWindow; # introduced=28
+ ASurfaceTexture_attachToGLContext; # introduced=28
+ ASurfaceTexture_detachFromGLContext; # introduced=28
+ ASurfaceTexture_fromSurfaceTexture; # introduced=28
+ ASurfaceTexture_getTimestamp; # introduced=28
+ ASurfaceTexture_getTransformMatrix; # introduced=28
+ ASurfaceTexture_release; # introduced=28
+ ASurfaceTexture_updateTexImage; # introduced=28
ATrace_beginSection; # introduced=23
ATrace_endSection; # introduced=23
ATrace_isEnabled; # introduced=23
- android_getTtsEngine; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=13 introduced-x86_64=21
android_getaddrinfofornetwork; # introduced=23
android_setprocnetwork; # introduced=23
android_setsocknetwork; # introduced=23
- getTtsEngine; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=13 introduced-x86_64=21
local:
*;
};
diff --git a/native/android/net.c b/native/android/net.c
index de4b90cc1956..60296a7bd00c 100644
--- a/native/android/net.c
+++ b/native/android/net.c
@@ -27,7 +27,7 @@ static int getnetidfromhandle(net_handle_t handle, unsigned *netid) {
static const uint32_t k32BitMask = 0xffffffff;
// This value MUST be kept in sync with the corresponding value in
// the android.net.Network#getNetworkHandle() implementation.
- static const uint32_t kHandleMagic = 0xfacade;
+ static const uint32_t kHandleMagic = 0xcafed00d;
// Check for minimum acceptable version of the API in the low bits.
if (handle != NETWORK_UNSPECIFIED &&
diff --git a/native/android/storage_manager.cpp b/native/android/storage_manager.cpp
index 137b72cf14e3..bf15b8d075e7 100644
--- a/native/android/storage_manager.cpp
+++ b/native/android/storage_manager.cpp
@@ -21,7 +21,7 @@
#include <binder/Binder.h>
#include <binder/IServiceManager.h>
-#include <utils/Atomic.h>
+#include <cutils/atomic.h>
#include <utils/Log.h>
#include <utils/RefBase.h>
#include <utils/String8.h>
diff --git a/native/android/surface_texture.cpp b/native/android/surface_texture.cpp
new file mode 100644
index 000000000000..b26688190ccd
--- /dev/null
+++ b/native/android/surface_texture.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android/surface_texture.h>
+#include <android/surface_texture_jni.h>
+
+#define LOG_TAG "ASurfaceTexture"
+
+#include <utils/Log.h>
+
+#include <gui/GLConsumer.h>
+#include <gui/Surface.h>
+
+#include <android_runtime/android_graphics_SurfaceTexture.h>
+
+using namespace android;
+
+struct ASurfaceTexture {
+ sp<GLConsumer> consumer;
+ sp<IGraphicBufferProducer> producer;
+};
+
+ASurfaceTexture* ASurfaceTexture_fromSurfaceTexture(JNIEnv* env, jobject surfacetexture) {
+ if (!surfacetexture || !android_SurfaceTexture_isInstanceOf(env, surfacetexture)) {
+ return nullptr;
+ }
+ ASurfaceTexture* ast = new ASurfaceTexture;
+ ast->consumer = SurfaceTexture_getSurfaceTexture(env, surfacetexture);
+ ast->producer = SurfaceTexture_getProducer(env, surfacetexture);
+ return ast;
+}
+
+ANativeWindow* ASurfaceTexture_acquireANativeWindow(ASurfaceTexture* st) {
+ sp<Surface> surface = new Surface(st->producer);
+ ANativeWindow* win(surface.get());
+ ANativeWindow_acquire(win);
+ return win;
+}
+
+void ASurfaceTexture_release(ASurfaceTexture* st) {
+ delete st;
+}
+
+int ASurfaceTexture_attachToGLContext(ASurfaceTexture* st, uint32_t tex) {
+ return st->consumer->attachToContext(tex);
+}
+
+int ASurfaceTexture_detachFromGLContext(ASurfaceTexture* st) {
+ return st->consumer->detachFromContext();
+}
+
+int ASurfaceTexture_updateTexImage(ASurfaceTexture* st) {
+ return st->consumer->updateTexImage();
+}
+
+void ASurfaceTexture_getTransformMatrix(ASurfaceTexture* st, float mtx[16]) {
+ st->consumer->getTransformMatrix(mtx);
+}
+
+int64_t ASurfaceTexture_getTimestamp(ASurfaceTexture* st) {
+ return st->consumer->getTimestamp();
+}
diff --git a/native/graphics/jni/Android.bp b/native/graphics/jni/Android.bp
index d456950037d4..0704e3545b62 100644
--- a/native/graphics/jni/Android.bp
+++ b/native/graphics/jni/Android.bp
@@ -12,6 +12,32 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+cc_library_shared {
+ name: "libjnigraphics",
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wunused",
+ "-Wunreachable-code",
+ ],
+
+ // our source files
+ //
+ srcs: ["bitmap.cpp"],
+
+ shared_libs: [
+ "libandroid_runtime",
+ ],
+
+ arch: {
+ arm: {
+ // TODO: This is to work around b/24465209. Remove after root cause is fixed
+ ldflags: ["-Wl,--hash-style=both"],
+ },
+ },
+}
+
// The headers module is in frameworks/native/Android.bp.
ndk_library {
name: "libjnigraphics",
diff --git a/native/graphics/jni/Android.mk b/native/graphics/jni/Android.mk
deleted file mode 100644
index ec4b35aac9c3..000000000000
--- a/native/graphics/jni/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-BASE_PATH := $(call my-dir)
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# setup for skia optimizations
-#
-ifneq ($(ARCH_ARM_HAVE_VFP),true)
- LOCAL_CFLAGS += -DSK_SOFTWARE_FLOAT
-endif
-
-ifeq ($(ARCH_ARM_HAVE_NEON),true)
- LOCAL_CFLAGS += -D__ARM_HAVE_NEON
-endif
-
-# our source files
-#
-LOCAL_SRC_FILES:= \
- bitmap.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libandroid_runtime \
- libskia \
- libui \
- libandroidfw
-
-LOCAL_C_INCLUDES += \
- frameworks/base/native/include \
- frameworks/base/core/jni/android/graphics \
- frameworks/base/libs/hwui
-
-LOCAL_MODULE:= libjnigraphics
-
-LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
-
-# TODO: This is to work around b/24465209. Remove after root cause is fixed
-LOCAL_LDFLAGS_arm := -Wl,--hash-style=both
-
-include $(BUILD_SHARED_LIBRARY)
-
diff --git a/native/graphics/jni/bitmap.cpp b/native/graphics/jni/bitmap.cpp
index bf5cabbe4bc2..ff14832a2f0f 100644
--- a/native/graphics/jni/bitmap.cpp
+++ b/native/graphics/jni/bitmap.cpp
@@ -15,7 +15,7 @@
*/
#include <android/bitmap.h>
-#include <Bitmap.h>
+#include <android/graphics/Bitmap.h>
int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap,
AndroidBitmapInfo* info) {
@@ -56,4 +56,3 @@ int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap) {
}
return ANDROID_BITMAP_RESULT_SUCCESS;
}
-
diff --git a/native/webview/OWNERS b/native/webview/OWNERS
index deee852093d7..00e540a46ab2 100644
--- a/native/webview/OWNERS
+++ b/native/webview/OWNERS
@@ -1,4 +1,3 @@
-boliu@google.com
-sgurun@google.com
+changwan@google.com
tobiasjs@google.com
torne@google.com
diff --git a/native/webview/loader/loader.cpp b/native/webview/loader/loader.cpp
index 376dbb844906..adb371dde0fc 100644
--- a/native/webview/loader/loader.cpp
+++ b/native/webview/loader/loader.cpp
@@ -143,17 +143,7 @@ jboolean ReserveAddressSpace(JNIEnv*, jclass, jlong size) {
return DoReserveAddressSpace(size);
}
-jboolean CreateRelroFile(JNIEnv* env, jclass, jstring lib32, jstring lib64,
- jstring relro32, jstring relro64) {
-#ifdef __LP64__
- jstring lib = lib64;
- jstring relro = relro64;
- (void)lib32; (void)relro32;
-#else
- jstring lib = lib32;
- jstring relro = relro32;
- (void)lib64; (void)relro64;
-#endif
+jboolean CreateRelroFile(JNIEnv* env, jclass, jstring lib, jstring relro) {
jboolean ret = JNI_FALSE;
const char* lib_utf8 = env->GetStringUTFChars(lib, NULL);
if (lib_utf8 != NULL) {
@@ -167,15 +157,8 @@ jboolean CreateRelroFile(JNIEnv* env, jclass, jstring lib32, jstring lib64,
return ret;
}
-jint LoadWithRelroFile(JNIEnv* env, jclass, jstring lib, jstring relro32,
- jstring relro64, jobject clazzLoader) {
-#ifdef __LP64__
- jstring relro = relro64;
- (void)relro32;
-#else
- jstring relro = relro32;
- (void)relro64;
-#endif
+jint LoadWithRelroFile(JNIEnv* env, jclass, jstring lib, jstring relro,
+ jobject clazzLoader) {
jint ret = LIBLOAD_FAILED_JNI_CALL;
const char* lib_utf8 = env->GetStringUTFChars(lib, NULL);
if (lib_utf8 != NULL) {
@@ -196,10 +179,10 @@ const JNINativeMethod kJniMethods[] = {
{ "nativeReserveAddressSpace", "(J)Z",
reinterpret_cast<void*>(ReserveAddressSpace) },
{ "nativeCreateRelroFile",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z",
+ "(Ljava/lang/String;Ljava/lang/String;)Z",
reinterpret_cast<void*>(CreateRelroFile) },
{ "nativeLoadWithRelroFile",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/ClassLoader;)I",
+ "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/ClassLoader;)I",
reinterpret_cast<void*>(LoadWithRelroFile) },
};
diff --git a/native/webview/plat_support/Android.mk b/native/webview/plat_support/Android.mk
new file mode 100644
index 000000000000..6a33fe208416
--- /dev/null
+++ b/native/webview/plat_support/Android.mk
@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This package provides the system interfaces allowing WebView to render.
+
+LOCAL_PATH := $(call my-dir)
+
+# Native support library (libwebviewchromium_plat_support.so) - does NOT link
+# any native chromium code.
+include $(CLEAR_VARS)
+
+LOCAL_MODULE:= libwebviewchromium_plat_support
+
+LOCAL_SRC_FILES:= \
+ draw_gl_functor.cpp \
+ jni_entry_point.cpp \
+ graphics_utils.cpp \
+ graphic_buffer_impl.cpp \
+
+LOCAL_C_INCLUDES:= \
+ external/skia/include/core \
+ frameworks/base/core/jni/android/graphics \
+ frameworks/native/include/ui \
+
+LOCAL_SHARED_LIBRARIES += \
+ libandroid_runtime \
+ liblog \
+ libcutils \
+ libui \
+ libutils \
+ libhwui \
+ libandroidfw
+
+LOCAL_MODULE_TAGS := optional
+
+# To remove warnings from skia header files
+LOCAL_CFLAGS := -Wno-unused-parameter
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/native/webview/plat_support/LICENSE b/native/webview/plat_support/LICENSE
new file mode 100644
index 000000000000..972bb2edb099
--- /dev/null
+++ b/native/webview/plat_support/LICENSE
@@ -0,0 +1,27 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+//
+// 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.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "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.
diff --git a/native/webview/plat_support/draw_gl.h b/native/webview/plat_support/draw_gl.h
new file mode 100644
index 000000000000..c8434b61eba5
--- /dev/null
+++ b/native/webview/plat_support/draw_gl.h
@@ -0,0 +1,131 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+//******************************************************************************
+// This is a copy of the coresponding android_webview/public/browser header.
+// Any changes to the interface should be made there.
+//
+// The purpose of having the copy is twofold:
+// - it removes the need to have Chromium sources present in the tree in order
+// to build the plat_support library,
+// - it captures API that the corresponding Android release supports.
+//******************************************************************************
+
+#ifndef ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_
+#define ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// 1 is L/L MR1
+//
+// 2 starts at M, and added an imperfect workaround for complex clipping by
+// elevating the WebView into an FBO layer. If any transform, clip, or outline
+// clip occurs that would either likely use the stencil buffer for clipping, or
+// require shader based clipping in HWUI, the WebView is drawn into an FBO (if
+// it fits).
+// This is a temporary workaround for a lack of WebView support for stencil/
+// shader based round rect clipping, and should be removed when webview is
+// capable of supporting these clips internally when drawing.
+//
+// 3 starts during development of P, when android defaults from HWUI to skia as
+// the GL renderer. Skia already maintains and restores its GL state, so there
+// is no need for WebView to restore this state. Skia also no longer promises
+// GL state on entering draw, such as no vertex array buffer binding.
+static const int kAwDrawGLInfoVersion = 3;
+
+// Holds the information required to trigger an OpenGL drawing operation.
+struct AwDrawGLInfo {
+ int version; // The AwDrawGLInfo this struct was built with.
+
+ // Input: tells the draw function what action to perform.
+ enum Mode {
+ kModeDraw = 0,
+ kModeProcess,
+ kModeProcessNoContext,
+ kModeSync,
+ } mode;
+
+ // Input: current clip rect in surface coordinates. Reflects the current state
+ // of the OpenGL scissor rect. Both the OpenGL scissor rect and viewport are
+ // set by the caller of the draw function and updated during View animations.
+ int clip_left;
+ int clip_top;
+ int clip_right;
+ int clip_bottom;
+
+ // Input: current width/height of destination surface.
+ int width;
+ int height;
+
+ // Input: is the View rendered into an independent layer.
+ // If false, the surface is likely to hold to the full screen contents, with
+ // the scissor box set by the caller to the actual View location and size.
+ // Also the transformation matrix will contain at least a translation to the
+ // position of the View to render, plus any other transformations required as
+ // part of any ongoing View animation. View translucency (alpha) is ignored,
+ // although the framework will set is_layer to true for non-opaque cases.
+ // Can be requested via the View.setLayerType(View.LAYER_TYPE_NONE, ...)
+ // Android API method.
+ //
+ // If true, the surface is dedicated to the View and should have its size.
+ // The viewport and scissor box are set by the caller to the whole surface.
+ // Animation transformations are handled by the caller and not reflected in
+ // the provided transformation matrix. Translucency works normally.
+ // Can be requested via the View.setLayerType(View.LAYER_TYPE_HARDWARE, ...)
+ // Android API method.
+ bool is_layer;
+
+ // Input: current transformation matrix in surface pixels.
+ // Uses the column-based OpenGL matrix format.
+ float transform[16];
+};
+
+// Function to invoke a direct GL draw into the client's pre-configured
+// GL context. Obtained via AwContents.getDrawGLFunction() (static).
+// |view_context| is an opaque identifier that was returned by the corresponding
+// call to AwContents.getAwDrawGLViewContext().
+// |draw_info| carries the in and out parameters for this draw.
+// |spare| ignored; pass NULL.
+typedef void (AwDrawGLFunction)(long view_context,
+ AwDrawGLInfo* draw_info,
+ void* spare);
+enum AwMapMode {
+ MAP_READ_ONLY,
+ MAP_WRITE_ONLY,
+ MAP_READ_WRITE,
+};
+
+// Called to create a GraphicBuffer
+typedef long AwCreateGraphicBufferFunction(int w, int h);
+// Called to release a GraphicBuffer
+typedef void AwReleaseGraphicBufferFunction(long buffer_id);
+// Called to map a GraphicBuffer in |mode|.
+typedef int AwMapFunction(long buffer_id, AwMapMode mode, void** vaddr);
+// Called to unmap a GraphicBuffer
+typedef int AwUnmapFunction(long buffer_id);
+// Called to get a native buffer pointer
+typedef void* AwGetNativeBufferFunction(long buffer_id);
+// Called to get the stride of the buffer
+typedef unsigned int AwGetStrideFunction(long buffer_id);
+
+static const int kAwDrawGLFunctionTableVersion = 1;
+
+// Set of functions used in rendering in hardware mode
+struct AwDrawGLFunctionTable {
+ int version;
+ AwCreateGraphicBufferFunction* create_graphic_buffer;
+ AwReleaseGraphicBufferFunction* release_graphic_buffer;
+ AwMapFunction* map;
+ AwUnmapFunction* unmap;
+ AwGetNativeBufferFunction* get_native_buffer;
+ AwGetStrideFunction* get_stride;
+};
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_GL_H_
diff --git a/native/webview/plat_support/draw_gl_functor.cpp b/native/webview/plat_support/draw_gl_functor.cpp
new file mode 100644
index 000000000000..d54f558b9866
--- /dev/null
+++ b/native/webview/plat_support/draw_gl_functor.cpp
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Provides a webviewchromium glue layer adapter from the internal Android
+// GL Functor data types into the types the chromium stack expects, and back.
+
+#define LOG_TAG "webviewchromium_plat_support"
+
+#include "draw_gl.h"
+
+#include <Properties.h>
+#include <errno.h>
+#include <jni.h>
+#include <private/hwui/DrawGlInfo.h>
+#include <string.h>
+#include <sys/resource.h>
+#include <sys/time.h>
+#include <utils/Functor.h>
+#include <utils/Log.h>
+
+#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
+#define COMPILE_ASSERT(expr, err) \
+__unused static const char (err)[(expr) ? 1 : -1] = "";
+
+namespace android {
+namespace {
+
+AwDrawGLFunction* g_aw_drawgl_function = NULL;
+
+class DrawGLFunctor : public Functor {
+ public:
+ explicit DrawGLFunctor(jlong view_context) : view_context_(view_context) {}
+ virtual ~DrawGLFunctor() {}
+
+ // Functor
+ virtual status_t operator ()(int what, void* data) {
+ using uirenderer::DrawGlInfo;
+ if (!g_aw_drawgl_function) {
+ ALOGE("Cannot draw: no DrawGL Function installed");
+ return DrawGlInfo::kStatusDone;
+ }
+
+ AwDrawGLInfo aw_info;
+ // TODO(boliu): Remove property check once OpenGL fallback is removed.
+ auto render_pipeline_type =
+ android::uirenderer::Properties::getRenderPipelineType();
+ aw_info.version = (render_pipeline_type ==
+ android::uirenderer::RenderPipelineType::OpenGL)
+ ? 2
+ : kAwDrawGLInfoVersion;
+ switch (what) {
+ case DrawGlInfo::kModeDraw: {
+ aw_info.mode = AwDrawGLInfo::kModeDraw;
+ DrawGlInfo* gl_info = reinterpret_cast<DrawGlInfo*>(data);
+
+ // Map across the input values.
+ aw_info.clip_left = gl_info->clipLeft;
+ aw_info.clip_top = gl_info->clipTop;
+ aw_info.clip_right = gl_info->clipRight;
+ aw_info.clip_bottom = gl_info->clipBottom;
+ aw_info.width = gl_info->width;
+ aw_info.height = gl_info->height;
+ aw_info.is_layer = gl_info->isLayer;
+ COMPILE_ASSERT(NELEM(aw_info.transform) == NELEM(gl_info->transform),
+ mismatched_transform_matrix_sizes);
+ for (int i = 0; i < NELEM(aw_info.transform); ++i) {
+ aw_info.transform[i] = gl_info->transform[i];
+ }
+ break;
+ }
+ case DrawGlInfo::kModeProcess:
+ aw_info.mode = AwDrawGLInfo::kModeProcess;
+ break;
+ case DrawGlInfo::kModeProcessNoContext:
+ aw_info.mode = AwDrawGLInfo::kModeProcessNoContext;
+ break;
+ case DrawGlInfo::kModeSync:
+ aw_info.mode = AwDrawGLInfo::kModeSync;
+ break;
+ default:
+ ALOGE("Unexpected DrawGLInfo type %d", what);
+ return DrawGlInfo::kStatusDone;
+ }
+
+ // Invoke the DrawGL method.
+ g_aw_drawgl_function(view_context_, &aw_info, NULL);
+
+ return DrawGlInfo::kStatusDone;
+ }
+
+ private:
+ intptr_t view_context_;
+};
+
+// Raise the file handle soft limit to the hard limit since gralloc buffers
+// uses file handles.
+void RaiseFileNumberLimit() {
+ static bool have_raised_limit = false;
+ if (have_raised_limit)
+ return;
+
+ have_raised_limit = true;
+ struct rlimit limit_struct;
+ limit_struct.rlim_cur = 0;
+ limit_struct.rlim_max = 0;
+ if (getrlimit(RLIMIT_NOFILE, &limit_struct) == 0) {
+ limit_struct.rlim_cur = limit_struct.rlim_max;
+ if (setrlimit(RLIMIT_NOFILE, &limit_struct) != 0) {
+ ALOGE("setrlimit failed: %s", strerror(errno));
+ }
+ } else {
+ ALOGE("getrlimit failed: %s", strerror(errno));
+ }
+}
+
+jlong CreateGLFunctor(JNIEnv*, jclass, jlong view_context) {
+ RaiseFileNumberLimit();
+ return reinterpret_cast<jlong>(new DrawGLFunctor(view_context));
+}
+
+void DestroyGLFunctor(JNIEnv*, jclass, jlong functor) {
+ delete reinterpret_cast<DrawGLFunctor*>(functor);
+}
+
+void SetChromiumAwDrawGLFunction(JNIEnv*, jclass, jlong draw_function) {
+ g_aw_drawgl_function = reinterpret_cast<AwDrawGLFunction*>(draw_function);
+}
+
+const char kClassName[] = "com/android/webview/chromium/DrawGLFunctor";
+const JNINativeMethod kJniMethods[] = {
+ { "nativeCreateGLFunctor", "(J)J",
+ reinterpret_cast<void*>(CreateGLFunctor) },
+ { "nativeDestroyGLFunctor", "(J)V",
+ reinterpret_cast<void*>(DestroyGLFunctor) },
+ { "nativeSetChromiumAwDrawGLFunction", "(J)V",
+ reinterpret_cast<void*>(SetChromiumAwDrawGLFunction) },
+};
+
+} // namespace
+
+void RegisterDrawGLFunctor(JNIEnv* env) {
+ jclass clazz = env->FindClass(kClassName);
+ LOG_ALWAYS_FATAL_IF(!clazz, "Unable to find class '%s'", kClassName);
+
+ int res = env->RegisterNatives(clazz, kJniMethods, NELEM(kJniMethods));
+ LOG_ALWAYS_FATAL_IF(res < 0, "register native methods failed: res=%d", res);
+}
+
+} // namespace android
diff --git a/native/webview/plat_support/draw_sw.h b/native/webview/plat_support/draw_sw.h
new file mode 100644
index 000000000000..7423e13bb8be
--- /dev/null
+++ b/native/webview/plat_support/draw_sw.h
@@ -0,0 +1,66 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+//******************************************************************************
+// This is a copy of the coresponding android_webview/public/browser header.
+// Any changes to the interface should be made there.
+//
+// The purpose of having the copy is twofold:
+// - it removes the need to have Chromium sources present in the tree in order
+// to build the plat_support library,
+// - it captures API that the corresponding Android release supports.
+//******************************************************************************
+
+#ifndef ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_
+#define ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_
+
+#include <jni.h>
+#include <stddef.h>
+
+#ifndef __cplusplus
+#error "Can't mix C and C++ when using jni.h"
+#endif
+
+class SkCanvasState;
+class SkPicture;
+
+static const int kAwPixelInfoVersion = 3;
+
+// Holds the information required to implement the SW draw to system canvas.
+struct AwPixelInfo {
+ int version; // The kAwPixelInfoVersion this struct was built with.
+ SkCanvasState* state; // The externalize state in skia format.
+ // NOTE: If you add more members, bump kAwPixelInfoVersion.
+};
+
+// Function that can be called to fish out the underlying native pixel data
+// from a Java canvas object, for optimized rendering path.
+// Returns the pixel info on success, which must be freed via a call to
+// AwReleasePixelsFunction, or NULL.
+typedef AwPixelInfo* (AwAccessPixelsFunction)(JNIEnv* env, jobject canvas);
+
+// Must be called to balance every *successful* call to AwAccessPixelsFunction
+// (i.e. that returned true).
+typedef void (AwReleasePixelsFunction)(AwPixelInfo* pixels);
+
+// Called to create an Android Picture object encapsulating a native SkPicture.
+typedef jobject (AwCreatePictureFunction)(JNIEnv* env, SkPicture* picture);
+
+// Method that returns the current Skia function.
+typedef void (SkiaVersionFunction)(int* major, int* minor, int* patch);
+
+// Called to verify if the Skia versions are compatible.
+typedef bool (AwIsSkiaVersionCompatibleFunction)(SkiaVersionFunction function);
+
+static const int kAwDrawSWFunctionTableVersion = 1;
+
+// "vtable" for the functions declared in this file. An instance must be set via
+// AwContents.setAwDrawSWFunctionTable
+struct AwDrawSWFunctionTable {
+ int version;
+ AwAccessPixelsFunction* access_pixels;
+ AwReleasePixelsFunction* release_pixels;
+};
+
+#endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_
diff --git a/native/webview/plat_support/graphic_buffer_impl.cpp b/native/webview/plat_support/graphic_buffer_impl.cpp
new file mode 100644
index 000000000000..44267784e4ec
--- /dev/null
+++ b/native/webview/plat_support/graphic_buffer_impl.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Provides the implementation of the GraphicBuffer interface in
+// renderer compostior
+
+#include "graphic_buffer_impl.h"
+
+#include <utils/Errors.h>
+
+namespace android {
+
+GraphicBufferImpl::GraphicBufferImpl(uint32_t w, uint32_t h)
+ : mBuffer(new android::GraphicBuffer(w, h, PIXEL_FORMAT_RGBA_8888,
+ android::GraphicBuffer::USAGE_HW_TEXTURE |
+ android::GraphicBuffer::USAGE_SW_READ_OFTEN |
+ android::GraphicBuffer::USAGE_SW_WRITE_OFTEN)) {
+}
+
+GraphicBufferImpl::~GraphicBufferImpl() {
+}
+
+// static
+long GraphicBufferImpl::Create(int w, int h) {
+ GraphicBufferImpl* buffer = new GraphicBufferImpl(
+ static_cast<uint32_t>(w), static_cast<uint32_t>(h));
+ if (buffer->InitCheck() != NO_ERROR) {
+ delete buffer;
+ return 0;
+ }
+ return reinterpret_cast<intptr_t>(buffer);
+}
+
+// static
+void GraphicBufferImpl::Release(long buffer_id) {
+ GraphicBufferImpl* buffer = reinterpret_cast<GraphicBufferImpl*>(buffer_id);
+ delete buffer;
+}
+
+// static
+int GraphicBufferImpl::MapStatic(long buffer_id, AwMapMode mode, void** vaddr) {
+ GraphicBufferImpl* buffer = reinterpret_cast<GraphicBufferImpl*>(buffer_id);
+ return buffer->Map(mode, vaddr);
+}
+
+// static
+int GraphicBufferImpl::UnmapStatic(long buffer_id) {
+ GraphicBufferImpl* buffer = reinterpret_cast<GraphicBufferImpl*>(buffer_id);
+ return buffer->Unmap();
+}
+
+// static
+void* GraphicBufferImpl::GetNativeBufferStatic(long buffer_id) {
+ GraphicBufferImpl* buffer = reinterpret_cast<GraphicBufferImpl*>(buffer_id);
+ return buffer->GetNativeBuffer();
+}
+
+// static
+uint32_t GraphicBufferImpl::GetStrideStatic(long buffer_id) {
+ GraphicBufferImpl* buffer = reinterpret_cast<GraphicBufferImpl*>(buffer_id);
+ return buffer->GetStride();
+}
+
+status_t GraphicBufferImpl::Map(AwMapMode mode, void** vaddr) {
+ int usage = 0;
+ switch (mode) {
+ case MAP_READ_ONLY:
+ usage = android::GraphicBuffer::USAGE_SW_READ_OFTEN;
+ break;
+ case MAP_WRITE_ONLY:
+ usage = android::GraphicBuffer::USAGE_SW_WRITE_OFTEN;
+ break;
+ case MAP_READ_WRITE:
+ usage = android::GraphicBuffer::USAGE_SW_READ_OFTEN |
+ android::GraphicBuffer::USAGE_SW_WRITE_OFTEN;
+ break;
+ default:
+ return INVALID_OPERATION;
+ }
+ return mBuffer->lock(usage, vaddr);
+}
+
+status_t GraphicBufferImpl::Unmap() {
+ return mBuffer->unlock();
+}
+
+status_t GraphicBufferImpl::InitCheck() const {
+ return mBuffer->initCheck();
+}
+
+void* GraphicBufferImpl::GetNativeBuffer() const {
+ return mBuffer->getNativeBuffer();
+}
+
+uint32_t GraphicBufferImpl::GetStride() const {
+ static const int kBytesPerPixel = 4;
+ return mBuffer->getStride() * kBytesPerPixel;
+}
+
+} // namespace android
diff --git a/native/webview/plat_support/graphic_buffer_impl.h b/native/webview/plat_support/graphic_buffer_impl.h
new file mode 100644
index 000000000000..442710aedf31
--- /dev/null
+++ b/native/webview/plat_support/graphic_buffer_impl.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Provides the implementation of the GraphicBuffer interface in
+// renderer compostior
+
+#ifndef ANDROID_GRAPHIC_BUFFER_IMPL_H
+#define ANDROID_GRAPHIC_BUFFER_IMPL_H
+
+#include <ui/GraphicBuffer.h>
+
+#include "draw_gl.h"
+
+namespace android {
+
+class GraphicBufferImpl {
+ public:
+ ~GraphicBufferImpl();
+
+ static long Create(int w, int h);
+ static void Release(long buffer_id);
+ static int MapStatic(long buffer_id, AwMapMode mode, void** vaddr);
+ static int UnmapStatic(long buffer_id);
+ static void* GetNativeBufferStatic(long buffer_id);
+ static uint32_t GetStrideStatic(long buffer_id);
+
+ private:
+ status_t Map(AwMapMode mode, void** vaddr);
+ status_t Unmap();
+ status_t InitCheck() const;
+ void* GetNativeBuffer() const;
+ uint32_t GetStride() const;
+ GraphicBufferImpl(uint32_t w, uint32_t h);
+
+ sp<android::GraphicBuffer> mBuffer;
+};
+
+} // namespace android
+
+#endif // ANDROID_GRAPHIC_BUFFER_IMPL_H
diff --git a/native/webview/plat_support/graphics_utils.cpp b/native/webview/plat_support/graphics_utils.cpp
new file mode 100644
index 000000000000..89beb754b52c
--- /dev/null
+++ b/native/webview/plat_support/graphics_utils.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Provides a webviewchromium glue layer adapter from the internal Android
+// graphics types into the types the chromium stack expects, and back.
+
+#define LOG_TAG "webviewchromium_plat_support"
+
+#include "draw_gl.h"
+#include "draw_sw.h"
+
+#include <cstdlib>
+#include <jni.h>
+#include <utils/Log.h>
+#include "graphic_buffer_impl.h"
+#include "GraphicsJNI.h"
+#include "SkCanvasStateUtils.h"
+#include "SkGraphics.h"
+#include "SkPicture.h"
+
+#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
+
+namespace android {
+namespace {
+
+class PixelInfo : public AwPixelInfo {
+ public:
+ explicit PixelInfo(android::Canvas* canvas);
+ ~PixelInfo();
+};
+
+
+PixelInfo::PixelInfo(android::Canvas* canvas) {
+ memset(this, 0, sizeof(AwPixelInfo));
+ version = kAwPixelInfoVersion;
+ state = canvas->captureCanvasState();
+}
+
+PixelInfo::~PixelInfo() {
+ if (state)
+ SkCanvasStateUtils::ReleaseCanvasState(state);
+}
+
+AwPixelInfo* GetPixels(JNIEnv* env, jobject java_canvas) {
+ android::Canvas* nativeCanvas = GraphicsJNI::getNativeCanvas(env, java_canvas);
+ if (!nativeCanvas)
+ return NULL;
+
+ PixelInfo* pixels = new PixelInfo(nativeCanvas);
+ if (!pixels->state) {
+ delete pixels;
+ pixels = NULL;
+ }
+ return pixels;
+}
+
+void ReleasePixels(AwPixelInfo* pixels) {
+ delete static_cast<PixelInfo*>(pixels);
+}
+
+jlong GetDrawSWFunctionTable(JNIEnv* env, jclass) {
+ static AwDrawSWFunctionTable function_table;
+ function_table.version = kAwDrawSWFunctionTableVersion;
+ function_table.access_pixels = &GetPixels;
+ function_table.release_pixels = &ReleasePixels;
+ return reinterpret_cast<intptr_t>(&function_table);
+}
+
+jlong GetDrawGLFunctionTable(JNIEnv* env, jclass) {
+ static AwDrawGLFunctionTable function_table;
+ function_table.version = kAwDrawGLFunctionTableVersion;
+ function_table.create_graphic_buffer = &GraphicBufferImpl::Create;
+ function_table.release_graphic_buffer = &GraphicBufferImpl::Release;
+ function_table.map = &GraphicBufferImpl::MapStatic;
+ function_table.unmap = &GraphicBufferImpl::UnmapStatic;
+ function_table.get_native_buffer = &GraphicBufferImpl::GetNativeBufferStatic;
+ function_table.get_stride = &GraphicBufferImpl::GetStrideStatic;
+ return reinterpret_cast<intptr_t>(&function_table);
+}
+
+const char kClassName[] = "com/android/webview/chromium/GraphicsUtils";
+const JNINativeMethod kJniMethods[] = {
+ { "nativeGetDrawSWFunctionTable", "()J",
+ reinterpret_cast<void*>(GetDrawSWFunctionTable) },
+ { "nativeGetDrawGLFunctionTable", "()J",
+ reinterpret_cast<void*>(GetDrawGLFunctionTable) },
+};
+
+} // namespace
+
+void RegisterGraphicsUtils(JNIEnv* env) {
+ jclass clazz = env->FindClass(kClassName);
+ LOG_ALWAYS_FATAL_IF(!clazz, "Unable to find class '%s'", kClassName);
+
+ int res = env->RegisterNatives(clazz, kJniMethods, NELEM(kJniMethods));
+ LOG_ALWAYS_FATAL_IF(res < 0, "register native methods failed: res=%d", res);
+}
+
+} // namespace android
diff --git a/native/webview/plat_support/jni_entry_point.cpp b/native/webview/plat_support/jni_entry_point.cpp
new file mode 100644
index 000000000000..4771be1bc258
--- /dev/null
+++ b/native/webview/plat_support/jni_entry_point.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "webviewchromium_plat_support"
+
+#include <jni.h>
+#include <utils/Log.h>
+
+namespace android {
+
+void RegisterDrawGLFunctor(JNIEnv* env);
+void RegisterGraphicsUtils(JNIEnv* env);
+
+} // namespace android
+
+JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
+ JNIEnv* env = NULL;
+ jint ret = vm->AttachCurrentThread(&env, NULL);
+ LOG_ALWAYS_FATAL_IF(ret != JNI_OK, "AttachCurrentThread failed");
+ android::RegisterDrawGLFunctor(env);
+ android::RegisterGraphicsUtils(env);
+
+ return JNI_VERSION_1_4;
+}