From e7d4a952a6f0f048d837f86a64c950fb3fd10ae5 Mon Sep 17 00:00:00 2001 From: xing Date: Thu, 17 Mar 2016 16:45:08 +0800 Subject: [PATCH] [Android] Enable transparent TextureView Enable transparent TextureView when user changes the default SurfaceView to TextureView. BUG=XWALK-6519 --- .../content/browser/ContentViewRenderView.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java index 4a39b09bcbca7..ae1b45675d06c 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java @@ -227,15 +227,22 @@ public ContentReadbackHandler getContentReadbackHandler() { return mContentReadbackHandler; } + private static boolean isOpaque(int color) { + return ((color >> 24) & 0xFF) == 0xFF; + } + /** - * Sets the background color of the surface view. This method is necessary because the + * Set the background color of SurfaceView or TextureView. This method is necessary because the * background color of ContentViewRenderView itself is covered by the background of - * SurfaceView. + * SurfaceView or TextureView. * @param color The color of the background. */ public void setSurfaceViewBackgroundColor(int color) { if (mSurfaceView != null) { mSurfaceView.setBackgroundColor(color); + } else if (mTextureView != null) { + mTextureView.setOpaque(isOpaque(color)); + mTextureView.setBackgroundColor(color); } }