开发者

Android Canvas Multiple Layers for WallpaperService.Engine

开发者 https://www.devze.com 2023-01-28 04:22 出处:网络
I\'m working on a live wallpaper. The wallpaper requires small movable images to be behind a large fixed image with transparent areas. The smaller images will only be visible when 开发者_JAVA百科they

I'm working on a live wallpaper. The wallpaper requires small movable images to be behind a large fixed image with transparent areas. The smaller images will only be visible when 开发者_JAVA百科they are in the transparent parts of the large image.

Here's how I've been doing it so far:

Canvas c = holder.lockCanvas();
c.save()
drawSmallImages(c); //draw the movable images
drawLargeImage(c); //draw the fixed large image
c.restore();

I ran this through traceview and it looks like android is spending a good chunk of processing power to draw the large image, and ideally I'd only want it to be drawn once when the wallpaper starts. I don't know how to get the smaller images to be drawn behind the larger image without re-drawing the large image after the smaller images on each frame.


The content of the Canvas won't be cleared so you could easily optimize your drawing by clearing small portions and using the clip rect to redraw only part of the large image.

0

精彩评论

暂无评论...
验证码 换一张
取 消