Skip to content

Commit

Permalink
expose option to create context with antialiasing
Browse files Browse the repository at this point in the history
fix #7543
  • Loading branch information
ansis committed Feb 25, 2019
1 parent 4bf07df commit ed3d0e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions debug/threejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

var map = window.map = new mapboxgl.Map({
container: 'map',
antialias: true,
zoom: 16.5,
center: [-79.390307, 43.658956],
bearing: 20,
Expand Down
11 changes: 8 additions & 3 deletions src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type MapOptions = {
logoPosition?: ControlPosition,
failIfMajorPerformanceCaveat?: boolean,
preserveDrawingBuffer?: boolean,
antialias?: boolean,
refreshExpiredTiles?: boolean,
maxBounds?: LngLatBoundsLike,
scrollZoom?: boolean,
Expand Down Expand Up @@ -183,6 +184,7 @@ const defaultOptions = {
* @param {boolean} [options.failIfMajorPerformanceCaveat=false] If `true`, map creation will fail if the performance of Mapbox
* GL JS would be dramatically worse than expected (i.e. a software renderer would be used).
* @param {boolean} [options.preserveDrawingBuffer=false] If `true`, the map's canvas can be exported to a PNG using `map.getCanvas().toDataURL()`. This is `false` by default as a performance optimization.
* @param {boolean} [options.antialias] If `true`, create the gl context will be created with msaa antialiasing, which can be useful for antialiasing custom layers. this is `false` by default as a performance optimization.
* @param {boolean} [options.refreshExpiredTiles=true] If `false`, the map won't attempt to re-request tiles once they expire per their HTTP `cacheControl`/`expires` headers.
* @param {LngLatBoundsLike} [options.maxBounds] If set, the map will be constrained to the given bounds.
* @param {boolean|Object} [options.scrollZoom=true] If `true`, the "scroll to zoom" interaction is enabled. An `Object` value is passed as options to {@link ScrollZoomHandler#enable}.
Expand Down Expand Up @@ -255,6 +257,7 @@ class Map extends Camera {
_trackResize: boolean;
_preserveDrawingBuffer: boolean;
_failIfMajorPerformanceCaveat: boolean;
_antialias: boolean;
_refreshExpiredTiles: boolean;
_hash: Hash;
_delegatedListeners: any;
Expand Down Expand Up @@ -317,6 +320,7 @@ class Map extends Camera {
this._maxTileCacheSize = options.maxTileCacheSize;
this._failIfMajorPerformanceCaveat = options.failIfMajorPerformanceCaveat;
this._preserveDrawingBuffer = options.preserveDrawingBuffer;
this._antialias = options.antialias;
this._trackResize = options.trackResize;
this._bearingSnap = options.bearingSnap;
this._refreshExpiredTiles = options.refreshExpiredTiles;
Expand Down Expand Up @@ -1547,10 +1551,11 @@ class Map extends Camera {
}

_setupPainter() {
const attributes = extend({
const attributes = extend({}, isSupported.webGLContextAttributes, {
failIfMajorPerformanceCaveat: this._failIfMajorPerformanceCaveat,
preserveDrawingBuffer: this._preserveDrawingBuffer
}, isSupported.webGLContextAttributes);
preserveDrawingBuffer: this._preserveDrawingBuffer,
antialias: this._antialias || false
});

const gl = this._canvas.getContext('webgl', attributes) ||
this._canvas.getContext('experimental-webgl', attributes);
Expand Down

0 comments on commit ed3d0e1

Please sign in to comment.