[flexcoders] Re: graphics object seems to degrade performance

2008-04-16 Thread Eric Cooper
Is there a way to clock exactly how long the actual drawing to the screen was 
taking? 
I know that profiling tools will show time spent within [pre-render] and 
[render], but I 
wonder if there is some thing that could be done inside my own code. In 
particular, I am 
trying to figure out where time is being spent. I suspect that it is not in 
rendering - but I 
would like to confirm that.
Thanks.
-Eric


 --- In flexcoders@yahoogroups.com, Gordon Smith [EMAIL PROTECTED] wrote:

  Btw, is there any way to inspect the graphics object to see the
 drawing commands that it has?
 
  
 
 Unfortunately, no.
 
  
 
 Gordon Smith
 
 Adobe Flex SDK Team
 
  
 
 
 
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of Eric Cooper
 Sent: Tuesday, April 15, 2008 1:47 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Re: graphics object seems to degrade performance
 
  
 
 Thanks. Yes, that one got me when I first started -- and took me a few
 days to realize what 
 was happening.
 
 Btw, is there any way to inspect the graphics object to see the drawing
 commands that it has? 
 
 --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
 , Alex Harui aharui@ wrote:
 
  Also make sure you are calling graphics.clear() before re-drawing all
 of
  your graphic commands.
 






Re: [flexcoders] Re: graphics object seems to degrade performance

