From 3643f9ec98298c8aa8aa071844295f25fd3a7e55 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Thu, 30 Apr 2020 13:04:30 +0100 Subject: [PATCH 1/6] Use BrokenDiagonalRendering with contextOptions Apply the BrokenDiagonalRendering processing if opt_contextOptions is set to avoid color distortion along reprojection edges --- src/ol/reproj.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/reproj.js b/src/ol/reproj.js index 274f732ff3..6a511bf04d 100644 --- a/src/ol/reproj.js +++ b/src/ol/reproj.js @@ -1,7 +1,7 @@ /** * @module ol/reproj */ -import {assign} from './obj.js'; +import {assign, isEmpty} from './obj.js'; import { containsCoordinate, createEmpty, @@ -330,7 +330,7 @@ export function render( context.save(); context.beginPath(); - if (isBrokenDiagonalRendering()) { + if (isBrokenDiagonalRendering() || !isEmpty(opt_contextOptions)) { // Make sure that everything is on pixel boundaries const u0r = pixelRound(u0); const v0r = pixelRound(v0); From fc2fe25e696b0bca264d26f5869c47d7ec8476e2 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Thu, 30 Apr 2020 16:23:39 +0100 Subject: [PATCH 2/6] Use explicit test for smoothing disabled --- src/ol/reproj.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ol/reproj.js b/src/ol/reproj.js index 6a511bf04d..98e86d05fb 100644 --- a/src/ol/reproj.js +++ b/src/ol/reproj.js @@ -1,7 +1,8 @@ /** * @module ol/reproj */ -import {assign, isEmpty} from './obj.js'; +import {IMAGE_SMOOTHING_DISABLED} from './source/common.js'; +import {assign} from './obj.js'; import { containsCoordinate, createEmpty, @@ -330,7 +331,7 @@ export function render( context.save(); context.beginPath(); - if (isBrokenDiagonalRendering() || !isEmpty(opt_contextOptions)) { + if (isBrokenDiagonalRendering() || opt_contextOptions === IMAGE_SMOOTHING_DISABLED) { // Make sure that everything is on pixel boundaries const u0r = pixelRound(u0); const v0r = pixelRound(v0); From c515183baded71655acd540ce528e933a4cd65dc Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Thu, 30 Apr 2020 16:27:43 +0100 Subject: [PATCH 3/6] Use explicit test for image smoothing disabled fix prettier --- src/ol/reproj.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ol/reproj.js b/src/ol/reproj.js index 98e86d05fb..da0b2b56d0 100644 --- a/src/ol/reproj.js +++ b/src/ol/reproj.js @@ -331,7 +331,10 @@ export function render( context.save(); context.beginPath(); - if (isBrokenDiagonalRendering() || opt_contextOptions === IMAGE_SMOOTHING_DISABLED) { + if ( + isBrokenDiagonalRendering() || + opt_contextOptions === IMAGE_SMOOTHING_DISABLED + ) { // Make sure that everything is on pixel boundaries const u0r = pixelRound(u0); const v0r = pixelRound(v0); From 3c1e00a3ec1303a5ab6d4fc9e7d52e324e357c1a Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Thu, 30 Apr 2020 16:49:05 +0100 Subject: [PATCH 4/6] Define browser specific IMAGE_SMOOTHING_DISABLED Avoid msImageSmoothingEnabled if the browser does not need it --- src/ol/source/common.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ol/source/common.js b/src/ol/source/common.js index 4176e1a1a2..eab85a456b 100644 --- a/src/ol/source/common.js +++ b/src/ol/source/common.js @@ -1,6 +1,7 @@ /** * @module ol/source/common */ +import {FIREFOX, SAFARI, WEBKIT} from '../has.js'; /** * Default WMS version. @@ -12,7 +13,9 @@ export const DEFAULT_WMS_VERSION = '1.3.0'; * Context options to disable image smoothing. * @type {Object} */ -export const IMAGE_SMOOTHING_DISABLED = { - imageSmoothingEnabled: false, - msImageSmoothingEnabled: false, -}; +export const IMAGE_SMOOTHING_DISABLED = FIREFOX || SAFARI || WEBKIT + ? {imageSmoothingEnabled: false} + : { + imageSmoothingEnabled: false, + msImageSmoothingEnabled: false, + }; From 48e938e2356f6438e5038f6894baca507222bccd Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Thu, 30 Apr 2020 16:56:02 +0100 Subject: [PATCH 5/6] Define browser specific IMAGE_SMOOTHING_DISABLED fix prettier --- src/ol/source/common.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ol/source/common.js b/src/ol/source/common.js index eab85a456b..80198b821f 100644 --- a/src/ol/source/common.js +++ b/src/ol/source/common.js @@ -13,9 +13,10 @@ export const DEFAULT_WMS_VERSION = '1.3.0'; * Context options to disable image smoothing. * @type {Object} */ -export const IMAGE_SMOOTHING_DISABLED = FIREFOX || SAFARI || WEBKIT - ? {imageSmoothingEnabled: false} - : { - imageSmoothingEnabled: false, - msImageSmoothingEnabled: false, - }; +export const IMAGE_SMOOTHING_DISABLED = + FIREFOX || SAFARI || WEBKIT + ? {imageSmoothingEnabled: false} + : { + imageSmoothingEnabled: false, + msImageSmoothingEnabled: false, + }; From bf77f596569f8f84112741cb389915fd9290e332 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Thu, 30 Apr 2020 21:33:00 +0100 Subject: [PATCH 6/6] revert change to IMAGE_SMOOTHING_DISABLED --- src/ol/source/common.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ol/source/common.js b/src/ol/source/common.js index 80198b821f..4176e1a1a2 100644 --- a/src/ol/source/common.js +++ b/src/ol/source/common.js @@ -1,7 +1,6 @@ /** * @module ol/source/common */ -import {FIREFOX, SAFARI, WEBKIT} from '../has.js'; /** * Default WMS version. @@ -13,10 +12,7 @@ export const DEFAULT_WMS_VERSION = '1.3.0'; * Context options to disable image smoothing. * @type {Object} */ -export const IMAGE_SMOOTHING_DISABLED = - FIREFOX || SAFARI || WEBKIT - ? {imageSmoothingEnabled: false} - : { - imageSmoothingEnabled: false, - msImageSmoothingEnabled: false, - }; +export const IMAGE_SMOOTHING_DISABLED = { + imageSmoothingEnabled: false, + msImageSmoothingEnabled: false, +};