Implemented texture caching for fromCanvas method