Commit Graph

396 Commits

Author SHA1 Message Date
Bruno de Oliveira Abinader
dcbdfde932 [core] Use RVO in PremultipliedImage::decodeJPEG 2016-02-18 13:27:35 +02:00
Thiago Marcos P. Santos
1efc299e66 [core] Faster access with unordered_set
The ordering won't be affected because requests are made
as they arrive and later stored on the map just for
keeping state.
2016-02-16 23:06:04 +02:00
Thiago Marcos P. Santos
f5b521ffb5 [core] Remove requests from the pending queue on cancel
If we don't do this, we can activate a request twice.

The issue here is that we use memory address as the 'key'. So if
we destroy a request, another request might take the same memory
address, or the same 'key'.

The entry at 'pendingRequests' survives the 'cancel()' and is
ultimatelly removed at 'activatePendingRequest()'. This is fine
unless a request is created using the same 'key' before we call
'activatePendingRequest()'.

The check if the request was canceled at 'activatePendingRequest()'
will be no longer valid, activating the request. At the same time
the request will be activated again by the task scheduled at the
constructor of the 'OnlineFileRequestImpl' class.
2016-02-16 23:06:04 +02:00
John Firebaugh
d66d145c6e [core] Remove RunLoop::{ref,unref} 2016-02-16 12:48:50 -08:00
John Firebaugh
c2ab5b34a7 [tests] Fix build 2016-02-11 18:01:53 -08:00
Young Hahn
43c44eccdc Allow using tileSize: 512 as a switch to trade retina support for 512px raster tiles 2016-02-11 11:28:35 -08:00
Konstantin Käfer
5726d2b357 [core] use std::move() to prevent copies 2016-02-11 12:17:33 +01:00
Konstantin Käfer
bd08984713 [core] return std::move() prevents copy elision 2016-02-11 12:15:40 +01:00
Brad Leege
4719b73ac7 [android][ios][core] - #2421 Moving Mapbox PROD and TEST certificates to common location and updating iOS projects to load them from there 2016-02-10 19:05:23 -08:00
John Firebaugh
20be32f217 [core] Always store tiles without ratio support with ratio = 1 2016-02-10 16:25:47 -08:00
John Firebaugh
7e287cae1b [core] Eliminate tilesets table
This results in a ~1% increase in database size, which is worth it for reducing complexity and making the tiles and resources tables more similar in structure.
2016-02-10 16:25:44 -08:00
John Firebaugh
40ecdeb0b6 [core] Optimize offline database schema
* Under the hood, SQLite creates surrogate keys (ROWID) anyway. We may as well take advantage of this and use the surrogates for foreign keys as well, since they are simpler and more efficient than compound foreign keys.
* Create indexes for efficient eviction queries
2016-02-10 15:40:20 -08:00
John Firebaugh
0cf450e3e5 [core] Retry errors encountered during offline downloads 2016-02-10 15:40:20 -08:00
John Firebaugh
a9e0c1b99a [core] Eliminate maximumCacheEntrySize
Instead, the eviction policy accounts for the actual size needed for an incoming put.
2016-02-10 15:40:20 -08:00
John Firebaugh
db3620c58f [core] Implement an eviction policy for OfflineDatabase
When inserting an cached resource, or removing a region, remove least-recently used resources and tiles, not used by offline regions, until the used database size, as calculated by multiplying the number of in-use pages by the page size, is less than the maximum cache size minus 5 times the page size.

In addition, OfflineDatabase may be configured to ignore cache puts of individual resources larger than a certain size.

This policy is similar but not identical to the former SQLiteCache policy:

