Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(692)

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 2790123002: [Merge m58] android: Workaround libhwui N bug (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 6e5400008fc2ab43ef06e668f841e59adbc85d0a..abb8d91336d4c81d90330c77bfd36e92d7027b7f 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -14,6 +14,8 @@ import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.ColorMatrix;
+import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.graphics.Picture;
import android.graphics.Rect;
@@ -362,6 +364,8 @@ public class AwContents implements SmartClipProvider {
private static String sCurrentLocales = "";
+ private Paint mPaintForNWorkaround;
+
private static final class AwContentsDestroyRunnable implements Runnable {
private final long mNativeAwContents;
// Hold onto a reference to the window (via its wrapper), so that it is not destroyed
@@ -3059,6 +3063,21 @@ public class AwContents implements SmartClipProvider {
int scrollX = mContainerView.getScrollX();
int scrollY = mContainerView.getScrollY();
Rect globalVisibleRect = getGlobalVisibleRect();
+ // Workaround for bug in libhwui on N that does not swap if inserting functor is the
+ // only operation in a canvas. See crbug.com/704212.
+ if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N
+ || Build.VERSION.SDK_INT == 25 /* N_MR1 */) {
+ if (mPaintForNWorkaround == null) {
+ mPaintForNWorkaround = new Paint();
+ // Note a completely transparent color will get optimized out. So draw almost
+ // transparent black, but then scale alpha down to effectively 0.
+ mPaintForNWorkaround.setColor(Color.argb(1, 0, 0, 0));
+ ColorMatrix colorMatrix = new ColorMatrix();
+ colorMatrix.setScale(0.f, 0.f, 0.f, 0.1f);
+ mPaintForNWorkaround.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
+ }
+ canvas.drawRect(0, 0, 1, 1, mPaintForNWorkaround);
+ }
boolean did_draw = nativeOnDraw(mNativeAwContents, canvas,
canvas.isHardwareAccelerated(), scrollX, scrollY, globalVisibleRect.left,
globalVisibleRect.top, globalVisibleRect.right, globalVisibleRect.bottom);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698