Add antialiasing mode API. Not Part Of The Build

This commit is contained in:
roc+%cs.cmu.edu 2005-04-11 22:22:10 +00:00
Родитель 0a0d19cb3f
Коммит dc25a09557
3 изменённых файлов: 38 добавлений и 15 удалений

Просмотреть файл

@ -41,7 +41,6 @@
#include <cairo.h>
#include "gfxColor.h"
#include "gfxPattern.h"
#include "gfxPoint.h"
#include "gfxRect.h"
#include "gfxTypes.h"
@ -51,6 +50,7 @@ class gfxMatrix;
class gfxRegion;
class gfxFilter;
class gfxTextRun;
class gfxPattern;
class gfxContext {
public:
@ -86,13 +86,15 @@ public:
void Rectangle(gfxRect rect);
void Polygon(const gfxPoint points[], unsigned long numPoints);
// Add the text outline to the current path
void AddStringToPath(gfxTextRun& text, int pos, int len);
// XXX These next two don't affect the current path?
// XXX document 'size'
void DrawSurface(gfxASurface *surface, gfxSize size);
// Draw a rectangle with aliasing on. Points whose centers are in the
// rectangle should be painted 100% with the current color; all other
// points are untouched.
void AliasedRectangle(gfxRect rect);
// Draw a substring of the text run at the current point
void DrawString(gfxTextRun& text, int pos, int len);
// transform stuff
void Translate(gfxPoint pt);
@ -102,7 +104,6 @@ public:
void SetMatrix(const gfxMatrix& matrix);
gfxMatrix CurrentMatrix() const;
// properties
void SetColor(const gfxRGBA& c);
gfxRGBA CurrentColor() const;
@ -133,6 +134,17 @@ public:
void SetOperator(GraphicsOperator op);
GraphicsOperator CurrentOperator() const;
/**
* MODE_ALIASED means that only pixels whose centers are in the drawn area
* should be modified, and they should be modified to take the value drawn
* at the pixel center.
*/
enum AntialiasMode {
MODE_ALIASED,
MODE_COVERAGE
};
void SetAntialiasMode(AntialiasMode mode);
AntialiasMode CurrentAntialiasMode();
enum GraphicsLineCap {
LINE_CAP_BUTT,
@ -163,9 +175,6 @@ public:
// patterns
void SetPattern(gfxPattern& pattern);
// fonts?
void DrawString(gfxTextRun& text, int pos, int len);
// filters
// Start rendering under the filter. We guarantee not to draw outside 'maxArea'.
void PushFilter(gfxFilter& filter, gfxRect& maxArea);

Просмотреть файл

@ -38,19 +38,23 @@
#ifndef GFX_TEXTRUN_H
#define GFX_TEXTRUN_H
#include "prtypes.h"
#include "gfxTypes.h"
class nsIFontMetrics;
class nsIAtom;
class gfxTextRun {
// these do not copy the text
gfxTextRun(const char* ASCII, int length);
gfxTextRun(const PRUnichar* unicode, int length);
gfxTextRun(const char* ASCII, int length, nsIFontMetrics* font, nsIAtom* language);
gfxTextRun(const PRUnichar* unicode, int length, nsIFontMetrics* font, nsIAtom* language);
void SetFont(nsFont* font, nsIAtom* language);
enum { ClusterStart = 0x1 } CharFlags;
// ClusterStart: character is the first character of a cluster/glyph
void GetCharacterFlags(int pos, int len, CharFlags* flags);
struct Dimensions {
double ascent, descent, width, leftBearing, rightBearing;
gfxFloat ascent, descent, width, leftBearing, rightBearing;
};
Dimensions MeasureText(int pos, int len);
@ -60,7 +64,7 @@ class gfxTextRun {
// preferences about where we allow breaks.
// We will usually want to call MeasureText right afterwards,
// the implementor could optimize for that.
int GetCharsFit(int pos, int len, double width, int breakflags);
int GetCharsFit(int pos, int len, gfxFloat width, int breakflags);
int GetPositionInString(gfxPoint& pt);
};

Просмотреть файл

@ -178,6 +178,16 @@ gfxRGBA gfxContext::CurrentColor() const
return c;
}
void gfxContext::SetAntialiasMode(AntialiasMode mode)
{
// XXX implement me
}
gfxContext::AntialiasMode gfxContext::CurrentAntialiasMode()
{
return MODE_COVERAGE;
}
void gfxContext::SetDash(gfxFloat* dashes, int ndash, gfxFloat offset)
{
cairo_set_dash(mCairo, dashes, ndash, offset);