mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
ie support
This commit is contained in:
@ -133,6 +133,7 @@ sources = []
|
||||
sources.append("raster.o")
|
||||
sources.append("wasm/src/drawingfile.cpp")
|
||||
|
||||
# command
|
||||
compile_files_array_len = len(compile_files_array)
|
||||
external_file = []
|
||||
|
||||
@ -166,7 +167,7 @@ arguments += "]\" "
|
||||
for item in sources:
|
||||
arguments += (item + " ")
|
||||
|
||||
external_file.append("call emcc -o drawingfile.js " + arguments + libs)
|
||||
external_file.append(prefix_call + "emcc -o drawingfile.js " + arguments + libs)
|
||||
|
||||
base.replaceInFile("../../../../Common/3dParty/icu/icu/source/common/udata.cpp", "\n{\n UDataMemory tData;", "\n{\n#ifdef BUILDING_WASM_MODULE\nreturn NULL;\n#endif\n UDataMemory tData;")
|
||||
base.run_as_bat(external_file)
|
||||
@ -186,8 +187,41 @@ engine_js_content = engine_js_content.replace("//string_utf8", string_utf8_conte
|
||||
base.writeFile("./deploy/drawingfile.js", engine_js_content)
|
||||
base.copy_file("./drawingfile.wasm", "./deploy/drawingfile.wasm")
|
||||
|
||||
# ie asm version
|
||||
arguments = arguments.replace("WASM=1", "WASM=0")
|
||||
|
||||
# command
|
||||
external_file = []
|
||||
|
||||
if base.host_platform() == "windows":
|
||||
external_file.append("call emsdk/emsdk_env.bat")
|
||||
else:
|
||||
external_file.append("#!/bin/bash")
|
||||
external_file.append("source ./emsdk/emsdk_env.sh")
|
||||
|
||||
external_file.append(prefix_call + "emcc -o drawingfile.js " + arguments + libs)
|
||||
base.run_as_bat(external_file)
|
||||
|
||||
# finalize
|
||||
base.replaceInFile("./drawingfile.js", "function getBinaryPromise(){", "function getBinaryPromise2(){")
|
||||
base.replaceInFile("./drawingfile.js", "__ATPOSTRUN__=[];", "__ATPOSTRUN__=[function(){window[\"AscViewer\"] && window[\"AscViewer\"][\"onLoadModule\"] && window[\"AscViewer\"][\"onLoadModule\"]();}];")
|
||||
|
||||
module_js_content = base.readFile("./drawingfile.js")
|
||||
engine_base_js_content = base.readFile("./wasm/js/drawingfile_base.js")
|
||||
string_utf8_content = base.readFile("./../../../../Common/js/string_utf8.js")
|
||||
polyfill_js_content = base.readFile("./../../../../Common/3dParty/hunspell/wasm/js/polyfill.js")
|
||||
engine_js_content = engine_base_js_content.replace("//module", module_js_content)
|
||||
engine_js_content = engine_js_content.replace("//string_utf8", string_utf8_content)
|
||||
engine_js_content = engine_js_content.replace("//polyfill", polyfill_js_content)
|
||||
|
||||
# write new version
|
||||
base.writeFile("./deploy/drawingfile_ie.js", engine_js_content)
|
||||
base.copy_file("./drawingfile.js.mem", "./deploy/drawingfile.js.mem")
|
||||
|
||||
# clear
|
||||
base.delete_file("drawingfile.js")
|
||||
base.delete_file("drawingfile.wasm")
|
||||
base.delete_file("drawingfile.js.mem")
|
||||
base.delete_dir("./o")
|
||||
base.delete_dir("./xml")
|
||||
# base.delete_file("./raster.o")
|
||||
|
||||
@ -2,6 +2,7 @@ import sys
|
||||
sys.path.append("../../../../../build_tools/scripts")
|
||||
import base
|
||||
import os
|
||||
import json
|
||||
|
||||
base.configure_common_apps()
|
||||
|
||||
@ -9,18 +10,18 @@ base.configure_common_apps()
|
||||
if base.is_dir("./deploy"):
|
||||
base.delete_dir("./deploy")
|
||||
base.create_dir("./deploy")
|
||||
if base.is_dir("./temp"):
|
||||
base.delete_dir("./temp")
|
||||
base.create_dir("./temp")
|
||||
if base.is_dir("./o"):
|
||||
base.delete_dir("./o")
|
||||
base.create_dir("./o")
|
||||
|
||||
# fetch emsdk
|
||||
command_prefix = "" if ("windows" == base.host_platform()) else "./"
|
||||
if not base.is_dir("emsdk"):
|
||||
base.cmd("git", ["clone", "https://github.com/emscripten-core/emsdk.git"])
|
||||
os.chdir("emsdk")
|
||||
base.cmd(command_prefix + "emsdk", ["install", "latest"])
|
||||
base.cmd(command_prefix + "emsdk", ["activate", "latest"])
|
||||
os.chdir("../")
|
||||
base.cmd("git", ["clone", "https://github.com/emscripten-core/emsdk.git"])
|
||||
os.chdir("emsdk")
|
||||
base.cmd(command_prefix + "emsdk", ["install", "latest"])
|
||||
base.cmd(command_prefix + "emsdk", ["activate", "latest"])
|
||||
os.chdir("../")
|
||||
|
||||
# compile
|
||||
compiler_flags = ["-O3",
|
||||
@ -31,108 +32,53 @@ compiler_flags = ["-O3",
|
||||
"-s ENVIRONMENT='web,worker'"]
|
||||
#"-s LLD_REPORT_UNDEFINED"]
|
||||
|
||||
exported_functions = ["_malloc",
|
||||
"_free",
|
||||
"_Raster_Malloc",
|
||||
"_Raster_Free",
|
||||
"_Raster_Create",
|
||||
"_Raster_Load",
|
||||
"_Raster_Init",
|
||||
"_Raster_Destroy",
|
||||
"_Raster_GetHeight",
|
||||
"_Raster_GetWidth",
|
||||
"_Raster_Decode",
|
||||
"_Raster_GetRGBA"]
|
||||
compile_files_array = []
|
||||
|
||||
libRaster_src_path = "../../../raster"
|
||||
input_raster_sources = ["BgraFrame.cpp", "ImageFileFormatChecker.cpp"]
|
||||
compile_files_array.append("r")
|
||||
compile_files_array.append("../../../raster/")
|
||||
compile_files_array.append(["BgraFrame.cpp", "ImageFileFormatChecker.cpp"])
|
||||
|
||||
libZlib_src_path = "../../../../OfficeUtils/src/zlib-1.2.11"
|
||||
input_zlib_sources = ["inflate.c", "zutil.c", "crc32.c", "adler32.c", "inftrees.c", "inffast.c", "deflate.c", "trees.c"]
|
||||
compile_files_array.append("ci")
|
||||
compile_files_array.append("../../../cximage/CxImage/")
|
||||
compile_files_array.append(["ximaenc.cpp", "ximaexif.cpp", "ximage.cpp", "ximainfo.cpp", "ximajpg.cpp", "ximalpha.cpp", "ximapal.cpp", "ximasel.cpp", "xmemfile.cpp", "ximapng.cpp", "ximabmp.cpp", "ximatran.cpp", "ximatif.cpp", "tif_xfile.cpp", "ximajas.cpp", "ximagif.cpp", "ximaico.cpp", "ximatga.cpp", "ximapcx.cpp", "ximawbmp.cpp", "ximamng.cpp", "ximapsd.cpp", "ximaska.cpp", "ximaraw.cpp"])
|
||||
|
||||
libCxImage_src_path = "../../../cximage/CxImage"
|
||||
input_cximage_sources = ["ximaenc.cpp", "ximaexif.cpp", "ximage.cpp", "ximainfo.cpp",
|
||||
"ximajpg.cpp", "ximalpha.cpp", "ximapal.cpp", "ximasel.cpp",
|
||||
"xmemfile.cpp", "ximapng.cpp", "ximabmp.cpp", "ximatran.cpp",
|
||||
"ximatif.cpp", "tif_xfile.cpp", "ximajas.cpp", "ximagif.cpp",
|
||||
"ximaico.cpp", "ximatga.cpp", "ximapcx.cpp", "ximawbmp.cpp",
|
||||
"ximamng.cpp", "ximapsd.cpp", "ximaska.cpp", "ximaraw.cpp"]
|
||||
compile_files_array.append("j")
|
||||
compile_files_array.append("../../../cximage/jpeg/")
|
||||
compile_files_array.append(["jerror.c", "jdmarker.c", "jdapimin.c", "jdmaster.c", "jdapistd.c", "jcomapi.c", "jutils.c", "jdinput.c", "jdmainct.c", "jmemmgr.c", "jquant1.c", "jquant2.c", "jdmerge.c", "jdcolor.c", "jdsample.c", "jdpostct.c", "jddctmgr.c", "jdarith.c", "jdhuff.c", "jdcoefct.c", "jmemnobs.c", "jidctint.c", "jidctfst.c", "jidctflt.c", "jaricom.c", "jcapimin.c", "jcparam.c", "jcapistd.c", "jcinit.c", "jcmaster.c", "jccolor.c", "jcmarker.c", "jcsample.c", "jcprepct.c", "jcdctmgr.c", "jcarith.c", "jchuff.c", "jccoefct.c", "jcmainct.c", "jfdctint.c", "jfdctfst.c", "jfdctflt.c"])
|
||||
|
||||
libJpeg_src_path = "../../../cximage/jpeg"
|
||||
input_jpeg_sources = ["jerror.c", "jdmarker.c", "jdapimin.c", "jdmaster.c", "jdapistd.c",
|
||||
"jcomapi.c", "jutils.c", "jdinput.c", "jdmainct.c", "jmemmgr.c",
|
||||
"jquant1.c", "jquant2.c", "jdmerge.c", "jdcolor.c", "jdsample.c",
|
||||
"jdpostct.c", "jddctmgr.c", "jdarith.c", "jdhuff.c", "jdcoefct.c",
|
||||
"jmemnobs.c", "jidctint.c", "jidctfst.c", "jidctflt.c", "jaricom.c",
|
||||
"jcapimin.c", "jcparam.c", "jcapistd.c", "jcinit.c", "jcmaster.c",
|
||||
"jccolor.c", "jcmarker.c", "jcsample.c", "jcprepct.c", "jcdctmgr.c",
|
||||
"jcarith.c", "jchuff.c", "jccoefct.c", "jcmainct.c", "jfdctint.c",
|
||||
"jfdctfst.c", "jfdctflt.c"]
|
||||
compile_files_array.append("p")
|
||||
compile_files_array.append("../../../cximage/png/")
|
||||
compile_files_array.append(["pngread.c", "pngmem.c", "pngerror.c", "png.c", "pngrio.c", "pngtrans.c", "pngget.c", "pngrutil.c", "pngrtran.c", "pngset.c", "pngwrite.c", "pngwio.c", "pngwutil.c", "pngwtran.c"])
|
||||
|
||||
libPng_src_path = "../../../cximage/png"
|
||||
input_png_sources = ["pngread.c", "pngmem.c", "pngerror.c", "png.c", "pngrio.c", "pngtrans.c", "pngget.c", "pngrutil.c", "pngrtran.c", "pngset.c", "pngwrite.c", "pngwio.c", "pngwutil.c", "pngwtran.c"]
|
||||
compile_files_array.append("t")
|
||||
compile_files_array.append("../../../cximage/tiff/")
|
||||
compile_files_array.append(["tif_close.c", "tif_dir.c", "tif_aux.c", "tif_getimage.c", "tif_strip.c", "tif_open.c", "tif_tile.c", "tif_error.c", "tif_read.c", "tif_flush.c", "tif_dirinfo.c", "tif_compress.c", "tif_warning.c", "tif_swab.c", "tif_color.c", "tif_dirread.c", "tif_write.c", "tif_codec.c", "tif_luv.c", "tif_dirwrite.c", "tif_dumpmode.c", "tif_fax3.c", "tif_ojpeg.c", "tif_jpeg.c", "tif_next.c", "tif_thunder.c", "tif_packbits.c", "tif_lzw.c", "tif_zip.c", "tif_fax3sm.c", "tif_predict.c"])
|
||||
|
||||
libTiff_src_path = "../../../cximage/tiff"
|
||||
input_tiff_sources = ["tif_close.c", "tif_dir.c", "tif_aux.c", "tif_getimage.c", "tif_strip.c",
|
||||
"tif_open.c", "tif_tile.c", "tif_error.c", "tif_read.c", "tif_flush.c",
|
||||
"tif_dirinfo.c", "tif_compress.c", "tif_warning.c", "tif_swab.c",
|
||||
"tif_color.c", "tif_dirread.c", "tif_write.c", "tif_codec.c", "tif_luv.c",
|
||||
"tif_dirwrite.c", "tif_dumpmode.c", "tif_fax3.c", "tif_ojpeg.c",
|
||||
"tif_jpeg.c", "tif_next.c", "tif_thunder.c", "tif_packbits.c", "tif_lzw.c",
|
||||
"tif_zip.c", "tif_fax3sm.c", "tif_predict.c"]
|
||||
compile_files_array.append("ja")
|
||||
compile_files_array.append("../../../cximage/jasper/")
|
||||
compile_files_array.append(["base/jas_init.c", "base/jas_stream.c", "base/jas_malloc.c", "base/jas_image.c", "base/jas_cm.c", "base/jas_seq.c", "base/jas_string.c", "base/jas_icc.c", "base/jas_debug.c", "base/jas_iccdata.c", "base/jas_tvp.c", "base/jas_version.c", "mif/mif_cod.c", "pnm/pnm_dec.c", "pnm/pnm_enc.c", "pnm/pnm_cod.c", "bmp/bmp_dec.c", "bmp/bmp_enc.c", "bmp/bmp_cod.c", "ras/ras_dec.c", "ras/ras_enc.c", "jp2/jp2_dec.c", "jp2/jp2_enc.c", "jp2/jp2_cod.c", "jpc/jpc_cs.c", "jpc/jpc_enc.c", "jpc/jpc_dec.c", "jpc/jpc_t1cod.c", "jpc/jpc_math.c", "jpc/jpc_util.c", "jpc/jpc_tsfb.c", "jpc/jpc_mct.c", "jpc/jpc_t1enc.c", "jpc/jpc_t1dec.c", "jpc/jpc_bs.c", "jpc/jpc_t2cod.c", "jpc/jpc_t2enc.c", "jpc/jpc_t2dec.c", "jpc/jpc_tagtree.c", "jpc/jpc_mqenc.c", "jpc/jpc_mqdec.c", "jpc/jpc_mqcod.c", "jpc/jpc_qmfb.c", "jpg/jpg_val.c", "jpg/jpg_dummy.c", "pgx/pgx_dec.c", "pgx/pgx_enc.c"])
|
||||
|
||||
libJasper_src_path = "../../../cximage/jasper"
|
||||
input_jasper_sources = ["base/jas_init.c", "base/jas_stream.c", "base/jas_malloc.c",
|
||||
"base/jas_image.c", "base/jas_cm.c", "base/jas_seq.c",
|
||||
"base/jas_string.c", "base/jas_icc.c", "base/jas_debug.c",
|
||||
"base/jas_iccdata.c", "base/jas_tvp.c", "base/jas_version.c",
|
||||
"mif/mif_cod.c", "pnm/pnm_dec.c", "pnm/pnm_enc.c", "pnm/pnm_cod.c",
|
||||
"bmp/bmp_dec.c", "bmp/bmp_enc.c", "bmp/bmp_cod.c", "ras/ras_dec.c",
|
||||
"ras/ras_enc.c", "jp2/jp2_dec.c", "jp2/jp2_enc.c", "jp2/jp2_cod.c",
|
||||
"jpc/jpc_cs.c", "jpc/jpc_enc.c", "jpc/jpc_dec.c", "jpc/jpc_t1cod.c",
|
||||
"jpc/jpc_math.c", "jpc/jpc_util.c", "jpc/jpc_tsfb.c", "jpc/jpc_mct.c",
|
||||
"jpc/jpc_t1enc.c", "jpc/jpc_t1dec.c", "jpc/jpc_bs.c", "jpc/jpc_t2cod.c",
|
||||
"jpc/jpc_t2enc.c", "jpc/jpc_t2dec.c", "jpc/jpc_tagtree.c",
|
||||
"jpc/jpc_mqenc.c", "jpc/jpc_mqdec.c", "jpc/jpc_mqcod.c",
|
||||
"jpc/jpc_qmfb.c", "jpg/jpg_val.c", "jpg/jpg_dummy.c", "pgx/pgx_dec.c",
|
||||
"pgx/pgx_enc.c"]
|
||||
compile_files_array.append("jp")
|
||||
compile_files_array.append("../../../raster/Jp2/")
|
||||
compile_files_array.append(["J2kFile.cpp", "Reader.cpp"])
|
||||
|
||||
libJ2kFile_src_path = "../../../raster/Jp2"
|
||||
input_j2k_sources = ["J2kFile.cpp", "Reader.cpp"]
|
||||
compile_files_array.append("m")
|
||||
compile_files_array.append("../../../cximage/mng/")
|
||||
compile_files_array.append(["libmng_hlapi.c", "libmng_callback_xs.c", "libmng_prop_xs.c", "libmng_object_prc.c", "libmng_zlib.c", "libmng_jpeg.c", "libmng_pixels.c", "libmng_read.c", "libmng_error.c", "libmng_display.c", "libmng_write.c", "libmng_chunk_io.c", "libmng_cms.c", "libmng_filter.c", "libmng_chunk_prc.c", "libmng_chunk_xs.c"])
|
||||
|
||||
libMng_src_path = "../../../cximage/mng"
|
||||
input_mng_sources = ["libmng_hlapi.c", "libmng_callback_xs.c", "libmng_prop_xs.c", "libmng_object_prc.c", "libmng_zlib.c", "libmng_jpeg.c", "libmng_pixels.c", "libmng_read.c", "libmng_error.c", "libmng_display.c", "libmng_write.c", "libmng_chunk_io.c", "libmng_cms.c", "libmng_filter.c", "libmng_chunk_prc.c", "libmng_chunk_xs.c"]
|
||||
compile_files_array.append("lp")
|
||||
compile_files_array.append("../../../cximage/libpsd/")
|
||||
compile_files_array.append(["psd.c", "file_header.c", "color_mode.c", "image_resource.c", "blend.c", "layer_mask.c", "image_data.c", "stream.c", "psd_system.c", "color.c", "pattern_fill.c", "color_balance.c", "channel_image.c", "gradient_fill.c", "invert.c", "posterize.c", "brightness_contrast.c", "solid_color.c", "threshold.c", "effects.c", "selective_color.c", "channel_mixer.c", "photo_filter.c", "type_tool.c", "gradient_map.c", "hue_saturation.c", "levels.c", "curves.c", "pattern.c", "psd_zip.c", "descriptor.c", "drop_shadow.c", "inner_shadow.c", "color_overlay.c", "outer_glow.c", "inner_glow.c", "bevel_emboss.c", "satin.c", "gradient_overlay.c", "stroke.c", "pattern_overlay.c"])
|
||||
|
||||
libPsd_src_path = "../../../cximage/libpsd"
|
||||
input_psd_sources = ["psd.c", "file_header.c", "color_mode.c", "image_resource.c", "blend.c", "layer_mask.c", "image_data.c", "stream.c", "psd_system.c", "color.c", "pattern_fill.c", "color_balance.c", "channel_image.c", "gradient_fill.c", "invert.c", "posterize.c", "brightness_contrast.c", "solid_color.c", "threshold.c", "effects.c", "selective_color.c", "channel_mixer.c", "photo_filter.c", "type_tool.c", "gradient_map.c", "hue_saturation.c", "levels.c", "curves.c", "pattern.c", "psd_zip.c", "descriptor.c", "drop_shadow.c", "inner_shadow.c", "color_overlay.c", "outer_glow.c", "inner_glow.c", "bevel_emboss.c", "satin.c", "gradient_overlay.c", "stroke.c", "pattern_overlay.c"]
|
||||
compile_files_array.append("ra")
|
||||
compile_files_array.append("../../../cximage/raw/")
|
||||
compile_files_array.append(["libdcr.c"])
|
||||
|
||||
libRaw_src_path = "../../../cximage/raw"
|
||||
input_raw_sources = ["libdcr.c"]
|
||||
compile_files_array.append("jb")
|
||||
compile_files_array.append("../../../raster/JBig2/source/")
|
||||
compile_files_array.append(["JBig2File.cpp", "Encoder/jbig2enc.cpp", "Encoder/jbig2arith.cpp", "Encoder/jbig2sym.cpp", "LeptonLib/pixconv.cpp", "LeptonLib/writefile.cpp", "LeptonLib/scale.cpp", "LeptonLib/pix1.cpp", "LeptonLib/pix2.cpp", "LeptonLib/pix3.cpp", "LeptonLib/pix4.cpp", "LeptonLib/pix5.cpp", "LeptonLib/grayquant.cpp", "LeptonLib/grayquantlow.cpp", "LeptonLib/seedfill.cpp", "LeptonLib/jbclass.cpp", "LeptonLib/pixabasic.cpp", "LeptonLib/numabasic.cpp", "LeptonLib/morphseq.cpp", "LeptonLib/binexpandlow.cpp", "LeptonLib/ptabasic.cpp", "LeptonLib/rop.cpp", "LeptonLib/colormap.cpp", "LeptonLib/pngiostub.cpp", "LeptonLib/lepton_utils.cpp", "LeptonLib/scalelow.cpp", "LeptonLib/enhance.cpp", "LeptonLib/jpegio.cpp", "LeptonLib/jpegiostub.cpp", "LeptonLib/spixio.cpp", "LeptonLib/webpio.cpp", "LeptonLib/webpiostub.cpp", "LeptonLib/psio2.cpp", "LeptonLib/gifio.cpp", "LeptonLib/gifiostub.cpp", "LeptonLib/pnmio.cpp", "LeptonLib/tiffio.cpp", "LeptonLib/tiffiostub.cpp", "LeptonLib/bmpio.cpp", "LeptonLib/binexpand.cpp", "LeptonLib/compare.cpp", "LeptonLib/boxbasic.cpp", "LeptonLib/conncomp.cpp", "LeptonLib/pixafunc1.cpp", "LeptonLib/boxfunc1.cpp", "LeptonLib/ptafunc1.cpp", "LeptonLib/binreduce.cpp", "LeptonLib/seedfilllow.cpp", "LeptonLib/sel1.cpp", "LeptonLib/morphapp.cpp", "LeptonLib/correlscore.cpp", "LeptonLib/sarray.cpp", "LeptonLib/morph.cpp", "LeptonLib/roplow.cpp", "LeptonLib/fpix1.cpp", "LeptonLib/stack.cpp", "LeptonLib/pixacc.cpp", "LeptonLib/pixarith.cpp", "LeptonLib/convolve.cpp", "LeptonLib/binreducelow.cpp", "LeptonLib/convolvelow.cpp", "LeptonLib/arithlow.cpp"])
|
||||
|
||||
libJBig2_src_path = "../../../raster/JBig2/source"
|
||||
input_jbig2_sources = ["JBig2File.cpp", "Encoder/jbig2enc.cpp", "Encoder/jbig2arith.cpp", "Encoder/jbig2sym.cpp", "LeptonLib/pixconv.cpp", "LeptonLib/writefile.cpp", "LeptonLib/scale.cpp", "LeptonLib/pix1.cpp", "LeptonLib/pix2.cpp", "LeptonLib/pix3.cpp", "LeptonLib/pix4.cpp", "LeptonLib/pix5.cpp", "LeptonLib/grayquant.cpp", "LeptonLib/grayquantlow.cpp", "LeptonLib/seedfill.cpp", "LeptonLib/jbclass.cpp", "LeptonLib/pixabasic.cpp", "LeptonLib/numabasic.cpp", "LeptonLib/morphseq.cpp", "LeptonLib/binexpandlow.cpp", "LeptonLib/ptabasic.cpp", "LeptonLib/rop.cpp", "LeptonLib/colormap.cpp", "LeptonLib/pngiostub.cpp", "LeptonLib/lepton_utils.cpp", "LeptonLib/scalelow.cpp", "LeptonLib/enhance.cpp", "LeptonLib/jpegio.cpp", "LeptonLib/jpegiostub.cpp", "LeptonLib/spixio.cpp", "LeptonLib/webpio.cpp", "LeptonLib/webpiostub.cpp", "LeptonLib/psio2.cpp", "LeptonLib/gifio.cpp", "LeptonLib/gifiostub.cpp", "LeptonLib/pnmio.cpp", "LeptonLib/tiffio.cpp", "LeptonLib/tiffiostub.cpp", "LeptonLib/bmpio.cpp", "LeptonLib/binexpand.cpp", "LeptonLib/compare.cpp", "LeptonLib/boxbasic.cpp", "LeptonLib/conncomp.cpp", "LeptonLib/pixafunc1.cpp", "LeptonLib/boxfunc1.cpp", "LeptonLib/ptafunc1.cpp", "LeptonLib/binreduce.cpp", "LeptonLib/seedfilllow.cpp", "LeptonLib/sel1.cpp", "LeptonLib/morphapp.cpp", "LeptonLib/correlscore.cpp", "LeptonLib/sarray.cpp", "LeptonLib/morph.cpp", "LeptonLib/roplow.cpp", "LeptonLib/fpix1.cpp", "LeptonLib/stack.cpp", "LeptonLib/pixacc.cpp", "LeptonLib/pixarith.cpp", "LeptonLib/convolve.cpp", "LeptonLib/binreducelow.cpp", "LeptonLib/convolvelow.cpp", "LeptonLib/arithlow.cpp"]
|
||||
|
||||
sources = []
|
||||
for item in input_raster_sources:
|
||||
sources.append(libRaster_src_path + '/' + item)
|
||||
# zlib
|
||||
# cximage
|
||||
# jpeg
|
||||
# png
|
||||
# tiff
|
||||
for item in input_jasper_sources:
|
||||
sources.append(libJasper_src_path + '/' + item)
|
||||
for item in input_j2k_sources:
|
||||
sources.append(libJ2kFile_src_path + '/' + item)
|
||||
# mng
|
||||
# psd
|
||||
for item in input_raw_sources:
|
||||
sources.append(libRaw_src_path + '/' + item)
|
||||
# jbig2
|
||||
sources.append("wasm/src/raster.cpp")
|
||||
|
||||
compiler_flags.append("-I../../../../OfficeUtils/src/zlib-1.2.11")
|
||||
compiler_flags.append("-I" + libJasper_src_path + "/include")
|
||||
compiler_flags.append("-I../../../../OfficeUtils/src/zlib-1.2.11 -I../../../cximage/jasper/include")
|
||||
compiler_flags.append("-D__linux__ -DBUILDING_WASM_MODULE -D_tcsnicmp=strncmp -D_lseek=lseek -D_getcwd=getcwd -DNO_CONSOLE_IO")
|
||||
|
||||
# arguments
|
||||
@ -141,122 +87,32 @@ for item in compiler_flags:
|
||||
arguments += (item + " ")
|
||||
|
||||
# command
|
||||
windows_bat = []
|
||||
compile_files_array_len = len(compile_files_array)
|
||||
external_file = []
|
||||
|
||||
prefix_call = ""
|
||||
if base.host_platform() == "windows":
|
||||
windows_bat.append("call emsdk/emsdk_env.bat")
|
||||
|
||||
libs = ""
|
||||
for item in input_cximage_sources:
|
||||
windows_bat.append("call emcc -o temp/" + item + ".o -c " + arguments + libCxImage_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_jpeg_sources:
|
||||
windows_bat.append("call emcc -o temp/" + item + ".o -c " + arguments + libJpeg_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_png_sources:
|
||||
windows_bat.append("call emcc -o temp/" + item + ".o -c " + arguments + libPng_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_tiff_sources:
|
||||
windows_bat.append("call emcc -o temp/" + item + ".o -c " + arguments + libTiff_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_psd_sources:
|
||||
windows_bat.append("call emcc -o temp/" + item + ".o -c " + arguments + libPsd_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_mng_sources:
|
||||
windows_bat.append("call emcc -o temp/" + item + ".o -c " + arguments + libMng_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_jbig2_sources:
|
||||
windows_bat.append("call emcc -o temp/" + os.path.basename(item) + ".o -c " + arguments + libJBig2_src_path + '/' + item)
|
||||
libs += ("temp/" + os.path.basename(item) + ".o ")
|
||||
|
||||
arguments2 = arguments
|
||||
for item in sources:
|
||||
arguments2 += (item + " ")
|
||||
windows_bat.append("call emcc -r -o raster.o " + arguments2 + libs)
|
||||
|
||||
zlib = ""
|
||||
for item in input_zlib_sources:
|
||||
windows_bat.append("call emcc -o temp/" + item + ".o -c " + arguments + libZlib_src_path + '/' + item)
|
||||
zlib += ("temp/" + item + ".o ")
|
||||
|
||||
arguments += "-s EXPORTED_FUNCTIONS=\"["
|
||||
for item in exported_functions:
|
||||
arguments += ("'" + item + "',")
|
||||
arguments = arguments[:-1]
|
||||
arguments += "]\" "
|
||||
|
||||
windows_bat.append("call emcc -o raster.js " + arguments + " raster.o " + zlib)
|
||||
prefix_call = "call "
|
||||
external_file.append("call emsdk/emsdk_env.bat")
|
||||
else:
|
||||
windows_bat.append("#!/bin/bash")
|
||||
windows_bat.append("source ./emsdk/emsdk_env.sh")
|
||||
|
||||
libs = ""
|
||||
for item in input_cximage_sources:
|
||||
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libCxImage_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_jpeg_sources:
|
||||
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libJpeg_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_png_sources:
|
||||
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libPng_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_tiff_sources:
|
||||
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libTiff_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_psd_sources:
|
||||
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libPsd_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_mng_sources:
|
||||
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libMng_src_path + '/' + item)
|
||||
libs += ("temp/" + item + ".o ")
|
||||
|
||||
for item in input_jbig2_sources:
|
||||
windows_bat.append("emcc -o temp/" + os.path.basename(item) + ".o -c " + arguments + libJBig2_src_path + '/' + item)
|
||||
libs += ("temp/" + os.path.basename(item) + ".o ")
|
||||
|
||||
arguments2 = arguments
|
||||
for item in sources:
|
||||
arguments2 += (item + " ")
|
||||
windows_bat.append("emcc -r -o raster.o " + arguments2 + libs)
|
||||
|
||||
zlib = ""
|
||||
for item in input_zlib_sources:
|
||||
windows_bat.append("emcc -o temp/" + item + ".o -c " + arguments + libZlib_src_path + '/' + item)
|
||||
zlib += ("temp/" + item + ".o ")
|
||||
|
||||
arguments += "-s EXPORTED_FUNCTIONS=\"["
|
||||
for item in exported_functions:
|
||||
arguments += ("'" + item + "',")
|
||||
arguments = arguments[:-1]
|
||||
arguments += "]\" "
|
||||
|
||||
windows_bat.append("emcc -o raster.js " + arguments + " raster.o " + zlib)
|
||||
base.run_as_bat(windows_bat)
|
||||
external_file.append("#!/bin/bash")
|
||||
external_file.append("source ./emsdk/emsdk_env.sh")
|
||||
|
||||
# finalize
|
||||
base.replaceInFile("./raster.js", "__ATPOSTRUN__=[];", "__ATPOSTRUN__=[function(){self.onEngineInit();}];")
|
||||
base.replaceInFile("./raster.js", "function getBinaryPromise(){", "function getBinaryPromise2(){")
|
||||
file_index = 0
|
||||
libs = ""
|
||||
while file_index < compile_files_array_len:
|
||||
objects_dir = compile_files_array[file_index]
|
||||
base_dir = compile_files_array[file_index + 1]
|
||||
files = compile_files_array[file_index + 2]
|
||||
file_index += 3
|
||||
base.create_dir("./o/" + objects_dir)
|
||||
for item in files:
|
||||
file_name = os.path.splitext(os.path.basename(item))[0]
|
||||
external_file.append(prefix_call + "emcc -o o/" + objects_dir + "/" + file_name + ".o -c " + arguments + base_dir + item)
|
||||
libs += ("o/" + objects_dir + "/" + file_name + ".o ")
|
||||
|
||||
raster_js_content = base.readFile("./raster.js")
|
||||
engine_base_js_content = base.readFile("./wasm/js/raster.js")
|
||||
engine_js_content = engine_base_js_content.replace("//module", raster_js_content)
|
||||
external_file.append(prefix_call + "emcc -r -o raster.o " + arguments + "wasm/src/raster.cpp " + libs)
|
||||
base.run_as_bat(external_file)
|
||||
|
||||
# write new version
|
||||
base.writeFile("./deploy/raster.js", engine_js_content)
|
||||
base.copy_file("./raster.wasm", "./deploy/raster.wasm")
|
||||
base.copy_file("./wasm/js/index.html", "./deploy/index.html")
|
||||
base.copy_file("./wasm/js/code_raster.js", "./deploy/code_raster.js")
|
||||
|
||||
base.delete_file("raster.js")
|
||||
base.delete_file("raster.wasm")
|
||||
base.delete_dir("./temp")
|
||||
# clear
|
||||
base.delete_dir("./o")
|
||||
|
||||
@ -74,6 +74,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
//polyfill
|
||||
|
||||
//string_utf8
|
||||
|
||||
//module
|
||||
@ -108,9 +110,10 @@
|
||||
|
||||
function CFile()
|
||||
{
|
||||
this.nativeFile = 0;
|
||||
this.pages = [];
|
||||
AscViewer.IFile.call(this);
|
||||
}
|
||||
CFile.prototype = Object.create(AscViewer.IFile.prototype);
|
||||
CFile.prototype.constructor = CFile;
|
||||
|
||||
CFile.prototype["loadFromData"] = function(arrayBuffer)
|
||||
{
|
||||
@ -118,22 +121,22 @@
|
||||
var _stream = Module["_malloc"](data.length);
|
||||
Module["HEAP8"].set(data, _stream);
|
||||
this.nativeFile = Module["_Open"](_stream, data.length);
|
||||
this.stream = _stream;
|
||||
this.type = Module["_GetType"](_stream, data.length);
|
||||
this.stream = _stream;
|
||||
this.type = Module["_GetType"](_stream, data.length);
|
||||
return this.getInfo();
|
||||
};
|
||||
CFile.prototype["getInfo"] = function()
|
||||
{
|
||||
if (!this.nativeFile)
|
||||
return false;
|
||||
|
||||
|
||||
var _info = Module["_GetInfo"](this.nativeFile);
|
||||
if (!_info)
|
||||
return false;
|
||||
|
||||
|
||||
var _pages = Module["HEAP32"][_info >> 2];
|
||||
var _buffer = new Int32Array(Module["HEAP8"].buffer, _info, 1 + 3 * _pages);
|
||||
|
||||
|
||||
var _cur = 1;
|
||||
for (var i = 0; i < _pages; i++)
|
||||
{
|
||||
@ -143,7 +146,7 @@
|
||||
"Dpi" : _buffer[_cur++]
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
this.free(_info);
|
||||
return this.pages.length > 0;
|
||||
};
|
||||
@ -152,8 +155,8 @@
|
||||
Module["_Close"](this.nativeFile);
|
||||
this.nativeFile = 0;
|
||||
this.pages = [];
|
||||
if (this.stream > 0)
|
||||
Module["_free"](this.stream);
|
||||
if (this.stream > 0)
|
||||
Module["_free"](this.stream);
|
||||
this.stream = -1;
|
||||
};
|
||||
|
||||
@ -180,27 +183,27 @@
|
||||
|
||||
this.pages[pageIndex].Lines = [];
|
||||
var buffer = new Uint8Array(Module["HEAP8"].buffer, glyphs + 4, len);
|
||||
var reader = new CBinaryReader(buffer, 0, len);
|
||||
|
||||
var Line = -1;
|
||||
while (reader.isValid())
|
||||
var reader = new CBinaryReader(buffer, 0, len);
|
||||
|
||||
var Line = -1;
|
||||
while (reader.isValid())
|
||||
{
|
||||
var rec = {};
|
||||
rec["word"] = reader.readString();
|
||||
if (this.type == 2)
|
||||
{
|
||||
rec["x"] = 1.015 * reader.readDouble();
|
||||
rec["y"] = 1.015 * reader.readDouble();
|
||||
}
|
||||
if (this.type == 2)
|
||||
{
|
||||
rec["x"] = 1.015 * reader.readDouble();
|
||||
rec["y"] = 1.015 * reader.readDouble();
|
||||
}
|
||||
else
|
||||
{
|
||||
rec["x"] = reader.readDouble();
|
||||
rec["y"] = reader.readDouble();
|
||||
}
|
||||
{
|
||||
rec["x"] = reader.readDouble();
|
||||
rec["y"] = reader.readDouble();
|
||||
}
|
||||
rec["w"] = reader.readDouble();
|
||||
rec["h"] = reader.readDouble();
|
||||
|
||||
Line++;
|
||||
|
||||
Line++;
|
||||
this.pages[pageIndex].Lines.push({ Glyphs : [] });
|
||||
for (let i = 0; i < _Word.length; i++)
|
||||
{
|
||||
@ -236,15 +239,15 @@
|
||||
var rec = {};
|
||||
rec["link"] = reader.readString();
|
||||
if (this.type == 2)
|
||||
{
|
||||
rec["x"] = 1.015 * reader.readDouble();
|
||||
rec["y"] = 1.015 * reader.readDouble();
|
||||
}
|
||||
{
|
||||
rec["x"] = 1.015 * reader.readDouble();
|
||||
rec["y"] = 1.015 * reader.readDouble();
|
||||
}
|
||||
else
|
||||
{
|
||||
rec["x"] = reader.readDouble();
|
||||
rec["y"] = reader.readDouble();
|
||||
}
|
||||
{
|
||||
rec["x"] = reader.readDouble();
|
||||
rec["y"] = reader.readDouble();
|
||||
}
|
||||
rec["w"] = reader.readDouble();
|
||||
rec["h"] = reader.readDouble();
|
||||
res.push(rec);
|
||||
@ -273,21 +276,21 @@
|
||||
var rec = {};
|
||||
rec["page"] = reader.readInt();
|
||||
rec["level"] = reader.readInt();
|
||||
if (this.type == 2)
|
||||
{
|
||||
rec["y"] = reader.readDouble();
|
||||
}
|
||||
if (this.type == 2)
|
||||
{
|
||||
rec["y"] = reader.readDouble();
|
||||
}
|
||||
else
|
||||
{
|
||||
rec["y"] = reader.readInt();
|
||||
}
|
||||
{
|
||||
rec["y"] = reader.readInt();
|
||||
}
|
||||
rec["description"] = reader.readString();
|
||||
res.push(rec);
|
||||
}
|
||||
|
||||
Module["_free"](str);
|
||||
return res;
|
||||
};
|
||||
};
|
||||
|
||||
CFile.prototype.memory = function()
|
||||
{
|
||||
@ -297,193 +300,7 @@
|
||||
{
|
||||
Module["_free"](pointer);
|
||||
};
|
||||
CFile.prototype.isValid = function()
|
||||
{
|
||||
return this.pages.length > 0;
|
||||
};
|
||||
CFile.prototype.getPage = function(pageIndex, width, height)
|
||||
{
|
||||
if (pageIndex < 0 || pageIndex >= this.pages.length)
|
||||
return null;
|
||||
if (!width) width = this.pages[pageIndex].W;
|
||||
if (!height) height = this.pages[pageIndex].H;
|
||||
var t0 = performance.now();
|
||||
var pixels = this.getPagePixmap(pageIndex, width, height);
|
||||
if (!pixels)
|
||||
return null;
|
||||
|
||||
if (!this.logging)
|
||||
{
|
||||
var image = this._pixelsToCanvas(pixels, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
};
|
||||
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);
|
||||
}
|
||||
};
|
||||
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;
|
||||
};
|
||||
window["AscViewer"]["CDrawingFile"] = CFile;
|
||||
|
||||
})(window, undefined);
|
||||
|
||||
@ -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