Skip to main content


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 08:21 Go to next message
Jiri Sliva is currently offline Jiri SlivaFriend
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 08:39 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
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: Fri Apr 26 12:44:13 GMT 2024

Powered by FUDForum. Page generated in 0.03699 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top