summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Perez <diegoperez@google.com>2015-05-07 00:08:53 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-05-07 00:08:53 +0000
commitffeb8117b139f61dd7c92bda6a7d47b83871cb66 (patch)
tree7d86cc9b18bf060203375904d09fd29b2e11d08e
parent3dbd18cdfe6af1a9c36261551ef98d39e849d389 (diff)
parent9c13c8de8291aac69958a106248d3229ff90609f (diff)
downloadframeworks_base-ffeb8117b139f61dd7c92bda6a7d47b83871cb66.zip
frameworks_base-ffeb8117b139f61dd7c92bda6a7d47b83871cb66.tar.gz
frameworks_base-ffeb8117b139f61dd7c92bda6a7d47b83871cb66.tar.bz2
am 9c13c8de: am bc47abe4: Merge "Make sure shaders use a color model compatible with the destination." into lmp-mr1-dev
* commit '9c13c8de8291aac69958a106248d3229ff90609f': Make sure shaders use a color model compatible with the destination.
-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];