From ddudouit at clio.ch Wed Apr 1 09:42:25 2015 From: ddudouit at clio.ch (Damien Dudouit) Date: Wed, 1 Apr 2015 11:42:25 +0200 Subject: Canvas : 2 pixel thick line width Message-ID: Hello, I'm using a Canvas to display some content (mostly text with lines also for underline). I've just noticed something that is a big problem for me : with line-width=1 and no scaling, actual line-width on display takes 2 pixels. Canvas canvas = new Canvas(300, 300); GraphicsContext gc = canvas.getGraphicsContext2D(); gc.setStroke(Color.BLACK); gc.setLineWidth(1); gc.strokeLine(10, 10, 110, 10); I'm running Win7 64bits and I have made the test with Oracle jdk8_40 and jdk7_71 and the result is the same. That 2 pixel thick line is not perfectly black but dark gray. If I do 'gc.setLineWidth(2)', then I get a 2 pixel thick line perfectly black. If I do 'gc.setLineWidth(0.5)', then I get a 2 pixel thick line with a lighter gray. I want to display underline text in the canvas and a 2 pixel thick underline looks bad. Any help would be greatly appreciated. Damien From ddudouit at clio.ch Wed Apr 1 10:14:15 2015 From: ddudouit at clio.ch (Damien Dudouit) Date: Wed, 1 Apr 2015 12:14:15 +0200 Subject: Canvas : 2 pixel thick line width In-Reply-To: References: Message-ID: Hello, I have found the following answer : http://stackoverflow.com/questions/27846659/how-to-draw-an-1-pixel-line-using-javafx-canvas *Imagine each pixel as a (small) rectangle (instead of a point). The integer coordinates are the boundaries between pixels; so a (horizontal or vertical) line with integer coordinates falls "between pixels". This is rendered via antialising, approximating half of the line on one pixel and half on the other. Moving the line 0.5 pixels left or right moves it to the center of the pixel, getting around the issue.* I have done quite a bit of custom controls drawing (canvas) with swing and swt and it's quite a shift of approach that plain coordinates to not match pixels on display. In swing/swt, if I want to draw a rectangle from pixel (0,0) to pixel (2,2), ie. a square of 3x3 pixels I do : gc.drawRectangle(0, 0, 3, 3); // x, y, width, height In JavaFX I must do : gc.strokeRect(0.5, 0.5, 2, 2) Have a good day, Damien 2015-04-01 11:42 GMT+02:00 Damien Dudouit : > Hello, > > I'm using a Canvas to display some content (mostly text with lines also > for underline). > > I've just noticed something that is a big problem for me : with > line-width=1 and no scaling, actual line-width on display takes 2 pixels. > > Canvas canvas = new Canvas(300, 300); > GraphicsContext gc = canvas.getGraphicsContext2D(); > gc.setStroke(Color.BLACK); > gc.setLineWidth(1); > gc.strokeLine(10, 10, 110, 10); > > I'm running Win7 64bits and I have made the test with Oracle jdk8_40 and > jdk7_71 and the result is the same. > > That 2 pixel thick line is not perfectly black but dark gray. > If I do 'gc.setLineWidth(2)', then I get a 2 pixel thick line perfectly > black. > If I do 'gc.setLineWidth(0.5)', then I get a 2 pixel thick line with a > lighter gray. > > I want to display underline text in the canvas and a 2 pixel thick > underline looks bad. > > Any help would be greatly appreciated. > > Damien > From tomas.mikula at gmail.com Wed Apr 1 17:44:30 2015 From: tomas.mikula at gmail.com (Tomas Mikula) Date: Wed, 1 Apr 2015 13:44:30 -0400 Subject: How to tell if KEY_PRESSED comes with a corresponding KEY_TYPED? Message-ID: On character input, two events are fired: KEY_PRESSED and KEY_TYPED. When my control is interested in the characters, KEY_TYPED should be handled, because it contains the entered Unicode characters. In that case, however, I would also like to consume the corresponding KEY_PRESSED event, so that it does not bubble up the scene graph. A user reported an instance of this problem with my RichTextFX control placed inside a ScrollPane: when spacebar was pressed, a space was inserted in the text area *and* the ScrollPane scrolled down. This happened because RichTextFX handled the KEY_TYPED event, but let the KEY_PRESSED bubble up and ScrollPane handled the KEY_PRESSED event. I can fix the above case by RichTextFX consuming KEY_PRESSED events whose key code isLetterKey(), isDigitKey() or isWhitespaceKey(), but it is not a general solution: it would still not work if ScrollPane used e.g. '[' and ']' to scroll up and down. My question is, is there a general solution for this kind of problem? Given a KEY_PRESSED event, being able to tell whether there is a corresponding KEY_TYPED event generated would solve the problem, but it is currently not possible AFAIK. Regards, Tomas From krueger at lesspain.de Wed Apr 1 19:23:18 2015 From: krueger at lesspain.de (=?UTF-8?Q?Robert_Kr=C3=BCger?=) Date: Wed, 1 Apr 2015 21:23:18 +0200 Subject: Media API question regarding metadata retrieval Message-ID: Hi, I was a bit surprised that the metadata retrieval functionality of javafx.scene.media.Media is only usable in conjunction with a player, so if I want to retrieve the dimensions of a video file I have to instantiate a player and wait for it to reach ready state? That's how I read the javadoc. Is this a misunderstanding? If not is there a specific reason not to offer this functionality independently of a player? Best regards, Robert From david.dehaven at oracle.com Wed Apr 1 19:48:55 2015 From: david.dehaven at oracle.com (David DeHaven) Date: Wed, 1 Apr 2015 12:48:55 -0700 Subject: Media API question regarding metadata retrieval In-Reply-To: References: Message-ID: > I was a bit surprised that the metadata retrieval functionality > of javafx.scene.media.Media is only usable in conjunction with a player, so > if I want to retrieve the dimensions of a video file I have to instantiate > a player and wait for it to reach ready state? That's how I read the > javadoc. Is this a misunderstanding? Nope, currently you have to create a player. Once a player is created it kicks off a parser to grab metadata or waits for the underlying native player to parse. > If not is there a specific reason not > to offer this functionality independently of a player? There were plans, there were also issues as we don't have a Java based mp4 parser so we're relying on the underlying platforms (e.g. QTKit, AVFoundation, etc..) to provide that data, which basically means we're creating a player at the native level anyways. If you're using the horribly outdated FXM format you get the benefit of a Java based parser, but honestly, who's using that these days? -DrD- From swpalmer at gmail.com Wed Apr 1 20:50:44 2015 From: swpalmer at gmail.com (Scott Palmer) Date: Wed, 1 Apr 2015 16:50:44 -0400 Subject: Media API question regarding metadata retrieval In-Reply-To: References: Message-ID: I seems like a decent compromise to defer to the native platform code that will ultimately be used to process the file anyway. It seems a little heavy, but the alternative is perhaps bloating the JavaFX API. It likely makes more sense to use the MediaInfo project with some JNA bindings (you can probably find either JNI or JNA bindings on the web) if you need access to the metadata: https://mediaarea.net/nn/MediaInfo I keep thinking a pure java port of MediaInfo would be cool... but probably not worth the time :-) Scott On Wed, Apr 1, 2015 at 3:48 PM, David DeHaven wrote: > > > I was a bit surprised that the metadata retrieval functionality > > of javafx.scene.media.Media is only usable in conjunction with a player, > so > > if I want to retrieve the dimensions of a video file I have to > instantiate > > a player and wait for it to reach ready state? That's how I read the > > javadoc. Is this a misunderstanding? > > Nope, currently you have to create a player. Once a player is created it > kicks off a parser to grab metadata or waits for the underlying native > player to parse. > > > > If not is there a specific reason not > > to offer this functionality independently of a player? > > There were plans, there were also issues as we don't have a Java based mp4 > parser so we're relying on the underlying platforms (e.g. QTKit, > AVFoundation, etc..) to provide that data, which basically means we're > creating a player at the native level anyways. If you're using the horribly > outdated FXM format you get the benefit of a Java based parser, but > honestly, who's using that these days? > > -DrD- > > From Fabrizio.Giudici at tidalwave.it Thu Apr 2 00:05:33 2015 From: Fabrizio.Giudici at tidalwave.it (Fabrizio Giudici) Date: Thu, 02 Apr 2015 02:05:33 +0200 Subject: Media API question regarding metadata retrieval In-Reply-To: References: Message-ID: On Wed, 01 Apr 2015 22:50:44 +0200, Scott Palmer wrote: > I seems like a decent compromise to defer to the native platform code > that > will ultimately be used to process the file anyway. It seems a little > heavy, but the alternative is perhaps bloating the JavaFX API. > > It likely makes more sense to use the MediaInfo project with some JNA > bindings (you can probably find either JNI or JNA bindings on the web) if > you need access to the metadata: > https://mediaarea.net/nn/MediaInfo > > I keep thinking a pure java port of MediaInfo would be cool... but > probably > not worth the time :-) There are some pure Java media parsers around; the problem is that one should check whether they are complete, that is whether they support all the kinds of media one needs. For instance, at the moment I'm using Jaudiotagger. -- Fabrizio Giudici - Java Architect @ Tidalwave s.a.s. "We make Java work. Everywhere." http://tidalwave.it/fabrizio/blog - fabrizio.giudici at tidalwave.it From krueger at lesspain.de Thu Apr 2 07:23:09 2015 From: krueger at lesspain.de (=?UTF-8?Q?Robert_Kr=C3=BCger?=) Date: Thu, 2 Apr 2015 09:23:09 +0200 Subject: Media API question regarding metadata retrieval In-Reply-To: References: Message-ID: On Wed, Apr 1, 2015 at 9:48 PM, David DeHaven wrote: > > > I was a bit surprised that the metadata retrieval functionality > > of javafx.scene.media.Media is only usable in conjunction with a player, > so > > if I want to retrieve the dimensions of a video file I have to > instantiate > > a player and wait for it to reach ready state? That's how I read the > > javadoc. Is this a misunderstanding? > > Nope, currently you have to create a player. Once a player is created it > kicks off a parser to grab metadata or waits for the underlying native > player to parse. > > > > If not is there a specific reason not > > to offer this functionality independently of a player? > > There were plans, there were also issues as we don't have a Java based mp4 > parser so we're relying on the underlying platforms (e.g. QTKit, > AVFoundation, etc..) to provide that data, which basically means we're > creating a player at the native level anyways. If you're using the horribly > outdated FXM format you get the benefit of a Java Deferring to native code absolutely makes sense but I didn't think that you needed to create a player to obtain duration, width and height in AVFoundation either. From krueger at lesspain.de Thu Apr 2 07:33:31 2015 From: krueger at lesspain.de (=?UTF-8?Q?Robert_Kr=C3=BCger?=) Date: Thu, 2 Apr 2015 09:33:31 +0200 Subject: Media API question regarding metadata retrieval In-Reply-To: References: Message-ID: On Wed, Apr 1, 2015 at 10:50 PM, Scott Palmer wrote: > I seems like a decent compromise to defer to the native platform code that > will ultimately be used to process the file anyway. It seems a little > heavy, but the alternative is perhaps bloating the JavaFX API. > > Yes absolutely but ... (see my reply to David). > It likely makes more sense to use the MediaInfo project with some JNA > bindings (you can probably find either JNI or JNA bindings on the web) if > you need access to the metadata: > https://mediaarea.net/nn/MediaInfo > > Yes, also agreed for real general-purpose metadata retrieval like in a broadcast or media converter product, it does not make sense to kick off such a huge project in Java, when there is already native code around for that and we are doing that already in one of our products using JNI. I am talking about the super-simple cases where I am fine with the (very limited) format support of JavaFX and I just want to know duration, width and height basically for those files and I do not want to ship native libs with my cross-platform app which otherwise works well enough with pure Java. I just don't see any technical reason to instantiate a player for that in any native framework I know and it should not be necessary in JavaFX IMHO. Of course I can wrap all that in my own library and probably will and then the fact that a player is instantiated and then thrown away is just an implementation detail, I just did not and still do not see why this is necessary or sensible, which is why I asked. > I keep thinking a pure java port of MediaInfo would be cool... but > probably not worth the time :-) > > Yes, I agree and it's doable but A LOT of work (if you want to have the level of completeness and maturity of MediaInfo) and therefore not likely to happen anytime soon. From elina.kleyman at oracle.com Thu Apr 2 13:42:37 2015 From: elina.kleyman at oracle.com (Elina Kleyman) Date: Thu, 2 Apr 2015 06:42:37 -0700 (PDT) Subject: [8u60] Review request: RT-40184 - Remove use of internal classes methods from samples Message-ID: <222f4a6a-5e6c-4c42-b0b0-8d4b59be9b8f@default> Hi Kevin, Chien, Please review fix for https://javafx-jira.kenai.com/browse/RT-40184 Link to webrev: http://cr.openjdk.java.net/~ekleyman/RT-40184/ Thanks, Elina From david.dehaven at oracle.com Thu Apr 2 16:16:23 2015 From: david.dehaven at oracle.com (David DeHaven) Date: Thu, 2 Apr 2015 09:16:23 -0700 Subject: Media API question regarding metadata retrieval In-Reply-To: References: Message-ID: > > If not is there a specific reason not > > to offer this functionality independently of a player? > > There were plans, there were also issues as we don't have a Java based mp4 parser so we're relying on the underlying platforms (e.g. QTKit, AVFoundation, etc..) to provide that data, which basically means we're creating a player at the native level anyways. If you're using the horribly outdated FXM format you get the benefit of a Java > > Deferring to native code absolutely makes sense but I didn't think that you needed to create a player to obtain duration, width and height in AVFoundation either. No, but for the lack of a separate interface for metadata retrieval. In hindsight there were a number of things that should have been done differently :/ -DrD- From krueger at lesspain.de Thu Apr 2 16:24:43 2015 From: krueger at lesspain.de (=?UTF-8?Q?Robert_Kr=C3=BCger?=) Date: Thu, 2 Apr 2015 18:24:43 +0200 Subject: Media API question regarding metadata retrieval In-Reply-To: References: Message-ID: On Thu, Apr 2, 2015 at 6:16 PM, David DeHaven wrote: > > > > If not is there a specific reason not > > > to offer this functionality independently of a player? > > > > There were plans, there were also issues as we don't have a Java based > mp4 parser so we're relying on the underlying platforms (e.g. QTKit, > AVFoundation, etc..) to provide that data, which basically means we're > creating a player at the native level anyways. If you're using the horribly > outdated FXM format you get the benefit of a Java > > > > Deferring to native code absolutely makes sense but I didn't think that > you needed to create a player to obtain duration, width and height in > AVFoundation either. > > No, but for the lack of a separate interface for metadata retrieval. In > hindsight there were a number of things that should have been done > differently :/ > > Alright, understood. No offense intended btw.. Thanks for taking the time to explain! From david.dehaven at oracle.com Thu Apr 2 16:27:51 2015 From: david.dehaven at oracle.com (David DeHaven) Date: Thu, 2 Apr 2015 09:27:51 -0700 Subject: Media API question regarding metadata retrieval In-Reply-To: References: Message-ID: > > > If not is there a specific reason not > > > to offer this functionality independently of a player? > > > > There were plans, there were also issues as we don't have a Java based mp4 parser so we're relying on the underlying platforms (e.g. QTKit, AVFoundation, etc..) to provide that data, which basically means we're creating a player at the native level anyways. If you're using the horribly outdated FXM format you get the benefit of a Java > > > > Deferring to native code absolutely makes sense but I didn't think that you needed to create a player to obtain duration, width and height in AVFoundation either. > > No, but for the lack of a separate interface for metadata retrieval. In hindsight there were a number of things that should have been done differently :/ > > > Alright, understood. No offense intended btw.. Thanks for taking the time to explain! None taken! :) Happy to help when I can. -DrD- From james.graham at oracle.com Thu Apr 2 22:49:56 2015 From: james.graham at oracle.com (Jim Graham) Date: Thu, 02 Apr 2015 15:49:56 -0700 Subject: Canvas : 2 pixel thick line width In-Reply-To: References: Message-ID: <551DC794.70609@oracle.com> Hi Damien, The main problem is that the definition of a stroked path and the definition of a filled path are at odds. If the default stroke width is 1.0 and the default stroke type is "CENTERED", then the stroke is centered on the outline of a path and half of it falls on either side of the outline. For those defaults, if you have the coordinates at pixel centers then integer coordinate fills end up with fuzzy sides (and basic rectangle fills are the most common operation in any system) even though that may help stroked lines and paths. If you have the coordinates at pixel edges then integer fills are nice and crisp and you then only need to adjust for stroked shapes. (Note that on a retina screen with 2x pixels you get both crisp fills and strokes either way, so all hail the new HiDPI world. ;) For non-AA rendering you actually don't get any fuzziness since only whole pixels are included or not, but you do have the phenomenon of coordinate stability. If you compute an outline and you are off by just a few rounding bits and your coordinates are at the same location as your sampling points then your shape shifts. If the coordinates are halfway between the sampling points then a few bits of rounding will not affect the shape. Our default is center of pixel sampling, as it is with most rendering systems, so having integer coordinates halfway between them (i.e. at the edges of pixels) makes sense for non-AA. Java2D has a concept called "stroke control" which applies some rounding process to all coordinates so as to help them end up creating crisper outlines, but it has its drawbacks - particularly in the fact that it fights your ability to have a nice round circle or oval since this concept of shifting points fights the exact geometry involved in the control points of "perfectly round" shapes. When we were first creating FX we decided that: - stroke control created some problems that we'd like to avoid even if it does provide some security for new programmers - the vast majority of control styling was shifting to using concentric filled backgrounds rather than strokes so the fact that default strokes can be fuzzy was a non-issue for the controls team - we introduced the concepts of inner and outer strokes which play better with outlining controls than the typical graphics library's default of centered strokes and they have similar needs of where integer coordinates should be placed to avoid fuzziness as fills do - it is time to advance this issue to an exposed one where developers will need to be cognizant of our rasterization rules and stroke geometries to render correctly. This should be documented better, though. That much is true... ...jim On 4/1/15 3:14 AM, Damien Dudouit wrote: > Hello, > > I have found the following answer : > > http://stackoverflow.com/questions/27846659/how-to-draw-an-1-pixel-line-using-javafx-canvas > > *Imagine each pixel as a (small) rectangle (instead of a point). The > integer coordinates are the boundaries between pixels; so a (horizontal or > vertical) line with integer coordinates falls "between pixels". This is > rendered via antialising, approximating half of the line on one pixel and > half on the other. Moving the line 0.5 pixels left or right moves it to the > center of the pixel, getting around the issue.* > > > I have done quite a bit of custom controls drawing (canvas) with swing and > swt and it's quite a shift of approach that plain coordinates to not match > pixels on display. > > In swing/swt, if I want to draw a rectangle from pixel (0,0) to pixel > (2,2), ie. a square of 3x3 pixels I do : > gc.drawRectangle(0, 0, 3, 3); // x, y, width, height > > In JavaFX I must do : > gc.strokeRect(0.5, 0.5, 2, 2) > > Have a good day, > > Damien > > 2015-04-01 11:42 GMT+02:00 Damien Dudouit : > >> Hello, >> >> I'm using a Canvas to display some content (mostly text with lines also >> for underline). >> >> I've just noticed something that is a big problem for me : with >> line-width=1 and no scaling, actual line-width on display takes 2 pixels. >> >> Canvas canvas = new Canvas(300, 300); >> GraphicsContext gc = canvas.getGraphicsContext2D(); >> gc.setStroke(Color.BLACK); >> gc.setLineWidth(1); >> gc.strokeLine(10, 10, 110, 10); >> >> I'm running Win7 64bits and I have made the test with Oracle jdk8_40 and >> jdk7_71 and the result is the same. >> >> That 2 pixel thick line is not perfectly black but dark gray. >> If I do 'gc.setLineWidth(2)', then I get a 2 pixel thick line perfectly >> black. >> If I do 'gc.setLineWidth(0.5)', then I get a 2 pixel thick line with a >> lighter gray. >> >> I want to display underline text in the canvas and a 2 pixel thick >> underline looks bad. >> >> Any help would be greatly appreciated. >> >> Damien >> From james.graham at oracle.com Thu Apr 2 23:13:51 2015 From: james.graham at oracle.com (Jim Graham) Date: Thu, 02 Apr 2015 16:13:51 -0700 Subject: Canvas performance on Mac OS In-Reply-To: <50c9b8ad2824e658caac6730f73fa931.squirrel@excalibur.xssl.net> References: <5515C483.9030901@oracle.com> <55199E52.9090503@oracle.com> <9AA17C6D-2B5D-407A-A6F5-164221C05483@gmail.com> <50c9b8ad2824e658caac6730f73fa931.squirrel@excalibur.xssl.net> Message-ID: <551DCD2F.8080900@oracle.com> On my retina MBP (10.8) I get 60fps for es2 and 44fps for sw. Are you running a newer version of MacOS? ...jim On 3/31/15 3:40 PM, Chris Newland wrote: > Hi Herv?, > > That's a valid question :) > > Probably because > > a) All my non-UI graphics experience is with immediate-mode / raster systems > > b) I'm interested in using JavaFX for particle effects / demoscene / > gaming so assumed (perhaps wrongly?) that scenegraph was not the way to go > for that due to the very large number of nodes. > > Numbers for my Sierpinski filled triangle example: > > System: 2011 iMac Core i7 3.4GHz / 20GB RAM / AMD Radeon HD 6970M 1024 MB > > java -Dprism.order=es2 -cp target/classes/ > com.chrisnewland.demofx.standalone.Sierpinski > fps: 1 > fps: 23 > fps: 18 > fps: 25 > fps: 18 > fps: 23 > fps: 23 > fps: 19 > fps: 25 > > java -Dprism.order=sw -cp target/classes/ > com.chrisnewland.demofx.standalone.Sierpinski > fps: 1 > fps: 54 > fps: 60 > fps: 60 > fps: 60 > fps: 60 > fps: 60 > fps: 60 > fps: 60 > fps: 60 > fps: 60 > > There are never more than 2500 filled triangles on screen. JDK is 1.8.0_40 > > I would say there is a performance problem here? (or at least a need for > documentation so as to set expectations for gc.fillPolygon). > > Best regards, > > Chris > > > > > On Tue, March 31, 2015 22:00, Herv?? Girod wrote: >> Why don't you use Nodes rather than Canvas ? >> >> >> Sent from my iPhone >> >> >>> On Mar 31, 2015, at 22:31, Chris Newland >>> wrote: >>> >>> >>> Hi Jim, >>> >>> >>> Thanks, that makes things much clearer. >>> >>> >>> I was surprised how much was going on under the hood of GraphicsContext >>> and hoped it was just magic glue that gave the best of GPU >>> acceleration where available and immediate-mode-like simple rasterizing >>> where not. >>> >>> I've managed to find an anomaly with GraphicsContext.fillPolygon where >>> the software pipeline achieves the full 60fps but ES2 can only manage >>> 30-35fps. It uses lots of overlapping filled triangles so I expect >>> suffers from the problem you've described. >>> >>> SSCCE: >>> https://github.com/chriswhocodes/DemoFX/blob/master/src/main/java/com/ch >>> risnewland/demofx/standalone/Sierpinski.java >>> >>> Was full frame rate canvas drawing an expected use case for JavaFX or >>> would I be better off with Graphics2D? >>> >>> Thanks, >>> >>> >>> Chris >>> >>> >>>> On Mon, March 30, 2015 20:04, Jim Graham wrote: >>>> Hi Chris, >>>> >>>> >>>> >>>> drawLine() is a very simple primitive that can be optimized with a >>>> GPU >>>> shader. It either looks like a (potentially rotated) rectangle or a >>>> rounded rect - and we have optimized shaders for both cases. A large >>>> number of drawLine() calls turns into simply accumulating a large >>>> vertex list and uploading it to the GPU with an appropriate shader >>>> which is very fast. >>>> >>>> drawPolygon() is a very complex operation that involves things like: >>>> >>>> - dealing with line joins between segments that don't exist for >>>> drawLine() - dealing with only rendering common points of intersection >>>> once >>>> >>>> To handle all of that complexity we have to involve a rasterizer that >>>> takes the entire collection of lines, analyzes the stroke attributes >>>> and interactions and computes a coverage mask for each pixel in the >>>> region. We do that in software currently for all pipelines. >>>> >>>> For the ES2 pipeline Line.v.Poly is dominated by pure GPU vs CPU path >>>> rasterization. >>>> >>>> For the SW pipeline, drawLine is a simplified case of drawPolygon and >>>> so the overhead of lots of calls to drawLine() dominates its >>>> performance. >>>> >>>> I would expect ES2 to blow the SW pipeline out of the water with >>>> drawLine() performance (as long as there are no additional rendering >>>> primitives interspersed in the set of lines). >>>> >>>> But, both should be on the same footing for the drawPolygon case. >>>> Does >>>> the ES2 pipeline compare similarly (hopefully better than) the SW >>>> pipeline for the polygon case? >>>> >>>> One thing I noticed is that we have no optimized case for drawLine() >>>> on the SW pipeline. It generates a path containing a single MOVETO >>>> and LINETO and feeds it to the generalized path rasterizer when it >>>> could instead compute the rounded/square rectangle and render it more >>>> directly. If we added that support then I'd expect the SW pipeline to >>>> perform the set of drawLine calls faster than drawPolygon as well... >>>> >>>> ...jim >>>> >>>> >>>> >>>>> On 3/28/15 3:22 AM, Chris Newland wrote: >>>>> >>>>> >>>>> Hi Robert, >>>>> >>>>> >>>>> >>>>> I've not filed a Jira yet as I was hoping to find time to >>>>> investigate thoroughly but when I saw your question I thought I'd >>>>> better add my findings. >>>>> >>>>> I believe the issue is in the ES2Pipeline as if I run with >>>>> -Dprism.order=sw then strokePolygon outperforms the series of >>>>> strokeLine commands as expected: >>>>> >>>>> java -cp target/DemoFX.jar -Dprism.order=sw >>>>> com.chrisnewland.demofx.DemoFXApplication -c 500 -m line Result: >>>>> 44fps >>>>> >>>>> >>>>> >>>>> java -cp target/DemoFX.jar -Dprism.order=sw >>>>> com.chrisnewland.demofx.DemoFXApplication -c 500 -m poly Result: >>>>> 60fps >>>>> >>>>> >>>>> >>>>> Will see if I can find the root cause as I've got plenty more >>>>> examples where ES2Pipeline performs horribly on my Mac which should >>>>> have no problem throwing around a few thousand polys. >>>>> >>>>> I realise there's a *lot* of indirection involved in making JavaFX >>>>> support such a wide range of underlying graphics systems but I do >>>>> think there's a bug here. >>>>> >>>>> Will file a Jira if I can contribute a bit more than "feels slow" >>>>> ;) >>>>> >>>>> >>>>> >>>>> Cheers, >>>>> >>>>> >>>>> >>>>> Chris >>>>> >>>>> >>>>> >>>>>> On Sat, March 28, 2015 10:06, Robert Kr??ger wrote: >>>>>> >>>>>> >>>>>> This is consistent with what I am observing. Is this something >>>>>> that Oracle >>>>>> is aware of? Looking at Jira, I don't see that anyone is working >>>>>> on this: >>>>>> >>>>>> >>>>>> >>>>>> https://javafx-jira.kenai.com/issues/?jql=status%20in%20(Open%2C% >>>>>> 20%2 >>>>>> 2In% >>>>>> 20Progress%22%2C%20Reopened)%20AND%20labels%20in%20(macosx)%20%20A >>>>>> ND%2 >>>>>> 0la >>>>>> bels%20in%20(performance) >>>>>> >>>>>> Given that one of the One of the main reasons to use JFX for me >>>>>> is to be able to develop with one code base for at least OSX and >>>>>> Windows and >>>>>> the official statement what JavaFX is for, i.e. >>>>>> >>>>>> "JavaFX is a set of graphics and media packages that enables >>>>>> developers to design, create, test, debug, and deploy rich client >>>>>> applications that operate consistently across diverse platforms" >>>>>> >>>>>> and the fact that this is clearly not the case currently (8u40) >>>>>> as soon as I do something else than simple forms, I run into >>>>>> performance/quality problems on the Mac, I am a bit unsure what >>>>>> to make of all that. Is Mac OSX a second-class citizen as far as >>>>>> dev resources are concerned? >>>>>> >>>>>> Tobi and Chris, have you filed Jira Issues on Mac graphics >>>>>> performance that can be tracked? >>>>>> >>>>>> I will file an issue with a simple test case and hope for the >>>>>> best. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Fri, Mar 27, 2015 at 11:08 PM, Chris Newland >>>>>> >>>>>> wrote: >>>>>> >>>>>> >>>>>> >>>>>> >>>>>>> Possibly related: >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> I can reproduce a massive (90%) performance drop on OSX between >>>>>>> drawing a wireframe polygon on a Canvas using a series of >>>>>>> gc.strokeLine(double x1, double y1, double x2, double y2) >>>>>>> commands versus using a single gc.strokePolygon(double[] >>>>>>> xPoints, double[] yPoints, int count) command. >>>>>>> >>>>>>> Creating the polygons manually with strokeLine() is >>>>>>> significantly faster using the ES2Pipeline on OSX. >>>>>>> >>>>>>> This is reproducible in a little GitHub JavaFX benchmarking >>>>>>> project I've >>>>>>> created: https://github.com/chriswhocodes/DemoFX >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> Build with ant >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> Run with: >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> # use strokeLine >>>>>>> ./run.sh -c 5000 -m line >>>>>>> result: 60 (sixty) fps >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> # use strokePolygon >>>>>>> ./run.sh -c 5000 -m poly >>>>>>> result: 6 (six) fps >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> System is 2011 iMac 27" / Mavericks / 3.4GHz Core i7 / 20GB RAM >>>>>>> / >>>>>>> Radeon >>>>>>> 6970M 1024MB >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> Looking at the code paths in >>>>>>> javafx.scene.canvas.GraphicsContext: >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> gc.strokeLine() maps to writeOp4(x1, y1, x2, y2, >>>>>>> NGCanvas.STROKE_LINE) >>>>>>> >>>>>>> >>>>>>> >>>>>>> gc.strokePolygon() maps to writePoly(xPoints, yPoints, nPoints, >>>>>>> true, NGCanvas.STROKE_PATH) which involves significantly more >>>>>>> work with adding to and flushing a GrowableDataBuffer. >>>>>>> >>>>>>> I've not had time to dig any deeper than this but it's surely a >>>>>>> bug when building a poly manually is 10x faster than using the >>>>>>> convenience method. >>>>>>> >>>>>>> Cheers, >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> Chris >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Fri, March 27, 2015 21:26, Tobias Bley wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>>> In my opinion the whole graphics performance on MacOSX >>>>>>>> isn????????t good at all with JavaFX???????. >>>>>>>> >>>>>>>> >>>>>>>>> Am 27.03.2015 um 22:10 schrieb Robert Kr????ger >>>>>>>>> : >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> The bad full screen performance is without the arcs. It is >>>>>>>>> just one call to fillRect, two to strokeOval and one to >>>>>>>>> fillOval, that's all. I will build a simple test case and >>>>>>>>> file an issue. >>>>>>>>> >>>>>>>>> On Fri, Mar 27, 2015 at 9:58 PM, Jim Graham >>>>>>>>> >>>>>>>>> wrote: >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>>> Hi Robert, >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Please file a Jira issue with a simple test case. Arcs >>>>>>>>>> are handled as a generalized shape rather than via a >>>>>>>>>> predetermined shader, but it shouldn't be that slow. >>>>>>>>>> Something else may >>>>>>>>>> be going on. >>>>>>>>>> >>>>>>>>>> Another test might be to replace the arcs with rectangles >>>>>>>>>> or ellipses and see if the performance changes... >>>>>>>>>> >>>>>>>>>> ...jim >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 3/27/15 1:52 PM, Robert Kr????ger wrote: >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>>> Hi, >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> I have a super-simple animation implemented using >>>>>>>>>>> AnimationTimer >>>>>>>>>>> and Canvas where the canvas just performs a few draw >>>>>>>>>>> operations, i.e. fills the screen with a color and then >>>>>>>>>>> draws and fills 2-3 circles and I have already >>>>>>>>>>> observed that each drawing operation I add, results in >>>>>>>>>>> significant CPU load (e.g. when I draw < 10 arcs in >>>>>>>>>>> addition to the circles, the CPU load goes up to 30-40% >>>>>>>>>>> on a Mac Book Pro >>>>>>>>>>> for a Canvas size of 600x600(!). >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Now I tested the animation in full screen mode (only >>>>>>>>>>> with a few circles) and playback is unusable for a >>>>>>>>>>> serious application (very choppy). Is 2D canvas >>>>>>>>>>> performance known to be very bad on Mac or >>>>>>>>>>> am I doing something wrong? Are there workarounds for >>>>>>>>>>> this? >>>>>>>>>>> >>>>>>>>>>> Thanks, >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Robert >>>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Robert Kr????ger >>>>>>>>> Managing Partner >>>>>>>>> Lesspain GmbH & Co. KG >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> www.lesspain-software.com >>>>>> >>>>>> >>>>>> -- >>>>>> Robert Kr??ger >>>>>> Managing Partner >>>>>> Lesspain GmbH & Co. KG >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> www.lesspain-software.com >>> >>> >> > > From peter.penzov at gmail.com Fri Apr 3 13:46:48 2015 From: peter.penzov at gmail.com (Peter Penzov) Date: Fri, 3 Apr 2015 16:46:48 +0300 Subject: Change BarChart Legend color Message-ID: Hi All, I have a question about changing dynamically the color of the BarChart. I'm using this code to change the chart Label for now successfully: Legend legend = (Legend) schart.lookup(".chart-legend"); Legend.LegendItem li1 = new Legend.LegendItem("Over 8", new Rectangle(10, 4, Color.NAVY)); Legend.LegendItem li2 = new Legend.LegendItem("Over 5 up to 8", new Rectangle(10, 4, Color.FIREBRICK)); Legend.LegendItem li3 = new Legend.LegendItem("Below 5", new Rectangle(10, 4, Color.ORANGE)); legend.getItems().setAll(li1, li2, li3); But Label is from the internal package com.sun.javafx.charts.Legend and I may have problems into the next JVM versions. Is there other way to change BarChart label colors. Please refer to this link for more information: http://stackoverflow.com/questions/29121687/change-color-in-barchart-legend Also are there any plans to make Label public package? BR, Peter From vadim.pakhnushev at oracle.com Fri Apr 3 14:37:59 2015 From: vadim.pakhnushev at oracle.com (Vadim Pakhnushev) Date: Fri, 03 Apr 2015 17:37:59 +0300 Subject: In(Sanity) Testing Mondays Message-ID: <551EA5C7.5060402@oracle.com> Reminder, Monday is our weekly sanity testing. You can find your testing assignment at: https://wiki.openjdk.java.net/display/OpenJFX/Sanity+Testing Also please remember that the repo will be locked from 1am PST until 1pm PST. Happy testing! Thanks, Vadim From tbee at tbee.org Fri Apr 3 17:48:15 2015 From: tbee at tbee.org (Tom Eugelink) Date: Fri, 03 Apr 2015 19:48:15 +0200 Subject: Debugging CSS Message-ID: <551ED25F.4070902@tbee.org> I'm pushing the envelope a bit -I think- concerning the use of CSS. I have setup a control (gauge) in such a way that, depending on the position of the needle, certain CSS classes are added or removed from the control. For example a "errorSegment-active" class if the value comes into the 90-100 value in a 0-100 gauge. In this class a CSS variable -fx-error-indicator-visibility is set to "visible" and that again shows some kind of indicator on the gauge. Works great. What is strange is when this class is assigned to the control, a totally unrelated node (the value in the needle) suddenly moves out of position. I do not understand this, because the CSS only involves colors and visibility, never any transformation. https://github.com/JFXtras/jfxtras-labs/blob/8.0/src/main/resources/jfxtras/labs/internal/scene/control/gauge/linear/SimpleMetroArcGauge.css Is there any way to debug what CSS settings are applied to nodes? I really would like to find out what causes that node to move. Tom From tbee at tbee.org Fri Apr 3 18:13:05 2015 From: tbee at tbee.org (Tom Eugelink) Date: Fri, 03 Apr 2015 20:13:05 +0200 Subject: Debugging CSS In-Reply-To: <551ED25F.4070902@tbee.org> References: <551ED25F.4070902@tbee.org> Message-ID: <551ED831.4000904@tbee.org> One addition: the move happens if, for example, "segment0-active" is added to the skinnable. Even if that class is empty or even not defined in the CSS. Tom On 3-4-2015 19:48, Tom Eugelink wrote: > I'm pushing the envelope a bit -I think- concerning the use of CSS. I have setup a control (gauge) in such a way that, depending on the position of the needle, certain CSS classes are added or removed from the control. For example a "errorSegment-active" class if the value comes into the 90-100 value in a 0-100 gauge. In this class a CSS variable -fx-error-indicator-visibility is set to "visible" and that again shows some kind of indicator on the gauge. Works great. > > What is strange is when this class is assigned to the control, a totally unrelated node (the value in the needle) suddenly moves out of position. I do not understand this, because the CSS only involves colors and visibility, never any transformation. > https://github.com/JFXtras/jfxtras-labs/blob/8.0/src/main/resources/jfxtras/labs/internal/scene/control/gauge/linear/SimpleMetroArcGauge.css > > Is there any way to debug what CSS settings are applied to nodes? I really would like to find out what causes that node to move. > > Tom From david.grieve at oracle.com Fri Apr 3 20:19:34 2015 From: david.grieve at oracle.com (David Grieve) Date: Fri, 03 Apr 2015 16:19:34 -0400 Subject: Debugging CSS In-Reply-To: <551ED831.4000904@tbee.org> References: <551ED25F.4070902@tbee.org> <551ED831.4000904@tbee.org> Message-ID: <551EF5D6.8090107@oracle.com> When you add or remove style-classes, CSS for the node (and all its children) is totally re-calculated. This means that cached data for that node is tossed out and the node is styled from scratch, as if it were just added to the scene-graph. You are much better off using pseudo-class state for what you are trying to do. Changes in pseudo-class state just causes evaluation of what styles are applied in that state, which is relatively low overhead compared to re-calculating styles. To debug, you should try using Scenic View (http://fxexperience.com/scenic-view/) You can also use the Node API Map,List