Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / android_webview / test / shell / src / org / chromium / android_webview / test / AwTestContainerView.java
index 34094ef..2c95030 100644 (file)
@@ -39,7 +39,7 @@ public class AwTestContainerView extends FrameLayout {
     private AwContents.NativeGLDelegate mNativeGLDelegate;
     private AwContents.InternalAccessDelegate mInternalAccessDelegate;
 
-    HardwareView mHardwareView = null;
+    private HardwareView mHardwareView = null;
     private boolean mAttachedContents = false;
 
     private class HardwareView extends GLSurfaceView {
@@ -204,11 +204,12 @@ public class AwTestContainerView extends FrameLayout {
                     mSyncLock.notifyAll();
                 }
             }
+            if (process) {
+                DrawGL.drawGL(mDrawGL, mViewContext, width, height, 0, 0, MODE_PROCESS);
+            }
             if (draw) {
                 DrawGL.drawGL(mDrawGL, mViewContext, width, height,
                         mCommittedScrollX, mCommittedScrollY, MODE_DRAW);
-            } else if (process) {
-                DrawGL.drawGL(mDrawGL, mViewContext, width, height, 0, 0, MODE_PROCESS);
             }
 
             if (waitForCompletion) {
@@ -227,18 +228,18 @@ public class AwTestContainerView extends FrameLayout {
         return new HardwareView(context);
     }
 
-    public AwTestContainerView(Context context, boolean hardwareAccelerated) {
+    public AwTestContainerView(Context context, boolean allowHardwareAcceleration) {
         super(context);
-        if (hardwareAccelerated) {
+        if (allowHardwareAcceleration) {
             mHardwareView = createHardwareViewOnlyOnce(context);
         }
-        if (mHardwareView != null) {
+        if (isBackedByHardwareView()) {
             addView(mHardwareView,
                     new FrameLayout.LayoutParams(
                         FrameLayout.LayoutParams.MATCH_PARENT,
                         FrameLayout.LayoutParams.MATCH_PARENT));
         } else {
-          setLayerType(LAYER_TYPE_SOFTWARE, null);
+            setLayerType(LAYER_TYPE_SOFTWARE, null);
         }
         mNativeGLDelegate = new NativeGLDelegate();
         mInternalAccessDelegate = new InternalAccessAdapter();
@@ -249,12 +250,16 @@ public class AwTestContainerView extends FrameLayout {
 
     public void initialize(AwContents awContents) {
         mAwContents = awContents;
-        if (mHardwareView != null) {
+        if (isBackedByHardwareView()) {
             mHardwareView.initialize(
                     mAwContents.getAwDrawGLFunction(), mAwContents.getAwDrawGLViewContext());
         }
     }
 
+    public boolean isBackedByHardwareView() {
+        return mHardwareView != null;
+    }
+
     public ContentViewCore getContentViewCore() {
         return mAwContents.getContentViewCore();
     }
@@ -289,6 +294,7 @@ public class AwTestContainerView extends FrameLayout {
             mAttachedContents = true;
         } else {
             mHardwareView.setReadyToRenderCallback(new Runnable() {
+                @Override
                 public void run() {
                     assert !mAttachedContents;
                     mAwContents.onAttachedToWindow();
@@ -379,7 +385,7 @@ public class AwTestContainerView extends FrameLayout {
 
     @Override
     public void onDraw(Canvas canvas) {
-        if (mHardwareView != null) {
+        if (isBackedByHardwareView()) {
             mHardwareView.updateScroll(getScrollX(), getScrollY());
         }
         mAwContents.onDraw(canvas);
@@ -389,7 +395,7 @@ public class AwTestContainerView extends FrameLayout {
     @Override
     public AccessibilityNodeProvider getAccessibilityNodeProvider() {
         AccessibilityNodeProvider provider =
-            mAwContents.getAccessibilityNodeProvider();
+                mAwContents.getAccessibilityNodeProvider();
         return provider == null ? super.getAccessibilityNodeProvider() : provider;
     }
 
@@ -416,14 +422,14 @@ public class AwTestContainerView extends FrameLayout {
         @Override
         public boolean requestDrawGL(Canvas canvas, boolean waitForCompletion,
                 View containerview) {
-            if (mHardwareView == null) return false;
+            if (!isBackedByHardwareView()) return false;
             mHardwareView.requestRender(canvas, waitForCompletion);
             return true;
         }
 
         @Override
         public void detachGLFunctor() {
-            if (mHardwareView != null) mHardwareView.detachGLFunctor();
+            if (isBackedByHardwareView()) mHardwareView.detachGLFunctor();
         }
     }
 
@@ -465,7 +471,7 @@ public class AwTestContainerView extends FrameLayout {
         public void super_scrollTo(int scrollX, int scrollY) {
             // We're intentionally not calling super.scrollTo here to make testing easier.
             AwTestContainerView.this.scrollTo(scrollX, scrollY);
-            if (mHardwareView != null) {
+            if (isBackedByHardwareView()) {
                 // Undo the scroll that will be applied because of mHardwareView
                 // being a child of |this|.
                 mHardwareView.setTranslationX(scrollX);