Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79f05bb4 authored by Xavier Ducrohet's avatar Xavier Ducrohet Committed by Android (Google) Code Review
Browse files

Merge "ADT/Layoutlib: improved gradient drawing for perf." into eclair

parents 89d538dc e8f4d7de
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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();
            }
        }