Ensure that LiveTileData can be reparsed

Annotation tiles may become partially parsed just like regular tiles,
for example if a point annotation is added to the map before the style's
sprite has been loaded. In such cases, they need to be reparsed or the
annotation will not be rendered. Previously, the code path for reparsing
would be short-circuited by a dynamic_cast<VectorTileData*> followed by
a null check. This commit removes that case and adds (back) a virtual
reparse method to the TileData interface.
This commit is contained in:
John Firebaugh
2015-09-22 16:58:38 -07:00
parent aec145ded3
commit 028abaab00
9 changed files with 46 additions and 23 deletions

View File

@@ -1,5 +1,3 @@
#include "../fixtures/fixture_log_observer.hpp"
#include "../fixtures/mock_file_source.hpp"
#include "../fixtures/util.hpp"
#include <mbgl/annotation/point_annotation.hpp>
@@ -7,30 +5,30 @@
#include <mbgl/map/still_image.hpp>
#include <mbgl/platform/default/headless_display.hpp>
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/io.hpp>
#include <future>
#include <vector>
TEST(API, PointAnnotation) {
TEST(Annotations, PointAnnotation) {
using namespace mbgl;
auto display = std::make_shared<mbgl::HeadlessDisplay>();
HeadlessView view(display, 1);
MockFileSource fileSource(MockFileSource::Success, "");
DefaultFileSource fileSource(nullptr);
Map map(view, fileSource, MapMode::Still);
map.setStyleURL("test/fixtures/resources/style.json");
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
map.addPointAnnotation(PointAnnotation({ 0, 0 }, "default_marker"));
std::vector<PointAnnotation> points;
points.emplace_back(PointAnnotation({ 50.0, 50.0 }, "default_marker"));
map.addPointAnnotations(points);
std::promise<bool> promise;
map.renderStill([&promise](std::exception_ptr, std::unique_ptr<const StillImage>) {
promise.set_value(true);
std::promise<std::unique_ptr<const StillImage>> promise;
map.renderStill([&promise](std::exception_ptr, std::unique_ptr<const StillImage> image) {
promise.set_value(std::move(image));
});
promise.get_future().get();
auto result = promise.get_future().get();
const std::string png = util::compress_png(result->width, result->height, result->pixels.get());
util::write_file("test/output/point_annotation.png", png);
}