More efficient default fill color

This commit is contained in:
ahocevar
2019-03-19 13:57:10 +01:00
parent 3f7c52c29f
commit b33ceaa400
3 changed files with 6 additions and 8 deletions
+2 -2
View File
@@ -85,9 +85,9 @@ export const defaultFont = '10px sans-serif';
/** /**
* @const * @const
* @type {import("../color.js").Color} * @type {import("../colorlike.js").ColorLike}
*/ */
export const defaultFillStyle = [0, 0, 0, 1]; export const defaultFillStyle = '#000';
/** /**
+3 -4
View File
@@ -1,7 +1,6 @@
/** /**
* @module ol/render/canvas/PolygonBuilder * @module ol/render/canvas/PolygonBuilder
*/ */
import {asString} from '../../color.js';
import {snap} from '../../geom/flat/simplify.js'; import {snap} from '../../geom/flat/simplify.js';
import {defaultFillStyle} from '../canvas.js'; import {defaultFillStyle} from '../canvas.js';
import CanvasInstruction, { import CanvasInstruction, {
@@ -77,7 +76,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
if (state.fillStyle !== undefined) { if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([ this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE, CanvasInstruction.SET_FILL_STYLE,
asString(defaultFillStyle) defaultFillStyle
]); ]);
} }
if (state.strokeStyle !== undefined) { if (state.strokeStyle !== undefined) {
@@ -121,7 +120,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
if (state.fillStyle !== undefined) { if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([ this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE, CanvasInstruction.SET_FILL_STYLE,
asString(defaultFillStyle) defaultFillStyle
]); ]);
} }
if (state.strokeStyle !== undefined) { if (state.strokeStyle !== undefined) {
@@ -153,7 +152,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
if (state.fillStyle !== undefined) { if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([ this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE, CanvasInstruction.SET_FILL_STYLE,
asString(defaultFillStyle) defaultFillStyle
]); ]);
} }
if (state.strokeStyle !== undefined) { if (state.strokeStyle !== undefined) {
+1 -2
View File
@@ -2,7 +2,6 @@
* @module ol/style/RegularShape * @module ol/style/RegularShape
*/ */
import {asString} from '../color.js';
import {asColorLike} from '../colorlike.js'; import {asColorLike} from '../colorlike.js';
import {createCanvasContext2D} from '../dom.js'; import {createCanvasContext2D} from '../dom.js';
import ImageState from '../ImageState.js'; import ImageState from '../ImageState.js';
@@ -482,7 +481,7 @@ class RegularShape extends ImageStyle {
} }
} }
context.fillStyle = asString(defaultFillStyle); context.fillStyle = defaultFillStyle;
context.fill(); context.fill();
if (this.stroke_) { if (this.stroke_) {
context.strokeStyle = renderOptions.strokeStyle; context.strokeStyle = renderOptions.strokeStyle;