set software mode will slow down performance (#20155)

This commit is contained in:
minggo 2019-09-24 14:29:14 +08:00 committed by GitHub
parent 9ee9917047
commit 77a47957a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 16 deletions

View File

@ -127,23 +127,15 @@ public class Cocos2dxWebViewHelper {
}
public static void setBackgroundTransparent(final int index) {
if(android.os.Build.VERSION.SDK_INT >10) {
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Cocos2dxWebView webView = webViews.get(index);
if (webView != null) {
webView.setBackgroundColor(Color.TRANSPARENT);
try {
Method method = webView.getClass().getMethod("setLayerType",int.class,Paint.class);
method.invoke(webView,WebView.LAYER_TYPE_SOFTWARE,null);
} catch (Exception e) {
e.printStackTrace();
}
}
sCocos2dxActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Cocos2dxWebView webView = webViews.get(index);
if (webView != null) {
webView.setBackgroundColor(Color.TRANSPARENT);
}
});
}
}
});
}
public static void setOpacityWebView(final int index, final float opacity) {