summaryrefslogtreecommitdiffstats
path: root/tools/layoutlib
diff options
context:
space:
mode:
authorDiego Perez <diegoperez@google.com>2015-05-06 23:43:49 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-06 23:43:50 +0000
commitbc47abe4b444d0386d1d939e4a223a976fade565 (patch)
tree68b86e9b585f3d17653c31aa13f63355d822e48c /tools/layoutlib
parent1f8e3de40c0aed9fa8b9216ddd3224b7ac94acf1 (diff)
parent2d3449f982f9f4b9f4370142bb846d2dbab5a38e (diff)
downloadframeworks_base-bc47abe4b444d0386d1d939e4a223a976fade565.zip
frameworks_base-bc47abe4b444d0386d1d939e4a223a976fade565.tar.gz
frameworks_base-bc47abe4b444d0386d1d939e4a223a976fade565.tar.bz2
Merge "Make sure shaders use a color model compatible with the destination." into lmp-mr1-dev
Diffstat (limited to 'tools/layoutlib')
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java12
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java5
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java5
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java5
4 files changed, 19 insertions, 8 deletions
diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java
index 610c867..e9b5d6e 100644
--- a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java
@@ -23,6 +23,8 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
import android.graphics.Shader.TileMode;
+import java.awt.image.ColorModel;
+
/**
* Delegate implementing the native methods of android.graphics.BitmapShader
*
@@ -124,6 +126,11 @@ public class BitmapShader_Delegate extends Shader_Delegate {
localMatrix = new java.awt.geom.AffineTransform();
}
+ if (!colorModel.isCompatibleRaster(mImage.getRaster())) {
+ // Fallback to the default ARGB color model
+ colorModel = ColorModel.getRGBdefault();
+ }
+
return new BitmapShaderContext(canvasMatrix, localMatrix, colorModel);
}
@@ -153,8 +160,9 @@ public class BitmapShader_Delegate extends Shader_Delegate {
@Override
public java.awt.image.Raster getRaster(int x, int y, int w, int h) {
- java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(w, h,
- java.awt.image.BufferedImage.TYPE_INT_ARGB);
+ java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(
+ mColorModel, mColorModel.createCompatibleWritableRaster(w, h),
+ mColorModel.isAlphaPremultiplied(), null);
int[] data = new int[w*h];
diff --git a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
index 55c4b98..703719c 100644
--- a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
@@ -172,8 +172,9 @@ public final class LinearGradient_Delegate extends Gradient_Delegate {
@Override
public java.awt.image.Raster getRaster(int x, int y, int w, int h) {
- java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(w, h,
- java.awt.image.BufferedImage.TYPE_INT_ARGB);
+ java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(
+ mColorModel, mColorModel.createCompatibleWritableRaster(w, h),
+ mColorModel.isAlphaPremultiplied(), null);
int[] data = new int[w*h];
diff --git a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
index 80179ee..6edb140 100644
--- a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
@@ -160,8 +160,9 @@ public class RadialGradient_Delegate extends Gradient_Delegate {
@Override
public java.awt.image.Raster getRaster(int x, int y, int w, int h) {
- java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(w, h,
- java.awt.image.BufferedImage.TYPE_INT_ARGB);
+ java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(
+ mColorModel, mColorModel.createCompatibleWritableRaster(w, h),
+ mColorModel.isAlphaPremultiplied(), null);
int[] data = new int[w*h];
diff --git a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java
index 95a57a9..544ba98 100644
--- a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java
@@ -152,8 +152,9 @@ public class SweepGradient_Delegate extends Gradient_Delegate {
@Override
public java.awt.image.Raster getRaster(int x, int y, int w, int h) {
- java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(w, h,
- java.awt.image.BufferedImage.TYPE_INT_ARGB);
+ java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(
+ mColorModel, mColorModel.createCompatibleWritableRaster(w, h),
+ mColorModel.isAlphaPremultiplied(), null);
int[] data = new int[w*h];