Romain, Thanks for the explanation.

On Feb 5, 10:26 pm, Romain Guy <romain...@google.com> wrote:
> Tom,
>
> A shader is a per-pixel operation, which lets you apply it to any
> shape, respecting alpha blending as well. As such it is not surprising
> that your first method is faster.
>
>
>
> On Thu, Feb 5, 2009 at 2:08 PM, tomgibara <m...@tomgibara.com> wrote:
>
> > I'm experimenting with tiling a fullscreen image (480x320px ARGB
> > bitmap) with a square image (160x160px ARGB bitmap). My initial
> > implementation was naive:
>
> > public void render(Canvas canvas) {
> >        final int size = tile.getWidth();
> >        final int w = canvas.getWidth();
> >        final int h = canvas.getHeight();
> >                for (int y = 0; y < h; y += size) {
> >                        for (int x = 0; x < w; x += size) {
> >                        canvas.drawBitmap(tile, x, y, null);
> >                }
> >        }
> > }
>
> > Then I remembered that Paint supports a Shader, so I swapped this
> > implementation for something much more satisfying:
>
> > public void render(Canvas canvas) {
> >                canvas.drawPaint(paint);
> > }
>
> > Where paint is initialized outside this method with:
>
> > paint = new Paint();
> > paint.setShader(new BitmapShader(tile, Shader.TileMode.REPEAT,
> > Shader.TileMode.REPEAT));
>
> > I expected that using a BitmapShader would be competitive with the
> > first implementation and probably slightly faster. But initial
> > benchmarking indicates that the first method is more than twice as
> > fast (almost 3x as fast if PorterDuff.Mode.SRC is used for both). I
> > found that surprising.
>
> > Is there a good reason that the BitmapShader is necessarily much
> > slower, or does it point to a deficiency in its implementation?
>
> --
> Romain Guy
> Android framework engineer
> romain...@android.com
>
> Note: please don't send private questions to me, as I don't have time
> to provide private support.  All such questions should be posted on
> public forums, where I and others can see and answer them
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to