* It accounts for offline, by exempting resources required by offline regions from eviction.
* It must delete from two tables (resources and tiles), rather than one. Currently the strategy is naive: evict 50 rows at a time from each table.
* It makes maximumCacheSize and maximumCacheEntrySize completely independent. The SQLiteCache implementation evicted when `usedSize > maximumCacheSize - 2 * maximumCacheEntrySize`. This evicts when `usedSize > maximumCacheSize - 5 * pageSize`.
* It uses a non-unlimited default value for maximumCacheSize: 50 MB. We should have always had a limit in place; "a cache without an eviction policy is a resource leak".
2016-02-10 15:40:20 -08:00
John Firebaugh
5910124010 [core] Reset SQLite statements after use in order to release locks 2016-02-10 15:40:20 -08:00
John Firebaugh
ff15bd51b9 [core] Throttle the number of concurrent requests to 20 2016-02-10 15:40:20 -08:00
John Firebaugh
5d42321b73 [core] Make {Default,Online}FileSource::Impl more similar 2016-02-10 15:40:20 -08:00
John Firebaugh
96e0e5252e [core] Disable SQLite busy timeouts so that multiple readers can access the same database 2016-02-10 15:40:20 -08:00
John Firebaugh
4bde1b0c88 [core] Explicit operator bool 2016-02-10 15:40:20 -08:00
John Firebaugh
c3c4c7b9a6 [core] Interface and implementation for offline 2016-02-10 15:40:20 -08:00
John Firebaugh
e9302c797f [all] Don't interpret 404s on non-tile resources as "no content" 2016-02-10 15:40:20 -08:00
John Firebaugh
7eb1a91c4e [all] Do not set Response data for 404s
For AssetFileSource and the node FileSource this was already the case; this makes the other implementations consistent.
2016-02-10 15:40:20 -08:00
John Firebaugh
cdedb66387 [core] Reimplement existing caching within an offline-capable database schema 2016-02-10 15:40:20 -08:00
John Firebaugh
025375ad0b [core] Cache with mapbox:// tile URLs 2016-02-10 15:40:20 -08:00
John Firebaugh
dbb8e58aea [core] Moving caching logic to DefaultFileSource
This results in OnlineFileSource containing precisely the logic we want for reuse by OfflineFileSource, and no more.
2016-02-10 15:40:20 -08:00
Konstantin Käfer
33b63f0ef6 [glfw] add "C" button to show stencil clip masks 2016-02-10 11:35:17 +01:00
Konstantin Käfer
e74987b07f [core] move GL value objects from gl_config.hpp to gl_values.hpp
Also removes duplicate code from gl_helper.hpp by reusing the GL values that we already have anyway.
2016-02-08 12:50:00 +01:00
Konstantin Käfer
5c3b01ffcf [core] move util/gl_helper.hpp to gl/gl_helper.hpp 2016-02-08 12:50:00 +01:00
Konstantin Käfer
2f06ca74e2 [core] move platform/gl.hpp to gl/gl.hpp 2016-02-08 12:50:00 +01:00
Bruno de Oliveira Abinader
2f86467586 Cleanup std::chrono usage
Use mbgl::Duration and mbgl::{,Milli}Seconds whenever possible.
2016-01-25 15:11:18 +02:00
John Firebaugh
a877b9b192 [core] Include prior values of caching headers in Resource
This allows the FileSource interface itself to support revalidation. We could (and probably should) now rewrite HTTPContextBase implementations as FileSource implementations.
2016-01-22 18:42:53 -08:00
John Firebaugh
cef5c331fe [core] Merge rfc1123, iso8601, and parse_date into chrono.hpp and fix their API 2016-01-22 18:41:54 -08:00
John Firebaugh
1c21d0fd4c [core] Use better types for modified / expires / etag 2016-01-21 11:22:11 -08:00
John Firebaugh
c33ed50c98 [core] Eliminate Response::stale and inline Response::isExpired()
Response::isExpired() had subtle and potentially confusing behavior around Seconds::zero(). It's best to inline it and comment why.
2016-01-21 11:22:11 -08:00
John Firebaugh
1766d7dcbf [core] Eliminate RequestBase
HTTPRequestBase can now itself be the base class.
2016-01-21 11:22:11 -08:00
Thiago Marcos P. Santos
55c31493af [core] Add ref counting to the main loop
Should not be used at all, added for a corner case
on OSX network backend where the request is processed on
a worker thread managed by OSX and we need to wait for
that reply before destroying the thread that pushed the
request.
2016-01-20 19:54:20 +02:00
Bruno de Oliveira Abinader
9cd9065031 Revert "Revert WebP support due to broken builds"
This reverts commit 6709bdcacd.

There was an issue with the script that removes '-lwebp' from WebP
linker flags, since we're statically linking. This is now fixed.
2016-01-20 10:35:44 +02:00
Ansis Brammanis
d34f8eb674 [core][ios][osx][android] make SpriteImage accept PremultipliedImage
the SpriteImage constructor signature changes from

SpriteImage(
        uint16_t width, uint16_t height, float pixelRatio,
        std::string&& data, bool sdf = false);

to

SpriteImage(PremultipliedImage&&, float pixelRatio, bool sdf = false)
2016-01-19 18:23:21 -08:00
John Firebaugh
dbfa932ed1 [core] Eliminate macros in sqlite3.cpp 2016-01-19 13:39:18 -08:00
John Firebaugh
6709bdcacd Revert WebP support due to broken builds
This reverts commits 2010fbb0e6, a361ce47a1, and d004bb275a.
2016-01-19 13:34:56 -08:00
Bruno de Oliveira Abinader
a361ce47a1 [linux] Added WebP tile support
- Android support is currently disabled due to a libwebp build issue.
- iOS and OS X support will appear after the next Mapbox iOS SDK release.

Related: #https://github.com/mapbox/mapbox-gl-native/issues/2354
2016-01-19 16:06:36 +02:00
Thiago Marcos P. Santos
7ad9e47bbe [glfw] Fix panning direction
Follow-up of the transform refactoring
2016-01-19 11:36:26 +02:00
Minh Nguyễn
47b69100f9 [core, ios, osx, android, glfw] Flipped origin of Map::latLngForPixel(), Map::pixelForLatLng()
Map and Transform methods assume an origin at the top-left corner of the view, like iOS, Android, and GLFW but unlike OS X. Transform is responsible for flipping coordinates between the top-left origin of Map and the bottom-left origin of TransformState.

Fixes #3574.
2016-01-18 16:54:58 -08:00
Konstantin Käfer
957415823a [core] Support multiple paths in SQLiteCache::getShared()
If you use many different caches, expired weak_ptrs will pile up in the unordered_map, but that is an edge case, and you probably shouldn't do that anyway.
2016-01-15 10:44:16 +01:00
Konstantin Käfer
8939a7b706 [core] move SharedSQLiteCache::get to SQLiteCache::getShared 2016-01-15 10:38:09 +01:00
John Firebaugh
f62d41ae05 [core] Restore existing response body
Until #2721 lands we still need this.
2016-01-14 18:38:56 -08:00
John Firebaugh
0066637e58 [core] Let SQLiteCache decide when store or refresh responses 2016-01-14 13:46:03 -08:00
John Firebaugh
2aafdbc1b8 [core] Add an explicit "not modified" indicator to Response 2016-01-14 13:46:03 -08:00
John Firebaugh
2ee1fe4178 [core] std::shared_ptr<const Response> ⇢ const Response& 2016-01-14 13:46:03 -08:00