summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@google.com>2010-01-14 19:15:28 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2010-01-14 19:15:28 -0800
commit20cc55703348827fbd80ff0410777a537f01e10e (patch)
tree7bd1ee56751af4f5030547028b5513a8d7ca57eb /tools
parent38fa9eee9324b2355f28372e80dba12c1d7cc105 (diff)
parent79f05bb4a502d5768f84cf975f791f3ba981e0e5 (diff)
downloadframeworks_base-20cc55703348827fbd80ff0410777a537f01e10e.zip
frameworks_base-20cc55703348827fbd80ff0410777a537f01e10e.tar.gz
frameworks_base-20cc55703348827fbd80ff0410777a537f01e10e.tar.bz2
am 79f05bb4: Merge "ADT/Layoutlib: improved gradient drawing for perf." into eclair
Merge commit '79f05bb4a502d5768f84cf975f791f3ba981e0e5' into eclair-plus-aosp * commit '79f05bb4a502d5768f84cf975f791f3ba981e0e5': ADT/Layoutlib: improved gradient drawing for perf.
Diffstat (limited to 'tools')
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/LinearGradient.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/layoutlib/bridge/src/android/graphics/LinearGradient.java b/tools/layoutlib/bridge/src/android/graphics/LinearGradient.java
index bd152a2..38ffed3 100644
--- a/tools/layoutlib/bridge/src/android/graphics/LinearGradient.java
+++ b/tools/layoutlib/bridge/src/android/graphics/LinearGradient.java
@@ -196,12 +196,15 @@ public class LinearGradient extends Shader {
public Raster getRaster(int x, int y, int w, int h) {
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
+ int[] data = new int[w*h];
+
if (mDx == 0) { // vertical gradient
// compute first column and copy to all other columns
+ int index = 0;
for (int iy = 0 ; iy < h ; iy++) {
int color = getColor(iy + y, mY0, mDy);
for (int ix = 0 ; ix < w ; ix++) {
- image.setRGB(ix, iy, color);
+ data[index++] = color;
}
}
} else if (mDy == 0) { // horizontal
@@ -212,16 +215,19 @@ public class LinearGradient extends Shader {
}
for (int iy = 0 ; iy < h ; iy++) {
- image.setRGB(0, iy, w, 1 /*h*/, line, 0 /* offset*/, w /*scansize*/);
+ System.arraycopy(line, 0, data, iy*w, line.length);
}
} else {
+ int index = 0;
for (int iy = 0 ; iy < h ; iy++) {
for (int ix = 0 ; ix < w ; ix++) {
- image.setRGB(ix, iy, getColor(ix + x, iy + y));
+ data[index++] = getColor(ix + x, iy + y);
}
}
}
+ image.setRGB(0 /*startX*/, 0 /*startY*/, w, h, data, 0 /*offset*/, w /*scansize*/);
+
return image.getRaster();
}
}