From 943992debccc8afc381538772993e6e055a4f30e Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Wed, 15 Feb 2017 17:23:20 +0100 Subject: [PATCH] Ship directly grayscale minimap font --- .../browser/viewParts/minimap/minimap.ts | 4 +- .../editor/common/view/minimapCharRenderer.ts | 27 +- .../common/view/runtimeMinimapCharRenderer.ts | 1146 ++++++++--------- .../test/browser/view/minimapFontCreator.ts | 8 +- .../common/view/minimapCharRenderer.test.ts | 6 +- .../common/view/minimapCharRendererFactory.ts | 32 +- 6 files changed, 603 insertions(+), 620 deletions(-) diff --git a/src/vs/editor/browser/viewParts/minimap/minimap.ts b/src/vs/editor/browser/viewParts/minimap/minimap.ts index 50611342e27..1065fb2a7ea 100644 --- a/src/vs/editor/browser/viewParts/minimap/minimap.ts +++ b/src/vs/editor/browser/viewParts/minimap/minimap.ts @@ -9,7 +9,7 @@ import 'vs/css!./minimap'; import { ViewPart } from 'vs/editor/browser/view/viewPart'; import { ViewContext } from 'vs/editor/common/view/viewContext'; import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common/view/renderingContext'; -import { createMinimapCharRenderer2 } from 'vs/editor/common/view/runtimeMinimapCharRenderer'; +import { createMinimapCharRenderer } from 'vs/editor/common/view/runtimeMinimapCharRenderer'; import * as browser from 'vs/base/browser/browser'; import { ParsedColor, MinimapTokensColorTracker, Constants } from 'vs/editor/common/view/minimapCharRenderer'; import * as editorCommon from 'vs/editor/common/editorCommon'; @@ -20,7 +20,7 @@ import { FastDomNode, createFastDomNode } from 'vs/base/browser/styleMutator'; import { IDisposable } from 'vs/base/common/lifecycle'; import { EditorScrollbar } from 'vs/editor/browser/viewParts/editorScrollbar/editorScrollbar'; -let charRenderer2 = createMinimapCharRenderer2(); // TODO@minimap +let charRenderer2 = createMinimapCharRenderer(); // TODO@minimap const enum RenderMinimap { None = 0, diff --git a/src/vs/editor/common/view/minimapCharRenderer.ts b/src/vs/editor/common/view/minimapCharRenderer.ts index 795b3aaaf36..fb56233ba0f 100644 --- a/src/vs/editor/common/view/minimapCharRenderer.ts +++ b/src/vs/editor/common/view/minimapCharRenderer.ts @@ -138,33 +138,12 @@ export const enum Constants { x1_CHAR_WIDTH = 1, RGBA_CHANNELS_CNT = 4, - CA_CHANNELS_CNT = 2, } -export class MinimapCharRenderer2 { +export class MinimapCharRenderer { _minimapCharRendererBrand: void; - public static create(x2CharData: Uint8ClampedArray, x1CharData: Uint8ClampedArray): MinimapCharRenderer2 { - let _x2CharData = this.toGrayscale(x2CharData); - let _x1CharData = this.toGrayscale(x1CharData); - return new MinimapCharRenderer2(_x2CharData, _x1CharData); - } - - private static toGrayscale(charData: Uint8ClampedArray): Uint8ClampedArray { - let newLength = charData.length / 2; - let result = new Uint8ClampedArray(newLength); - let sourceOffset = 0; - for (var i = 0; i < newLength; i++) { - let color = charData[sourceOffset]; - let alpha = charData[sourceOffset + 1]; - let newColor = Math.round((color * alpha) / 255); - result[i] = newColor; - sourceOffset += 2; - } - return result; - } - public readonly x2charData: Uint8ClampedArray; public readonly x1charData: Uint8ClampedArray; @@ -194,7 +173,7 @@ export class MinimapCharRenderer2 { return; } const x2CharData = this.x2charData; - const chIndex = MinimapCharRenderer2._getChIndex(chCode); + const chIndex = MinimapCharRenderer._getChIndex(chCode); const outWidth = target.width * Constants.RGBA_CHANNELS_CNT; @@ -271,7 +250,7 @@ export class MinimapCharRenderer2 { return; } const x1CharData = this.x1charData; - const chIndex = MinimapCharRenderer2._getChIndex(chCode); + const chIndex = MinimapCharRenderer._getChIndex(chCode); const outWidth = target.width * Constants.RGBA_CHANNELS_CNT; diff --git a/src/vs/editor/common/view/runtimeMinimapCharRenderer.ts b/src/vs/editor/common/view/runtimeMinimapCharRenderer.ts index 9b68ac75a12..3496f047c0e 100644 --- a/src/vs/editor/common/view/runtimeMinimapCharRenderer.ts +++ b/src/vs/editor/common/view/runtimeMinimapCharRenderer.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { MinimapCharRenderer2 } from 'vs/editor/common/view/minimapCharRenderer'; +import { MinimapCharRenderer } from 'vs/editor/common/view/minimapCharRenderer'; function toUint8ClampedArrat(arr: number[]): Uint8ClampedArray { let r = new Uint8ClampedArray(arr.length); @@ -27,965 +27,965 @@ function init(): void { x2Data = null; } -export function createMinimapCharRenderer2(): MinimapCharRenderer2 { +export function createMinimapCharRenderer(): MinimapCharRenderer { init(); - return MinimapCharRenderer2.create(_x2Data, _x1Data); + return new MinimapCharRenderer(_x2Data, _x1Data); } var x2Data = [ // - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, + 0, 0, + 0, 0, + 0, 0, + 0, 0, // ! - 128, 78, 64, 55, - 128, 77, 64, 54, - 85, 43, 42, 29, - 128, 58, 64, 41, + 39, 14, + 39, 14, + 14, 5, + 29, 10, // " - 191, 128, 191, 128, - 128, 57, 128, 57, - 0, 0, 0, 0, - 0, 0, 0, 0, + 96, 96, + 29, 29, + 0, 0, + 0, 0, // # - 128, 98, 234, 123, - 255, 195, 255, 214, - 255, 227, 234, 181, - 255, 135, 128, 84, + 49, 113, + 195, 214, + 227, 166, + 135, 42, // $ - 128, 79, 106, 70, - 255, 194, 128, 76, - 170, 113, 234, 161, - 255, 197, 255, 187, + 40, 29, + 194, 38, + 75, 148, + 197, 187, // % - 255, 145, 21, 2, - 255, 160, 212, 73, - 234, 82, 255, 143, - 42, 13, 255, 183, + 145, 0, + 160, 61, + 75, 143, + 2, 183, // & - 234, 150, 170, 87, - 234, 178, 106, 14, - 255, 177, 255, 223, - 255, 197, 255, 227, + 138, 58, + 163, 6, + 177, 223, + 197, 227, // ' - 128, 76, 64, 52, - 85, 34, 42, 23, - 0, 0, 0, 0, - 0, 0, 0, 0, + 38, 13, + 11, 4, + 0, 0, + 0, 0, // ( - 85, 30, 149, 93, - 128, 103, 64, 33, - 128, 124, 64, 15, - 170, 106, 255, 122, + 10, 54, + 52, 8, + 62, 4, + 71, 122, // ) - 170, 109, 42, 15, - 85, 56, 128, 80, - 64, 39, 128, 100, - 255, 155, 128, 72, + 73, 2, + 19, 40, + 10, 50, + 155, 36, // * - 170, 119, 191, 93, - 234, 158, 234, 132, - 64, 29, 85, 16, - 0, 0, 0, 0, + 79, 70, + 145, 121, + 7, 5, + 0, 0, // + - 42, 15, 21, 10, - 128, 71, 64, 48, - 255, 204, 234, 181, - 85, 47, 42, 32, + 2, 1, + 36, 12, + 204, 166, + 16, 5, // , - 0, 0, 0, 0, - 0, 0, 0, 0, - 42, 4, 42, 3, - 234, 168, 128, 67, + 0, 0, + 0, 0, + 1, 0, + 154, 34, // - - 0, 0, 0, 0, - 0, 0, 0, 0, - 191, 128, 191, 111, - 0, 0, 0, 0, + 0, 0, + 0, 0, + 96, 83, + 0, 0, // . - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 128, 91, 128, 68, + 0, 0, + 0, 0, + 0, 0, + 46, 34, // / - 0, 0, 191, 110, - 42, 14, 149, 95, - 149, 91, 42, 19, - 255, 146, 0, 0, + 0, 82, + 2, 56, + 53, 3, + 146, 0, // 0 - 234, 159, 212, 143, - 234, 166, 212, 159, - 234, 166, 212, 158, - 234, 158, 212, 143, + 146, 119, + 152, 132, + 152, 131, + 145, 119, // 1 - 255, 170, 128, 83, - 64, 61, 128, 83, - 64, 61, 128, 83, - 255, 172, 255, 194, + 170, 42, + 15, 42, + 15, 42, + 172, 194, // 2 - 212, 157, 234, 144, - 21, 2, 234, 152, - 191, 107, 128, 56, - 255, 227, 255, 143, + 131, 132, + 0, 139, + 80, 28, + 227, 143, // 3 - 255, 159, 234, 147, - 85, 44, 212, 142, - 64, 42, 212, 151, - 255, 171, 234, 157, + 159, 135, + 15, 118, + 11, 126, + 171, 144, // 4 - 106, 49, 191, 166, - 191, 117, 191, 142, - 255, 217, 234, 214, - 0, 0, 191, 142, + 20, 124, + 88, 106, + 217, 196, + 0, 106, // 5 - 255, 189, 191, 123, - 234, 183, 128, 86, - 85, 14, 212, 156, - 255, 164, 234, 145, + 189, 92, + 168, 43, + 5, 130, + 164, 133, // 6 - 234, 142, 234, 125, - 234, 199, 149, 112, - 212, 161, 212, 144, - 234, 154, 234, 154, + 130, 115, + 183, 65, + 134, 120, + 141, 141, // 7 - 255, 170, 255, 196, - 42, 10, 191, 141, - 106, 74, 106, 76, - 191, 140, 42, 11, + 170, 196, + 2, 106, + 31, 32, + 105, 2, // 8 - 234, 158, 234, 142, - 212, 140, 212, 137, - 212, 159, 234, 147, - 212, 166, 234, 153, + 145, 130, + 116, 114, + 132, 135, + 138, 140, // 9 - 212, 166, 212, 136, - 255, 147, 212, 165, - 170, 122, 255, 183, - 234, 141, 191, 126, + 138, 113, + 147, 137, + 81, 183, + 129, 94, // : - 0, 0, 0, 0, - 85, 63, 85, 47, - 42, 27, 42, 20, - 128, 91, 128, 68, + 0, 0, + 21, 16, + 4, 3, + 46, 34, // ; - 0, 0, 0, 0, - 128, 90, 128, 68, - 42, 4, 42, 3, - 234, 174, 170, 73, + 0, 0, + 45, 34, + 1, 0, + 160, 49, // < - 0, 0, 21, 1, - 149, 74, 234, 156, - 255, 203, 128, 45, - 42, 9, 170, 114, + 0, 0, + 43, 143, + 203, 23, + 1, 76, // = - 0, 0, 0, 0, - 106, 92, 85, 84, - 212, 157, 170, 144, - 106, 92, 85, 84, + 0, 0, + 38, 28, + 131, 96, + 38, 28, // > - 42, 1, 0, 0, - 255, 168, 128, 62, - 128, 57, 255, 191, - 212, 118, 21, 5, + 0, 0, + 168, 31, + 29, 191, + 98, 0, // ? - 234, 129, 234, 151, - 64, 18, 212, 136, - 128, 89, 85, 40, - 128, 74, 64, 25, + 118, 139, + 5, 113, + 45, 13, + 37, 6, // @ - 212, 117, 234, 125, - 255, 161, 255, 179, - 255, 204, 234, 114, - 255, 223, 255, 224, + 97, 115, + 161, 179, + 204, 105, + 223, 224, // A - 170, 124, 128, 104, - 212, 133, 191, 134, - 234, 200, 255, 186, - 212, 144, 234, 144, + 83, 52, + 111, 100, + 184, 186, + 120, 132, // B - 255, 212, 234, 158, - 255, 180, 234, 151, - 255, 174, 255, 161, - 255, 212, 255, 182, + 212, 145, + 180, 139, + 174, 161, + 212, 182, // C - 191, 139, 255, 162, - 212, 158, 21, 0, - 212, 158, 21, 0, - 191, 139, 255, 161, + 104, 162, + 131, 0, + 131, 0, + 104, 161, // D - 255, 219, 212, 144, - 191, 147, 191, 155, - 191, 147, 191, 155, - 255, 219, 212, 144, + 219, 120, + 110, 116, + 110, 116, + 219, 120, // E - 255, 207, 255, 154, - 234, 178, 149, 68, - 212, 177, 85, 66, - 255, 207, 255, 154, + 207, 154, + 163, 40, + 147, 22, + 207, 154, // F - 255, 202, 255, 159, - 234, 175, 170, 71, - 212, 175, 85, 69, - 191, 148, 0, 0, + 202, 159, + 161, 47, + 145, 23, + 111, 0, // G - 234, 151, 255, 154, - 234, 157, 106, 73, - 234, 157, 212, 162, - 234, 151, 255, 187, + 139, 154, + 144, 30, + 144, 135, + 139, 187, // H - 191, 147, 191, 147, - 234, 183, 234, 175, - 212, 181, 212, 174, - 191, 147, 191, 147, + 110, 110, + 168, 161, + 150, 145, + 110, 110, // I - 255, 185, 255, 162, - 128, 85, 64, 62, - 128, 85, 64, 62, - 255, 185, 255, 162, + 185, 162, + 43, 16, + 43, 16, + 185, 162, // J - 191, 97, 191, 172, - 0, 0, 191, 147, - 42, 3, 191, 147, - 255, 191, 170, 131, + 73, 129, + 0, 110, + 0, 110, + 191, 87, // K - 255, 149, 234, 162, - 255, 236, 149, 82, - 255, 195, 170, 137, - 255, 146, 234, 162, + 149, 149, + 236, 48, + 195, 91, + 146, 149, // L - 255, 146, 0, 0, - 255, 146, 0, 0, - 255, 146, 0, 0, - 255, 187, 255, 173, + 146, 0, + 146, 0, + 146, 0, + 187, 173, // M - 255, 200, 255, 201, - 255, 222, 255, 215, - 255, 172, 234, 160, - 191, 127, 191, 127, + 200, 201, + 222, 215, + 172, 147, + 95, 95, // N - 255, 193, 191, 130, - 255, 224, 234, 141, - 255, 159, 255, 206, - 191, 130, 255, 192, + 193, 97, + 224, 129, + 159, 206, + 97, 192, // O - 234, 169, 234, 152, - 255, 153, 191, 153, - 255, 153, 191, 153, - 234, 170, 234, 153, + 155, 139, + 153, 115, + 153, 115, + 156, 140, // P - 234, 206, 234, 172, - 212, 148, 212, 163, - 234, 207, 149, 110, - 191, 148, 0, 0, + 189, 158, + 123, 136, + 190, 64, + 111, 0, // Q - 234, 169, 234, 152, - 255, 153, 191, 153, - 255, 153, 191, 152, - 234, 170, 255, 241, + 155, 139, + 153, 115, + 153, 114, + 156, 241, // R - 234, 215, 234, 161, - 212, 180, 234, 166, - 234, 185, 212, 139, - 191, 147, 255, 157, + 197, 148, + 150, 152, + 170, 116, + 110, 157, // S - 234, 170, 255, 128, - 234, 184, 85, 41, - 106, 31, 234, 173, - 234, 172, 234, 162, + 156, 128, + 169, 14, + 13, 159, + 158, 149, // T - 255, 212, 255, 189, - 128, 85, 64, 62, - 128, 85, 64, 62, - 128, 85, 64, 62, + 212, 189, + 43, 16, + 43, 16, + 43, 16, // U - 255, 148, 191, 147, - 255, 148, 191, 147, - 255, 147, 191, 146, - 255, 182, 234, 165, + 148, 110, + 148, 110, + 147, 109, + 182, 151, // V - 234, 145, 212, 146, - 191, 141, 212, 142, - 212, 137, 191, 138, - 170, 133, 149, 113, + 133, 121, + 106, 118, + 114, 103, + 89, 66, // W - 191, 126, 191, 126, - 255, 211, 255, 188, - 255, 205, 255, 207, - 212, 167, 255, 168, + 94, 94, + 211, 188, + 205, 207, + 139, 168, // X - 255, 151, 255, 152, - 170, 131, 170, 114, - 191, 135, 170, 119, - 255, 151, 255, 152, + 151, 152, + 87, 76, + 101, 79, + 151, 152, // Y - 212, 156, 255, 156, - 212, 150, 212, 139, - 128, 93, 106, 70, - 128, 85, 64, 62, + 130, 156, + 125, 116, + 47, 29, + 43, 16, // Z - 255, 169, 255, 228, - 85, 34, 191, 138, - 212, 144, 64, 24, - 255, 230, 255, 176, + 169, 228, + 11, 103, + 120, 6, + 230, 176, // [ - 128, 109, 149, 84, - 128, 109, 64, 24, - 128, 109, 64, 24, - 255, 193, 255, 102, + 55, 49, + 55, 6, + 55, 6, + 193, 102, // \ - 212, 111, 0, 0, - 170, 106, 21, 4, - 85, 38, 106, 73, - 0, 0, 255, 147, + 92, 0, + 71, 0, + 13, 30, + 0, 147, // ] - 149, 107, 128, 86, - 64, 47, 128, 86, - 64, 47, 128, 86, - 255, 142, 255, 152, + 63, 43, + 12, 43, + 12, 43, + 142, 152, // ^ - 170, 107, 149, 91, - 170, 91, 170, 92, - 0, 0, 0, 0, - 0, 0, 0, 0, + 71, 53, + 61, 61, + 0, 0, + 0, 0, // _ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 255, 158, 255, 146, + 0, 0, + 0, 0, + 0, 0, + 158, 146, // ` - 106, 61, 42, 14, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, + 25, 2, + 0, 0, + 0, 0, + 0, 0, // a - 0, 0, 0, 0, - 212, 129, 212, 156, - 255, 170, 255, 194, - 255, 176, 255, 188, + 0, 0, + 107, 130, + 170, 194, + 176, 188, // b - 191, 146, 0, 0, - 255, 203, 234, 173, - 191, 151, 191, 148, - 255, 202, 234, 172, + 109, 0, + 203, 159, + 113, 111, + 202, 158, // c - 0, 0, 0, 0, - 234, 147, 255, 135, - 191, 152, 0, 0, - 234, 148, 255, 135, + 0, 0, + 135, 135, + 114, 0, + 136, 135, // d - 0, 0, 191, 146, - 255, 187, 255, 190, - 255, 148, 212, 151, - 255, 177, 255, 187, + 0, 109, + 187, 190, + 148, 126, + 177, 187, // e - 0, 0, 0, 0, - 234, 162, 212, 156, - 255, 218, 170, 158, - 255, 169, 234, 147, + 0, 0, + 149, 130, + 218, 105, + 169, 135, // f - 128, 74, 191, 151, - 212, 176, 191, 151, - 128, 97, 64, 50, - 128, 97, 64, 50, + 37, 113, + 146, 113, + 49, 13, + 49, 13, // g - 0, 0, 0, 0, - 255, 178, 255, 195, - 255, 147, 191, 152, - 255, 255, 255, 255, + 0, 0, + 178, 195, + 147, 114, + 255, 255, // h - 191, 146, 0, 0, - 255, 193, 234, 162, - 191, 147, 191, 146, - 191, 146, 191, 146, + 109, 0, + 193, 149, + 110, 109, + 109, 109, // i - 85, 37, 85, 45, - 212, 150, 128, 81, - 128, 66, 128, 81, - 212, 173, 255, 188, + 12, 15, + 125, 41, + 33, 41, + 144, 188, // j - 21, 14, 42, 35, - 149, 128, 128, 105, - 64, 41, 128, 105, - 255, 210, 234, 175, + 1, 6, + 75, 53, + 10, 53, + 210, 161, // k - 191, 147, 0, 0, - 234, 166, 255, 148, - 255, 210, 149, 102, - 191, 147, 255, 156, + 110, 0, + 152, 148, + 210, 60, + 110, 156, // l - 255, 213, 64, 20, - 128, 126, 64, 20, - 128, 126, 64, 20, - 128, 90, 191, 148, + 213, 5, + 63, 5, + 63, 5, + 45, 111, // m - 0, 0, 0, 0, - 255, 232, 234, 187, - 255, 190, 255, 168, - 255, 190, 255, 169, + 0, 0, + 232, 172, + 190, 168, + 190, 169, // n - 0, 0, 0, 0, - 255, 190, 234, 157, - 191, 146, 191, 146, - 191, 146, 191, 146, + 0, 0, + 190, 144, + 109, 109, + 109, 109, // o - 0, 0, 0, 0, - 255, 168, 234, 153, - 255, 148, 191, 148, - 255, 168, 234, 153, + 0, 0, + 168, 140, + 148, 111, + 168, 140, // p - 0, 0, 0, 0, - 255, 200, 234, 165, - 191, 151, 191, 147, - 255, 255, 234, 172, + 0, 0, + 200, 151, + 113, 110, + 255, 158, // q - 0, 0, 0, 0, - 255, 184, 255, 188, - 255, 147, 234, 151, - 255, 186, 255, 255, + 0, 0, + 184, 188, + 147, 139, + 186, 255, // r - 0, 0, 0, 0, - 191, 163, 212, 156, - 191, 148, 0, 0, - 191, 146, 0, 0, + 0, 0, + 122, 130, + 111, 0, + 109, 0, // s - 0, 0, 0, 0, - 212, 159, 170, 103, - 212, 131, 191, 124, - 212, 132, 234, 148, + 0, 0, + 132, 69, + 109, 93, + 110, 136, // t - 128, 101, 64, 21, - 255, 205, 191, 138, - 128, 121, 64, 25, - 128, 93, 191, 141, + 51, 5, + 205, 103, + 61, 6, + 47, 106, // u - 0, 0, 0, 0, - 191, 147, 191, 146, - 191, 147, 212, 147, - 234, 169, 255, 179, + 0, 0, + 110, 109, + 110, 122, + 155, 179, // v - 0, 0, 0, 0, - 234, 144, 212, 144, - 212, 136, 212, 137, - 170, 126, 149, 108, + 0, 0, + 132, 120, + 113, 114, + 84, 63, // w - 0, 0, 0, 0, - 234, 135, 212, 130, - 255, 202, 255, 189, - 234, 174, 255, 174, + 0, 0, + 124, 108, + 202, 189, + 160, 174, // x - 0, 0, 0, 0, - 234, 157, 234, 155, - 170, 118, 149, 97, - 255, 159, 234, 159, + 0, 0, + 144, 142, + 79, 57, + 159, 146, // y - 0, 0, 0, 0, - 234, 150, 234, 150, - 212, 143, 212, 141, - 255, 255, 170, 103, + 0, 0, + 138, 138, + 119, 117, + 255, 69, // z - 0, 0, 0, 0, - 191, 130, 255, 198, - 128, 93, 128, 75, - 255, 208, 170, 126, + 0, 0, + 97, 198, + 47, 38, + 208, 84, // { - 106, 56, 212, 135, - 128, 81, 64, 56, - 234, 171, 64, 28, - 234, 132, 255, 192, + 23, 112, + 41, 14, + 157, 7, + 121, 192, // | - 128, 69, 64, 45, - 128, 69, 64, 45, - 128, 69, 64, 45, - 255, 160, 149, 105, + 35, 11, + 35, 11, + 35, 11, + 160, 61, // } - 212, 155, 64, 35, - 128, 79, 85, 57, - 106, 48, 234, 151, - 255, 236, 128, 88, + 129, 9, + 40, 19, + 20, 139, + 236, 44, // ~ - 0, 0, 0, 0, - 85, 45, 64, 10, - 212, 117, 170, 139, - 0, 0, 0, 0, + 0, 0, + 15, 3, + 97, 93, + 0, 0, ]; var x1Data = [ // - 0, 0, - 0, 0, + 0, + 0, // ! - 92, 63, - 76, 41, + 23, + 12, // " - 153, 89, - 0, 0, + 53, + 0, // # - 219, 151, - 214, 151, + 130, + 127, // $ - 148, 100, - 240, 158, + 58, + 149, // % - 189, 91, - 194, 101, + 67, + 77, // & - 178, 103, - 255, 198, + 72, + 198, // ' - 76, 44, - 0, 0, + 13, + 0, // ( - 102, 62, - 148, 88, + 25, + 51, // ) - 102, 62, - 143, 88, + 25, + 49, // * - 199, 120, - 36, 11, + 94, + 2, // + - 61, 34, - 148, 111, + 8, + 64, // , - 0, 0, - 107, 58, + 0, + 24, // - - 0, 0, - 92, 57, + 0, + 21, // . - 0, 0, - 61, 38, + 0, + 9, // / - 92, 53, - 112, 61, + 19, + 27, // 0 - 214, 150, - 214, 150, + 126, + 126, // 1 - 138, 95, - 168, 122, + 51, + 80, // 2 - 168, 109, - 209, 128, + 72, + 105, // 3 - 189, 118, - 199, 125, + 87, + 98, // 4 - 163, 114, - 173, 137, + 73, + 93, // 5 - 194, 139, - 189, 115, + 106, + 85, // 6 - 204, 139, - 214, 147, + 111, + 123, // 7 - 178, 124, - 107, 72, + 87, + 30, // 8 - 214, 138, - 214, 150, + 116, + 126, // 9 - 214, 147, - 204, 137, + 123, + 110, // : - 41, 26, - 82, 49, + 4, + 16, // ; - 61, 38, - 117, 61, + 9, + 28, // < - 97, 55, - 153, 89, + 21, + 53, // = - 46, 42, - 138, 114, + 8, + 62, // > - 107, 55, - 148, 89, + 23, + 52, // ? - 178, 104, - 97, 55, + 73, + 21, // @ - 240, 140, - 255, 183, + 132, + 183, // A - 168, 119, - 224, 162, + 78, + 142, // B - 255, 168, - 255, 175, + 168, + 175, // C - 163, 110, - 163, 110, + 70, + 70, // D - 204, 160, - 204, 160, + 128, + 128, // E - 214, 146, - 194, 145, + 123, + 110, // F - 219, 146, - 117, 94, + 125, + 43, // G - 199, 128, - 224, 158, + 100, + 139, // H - 204, 156, - 194, 156, + 125, + 119, // I - 168, 119, - 168, 119, + 78, + 78, // J - 138, 100, - 173, 113, + 54, + 77, // K - 235, 151, - 230, 154, + 139, + 139, // L - 122, 70, - 184, 121, + 33, + 87, // M - 255, 201, - 214, 140, + 201, + 117, // N - 250, 165, - 230, 165, + 162, + 149, // O - 219, 151, - 219, 151, + 130, + 130, // P - 214, 165, - 138, 111, + 138, + 60, // Q - 219, 151, - 255, 172, + 130, + 172, // R - 219, 173, - 214, 151, + 149, + 127, // S - 194, 125, - 194, 129, + 95, + 98, // T - 184, 131, - 92, 70, + 95, + 25, // U - 214, 141, - 224, 154, + 118, + 135, // V - 204, 138, - 173, 125, + 110, + 85, // W - 240, 156, - 250, 179, + 147, + 175, // X - 204, 131, - 209, 134, + 105, + 110, // Y - 214, 144, - 102, 75, + 121, + 30, // Z - 189, 136, - 209, 138, + 101, + 113, // [ - 112, 78, - 168, 103, + 34, + 68, // \ - 97, 53, - 107, 62, + 20, + 26, // ] - 112, 78, - 168, 103, + 34, + 68, // ^ - 158, 91, - 0, 0, + 56, + 0, // _ - 0, 0, - 153, 73, + 0, + 44, // ` - 36, 18, - 0, 0, + 3, + 0, // a - 102, 68, - 255, 175, + 27, + 175, // b - 163, 125, - 209, 162, + 80, + 133, // c - 117, 68, - 163, 104, + 31, + 66, // d - 173, 125, - 235, 159, + 85, + 147, // e - 107, 76, - 230, 166, + 32, + 150, // f - 173, 133, - 92, 70, + 90, + 25, // g - 128, 90, - 255, 230, + 45, + 230, // h - 163, 120, - 184, 140, + 77, + 101, // i - 122, 75, - 173, 122, + 36, + 83, // j - 82, 68, - 168, 127, + 22, + 84, // k - 163, 111, - 204, 148, + 71, + 118, // l - 122, 91, - 122, 92, + 44, + 44, // m - 133, 100, - 255, 172, + 52, + 172, // n - 117, 83, - 184, 140, + 38, + 101, // o - 117, 77, - 224, 148, + 35, + 130, // p - 117, 88, - 255, 197, + 40, + 197, // q - 122, 89, - 255, 197, + 43, + 197, // r - 97, 76, - 92, 71, + 29, + 26, // s - 92, 63, - 204, 129, + 23, + 103, // t - 153, 111, - 122, 91, + 67, + 44, // u - 92, 70, - 214, 154, + 25, + 129, // v - 107, 69, - 178, 122, + 29, + 85, // w - 107, 64, - 255, 177, + 27, + 177, // x - 112, 75, - 194, 128, + 33, + 97, // y - 112, 72, - 230, 161, + 32, + 145, // z - 107, 79, - 163, 121, + 33, + 77, // { - 122, 79, - 194, 126, + 38, + 96, // | - 92, 55, - 153, 91, + 20, + 55, // } - 117, 78, - 194, 125, + 36, + 95, // ~ - 36, 13, - 92, 61, + 2, + 22, ]; diff --git a/src/vs/editor/test/browser/view/minimapFontCreator.ts b/src/vs/editor/test/browser/view/minimapFontCreator.ts index 8be6afeed88..d6300573570 100644 --- a/src/vs/editor/test/browser/view/minimapFontCreator.ts +++ b/src/vs/editor/test/browser/view/minimapFontCreator.ts @@ -4,9 +4,9 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { Constants, MinimapCharRenderer2, ParsedColor } from 'vs/editor/common/view/minimapCharRenderer'; +import { Constants, MinimapCharRenderer, ParsedColor } from 'vs/editor/common/view/minimapCharRenderer'; import { MinimapCharRendererFactory } from 'vs/editor/test/common/view/minimapCharRendererFactory'; -import { createMinimapCharRenderer2 } from 'vs/editor/common/view/runtimeMinimapCharRenderer'; +import { createMinimapCharRenderer } from 'vs/editor/common/view/runtimeMinimapCharRenderer'; let canvas = document.getElementById('my-canvas'); let ctx = canvas.getContext('2d'); @@ -28,7 +28,7 @@ let minimapCharRenderer = MinimapCharRendererFactory.create(sampleData.data); renderImageData(sampleData, 10, 100); renderMinimapCharRenderer(minimapCharRenderer, 400); -renderMinimapCharRenderer(createMinimapCharRenderer2(), 600); +renderMinimapCharRenderer(createMinimapCharRenderer(), 600); function createFakeImageData(width: number, height: number): ImageData { return { @@ -38,7 +38,7 @@ function createFakeImageData(width: number, height: number): ImageData { }; } -function renderMinimapCharRenderer(minimapCharRenderer: MinimapCharRenderer2, y: number): void { +function renderMinimapCharRenderer(minimapCharRenderer: MinimapCharRenderer, y: number): void { let background = new ParsedColor(0, 0, 0); let color = new ParsedColor(255, 255, 255); diff --git a/src/vs/editor/test/common/view/minimapCharRenderer.test.ts b/src/vs/editor/test/common/view/minimapCharRenderer.test.ts index fb796d9beaa..3340bad6afb 100644 --- a/src/vs/editor/test/common/view/minimapCharRenderer.test.ts +++ b/src/vs/editor/test/common/view/minimapCharRenderer.test.ts @@ -7,7 +7,7 @@ import * as assert from 'assert'; import { MinimapTokensColorTracker, ParsedColor, Constants } from 'vs/editor/common/view/minimapCharRenderer'; import { MinimapCharRendererFactory } from 'vs/editor/test/common/view/minimapCharRendererFactory'; -import { createMinimapCharRenderer2 } from 'vs/editor/common/view/runtimeMinimapCharRenderer'; +import { createMinimapCharRenderer } from 'vs/editor/common/view/runtimeMinimapCharRenderer'; suite('MinimapColors', () => { @@ -137,7 +137,7 @@ suite('MinimapCharRenderer', () => { }); test('letter d @ 2x at runtime', () => { - let renderer = createMinimapCharRenderer2(); + let renderer = createMinimapCharRenderer(); let background = new ParsedColor(0, 0, 0); let color = new ParsedColor(255, 255, 255); @@ -192,7 +192,7 @@ suite('MinimapCharRenderer', () => { }); test('letter d @ 1x at runtime', () => { - let renderer = createMinimapCharRenderer2(); + let renderer = createMinimapCharRenderer(); let background = new ParsedColor(0, 0, 0); let color = new ParsedColor(255, 255, 255); diff --git a/src/vs/editor/test/common/view/minimapCharRendererFactory.ts b/src/vs/editor/test/common/view/minimapCharRendererFactory.ts index 4289fa75d3d..83cf1b63167 100644 --- a/src/vs/editor/test/common/view/minimapCharRendererFactory.ts +++ b/src/vs/editor/test/common/view/minimapCharRendererFactory.ts @@ -4,11 +4,15 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { Constants, MinimapCharRenderer2 } from 'vs/editor/common/view/minimapCharRenderer'; +import { Constants, MinimapCharRenderer } from 'vs/editor/common/view/minimapCharRenderer'; + +const enum InternalConstants { + CA_CHANNELS_CNT = 2, +} export class MinimapCharRendererFactory { - public static create(source: Uint8ClampedArray): MinimapCharRenderer2 { + public static create(source: Uint8ClampedArray): MinimapCharRenderer { const expectedLength = (Constants.SAMPLED_CHAR_HEIGHT * Constants.SAMPLED_CHAR_WIDTH * Constants.RGBA_CHANNELS_CNT * Constants.CHAR_COUNT); if (source.length !== expectedLength) { throw new Error('Unexpected source in MinimapCharRenderer'); @@ -16,7 +20,7 @@ export class MinimapCharRendererFactory { let x2CharData = this.toGrayscale(MinimapCharRendererFactory._downsample2x(source)); let x1CharData = this.toGrayscale(MinimapCharRendererFactory._downsample1x(source)); - return new MinimapCharRenderer2(x2CharData, x1CharData); + return new MinimapCharRenderer(x2CharData, x1CharData); } private static toGrayscale(charData: Uint8ClampedArray): Uint8ClampedArray { @@ -52,7 +56,7 @@ export class MinimapCharRendererFactory { private static _downsample2xChar(source: Uint8ClampedArray, dest: Uint8ClampedArray): void { // chars are 2 x 4px (width x height) - const resultLen = Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * Constants.CA_CHANNELS_CNT; + const resultLen = Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT; const result = new Uint16Array(resultLen); for (let i = 0; i < resultLen; i++) { result[i] = 0; @@ -72,7 +76,7 @@ export class MinimapCharRendererFactory { } result[outputOffset] += color; result[outputOffset + 1] += alpha; - outputOffset += Constants.CA_CHANNELS_CNT; + outputOffset += InternalConstants.CA_CHANNELS_CNT; color = 0; alpha = 0; @@ -83,7 +87,7 @@ export class MinimapCharRendererFactory { } result[outputOffset] += color; result[outputOffset + 1] += alpha; - outputOffset += Constants.CA_CHANNELS_CNT; + outputOffset += InternalConstants.CA_CHANNELS_CNT; if (i === 2 || i === 5 || i === 8) { globalOutputOffset = outputOffset; @@ -96,16 +100,16 @@ export class MinimapCharRendererFactory { } private static _downsample2x(data: Uint8ClampedArray): Uint8ClampedArray { - const resultLen = Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * Constants.CA_CHANNELS_CNT * Constants.CHAR_COUNT; + const resultLen = Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT * Constants.CHAR_COUNT; const result = new Uint8ClampedArray(resultLen); const sampledChar = new Uint8ClampedArray(Constants.SAMPLED_CHAR_HEIGHT * Constants.SAMPLED_CHAR_WIDTH * Constants.RGBA_CHANNELS_CNT); - const downsampledChar = new Uint8ClampedArray(Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * Constants.CA_CHANNELS_CNT); + const downsampledChar = new Uint8ClampedArray(Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT); for (let charIndex = 0; charIndex < Constants.CHAR_COUNT; charIndex++) { this._extractSampledChar(data, charIndex, sampledChar); this._downsample2xChar(sampledChar, downsampledChar); - let resultOffset = (Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * Constants.CA_CHANNELS_CNT * charIndex); + let resultOffset = (Constants.x2_CHAR_HEIGHT * Constants.x2_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT * charIndex); for (let i = 0; i < downsampledChar.length; i++) { result[resultOffset + i] = downsampledChar[i]; } @@ -116,7 +120,7 @@ export class MinimapCharRendererFactory { private static _downsample1xChar(source: Uint8ClampedArray, dest: Uint8ClampedArray): void { // chars are 1 x 2px (width x height) - const resultLen = Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * Constants.CA_CHANNELS_CNT; + const resultLen = Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT; const result = new Uint16Array(resultLen); for (let i = 0; i < resultLen; i++) { result[i] = 0; @@ -136,7 +140,7 @@ export class MinimapCharRendererFactory { } result[outputOffset] += color; result[outputOffset + 1] += alpha; - outputOffset += Constants.CA_CHANNELS_CNT; + outputOffset += InternalConstants.CA_CHANNELS_CNT; if (i === 5) { globalOutputOffset = outputOffset; @@ -149,16 +153,16 @@ export class MinimapCharRendererFactory { } private static _downsample1x(data: Uint8ClampedArray): Uint8ClampedArray { - const resultLen = Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * Constants.CA_CHANNELS_CNT * Constants.CHAR_COUNT; + const resultLen = Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT * Constants.CHAR_COUNT; const result = new Uint8ClampedArray(resultLen); const sampledChar = new Uint8ClampedArray(Constants.SAMPLED_CHAR_HEIGHT * Constants.SAMPLED_CHAR_WIDTH * Constants.RGBA_CHANNELS_CNT); - const downsampledChar = new Uint8ClampedArray(Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * Constants.CA_CHANNELS_CNT); + const downsampledChar = new Uint8ClampedArray(Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT); for (let charIndex = 0; charIndex < Constants.CHAR_COUNT; charIndex++) { this._extractSampledChar(data, charIndex, sampledChar); this._downsample1xChar(sampledChar, downsampledChar); - let resultOffset = (Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * Constants.CA_CHANNELS_CNT * charIndex); + let resultOffset = (Constants.x1_CHAR_HEIGHT * Constants.x1_CHAR_WIDTH * InternalConstants.CA_CHANNELS_CNT * charIndex); for (let i = 0; i < downsampledChar.length; i++) { result[resultOffset + i] = downsampledChar[i]; } -- GitLab