Commit Graph

74 Commits

Author SHA1 Message Date
Bruno de Oliveira Abinader
38f3bed63e Export default transition delay in Map public API
Added a setter/getter for default transition delay, in the same fashion
as the default transition duration.

Spin-off from #1888. Fixes #302.
2015-07-21 18:02:09 +03:00
Bruno de Oliveira Abinader
0753aad57b Check for pending animations or transitions when scheduling another render pass
In continuous mode, we need to check if there are any pending animations or
transitions so we can properly tell the client application that another render
pass is required.
2015-07-20 14:38:19 +03:00
Bruno de Oliveira Abinader
bef3e1590b Force style cascade in MapContext::loadStyleJSON
Fixes #1889.
2015-07-14 18:12:52 +03:00
Bruno de Oliveira Abinader
0ea8a37cb0 Unify default transition values in MapData
Relevant changes:
 - Added 'defaultFadeDuration' and 'defaultTransitionDelay' to MapData;
 - Painter & StyleParser now receives a reference to MapData;
 - As previously seen on the code: 300ms is the default fade duration
   and 0ms is the default transition duration;
 - We no longer pass the current time point to Style, since it now uses
   MapData.animationTime, which gets updated in MapContext::update().
 - Updated StyleParser check to use a mock MapData;
2015-07-14 16:58:32 +03:00
Bruno de Oliveira Abinader
2aad2f4e14 Pass {Duration,TimePoint} by const ref if possible 2015-07-14 16:48:34 +03:00
Bruno de Oliveira Abinader
7023ea061c Unify time point for Mapcontext::update
- Let style classes cascade use the same time point as the one used to
  recalculate style.
- Cleaned up MapContext::update to return early whenever possible.
- Cleaned up MapContext::loadStyleJSON to avoid redundant calls to style
  classes cascade.
2015-07-14 16:44:42 +03:00
Thiago Marcos P. Santos
8a9665b085 Deffer updateAnnotationTiles() if Source is not available
The Style object might have been created but the Source is not
yet available because the JSON file was not set. Can happen
specially when the style is loaded from the network.
2015-07-10 20:25:49 +03:00
Justin R. Miller
cd7c3ddb9c fixes #1858: proper shape placement in style layers 2015-07-09 08:55:12 -07:00
Konstantin Käfer
b2a3314192 replace Style object immediately
this makes sure that adding custom sprite imagery will add them to the new Style object rather than
the old one in case a user adds new custom sprites immediately after changing a stylesheet
2015-07-08 19:46:01 +02:00
Konstantin Käfer
f9601ae685 add ability to set custom sprites on the Map object 2015-07-08 19:46:01 +02:00
Konstantin Käfer
afaf74e41a use SpriteStore from the SpriteAtlas 2015-07-08 19:46:00 +02:00
Konstantin Käfer
675ddddee7 Make pixelRatio constant across a Map object lifetime
also moves framebuffer size out of TransformState into its own object
2015-07-08 10:40:05 +02:00
Thiago Marcos P. Santos
ec1b4c43fd Do not force uv_loop_t as the first parameter for a threaded object ctor 2015-07-06 16:01:59 +03:00
Thiago Marcos P. Santos
f6b8dd4be9 Add simple static method to retrieve the current loop
In the lines of how we do for getting information of the
current thread.
2015-07-06 15:54:51 +03:00
John Firebaugh
f5f19d0eb0 External synchronization for AnnotationManager 2015-07-02 10:12:04 -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
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
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
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
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
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
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
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
Thiago Marcos P. Santos
b09df7acb5 Cleanup the MapContext before the util::Thread destructor
The util::Thread will call the stop() method of the MapContext's RunLoop
which will wait for the pending tasks tied to it to complete.

If we have a request that is timeout'ing, this could mean a really long
wait. Instead, we now send a cleanup message that will reset all the
attributes first (canceling the pending requests) so the the MapContext
gets destructed quickly.
2015-06-04 14:44:34 +03:00
Thiago Marcos P. Santos
29b8b44b77 Fix race condition on error notification
We start loading the resources at the moment we set the style, but we
set the callback for error notification at renderStill(), which happen
afterwards.

