mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
233 lines
13 KiB
HTML
233 lines
13 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
|
<html lang="en-US">
|
|
<head>
|
|
<title>GFX2 Proposal</title>
|
|
|
|
<style type="text/css">
|
|
/* FONTS */
|
|
|
|
/* pavlov said no
|
|
body { font: 900 3em sans-serif; }
|
|
div { font-size: 0.8em; font-weight: lighter; }
|
|
div > div > div > div > div > div { font-size: 1em; }
|
|
h1, h2, h3, h4, h5, h6, p, ul, ol, li { font: inherit; }
|
|
*/
|
|
|
|
|
|
/* LAYOUT */
|
|
h1, h2, h3, h4, h5, h6, p, ul, ol, li { margin: 0; padding: 0; }
|
|
div { margin: 0.25em 0 0.5em 2em; }
|
|
|
|
|
|
/* DECORATION */
|
|
|
|
/* pavlov said no to this too * { border: solid 1px; } */
|
|
|
|
|
|
/* COLOUR */
|
|
body { background: white; color: black; }
|
|
|
|
strong { font-size: 0.7em; color: red; }
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
<div><h1>GFX2: widget/gfx rewrite</h1>
|
|
<div>"GFX2" provides what is currently provided by both gfx and widget (including timers).</div>
|
|
</div>
|
|
|
|
<div><h1>Problems:</h1>
|
|
|
|
<div><h2>Graphics</h2>
|
|
<div>Windows specific apis, hacks, etc. <strong>(make this better)</strong></div>
|
|
<div><h3>Performance</h3>
|
|
<div>Due to some of the current APIs, it is hard for us to use the operating system for many things that it can be used for.</div>
|
|
|
|
<div><h4>Blending/Alpha compositing</h4>
|
|
<div><strong>???</strong></div>
|
|
</div>
|
|
|
|
<div><h4>Clipping</h4>
|
|
<div>We currently do far too much clipping. This causes numerous performance problems, especially on X11 based systems. Due to the way X works, changing the clip region makes the X server have to flush its connections to make sure nothing has changed since it received the clip region. <strong>(this isn't a completely accurate description, change it)</strong></div>
|
|
</div>
|
|
|
|
<div><h4>Images</h4>
|
|
<div><h5>Memory size</h5>
|
|
<div>Currently, we hold around at least two copies of the image data around in memory. One compressed and one decompressed. As part of GFX2 and imagelib 1.5, we hope to only hold a single copy of the image data around.</div>
|
|
</div>
|
|
<div><h5>Scaling and dithering</h5>
|
|
<div>Both image scaling and dithering currently is done in both imagelib and gfx depending on your platform and the code path that layout uses to draw the image. This causes confusion and does not allow the platform to optimize the scaling and dithering operations.</div>
|
|
</div>
|
|
<div><h5>Gamma</h5>
|
|
<div><strong>??</strong></div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div><h3>twips</h3>
|
|
<div>twips are the devices independent units that we use so that printing, etc can print and look the same, but they are not needed and cause performance hits due to constant float to integer conversions and back. They also provide confusion with some APIs taking twips and others pixels.</div>
|
|
</div>
|
|
|
|
<div><h3>SVG (scaleable vector graphics)</h3>
|
|
<div>The current graphics APIs that we have do not provide support for rendering vector graphic. There is no clean way to add these drawing primitives to the current gfx APIs.</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div><h2>Widgets</h2>
|
|
<div>Obsolete APIs (designed for when we had native widgets) <strong>(make this better)</strong></div>
|
|
<div><h3>Events</h3>
|
|
<div>The way operating systems handle events are often quite different. This creates a problem with the current way we handle events. Engineers are forced to spend large amounts of time tracking down bugs that are caused by event ordering, and with no solid specification on how we should sent events, this problem will continue. <strong>(make this better)</strong></div>
|
|
</div>
|
|
|
|
<div><h3>Native form controls</h3>
|
|
<div>There is good bit of code left in the current widget module that is no longer used or needed. These interfaces and code should be removed. Should the need for "native" form controls arise again, XBL should be able to do the job of making native looking and feeling form controls.</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<div><h1>Proposal:</h1>
|
|
<div><h2>Graphics</h2>
|
|
|
|
<div><h3>merge widget and gfx in to a single component</h3>
|
|
<div>Since both widget and gfx deal with the native OS, drawing, and events, there is no reason for them to be separate components.</div>
|
|
</div>
|
|
|
|
<div><h3>floating point pixel coordinate system</h3>
|
|
<div>Remove twips.</div>
|
|
<div>With the CPUs used in modern hardware, we can replace twips with floating point pixel based coordinates and dimensions. Using floating point will account for the rounding problems that using twips aims to fix as well as reduce the need to convert to and from twips constantly. For systems without a FPU (StrongArm, etc), <a href="mailto:scc@mozilla.org">Scott Collins</a> has volunteered to write a fixed-point class that we could simply plug in instead of floating points. Devices such as printers would be able to use a transformation matrix to scale the pixel values so that they match the DPI that you are printing to.</div>
|
|
</div>
|
|
|
|
<div><h3>SVG (scaleable vector graphics)</h3>
|
|
<div><h4>Interfaces</h4>
|
|
<div>SVG related drawing methods will be put on their own interface, something like nsIVectorDrawable, which you can QI to and from an nsIDrawable. An XP implementation that does its own rasterization and delegates everything else to an underlying GFX implimentation is needed to do this.</div>
|
|
</div>
|
|
<div><h4>Cross-platform Solutions</h4>
|
|
<div><h5>Fonts</h5>
|
|
<div><a href="http://www.freetype.org/">FreeType</a> is a high-quality font rendering engine capible of rendering anti-aliased fonts as well as rotating them.<strong>(blah blah blah)</strong></div>
|
|
</div>
|
|
<div><h5>Drawing</h5>
|
|
<div><a href="http://www.artofcode.com/libart.html">libart</a> is a library designed to render curves, vectors, do alpha compositing, etc. Unfortunatly the author no longer has much time to work on it, so we would need someone here to work on it and integrate it with our system. <strong>(blah blah blah)</strong></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div><h3>Clipping</h3>
|
|
<div><h4>Less of it</h4>
|
|
<div>Clipping should be done only when it is absolutly needed. <strong>(more stuff)</strong></div>
|
|
</div>
|
|
<div><h4>Mandatory vs. discretionary clip regions (potentially)</h4>
|
|
<div><strong>add some of the things roc and I have discussed.</strong></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div><h3>Images</h3>
|
|
|
|
<div><h4>Imglib1.5</h4>
|
|
<div><a href="mailto:tor@cs.brown.edu">Tim Rowley</a> is working on imglib 1.5. The new image library in conjunction with the new imaging APIs in GFX2, we should be able to reduce the number of copies of the image data to one.</div>
|
|
</div>
|
|
|
|
<div><h5>Scaling and dithering</h5>
|
|
<div>As part of imglib 1.5, Tim will be removing imglib's image scaling and dithering code. All image data will come from imglib as 24bit image data.</div>
|
|
<div>Each GFX2 implementation must be able to scale an image using either native system APIs or another means. Having each platform do this allows platforms that do support scaling and/or dithering to take advantage of any hardware optimizations that they can.</div>
|
|
<div>nsIDrawable provides separate methods for drawing an image and drawing a scaled image to avoid any confusion about how to draw an image.</div>
|
|
<div>Platforms that do not support scaling or dithering could probably port gdkrgb and/or gdk_pixbuf to their platform to provide these services in software for them.</div>
|
|
</div>
|
|
|
|
<div><h5>RGBA packed image data</h5>
|
|
<div><strong>???</strong></div>
|
|
</div>
|
|
|
|
<div><h5>Gamma</h5>
|
|
<div><strong>???</strong></div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div><h2>Widgets</h2>
|
|
|
|
<div><h3>Events</h3>
|
|
<div>As part of GFX2, the events generated by the system will have to conform to a specification that will be written up by <a href="mailto:pavlov@netscape.com">Stuart Parmenter</a>, <a href="mailto:joki@netscape.com">Tom Pixley</a>, <a href="mailto:saari@netscape.com">Chris Saari</a>, and others. This will ensure that all events received by listeners to windows will receive them in a cross platform manner and help to remove numerous problems that we currently have due to this. A test listener suite should be made that validates a platform implementation to ensure that it meets the specification perfectly.</div>
|
|
</div>
|
|
|
|
<div><h3>Native form controls</h3>
|
|
<div>XBL can be used to do this work with less overhead and problems than using real native widgets.</div>
|
|
<div>Internet Explorer on widows does not use win32 native form controls.</div>
|
|
<div>Currently there is no need for native form controls, but this could change. The APIs have been designed so that native form controls and other native widgets may be added later without disrupting the current set of GFX2 APIs.</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div><h2>System services</h2>
|
|
<div><h3>Clipboard</h3>
|
|
<div>The clipboard interfaces remain mostly the same. There has been discussion about making the getData methods asynchronous, but nothing has been finalized at this time.</div>
|
|
</div>
|
|
<div><h3>Drag and Drop</h3>
|
|
<div>At the time of this writing, the drag and drop interfaces have not been looked at, but they are not expected to change a great deal.</div>
|
|
</div>
|
|
<div><h3>File Picker</h3>
|
|
<div>The file picker interface has not changed. There has been talk of changing the way filtering works a bit, but this has not been finalized at this time.</div>
|
|
</div>
|
|
<div><h3>System look and feel</h3>
|
|
<div>Currently, we have two interfaces, nsILookAndFeel and nsIDeviceContext that can both be asked for information about CSS fonts, colors, etc. These have been merged in to a single <a href="class_nsISystemLook.html">nsISystemLook</a> interface that contains all of this information.</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div><h2>Interfaces</h2>
|
|
<div><h3>Documentation</h3>
|
|
<div>The GFX2 interfaces are full documented using doxygen and JavaDoc style comments.</div>
|
|
<div>See <a href="annotated.html">the full list of interfaces and information</a>.</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div><h2>Questions</h2>
|
|
<div><h3>Is GFX2 thread safe?</h3>
|
|
<div>The implementations are probably not, however an attempt has been made to make the interfaces reentrant (with noted exceptions such as nsIClipboard)</div>
|
|
</div>
|
|
<div><h3>Will GFX2 break existing platforms such as BeOS and OS/2?</h3>
|
|
<div><h4>No</h4>
|
|
<div>An adaptation layer will be made that will convert calls made to the new GFX2 APIs in to the old APIs allowing current implementations to continue working until they are ported.</div>
|
|
</div>
|
|
</div>
|
|
<div><h3>Should GFX2 interfaces use XPCOM?</h3>
|
|
<div><h4>Pro</h4>
|
|
<div><h5>Scriptability</h5>
|
|
<div>Having the interfaces be scriptable makes writing test cases for them much easier. To help people writing new implementations and porting to new platforms, having a test suite that tests all of their code will make a huge difference. We can also use scriptability to do things like check event ordering from windows, etc.</div>
|
|
</div>
|
|
<div><h5>Run time switching</h5>
|
|
<div>Having GFX2 use XPCOM interfaces allows us to change toolkits at runtime. This may not seem like a big win, but imagine us shipping an Xlib based browser for Unix systems and someone wants to run using NanoX. They could use our Unix builds and simply switch out their GFX2 implementation for their own without having to build the whole product specifically for them.</div>
|
|
</div>
|
|
</div>
|
|
<div><h4>Con</h4>
|
|
<div><h5>Speed</h5>
|
|
<div>Due to the cost of virtual functions, it will be a bit slower than if we did not use XPCOM for GFX2. If the GFX2 library was linked to other libraries, the compiler/linker might be able to further optimize the code paths.</div>
|
|
</div>
|
|
</div>
|
|
<div><h4>Overall</h4>
|
|
<div><h5>Should we use it?</h5>
|
|
<div>After spending time looking at the usage patterns of GFX through layout, using XPCOM should provide only an insignificant speed hit, while providing us with scriptability and run time switching of implementations.</div>
|
|
<div>Time would be better spent removing XPCOM interfaces by focusing on interfaces such as nsISupportsArray that are used constantly throughout the entire code base.</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div><h3>Is GFX2 Y2K compliant?</h3>
|
|
<div>maybe</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<p>
|
|
comments/questions: email <a href="mailto:pavlov@netscape.com">Stuart Parmenter</a>
|
|
</p>
|
|
|
|
</body>
|
|
</html>
|