mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-09 16:21:51 +00:00
Inline {enable,disable}ImageSmoothing usages
The method isn't as complex as it used to be, and is only used in two places. It is simpler to have it inlined instead.
This commit is contained in:
parent
36a3ae2da9
commit
2f23c0174d
@ -4,23 +4,6 @@ import { fastArrayDelete } from "./utils";
|
||||
|
||||
const logger = createLogger("buffer_utils");
|
||||
|
||||
/**
|
||||
* Enables images smoothing on a context
|
||||
* @param {CanvasRenderingContext2D} context
|
||||
*/
|
||||
export function enableImageSmoothing(context) {
|
||||
context.imageSmoothingEnabled = true;
|
||||
context.imageSmoothingQuality = globalConfig.smoothing.quality;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables image smoothing on a context
|
||||
* @param {CanvasRenderingContext2D} context
|
||||
*/
|
||||
export function disableImageSmoothing(context) {
|
||||
context.imageSmoothingEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* canvas: HTMLCanvasElement,
|
||||
@ -175,11 +158,8 @@ export function makeOffscreenBuffer(w, h, { smooth = true, reusable = true, labe
|
||||
// @ts-ignore
|
||||
canvas.label = label;
|
||||
|
||||
if (smooth) {
|
||||
enableImageSmoothing(context);
|
||||
} else {
|
||||
disableImageSmoothing(context);
|
||||
}
|
||||
context.imageSmoothingEnabled = smooth;
|
||||
context.imageSmoothingQuality = globalConfig.smoothing.quality;
|
||||
|
||||
if (reusable) {
|
||||
registerCanvas(canvas, context);
|
||||
|
||||
@ -2,12 +2,7 @@
|
||||
import { Application } from "../application";
|
||||
/* typehints:end */
|
||||
import { BufferMaintainer } from "../core/buffer_maintainer";
|
||||
import {
|
||||
disableImageSmoothing,
|
||||
enableImageSmoothing,
|
||||
getBufferStats,
|
||||
registerCanvas,
|
||||
} from "../core/buffer_utils";
|
||||
import { getBufferStats, registerCanvas } from "../core/buffer_utils";
|
||||
import { globalConfig } from "../core/config";
|
||||
import { getDeviceDPI, resizeHighDPICanvas } from "../core/dpi_manager";
|
||||
import { DrawParameters } from "../core/draw_parameters";
|
||||
@ -244,11 +239,8 @@ export class GameCore {
|
||||
// Oof, use :not() instead
|
||||
canvas.classList.toggle("unsmoothed", !globalConfig.smoothing.smoothMainCanvas);
|
||||
|
||||
if (globalConfig.smoothing.smoothMainCanvas) {
|
||||
enableImageSmoothing(context);
|
||||
} else {
|
||||
disableImageSmoothing(context);
|
||||
}
|
||||
context.imageSmoothingEnabled = globalConfig.smoothing.smoothMainCanvas;
|
||||
context.imageSmoothingQuality = globalConfig.smoothing.quality;
|
||||
|
||||
this.root.canvas = canvas;
|
||||
this.root.context = context;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user