2008-04-16 Thread Daniel Freiman
You could use the getTimer() function.  (It's a function of the flash.utils
package: http://livedocs.adobe.com/flex/201/langref/flash/utils/package.html).
However, that will only tell you the execution time of the code.  I've had
issues with the graphics object where the time it takes to run the code is
shorter than the time it takes the player to render those instructions.  If
that happens it'll probably be pretty obvious if what's going on.

- Daniel Freiman

On Wed, Apr 16, 2008 at 2:54 AM, Eric Cooper [EMAIL PROTECTED] wrote:

   Is there a way to clock exactly how long the actual drawing to the
 screen was taking?
 I know that profiling tools will show time spent within [pre-render] and
 [render], but I
 wonder if there is some thing that could be done inside my own code. In
 particular, I am
 trying to figure out where time is being spent. I suspect that it is not
 in rendering - but I
 would like to confirm that.
 Thanks.
 -Eric


 --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Gordon
 Smith [EMAIL PROTECTED] wrote:
 
   Btw, is there any way to inspect the graphics object to see the
  drawing commands that it has?
 
 
 
  Unfortunately, no.
 
 
 
  Gordon Smith
 
  Adobe Flex SDK Team
 
 
 
  
 
  From: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com [mailto:
 flexcoders@yahoogroups.com flexcoders%40yahoogroups.com] On
  Behalf Of Eric Cooper
  Sent: Tuesday, April 15, 2008 1:47 PM
  To: flexcoders@yahoogroups.com flexcoders%40yahoogroups.com
  Subject: [flexcoders] Re: graphics object seems to degrade performance
 
 
 
  Thanks. Yes, that one got me when I first started -- and took me a few
  days to realize what
  was happening.
 
  Btw, is there any way to inspect the graphics object to see the drawing
  commands that it has?
 
  --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.commailto:
 flexcoders%40yahoogroups.com flexcoders%2540yahoogroups.com
  , Alex Harui aharui@ wrote:
  
   Also make sure you are calling graphics.clear() before re-drawing all
  of
   your graphic commands.
  
 

  



[flexcoders] Re: graphics object seems to degrade performance

2008-04-15 Thread Eric Cooper
I am experiencing performance issues similar to those described in this thread. 
By way of 
background, I am working on a geometry tool that allows the user to create 
points, line 
segments, circles and polygons, to move then about and to create constraints 
between 
them. I am new to ActionScript/Flex/Flash and, perhaps, tainted by other 
languages/frameworks. So, I have subclasses Canvas and it is responsible of 
rendering all 
the geometric shapes. In other words, my geometric shapes do extend 
DisplayObject and 
are *not* in the display list.

As I add more and more shapes (i.e., more than 10), I see that drag performance 
degrades 
rapidly. I am considering adopting Alex's suggestion: generating a bitmap at 
the start of a 
drag (such that the bitmap contains all shapes that are not about to be 
dragged), clearing 
the graphics object, blitting the bitmap and then drawing the object(s) being 
dragged.

I am wondering, though, if I would get this for free if I used DisplayObject 
and the built-
in drag events. I am also wondering, if I am saving that much in terms of 
memory and 
speed, by rolling my own as it were.

Thanks,
-Eric

--- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote:

 It will help some, but you'll still end up with 500,000 vectors spread
 thorough 1000 overlaid shapes.
 
  
 
 In order to handle undo, you would track the vectors in your own array
 of points and take snapshots as I suggested.  I wouldn't even encode as
 png, all you need is one extra bitmapdata.





Re: [flexcoders] Re: graphics object seems to degrade performance

2008-04-15 Thread Tom Chiverton
On Tuesday 15 Apr 2008, Eric Cooper wrote:
 I am wondering, though, if I would get this for free if I used
 DisplayObject and the built- in drag events. I am also wondering, if I am
 saving that much in terms of memory and speed, by rolling my own as it
 were.

I would definetaly use Adobe's to start with, then until or unless some 
problem actually appeared.

-- 
Tom Chiverton
Helping to continually aggregate leading-edge infrastructures
on: http://thefalken.livejournal.com



This email is sent for and on behalf of Halliwells LLP.

Halliwells LLP is a limited liability partnership registered in England and 
Wales under registered number OC307980 whose registered office address is at 
Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB.  A list 
of members is available for inspection at the registered office. Any reference 
to a partner in relation to Halliwells LLP means a member of Halliwells LLP.  
Regulated by The Solicitors Regulation Authority.

CONFIDENTIALITY

This email is intended only for the use of the addressee named above and may be 
confidential or legally privileged.  If you are not the addressee you must not 
read it and must not use any information contained in nor copy it nor inform 
any person other than Halliwells LLP or the addressee of its existence or 
contents.  If you have received this email in error please delete it and notify 
Halliwells LLP IT Department on 0870 365 2500.

For more information about Halliwells LLP visit www.halliwells.com.



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [flexcoders] Re: graphics object seems to degrade performance

2008-04-15 Thread Troy Gilbert
  I am wondering, though, if I would get this for free if I used
 DisplayObject and the built-
  in drag events. I am also wondering, if I am saving that much in terms of
 memory and
  speed, by rolling my own as it were.

If you make each draggable item (each shape) its own DisplayObject
then yes, you'll get some optimizations for free, such as bitmap
caching. You'll also get the benefit of the fact that the drawing
loop is at least written in native code (the display list), and may
even have some additional optimizations helping you depending on your
specific dataset (dirty rectangle lists, etc.).

Finally, by making each object a DisplayObject instead of managing the
shapes yourself, you get a huge amount of features for free, such as
alpha, filters, sort order, scaling, rotation... all those nice,
native things DisplayObjects do.

Troy.


Re: [flexcoders] Re: graphics object seems to degrade performance

2008-04-15 Thread Jon Bradley


On Apr 15, 2008, at 12:23 AM, Eric Cooper wrote:

I am wondering, though, if I would get this for free if I used  
DisplayObject and the built-
in drag events. I am also wondering, if I am saving that much in  
terms of memory and

speed, by rolling my own as it were.


My personal choice was not to use any of the built-in drag event  
stuff for this.


I created my own handler for clicking and 'selecting' or initiating a  
drag or other transform on a display object using transformation  
matrices. Objects extend some base classes that implement an  
interface containing a setTransformation method. Each object can then  
override the capabilities of the transformation that is being applied  
(as a matrix parameter).


I find it pretty weird you run into issues with more than 10 display  
objects. I would imaging you'd have issues with a few hundred or  
thousand, but not low single digits.


If you get to really complex vector shapes dragging can slow down  
quickly because the renderer has to deal with visibility and  
compositing of that complex shape. Bitmap representations here are  
much more efficient, using cacheAsBitmap=true (gotta extend  
movieclip) and have your class that contains the graphics  
automatically handle the drawing of the bitmap into itself. I do this  
with text because animating or moving type in a layered 'canvas' has  
performance and display issues.


My 0.02.

cheers,

jon

RE: [flexcoders] Re: graphics object seems to degrade performance

2008-04-15 Thread Alex Harui
Also make sure you are calling graphics.clear() before re-drawing all of
your graphic commands.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Eric Cooper
Sent: Monday, April 14, 2008 9:23 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: graphics object seems to degrade performance

 

I am experiencing performance issues similar to those described in this
thread. By way of 
background, I am working on a geometry tool that allows the user to
create points, line 
segments, circles and polygons, to move then about and to create
constraints between 
them. I am new to ActionScript/Flex/Flash and, perhaps, tainted by other

languages/frameworks. So, I have subclasses Canvas and it is responsible
of rendering all 
the geometric shapes. In other words, my geometric shapes do extend
DisplayObject and 
are *not* in the display list.

As I add more and more shapes (i.e., more than 10), I see that drag
performance degrades 
rapidly. I am considering adopting Alex's suggestion: generating a
bitmap at the start of a 
drag (such that the bitmap contains all shapes that are not about to be
dragged), clearing 
the graphics object, blitting the bitmap and then drawing the object(s)
being dragged.

I am wondering, though, if I would get this for free if I used
DisplayObject and the built-
in drag events. I am also wondering, if I am saving that much in terms
of memory and 
speed, by rolling my own as it were.

Thanks,
-Eric

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Alex Harui [EMAIL PROTECTED] wrote:

 It will help some, but you'll still end up with 500,000 vectors spread
 thorough 1000 overlaid shapes.
 
 
 
 In order to handle undo, you would track the vectors in your own array
 of points and take snapshots as I suggested. I wouldn't even encode as
 png, all you need is one extra bitmapdata.

 



[flexcoders] Re: graphics object seems to degrade performance

2008-04-15 Thread Eric Cooper
Thanks. Yes, that one got me when I first started -- and took me a few days to 
realize what 
was happening.

Btw, is there any way to inspect the graphics object to see the drawing 
commands that it has? 

--- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote:

 Also make sure you are calling graphics.clear() before re-drawing all of
 your graphic commands.
 





[flexcoders] Re: graphics object seems to degrade performance

2008-04-15 Thread Eric Cooper
Thank, Tom. Perhaps I should have started by extending DisplayObject. At this 
point, that 
would be a bit of a slog. I may end up resorting to that, but would like to try 
other 
avenues first.

--- In flexcoders@yahoogroups.com, Tom Chiverton [EMAIL PROTECTED] wrote:

 On Tuesday 15 Apr 2008, Eric Cooper wrote:
  I am wondering, though, if I would get this for free if I used
  DisplayObject and the built- in drag events. I am also wondering, if I am
  saving that much in terms of memory and speed, by rolling my own as it
  were.
 
 I would definetaly use Adobe's to start with, then until or unless some 
 problem actually appeared.
 
 -- 
 Tom Chiverton
 Helping to continually aggregate leading-edge infrastructures
 on: http://thefalken.livejournal.com
 
 




RE: [flexcoders] Re: graphics object seems to degrade performance

2008-04-15 Thread Gordon Smith
 Btw, is there any way to inspect the graphics object to see the
drawing commands that it has?

 

Unfortunately, no.

 

Gordon Smith

Adobe Flex SDK Team

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Eric Cooper
Sent: Tuesday, April 15, 2008 1:47 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: graphics object seems to degrade performance

 

Thanks. Yes, that one got me when I first started -- and took me a few
days to realize what 
was happening.

Btw, is there any way to inspect the graphics object to see the drawing
commands that it has? 

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Alex Harui [EMAIL PROTECTED] wrote:

 Also make sure you are calling graphics.clear() before re-drawing all
of
 your graphic commands.
 

 



[flexcoders] Re: graphics object seems to degrade performance

2008-04-15 Thread Eric Cooper
Thanks, Troy. 
I am using alpha currently, and think that I will be able to use various matrix 
manipulations when I get there. I 
am drawing to a Canvas. I think that I will be exploring bitmap caching 
shortly. But if it starts looking like I will 
need to manage my own dirty rectangles then I will spend some time extending 
DisplayObject.
-Eric

--- In flexcoders@yahoogroups.com, Troy Gilbert [EMAIL PROTECTED] wrote:

   I am wondering, though, if I would get this for free if I used
  DisplayObject and the built-
   in drag events. I am also wondering, if I am saving that much in terms of
  memory and
   speed, by rolling my own as it were.
 
 If you make each draggable item (each shape) its own DisplayObject
 then yes, you'll get some optimizations for free, such as bitmap
 caching. You'll also get the benefit of the fact that the drawing
 loop is at least written in native code (the display list), and may
 even have some additional optimizations helping you depending on your
 specific dataset (dirty rectangle lists, etc.).
 
 Finally, by making each object a DisplayObject instead of managing the
 shapes yourself, you get a huge amount of features for free, such as
 alpha, filters, sort order, scaling, rotation... all those nice,
 native things DisplayObjects do.
 
 Troy.






[flexcoders] Re: graphics object seems to degrade performance

2008-04-15 Thread Eric Cooper
John,
This is helpful. I am not dealing with complex polygons. Rather, I am dealing 
with triangles and quadrilaterals. I am calling 
out to a C++ server that includes code that helps maintain constraints within 
and between my polygons (e.g., 
perpendicular, concentric, congruence, etc.). This means that every moveBy 
call on a polygon gets sent to the server and 
the server sends back a list of points that have changed position. I suspect 
that much of my slowness is a result of the 
drawing taking a bit longer than the network roundtrip - with the result that a 
backlog of point updates builds up.
I wonder, though, if caching bitmaps for each polygon would speed things up. I 
don't think that I can get away with 
creating a single bitmap of non-dragged polygons because there is a potential 
for interaction between dragged and non-
dragged objects (that's one way that constraints can be made, albeit with 
modifier key).
Thanks.
-Eric

--- In flexcoders@yahoogroups.com, Jon Bradley [EMAIL PROTECTED] wrote:

 
 On Apr 15, 2008, at 12:23 AM, Eric Cooper wrote:
 
  I am wondering, though, if I would get this for free if I used  
  DisplayObject and the built-
  in drag events. I am also wondering, if I am saving that much in  
  terms of memory and
  speed, by rolling my own as it were.
 
 My personal choice was not to use any of the built-in drag event  
 stuff for this.
 
 I created my own handler for clicking and 'selecting' or initiating a  
 drag or other transform on a display object using transformation  
 matrices. Objects extend some base classes that implement an  
 interface containing a setTransformation method. Each object can then  
 override the capabilities of the transformation that is being applied  
 (as a matrix parameter).
 
 I find it pretty weird you run into issues with more than 10 display  
 objects. I would imaging you'd have issues with a few hundred or  
 thousand, but not low single digits.
 
 If you get to really complex vector shapes dragging can slow down  
 quickly because the renderer has to deal with visibility and  
 compositing of that complex shape. Bitmap representations here are  
 much more efficient, using cacheAsBitmap=true (gotta extend  
 movieclip) and have your class that contains the graphics  
 automatically handle the drawing of the bitmap into itself. I do this  
 with text because animating or moving type in a layered 'canvas' has  
 performance and display issues.
 
 My 0.02.
 
 cheers,
 
 jon






[flexcoders] Re: graphics object seems to degrade performance

2008-03-28 Thread dannyvenier
Thanks Alex,

Are you suggesting I choose a point in time, for instance, when 500 
vectors are drawn, then convert them, encode as png file, overlay as 
another child image, clear the graphics object and let user continue 
scribbling on newly cleared graphics object?.

I was planning on doing something similar, based on user control, 
such that they could record layers of annotations but it would work 
as a background automation too, although then I have to worry about 
combining the automatically generated images (not suggested by user) 
to create the annotation layer that they have requested.

--- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote:

 Flash/AIR are vector display list renderers.  If you give it tons of
 vectors to display, it will take a while to render them.  This is 
quite
 different from bitmap renderers like Windows.  There are advantages 
and
 disadvantages to each.
 
  
 
 If I were writing such an app, I would probably take a snapshot 
every
 once in a while and draw on top of the recent snapshot.
 
  
 
 
 
 From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
 Behalf Of dannyvenier
 Sent: Thursday, March 27, 2008 7:19 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] graphics object seems to degrade performance
 
  
 
 Hi,
 I'm writing an AIR app that uses a scribble type component. In a 
 nutshell, just uses the graphics lineTo() method to draw a line 
