Commit Graph

2256 Commits

Author SHA1 Message Date
John Firebaugh
24f50fdd4f Remove indirection 2015-07-01 15:21:09 -07:00
Konstantin Käfer
9e0b241dde reset partialParse when starting a new parsing run 2015-07-01 15:21:09 -07:00
John Firebaugh
4676553a3e Merge TileParser into TileWorker 2015-07-01 15:21:09 -07:00
John Firebaugh
875ef979be Remove indirection 2015-07-01 15:21:09 -07:00
John Firebaugh
217c376291 Push TileMembers members down hierarchy 2015-07-01 15:21:09 -07:00
John Firebaugh
29a2cd908f Introduce TileWorker 2015-07-01 15:21:08 -07:00
John Firebaugh
7e71145a89 Make request and reparse pure virtual 2015-07-01 15:21:08 -07:00
John Firebaugh
ee46378583 Reduce number of arguments in Source::update pathway 2015-07-01 15:21:08 -07:00
John Firebaugh
4eff674c1d Revert "Do not hold a reference to the Style at the [Live|Vector]TileData"
This reverts commit 044454417b.
2015-07-01 15:21:08 -07:00
Thiago Marcos P. Santos
295ea0856b Cancel pending Style requests before making a new one
Calling setStyleURL() multiple times in a short period
of time will enqueue requests on the FileSource. The
order they get replied is not guaranteed to be the same
as the order we make the requests. The side effect was
the last style set not always being the one rendered.

Now we cancel the current request if we make a new one
(and there was no point on keeping it around anyway).
2015-07-01 15:18:37 +03:00
Ansis Brammanis
176e42cb61 show symbols at z0, fix #1279 2015-07-01 13:16:16 +02:00
John Firebaugh
6532438fe4 Rationalize *RenderingMap notifications 2015-06-30 10:13:24 -07:00
John Firebaugh
37117dae00 Eliminate MapData::get/setFullyLoaded 2015-06-30 10:13:23 -07:00
Thiago Marcos P. Santos
dc9a88629b Check if the style was loaded before rendering
We now drive rendering from the main thread calling renderSync(),
but if we do it just after we set the style URL it will assert
because renderSync() expects the style to be fully loaded.
2015-06-30 15:39:41 +03:00
John Firebaugh
42c06e7039 Use array of structs rather than parallel arrays for annotations 2015-06-29 10:54:17 -07:00
Konstantin Käfer
45d0cbb4c7 add assert_always() macro for release build assertions 2015-06-29 11:32:19 +02:00
Minh Nguyễn
ac2ad993a5 Fit to coordinates
Whoever determined the boundaries of the District of Columbia did not have fit-to-bounds implementations in mind. With this change, shapes that are not unrotated rectangles fit much, much better.
2015-06-26 21:46:15 -07:00
John Firebaugh
95351dd906 Send MapChangeRegionIsChanging notifications 2015-06-26 10:32:07 -07:00
John Firebaugh
d193083513 Remove duration argument from View::notifyMapChange
Fixes #1026
2015-06-26 10:32:07 -07:00
John Firebaugh
e6a576f6eb currentState() ⇢ getState() 2015-06-26 10:32:07 -07:00
John Firebaugh
07a6d2ef64 Move Transform from MapData to Map
Pass current state to MapContext where needed. Remove mutex from
Transform.
2015-06-26 10:32:07 -07:00
John Firebaugh
e87a36444f Move getMin/MaxZoom to TransformState 2015-06-26 10:32:07 -07:00
John Firebaugh
874aa69efb Inline updateTiles and recalculateStyle 2015-06-26 10:32:07 -07:00
Konstantin Käfer
84e2ea886d drive map rendering from main thread 2015-06-26 10:32:06 -07:00
Konstantin Käfer
740281cc89 remove unused renderAsync() function 2015-06-26 10:32:06 -07:00
Minh Nguyễn
bcbb56c188 Maintain rotation when fitting to bounds
Also fit to the rotated bounds. A little more verbose than necessary due to <http://stackoverflow.com/a/2357688/4585461>.

