Painter - fixes, printing fixes, NOAA (for better printing output)

git-svn-id: svn://ultimatepp.org/upp/trunk@779 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-01-17 11:58:41 +00:00
parent 9ee7e1d00d
commit 82b316980d
19 changed files with 621 additions and 537 deletions

View file

@ -74,7 +74,7 @@ static String sPainting;
bool PassWindowsKey(int wParam); bool PassWindowsKey(int wParam);
LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { LRESULT Ctrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
ASSERT(IsNull(sPainting)); // WindowProc invoked while in Paint routine ASSERT_(IsNull(sPainting), "WindowProc invoked while in Paint routine");
// LLOG("Ctrl::WindowProc(" << message << ") in " << ::Name(this) << ", focus " << (void *)::GetFocus()); // LLOG("Ctrl::WindowProc(" << message << ") in " << ::Name(this) << ", focus " << (void *)::GetFocus());
Ptr<Ctrl> _this = this; Ptr<Ctrl> _this = this;
HWND hwnd = GetHWND(); HWND hwnd = GetHWND();

View file

@ -336,11 +336,11 @@ bool Draw::IsPainting(int x, int y, int cx, int cy) const
return IsPainting(RectC(x, y, cx, cy)); return IsPainting(RectC(x, y, cx, cy));
} }
static void (*sIgfn)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos); static void (*sIgfn)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos, bool noaa);
static void (*sIwfn)(ImageBuffer& ib, const Drawing& p); static void (*sIwfn)(ImageBuffer& ib, const Drawing& p, bool noaa);
void RegisterPaintingFns__(void (*ig)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos), void RegisterPaintingFns__(void (*ig)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos, bool noaa),
void (*iw)(ImageBuffer& ib, const Drawing& p)) void (*iw)(ImageBuffer& ib, const Drawing& p, bool noaa))
{ {
sIgfn = ig; sIgfn = ig;
sIwfn = iw; sIwfn = iw;
@ -351,21 +351,21 @@ bool HasPainter()
return sIgfn && sIwfn; return sIgfn && sIwfn;
} }
void PaintImageBuffer(ImageBuffer& ib, const Painting& p, Size sz, Point pos) void PaintImageBuffer(ImageBuffer& ib, const Painting& p, Size sz, Point pos, bool noaa)
{ {
if(sIgfn) if(sIgfn)
(*sIgfn)(ib, p, sz, pos); (*sIgfn)(ib, p, sz, pos, noaa);
} }
void PaintImageBuffer(ImageBuffer& ib, const Painting& p) void PaintImageBuffer(ImageBuffer& ib, const Painting& p, bool noaa)
{ {
PaintImageBuffer(ib, p, ib.GetSize(), Point(0, 0)); PaintImageBuffer(ib, p, ib.GetSize(), Point(0, 0), noaa);
} }
void PaintImageBuffer(ImageBuffer& ib, const Drawing& iw) void PaintImageBuffer(ImageBuffer& ib, const Drawing& iw, bool noaa)
{ {
if(sIwfn) if(sIwfn)
(*sIwfn)(ib, iw); (*sIwfn)(ib, iw, noaa);
} }
void Draw::DrawPaintingOp(const Rect& target, const Painting& pw) void Draw::DrawPaintingOp(const Rect& target, const Painting& pw)
@ -378,16 +378,16 @@ void Draw::DrawPaintingOp(const Rect& target, const Painting& pw)
while(yy < sz.cy) { while(yy < sz.cy) {
int ccy = min(sz.cy - yy, 100); int ccy = min(sz.cy - yy, 100);
ImageBuffer ib(sz.cx, ccy); ImageBuffer ib(sz.cx, ccy);
Fill(~ib, RGBAZero(), ib.GetLength()); Fill(~ib, White(), ib.GetLength());
PaintImageBuffer(ib, pw, sz, Point(0, yy)); PaintImageBuffer(ib, pw, sz, Point(0, yy), true);
DrawImageBandRLE(*this, target.left, target.top + yy, ib, 16); DrawImageBandRLE(*this, target.left, target.top + yy, ib, 16);
yy += ccy; yy += ccy;
} }
} }
else { else {
ImageBuffer ib(sz); ImageBuffer ib(sz);
Fill(~ib, RGBAZero(), ib.GetLength()); Fill(~ib, IsPrinter() ? White() : SColorPaper(), ib.GetLength());
PaintImageBuffer(ib, pw, sz, Point(0, 0)); PaintImageBuffer(ib, pw, sz, Point(0, 0), IsPrinter());
DrawImage(target.left, target.top, ib); DrawImage(target.left, target.top, ib);
} }
} }

View file

@ -473,10 +473,35 @@ void SColorDkShadow_Write(Color c);
inline Color InvertColor() { return Color(255, 0); } inline Color InvertColor() { return Color(255, 0); }
inline Color DefaultInk() { return Black(); } //TODO! inline Color DefaultInk() { return Black(); } //TODO!
class Painting : AssignValueTypeNo<Painting, 48, Moveable<Painting> >{
String cmd;
ValueArray data;
Sizef size;
friend class PaintingPainter;
friend class Painter;
public:
Sizef GetSize() const { return size; }
void Clear() { size = Null; data.Clear(); cmd.Clear(); }
void Serialize(Stream& s) { s % cmd % data % size; }
bool IsNullInstance() const { return data.IsEmpty(); }
bool operator==(const Painting& b) const { return cmd == b.cmd && data == b.data && size == b.size; }
unsigned GetHashValue() const { return CombineHash(cmd, data); }
String ToString() const { return "painting " + AsString(size); }
operator Value() const { return RichValue<Painting>(*this); }
Painting(const Value& q) { *this = RichValue<Painting>::Extract(q); }
Painting() { size = Null; }
Painting(const Nuller&) { size = Null; }
};
bool HasPainter(); bool HasPainter();
void PaintImageBuffer(ImageBuffer& ib, const Painting& p, Size sz, Point pos); void PaintImageBuffer(ImageBuffer& ib, const Painting& p, Size sz, Point pos, bool noaa = false);
void PaintImageBuffer(ImageBuffer& ib, const Painting& p); void PaintImageBuffer(ImageBuffer& ib, const Painting& p, bool noaa = false);
void PaintImageBuffer(ImageBuffer& ib, const Drawing& p); void PaintImageBuffer(ImageBuffer& ib, const Drawing& p, bool noaa = false);
class Draw { class Draw {
protected: protected:
@ -693,6 +718,7 @@ public:
DRAWPOLYPOLYLINE = 16, DRAWPOLYPOLYLINE = 16,
DRAWPOLYPOLYPOLYGON = 17, DRAWPOLYPOLYPOLYGON = 17,
DRAWDATA = 18, DRAWDATA = 18,
DRAWPAINTING = 19,
}; };
typedef void (*Drawer)(Draw&, Stream&, const DrawingPos&); typedef void (*Drawer)(Draw&, Stream&, const DrawingPos&);
@ -1064,6 +1090,7 @@ public:
Color ink, int n, const int *dx); Color ink, int n, const int *dx);
virtual void DrawDrawingOp(const Rect& target, const Drawing& w); virtual void DrawDrawingOp(const Rect& target, const Drawing& w);
virtual void DrawPaintingOp(const Rect& target, const Painting& w);
private: private:
Size size; Size size;