from 
 the current location to the new position of the mouse on a mouse 
move 
 event.
 
 I have noticed that after scribbling for a bit (maybe 30 seconds), 
 the mouse movement tracking is impaired and my scribbling which 
once 
 resembled smooth circles, starts to look like octagons, hexagons, 
 pentagons...eventually trianglesyou get the picture. The 
 frequency which the application picks up the move events is reduced 
 so the smooth tracking turns to noticable lines. The graphics 
object 
 appears to be bogging down the application and mouse event 
frequency 
 as the number of lines in the graphics object increases. It doesn't 
 take long to degrade.
 
 I tried out the flex profiler and didn't show any significant 
growth 
 in memory over this scribble period. I tried a scrible application 
 from Andy Rayne's scribble board 
 http://weblogs.macromedia.com/arayne/
 http://weblogs.macromedia.com/arayne/  and it behaves exactly the 
same
 
 way. There is no scaling, zooming or manipulation of the graphics 
 lines at all. I'm assuming they're just pushing points onto an 
array 
 but haven't looked into the source to confirm how this type of 
class 
 behaves.
 
 Has anyone experienced this kind of degradation with a graphics 
 object and if so, have you figured out what's going on?





Re: [flexcoders] Re: graphics object seems to degrade performance

2008-03-28 Thread Troy Gilbert
  Are you suggesting I choose a point in time, for instance, when 500
  vectors are drawn, then convert them, encode as png file, overlay as
  another child image, clear the graphics object and let user continue
  scribbling on newly cleared graphics object?.

