Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

weex-gcanvas

Package Overview
Dependencies
Maintainers
4
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

weex-gcanvas - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

39

gcanvas.js

@@ -25,3 +25,2 @@ /**

var GImage = require('./gcanvasimage.js');
var GBridge = require("./gutil").GBridge;

@@ -97,3 +96,2 @@ var GLog = require("./gutil").GLog;

var _context = null;
var renderImpl = null;
var _context_type = 0;//0--2d;1--webgl

@@ -150,6 +148,6 @@ ///////////////////////////////

}else{
GCanvasPlatform = 2;
GCanvasPlatform = 2;
}
console.log(GCanvasPlatform);
GBridge.setup({'platform': GCanvasPlatform});
console.log('GCanvasPlatform = ' + GCanvasPlatform);
succ();

@@ -200,3 +198,3 @@ /*

startLoop: function(fps, callback){
startLoop: function(fps){
if(!_context){

@@ -207,23 +205,5 @@ GLog.d('context not initialize. call setContextType first');

console.log()
var numOfArgs = arguments.length;
var _fps = 16;
console.log("numOfArgs =====> " + numOfArgs);
if(numOfArgs === 2){
_fps = parseFloat(fps) || 16;
this.renderImpl = callback;
}else if( numOfArgs === 1){
console.log("fps =====> " + fps + ", typeof ===> " + (typeof fps));
if(typeof fps === 'function'){
renderImpl = fps;
console.log("setup renderImpl =====> " + renderImpl + ", typeof ===> " + (typeof renderImpl));
}else{
_fps = parseFloat(fps) || 16;
}
}
fps = parseFloat(fps) || 16;
if(!_context.timer){
console.log("_context.timer start!!!!!!!!!!!!!!!!");
_context.timer = setInterval(this.render.bind(this), _fps);
_context.timer = setInterval(this.render.bind(this),fps);
}

@@ -238,3 +218,2 @@ },

stopLoop: function(){
console.log('====================stopLoop');
if(!_context){

@@ -245,3 +224,2 @@ return;

if(_context.timer){
console.log('====================cleartimer');
clearInterval(_context.timer);

@@ -252,5 +230,6 @@ _context.timer = null;

render: function(){
render: function(cb){
console.log(_context);
// GLog.d('[GCanvas::render] start...');
_context.render("auto", GCanvasPlatform, renderImpl);
_context.render("auto", GCanvasPlatform, cb);
},

@@ -257,0 +236,0 @@

@@ -6,4 +6,2 @@ var GBridge = require("./gutil").GBridge;

var GCanvasImage = require("./gcanvasimage");
function GContext2D() {

@@ -67,3 +65,2 @@ this._drawCommands = "";

function maintainPicurlToTextureidMap(e) {
console.log("maintainPicurlToTextureidMap======");
if(!_hashmap){

@@ -85,14 +82,4 @@ return;

if (e.url){
var image = new GCanvasImage();
console.log(JSON.stringify(image));
image.width = parseInt(e.width) || 0;
console.log("width ===================== ");
image.height = parseInt(e.height) || 0;
console.log("height ===================== ");
image.id = e.id;
console.log("id ===================== ");
image._id = e.id;
console.log("_id ===================== ");
//GLog.d("GContext2D maintainPicurlToTextureidMap map " + e.url + " to " + e.id);
_hashmap.put(e.url, image);
_hashmap.put(e.url, e.id);
}

@@ -514,2 +501,3 @@ }

successCallback && successCallback(e);
}else{

@@ -675,92 +663,58 @@ GLog.d("GContext2D loadTexture errorCallback!");

GContext2D.prototype._drawAndroidImage = function(numArgs, image, // image
GContext2D.prototype.drawImage = function(image, // image
sx, sy, sw, sh, // source (or destination if fewer args)
dx, dy, dw, dh){
var imageInfo = _hashmap.get(image);
dx, dy, dw, dh) { // destination
// if(textureId == null){
// GBridge.preLoadImage(image, maintainPicurlToTextureidMap);
// }else{
var that = this;
var preloadImgCallback = function(e){
if(!e){
return;
//GLog.d("[GContext2D.drawImage] start...");
if (typeof image !== 'string') {
image = image.src;
}
maintainPicurlToTextureidMap(e);
that._concatDrawCmd(numArgs, image, sx, sy, sw, sh, dx, dy, dw, dh);
};
//GLog.d("[GContext2D.drawImage] start... image: " + image);
// }
if(imageInfo == null){
GBridge.preLoadImage(image, preloadImgCallback);
}else{
GLog.d("[GContext2D.drawImage] image is cached, pass");
this._concatDrawCmd(numArgs, image, sx, sy, sw, sh, dx, dy, dw, dh);
}
};
var textureId = _hashmap.get(image);
GContext2D.prototype._drawIOSImage = function(numArgs, image,
sx, sy, sw, sh,// source (or destination if fewer args)
dx, dy, dw, dh){
GBridge.preLoadImage(image);
this._drawCommands += ("d" + numArgs + "," + image + ","
+ sx + "," + sy + "," + sw + "," + sh + ","
+ dx + "," + dy + "," + dw + "," + dh + ";");
};
// if(textureId == null){
// GBridge.preLoadImage(image, maintainPicurlToTextureidMap);
// }else{
GContext2D.prototype._concatDrawCmd = function(numArgs, image,
sx, sy, sw, sh, // source (or destination if fewer args)
dx, dy, dw, dh){// destination
var imageInfo = _hashmap.get(image);
if(!imageInfo){
return;
}
// }
if(numArgs === 3){
var x = parseFloat(sx) || 0;
var y = parseFloat(sy) || 0;
this._drawCommands += ("d" + imageInfo.id + ", 0, 0,"
+ imageInfo.width + "," + imageInfo.height + ","
+ x + "," + y + "," + imageInfo.width + "," + imageInfo.height + ";");
}else if(numArgs === 5){
var x = parseFloat(sx) || 0;
var y = parseFloat(sy) || 0;
var width = parseInt(sw) || imageInfo.width;
var height = parseInt(sh) || imageInfo.heiht;
this._drawCommands += ("d" + imageInfo.id + ", 0, 0,"
+ imageInfo.width + "," + imageInfo.height + ","
+ x + "," + y + "," + width + "," + height + ";");
}else if(numArgs === 9){
var sx = parseFloat(sx) || 0;
var sy = parseFloat(sy) || 0;
var sw = parseInt(sw) || imageInfo.width;
var sh = parseInt(sh) || imageInfo.heiht;
var dx = parseFloat(dx) || 0;
var dy = parseFloat(dy) || 0;
var dw = parseInt(dw) || imageInfo.width;
var dy = parseInt(dy) || imageInfo.height;
this._drawCommands += ("d" + imageInfo.id + ","
+ sx + "," + sy + "," + sw + "," + sh + ","
+ dx + "," + dy + "," + dw + "," + dh + ";");
}
};
var preloadCb = function(e){
maintainPicurlToTextureidMap(e);
textureId = _hashmap.get(image);
concatDrawCmd(textureId);
}
GContext2D.prototype.drawImage = function(image, // image
sx, sy, sw, sh, // source (or destination if fewer args)
dx, dy, dw, dh) { // destination
if (typeof image !== 'string') {
image = image.src;
}
//GLog.d("[GContext2D.drawImage] start...");
var that = this;
var concatDrawCmd = function(id){
var numArgs = arguments.length;
if( textureId == null ){
that._drawCommands += ("d" + numArgs + "," + image + ","
+ sx + "," + sy + "," + sw + "," + sh + ","
+ dx + "," + dy + "," + dw + "," + dh + ";");
//GLog.d("[GContext2D.drawImage] start... image: " + image);
var that = this;
var numArgs = arguments.length;
if(GBridge.isIOS()){
that._drawIOSImage(numArgs, image, sx, sy, sw, sh, dx, dy, dw, dh);
}else{
that._drawCommands += ("d" + textureId + ","
+ sx + "," + sy + "," + sw + "," + sh + ","
+ dx + "," + dy + "," + dw + "," + dh + ";");
}
console.log('===========================' + that._drawCommands);
GLog.d('[GContext2D.drawImage]===========================' + that._drawCommands);
}
if(textureId == null){
GBridge.preLoadImage(image, preloadCb);
}else{
that._drawAndroidImage(numArgs, image, sx, sy, sw, sh, dx, dy, dw, dh);
GLog.d("[GContext2D.drawImage] image is cached, pass");
concatDrawCmd(textureId);
}
/*

@@ -767,0 +721,0 @@ this._drawCommands += ("d" + numArgs + "," + image + ","

@@ -8,3 +8,2 @@ /////////////////////////////////////////////////////////////////

var debug = true;
var platform;
var canvasModule;

@@ -18,13 +17,5 @@

canvasModule= (typeof weex!=='undefined' && weex.requireModule) ? weex.requireModule('gcanvas'):__weex_require__('@weex-module/gcanvas');
canvasModule=typeof weex!=='undefined'&&weex.requireModule?weex.requireModule('gcanvas'):__weex_require__('@weex-module/gcanvas');
var GBridge = {
setup: function(data){
platform = data.platform;
},
isIOS: function(){
return platform === 1;
},
/**执行render指令*/

@@ -77,3 +68,4 @@ callRender: function (commands) {

e.url = src;
GLog.d('bridge#preLoadImage() callback, e ' + JSON.stringify(e));
GLog.d('bridge#callcb()');
//GLog.d('bridge#preLoadImage() callback, e ' + JSON.stringify(e));
cb && cb(e);

@@ -113,3 +105,3 @@ });

var params = {
};

@@ -116,0 +108,0 @@ canvasModule.disable(params, function(e){

{
"name": "weex-gcanvas",
"version": "1.0.0",
"version": "1.0.1",
"main":"gcanvas.js",

@@ -5,0 +5,0 @@ "platform": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc