Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added lots of new methods and modules
- Loading branch information
Showing
21 changed files
with
4,079 additions
and
402 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,71 @@ | |||
/** | |||
* @author Eugene Zatepyakin / http://inspirit.ru/ | |||
*/ | |||
|
|||
(function(global) { | |||
"use strict"; | |||
// | |||
|
|||
var cache = (function() { | |||
|
|||
// very primitive array cache, still need testing if it helps | |||
// of course V8 has its own powerful cache sys but i'm not sure | |||
// it caches several multichannel 640x480 buffer creations each frame | |||
|
|||
var _pool_node_t = (function () { | |||
function _pool_node_t(size_in_bytes) { | |||
this.next = null; | |||
this.size = size_in_bytes|0; | |||
this.buffer = new ArrayBuffer(size_in_bytes); | |||
this.u8 = new Uint8Array(this.buffer); | |||
this.i32 = new Int32Array(this.buffer); | |||
this.f32 = new Float32Array(this.buffer); | |||
} | |||
return _pool_node_t; | |||
})(); | |||
|
|||
var _pool_head, _pool_tail; | |||
var _pool_size = 0; | |||
|
|||
return { | |||
|
|||
allocate: function(capacity, data_size) { | |||
_pool_head = _pool_tail = new _pool_node_t(data_size); | |||
for (var i = 0; i < capacity; ++i) { | |||
var node = new _pool_node_t(data_size); | |||
_pool_tail = _pool_tail.next = node; | |||
|
|||
_pool_size++; | |||
} | |||
}, | |||
|
|||
get_buffer: function(size_in_bytes) { | |||
// assume we have enough free nodes | |||
var node = _pool_head; | |||
_pool_head = _pool_head.next; | |||
_pool_size--; | |||
|
|||
if(size_in_bytes > node.size) { | |||
node.buffer = new ArrayBuffer(size_in_bytes); | |||
node.u8 = new Uint8Array(node.buffer); | |||
node.i32 = new Int32Array(node.buffer); | |||
node.f32 = new Float32Array(node.buffer); | |||
node.size = size_in_bytes; | |||
} | |||
|
|||
return node; | |||
}, | |||
|
|||
put_buffer: function(node) { | |||
_pool_tail = _pool_tail.next = node; | |||
_pool_size++; | |||
} | |||
}; | |||
})(); | |||
|
|||
global.cache = cache; | |||
// for now we dont need more than 30 buffers | |||
// if having cache sys really helps we can add auto extending sys | |||
cache.allocate(30, 640*4); | |||
|
|||
})(jsfeat); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.