diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-13 17:44:21 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-13 17:45:20 -0800 |
commit | e657c74773dfa7834a0e56fd895649df15593d97 (patch) | |
tree | c34b36d8cb4a94c2b8c4d00060e8f1374049ef19 /src | |
parent | d46071bcb61b555a51ee985c8b38e621a956bafa (diff) | |
parent | f7dd2645ee157a60cce28cb7db9327728699d544 (diff) |
Merge branch 'incoming' into asm_js
Diffstat (limited to 'src')
-rw-r--r-- | src/library_gl.js | 5 | ||||
-rw-r--r-- | src/parseTools.js | 22 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index 6927c3ec..e9e93b93 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -2100,6 +2100,11 @@ var LibraryGL = { }, glColor4f: function(r, g, b, a) { + r = Math.max(Math.min(r, 1), 0); + g = Math.max(Math.min(g, 1), 0); + b = Math.max(Math.min(b, 1), 0); + a = Math.max(Math.min(a, 1), 0); + // TODO: make ub the default, not f, save a few mathops if (GL.immediate.mode) { var start = GL.immediate.vertexCounter << 2; diff --git a/src/parseTools.js b/src/parseTools.js index 45d3d862..1ef09f49 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1410,7 +1410,27 @@ function makePointer(slab, pos, allocator, type, ptr) { types = de[0]; } } - return 'allocate(' + slab + ', ' + JSON.stringify(types) + (allocator ? ', ' + allocator : '') + (allocator == 'ALLOC_NONE' ? ', ' + ptr : '') + ')'; + // JS engines sometimes say array initializers are too large. Work around that by chunking and calling concat to combine at runtime + var chunkSize = 10240; + function chunkify(array) { + // break very large slabs into parts + var ret = ''; + var index = 0; + while (index < array.length) { + ret = (ret ? ret + '.concat(' : '') + '[' + array.slice(index, index + chunkSize).map(JSON.stringify) + ']' + (ret ? ')' : ''); + index += chunkSize; + } + return ret; + } + if (typeof slab == 'string' && evaled && evaled.length > chunkSize) { + slab = chunkify(evaled); + } + if (typeof types != 'string' && types.length > chunkSize) { + types = chunkify(types); + } else { + types = JSON.stringify(types); + } + return 'allocate(' + slab + ', ' + types + (allocator ? ', ' + allocator : '') + (allocator == 'ALLOC_NONE' ? ', ' + ptr : '') + ')'; } function makeGetSlabs(ptr, type, allowMultiple, unsigned) { |