View file

@ -381,6 +381,13 @@ static void wsDrawDrawing(Draw& w, Stream& s, const DrawingPos& ps) {
w.DrawDrawing(ps(rc), dw); w.DrawDrawing(ps(rc), dw);
} }
static void wsDrawPainting(Draw& w, Stream& s, const DrawingPos& ps) {
Painting dw;
Rect rc;
s % dw % rc;
w.DrawPainting(ps(rc), dw);
}
static void wsDrawLine(Draw& w, Stream& s, const DrawingPos& ps) { static void wsDrawLine(Draw& w, Stream& s, const DrawingPos& ps) {
int x1, y1, x2, y2, width; int x1, y1, x2, y2, width;
Color color; Color color;
@ -591,6 +598,7 @@ void Draw::DrawDrawingOp(const Rect& target, const Drawing& w) {
Register(DRAWRECT, wsDrawRect); Register(DRAWRECT, wsDrawRect);
Register(DRAWIMAGE, wsDrawImage); Register(DRAWIMAGE, wsDrawImage);
Register(DRAWDRAWING, wsDrawDrawing); Register(DRAWDRAWING, wsDrawDrawing);
Register(DRAWPAINTING, wsDrawPainting);
Register(DRAWLINE, wsDrawLine); Register(DRAWLINE, wsDrawLine);
Register(DRAWELLIPSE, wsDrawEllipse); Register(DRAWELLIPSE, wsDrawEllipse);
Register(DRAWTEXT, wsDrawText); Register(DRAWTEXT, wsDrawText);
@ -639,6 +647,11 @@ void DrawingDraw::DrawDrawingOp(const Rect& target, const Drawing& w)
return; return;
} }
void DrawingDraw::DrawPaintingOp(const Rect& target, const Painting& w)
{
DrawingOp(DRAWPAINTING) % const_cast<Painting&>(w) % const_cast<Rect&>(target);
}
void Draw::DrawDrawing(int x, int y, int cx, int cy, const Drawing& w) { void Draw::DrawDrawing(int x, int y, int cx, int cy, const Drawing& w) {
DrawDrawing(RectC(x, y, cx, cy), w); DrawDrawing(RectC(x, y, cx, cy), w);
} }

View file

@ -1,155 +1,156 @@
#include "Painter.h" #include "Painter.h"
NAMESPACE_UPP NAMESPACE_UPP
#define LTIMING(x) RTIMING(x) #define LTIMING(x) RTIMING(x)
void BufferPainter::ClearOp(const RGBA& color) void BufferPainter::ClearOp(const RGBA& color)
{ {
Upp::Fill(~buffer, color, buffer.GetLength()); Upp::Fill(~buffer, color, buffer.GetLength());
} }
inline void BufferPainter::PathPoint0(double x, double y) inline void BufferPainter::PathPoint0(double x, double y)
{ {
pathrect.left = min(pathrect.left, x); pathrect.left = min(pathrect.left, x);
pathrect.top = min(pathrect.top, y); pathrect.top = min(pathrect.top, y);
pathrect.right = max(pathrect.right, x); pathrect.right = max(pathrect.right, x);
pathrect.bottom = max(pathrect.bottom, y); pathrect.bottom = max(pathrect.bottom, y);
} }
inline void BufferPainter::PathPoint(double& x, double& y, bool rel) inline void BufferPainter::PathPoint(double& x, double& y, bool rel)
{ {
x = IsNull(x) ? current.x : rel ? x + current.x : x; x = IsNull(x) ? current.x : rel ? x + current.x : x;
y = IsNull(y) ? current.y : rel ? y + current.y : y; y = IsNull(y) ? current.y : rel ? y + current.y : y;
if(inpath) if(inpath)
PathPoint0(x, y); PathPoint0(x, y);
else { else {
path.remove_all(); path.remove_all();
pathrect.left = pathrect.right = x; pathrect.left = pathrect.right = x;
pathrect.top = pathrect.bottom = y; pathrect.top = pathrect.bottom = y;
pathattr = attr; pathattr = attr;
} }
inpath = true; inpath = true;
} }
inline void BufferPainter::EndPoint(double& x, double& y, bool rel) inline void BufferPainter::EndPoint(double& x, double& y, bool rel)
{ {
PathPoint(x, y, rel); PathPoint(x, y, rel);
current = Pointf(x, y); current = Pointf(x, y);
} }
void BufferPainter::MoveOp(double x, double y, bool rel) void BufferPainter::MoveOp(double x, double y, bool rel)
{ {
EndPoint(x, y, rel); EndPoint(x, y, rel);
ccontrol = qcontrol = current; ccontrol = qcontrol = current;
path.move_to(x, y); path.move_to(x, y);
inpath = true; inpath = true;
} }
void BufferPainter::LineOp(double x, double y, bool rel) void BufferPainter::LineOp(double x, double y, bool rel)
{ {
EndPoint(x, y, rel); EndPoint(x, y, rel);
ccontrol = qcontrol = current; ccontrol = qcontrol = current;
path.line_to(x, y); path.line_to(x, y);
inpath = true; inpath = true;
} }
void BufferPainter::QuadraticOp(double x1, double y1, double x, double y, bool rel) void BufferPainter::QuadraticOp(double x1, double y1, double x, double y, bool rel)
{ {
PathPoint(x1, y1, rel); PathPoint(x1, y1, rel);
qcontrol = Pointf(x1, y1); qcontrol = Pointf(x1, y1);
EndPoint(x, y, rel); EndPoint(x, y, rel);
ccontrol = current; ccontrol = current;
path.curve3(x1, y1, x, y); path.curve3(x1, y1, x, y);
} }
void BufferPainter::QuadraticOp(double x, double y, bool rel) void BufferPainter::QuadraticOp(double x, double y, bool rel)
{ {
qcontrol = current + current - qcontrol; qcontrol = current + current - qcontrol;
PathPoint0(qcontrol.x, qcontrol.y); PathPoint0(qcontrol.x, qcontrol.y);
EndPoint(x, y, rel); EndPoint(x, y, rel);
ccontrol = current; ccontrol = current;
path.curve3(qcontrol.x, qcontrol.y, x, y); path.curve3(qcontrol.x, qcontrol.y, x, y);
} }
void BufferPainter::CubicOp(double x1, double y1, double x2, double y2, double x, double y, bool rel) void BufferPainter::CubicOp(double x1, double y1, double x2, double y2, double x, double y, bool rel)
{ {
PathPoint(x1, y1, rel); PathPoint(x1, y1, rel);
PathPoint(x2, y2, rel); PathPoint(x2, y2, rel);
ccontrol = Pointf(x2, y2); ccontrol = Pointf(x2, y2);
EndPoint(x, y, rel); EndPoint(x, y, rel);
qcontrol = current; qcontrol = current;
path.curve4(x1, y1, x2, y2, x, y); path.curve4(x1, y1, x2, y2, x, y);
} }
void BufferPainter::CubicOp(double x2, double y2, double x, double y, bool rel) void BufferPainter::CubicOp(double x2, double y2, double x, double y, bool rel)
{ {
Pointf c = current + current - ccontrol; Pointf c = current + current - ccontrol;
PathPoint0(c.x, c.y); PathPoint0(c.x, c.y);
PathPoint(x2, y2, rel); PathPoint(x2, y2, rel);
ccontrol = Pointf(x2, y2); ccontrol = Pointf(x2, y2);
EndPoint(x, y, rel); EndPoint(x, y, rel);
qcontrol = current; qcontrol = current;
path.curve4(c.x, c.y, x2, y2, x, y); path.curve4(c.x, c.y, x2, y2, x, y);
} }
void BufferPainter::CloseOp() void BufferPainter::CloseOp()
{ {
path.close_polygon(); path.close_polygon();
} }
inline void BufferPainter::MinMax(Pointf& minv, Pointf& maxv, Pointf p) const inline void BufferPainter::MinMax(Pointf& minv, Pointf& maxv, Pointf p) const
{ {
p = pathattr.mtx.Transformed(p); p = pathattr.mtx.Transformed(p);
minv.x = min(minv.x, p.x); minv.x = min(minv.x, p.x);
minv.y = min(minv.y, p.y); minv.y = min(minv.y, p.y);
maxv.x = max(maxv.x, p.x); maxv.x = max(maxv.x, p.x);
maxv.y = max(maxv.y, p.y); maxv.y = max(maxv.y, p.y);
} }
bool BufferPainter::PathVisible(double w) const bool BufferPainter::PathVisible(double w) const
{ {
Pointf h = pathattr.mtx.Transformed(w, w); Pointf h = pathattr.mtx.Transformed(w, w);
w = max(fabs(h.x), fabs(h.y)); w = max(fabs(h.x), fabs(h.y));
Pointf min; Pointf min;
Pointf max; Pointf max;
min = max = pathattr.mtx.Transformed(pathrect.TopLeft()); min = max = pathattr.mtx.Transformed(pathrect.TopLeft());
MinMax(min, max, pathrect.TopRight()); MinMax(min, max, pathrect.TopRight());
MinMax(min, max, pathrect.BottomLeft()); MinMax(min, max, pathrect.BottomLeft());
MinMax(min, max, pathrect.BottomRight()); MinMax(min, max, pathrect.BottomRight());
return max.x + w >= 0 && max.y + w >= 0 && min.x - w <= sizef.cx && min.y - w <= sizef.cy; return max.x + w >= 0 && max.y + w >= 0 && min.x - w <= sizef.cx && min.y - w <= sizef.cy;
} }
void BufferPainter::SetRbuf() void BufferPainter::SetRbuf()
{ {
pixf.attach(buffer); pixf.attach(buffer);
renb.attach(pixf); renb.attach(pixf);
renderer.attach(renb); renderer.attach(renb);
} }
BufferPainter::BufferPainter(ImageBuffer& ib) BufferPainter::BufferPainter(ImageBuffer& ib)
: buffer(ib), : buffer(ib),
curved(path), curved(path),
curved_trans(curved, attr.mtx) curved_trans(curved, attr.mtx)
{ {
size = ib.GetSize(); size = ib.GetSize();
sizef = size; sizef = size;
inpath = false; inpath = false;
pathrect = Null; pathrect = Null;
ccontrol = qcontrol = current = Point(0, 0); ccontrol = qcontrol = current = Point(0, 0);
attr.cap = LINECAP_BUTT; attr.cap = LINECAP_BUTT;
attr.join = LINEJOIN_MITER; attr.join = LINEJOIN_MITER;
attr.miter_limit = 4; attr.miter_limit = 4;
attr.evenodd = false; attr.evenodd = false;
attr.hasclip = false; attr.hasclip = false;
attr.cliplevel = 0; attr.cliplevel = 0;
attr.dash_start = 0.0; attr.dash_start = 0.0;
attr.opacity = 1.0; attr.opacity = 1.0;
attr.mask = false; attr.mask = false;
pathattr = attr; attr.noaa = false;
pathattr = attr;
SetRbuf();
} SetRbuf();
}
END_UPP_NAMESPACE
END_UPP_NAMESPACE

View file

@ -65,6 +65,8 @@ protected:
virtual void MiterLimitOp(double l); virtual void MiterLimitOp(double l);
virtual void EvenOddOp(bool evenodd); virtual void EvenOddOp(bool evenodd);
virtual void DashOp(const Vector<double>& dash, double start); virtual void DashOp(const Vector<double>& dash, double start);
virtual void NoAAOp(bool noaa);
virtual void TransformOp(const Matrix2D& m); virtual void TransformOp(const Matrix2D& m);
@ -122,7 +124,9 @@ private:
typedef byte value_type; typedef byte value_type;
typedef int calc_type; typedef int calc_type;
typedef agg::const_row_info<RGBA> row_data; typedef agg::const_row_info<RGBA> row_data;
bool noaa;
void attach(ImageBuffer& ib) { buffer = ib; sz = ib.GetSize(); } void attach(ImageBuffer& ib) { buffer = ib; sz = ib.GetSize(); }
int width() const { return sz.cx; } int width() const { return sz.cx; }
@ -195,6 +199,7 @@ private:
int cliplevel; int cliplevel;
bool hasclip; bool hasclip;
bool mask; bool mask;
bool noaa;
}; };
Attr attr; Attr attr;

