Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Re-Initialization of Canvas/GC in RAP
Re-Initialization of Canvas/GC in RAP [message #765514] Wed, 14 December 2011 03:21 Go to next message
Jiri Sliva is currently offline Jiri Sliva
Messages: 3
Registered: October 2010
Junior Member
Hello,
I found out strange behavior of RAP for drawing into Canvas.

Each update of Canvas (draw new graphic element from asyncExec) causes re-initialization of JS canvas (set size and clean canvas content).
For example: repeated call of following code:

display.asyncExec(new Runnable() {
public void run() {
final GC gc = new GC(canvas);
gc.drawLine(x, 0, x, 100);
gc.dispose();
}
});
Where x is changed each time will produce only ONE line on canvas in same time.
Doesn't matter if GC is created once or repeatly.

RAP's class CGOperationsWriter produces following JS code:

var wm = org.eclipse.swt.WidgetManager.getInstance();
var w = wm.findWidgetById( "w3" );
var gc = w.getGC();
gc.init( 468, 430, "14px Verdana, 'Lucida Sans', Arial, Helvetica, sans-serif", "#ffffff", "#4a4a4a" );
gc.drawLine( ... )
And there is init method from GC.js

init : qx.core.Variant.select( "qx.client", {
"mshtml" : function( width, height, font, background, foreground ) {
// TODO [tb]: Should the control be detached from the DOM
// (e.g. by Widget.prepareEnhancedBorder), this might lead to glitches
// in IE/VML. The flush prevents this in some cases:
qx.ui.core.Widget.flushGlobalQueues();
this._initTextCanvas( width, height );
this._context.clearRect( 0, 0, width, height );
this._initFields( font, background, foreground );
},
"default" : function( width, height, font, background, foreground ) {
this._initTextCanvas( width, height );
this._canvas.width = width;
this._canvas.style.width = width + "px";
this._canvas.height = height;
this._canvas.style.height = height + "px";
this._context.clearRect( 0, 0, width, height );
this._initFields( font, background, foreground );
}
} ),
Call of this._canvas.width = width; is enough to reset/clean content of JS canvas (I have tried to remove only call of this._context.clearRect( 0, 0, width, height ); but this didn't help).

We have to avoid add this call (init) into each drawing JS code generated by RAP.


var wm = org.eclipse.swt.WidgetManager.getInstance();
var w = wm.findWidgetById( "w3" );
var gc = w.getGC();
// -- removed -- gc.init( 468, 430, "14px Verdana, 'Lucida Sans', Arial, Helvetica, sans-serif", "#ffffff", "#4a4a4a" );
gc.drawLine( ... )

Before I enter this into RAP bugs I want to ask you. Do you know what is purpose of this behavior?
With this is impossible to make additional drawings into canvas (which is possible in SWT).

Thanks for any comment.
Re: Re-Initialization of Canvas/GC in RAP [message #765520 is a reply to message #765514] Wed, 14 December 2011 03:39 Go to previous message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1690
Registered: July 2009
Senior Member
Hi Jiri,
this is a known limitation of the current GC implementation in RAP.
Drawing in IE is implemented with VML. Our tests show that above 500 VML
shapes the performance of the IE *became extreamly slow. *That's why we
have to clear (init) the GC with every drawing (request). Anyway, please
file an enhancement request to allow continues drawing without
reinitialization.
Best,
Ivan

On 12/14/2011 10:21 AM, Jiri Sliva wrote:
> Hello,
> I found out strange behavior of RAP for drawing into Canvas.
>
> Each update of Canvas (draw new graphic element from asyncExec) causes
> re-initialization of JS canvas (set size and clean canvas content).
> For example: repeated call of following code:
>
> display.asyncExec(new Runnable() {
> public void run() {
> final GC gc = new GC(canvas);
> gc.drawLine(x, 0, x, 100);
> gc.dispose();
> }
> });
> Where x is changed each time will produce only ONE line on canvas in
> same time.
> Doesn't matter if GC is created once or repeatly.
>
> RAP's class CGOperationsWriter produces following JS code:
>
> var wm = org.eclipse.swt.WidgetManager.getInstance();
> var w = wm.findWidgetById( "w3" );
> var gc = w.getGC();
> gc.init( 468, 430, "14px Verdana, 'Lucida Sans', Arial, Helvetica,
> sans-serif", "#ffffff", "#4a4a4a" );
> gc.drawLine( ... )
> And there is init method from GC.js
>
> init : qx.core.Variant.select( "qx.client", {
> "mshtml" : function( width, height, font, background, foreground ) {
> // TODO [tb]: Should the control be detached from the DOM //
> (e.g. by Widget.prepareEnhancedBorder), this might lead to glitches
> // in IE/VML. The flush prevents this in some cases:
> qx.ui.core.Widget.flushGlobalQueues();
> this._initTextCanvas( width, height );
> this._context.clearRect( 0, 0, width, height );
> this._initFields( font, background, foreground );
> },
> "default" : function( width, height, font, background, foreground ) {
> this._initTextCanvas( width, height );
> this._canvas.width = width;
> this._canvas.style.width = width + "px";
> this._canvas.height = height;
> this._canvas.style.height = height + "px";
> this._context.clearRect( 0, 0, width, height );
> this._initFields( font, background, foreground );
> }
> } ),
> Call of this._canvas.width = width; is enough to reset/clean content
> of JS canvas (I have tried to remove only call of
> this._context.clearRect( 0, 0, width, height ); but this didn't help).
> We have to avoid add this call (init) into each drawing JS code
> generated by RAP.
>
>
> var wm = org.eclipse.swt.WidgetManager.getInstance();
> var w = wm.findWidgetById( "w3" );
> var gc = w.getGC();
> // -- removed -- gc.init( 468, 430, "14px Verdana, 'Lucida Sans',
> Arial, Helvetica, sans-serif", "#ffffff", "#4a4a4a" );
> gc.drawLine( ... )
>
> Before I enter this into RAP bugs I want to ask you. Do you know what
> is purpose of this behavior? With this is impossible to make
> additional drawings into canvas (which is possible in SWT).
>
> Thanks for any comment.
Previous Topic:Re-Initialization of Canvas/GC in RAP
Next Topic:RAP View toolbar automatically shut off the line?
Goto Forum:
  


Current Time: Thu Apr 17 08:49:01 EDT 2014

Powered by FUDForum. Page generated in 0.03099 seconds