mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
ie support
This commit is contained in:
@ -388,8 +388,6 @@ window.onload = function()
|
||||
return res;
|
||||
};
|
||||
|
||||
this.links = null;
|
||||
|
||||
this._paint = function()
|
||||
{
|
||||
if (!this.isRepaint)
|
||||
@ -467,12 +465,7 @@ window.onload = function()
|
||||
}
|
||||
|
||||
if (!page.Image)
|
||||
{
|
||||
page.Image = this.file.getPage(i, w, h);
|
||||
//this.getGlyphs(i, w, h);
|
||||
this.links = this.getLinks(i, w, h);
|
||||
this.links.Page = i;
|
||||
}
|
||||
|
||||
let x = ((xCenter * this.retinaPixelRatio) >> 0) - (w >> 1);
|
||||
let y = ((page.Y - yPos) * this.retinaPixelRatio) >> 0;
|
||||
@ -480,16 +473,6 @@ window.onload = function()
|
||||
ctx.drawImage(page.Image, 0, 0, w, h, x, y, w, h);
|
||||
if (this.Selection.page == i && this.Selection.IsSelection)
|
||||
ctx.drawImage(this.Selection.Image, 0, 0, w, h, x, y, w, h);
|
||||
|
||||
if (this.links && this.links.Page == i)
|
||||
{
|
||||
ctx.fillStyle = "#FF0000";
|
||||
for (let j = 0; j < this.links.length; j++)
|
||||
{
|
||||
let Link = this.links[j];
|
||||
ctx.fillRect(x + Link.x, y + Link.y, Link.w, Link.h);
|
||||
}
|
||||
}
|
||||
|
||||
ctx.strokeRect(x + lineW / 2, y + lineW / 2, w - lineW, h - lineW);
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
BIN
DjVuFile/wasm/all_files_test/drawingfile.js.mem
Normal file
BIN
DjVuFile/wasm/all_files_test/drawingfile.js.mem
Normal file
Binary file not shown.
Binary file not shown.
671
DjVuFile/wasm/all_files_test/drawingfile_ie.js
Normal file
671
DjVuFile/wasm/all_files_test/drawingfile_ie.js
Normal file
File diff suppressed because one or more lines are too long
@ -57,23 +57,7 @@
|
||||
var t1 = performance.now();
|
||||
var image = this._pixelsToCanvas(pixels, width, height);
|
||||
var t2 = performance.now();
|
||||
//console.log("time: " + (t1 - t0) + ", " + (t2 - t1));
|
||||
}
|
||||
/*
|
||||
if (this.pages[pageIndex].Lines)
|
||||
{
|
||||
var ctx = image.getContext("2d");
|
||||
for (let i = 0; i < this.pages[pageIndex].Lines.length; i++)
|
||||
{
|
||||
for (let j = 0; j < this.pages[pageIndex].Lines[i].Glyphs.length; j++)
|
||||
{
|
||||
let glyph = this.pages[pageIndex].Lines[i].Glyphs[j];
|
||||
ctx.font = glyph.fontSize + 'px ' + glyph.fontName;
|
||||
ctx.fillText(glyph.UChar, glyph.X, glyph.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
this.free(pixels);
|
||||
return image;
|
||||
};
|
||||
@ -242,7 +226,157 @@
|
||||
|
||||
return "";
|
||||
};
|
||||
CFile.prototype.isValid = function()
|
||||
{
|
||||
return this.pages.length > 0;
|
||||
};
|
||||
|
||||
// private functions
|
||||
CFile.prototype._pixelsToCanvas2d = function(pixels, width, height)
|
||||
{
|
||||
var canvas = null;
|
||||
if (this.cacheManager)
|
||||
{
|
||||
canvas = this.cacheManager.lock(width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
canvas = document.createElement("canvas");
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
}
|
||||
|
||||
var mappedBuffer = new Uint8ClampedArray(this.memory().buffer, pixels, 4 * width * height);
|
||||
var imageData = new ImageData(mappedBuffer, width, height);
|
||||
var ctx = canvas.getContext("2d");
|
||||
if (ctx)
|
||||
ctx.putImageData(imageData, 0, 0);
|
||||
return canvas;
|
||||
};
|
||||
|
||||
CFile.prototype._pixelsToCanvas3d = function(pixels, width, height)
|
||||
{
|
||||
var vs_source = "\
|
||||
attribute vec2 aVertex;\n\
|
||||
attribute vec2 aTex;\n\
|
||||
varying vec2 vTex;\n\
|
||||
void main() {\n\
|
||||
gl_Position = vec4(aVertex, 0.0, 1.0);\n\
|
||||
vTex = aTex;\n\
|
||||
}";
|
||||
|
||||
var fs_source = "\
|
||||
precision mediump float;\n\
|
||||
uniform sampler2D uTexture;\n\
|
||||
varying vec2 vTex;\n\
|
||||
void main() {\n\
|
||||
gl_FragColor = texture2D(uTexture, vTex);\n\
|
||||
}";
|
||||
var canvas = null;
|
||||
if (this.cacheManager)
|
||||
{
|
||||
canvas = this.cacheManager.lock(width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
canvas = document.createElement("canvas");
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
}
|
||||
|
||||
var gl = canvas.getContext('webgl', { preserveDrawingBuffer : true });
|
||||
if (!gl)
|
||||
throw new Error('FAIL: could not create webgl canvas context');
|
||||
|
||||
var colorCorrect = gl.BROWSER_DEFAULT_WEBGL;
|
||||
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, colorCorrect);
|
||||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
||||
|
||||
gl.viewport(0, 0, canvas.width, canvas.height);
|
||||
gl.clearColor(0, 0, 0, 1);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
|
||||
if (gl.getError() != gl.NONE)
|
||||
throw new Error('FAIL: webgl canvas context setup failed');
|
||||
|
||||
function createShader(source, type) {
|
||||
var shader = gl.createShader(type);
|
||||
gl.shaderSource(shader, source);
|
||||
gl.compileShader(shader);
|
||||
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS))
|
||||
throw new Error('FAIL: shader ' + id + ' compilation failed');
|
||||
return shader;
|
||||
}
|
||||
|
||||
var program = gl.createProgram();
|
||||
gl.attachShader(program, createShader(vs_source, gl.VERTEX_SHADER));
|
||||
gl.attachShader(program, createShader(fs_source, gl.FRAGMENT_SHADER));
|
||||
gl.linkProgram(program);
|
||||
if (!gl.getProgramParameter(program, gl.LINK_STATUS))
|
||||
throw new Error('FAIL: webgl shader program linking failed');
|
||||
gl.useProgram(program);
|
||||
|
||||
var texture = gl.createTexture();
|
||||
gl.activeTexture(gl.TEXTURE0);
|
||||
gl.bindTexture(gl.TEXTURE_2D, texture);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(this.memory().buffer, pixels, 4 * width * height));
|
||||
|
||||
if (gl.getError() != gl.NONE)
|
||||
throw new Error('FAIL: creating webgl image texture failed');
|
||||
|
||||
function createBuffer(data) {
|
||||
var buffer = gl.createBuffer();
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
var vertexCoords = new Float32Array([-1, 1, -1, -1, 1, -1, 1, 1]);
|
||||
var vertexBuffer = createBuffer(vertexCoords);
|
||||
var location = gl.getAttribLocation(program, 'aVertex');
|
||||
gl.enableVertexAttribArray(location);
|
||||
gl.vertexAttribPointer(location, 2, gl.FLOAT, false, 0, 0);
|
||||
|
||||
if (gl.getError() != gl.NONE)
|
||||
throw new Error('FAIL: vertex-coord setup failed');
|
||||
|
||||
var texCoords = new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]);
|
||||
var texBuffer = createBuffer(texCoords);
|
||||
var location = gl.getAttribLocation(program, 'aTex');
|
||||
gl.enableVertexAttribArray(location);
|
||||
gl.vertexAttribPointer(location, 2, gl.FLOAT, false, 0, 0);
|
||||
|
||||
if (gl.getError() != gl.NONE)
|
||||
throw new Error('FAIL: tex-coord setup setup failed');
|
||||
|
||||
gl.drawArrays(gl.TRIANGLE_FAN, 0, 4);
|
||||
return canvas;
|
||||
};
|
||||
|
||||
CFile.prototype._pixelsToCanvas = function(pixels, width, height)
|
||||
{
|
||||
if (!this.isUse3d)
|
||||
{
|
||||
return this._pixelsToCanvas2d(pixels, width, height);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return this._pixelsToCanvas3d(pixels, width, height);
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
this.isUse3d = false;
|
||||
if (this.cacheManager)
|
||||
this.cacheManager.clear();
|
||||
return this._pixelsToCanvas(pixels, width, height);
|
||||
}
|
||||
};
|
||||
|
||||
window["AscViewer"] = window["AscViewer"] || {};
|
||||
window["AscViewer"].IFile = CFile;
|
||||
|
||||
|
||||
@ -17,6 +17,8 @@ base.cmd_in_dir("./../../DesktopEditor/graphics/pro/js", "python", ["make.py"])
|
||||
if base.is_exist("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.wasm"):
|
||||
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.js", "./deploy/drawingfile.js")
|
||||
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.wasm", "./deploy/drawingfile.wasm")
|
||||
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile_ie.js", "./deploy/drawingfile_ie.js")
|
||||
base.copy_file("./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.js.mem", "./deploy/drawingfile.js.mem")
|
||||
else:
|
||||
print("make.py error")
|
||||
base.copy_dir("./all_files_test/xps_djvu", "./deploy")
|
||||
|
||||
Reference in New Issue
Block a user