summaryrefslogtreecommitdiffstats
path: root/android_webview/test
diff options
context:
space:
mode:
authorboliu <boliu@chromium.org>2014-09-23 14:45:21 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-23 21:45:52 +0000
commitcc5ed8647904a5bab9a1062a2a3a786e0152cfd7 (patch)
tree0b758bf98cc91cd8e60ca00f492a68c8ffb029fb /android_webview/test
parent2340a8b517629e460dec10d4c6cf3e9b2770fea2 (diff)
downloadchromium_src-cc5ed8647904a5bab9a1062a2a3a786e0152cfd7.zip
chromium_src-cc5ed8647904a5bab9a1062a2a3a786e0152cfd7.tar.gz
chromium_src-cc5ed8647904a5bab9a1062a2a3a786e0152cfd7.tar.bz2
aw: Fix HardwareView for instrumentation tests
* Implement detachGLFunctor. The contract here is after detachGLFunctor is called, DrawGL is no longer called until the next requestDrawGL. Implement just with a mFunctorAttached variable. * Only create one HardwareView. Each GLSurfaceView creates its own GL thread, but we only assume a single render thread. Using SurfaceView or hosting multiple AwContents in the same GLSurfaceView is too hard, so just do the simplest thing, and create the first view has hardware accelerated. BUG=416981 Review URL: https://codereview.chromium.org/594333002 Cr-Commit-Position: refs/heads/master@{#296261}
Diffstat (limited to 'android_webview/test')
-rw-r--r--android_webview/test/shell/src/org/chromium/android_webview/test/AwTestContainerView.java31
1 files changed, 29 insertions, 2 deletions
diff --git a/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestContainerView.java b/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestContainerView.java
index 3c64b65..34094ef 100644
--- a/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestContainerView.java
+++ b/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestContainerView.java
@@ -52,6 +52,7 @@ public class AwTestContainerView extends FrameLayout {
// and drawGL on the rendering thread. The variables following
// are protected by it.
private final Object mSyncLock = new Object();
+ private boolean mFunctorAttached = false;
private boolean mNeedsProcessGL = false;
private boolean mNeedsDrawGL = false;
private boolean mWaitForCompletion = false;
@@ -135,9 +136,19 @@ public class AwTestContainerView extends FrameLayout {
}
}
+ public void detachGLFunctor() {
+ synchronized (mSyncLock) {
+ mFunctorAttached = false;
+ mNeedsProcessGL = false;
+ mNeedsDrawGL = false;
+ mWaitForCompletion = false;
+ }
+ }
+
public void requestRender(Canvas canvas, boolean waitForCompletion) {
synchronized (mSyncLock) {
super.requestRender();
+ mFunctorAttached = true;
mWaitForCompletion = waitForCompletion;
if (canvas == null) {
mNeedsProcessGL = true;
@@ -173,6 +184,11 @@ public class AwTestContainerView extends FrameLayout {
final boolean waitForCompletion;
synchronized (mSyncLock) {
+ if (!mFunctorAttached) {
+ mSyncLock.notifyAll();
+ return;
+ }
+
draw = mNeedsDrawGL;
process = mNeedsProcessGL;
waitForCompletion = mWaitForCompletion;
@@ -204,14 +220,25 @@ public class AwTestContainerView extends FrameLayout {
}
}
+ private static boolean sCreatedOnce = false;
+ private HardwareView createHardwareViewOnlyOnce(Context context) {
+ if (sCreatedOnce) return null;
+ sCreatedOnce = true;
+ return new HardwareView(context);
+ }
+
public AwTestContainerView(Context context, boolean hardwareAccelerated) {
super(context);
if (hardwareAccelerated) {
- mHardwareView = new HardwareView(context);
+ mHardwareView = createHardwareViewOnlyOnce(context);
+ }
+ if (mHardwareView != null) {
addView(mHardwareView,
new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT));
+ } else {
+ setLayerType(LAYER_TYPE_SOFTWARE, null);
}
mNativeGLDelegate = new NativeGLDelegate();
mInternalAccessDelegate = new InternalAccessAdapter();
@@ -396,7 +423,7 @@ public class AwTestContainerView extends FrameLayout {
@Override
public void detachGLFunctor() {
- // Intentional no-op.
+ if (mHardwareView != null) mHardwareView.detachGLFunctor();
}
}