Fix for shadows on theme editor
If the preferred ColorModel doesn't support alpha, the shadows are
incorrectly rendered. In the theme editor on Linux, the graphics device
object doesn't support alpha so we need to use a different color model.
We default to ARGB which works fine.
Change-Id: I3e71e3d086fa4975a9149d36792e574813f37dfd
diff --git a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
index 703719c..cbc30c3 100644
--- a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
@@ -23,6 +23,8 @@
import android.graphics.Shader.TileMode;
+import java.awt.image.ColorModel;
+
/**
* Delegate implementing the native methods of android.graphics.LinearGradient
*
@@ -158,7 +160,7 @@
java.awt.image.ColorModel colorModel) {
mCanvasMatrix = canvasMatrix;
mLocalMatrix = localMatrix;
- mColorModel = colorModel;
+ mColorModel = colorModel.hasAlpha() ? colorModel : ColorModel.getRGBdefault();
}
@Override
diff --git a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
index 6edb140..750580b 100644
--- a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
@@ -23,6 +23,8 @@
import android.graphics.Shader.TileMode;
+import java.awt.image.ColorModel;
+
/**
* Delegate implementing the native methods of android.graphics.RadialGradient
*
@@ -146,7 +148,7 @@
java.awt.image.ColorModel colorModel) {
mCanvasMatrix = canvasMatrix;
mLocalMatrix = localMatrix;
- mColorModel = colorModel;
+ mColorModel = colorModel.hasAlpha() ? colorModel : ColorModel.getRGBdefault();
}
@Override