OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.android_webview.test; | 5 package org.chromium.android_webview.test; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.content.res.Configuration; | 9 import android.content.res.Configuration; |
10 import android.graphics.Canvas; | 10 import android.graphics.Canvas; |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 /** | 31 /** |
32 * A View used for testing the AwContents internals. | 32 * A View used for testing the AwContents internals. |
33 * | 33 * |
34 * This class takes the place android.webkit.WebView would have in the productio
n configuration. | 34 * This class takes the place android.webkit.WebView would have in the productio
n configuration. |
35 */ | 35 */ |
36 public class AwTestContainerView extends FrameLayout { | 36 public class AwTestContainerView extends FrameLayout { |
37 private AwContents mAwContents; | 37 private AwContents mAwContents; |
38 private AwContents.InternalAccessDelegate mInternalAccessDelegate; | 38 private AwContents.InternalAccessDelegate mInternalAccessDelegate; |
39 | 39 |
40 private HardwareView mHardwareView = null; | 40 private HardwareView mHardwareView; |
41 private boolean mAttachedContents = false; | 41 private boolean mAttachedContents; |
42 | 42 |
43 private class HardwareView extends GLSurfaceView { | 43 private class HardwareView extends GLSurfaceView { |
44 private static final int MODE_DRAW = 0; | 44 private static final int MODE_DRAW = 0; |
45 private static final int MODE_PROCESS = 1; | 45 private static final int MODE_PROCESS = 1; |
46 private static final int MODE_PROCESS_NO_CONTEXT = 2; | 46 private static final int MODE_PROCESS_NO_CONTEXT = 2; |
47 private static final int MODE_SYNC = 3; | 47 private static final int MODE_SYNC = 3; |
48 | 48 |
49 // mSyncLock is used to synchronized requestRender on the UI thread | 49 // mSyncLock is used to synchronized requestRender on the UI thread |
50 // and drawGL on the rendering thread. The variables following | 50 // and drawGL on the rendering thread. The variables following |
51 // are protected by it. | 51 // are protected by it. |
52 private final Object mSyncLock = new Object(); | 52 private final Object mSyncLock = new Object(); |
53 private boolean mFunctorAttached = false; | 53 private boolean mFunctorAttached; |
54 private boolean mNeedsProcessGL = false; | 54 private boolean mNeedsProcessGL; |
55 private boolean mNeedsDrawGL = false; | 55 private boolean mNeedsDrawGL; |
56 private boolean mWaitForCompletion = false; | 56 private boolean mWaitForCompletion; |
57 private int mLastScrollX = 0; | 57 private int mLastScrollX; |
58 private int mLastScrollY = 0; | 58 private int mLastScrollY; |
59 | 59 |
60 // Only used by drawGL on render thread to store the value of scroll off
sets at most recent | 60 // Only used by drawGL on render thread to store the value of scroll off
sets at most recent |
61 // sync for subsequent draws. | 61 // sync for subsequent draws. |
62 private int mCommittedScrollX = 0; | 62 private int mCommittedScrollX; |
63 private int mCommittedScrollY = 0; | 63 private int mCommittedScrollY; |
64 | 64 |
65 private boolean mHaveSurface = false; | 65 private boolean mHaveSurface; |
66 private Runnable mReadyToRenderCallback = null; | 66 private Runnable mReadyToRenderCallback; |
67 private Runnable mReadyToDetachCallback = null; | 67 private Runnable mReadyToDetachCallback; |
68 | 68 |
69 private long mDrawGL = 0; | 69 private long mDrawGL; |
70 private long mViewContext = 0; | 70 private long mViewContext; |
71 | 71 |
72 public HardwareView(Context context) { | 72 public HardwareView(Context context) { |
73 super(context); | 73 super(context); |
74 setEGLContextClientVersion(2); // GLES2 | 74 setEGLContextClientVersion(2); // GLES2 |
75 getHolder().setFormat(PixelFormat.OPAQUE); | 75 getHolder().setFormat(PixelFormat.OPAQUE); |
76 setPreserveEGLContextOnPause(true); | 76 setPreserveEGLContextOnPause(true); |
77 setRenderer(new Renderer() { | 77 setRenderer(new Renderer() { |
78 private int mWidth = 0; | 78 private int mWidth; |
79 private int mHeight = 0; | 79 private int mHeight; |
80 | 80 |
81 @Override | 81 @Override |
82 public void onDrawFrame(GL10 gl) { | 82 public void onDrawFrame(GL10 gl) { |
83 HardwareView.this.drawGL(mWidth, mHeight); | 83 HardwareView.this.drawGL(mWidth, mHeight); |
84 } | 84 } |
85 | 85 |
86 @Override | 86 @Override |
87 public void onSurfaceChanged(GL10 gl, int width, int height) { | 87 public void onSurfaceChanged(GL10 gl, int width, int height) { |
88 gl.glViewport(0, 0, width, height); | 88 gl.glViewport(0, 0, width, height); |
89 gl.glScissor(0, 0, width, height); | 89 gl.glScissor(0, 0, width, height); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 if (waitForCompletion) { | 226 if (waitForCompletion) { |
227 synchronized (mSyncLock) { | 227 synchronized (mSyncLock) { |
228 mWaitForCompletion = false; | 228 mWaitForCompletion = false; |
229 mSyncLock.notifyAll(); | 229 mSyncLock.notifyAll(); |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 private static boolean sCreatedOnce = false; | 235 private static boolean sCreatedOnce; |
236 private HardwareView createHardwareViewOnlyOnce(Context context) { | 236 private HardwareView createHardwareViewOnlyOnce(Context context) { |
237 if (sCreatedOnce) return null; | 237 if (sCreatedOnce) return null; |
238 sCreatedOnce = true; | 238 sCreatedOnce = true; |
239 return new HardwareView(context); | 239 return new HardwareView(context); |
240 } | 240 } |
241 | 241 |
242 public AwTestContainerView(Context context, boolean allowHardwareAcceleratio
n) { | 242 public AwTestContainerView(Context context, boolean allowHardwareAcceleratio
n) { |
243 super(context); | 243 super(context); |
244 if (allowHardwareAcceleration) { | 244 if (allowHardwareAcceleration) { |
245 mHardwareView = createHardwareViewOnlyOnce(context); | 245 mHardwareView = createHardwareViewOnlyOnce(context); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 | 570 |
571 @Override | 571 @Override |
572 public int super_getScrollBarStyle() { | 572 public int super_getScrollBarStyle() { |
573 return AwTestContainerView.super.getScrollBarStyle(); | 573 return AwTestContainerView.super.getScrollBarStyle(); |
574 } | 574 } |
575 | 575 |
576 @Override | 576 @Override |
577 public void super_startActivityForResult(Intent intent, int requestCode)
{} | 577 public void super_startActivityForResult(Intent intent, int requestCode)
{} |
578 } | 578 } |
579 } | 579 } |
OLD | NEW |