This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Move Sprite parsing to thread pool
- Loading branch information
Showing
20 changed files
with
144 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <mbgl/sprite/sprite_atlas_worker.hpp> | ||
#include <mbgl/sprite/sprite_atlas.hpp> | ||
#include <mbgl/sprite/sprite_parser.hpp> | ||
|
||
namespace mbgl { | ||
|
||
SpriteAtlasWorker::SpriteAtlasWorker(ActorRef<SpriteAtlasWorker>, ActorRef<SpriteAtlas> parent_) | ||
: parent(std::move(parent_)) { | ||
} | ||
|
||
void SpriteAtlasWorker::parse(std::shared_ptr<const std::string> image, | ||
std::shared_ptr<const std::string> json) { | ||
try { | ||
if (!image) { | ||
// This shouldn't happen, since we always invoke it with a non-empty pointer. | ||
throw std::runtime_error("missing sprite image"); | ||
} | ||
if (!json) { | ||
// This shouldn't happen, since we always invoke it with a non-empty pointer. | ||
throw std::runtime_error("missing sprite metadata"); | ||
} | ||
|
||
parent.invoke(&SpriteAtlas::onParsed, parseSprite(*image, *json)); | ||
} catch (...) { | ||
parent.invoke(&SpriteAtlas::onError, std::current_exception()); | ||
} | ||
} | ||
|
||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <mbgl/actor/actor_ref.hpp> | ||
#include <mbgl/sprite/sprite_parser.hpp> | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
namespace mbgl { | ||
|
||
class SpriteAtlas; | ||
|
||
class SpriteAtlasWorker { | ||
public: | ||
SpriteAtlasWorker(ActorRef<SpriteAtlasWorker>, ActorRef<SpriteAtlas>); | ||
|
||
void parse(std::shared_ptr<const std::string> image, std::shared_ptr<const std::string> json); | ||
|
||
private: | ||
ActorRef<SpriteAtlas> parent; | ||
}; | ||
|
||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.