ref mapbox/mapbox-gl-js#1338
2015-06-25 21:54:57 -07:00
Minh Nguyễn
68e404c522 Fit to bounds with padding
Each side of the bounding box is specified independently, allowing more flexibility than the offset + padding construct supported in mapbox/mapbox-gl-js’ Camera.
2015-06-25 21:54:57 -07:00
Minh Nguyễn
c57799f26c Reimplemented fit to bounds
The new implementation is now public and takes advantage of MGLCoordinateBounds. It is re-ported from `Camera.prototype.fitBounds()` in mapbox/mapbox-gl-js to ensure correct behavior. A new function, MGLCoordinateBoundsMake(), makes it easier to create an MGLCoordinateBounds for use with this method.
2015-06-25 21:54:53 -07:00
Thiago Marcos P. Santos
07086981fe Get rid of Environment et al.
mbgl::Environment is not used anymore and can
removed.
2015-06-25 16:26:22 +03:00
Thiago Marcos P. Santos
e32b0b7e20 Introduce GLObjectStore
Make a class for keeping GL objects ids and attach it
to the ThreadContext instead of hanging it on the Environment.
2015-06-25 16:26:21 +03:00
Thiago Marcos P. Santos
be4cb6786b Make the FileSource available from the ThreadContext
For now we set the FileSource for the Worker context
but in the future after fixing #1664 we can assert()
that FileSource are set only for the Map thread context.
2015-06-25 16:26:21 +03:00
Thiago Marcos P. Santos
b56c356de7 Use ThreadContext data for logging
Do not use the Environment anymore. The Environment ID is not
really necessary anymore as we are forwarding exceptions to the
main thread, so we always know which Map object triggered the
error.
2015-06-25 16:26:21 +03:00
Thiago Marcos P. Santos
a8b6b67dfe Introduce the ThreadContext
mbgl::Thread will keep a ThreadContext for each running instance
in a thread_local so we don't need to lookup a man in the Environment
every time we need some info about the current thread.

This patch is moving the ::currentlyOn check used on Debug build from
the Environment class to the ThreadContext.
2015-06-25 16:26:21 +03:00
John Firebaugh
7bb86368d4 Remove unused 2015-06-24 14:56:48 -07:00
John Firebaugh
a05698fe06 Remove MapData dependency from AnnotationManager 2015-06-24 13:08:37 -07:00
John Firebaugh
4ba78b6bcf Transform needs only a single TransformState 2015-06-24 13:08:36 -07:00
Bruno de Oliveira Abinader
3396bcaaac Cleaned up remaining bool function return values 2015-06-23 19:59:22 +03:00
Bruno de Oliveira Abinader
71ed184bc4 Improve readibility for style parser results
Introduces StyleParser::Result being a std::tuple<Status, T>, where
StyleParser::Status is a boolean enumerator which improves readibility.
2015-06-23 19:58:14 +03:00
Bruno de Oliveira Abinader
7bfae2a1a5 Fix result value from parseProperty when T = std::array<float, 2> 2015-06-22 22:46:37 +03:00
Mike Morris
898f4d3f08 Check libuv version semver-ishly
Fixes https://github.com/mapbox/node-mapbox-gl-native/issues/137
2015-06-19 11:48:41 -07:00
Konstantin Käfer
0f5ad29b4e propertly initialize the name 2015-06-19 12:35:14 +03:00
John Firebaugh
eb52f86ee1 Fix an order-of-operations issue with tileLoadingCompleteCallback
==7466== Invalid read of size 8
==7466==    at 0x5F1D0B: mbgl::TransformState::getAngle() const (transform_state.cpp:159)
==7466==    by 0x700CD2: mbgl::Source::tileLoadingCompleteCallback(mbgl::TileID const&, mbgl::TransformState const&, bool) (source.cpp:574)

==7466==  Address 0xf1d1508 is 56 bytes inside a block of size 120 free'd
==7466==    at 0x4C2A4BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7466==    by 0x70AD61: std::_Function_base::_Base_manager<std::_Bind<std::_Mem_fn<void (mbgl::Source::*)(mbgl::TileID const&, mbgl::TransformState const&, bool)> ()(mbgl::Source*, mbgl::TileID, mbgl::TransformState, bool)> >::_M_destroy(std::_Any_data&, std::integral_constant<bool, false>) (functional:1894)
==7466==    by 0x7080EB: std::_Function_base::_Base_manager<std::_Bind<std::_Mem_fn<void (mbgl::Source::*)(mbgl::TileID const&, mbgl::TransformState const&, bool)> ()(mbgl::Source*, mbgl::TileID, mbgl::TransformState, bool)> >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) (functional:1918)
==7466==    by 0x535033: _ZNSt8functionIFvvEEaSEDn (functional:2277)
==7466==    by 0x56A3F5: mbgl::WorkTask::cancel() (work_task.cpp:34)
==7466==    by 0x56146C: mbgl::WorkRequest::~WorkRequest() (work_request.cpp:13)
==7466==    by 0x50C5E0: std::default_delete<mbgl::WorkRequest>::operator()(mbgl::WorkRequest*) const (unique_ptr.h:76)
==7466==    by 0x50C411: std::unique_ptr<mbgl::WorkRequest, std::default_delete<mbgl::WorkRequest> >::reset(mbgl::WorkRequest*) (unique_ptr.h:344)
==7466==    by 0x50C374: std::unique_ptr<mbgl::WorkRequest, std::default_delete<mbgl::WorkRequest> >::operator=(std::unique_ptr<mbgl::WorkRequest, std::default_delete<mbgl::WorkRequest> >&&) (unique_ptr.h:251)
==7466==    by 0x743136: mbgl::TileData::reparse(mbgl::Worker&, std::function<void ()()>) (tile_data.cpp:89)
==7466==    by 0x6FEA7C: mbgl::Source::handlePartialTile(mbgl::TileID const&, mbgl::Worker&) (source.cpp:250)
==7466==    by 0x700338: mbgl::Source::update(mbgl::MapData&, mbgl::TransformState const&, mbgl::Style&, mbgl::GlyphAtlas&, mbgl::GlyphStore&, mbgl::SpriteAtlas&, mbgl::util::ptr<mbgl::Sprite>, mbgl::TexturePool&, bool) (source.cpp:438)
==7466==    by 0x68C1A5: mbgl::Style::update(mbgl::MapData&, mbgl::TransformState const&, mbgl::TexturePool&) (style.cpp:82)
==7466==    by 0x548F5C: (anonymous namespace)::MockMapContext::update() (resource_loading.cpp:51)
==7466==    by 0x548FA3: (anonymous namespace)::MockMapContext::onTileDataChanged() (resource_loading.cpp:56)
==7466==    by 0x68CDE4: mbgl::Style::emitTileDataChanged() (style.cpp:212)
==7466==    by 0x68CBDB: mbgl::Style::onTileLoaded(bool) (style.cpp:191)
==7466==    by 0x700F38: mbgl::Source::emitTileLoaded(bool) (source.cpp:595)
==7466==    by 0x700CA2: mbgl::Source::tileLoadingCompleteCallback(mbgl::TileID const&, mbgl::TransformState const&, bool) (source.cpp:573)

