A coworker of mine suggested I avoid using any gradients in my mobile apps because the phones can't handle开发者_如何转开发 the work load required for rendering gradients on buttons/backgrounds etc. I have not seen any hang ups or anything when rendering buttons, but are there gradients I should avoid?
It depends on where you use it. If you are comparing a SolidColorBrush against a GradientBrush ofcourse there is more work to do by the platform to render the gradient, but it is a negligible performance difference.
The only case I can think of is, suppose you use a complex gradient in a large ListBox and used it inside ListBoxItems, which makes a lot of that gradients get instantiated. In that case I would rather replace gradient with a low quality JPEG. The JPEG(Image) will give me more system level caching automatically and the listbox will performs better than you providing vector-gradient in there.
But if it is individual buttons or some other control styling it is totally fine to use Gradients.
More of this kind of tips can be found in my blog here - http://jobijoy.blogspot.com/2011/05/wp7dev-tip-2-few-things-to-remember-on.html
I don't see why gradients would affect performance, but gradients don't render well on many WP7 screens, since they are optimised for metro, which doesn't promote gradients. I've seen colour banding on an HTC Trophy we used for a prototype
Using gradients - linear or radial - ought not have any noticeable impact. That doesn't mean it won't, however.
WP7 Silverlight is based on normal Silverlight, which in turn is based on WPF. In WPF, linear gradients do have a noticeable impact when used extensively, and radial gradients, for whatever reason, have a pretty large impact. So looking at it's history and pedigree, it may have a substantial impact when used frequently.
That said, if you consider the what work the GPU actually needs to do to draw these, both linear and radial gradients are near the same amount of work, and can be optimized to use very few shader instructions. I got linear down to 4 (1 if the underlying scene graph allows vertex modification) and radial down to 5 (4 if I can modify vertices, even 3 in probably most cases). Both of these shaders are pretty trivial. This means there shouldn't be any real impact. Perhaps it's something Microsoft can optimize at some point.
精彩评论