PrimaryFeather/Starling-Framework — pull request #537 by zeh (2014-04-30 18:01:52+00:00)
Title: Added a way to upload an array of bitmaps for textures with custom mipmap levels with Texture.uploadBitmapDatas()

This patch allows a user to upload custom mipmaps to be used for a texture. Custom mipmaps are useful when creating textures that render different content depending on the resolution it is being drawn. In my own case, I'm using textures with custom mipmaps to simulate lines with a uniform thickness: whatever the texture of my quad, the lines drawn on it have the same thickness. Such a solution is best used when combined with trilinear filtering, since it interpolates the texture between different mimap levels.

This patch doesn't break compatibility with the current version of Starling. It adds two new methods:

`.uploadBitmapDatas(datas:Array of BitmapData)`
and
`ConcreteTexture.fromBitmapDatas(datas:Array of BitmapData, optimizeForRenderToTexture:Boolean=false, scale:Number=1, format:String="bgra", repeat:Boolean=false)`

It also changes `.uploadBitmapData()` to call `.uploadBitmapDatas()` to avoid duplicating code.

In a nutshell, `uploadBitmapDatas()` works the same way as `uploadBitmapData()`. The difference is that it uses the first BitmapData instance in the array as the main textures, and subsequent instances as mipmap levels for the texture. It therefore would take arguments like:

`texture.uploadBitmapDatas([bitmap256x256, bitmap128x128, bitmap64x64], ...)`

It continues using bitmaps (*assuming* each subsequent bitmap is half the resolution of the previous) until there's no more bitmapdatas available. When this happens, it falls back into resizing the last image and using it as the next mitmap level (similar to what the original `uploadBitmapData()` does).

I'm open to suggestions of a different interface. I have been using this patch on a current project and it plays well with normal Starling content.

Other details:

* This patch does not make any attempt to hook into the asset manager and allow upload of bitmaps for separate mipmap levels. I don't use the AssetManager that much and I don't think I'd come up with the ideal interface for it.