Reading through this thread reminded me of a similar performance issue
I encountered. I have a component that allows the user to erase parts
of image. I originally implemented this by creating a mask for the
bitmap and drawing on the mask to erase. I ran into the same problem:
the more the user erased, the slower the app got.

I eventually switched to using a bitmap as the mask, but I lost my
nice soft brushes and easy, smooth resizing that the vectors gave me.
In thinking about Alex's suggestion I had a thought (that would help
you as well).

Instead of baking your lines to a bitmap, creating a new shape and
drawing on that, then baking that into your bitmap, repeat... which
has the problem of losing your vectors... could you keep an array (or
rather, a stack) of shape layers, and as the user draws a certain
amount of vectors on that shape (like you said, 500 lines or such),
you push another shape layer on the stack and set the previous shape
layer cacheAsBitmap to true. You'd then get the performance boost of
the bitmap without losing the fidelity of your vectors.

When the user is ready to finalize their drawing, you just start at
the bottom of the stack and draw the shapes into a bitmap at whatever
is the desired final resolution (scaling it up or down as needed).

That should be an excellent trade-off... the only drawback would be if
you were using the vector renderer to draw things that interact with
existing vectors, i.e. using fills with intersections, etc.

Troy.


RE: [flexcoders] Re: graphics object seems to degrade performance