View file

@ -23,9 +23,8 @@ void BufferPainter::EndOp()
void BufferPainter::TransformOp(const Matrix2D& m) void BufferPainter::TransformOp(const Matrix2D& m)
{ {
ASSERT_(!inpath, "Cannot change transformation during path definition"); ASSERT_(!inpath, "Cannot change transformation during path definition");
pathattr.mtx = m * attr.mtx; attr.mtx = m * attr.mtx;
if(!inpath) pathattr.mtx = attr.mtx;
attr.mtx = m * attr.mtx;
} }
void BufferPainter::OpacityOp(double o) void BufferPainter::OpacityOp(double o)
@ -73,4 +72,11 @@ void BufferPainter::DashOp(const Vector<double>& dash, double start)
} }
} }
void BufferPainter::NoAAOp(bool noaa)
{
pathattr.noaa = noaa;
if(!inpath)
attr.noaa = noaa;
}
END_UPP_NAMESPACE END_UPP_NAMESPACE

View file

@ -6,6 +6,7 @@ void BufferPainter::FillOp(const RGBA& c)
{ {
if(inpath) if(inpath)
path.close_polygon(); path.close_polygon();
pixf.noaa = pathattr.noaa;
RGBA color = c; RGBA color = c;
if(PathVisible(0) && color.a) { if(PathVisible(0) && color.a) {
if(pathattr.opacity != 1.0) { if(pathattr.opacity != 1.0) {
@ -177,6 +178,7 @@ void BufferPainter::FillOp(const Image& image, const Matrix2D& transsrc, dword f
path.close_polygon(); path.close_polygon();
span_alloc sa; span_alloc sa;
pixf.noaa = pathattr.noaa;
Matrix2D m = transsrc * pathattr.mtx; Matrix2D m = transsrc * pathattr.mtx;
m.invert(); m.invert();
UppImageAggSpan sg; UppImageAggSpan sg;

View file

@ -96,7 +96,6 @@ struct sMakeCharOutline : LRUCache<String, FontChar>::Maker {
void Painter::CharacterOp(double x, double y, int ch, Font fnt) void Painter::CharacterOp(double x, double y, int ch, Font fnt)
{ {
RTIMING("Character");
String s; String s;
INTERLOCKED { INTERLOCKED {
static LRUCache<String, FontChar> cache; static LRUCache<String, FontChar> cache;
@ -106,7 +105,7 @@ void Painter::CharacterOp(double x, double y, int ch, Font fnt)
h.fc.chr = ch; h.fc.chr = ch;
s = cache.Get(h); s = cache.Get(h);
} }
RenderCharPath(s, s.GetLength(), *this, x, y); RenderCharPath(s, s.GetLength(), *this, x, y + fnt.Info().GetAscent());
EvenOdd(true); EvenOdd(true);
} }

View file

@ -1,151 +1,151 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.4 // Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
// //
// Permission to copy, use, modify, sell and distribute this software // Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all coM_PIes. // is granted provided this copyright notice appears in all coM_PIes.
// This software is provided "as is" without express or implied // This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose. // warranty, and with no claim as to its suitability for any purpose.
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Contact: mcseem@antigrain.com // Contact: mcseem@antigrain.com
// mcseemagg@yahoo.com // mcseemagg@yahoo.com
// http://www.antigrain.com // http://www.antigrain.com
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Recycled for U++ by Miroslav Fidler 2008 // Recycled for U++ by Miroslav Fidler 2008
#include "Painter.h" #include "Painter.h"
NAMESPACE_UPP NAMESPACE_UPP
#ifdef PLATFORM_X11 #ifdef PLATFORM_X11
static inline double ft_dbl(int p) static inline double ft_dbl(int p)
{ {
return double(p) / 64.0; return double(p) / 64.0;
} }
bool RenderOutline(const FT_Outline& outline, Painter& path, double xx, double yy) bool RenderOutline(const FT_Outline& outline, Painter& path, double xx, double yy)
{ {
FT_Vector v_last; FT_Vector v_last;
FT_Vector v_control; FT_Vector v_control;
FT_Vector v_start; FT_Vector v_start;
double x1, y1, x2, y2, x3, y3; double x1, y1, x2, y2, x3, y3;
FT_Vector* point; FT_Vector* point;
FT_Vector* limit; FT_Vector* limit;
char* tags; char* tags;
int n; // index of contour in outline int n; // index of contour in outline
char tag; // current point's state char tag; // current point's state
int first = 0; // index of first point in contour int first = 0; // index of first point in contour
for(n = 0; n < outline.n_contours; n++) { for(n = 0; n < outline.n_contours; n++) {
int last = outline.contours[n]; int last = outline.contours[n];
limit = outline.points + last; limit = outline.points + last;
v_start = outline.points[first]; v_start = outline.points[first];
v_last = outline.points[last]; v_last = outline.points[last];
v_control = v_start; v_control = v_start;
point = outline.points + first; point = outline.points + first;
tags = outline.tags + first; tags = outline.tags + first;
tag = FT_CURVE_TAG(tags[0]); tag = FT_CURVE_TAG(tags[0]);
if(tag == FT_CURVE_TAG_CUBIC) return false; if(tag == FT_CURVE_TAG_CUBIC) return false;
if(tag == FT_CURVE_TAG_CONIC) { if(tag == FT_CURVE_TAG_CONIC) {
if(FT_CURVE_TAG(outline.tags[last]) == FT_CURVE_TAG_ON) { if(FT_CURVE_TAG(outline.tags[last]) == FT_CURVE_TAG_ON) {
// start at last point if it is on the curve // start at last point if it is on the curve
v_start = v_last; v_start = v_last;
limit--; limit--;
} }
else { else {
// if both first and last points are conic, // if both first and last points are conic,
// start at their middle and record its position // start at their middle and record its position
// for closure // for closure
v_start.x = (v_start.x + v_last.x) / 2; v_start.x = (v_start.x + v_last.x) / 2;
v_start.y = (v_start.y + v_last.y) / 2; v_start.y = (v_start.y + v_last.y) / 2;
v_last = v_start; v_last = v_start;
} }
point--; point--;
tags--; tags--;
} }
path.Move(ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy); path.Move(ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy);
while(point < limit) { while(point < limit) {
point++; point++;
tags++; tags++;
tag = FT_CURVE_TAG(tags[0]); tag = FT_CURVE_TAG(tags[0]);
switch(tag) { switch(tag) {
case FT_CURVE_TAG_ON: case FT_CURVE_TAG_ON:
path.Line(ft_dbl(point->x) + xx, -ft_dbl(point->y) + yy); path.Line(ft_dbl(point->x) + xx, -ft_dbl(point->y) + yy);
continue; continue;
case FT_CURVE_TAG_CONIC: case FT_CURVE_TAG_CONIC:
v_control.x = point->x; v_control.x = point->x;
v_control.y = point->y; v_control.y = point->y;
Do_Conic: Do_Conic:
if(point < limit) { if(point < limit) {
FT_Vector vec; FT_Vector vec;
FT_Vector v_middle; FT_Vector v_middle;
point++; point++;
tags++; tags++;
tag = FT_CURVE_TAG(tags[0]); tag = FT_CURVE_TAG(tags[0]);
vec.x = point->x; vec.x = point->x;
vec.y = point->y; vec.y = point->y;
if(tag == FT_CURVE_TAG_ON) { if(tag == FT_CURVE_TAG_ON) {
path.Quadratic(ft_dbl(v_control.x) + xx, -ft_dbl(v_control.y) + yy, path.Quadratic(ft_dbl(v_control.x) + xx, -ft_dbl(v_control.y) + yy,
ft_dbl(vec.x) + xx, -ft_dbl(vec.y) + yy); ft_dbl(vec.x) + xx, -ft_dbl(vec.y) + yy);
continue; continue;
} }
if(tag != FT_CURVE_TAG_CONIC) return false; if(tag != FT_CURVE_TAG_CONIC) return false;
v_middle.x = (v_control.x + vec.x) / 2; v_middle.x = (v_control.x + vec.x) / 2;
v_middle.y = (v_control.y + vec.y) / 2; v_middle.y = (v_control.y + vec.y) / 2;
path.Quadratic(ft_dbl(v_control.x) + xx, -ft_dbl(v_control.y) + yy, path.Quadratic(ft_dbl(v_control.x) + xx, -ft_dbl(v_control.y) + yy,
ft_dbl(v_middle.x) + xx, -ft_dbl(v_middle.y) + yy); ft_dbl(v_middle.x) + xx, -ft_dbl(v_middle.y) + yy);
v_control = vec; v_control = vec;
goto Do_Conic; goto Do_Conic;
} }
path.Quadratic(ft_dbl(v_control.x) + xx, -ft_dbl(v_control.y) + yy, path.Quadratic(ft_dbl(v_control.x) + xx, -ft_dbl(v_control.y) + yy,
ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy); ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy);
goto Close; goto Close;
default: default:
FT_Vector vec1, vec2; FT_Vector vec1, vec2;
if(point + 1 > limit || FT_CURVE_TAG(tags[1]) != FT_CURVE_TAG_CUBIC) if(point + 1 > limit || FT_CURVE_TAG(tags[1]) != FT_CURVE_TAG_CUBIC)
return false; return false;
vec1.x = point[0].x; vec1.x = point[0].x;
vec1.y = point[0].y; vec1.y = point[0].y;
vec2.x = point[1].x; vec2.x = point[1].x;
vec2.y = point[1].y; vec2.y = point[1].y;
point += 2; point += 2;
tags += 2; tags += 2;
if(point <= limit) { if(point <= limit) {
FT_Vector vec; FT_Vector vec;
vec.x = point->x; vec.x = point->x;
vec.y = point->y; vec.y = point->y;
path.Cubic(ft_dbl(vec1.x) + xx, -ft_dbl(vec1.y) + yy, path.Cubic(ft_dbl(vec1.x) + xx, -ft_dbl(vec1.y) + yy,
ft_dbl(vec2.x) + xx, -ft_dbl(vec2.y) + yy, ft_dbl(vec2.x) + xx, -ft_dbl(vec2.y) + yy,
ft_dbl(vec.x) + xx, -ft_dbl(vec.y) + yy); ft_dbl(vec.x) + xx, -ft_dbl(vec.y) + yy);
continue; continue;
} }
path.Cubic(ft_dbl(vec1.x) + xx, -ft_dbl(vec1.y) + yy, path.Cubic(ft_dbl(vec1.x) + xx, -ft_dbl(vec1.y) + yy,
ft_dbl(vec2.x) + xx, -ft_dbl(vec2.y) + yy, ft_dbl(vec2.x) + xx, -ft_dbl(vec2.y) + yy,
ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy); ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy);
goto Close; goto Close;
} }
} }
Close: Close:
path.Close(); path.Close();
first = last + 1; first = last + 1;
} }
return true; return true;
} }
void Painter::CharacterOp(double x, double y, int ch, Font fnt) void Painter::CharacterOp(double x, double y, int ch, Font fnt)
{ {
FontInfo fi = fnt.Info(); FontInfo fi = fnt.Info();
FT_Face face = XftLockFace(fi.GetXftFont()); FT_Face face = XftLockFace(fi.GetXftFont());
int glyph_index = FT_Get_Char_Index(face, ch); int glyph_index = FT_Get_Char_Index(face, ch);
if(FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT) == 0) if(FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT) == 0)
RenderOutline(face->glyph->outline, *this, x, y); RenderOutline(face->glyph->outline, *this, x, y + fnt.Info().GetAscent());
XftUnlockFace(fi.GetXftFont()); XftUnlockFace(fi.GetXftFont());
} }
#endif #endif
END_UPP_NAMESPACE END_UPP_NAMESPACE

View file

@ -30,7 +30,7 @@ void Painter::Paint(const Painting& pic)
{ {
StringStream ss(pic.cmd); StringStream ss(pic.cmd);
Pointf p, p1, p2; Pointf p, p1, p2;
Color c, c1; RGBA c, c1;
Value v; Value v;
int f, ch, n, hasdx; int f, ch, n, hasdx;
Matrix2D m; Matrix2D m;
@ -117,6 +117,7 @@ void Painter::Paint(const Painting& pic)
sGet(w, ss); sGet(w, ss);
sGet(c, ss); sGet(c, ss);
Stroke(w, c); Stroke(w, c);
DDUMP((Color)c);
break; break;
case PAINTING_STROKE_IMAGE: case PAINTING_STROKE_IMAGE:
sGet(w, ss); sGet(w, ss);
@ -206,6 +207,9 @@ void Painter::Paint(const Painting& pic)
Dash(dash, r); Dash(dash, r);
} }
break; break;
case PAINTING_NOAA:
NoAA(ss.Get());
break;
case PAINTING_TRANSFORM: case PAINTING_TRANSFORM:
sGet(m, ss); sGet(m, ss);
Transform(m); Transform(m);
@ -223,26 +227,28 @@ void Painter::Paint(const Painting& pic)
} }
} }
void PaintImageBufferPaintingFn(ImageBuffer& ib, const Painting& p, Size sz, Point pos) void PaintImageBufferPaintingFn(ImageBuffer& ib, const Painting& p, Size sz, Point pos, bool noaa)
{ {
BufferPainter sw(ib); BufferPainter sw(ib);
sw.NoAA(noaa);
Sizef psz = p.GetSize(); Sizef psz = p.GetSize();
sw.Translate(-pos.x, -pos.y); sw.Translate(-pos.x, -pos.y);
sw.Scale(sz.cx / psz.cx, sz.cy / psz.cy); sw.Scale(sz.cx / psz.cx, sz.cy / psz.cy);
sw.Paint(p); sw.Paint(p);
} }
void PaintImageBufferDrawingFn(ImageBuffer& ib, const Drawing& iw) void PaintImageBufferDrawingFn(ImageBuffer& ib, const Drawing& iw, bool noaa)
{ {
BufferPainter sw(ib); BufferPainter sw(ib);
sw.NoAA(noaa);
Sizef sz = ib.GetSize(); Sizef sz = ib.GetSize();
Size isz = iw.GetSize(); Size isz = iw.GetSize();
sw.Scale(sz.cx / isz.cx, sz.cy / isz.cy); sw.Scale(sz.cx / isz.cx, sz.cy / isz.cy);
sw.DrawDrawing(0, 0, isz.cx, isz.cy, iw); sw.DrawDrawing(0, 0, isz.cx, isz.cy, iw);
} }
void RegisterPaintingFns__(void (*ig)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos), void RegisterPaintingFns__(void (*ig)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos, bool noaa),
void (*iw)(ImageBuffer& ib, const Drawing& p)); void (*iw)(ImageBuffer& ib, const Drawing& p, bool noaa));
INITBLOCK INITBLOCK

