Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
84 deletions.
There are no files selected for viewing
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,47 @@ | ||
//var logo = require('./node-png').readPng('./node-logo.png'); | ||
var logo = require('./node-png').readPng('./node-logo.png'); | ||
|
||
var x11 = require('../../lib'); | ||
|
||
var Exposure = x11.eventMask.Exposure; | ||
var KeyPress = x11.eventMask.KeyPress; | ||
var KeyRelease = x11.eventMask.KeyRelease; | ||
var ButtonPress = x11.eventMask.ButtonPress; | ||
var ButtonRelease = x11.eventMask.ButtonRelease; | ||
var PointerMotion = x11.eventMask.PointerMotion; | ||
|
||
var interv = 0; | ||
var total_frames = 0; | ||
var last_frames = 0; | ||
|
||
x11.createClient(function(err, display) | ||
{ | ||
var X = display.client; | ||
X.require('render', function(Render) { | ||
var root = display.screen[0].root; | ||
main(root, X, Render); | ||
}); | ||
}); | ||
|
||
console.log('111111'); | ||
var X = display.client; | ||
X.require('big-requests', function(BigReq) | ||
{ | ||
X.require('render', function(Render) { | ||
X.Render = Render; | ||
BigReq.Enable(function(err, maxLen) | ||
{ | ||
|
||
console.log('222222'); | ||
|
||
var root = display.screen[0].root; | ||
var white = display.screen[0].white_pixel; | ||
var black = display.screen[0].black_pixel; | ||
function main(root, X, Render) { | ||
|
||
var win, picWin, piclogoi, pic; | ||
|
||
|
||
function showpic(path) | ||
{ | ||
|
||
console.log(path); | ||
|
||
pic = require('./node-png').readPng(path); | ||
/* | ||
var d = pic.data; var l = pic.data.length; | ||
for (var p=0; p < l; p+=4) | ||
{ | ||
b = d[p]; | ||
d[p] = d[p+2]; | ||
d[p+2] = b; | ||
} | ||
*/ | ||
|
||
console.log(pic); | ||
win = X.AllocID(); | ||
X.CreateWindow( | ||
win, root, | ||
0, 0, pic.width, pic.height, | ||
0, 0, 0, 0, | ||
{ | ||
backgroundPixel: white, eventMask: Exposure|KeyPress|ButtonPress|PointerMotion | ||
} | ||
); | ||
X.MapWindow(win); | ||
|
||
X.gc = X.AllocID(); | ||
X.CreateGC(X.gc, win); | ||
|
||
//X.PutImage(2, win, X.gc, pic.width, pic.height, 0, 0, 0, 24, pic.data); | ||
//piclogo = X.AllocID(); | ||
//Render.CreatePicture(piclogo, pixmaplogo, Render.rgb24); | ||
//picWin = X.AllocID(); | ||
//Render.CreatePicture(picWin, win, Render.rgb24); | ||
|
||
} | ||
|
||
var win, picWin, pic, gc; | ||
|
||
win = X.AllocID(); | ||
X.CreateWindow( | ||
win, root, | ||
0, 0, logo.width, logo.height, | ||
0, 0, 0, 0, | ||
{ eventMask: Exposure } | ||
); | ||
X.MapWindow(win); | ||
|
||
gc = X.AllocID(); | ||
X.CreateGC(gc, win); | ||
|
||
var logoPixmap = X.AllocID(); | ||
X.CreatePixmap(logoPixmap, win, 24, logo.width, logo.height); | ||
// TODO: add proper png pixel conversion here | ||
X.PutImage(2, logoPixmap, gc, logo.width, logo.height, 0, 0, 0, 24, logo.data); | ||
|
||
var logoPicture = X.AllocID(); | ||
Render.CreatePicture(logoPicture, logoPixmap, Render.rgb24); | ||
var winPicture = X.AllocID(); | ||
Render.CreatePicture(winPicture, win, Render.rgb24); | ||
|
||
showpic(process.argv[2]); | ||
|
||
|
||
X.on('event', function(ev) { | ||
if (ev.type == 12) // expose | ||
{ | ||
X.PutImage(2, win, X.gc, pic.width, pic.height, 0, 0, 0, 24, pic.data); | ||
//Render.Composite(3, piclogo, 0, picWin, 0, 0, 0, 0, 0, 0, logo.width, logo.height); | ||
} | ||
}); | ||
|
||
X.on('error', function(err) { | ||
console.log(err); | ||
}); | ||
|
||
}); | ||
}); | ||
}); | ||
}); | ||
X.on('event', function(ev) { | ||
if (ev.name == 'Expose') | ||
Render.Composite(3, logoPicture, 0, winPicture, 0, 0, 0, 0, 0, 0, logo.width, logo.height); | ||
}); | ||
} |