forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
android: Use hw acceleration in android_webview_shell
This creates a (GL)SurfaceView overlay on top of the shell container view which runs its own thread for rendering. It calls into the native draw functor through a small dynamic library (drawgl.so). Committed previously: https://chromium.googlesource.com/chromium/src/+/09acbf59e7e8f1de574498ee5ba8eae0b0775438 Review URL: https://codereview.chromium.org/414503004 Cr-Commit-Position: refs/heads/master@{#292761}
- Loading branch information
sievers
authored and
Commit bot
committed
Aug 30, 2014
1 parent
b139474
commit 625a786
Showing
9 changed files
with
322 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include_rules = [ | ||
# draw_gl compiles its own shared library for a single entry point | ||
# for testing. Therefore it cannot depend on any other module, | ||
# except for shared definitions. | ||
"-android_webview", | ||
"+android_webview/public/browser", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) 2014 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. | ||
|
||
#include <jni.h> | ||
|
||
#include "android_webview/public/browser/draw_gl.h" | ||
|
||
extern "C" { | ||
|
||
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { | ||
return JNI_VERSION_1_4; | ||
} | ||
|
||
// This code goes into its own dynamic library, so we cannot depend on | ||
// any other components like base. | ||
JNIEXPORT void JNICALL | ||
Java_org_chromium_android_1webview_shell_DrawGL_nativeDrawGL( | ||
JNIEnv*, | ||
jclass, | ||
jlong draw_gl, | ||
jlong view, | ||
jint width, | ||
jint height, | ||
jint scroll_x, | ||
jint scroll_y, | ||
jint mode) { | ||
AwDrawGLInfo draw_info; | ||
draw_info.mode = static_cast<AwDrawGLInfo::Mode>(mode); | ||
draw_info.version = kAwDrawGLInfoVersion; | ||
draw_info.is_layer = false; | ||
draw_info.width = width; | ||
draw_info.height = height; | ||
draw_info.clip_left = 0; | ||
draw_info.clip_top = 0; | ||
draw_info.clip_bottom = height; | ||
draw_info.clip_right = width; | ||
draw_info.transform[0] = 1.0; | ||
draw_info.transform[1] = 0.0; | ||
draw_info.transform[2] = 0.0; | ||
draw_info.transform[3] = 0.0; | ||
|
||
draw_info.transform[4] = 0.0; | ||
draw_info.transform[5] = 1.0; | ||
draw_info.transform[6] = 0.0; | ||
draw_info.transform[7] = 0.0; | ||
|
||
draw_info.transform[8] = 0.0; | ||
draw_info.transform[9] = 0.0; | ||
draw_info.transform[10] = 1.0; | ||
draw_info.transform[11] = 0.0; | ||
|
||
draw_info.transform[12] = -scroll_x; | ||
draw_info.transform[13] = -scroll_y; | ||
draw_info.transform[14] = 0.0; | ||
draw_info.transform[15] = 1.0; | ||
AwDrawGLFunction* draw_func = reinterpret_cast<AwDrawGLFunction*>(draw_gl); | ||
draw_func(view, &draw_info, 0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
android_webview/test/shell/src/org/chromium/android_webview/shell/DrawGL.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2014 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. | ||
|
||
package org.chromium.android_webview.shell; | ||
|
||
/** | ||
* Provides an entry point to the native draw functor. | ||
*/ | ||
public class DrawGL { | ||
public static void drawGL(long drawGL, long viewContext, int width, int height, | ||
int scrollX, int scrollY, int mode) { | ||
nativeDrawGL(drawGL, viewContext, width, height, scrollX, scrollY, mode); | ||
} | ||
|
||
private static native void nativeDrawGL(long drawGL, long viewContext, | ||
int width, int height, int scrollX, int scrollY, int mode); | ||
} |
Oops, something went wrong.