diff options
| author | 2010-01-21 14:31:11 -0800 | |
|---|---|---|
| committer | 2010-01-21 14:31:11 -0800 | |
| commit | 18d21ef83e5de1cbd3875274f3c5f6eee198af6e (patch) | |
| tree | 81f73f8b785e336e550dafaf29fbada98a43a193 | |
| parent | beb0993c6aa7ccaf4e1ec88355a28f4c3ea93c7a (diff) | |
| parent | 20cc55703348827fbd80ff0410777a537f01e10e (diff) | |
am 20cc5570: am 79f05bb4: Merge "ADT/Layoutlib: improved gradient drawing for perf." into eclair
Merge commit '20cc55703348827fbd80ff0410777a537f01e10e'
* commit '20cc55703348827fbd80ff0410777a537f01e10e':
ADT/Layoutlib: improved gradient drawing for perf.
| -rw-r--r-- | tools/layoutlib/bridge/src/android/graphics/LinearGradient.java | 12 |
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 bd152a250b13..38ffed362c94 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(); } } |