-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-25461] HEX backgroundColor with alpha channel act as a mask #9588
Changes from 5 commits
1b8c339
06e0363
0c8e0fc
e73e09d
526343d
f4cbda2
0861b0e
bb7f488
11ad53c
2eb23b8
301cb3b
8326d79
d5d2e3e
3207259
7b89c8a
7dbd622
80af595
8163828
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,7 @@ public abstract class TiUIView | |
|
||
private static final boolean HONEYCOMB_OR_GREATER = (Build.VERSION.SDK_INT >= 11); | ||
private static final boolean LOLLIPOP_OR_GREATER = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP); | ||
private static final boolean LOWER_THAN_JELLYBEAN = (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2); | ||
protected static final boolean LOWER_THAN_JELLYBEAN = (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2); | ||
private static final boolean LOWER_THAN_MARSHMALLOW = (Build.VERSION.SDK_INT < Build.VERSION_CODES.M); | ||
|
||
private static final int LAYER_TYPE_SOFTWARE = 1; | ||
|
@@ -442,7 +442,7 @@ private boolean hasGradient(KrollDict d) | |
return d.containsKeyAndNotNull(TiC.PROPERTY_BACKGROUND_GRADIENT); | ||
} | ||
|
||
private boolean hasBorder(KrollDict d) | ||
protected boolean hasBorder(KrollDict d) | ||
{ | ||
return d.containsKeyAndNotNull(TiC.PROPERTY_BORDER_COLOR) | ||
|| (d.containsKeyAndNotNull(TiC.PROPERTY_BORDER_WIDTH) | ||
|
@@ -886,8 +886,8 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP | |
|
||
// TIMOB-24898: disable HW acceleration to allow transparency | ||
// when the backgroundColor alpha channel has been set | ||
byte bgAlpha = bgColor != null ? (byte)(bgColor >> 24) : (byte)0xFF; | ||
if (bgAlpha != 0xFF) { | ||
|
||
if (bgColor != null && bgColor >>> 24 != 0xFF) { | ||
disableHWAcceleration(); | ||
} | ||
} | ||
|
@@ -1451,8 +1451,7 @@ private void initializeBorder(KrollDict d, Integer bgColor) | |
|
||
// TIMOB-24898: disable HW acceleration to allow transparency | ||
// when the backgroundColor alpha channel has been set | ||
byte bgAlpha = bgColor != null ? (byte)(bgColor >> 24) : (byte)0xFF; | ||
if (bgAlpha != 0xFF) { | ||
if (bgColor != null && bgColor >>> 24 != 0xFF) { | ||
disableHWAcceleration(); | ||
} | ||
} | ||
|
@@ -1990,7 +1989,7 @@ public boolean onLongClick(View view) | |
|
||
protected void disableHWAcceleration() | ||
{ | ||
if (borderView == null || (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN && !borderView.isHardwareAccelerated())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was added to resolve a WebView crash on Android 4.1... The reason it crashed is because a BorderView was always being applied to a WebView (because it initializing itself with a zero border width unlike other views) and a hardware accelerator border causes a C/C++ segfault, likely because the WebKit driven WebView's hardware accelerated rendering conflicts with it. We don't want to re-introduce this crash. So, if you feel we need to change the code here, then we may need to look into an alternative solution for Android 4.1 WebViews. We could simply always disable hardware accelerated WebView rendering on 4.1, but my understanding is that could break HTML5 video rendering. The other approach is to keep hardware accelerated rendering but don't support a border. Hmm... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I double checked the test cases in the ticket and the PR. There are no crashes on API 16. But I have tested only on emulator - no device with that version at hand. TiBorderWrapperView currently draws a border if we have set a borderColor or a borderWidth greater than 1 or borderRadius greater than 1. As for the conflict for HTML 5 video rendering when having a border on API 16 - I suppose we could drop the support for borderRadius only. It is the one which combined with opacity and background color with alpha channel requires disabling of HW acceleration - the unsupported methods for this API from: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for looking into this. I suppose the thing to do is have QE re-run the test attached to PR #9432 when testing this PR, just in case. @lokeshchdhry has done the test before and has a physical Android 4.1. device to test with. |
||
if (borderView == null) { | ||
return; | ||
} | ||
Log.d(TAG, "Disabling hardware acceleration for instance of " + borderView.getClass().getSimpleName(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor, but a warning could be thrown suggesting the method does not return a value (even though it does). You should change it to this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.