UNPKG

wonder.js

Version:
112 lines (104 loc) 6.23 kB
'use strict'; var Caml_option = require("bs-platform/lib/js/caml_option.js"); var Log$WonderLog = require("wonder-log/lib/js/src/Log.js"); var Contract$WonderLog = require("wonder-log/lib/js/src/Contract.js"); var StateDataMain$Wonderjs = require("../../../../main/data/StateDataMain.js"); var IsDebugMainService$Wonderjs = require("../../../../main/state/IsDebugMainService.js"); var TextureTypeService$Wonderjs = require("../../../../../primitive/texture/TextureTypeService.js"); var TextureWrapService$Wonderjs = require("../../../../../primitive/texture/TextureWrapService.js"); var TextureFormatService$Wonderjs = require("../../../../../primitive/texture/TextureFormatService.js"); var TextureSourceMapService$Wonderjs = require("../../../../../primitive/texture/TextureSourceMapService.js"); var UpdateTextureRenderService$Wonderjs = require("../../UpdateTextureRenderService.js"); var UpdateGLTextureRenderService$Wonderjs = require("../../UpdateGLTextureRenderService.js"); var BufferArrayBufferViewSourceTextureService$Wonderjs = require("../../../../../record/main/texture/source/arrayBufferView_source/BufferArrayBufferViewSourceTextureService.js"); var OperateTypeArrayAllArrayBufferViewSourceTextureService$Wonderjs = require("../../../../../record/all/texture/source/arrayBufferView_source/OperateTypeArrayAllArrayBufferViewSourceTextureService.js"); function _drawTexture(gl, param, param$1) { var height = param$1[1]; var width = param$1[0]; var glFormat = param[3]; Contract$WonderLog.requireCheck((function (param) { return Contract$WonderLog.test(Log$WonderLog.buildAssertMessage("width/height shouldn\'t be 0", "width is " + (String(width) + ("; height is " + (String(height) + "")))), (function (param) { Contract$WonderLog.Operators[/* <>= */3](width, 0); return Contract$WonderLog.Operators[/* <>= */3](height, 0); })); }), IsDebugMainService$Wonderjs.getIsDebug(StateDataMain$Wonderjs.stateData)); gl.texImage2D(param[0], param[1], glFormat, width, height, 0, glFormat, param[4], param[2]); return /* () */0; } function _drawTwoDTexture(gl, param, sizeTuple, source) { return _drawTexture(gl, /* tuple */[ param[0], 0, source, param[1], param[2] ], sizeTuple); } function _allocateSourceToTexture(sizeTuple, gl, paramTuple, source) { return _drawTwoDTexture(gl, paramTuple, sizeTuple, source); } function update(gl, param, param$1) { var arrayBufferViewSourceTextureRecord = param$1[0]; var browserDetectRecord = param$1[1]; var textureInTypeArray = param[1]; var match = TextureSourceMapService$Wonderjs.getSource(param[0], arrayBufferViewSourceTextureRecord[/* sourceMap */10]); if (match !== undefined) { var width = OperateTypeArrayAllArrayBufferViewSourceTextureService$Wonderjs.getWidth(textureInTypeArray, arrayBufferViewSourceTextureRecord[/* widths */8]); var height = OperateTypeArrayAllArrayBufferViewSourceTextureService$Wonderjs.getHeight(textureInTypeArray, arrayBufferViewSourceTextureRecord[/* heights */9]); var glWrapS = TextureWrapService$Wonderjs.getGlWrap(gl, OperateTypeArrayAllArrayBufferViewSourceTextureService$Wonderjs.getWrapS(textureInTypeArray, arrayBufferViewSourceTextureRecord[/* wrapSs */0])); var glWrapT = TextureWrapService$Wonderjs.getGlWrap(gl, OperateTypeArrayAllArrayBufferViewSourceTextureService$Wonderjs.getWrapT(textureInTypeArray, arrayBufferViewSourceTextureRecord[/* wrapTs */1])); var magFilter = OperateTypeArrayAllArrayBufferViewSourceTextureService$Wonderjs.getMagFilter(textureInTypeArray, arrayBufferViewSourceTextureRecord[/* magFilters */2]); var minFilter = OperateTypeArrayAllArrayBufferViewSourceTextureService$Wonderjs.getMinFilter(textureInTypeArray, arrayBufferViewSourceTextureRecord[/* minFilters */3]); var glFormat = TextureFormatService$Wonderjs.getGlFormat(gl, OperateTypeArrayAllArrayBufferViewSourceTextureService$Wonderjs.getFormat(textureInTypeArray, arrayBufferViewSourceTextureRecord[/* formats */4])); var glType = TextureTypeService$Wonderjs.getGlType(gl, OperateTypeArrayAllArrayBufferViewSourceTextureService$Wonderjs.getType(textureInTypeArray, arrayBufferViewSourceTextureRecord[/* types */5])); var flipY = OperateTypeArrayAllArrayBufferViewSourceTextureService$Wonderjs.isFlipY(textureInTypeArray, arrayBufferViewSourceTextureRecord[/* flipYs */7]); var target = gl.TEXTURE_2D; var partial_arg = /* tuple */[ width, height ]; UpdateGLTextureRenderService$Wonderjs.update(/* tuple */[ gl, textureInTypeArray, Caml_option.valFromOption(match) ], /* tuple */[ width, height, glWrapS, glWrapT, magFilter, minFilter, glFormat, glType, flipY, target, target ], /* tuple */[ arrayBufferViewSourceTextureRecord[/* isNeedUpdates */6], browserDetectRecord ], /* tuple */[ (function (param, param$1, param$2) { return _allocateSourceToTexture(partial_arg, param, param$1, param$2); }), arrayBufferViewSourceTextureRecord[/* setFlipYFunc */12] ]); return /* tuple */[ arrayBufferViewSourceTextureRecord, browserDetectRecord ]; } else { return /* tuple */[ arrayBufferViewSourceTextureRecord, browserDetectRecord ]; } } function isNeedUpdate(textureInTypeArray, arrayBufferViewSourceTextureRecord) { return UpdateTextureRenderService$Wonderjs.isNeedUpdate(textureInTypeArray, BufferArrayBufferViewSourceTextureService$Wonderjs.getDefaultIsNeedUpdate(/* () */0), arrayBufferViewSourceTextureRecord[/* isNeedUpdates */6], OperateTypeArrayAllArrayBufferViewSourceTextureService$Wonderjs.getIsNeedUpdate); } exports._drawTexture = _drawTexture; exports._drawTwoDTexture = _drawTwoDTexture; exports._allocateSourceToTexture = _allocateSourceToTexture; exports.update = update; exports.isNeedUpdate = isNeedUpdate; /* Log-WonderLog Not a pure module */