Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into HEAD
Browse files Browse the repository at this point in the history
Conflicts:
	src/mbgl/renderer/painter_fill.cpp
  • Loading branch information
ansis committed Jun 3, 2015
2 parents 2bd7e45 + 295dc73 commit 9c03b39
Show file tree
Hide file tree
Showing 29 changed files with 348 additions and 465 deletions.
2 changes: 1 addition & 1 deletion .mason
Submodule .mason updated 1 files
+2 −2 mason.sh
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ matrix:
sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ]
packages: [ 'gdb', 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ]
- os: osx
osx_image: beta-xcode6.3
env: FLAVOR=osx BUILDTYPE=Debug
- os: osx
osx_image: beta-xcode6.3
env: FLAVOR=ios BUILDTYPE=Release
- os: linux
env: FLAVOR=android ANDROID_ABI=arm-v7 BUILDTYPE=Release
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ pod 'MapboxGL'

#### Manually

1. Install [appledoc](http://appledoc.gentlebytes.com/appledoc/) for API docs generation. We recommend [`2.2v963`](https://github.com/tomaz/appledoc/releases/tag/v2.2-963), which currently isn't available in Homebrew.
1. Install [appledoc](http://appledoc.gentlebytes.com/appledoc/) 2.2v963 for API docs generation (only this exact version works).

```
curl -L -o appledoc.zip https://github.com/tomaz/appledoc/releases/download/v2.2-963/appledoc.zip
unzip appledoc.zip
cp appledoc /usr/local/bin
cp -Rf Templates/ ~/.appledoc
```
1. Run `make ipackage`. The packaging script will produce the statically-linked `libMapboxGL.a`, `MapboxGL.bundle` for resources, a `Headers` folder, and a `Docs` folder with HTML API documentation.
1. Copy the contents of `build/ios/pkg/static` into your project. It should happen automatically, but ensure that:
- `Headers` is in your *Header Search Paths* (`HEADER_SEARCH_PATHS`) build setting.
Expand All @@ -82,6 +90,7 @@ pod 'MapboxGL'

If you want to build from source and/or contribute to development of the project, run `make iproj`, which will create and open an Xcode project which can build the entire library from source as well as an Objective-C test app. If you don't have an Apple Developer account, change the destination from "My Mac" to a simulator such as "iPhone 6" before you run and build the app.

#### Testing
You can run `make itest` to run the included integration tests. Requires `gem install xcpretty`. If you want to run the tests in Xcode instead, first `make ipackage` to create a local static library version, then open `test/ios/ios-tests.xcodeproj`, and lastly `Command + U` on the `Mapbox GL Tests` application target.

Target devices: iPhone 4S and above (5, 5c, 5s, 6, 6 Plus) and iPad 2 and above (3, 4, Mini, Air, Mini 2, Air 2).
Expand Down
4 changes: 2 additions & 2 deletions include/mbgl/platform/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum class Event : uint8_t {
ParseStyle,
ParseTile,
Render,
ResourceLoader,
Style,
Database,
HttpRequest,
Sprite,
Expand All @@ -47,7 +47,7 @@ MBGL_DEFINE_ENUM_CLASS(EventClass, Event, {
{ Event::ParseStyle, "ParseStyle" },
{ Event::ParseTile, "ParseTile" },
{ Event::Render, "Render" },
{ Event::ResourceLoader, "ResourceLoader" },
{ Event::Style, "Style" },
{ Event::Database, "Database" },
{ Event::HttpRequest, "HttpRequest" },
{ Event::Sprite, "Sprite" },
Expand Down
2 changes: 1 addition & 1 deletion ios/benchmark/MBXBenchViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (void)viewDidLoad
[super viewDidLoad];

NSURL* url = [[NSURL alloc] initWithString:@"asset://styles/mapbox-streets-v7.json"];
self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds accessToken:nil styleURL:url];
self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds styleURL:url];
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.mapView.delegate = self;
self.mapView.zoomEnabled = NO;
Expand Down
2 changes: 1 addition & 1 deletion ios/docs/install_docs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

if [ -z `which appledoc` ]; then
echo "Unable to find appledoc. Consider installing it from source or Homebrew."
echo "Unable to find appledoc. See https://github.com/mapbox/mapbox-gl-native#manually"
exit 1
fi

Expand Down
32 changes: 29 additions & 3 deletions platform/ios/MGLMapboxEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ @interface MGLMapboxEvents () <CLLocationManagerDelegate>
@property (atomic) NSURLSession *session;
@property (atomic) NSData *digicertCert;
@property (atomic) NSData *geoTrustCert;
@property (atomic) NSData *testServerCert;
@property (atomic) BOOL usesTestServer;

// Main thread only
@property (nonatomic) CLLocationManager *locationManager;
Expand Down Expand Up @@ -239,6 +241,10 @@ - (instancetype) init {
NSString *testURL = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLMetricsTestServerURL"];
if (testURL != nil) {
MGLMapboxEventsAPIBase = testURL;
_usesTestServer = YES;
} else {
// Explicitly Set For Clarity
_usesTestServer = NO;
}

_paused = YES;
Expand All @@ -256,6 +262,10 @@ - (instancetype) init {
if (cerPath != nil) {
_digicertCert = [NSData dataWithContentsOfFile:cerPath];
}
cerPath = [resourceBundle pathForResource:@"star_tilestream_net" ofType:@"der"];
if (cerPath != nil) {
_testServerCert = [NSData dataWithContentsOfFile:cerPath];
}

// Events Control
_eventQueue = [[NSMutableArray alloc] init];
Expand Down Expand Up @@ -848,7 +858,7 @@ - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticat
// Look for a pinned certificate in the server's certificate chain
long numKeys = SecTrustGetCertificateCount(serverTrust);

BOOL found = false;
BOOL found = NO;
// Try GeoTrust Cert First
for (int lc = 0; lc < numKeys; lc++) {
SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc);
Expand All @@ -858,7 +868,7 @@ - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticat
if ([remoteCertificateData isEqualToData:_geoTrustCert]) {
// Found the certificate; continue connecting
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
found = true;
found = YES;
break;
}
}
Expand All @@ -873,11 +883,27 @@ - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticat
if ([remoteCertificateData isEqualToData:_digicertCert]) {
// Found the certificate; continue connecting
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
found = true;
found = YES;
break;
}
}

if (!found && _usesTestServer) {
// See if this is test server
for (int lc = 0; lc < numKeys; lc++) {
SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc);
NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate));

// Compare Remote Key With Local Version
if ([remoteCertificateData isEqualToData:_testServerCert]) {
// Found the certificate; continue connecting
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
found = YES;
break;
}
}
}

