Performance of the canvas

I've been testing the performance of canvas on a very fast machine (quad core Xeon) by recent NVidia graphics cards, but I am unable to make the video full screen 1920 x 1080 with this configuration using the Web.

It's simply too much hope for or am I missing some obvious performance enhancements?

Here's the code I used:
import java.nio.ByteBuffer;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.image.PixelFormat;
import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritablePixelFormat;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import uk.co.caprica.vlcj.component.DirectMediaPlayerComponent;

import com.sun.jna.Memory;
import com.sun.jna.NativeLibrary;

public class VLCDirectTest extends Application {

  public static void main(final String[] args) {
    Application.launch(args);
  }

  private DirectMediaPlayerComponent mp;

  @Override
  public void start(Stage primaryStage) throws Exception {
    NativeLibrary.addSearchPath("libvlc", "c:/program files (x86)/videolan/vlc");

    BorderPane borderPane = new BorderPane();
    final Canvas canvas = new Canvas(1920, 1080);
    borderPane.setCenter(canvas);
    System.out.println(">>> " + canvas.getGraphicsContext2D().getPixelWriter().getPixelFormat());
    Scene scene = new Scene(borderPane);
    final PixelWriter pixelWriter = canvas.getGraphicsContext2D().getPixelWriter();
    final WritablePixelFormat<ByteBuffer> byteBgraInstance = PixelFormat.getByteBgraInstance();

    mp = new DirectMediaPlayerComponent("RV32", 1920, 1080, 1920*4) {
      @Override
      public void display(Memory nativeBuffer) {
        ByteBuffer byteBuffer = nativeBuffer.getByteBuffer(0, nativeBuffer.size());
        pixelWriter.setPixels(0, 0, 1920, 1080, byteBgraInstance, byteBuffer, 1920*4);
      }
    };

    mp.getMediaPlayer().playMedia("L:\\test-movies\\2012.mkv");

    primaryStage.setScene(scene);
    primaryStage.show();
  }
}
It works, but it hickups and distorts a lot when it hickups. Lower the resolution of 1600 x 900 to say, it is almost smooth. Lowering still gets the expected 24 frames per second.

Try to use IntBuffer, it's get-buffer possible bytes converted per pixel. I think if the pixel format and the width of the scan line corresponds,
System.arraycopy (...) is used instead of a loop / conversion on each pixel. It should be enough to download full HD of 25 frames per second.

There is also no need to use the node of the Web, you can use WritableImage.getImageWriter () .setPixels () with IntBuffer.
It is possible that the canvas node distributes all the draw lots / pixel in the render thread events and copy the array / buffer again.
I'd be curious what performance you get.

And well, I didn't know you could so easily integrate VLC =)

-----

PS:
Oh too bad for me that the WritableImage has a 'ByteBgraPre' (premultiplied) PixelFormat. Then
imgWriter.setPixels (0, 0, w, h, PixelFormat.getByteBgraPreInstance (), pixels.asByteBuffer (), w * 4);
was a little better than:
imgWriter.setPixels (0, 0, w, h, PixelFormat.getByteBgraInstance (), pixels.asByteBuffer (), w * 4);
For opaque, premultiplied images is not serious anyway. I managed to get 45 fps with upload of 1920 x 1200 pixels.

Published by: Fatima Sep 2, 2012 09:34

Tags: Java

