Clean up Sprite

* Provide a callback so MapContext can re-render when it loads.
* Cancel in-progress loading rather than relying on keeping it
  alive with a shared_ptr.
* Remove / privatize as much as possible.
This commit is contained in:
John Firebaugh
2015-04-21 18:03:38 -07:00
parent ec7588f1fd
commit 958142c512
3 changed files with 50 additions and 61 deletions

View File

@@ -101,7 +101,10 @@ util::ptr<Sprite> MapContext::getSprite() {
const float pixelRatio = data.getTransformState().getPixelRatio();
const std::string &sprite_url = style->getSpriteURL();
if (!sprite || !sprite->hasPixelRatio(pixelRatio)) {
sprite = Sprite::Create(sprite_url, pixelRatio, env);
sprite = std::make_shared<Sprite>(sprite_url, pixelRatio, env, [this] {
assert(Environment::currentlyOn(ThreadType::Map));
triggerUpdate();
});
}
return sprite;