Mozilla2:GFXGraphics: Difference between revisions

No edit summary
Line 1: Line 1:
== Class Graphics ==
== Class Context ==
Your 2d drawing API.  To use this you need to first create a surface and call SetSurface().
Your 2d drawing API.  To use this you need to first create a surface and call SetSurface().


=== API ===
=== API ===
[http://pavlov.net/projects/thebes/public/Graphics.h Graphics.h]
[http://lxr.mozilla.org/mozilla/source/gfx/thebes/public/gfxContext.h gfxContext.h]


=== Filters ===
=== Filters ===
[http://pavlov.net/projects/thebes/public/Filter.h Filter.h]
[http://lxr.mozilla.org/mozilla/source/gfx/thebes/public/gfxFilter.h gfxFilter.h]


For blending and SVG filters we need an API like this:
See gfxContext::PushFilter. This API lets clients not worry about what resolution to create a temporary surface at, etc. It is GFX/Cairo's responsibility to choose a good resolution, based on the current transformation.
class Filter {
  static Filter* CreateOpacityFilter(double alpha);
  // CreateGaussianFilter, etc
};
 
In Graphics:
  // Start rendering under the filter. We guarantee not to draw outside 'maxArea'.
  void PushFilter(Filter f, Rect maxArea);
  // Completed rendering under the filter, composite what we rendered back to the
  // underlying surface using the filter.
  void PopFilter();
 
This API lets clients not worry about what resolution to create a temporary surface at, etc. It is GFX/Cairo's responsibility to choose a good resolution, based on the current transformation.


The way to implement this is to transform maxArea to device coordinates, take its bounding box, and use that as the area for the temporary surface.
The way to implement this is to transform maxArea to device coordinates, take its bounding box, and use that as the area for the temporary surface.
1,295

edits