View file

@ -42,6 +42,7 @@ bool Painter::ExcludeClipOp(const Rect& r)
bool Painter::IntersectClipOp(const Rect& r) bool Painter::IntersectClipOp(const Rect& r)
{ {
return true;
RectPath(r); RectPath(r);
Clip(); Clip();
return true; return true;
@ -123,6 +124,17 @@ void Painter::DrawTextOp(int x, int y, int angle, const wchar *text, Font font,
End(); End();
} }
void Painter::DrawPaintingOp(const Rect& target, const Painting& p)
{
Size sz = target.GetSize();
Sizef psz = p.GetSize();
Begin();
Translate(target.left, target.top);
Scale(sz.cx / psz.cx, sz.cy / psz.cy);
Paint(p);
End();
}
Painter& Painter::Move(double x, double y) Painter& Painter::Move(double x, double y)
{ {
return Move(x, y, false); return Move(x, y, false);

View file

@ -99,6 +99,7 @@ protected:
virtual void DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor); virtual void DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor);
virtual void DrawTextOp(int x, int y, int angle, const wchar *text, Font font, virtual void DrawTextOp(int x, int y, int angle, const wchar *text, Font font,
Color ink, int n, const int *dx); Color ink, int n, const int *dx);
virtual void DrawPaintingOp(const Rect& target, const Painting& w);
protected: protected:
virtual void ClearOp(const RGBA& color) = 0; virtual void ClearOp(const RGBA& color) = 0;
@ -144,6 +145,7 @@ protected:
virtual void MiterLimitOp(double l) = 0; virtual void MiterLimitOp(double l) = 0;
virtual void EvenOddOp(bool evenodd) = 0; virtual void EvenOddOp(bool evenodd) = 0;
virtual void DashOp(const Vector<double>& dash, double start = 0) = 0; virtual void DashOp(const Vector<double>& dash, double start = 0) = 0;
virtual void NoAAOp(bool noaa) = 0;
virtual void TransformOp(const Matrix2D& m) = 0; virtual void TransformOp(const Matrix2D& m) = 0;
@ -229,6 +231,7 @@ public:
Painter& EvenOdd(bool evenodd); Painter& EvenOdd(bool evenodd);
Painter& Dash(const Vector<double>& dash, double start = 0); Painter& Dash(const Vector<double>& dash, double start = 0);
Painter& Dash(const char *dash, double start = 0); Painter& Dash(const char *dash, double start = 0);
Painter& NoAA(bool noaa = true);
void Transform(const Matrix2D& m); void Transform(const Matrix2D& m);

View file

@ -1,185 +1,191 @@
NAMESPACE_UPP NAMESPACE_UPP
inline void Painter::Clear(const RGBA& color) inline void Painter::Clear(const RGBA& color)
{ {
ClearOp(color); ClearOp(color);
} }
inline Painter& Painter::Move(double x, double y, bool rel) inline Painter& Painter::Move(double x, double y, bool rel)
{ {
MoveOp(x, y, rel); MoveOp(x, y, rel);
return *this; return *this;
} }
inline Painter& Painter::Line(double x, double y, bool rel) inline Painter& Painter::Line(double x, double y, bool rel)
{ {
LineOp(x, y, rel); LineOp(x, y, rel);
return *this; return *this;
} }
inline Painter& Painter::Quadratic(double x1, double y1, double x, double y, bool rel) inline Painter& Painter::Quadratic(double x1, double y1, double x, double y, bool rel)
{ {
QuadraticOp(x1, y1, x, y, rel); QuadraticOp(x1, y1, x, y, rel);
return *this; return *this;
} }
inline Painter& Painter::Quadratic(double x, double y, bool rel) inline Painter& Painter::Quadratic(double x, double y, bool rel)
{ {
QuadraticOp(x, y, rel); QuadraticOp(x, y, rel);
return *this; return *this;
} }
inline Painter& Painter::Cubic(double x1, double y1, double x2, double y2, double x, double y, bool rel) inline Painter& Painter::Cubic(double x1, double y1, double x2, double y2, double x, double y, bool rel)
{ {
CubicOp(x1, y1, x2, y2, x, y, rel); CubicOp(x1, y1, x2, y2, x, y, rel);
return *this; return *this;
} }
inline Painter& Painter::Cubic(double x2, double y2, double x, double y, bool rel) inline Painter& Painter::Cubic(double x2, double y2, double x, double y, bool rel)
{ {
CubicOp(x2, y2, x, y, rel); CubicOp(x2, y2, x, y, rel);
return *this; return *this;
} }
inline Painter& Painter::Close() inline Painter& Painter::Close()
{ {
CloseOp(); CloseOp();
return *this; return *this;
} }
inline Painter& Painter::Fill(const RGBA& color) inline Painter& Painter::Fill(const RGBA& color)
{ {
FillOp(color); FillOp(color);
return *this; return *this;
} }
inline Painter& Painter::Fill(const Image& image, const Matrix2D& transsrc, dword flags) inline Painter& Painter::Fill(const Image& image, const Matrix2D& transsrc, dword flags)
{ {
FillOp(image, transsrc, flags); FillOp(image, transsrc, flags);
return *this; return *this;
} }
inline Painter& Painter::Fill(double x1, double y1, const RGBA& color1, inline Painter& Painter::Fill(double x1, double y1, const RGBA& color1,
double x2, double y2, const RGBA& color2, int style) double x2, double y2, const RGBA& color2, int style)
{ {
FillOp(x1, y1, color1, x2, y2, color2, style); FillOp(x1, y1, color1, x2, y2, color2, style);
return *this; return *this;
} }
inline Painter& Painter::Fill(double fx, double fy, const RGBA& color1, double x1, double y1, double r, const RGBA& color2, int style) inline Painter& Painter::Fill(double fx, double fy, const RGBA& color1, double x1, double y1, double r, const RGBA& color2, int style)
{ {
FillOp(fx, fy, color1, x1, y1, r, color2, style); FillOp(fx, fy, color1, x1, y1, r, color2, style);
return *this; return *this;
} }
inline Painter& Painter::Fill(double x1, double y1, const RGBA& color1, double r, const RGBA& color2, int style) inline Painter& Painter::Fill(double x1, double y1, const RGBA& color1, double r, const RGBA& color2, int style)
{ {
return Fill(x1, y1, color1, x1, y1, r, color2, style); return Fill(x1, y1, color1, x1, y1, r, color2, style);
} }
inline Painter& Painter::Stroke(double width, const RGBA& color) inline Painter& Painter::Stroke(double width, const RGBA& color)
{ {
StrokeOp(width, color); StrokeOp(width, color);
return *this; return *this;
} }
inline Painter& Painter::Stroke(double width, const Image& image, const Matrix2D& transsrc, dword flags) inline Painter& Painter::Stroke(double width, const Image& image, const Matrix2D& transsrc, dword flags)
{ {
StrokeOp(width, image, transsrc, flags); StrokeOp(width, image, transsrc, flags);
return *this; return *this;
} }
inline Painter& Painter::Stroke(double width, double x1, double y1, const RGBA& color1, inline Painter& Painter::Stroke(double width, double x1, double y1, const RGBA& color1,
double x2, double y2, const RGBA& color2, int style) double x2, double y2, const RGBA& color2, int style)
{ {
StrokeOp(width, x1, y1, color1, x2, y2, color2, style); StrokeOp(width, x1, y1, color1, x2, y2, color2, style);
return *this; return *this;
} }
inline Painter& Painter::Stroke(double width, double fx, double fy, const RGBA& color1, inline Painter& Painter::Stroke(double width, double fx, double fy, const RGBA& color1,
double x1, double y1, double r, const RGBA& color2, int style) double x1, double y1, double r, const RGBA& color2, int style)
{ {
StrokeOp(width, fx, fy, color1, x1, y1, r, color2, style); StrokeOp(width, fx, fy, color1, x1, y1, r, color2, style);
return *this; return *this;
} }
inline Painter& Painter::Stroke(double width, double x1, double y1, const RGBA& color1, double r, const RGBA& color2, int style) inline Painter& Painter::Stroke(double width, double x1, double y1, const RGBA& color1, double r, const RGBA& color2, int style)
{ {
return Stroke(width, x1, y1, color1, x1, y1, r, color2, style); return Stroke(width, x1, y1, color1, x1, y1, r, color2, style);
} }
inline Painter& Painter::Clip() inline Painter& Painter::Clip()
{ {
ClipOp(); ClipOp();
return *this; return *this;
} }
inline Painter& Painter::ColorStop(double pos, const RGBA& color) inline Painter& Painter::ColorStop(double pos, const RGBA& color)
{ {
ColorStopOp(pos, color); ColorStopOp(pos, color);
return *this; return *this;
} }
inline Painter& Painter::ClearStops() inline Painter& Painter::ClearStops()
{ {
ClearStopsOp(); ClearStopsOp();
return *this; return *this;
} }
inline Painter& Painter::Opacity(double o) inline Painter& Painter::Opacity(double o)
{ {
OpacityOp(o); OpacityOp(o);
return *this; return *this;
} }
inline Painter& Painter::LineCap(int linecap) inline Painter& Painter::LineCap(int linecap)
{ {
LineCapOp(linecap); LineCapOp(linecap);
return *this; return *this;
} }
inline Painter& Painter::LineJoin(int linejoin) inline Painter& Painter::LineJoin(int linejoin)
{ {
LineJoinOp(linejoin); LineJoinOp(linejoin);
return *this; return *this;
} }
inline Painter& Painter::MiterLimit(double l) inline Painter& Painter::MiterLimit(double l)
{ {
MiterLimitOp(l); MiterLimitOp(l);
return *this; return *this;
} }
inline Painter& Painter::EvenOdd(bool evenodd) inline Painter& Painter::EvenOdd(bool evenodd)
{ {
EvenOddOp(evenodd); EvenOddOp(evenodd);
return *this; return *this;
} }
inline Painter& Painter::Dash(const Vector<double>& dash, double start) inline Painter& Painter::Dash(const Vector<double>& dash, double start)
{ {
DashOp(dash, start); DashOp(dash, start);
return *this; return *this;
} }
inline void Painter::Transform(const Matrix2D& m) inline Painter& Painter::NoAA(bool noaa)
{ {
TransformOp(m); NoAAOp(noaa);
} return *this;
}
inline void Painter::Begin()
{ inline void Painter::Transform(const Matrix2D& m)
BeginOp(); {
} TransformOp(m);
}
inline void Painter::End()
{ inline void Painter::Begin()
EndOp(); {
} BeginOp();
}
inline void Painter::BeginMask()
{ inline void Painter::End()
BeginMaskOp(); {
} EndOp();
}
END_UPP_NAMESPACE
inline void Painter::BeginMask()
{
BeginMaskOp();
}
END_UPP_NAMESPACE

View file

@ -93,6 +93,7 @@ void PaintingPainter::StrokeOp(double width, const RGBA& color)
Put(PAINTING_STROKE_SOLID); Put(PAINTING_STROKE_SOLID);
Putf(width); Putf(width);
Put(color); Put(color);
DDUMP(Color(color));
} }
void PaintingPainter::StrokeOp(double width, const Image& image, const Matrix2D& transsrc, dword flags) void PaintingPainter::StrokeOp(double width, const Image& image, const Matrix2D& transsrc, dword flags)
@ -135,6 +136,7 @@ void PaintingPainter::ClipOp()
void PaintingPainter::CharacterOp(double x, double y, int ch, Font fnt) void PaintingPainter::CharacterOp(double x, double y, int ch, Font fnt)
{ {
Put(PAINTING_CHARACTER); Put(PAINTING_CHARACTER);
Putf(x, y);
Put32(ch); Put32(ch);
Put(fnt); Put(fnt);
} }
@ -204,6 +206,12 @@ void PaintingPainter::DashOp(const Vector<double>& dash, double start)
Putf(start); Putf(start);
} }
void PaintingPainter::NoAAOp(bool noaa)
{
Put(PAINTING_NOAA);
Put(noaa);
}
void PaintingPainter::TransformOp(const Matrix2D& m) void PaintingPainter::TransformOp(const Matrix2D& m)
{ {
Put(PAINTING_TRANSFORM); Put(PAINTING_TRANSFORM);

View file

@ -1,15 +1,3 @@
class Painting {
String cmd;
ValueArray data;
Sizef size;
friend class PaintingPainter;
friend class Painter;
public:
Sizef GetSize() const { return size; }
};
enum { enum {
PAINTING_EOF, PAINTING_EOF,
PAINTING_CLEAR, PAINTING_CLEAR,
@ -51,6 +39,7 @@ enum {
PAINTING_MITERLIMIT, PAINTING_MITERLIMIT,
PAINTING_EVENODD, PAINTING_EVENODD,
PAINTING_DASH, PAINTING_DASH,
PAINTING_NOAA,
PAINTING_TRANSFORM, PAINTING_TRANSFORM,
PAINTING_BEGIN, PAINTING_BEGIN,
@ -115,6 +104,7 @@ protected:
virtual void MiterLimitOp(double l); virtual void MiterLimitOp(double l);
virtual void EvenOddOp(bool evenodd); virtual void EvenOddOp(bool evenodd);
virtual void DashOp(const Vector<double>& dash, double start); virtual void DashOp(const Vector<double>& dash, double start);
virtual void NoAAOp(bool noaa);
virtual void TransformOp(const Matrix2D& m); virtual void TransformOp(const Matrix2D& m);
@ -136,6 +126,3 @@ public:
PaintingPainter(double cx, double cy) { Create(cx, cy); } PaintingPainter(double cx, double cy) { Create(cx, cy); }
PaintingPainter(Sizef sz) { Create(sz); } PaintingPainter(Sizef sz) { Create(sz); }
}; };
void PaintImageBuffer(ImageBuffer& ib, const Painting& p, Size sz, Point pos);
void PaintImageBuffer(ImageBuffer& ib, const Drawing& p);

View file

@ -6,6 +6,8 @@ void BufferPainter::upp_pixfmt::blend_hline(int x, int y, int len, RGBA c, byte
{ {
if(c.a == 0) return; if(c.a == 0) return;
RGBA *t = ptr(x, y); RGBA *t = ptr(x, y);
if(noaa)
cover = cover > 127 ? 255 : 0;
if((c.a & cover) == 255) { if((c.a & cover) == 255) {
#if 1 #if 1
while(len >= 16) { while(len >= 16) {
@ -57,6 +59,8 @@ void BufferPainter::upp_pixfmt::blend_solid_hspan(int x, int y, int len,
RGBA *e = t + len; RGBA *e = t + len;
while(t < e) { while(t < e) {
byte cover = *covers++; byte cover = *covers++;
if(noaa)
cover = cover > 127 ? 255 : 0;
if((cover & c.a) == 255) // is it worth it? if((cover & c.a) == 255) // is it worth it?
*t++ = c; *t++ = c;
else else
@ -69,9 +73,14 @@ void BufferPainter::upp_pixfmt::blend_color_hspan(int x, int y, int len, const R
{ {
RGBA *t = ptr(x, y); RGBA *t = ptr(x, y);
RGBA *e = t + len; RGBA *e = t + len;
if(noaa)
cover = cover > 127 ? 255 : 0;
while(t < e) { while(t < e) {
if(covers) if(covers) {
cover = *covers++; cover = *covers++;
if(noaa)
cover = cover > 127 ? 255 : 0;
}
if((cover & colors->a) == 255) if((cover & colors->a) == 255)
*t = *colors; *t = *colors;
else else

View file

@ -213,6 +213,7 @@ void BufferPainter::FillOp(double fx, double fy, const RGBA& color1,
{ {
if(inpath) if(inpath)
path.close_polygon(); path.close_polygon();
pixf.noaa = pathattr.noaa;
span_alloc sa; span_alloc sa;
Matrix2D m = pathattr.mtx; Matrix2D m = pathattr.mtx;
m.invert(); m.invert();

View file

@ -8,7 +8,6 @@ void Painter::TextOp(double x, double y, const wchar *text, Font fnt, int n, dou
FontInfo fi = fnt.Info(); FontInfo fi = fnt.Info();
if(n < 0) if(n < 0)
n = wstrlen(text); n = wstrlen(text);
y += fi.GetAscent();
while(n) { while(n) {
int ch = *text++; int ch = *text++;
Character(x, y, ch, fnt); Character(x, y, ch, fnt);