private AwContents.NativeGLDelegate mNativeGLDelegate;
private AwContents.InternalAccessDelegate mInternalAccessDelegate;
- HardwareView mHardwareView = null;
+ private HardwareView mHardwareView = null;
private boolean mAttachedContents = false;
private class HardwareView extends GLSurfaceView {
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) {
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();
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();
}
mAttachedContents = true;
} else {
mHardwareView.setReadyToRenderCallback(new Runnable() {
+ @Override
public void run() {
assert !mAttachedContents;
mAwContents.onAttachedToWindow();
@Override
public void onDraw(Canvas canvas) {
- if (mHardwareView != null) {
+ if (isBackedByHardwareView()) {
mHardwareView.updateScroll(getScrollX(), getScrollY());
}
mAwContents.onDraw(canvas);
@Override
public AccessibilityNodeProvider getAccessibilityNodeProvider() {
AccessibilityNodeProvider provider =
- mAwContents.getAccessibilityNodeProvider();
+ mAwContents.getAccessibilityNodeProvider();
return provider == null ? super.getAccessibilityNodeProvider() : provider;
}
@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();
}
}
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);