Merge "Workaround glitches from SOFT_INPUT_ADJUST_PAN" into oc-dev

This commit is contained in:
TreeHugger Robot
2017-06-03 01:01:21 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 2 deletions

View File

@@ -341,6 +341,7 @@ public final class ThreadedRenderer {
private boolean mEnabled;
private boolean mRequested = true;
private boolean mIsOpaque = false;
ThreadedRenderer(Context context, boolean translucent, String name) {
final TypedArray a = context.obtainStyledAttributes(null, R.styleable.Lighting, 0, 0);
@@ -355,6 +356,7 @@ public final class ThreadedRenderer {
long rootNodePtr = nCreateRootRenderNode();
mRootNode = RenderNode.adopt(rootNodePtr);
mRootNode.setClipToBounds(false);
mIsOpaque = !translucent;
mNativeProxy = nCreateProxy(translucent, rootNodePtr);
nSetName(mNativeProxy, name);
@@ -571,7 +573,12 @@ public final class ThreadedRenderer {
* Change the ThreadedRenderer's opacity
*/
void setOpaque(boolean opaque) {
nSetOpaque(mNativeProxy, opaque && !mHasInsets);
mIsOpaque = opaque && !mHasInsets;
nSetOpaque(mNativeProxy, mIsOpaque);
}
boolean isOpaque() {
return mIsOpaque;
}
/**

View File

@@ -40,6 +40,7 @@ import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.graphics.Point;
@@ -2651,6 +2652,15 @@ public final class ViewRootImpl implements ViewParent,
@Override
public void onPreDraw(DisplayListCanvas canvas) {
// If mCurScrollY is not 0 then this influences the hardwareYOffset. The end result is we
// can apply offsets that are not handled by anything else, resulting in underdraw as
// the View is shifted (thus shifting the window background) exposing unpainted
// content. To handle this with minimal glitches we just clear to BLACK if the window
// is opaque. If it's not opaque then HWUI already internally does a glClear to
// transparent, so there's no risk of underdraw on non-opaque surfaces.
if (mCurScrollY != 0 && mHardwareYOffset != 0 && mAttachInfo.mThreadedRenderer.isOpaque()) {
canvas.drawColor(Color.BLACK);
}
canvas.translate(-mHardwareXOffset, -mHardwareYOffset);
}
@@ -2668,7 +2678,7 @@ public final class ViewRootImpl implements ViewParent,
void outputDisplayList(View view) {
view.mRenderNode.output();
if (mAttachInfo.mThreadedRenderer != null) {
((ThreadedRenderer)mAttachInfo.mThreadedRenderer).serializeDisplayListTree();
mAttachInfo.mThreadedRenderer.serializeDisplayListTree();
}
}