2008-03-28 Thread Alex Harui
It will help some, but you'll still end up with 500,000 vectors spread
thorough 1000 overlaid shapes.

 

In order to handle undo, you would track the vectors in your own array
of points and take snapshots as I suggested.  I wouldn't even encode as
png, all you need is one extra bitmapdata.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Troy Gilbert
Sent: Friday, March 28, 2008 10:36 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: graphics object seems to degrade
performance

 

 Are you suggesting I choose a point in time, for instance, when 500
 vectors are drawn, then convert them, encode as png file, overlay as
 another child image, clear the graphics object and let user continue
 scribbling on newly cleared graphics object?.

Reading through this thread reminded me of a similar performance issue
I encountered. I have a component that allows the user to erase parts
of image. I originally implemented this by creating a mask for the
bitmap and drawing on the mask to erase. I ran into the same problem:
the more the user erased, the slower the app got.

I eventually switched to using a bitmap as the mask, but I lost my
nice soft brushes and easy, smooth resizing that the vectors gave me.
In thinking about Alex's suggestion I had a thought (that would help
you as well).

Instead of baking your lines to a bitmap, creating a new shape and
drawing on that, then baking that into your bitmap, repeat... which
has the problem of losing your vectors... could you keep an array (or
rather, a stack) of shape layers, and as the user draws a certain
amount of vectors on that shape (like you said, 500 lines or such),
you push another shape layer on the stack and set the previous shape
layer cacheAsBitmap to true. You'd then get the performance boost of
the bitmap without losing the fidelity of your vectors.

When the user is ready to finalize their drawing, you just start at
the bottom of the stack and draw the shapes into a bitmap at whatever
is the desired final resolution (scaling it up or down as needed).

That should be an excellent trade-off... the only drawback would be if
you were using the vector renderer to draw things that interact with
existing vectors, i.e. using fills with intersections, etc.

Troy.