If some error occurs in this short window, it was never being notified.
Now we save the last error and we check after we set the callback.
2015-06-04 14:44:34 +03:00
John Firebaugh
ec06bb7e3c Merge ResourceLoader into Style and move atlas ownership 2015-06-01 13:22:02 -07:00
Konstantin Käfer
f4707f72e0 Replace mbgl::util::make_unique<> with std::make_unique<> 2015-05-26 17:57:38 +02:00
John Firebaugh
87b1da7611 DefaultFileSource has responsibility for handling mapbox:// URLs 2015-05-26 12:14:10 +02:00
Thiago Marcos P. Santos
da81211fea Add callback for error notifications on renderStill()
The callback will be called when any of the resources requested
from the network failed to load.

There is not recovery implemented yet, so the closest thing to
reseting the Map object and reloading all the resources would
be setting a new style.
2015-05-22 10:44:18 +03:00
Thiago Marcos P. Santos
41dc5e836a Emit the signal on the MapThread
We were previously emitting the signal on the thread parsing the
glyph, but signals can only be trigger from the MapThread
because the observers are living there.
2015-05-18 10:42:05 +03:00
Thiago Marcos P. Santos
f222efb939 Keep a pointer to GlyphStore on ResourceLoader
For now, keep a pointer so we can subscribe/unsubscribe to events. In
the future, we should move this object completely to ResourceLoader, but
we can't do it now because we delete the ResourceLoader when changing
the style.
2015-05-18 10:42:05 +03:00
John Firebaugh
c1d004b8fb Restore sprite load check
This is necessary to ensure that background and fill images are ready
to render.

Fixes #1563
2015-05-14 18:15:54 -07:00
Konstantin Käfer
e274959753 abort rendering early when we don't need to
when rendering still images, we don't need to render until everything is completely loaded
2015-05-13 10:39:22 +02:00
Leith Bade
703e0bc2ee Ignore deactivate when no valid EGL display. Fixes #1435
Initialise NativeMapView's EGL variables before Map

Fix hang

Add check for double pause

Add test for double pause
2015-05-09 12:02:39 +10:00
Thiago Marcos P. Santos
c487c521b4 Move the Sprite handling to ResourceLoader
This is the first concrete step to remove promises from the parsing
pipeline. Buckets depending on the Sprite (i.e. SymbolBucket) won't
be created if the Sprite is not loaded yet. When the Sprite finally gets
loaded, it will fire a signal that will ultimately trigger a reparse.

We still have to expose the Sprite to the Map object as it is needed
for getting offset pixels for annotation symbols, but we can probably
improve that.
2015-05-05 18:10:21 +03:00
Thiago Marcos P. Santos
d726613f6f Update the tiles via ResourceLoader 2015-05-05 18:10:21 +03:00
Thiago Marcos P. Santos
f4baa0ba3e Notify data changes using Observer pattern
This pattern, in contrast with callbacks, allows us to clearly see
the dependency and hierarchy between the objects. It will also help
on writing unit tests as we can count how many times a notification
was triggered.
2015-05-05 18:10:20 +03:00
Thiago Marcos P. Santos
4956da61b9 Introduce the ResourceLoader
ResourceLoader will handle all the tile changes and notifications
through the Source object owned by the Style. This object lives
entirely on the Map thread and should be only accessed by it.

The observer will receive notifications every time the tile data changes
and this will probably trigger a new rendering operation.

This first patch will delegate Source loading to the ResourceLoader.
2015-05-05 18:04:54 +03:00
Konstantin Käfer
5aa0caf5c5 don't trigger cleanups when we're not rendering 2015-05-05 11:53:23 +02:00
Konstantin Käfer
691c305467 add Map::isFullyLoaded()
returns whether the Map is still loading/parsing any assets or whether everything is there and a render will likely be complete
2015-05-05 11:47:23 +02:00
John Firebaugh
00a1f44cfc Ensure no GL commands are executed after pause 2015-05-04 18:27:48 -07:00
John Firebaugh
dac4b7d3c9 Reset previous style before creating new one
This ensures that the worker threads associated with the
style are joined before new worker threads are launched.
I don't know exactly why, but it seems to fix #1384.
2015-05-01 16:29:06 -04:00
John Firebaugh
1d957d6898 Deactivate after cleanup 2015-04-30 09:57:58 -04:00
John Firebaugh
cdb466e7f7 Convert Style to unique_ptr and pass by reference
Fixes #1277
Fixes #1309
2015-04-28 14:32:26 -04:00
John Firebaugh
0c280adebc Move Worker to Style
This ensures that worker tasks are entirely complete by the
time the style is destructed, and enables us to pass Style&
rather than a shared pointer.
2015-04-28 14:32:26 -04:00