Similar Questions

  • What does the option, 2nd right, down the canvas of fresh paint do?

    I do not know how to make it any easier than this.  The first option (circle) reverses the last traces of paint, the next option (circle) put the paint back stroke and the 4th (circle) is to dry the paint on the canvas so your next color will not mix.  I don't know what option 3 (circle) is for.  I tried several times to see what will happen without any result.  A Yes, I know I'll feel stupid when I find, however, someone please tell me.

    I do not know how to make it any easier than this.  The first option (circle) reverses the last traces of paint, the next option (circle) put the paint back stroke and the 4th (circle) is to dry the paint on the canvas so your next color will not mix.  I don't know what option 3 (circle) is for.  I tried several times to see what will happen without any result.  A Yes, I know I'll feel stupid when I find, however, someone please tell me.

    ==========================================
    The following tutorial might be worth a visit:

    Fresh paint allows you to create masterpieces in Windows 8
    http://www.technorms.com/18136/fresh-paint-lets-create-masterpieces-Windows-8

    The following of the tutorial seems to address
    your question:

    ===

    "The bottom of the page also has a small set of menu items.
    From left to right, there is a button undo and redo. Unfortunately
    almost universal Ctrl + Z Undo does not in
    This app so it will be your best friend when painting, as
    We all make mistakes. The middle button is to hide the lines
    image and perform more than one painting of freestyle. Next is a
    fit to window button, so you can quickly zoom out and see the
    image as a whole. Finally, there is a dry button that deploys
    the paint. In this way, you're not autour galling when you
    don't want to - as a tool that you will learn to use a lot. »

    ===

    Also the following FAQ may be useful:

    Fresh paint FAQ
    http://answers.Microsoft.com/en-us/Windows/Forum/windows_8-Winapps/fresh-paint-FAQ/552a7366-fbd2-4b19-a4b8-4021453a4835

  • Rendering of the canvas deteriorates proportionately with the size?

    Can someone explain to me how I can avoid the drop in performance of drawing on a canvas, as its size grows?
    What is the reason for this?

    Run even on a canvas runs more slowly, as the canvas size.

    It also seems that, despite "dirty zone" rendered using JavaFX technology, rendering the scene becomes slower as the size of nodes increases (e.g.: the canvas).
    even if most of it is off-screen. Speed is acceptable when the canvas completely fills my screen size, then the entire screen should already be redrawn.
    but as I increase the size, so the node/canvas already extends outside of the window, made performance continuously decreases as the node expands.

    It is corrected, when setCache (true) is applied.
    However, this does NOT improve drawing performance on the Web, where low latency is essential for a painting application.
    Who seems to be involved, as the documentation advises NOT to Cache, if the node changes frequently.
    Surprisingly then, still cached to True on the Web currently drawn on, more CacheHint = SPEED, seems to improve a little speed.

    Anyway, back to the question: why is based on a painting becomes slower with the size, although the same race, covering the same amount of area, is performed?

    My apologies if I seem confused or repeated myself, I am extremely tired. Thank you in advance and good night.

    It's a beautiful Shindoh descriptive answer.  You have a talent for this sort of thing.

    Reproduce your problem

    Your application does not work even on my machine (Java 8u5, Win 7, 64 bit, ATI Radeon HD 4600), except if I drop the size of the canvas to 8Kx8K (probably because I use an older graphics with capabilities of textures limited).  I drop the size of the canvas, I noticed improvements in performance that outline you, 8 k is really slow to update and pretty unusable at 1 K being quite catchy.

    The exception I get a canvas of 10Kx10K is =>

    java.lang.NullPointerException

    to com.sun.javafx.sg.prism.NGCanvas$ RenderBuf.validate (NGCanvas.java:199)

    at com.sun.javafx.sg.prism.NGCanvas.initCanvas(NGCanvas.java:598)

    at com.sun.javafx.sg.prism.NGCanvas.renderContent(NGCanvas.java:575)

    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2043)

    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1951)

    at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:225)

    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:575)

    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2043)

    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1951)

    at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:469)

    at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:324)

    at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:89)

    to java.util.concurrent.Executors$ RunnableAdapter.call (Executors.java:511)

    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)

    at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

    to java.util.concurrent.ThreadPoolExecutor$ Worker.run (ThreadPoolExecutor.java:617)

    to com.sun.javafx.tk.quantum.QuantumRenderer$ PipelineRunnable.run (QuantumRenderer.java:129)

    at java.lang.Thread.run(Thread.java:745)

    A few suggestions

    10Kx10K is a very large canvas.

    Creation of such a thing is a really a kind of brute force solution.

    I think that you would need to get smarter about manage you such situations.

    In my view, relying on the library to manage the optimization of these paintings is not the way to go.

    Of course, the library can handle OK, but your tests show otherwise, so you'll have to work on a different solution.

    What you can do, is take some knowledge of the specific area of your application to help optimize the use of the canvas so that you can get with a smaller canvas.

    For example, consider the technique involved in the drafting of an engine of tile in JavaFX. It is average for the rendering of graphics games such as Pokemon or Zelda on a canvas, old-school style.  There is a support data format that is the TileMap, there are control logic that keeps track of the coordinates of the currently visible TileMap and there is a rendering engine that makes just the coordinates of tile currently visible on the screen.  You can apply a similar approach to your application - this would allow you to limit the size of the canvas limited to just the size of the portion of the visible screen.  Of course the nature of TileMaps make them especially well optimized for this approach, so the solution is not directly transferable to your application.

    Another project that demonstrates rendering an area almost infinitely great is the Grezi project that defines a JavaFX zoomable user interface, although it uses the SceneGraph and not canvas for this.

    The question may be "why should I should I put the extra mention, more complex logic in my code to draw effectively on a canvas? ' that is ' Why can't the library take care of these things for me?  I think the answers are:

    1. the current implementation of the Web on various platforms may not completely optimized for the treatment of the dirty area and overflow in the visible region to the areas off the screen.

    2. the implementation of the Web cannot make use of any domain specific design optimizations that your application may be familiar with.

    3. you qualify for an architecture of MVC type for your design in any case.

    4. the needs of canvas to deliver a very versatile solution that makes it work well in many situations, but may be not optimal for your particular situation.

    See for example-online the best optimizer is between your ears.

    You might want to try another option is to use the SceneGraph instead of a canvas.  The optimization of the library around the larger scene graphs and area sale/offscreen surface treatment can be more effective in the case of SceneGraphs compared to paintings, particularly in the case of graphs of scene quite sparsely populated.

    No matter what you do, if you want to render the box for 4 K screens, I think that JavaFX (and even some of his other computer pipeline components such as native libraries, drivers graphic, material interfaces screen etc), are not particularly well optimized for the treatment of these high resolutions at the moment.  This is likely to change over time, but expect problems of teeth if you try to make these resolutions at the moment.

    Another thing that I remember is that, to a lesser degree, JavaFX makes often content to the textures on a video card.  Most video cards have some sort of limit to the maximum size of texture and when this limit is reached, to do a layer of additional conversion somewhere in the library code that maps the content to several textures video card and when this way of rendering is called, things slow down significantly.  This limit may be generally around 8Kx8K 4Kx4K (I'm not sure).

    My guess is that this is probably not the answer you wanted ;-)

  • The plans of work and the canvas color questions

    Downloaded the 2015 version of Photoshop and the problems with the color of the cloth and work plans. Work plans are displayed on a white background. I tried to change the color of the canvas by a right click and also through preferences > Interfaces but nothing has changed. Can someone advise?

    The preferred mode for work plans is:

    (1) preferences > performance > use the graphics processor = WE

    (2) the preferences > performance > avancΘs > draw = Advanced Mode

    (3) the RGB documents

    Other adjustments can result in a degraded experience. Work plans still work, but they can rate a part of the 'Visual' sugar

  • The canvas rotation?

    Which versions of Photoshop Elements supports the canvas Rotation tool? (If there is no PE that supports the tool, want someone to recommend me to another product from Adobe that "can't" stand?) A reason I ask this, is because I am a user of graphics tablet and it has come to my attention than most others I know who use other arty programs to design their comics of web graphics. Have some form of rotation of the canvas tool. Makes things ten times more for the traditional artist doing their job without doubt. But another reason, I want to know because I've been sticking with Photoshop Elements 8.0 since... For like... Forever at least. And again - I feel forced while his time, I took what was my PE 8.0. And then big step towards upgrading EP 13.

    I would have thought PE8 can rotate the canvas/image, but I can't test it because I don't have it.  In PSE10, 11, 12, 13 & TI is done by going to:

    Image > rotate

    you will see options for 90 left, 90, 180 and custom ===>> these are very simple, but you can also get a lot more options.  It's just a matter of the use of each of them and see that it fits your needs.  I don't know it can be done otherwise, a graphics package is useless if it can't do simple things like the rotation of a picture or an image layer.

    To rotate the entire canvas, simply select the entire image and then try to turn it.  Make sure that you have performed the copy of the image, just in case you're wrong.

    Good luck.

  • Adding a NL changes to the scope behind the canvas?

    Hello: Level: a bit Newbie OS: Win 8 Ps: Cs6... I am new to Windows 8 - have had it for 5 days

    I activated Photoshop on my new laptop computer and set my preferences about how I love them, and then I made a new Document and adds a new layer

    but when I clicked on the icon of the new layer at the bottom of the Panel the area behind the canvas tour in a dark gray transparent layers, then when I tried to draw a Rectangle shape throughout the document went black and when I clicked on the new layer icon again black went and shape appeared and at the same time the area behind the canvas turned over the grey dark black and transparency again...

    first to clarify... to the area behind the canvas went transparent dark gray, but in other circumstances such as using the brush, draw shapes etc the area behind the canvas can first be dark, then black and then transparent.

    It's really annoying trying to work like that.

    I called Adobe and spent over an hour on the phone with them. The man who took my call seemed to have fixed the problems, but when I quit Ps and restarted again the same problems returned.

    I tried to reset the preferences by Alt + Ctrl + Shift to the launch of the Ps, but it did not help at all.

    The nice man at Adobe has done something with my files and when he placed a Prefs icon on my desktop.

    Has anyone encountered this problem? Any ideas or solutions?

    I was wondering if I should maybe disable and re-enable or just go out and to uninstall and reinstall.

    I'm not particularly good with computers, so I do not know where to start by checking if there is a conflict of orders between Ps Cs6 and Windows 8.

    Thank you very much for your time and your efforts.

    Not turning off"use graphics processor" in the Performance preference and restarting Photoshop have a bearing on the issue.

    Photoshop is fully up to date?

  • Get/apply the canvas size

    I do some scripts cleaning for some processes of photoshop where I work and thought in a way to eliminate the duty change actions but am not sure that the characters used to perform actions.  What I need is a script that will get the size of the canvas of a single document (I'll call him original.psd for easy reference) and apply it to another document without damaging or resize the layers (I'll call her what a target.psd).

    I already have most of the script, so I just need the lines that will be

    (a) get the canvas of original.psd size and

    (b) applies that the canvas size to target.psd

    Thanks in advance for any help!

    DGolberg

    Need a script to a document of reference before you can work with it. You're not telling the order, that the images have been opened or their names. The code below will get the size of the canvas of the first open document and apply it to the second open.

    var w = app.documents[0].width;// the width of the first open document
    var h = app.documents[0].height;
    app.activeDocument = app.documents[1];// make sure the second open document is active
    app.activeDocument.resizeCanvas (w, h);
    

    If you want the order of the just switched document exchange the 0 and 1.

  • How to know the effect on performance on the Exchange or modification of containers?

    Hello

    As part of the element to a DataGridColumn converter, I will have this code below:

    < mx:HBox id = "jai" >
    < mx:Image source = "images/canvas.png" visible = "true" height = "100%" width="100%"/ > "
    < mx:Label id = "kkk" text = "Pavane" / >
    < mx:Button label = "Edit" click = "openPopUpWindow ()" / >
    < / mx:HBox >

    But unfortunately, it does not look good, so I decided to use the Panel
    instead of HBox, means this way

    < mx:Panel id = "jai" >
    < mx:Image source = "images/canvas.png" visible = "true" height = "100%" width="100%"/ > "
    < mx:Label id = "kkk" text = "Pavane" / >
    < mx:Button label = "Edit" click = "openPopUpWindow ()" / >
    < / mx:Panel >

    I am also concerned by the performance of the Application at the same time.
    Please tell me that how I know or confirm this change of the HBox container to the Panel
    has not affected how whether performance wise or not?

    Thank you.

    Use the performance profiler.  We use generally 3 to 5 outputs, in search of

    convergence around a range of time.

  • Low power mode will affect the performance of the camera?

    I take my iPhone 6 on a trip backpack my camera. I intend to put the phone in airplane mode and I wonder if I should also set low power mode. If I put it in low power mode, it will reduce the performance of the camera?

    I suggest that you test this configuration by yourself before you leave.

    You can also consider taking the external battery back up like those manufactured by mophie.

  • The operation cannot be performed because the "Firefox" element is in use.

    Whenever I try to download the latest version of Firefox on my mac, I get the following error:

    "The operation cannot be performed because the"Firefox"element is in use."

    I close Firefox and still get this error. I tried this guy 100 times and may not know how to solve this problem. Help!

    I have Mac OS X 10.6.8 v.

    Download the full Firefox installation program and save the file to the desktop
    https://www.Mozilla.org/en-us/Firefox/all.html

    If he has problems with the update or with the permissions then best is to download the full version and trash the version currently installed to do a fresh install of the new version.

    Download a new copy of the Firefox application and save the file to disk on the desktop image

    Your personal data are stored in the Firefox profile folder, so you will not lose your bookmarks and other data to personal when you uninstall and (re) install Firefox.

  • HP 15-g018dx Notebook PC: HP 15-g018dx Notebook PC can upgrade my graphics card to give me a high performance on the game?

    Serial number: [personal information deleted]

    Model: 15-g018dx

    Product number: J5T41UA #ABA

    I tried to figure out if I can update my graphics card and I was wondering if I could, and what graphics card would be better for my laptop for high performance on the game.

    Hello

    No, it uses the CPU/processor AMD Quad-Core APU A6-6310 2.4/1.8GHz:

    http://support.HP.com/au-en/document/c04368180

    You will also need to change the motherboard and it is a very expensive upgrade.

    Kind regards.

  • To increase the performance of the system (Windows XP, Vista, 7 and 8)

    Hi all

    Most people enjoy to keep their work in the computer and working properly, as long as possible. I have provided a few interesting documents that they will help you to keep your system as recent as possible concerning regular maintenance. I am able to provide information for systems already in Windows XP and as recent as Windows 8. What's even better is that these changes and updates can be performed without modification or upgrade any hardware.

    Increase the performance of the XP system

    Increase the Performance of the system Vista

    Increase the performance of the system 7

    Increase the performance of the system 8

    Thank you

    I hope this helps everyone.

  • Can I use an SDXC (512MB) card as a drive hard primary (such as startup HD with El Capitan) on my iMac 5 K - end 2015? It will slow down the performance of the iMac?

    Can I use an SDXC (512MB) card as a drive hard primary (such as startup HD with El Capitan) on my iMac 5 K - end 2015? It will slow down the performance of the iMac?

    I did it with a 32GB SDHC UHS - I Transcend

    I do not recommend under OS X from such media, but it works very well. I was preparing for my review of the CPHA Yosemite and did not want to mess with the internal drive of OS X.

  • Performance of the fans on Satellite L30-134

    Hello

    I have a question about the performance of the cpu on my L30-134 fans (celeron M 410 @1. 46 ghz). Some users posted similar questions on different laptops series L, but I'd love to hear some comments L30 - 134 user/advice.

    The problem is that by default, the fan does not work on the down low all the time, but it is off and goes on every 2-3 minutes hit RPM high and causing a lot of noise. Sometimes however it works down low most of the time, being really quiet and keep the temperature at 48 to 55 degrees, while during for turning on and off the temperature is 58-65.

    There are two options for cooling in Toshiba Power Saver (which came preinstalled) we're max performance, the other is to optimize the battery. The fan seems to work on the Tower on / disable system regardless of the option selected.

    Q1 Do these two options are actually on the fan is constantly working on low speed or activation and deactivation?
    Q2 How can I do the fan runs all the time at low revs?
    Q3 is there third-party security programs to control the fan speed?

    PS: I don't have all of the options on the fan speed in the BIOS

    I'd appreciate your comments. It is not fun to have a noisy fan :)

    Hello

    As you have already mentioned the Toshiba Power saver is preinstalled on your device.
    My phone supports also this utility and energy saver controls the speed of the CPU and cooling mode.
    M unit fan starts to turn if the temperature rises to a higher level, but it depends on the use of the laptop. I don t play much games performance, but I use my camera for graphic design. Sometimes, the fans run really fast and long, but sometimes the laptop is quite.
    My support of intelligence tools speed level 4 CPU processing power and cooling method is the value max performance.
    I think the cooling also depends on the environment

    Moreover, I also read a lot of reviews on the cooling fan rotation and. Sometimes, the update of the BIOS changed the performance of fans

    A small comment to Q3: Don t think that any 3rd party application will control the performance of the fans properly. If the energy saver is not installed on the device, the power of Microsoft options are responsible for execution.

  • Re: Satellite L500-19Z - how to increase the performance of the game?

    Hey

    Basically, I have a Toshiba Satellite L500-19z, with chipsets Intel Series 4 express. I know this isn't a particularly good game, but surely the performance of game should be reasonable?

    I get 80% of the time lag - while on my old laptop (which costs no more than £200) I could play World of Warcraft on it no problem (I played the Sims3 on this laptop and had very few problems. I'm playing Dragon Age, but it is almost impossible.) My laptop is not more than 8 months old.

    I just want to know if there is a way to increase the performance of the game? I thought that maybe to connect my laptop to a PC Tower, but that could lead to the worst game performance, so I said.
    I'm sure I can't replace the graphics card, I've updated my drivers, defragment disks and so on.

    Any help is really appreciated, thanks in advance.

    Hello

    Is there anything to do to increase game performance. It depends on the graphics card and Intel cards are not designed for games, they are a good choice for mobile use because they don t need a lot of power.
    In addition, the peut t graphics card be exchanged, s thereby.

    It s always depending on the game that you can play. Therefore, check the system requirements of all the games you want to play and if your graphics card is supported. Not all games support all graphics cards.

    You must also use low graphics settings in each game. You can use the parameters of t.

    For example on my Satellite U400, possessing the same Intel graphics card, I can play Half Life 2 which has already 5 years but always low medium graphics settings.

Maybe you are looking for