Updownquark / Quick

Quark's User Interface Creation Kit
0 stars 0 forks source link

Alternative Rendering #34

Closed Updownquark closed 11 years ago

Updownquark commented 11 years ago

I'm not sure how this could be done, but it would be ideal if it was possible to plug in different renderers than just the plain java Graphics implementation. Examples would be JavaFX and OpenGL. These would make MUIS much more performant.

Updownquark commented 11 years ago

I think instead of having pluggable or switchable rendering, that I'll eventually just switch over to OpenGL completely. The only possible problem with this may be security. If I give a library an OpenGL "session" or whetever, how much power does it have through that? Is it governed by permissions? Can they take over the video card or crash it or anything? Can I gain any control over how much GPU resources a thread takes? Need to investigate.

Updownquark commented 11 years ago

I think I'll include another rendering architecture improvement here. The re-rendering should be done to a buffered image, which is then rendered all at once to the display. Would look much better.

We also need to think about double-buffering some time. Probably not all elements would use it, but it would be a good option to have for some.

Updownquark commented 11 years ago

Having a problem with rendering on issue #2 (Border Layout). Not at all sure that this is the only issue, but one thing that is an issue is that the rendering is taking place in 2 threads--the AWT Event Queue and the MUIS Event Queue. Rendering in AWT happens on initial rendering and due to resizes of the browser window. Rendering on the MUIS threads happens for those things and in response to MUIS events, like state changes causing a different style to become active.

The best way I can think of to overcome this problem is to do what I said above with the buffered image. I need to redo the architecture by which MUIS draws things on demand. Here's how it will work.

Updownquark commented 11 years ago

I wanted to write that down and finish my thought, but as I was making that list, I was realizing that it's very possible that none of that will make any sense once I switch over to OpenGL. Even in AWT land animation performance might be terrible with that architecture. Might have to work around it somehow. Kinda looking like I might need to work the OpenGL part of this issue before I do anything about buffers

While I'm doing the brain dump thing, an idea that just occurred to me is that maybe the animation needs to coordinate more with the event queue. Maybe instead of having its own thread, the motion package should just fire events on the MUIS event thread. This would allow the renders to happen quicker (don't have to wait for another thread).

Updownquark commented 11 years ago

Waffling on this a little bit. If I can get the performance to be good without OpenGL, there would be some benefits to that:

Additionally, even if I do end up going OpenGL, a lot of the architecture changes I would do (mentioned above) would still be useful. I think I'll do that and maybe some profiling and optimization and see if I can get things to perform more reasonably.

Updownquark commented 11 years ago

I think I'll call this done except for the OpenGL part, which I may or may not ever do. That will depend on whether I can get performance to be good for more complex documents, which I have yet to write. The only part of the list above I didn't do is the render event batching, but I did batch the resize events, which helped a lot. Didn't even have to modify the eventing architecture for that. I can batch the paint events later if I decide there's enough benefit to it.

I'll close this for now and reopen if and when I decide to tackle OpenGL.

Updownquark commented 11 years ago

I'm reopening this because the new architecture changes caused delays in repaints. Need to fix this.

Updownquark commented 11 years ago

Fixed this. There is, however, still something of an issue. When a widget is rendered now, it's rendered to both the stored image in the document and to the actual device graphics. This makes things more responsive than before, but since the rendering is to the device, the progress of rendering operations that take significant time can be watched on the screen, which doesn't look very nice.

Updownquark commented 11 years ago

Still have delays between clicking on an element and the stateful style color displaying on the screen

Updownquark commented 11 years ago

Although the delay is now gone, I still want to do another optimization. Even though evaluations are now pretty fast, there's absolutely no need to do as many as are being done for each state change. I want to change the style sheet to return a subclass of StyleExpressionValue whose getValue() method evaluates the value. Thus the expressions in a style sheet can be investigated without any unnecessary evaluations.

Updownquark commented 11 years ago

As noted above, the fix was actually in PRISMS. In detail, the slowdown was due to the calling (thousands of times each) of a utility method to determine whether an package-like expression was indeed a package on the classpath, and Class.forName. I delegated the Class.forName call to a new utility method in the same class as the package tester method and added caches for each. This cut the state change time for the "pressed" state down from about 1/3 second to 1/50 on my home machine.

Then, after adding the feature described above for evaluating animated style sheets only as needed, the time went down to about 1/200 of a second. It's possible other performance issues related to styles will pop up, but I made them a ton better. This is done for now.