The invalid `TransformState::getAngle()` read comes from the following: the
storage for `TransformState` is the [bound parameter in this
callback](https://github.com/mapbox/mapbox-gl-native/blob/5e0775d276f9ea3652bae1
23c4e85cc05ae13bd5/src/mbgl/map/source.cpp#L292-292). The callback itself is
copied into various lambda bindings and eventually winds up as the [after
callback](https://github.com/mapbox/mapbox-gl-native/blob/5e0775d276f9ea3652bae1
23c4e85cc05ae13bd5/src/mbgl/map/tile_data.cpp#L89-89) for the worker task.

On the way out, `tileLoadingCompleteCallback` gets called via this callback
binding. It first does `emitTileLoaded`, which happens to cause [a _new_ work
request to be
queued](https://github.com/mapbox/mapbox-gl-native/blob/5e0775d276f9ea3652bae123
c4e85cc05ae13bd5/src/mbgl/map/source.cpp#L250-250). This cancels the
in-progress work request, [by nulling-out the `after`
callback](https://github.com/mapbox/mapbox-gl-native/blob/5e0775d276f9ea3652bae1
23c4e85cc05ae13bd5/src/mbgl/util/work_task.cpp#L34-34). But in fact, the after
callback is still executing. The next thing it does is [call
transformState.getAngle()](https://github.com/mapbox/mapbox-gl-native/blob/5e077
5d276f9ea3652bae123c4e85cc05ae13bd5/src/mbgl/map/source.cpp#L574), but the
transformState is now gone.
2015-06-18 13:39:18 +03:00
John Firebaugh
3ef8d8728e Don't abandon a null texture 2015-06-18 13:39:18 +03:00
John Firebaugh
0cce08b67b Change StyleBucket::source to indirect reference
This eliminates a reference loop: VectorTileData holds StyleLayers which
hold StyleBuckets which held Sources which hold VectorTileDatas. This
breaks the StyleBucket -> Source link in favor of manually resolving the
reference where necessary.
2015-06-18 13:39:18 +03:00
Thiago Marcos P. Santos
044454417b Do not hold a reference to the Style at the [Live|Vector]TileData
Layers are added and removed dynamically on the Map thread when we use shape
annotations and we are iterating style.layers on the Worker thread without
any lock.

Now when we create a [Live|Vector]TileData at the Map thread we give it
a layers list (instead of the Style) and [Live|Vector]TileData will ultimately
make a copy of this list (on the Map thread, so no concurrency with
adding shape annotations).

The copy should be relatively cheap because we are using a shared pointer
for storing the layers on the list.
2015-06-18 13:39:18 +03:00
Bruno de Oliveira Abinader
ff0e54f35a Cleaned up #defines for BUFFER_OFFSET 2015-06-18 09:48:34 +03:00
Thiago Marcos P. Santos
57c34747a2 Report errors for renderStill() misuse using the callback
Use the callback provided for reporting the errors instead of throwing
an exception. The problem with the exception is it will happen on the
Map thread which makes it impossible to the user of our API to catch,
ultimately resulting in a crash.

In the scenario of not providing a callback, we just print an error.
2015-06-16 14:06:29 +03:00
Justin R. Miller
bd0bf294bf squash of #1655: shape annotations support for core & iOS 2015-06-15 18:30:39 -07:00
Minh Nguyễn
714b68f7b3 Revert "use array of structs rather than parallel arrays for annotations"
This reverts commit 2435c1ad26 (#1710), which needs to be revisited in light of #1655, which is a much higher priority at the moment.
2015-06-15 15:58:22 -07:00
hanchao
b8c251592a fix roundabout not closed #1450 2015-06-14 07:56:31 +02:00