if (!found) {
// The certificate wasn't found in GeoTrust nor Digicert. Cancel the connection.
completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
Expand Down
Binary file added platform/ios/resources/star_tilestream_net.der
Binary file not shown.
6 changes: 6 additions & 0 deletions scripts/ios/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ brew install git
mapbox_time "install_awscli" \
brew install awscli

mapbox_time "install_appledoc" \
wget https://github.com/tomaz/appledoc/releases/download/v2.2-963/appledoc.zip && \
tar xvzf appledoc.zip && \
cp appledoc /usr/local/bin && \
cp -Rf Templates/ ~/.appledoc

mkdir -p ${KIF_SCREENSHOTS}
2 changes: 1 addition & 1 deletion scripts/ios/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ cp -prv styles/styles "${OUTPUT}/static/${NAME}.bundle/styles"

step "Creating API Docs..."
if [ -z `which appledoc` ]; then
echo "Unable to find appledoc. Consider installing it from source or Homebrew."
echo "Unable to find appledoc. See https://github.com/mapbox/mapbox-gl-native#manually"
exit 1
fi
DOCS_OUTPUT="${OUTPUT}/static/Docs"
Expand Down
38 changes: 6 additions & 32 deletions src/mbgl/map/map_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@
#include <mbgl/map/map_data.hpp>
#include <mbgl/map/view.hpp>
#include <mbgl/map/environment.hpp>
#include <mbgl/map/source.hpp>
#include <mbgl/map/still_image.hpp>

#include <mbgl/platform/log.hpp>

#include <mbgl/renderer/painter.hpp>

#include <mbgl/text/glyph_store.hpp>

#include <mbgl/geometry/glyph_atlas.hpp>
#include <mbgl/geometry/sprite_atlas.hpp>
#include <mbgl/geometry/line_atlas.hpp>

#include <mbgl/storage/resource.hpp>
#include <mbgl/storage/response.hpp>

Expand All @@ -34,10 +27,6 @@ MapContext::MapContext(uv_loop_t* loop, View& view_, FileSource& fileSource, Map
envScope(env, ThreadType::Map, "Map"),
updated(static_cast<UpdateType>(Update::Nothing)),
asyncUpdate(std::make_unique<uv::async>(loop, [this] { update(); })),
glyphStore(std::make_unique<GlyphStore>(loop, env)),
glyphAtlas(std::make_unique<GlyphAtlas>(1024, 1024)),
spriteAtlas(std::make_unique<SpriteAtlas>(512, 512)),
lineAtlas(std::make_unique<LineAtlas>(512, 512)),
texturePool(std::make_unique<TexturePool>()) {
assert(Environment::currentlyOn(ThreadType::Map));

Expand All @@ -51,14 +40,9 @@ MapContext::~MapContext() {

// Explicit resets currently necessary because these abandon resources that need to be
// cleaned up by env.performCleanup();
resourceLoader.reset();
style.reset();
painter.reset();
texturePool.reset();
lineAtlas.reset();
spriteAtlas.reset();
glyphAtlas.reset();
glyphStore.reset();

env.performCleanup();

Expand Down Expand Up @@ -116,29 +100,19 @@ void MapContext::setStyleJSON(const std::string& json, const std::string& base)
void MapContext::loadStyleJSON(const std::string& json, const std::string& base) {
assert(Environment::currentlyOn(ThreadType::Map));

resourceLoader.reset();
style.reset();

style = std::make_unique<Style>();
style->base = base;
style->loadJSON((const uint8_t *)json.c_str());
style = std::make_unique<Style>(json, base, asyncUpdate->get()->loop, env);
style->cascade(data.getClasses());
style->setDefaultTransitionDuration(data.getDefaultTransitionDuration());

glyphStore->setURL(style->glyph_url);

resourceLoader = std::make_unique<ResourceLoader>();
resourceLoader->setObserver(this);
resourceLoader->setStyle(style.get());
resourceLoader->setGlyphStore(glyphStore.get());
style->setObserver(this);

triggerUpdate(Update::Zoom);
}

void MapContext::updateTiles() {
assert(Environment::currentlyOn(ThreadType::Map));

resourceLoader->update(data, transformState, *glyphAtlas, *spriteAtlas, *texturePool);
style->update(data, transformState, *texturePool);
}

void MapContext::updateAnnotationTiles(const std::vector<TileID>& ids) {
Expand Down Expand Up @@ -177,7 +151,7 @@ void MapContext::update() {

updateTiles();

if (style->isLoaded() && resourceLoader->getSprite()->isLoaded()) {
if (style->isLoaded()) {
if (!data.getFullyLoaded()) {
data.setFullyLoaded(true);
}
Expand Down Expand Up @@ -220,7 +194,7 @@ void MapContext::render() {
assert(style);

if (!painter) {
painter = std::make_unique<Painter>(*spriteAtlas, *glyphAtlas, *lineAtlas);
painter = std::make_unique<Painter>();
painter->setup();
}

Expand All @@ -240,7 +214,7 @@ void MapContext::render() {

double MapContext::getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol) {
assert(Environment::currentlyOn(ThreadType::Map));
const SpritePosition pos = resourceLoader->getSprite()->getSpritePosition(symbol);
const SpritePosition pos = style->sprite->getSpritePosition(symbol);
return -pos.height / pos.pixelRatio / 2;
}

Expand Down
16 changes: 3 additions & 13 deletions src/mbgl/map/map_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <mbgl/map/tile_id.hpp>
#include <mbgl/map/update.hpp>
#include <mbgl/map/environment.hpp>
#include <mbgl/map/resource_loader.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/util/ptr.hpp>

#include <vector>
Expand All @@ -20,20 +20,15 @@ namespace mbgl {

class View;
class MapData;
class GlyphStore;
class GlyphAtlas;
class SpriteAtlas;
class LineAtlas;
class TexturePool;
class Painter;
class Sprite;
class Style;
class Worker;
class StillImage;
struct LatLng;
struct LatLngBounds;

class MapContext : public ResourceLoader::Observer {
class MapContext : public Style::Observer {
public:
MapContext(uv_loop_t*, View&, FileSource&, MapData&);
~MapContext();
Expand All @@ -59,7 +54,7 @@ class MapContext : public ResourceLoader::Observer {
void setSourceTileCacheSize(size_t size);
void onLowMemory();

// ResourceLoader::Observer implementation.
// Style::Observer implementation.
void onTileDataChanged() override;
void onResourceLoadingFailed(std::exception_ptr error) override;

Expand All @@ -81,14 +76,9 @@ class MapContext : public ResourceLoader::Observer {
UpdateType updated { static_cast<UpdateType>(Update::Nothing) };
std::unique_ptr<uv::async> asyncUpdate;

std::unique_ptr<GlyphStore> glyphStore;
std::unique_ptr<GlyphAtlas> glyphAtlas;
std::unique_ptr<SpriteAtlas> spriteAtlas;
std::unique_ptr<LineAtlas> lineAtlas;
std::unique_ptr<TexturePool> texturePool;
std::unique_ptr<Painter> painter;
std::unique_ptr<Style> style;
std::unique_ptr<ResourceLoader> resourceLoader;

std::string styleURL;
std::string styleJSON;
Expand Down
Loading

0 comments on commit 9c03b39

Please sign in to comment.