diff --git a/uppsrc/CtrlCore/Win32Proc.cpp b/uppsrc/CtrlCore/Win32Proc.cpp index dca905864..dd4734f5d 100644 --- a/uppsrc/CtrlCore/Win32Proc.cpp +++ b/uppsrc/CtrlCore/Win32Proc.cpp @@ -74,7 +74,7 @@ static String sPainting; bool PassWindowsKey(int wParam); 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()); Ptr _this = this; HWND hwnd = GetHWND(); diff --git a/uppsrc/Draw/Draw.cpp b/uppsrc/Draw/Draw.cpp index 29bfd2a92..439f9bf2f 100644 --- a/uppsrc/Draw/Draw.cpp +++ b/uppsrc/Draw/Draw.cpp @@ -336,11 +336,11 @@ bool Draw::IsPainting(int x, int y, int cx, int cy) const return IsPainting(RectC(x, y, cx, cy)); } -static void (*sIgfn)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos); -static void (*sIwfn)(ImageBuffer& ib, const Drawing& p); +static void (*sIgfn)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos, bool noaa); +static void (*sIwfn)(ImageBuffer& ib, const Drawing& p, bool noaa); -void RegisterPaintingFns__(void (*ig)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos), - void (*iw)(ImageBuffer& ib, const Drawing& p)) +void RegisterPaintingFns__(void (*ig)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos, bool noaa), + void (*iw)(ImageBuffer& ib, const Drawing& p, bool noaa)) { sIgfn = ig; sIwfn = iw; @@ -351,21 +351,21 @@ bool HasPainter() 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) - (*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) - (*sIwfn)(ib, iw); + (*sIwfn)(ib, iw, noaa); } 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) { int ccy = min(sz.cy - yy, 100); ImageBuffer ib(sz.cx, ccy); - Fill(~ib, RGBAZero(), ib.GetLength()); - PaintImageBuffer(ib, pw, sz, Point(0, yy)); + Fill(~ib, White(), ib.GetLength()); + PaintImageBuffer(ib, pw, sz, Point(0, yy), true); DrawImageBandRLE(*this, target.left, target.top + yy, ib, 16); yy += ccy; } } else { ImageBuffer ib(sz); - Fill(~ib, RGBAZero(), ib.GetLength()); - PaintImageBuffer(ib, pw, sz, Point(0, 0)); + Fill(~ib, IsPrinter() ? White() : SColorPaper(), ib.GetLength()); + PaintImageBuffer(ib, pw, sz, Point(0, 0), IsPrinter()); DrawImage(target.left, target.top, ib); } } diff --git a/uppsrc/Draw/Draw.h b/uppsrc/Draw/Draw.h index 0f4828e7b..9f634cfbd 100644 --- a/uppsrc/Draw/Draw.h +++ b/uppsrc/Draw/Draw.h @@ -473,10 +473,35 @@ void SColorDkShadow_Write(Color c); inline Color InvertColor() { return Color(255, 0); } inline Color DefaultInk() { return Black(); } //TODO! +class Painting : AssignValueTypeNo >{ + 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(*this); } + Painting(const Value& q) { *this = RichValue::Extract(q); } + + Painting() { size = Null; } + Painting(const Nuller&) { size = Null; } +}; + bool HasPainter(); -void PaintImageBuffer(ImageBuffer& ib, const Painting& p, Size sz, Point pos); -void PaintImageBuffer(ImageBuffer& ib, const Painting& p); -void PaintImageBuffer(ImageBuffer& ib, const Drawing& p); +void PaintImageBuffer(ImageBuffer& ib, const Painting& p, Size sz, Point pos, bool noaa = false); +void PaintImageBuffer(ImageBuffer& ib, const Painting& p, bool noaa = false); +void PaintImageBuffer(ImageBuffer& ib, const Drawing& p, bool noaa = false); class Draw { protected: @@ -693,6 +718,7 @@ public: DRAWPOLYPOLYLINE = 16, DRAWPOLYPOLYPOLYGON = 17, DRAWDATA = 18, + DRAWPAINTING = 19, }; typedef void (*Drawer)(Draw&, Stream&, const DrawingPos&); @@ -1064,6 +1090,7 @@ public: Color ink, int n, const int *dx); virtual void DrawDrawingOp(const Rect& target, const Drawing& w); + virtual void DrawPaintingOp(const Rect& target, const Painting& w); private: Size size; diff --git a/uppsrc/Draw/Drawing.cpp b/uppsrc/Draw/Drawing.cpp index 7d20506b0..45b3e7812 100644 --- a/uppsrc/Draw/Drawing.cpp +++ b/uppsrc/Draw/Drawing.cpp @@ -381,6 +381,13 @@ static void wsDrawDrawing(Draw& w, Stream& s, const DrawingPos& ps) { 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) { int x1, y1, x2, y2, width; Color color; @@ -591,6 +598,7 @@ void Draw::DrawDrawingOp(const Rect& target, const Drawing& w) { Register(DRAWRECT, wsDrawRect); Register(DRAWIMAGE, wsDrawImage); Register(DRAWDRAWING, wsDrawDrawing); + Register(DRAWPAINTING, wsDrawPainting); Register(DRAWLINE, wsDrawLine); Register(DRAWELLIPSE, wsDrawEllipse); Register(DRAWTEXT, wsDrawText); @@ -639,6 +647,11 @@ void DrawingDraw::DrawDrawingOp(const Rect& target, const Drawing& w) return; } +void DrawingDraw::DrawPaintingOp(const Rect& target, const Painting& w) +{ + DrawingOp(DRAWPAINTING) % const_cast(w) % const_cast(target); +} + void Draw::DrawDrawing(int x, int y, int cx, int cy, const Drawing& w) { DrawDrawing(RectC(x, y, cx, cy), w); } diff --git a/uppsrc/Painter/BufferPainter.cpp b/uppsrc/Painter/BufferPainter.cpp index 3e2e6148a..cfd750aaf 100644 --- a/uppsrc/Painter/BufferPainter.cpp +++ b/uppsrc/Painter/BufferPainter.cpp @@ -1,155 +1,156 @@ -#include "Painter.h" - -NAMESPACE_UPP - -#define LTIMING(x) RTIMING(x) - -void BufferPainter::ClearOp(const RGBA& color) -{ - Upp::Fill(~buffer, color, buffer.GetLength()); -} - -inline void BufferPainter::PathPoint0(double x, double y) -{ - pathrect.left = min(pathrect.left, x); - pathrect.top = min(pathrect.top, y); - pathrect.right = max(pathrect.right, x); - pathrect.bottom = max(pathrect.bottom, y); -} - -inline void BufferPainter::PathPoint(double& x, double& y, bool rel) -{ - x = IsNull(x) ? current.x : rel ? x + current.x : x; - y = IsNull(y) ? current.y : rel ? y + current.y : y; - if(inpath) - PathPoint0(x, y); - else { - path.remove_all(); - pathrect.left = pathrect.right = x; - pathrect.top = pathrect.bottom = y; - pathattr = attr; - } - inpath = true; -} - -inline void BufferPainter::EndPoint(double& x, double& y, bool rel) -{ - PathPoint(x, y, rel); - current = Pointf(x, y); -} - -void BufferPainter::MoveOp(double x, double y, bool rel) -{ - EndPoint(x, y, rel); - ccontrol = qcontrol = current; - path.move_to(x, y); - inpath = true; -} - -void BufferPainter::LineOp(double x, double y, bool rel) -{ - EndPoint(x, y, rel); - ccontrol = qcontrol = current; - path.line_to(x, y); - inpath = true; -} - -void BufferPainter::QuadraticOp(double x1, double y1, double x, double y, bool rel) -{ - PathPoint(x1, y1, rel); - qcontrol = Pointf(x1, y1); - EndPoint(x, y, rel); - ccontrol = current; - path.curve3(x1, y1, x, y); -} - -void BufferPainter::QuadraticOp(double x, double y, bool rel) -{ - qcontrol = current + current - qcontrol; - PathPoint0(qcontrol.x, qcontrol.y); - EndPoint(x, y, rel); - ccontrol = current; - 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) -{ - PathPoint(x1, y1, rel); - PathPoint(x2, y2, rel); - ccontrol = Pointf(x2, y2); - EndPoint(x, y, rel); - qcontrol = current; - path.curve4(x1, y1, x2, y2, x, y); -} - -void BufferPainter::CubicOp(double x2, double y2, double x, double y, bool rel) -{ - Pointf c = current + current - ccontrol; - PathPoint0(c.x, c.y); - PathPoint(x2, y2, rel); - ccontrol = Pointf(x2, y2); - EndPoint(x, y, rel); - qcontrol = current; - path.curve4(c.x, c.y, x2, y2, x, y); -} - -void BufferPainter::CloseOp() -{ - path.close_polygon(); -} - -inline void BufferPainter::MinMax(Pointf& minv, Pointf& maxv, Pointf p) const -{ - p = pathattr.mtx.Transformed(p); - minv.x = min(minv.x, p.x); - minv.y = min(minv.y, p.y); - maxv.x = max(maxv.x, p.x); - maxv.y = max(maxv.y, p.y); -} - -bool BufferPainter::PathVisible(double w) const -{ - Pointf h = pathattr.mtx.Transformed(w, w); - w = max(fabs(h.x), fabs(h.y)); - Pointf min; - Pointf max; - min = max = pathattr.mtx.Transformed(pathrect.TopLeft()); - MinMax(min, max, pathrect.TopRight()); - MinMax(min, max, pathrect.BottomLeft()); - MinMax(min, max, pathrect.BottomRight()); - return max.x + w >= 0 && max.y + w >= 0 && min.x - w <= sizef.cx && min.y - w <= sizef.cy; -} - -void BufferPainter::SetRbuf() -{ - pixf.attach(buffer); - renb.attach(pixf); - renderer.attach(renb); -} - -BufferPainter::BufferPainter(ImageBuffer& ib) -: buffer(ib), - curved(path), - curved_trans(curved, attr.mtx) -{ - size = ib.GetSize(); - sizef = size; - inpath = false; - pathrect = Null; - ccontrol = qcontrol = current = Point(0, 0); - - attr.cap = LINECAP_BUTT; - attr.join = LINEJOIN_MITER; - attr.miter_limit = 4; - attr.evenodd = false; - attr.hasclip = false; - attr.cliplevel = 0; - attr.dash_start = 0.0; - attr.opacity = 1.0; - attr.mask = false; - pathattr = attr; - - SetRbuf(); -} - -END_UPP_NAMESPACE +#include "Painter.h" + +NAMESPACE_UPP + +#define LTIMING(x) RTIMING(x) + +void BufferPainter::ClearOp(const RGBA& color) +{ + Upp::Fill(~buffer, color, buffer.GetLength()); +} + +inline void BufferPainter::PathPoint0(double x, double y) +{ + pathrect.left = min(pathrect.left, x); + pathrect.top = min(pathrect.top, y); + pathrect.right = max(pathrect.right, x); + pathrect.bottom = max(pathrect.bottom, y); +} + +inline void BufferPainter::PathPoint(double& x, double& y, bool rel) +{ + x = IsNull(x) ? current.x : rel ? x + current.x : x; + y = IsNull(y) ? current.y : rel ? y + current.y : y; + if(inpath) + PathPoint0(x, y); + else { + path.remove_all(); + pathrect.left = pathrect.right = x; + pathrect.top = pathrect.bottom = y; + pathattr = attr; + } + inpath = true; +} + +inline void BufferPainter::EndPoint(double& x, double& y, bool rel) +{ + PathPoint(x, y, rel); + current = Pointf(x, y); +} + +void BufferPainter::MoveOp(double x, double y, bool rel) +{ + EndPoint(x, y, rel); + ccontrol = qcontrol = current; + path.move_to(x, y); + inpath = true; +} + +void BufferPainter::LineOp(double x, double y, bool rel) +{ + EndPoint(x, y, rel); + ccontrol = qcontrol = current; + path.line_to(x, y); + inpath = true; +} + +void BufferPainter::QuadraticOp(double x1, double y1, double x, double y, bool rel) +{ + PathPoint(x1, y1, rel); + qcontrol = Pointf(x1, y1); + EndPoint(x, y, rel); + ccontrol = current; + path.curve3(x1, y1, x, y); +} + +void BufferPainter::QuadraticOp(double x, double y, bool rel) +{ + qcontrol = current + current - qcontrol; + PathPoint0(qcontrol.x, qcontrol.y); + EndPoint(x, y, rel); + ccontrol = current; + 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) +{ + PathPoint(x1, y1, rel); + PathPoint(x2, y2, rel); + ccontrol = Pointf(x2, y2); + EndPoint(x, y, rel); + qcontrol = current; + path.curve4(x1, y1, x2, y2, x, y); +} + +void BufferPainter::CubicOp(double x2, double y2, double x, double y, bool rel) +{ + Pointf c = current + current - ccontrol; + PathPoint0(c.x, c.y); + PathPoint(x2, y2, rel); + ccontrol = Pointf(x2, y2); + EndPoint(x, y, rel); + qcontrol = current; + path.curve4(c.x, c.y, x2, y2, x, y); +} + +void BufferPainter::CloseOp() +{ + path.close_polygon(); +} + +inline void BufferPainter::MinMax(Pointf& minv, Pointf& maxv, Pointf p) const +{ + p = pathattr.mtx.Transformed(p); + minv.x = min(minv.x, p.x); + minv.y = min(minv.y, p.y); + maxv.x = max(maxv.x, p.x); + maxv.y = max(maxv.y, p.y); +} + +bool BufferPainter::PathVisible(double w) const +{ + Pointf h = pathattr.mtx.Transformed(w, w); + w = max(fabs(h.x), fabs(h.y)); + Pointf min; + Pointf max; + min = max = pathattr.mtx.Transformed(pathrect.TopLeft()); + MinMax(min, max, pathrect.TopRight()); + MinMax(min, max, pathrect.BottomLeft()); + MinMax(min, max, pathrect.BottomRight()); + return max.x + w >= 0 && max.y + w >= 0 && min.x - w <= sizef.cx && min.y - w <= sizef.cy; +} + +void BufferPainter::SetRbuf() +{ + pixf.attach(buffer); + renb.attach(pixf); + renderer.attach(renb); +} + +BufferPainter::BufferPainter(ImageBuffer& ib) +: buffer(ib), + curved(path), + curved_trans(curved, attr.mtx) +{ + size = ib.GetSize(); + sizef = size; + inpath = false; + pathrect = Null; + ccontrol = qcontrol = current = Point(0, 0); + + attr.cap = LINECAP_BUTT; + attr.join = LINEJOIN_MITER; + attr.miter_limit = 4; + attr.evenodd = false; + attr.hasclip = false; + attr.cliplevel = 0; + attr.dash_start = 0.0; + attr.opacity = 1.0; + attr.mask = false; + attr.noaa = false; + pathattr = attr; + + SetRbuf(); +} + +END_UPP_NAMESPACE diff --git a/uppsrc/Painter/BufferPainter.h b/uppsrc/Painter/BufferPainter.h index 5194eaa38..7d8a1f5bd 100644 --- a/uppsrc/Painter/BufferPainter.h +++ b/uppsrc/Painter/BufferPainter.h @@ -65,6 +65,8 @@ protected: virtual void MiterLimitOp(double l); virtual void EvenOddOp(bool evenodd); virtual void DashOp(const Vector& dash, double start); + virtual void NoAAOp(bool noaa); + virtual void TransformOp(const Matrix2D& m); @@ -122,7 +124,9 @@ private: typedef byte value_type; typedef int calc_type; typedef agg::const_row_info row_data; - + + bool noaa; + void attach(ImageBuffer& ib) { buffer = ib; sz = ib.GetSize(); } int width() const { return sz.cx; } @@ -195,6 +199,7 @@ private: int cliplevel; bool hasclip; bool mask; + bool noaa; }; Attr attr; diff --git a/uppsrc/Painter/Context.cpp b/uppsrc/Painter/Context.cpp index 3a0596a6a..47a8fb3b2 100644 --- a/uppsrc/Painter/Context.cpp +++ b/uppsrc/Painter/Context.cpp @@ -23,9 +23,8 @@ void BufferPainter::EndOp() void BufferPainter::TransformOp(const Matrix2D& m) { ASSERT_(!inpath, "Cannot change transformation during path definition"); - pathattr.mtx = m * attr.mtx; - if(!inpath) - attr.mtx = m * attr.mtx; + attr.mtx = m * attr.mtx; + pathattr.mtx = attr.mtx; } void BufferPainter::OpacityOp(double o) @@ -73,4 +72,11 @@ void BufferPainter::DashOp(const Vector& dash, double start) } } +void BufferPainter::NoAAOp(bool noaa) +{ + pathattr.noaa = noaa; + if(!inpath) + attr.noaa = noaa; +} + END_UPP_NAMESPACE diff --git a/uppsrc/Painter/Fill.cpp b/uppsrc/Painter/Fill.cpp index b099bf1c7..1e0c2086d 100644 --- a/uppsrc/Painter/Fill.cpp +++ b/uppsrc/Painter/Fill.cpp @@ -6,6 +6,7 @@ void BufferPainter::FillOp(const RGBA& c) { if(inpath) path.close_polygon(); + pixf.noaa = pathattr.noaa; RGBA color = c; if(PathVisible(0) && color.a) { if(pathattr.opacity != 1.0) { @@ -177,6 +178,7 @@ void BufferPainter::FillOp(const Image& image, const Matrix2D& transsrc, dword f path.close_polygon(); span_alloc sa; + pixf.noaa = pathattr.noaa; Matrix2D m = transsrc * pathattr.mtx; m.invert(); UppImageAggSpan sg; diff --git a/uppsrc/Painter/FontWin32.cpp b/uppsrc/Painter/FontWin32.cpp index 504dfd031..f3e7d05c2 100644 --- a/uppsrc/Painter/FontWin32.cpp +++ b/uppsrc/Painter/FontWin32.cpp @@ -96,7 +96,6 @@ struct sMakeCharOutline : LRUCache::Maker { void Painter::CharacterOp(double x, double y, int ch, Font fnt) { - RTIMING("Character"); String s; INTERLOCKED { static LRUCache cache; @@ -106,7 +105,7 @@ void Painter::CharacterOp(double x, double y, int ch, Font fnt) h.fc.chr = ch; s = cache.Get(h); } - RenderCharPath(s, s.GetLength(), *this, x, y); + RenderCharPath(s, s.GetLength(), *this, x, y + fnt.Info().GetAscent()); EvenOdd(true); } diff --git a/uppsrc/Painter/FontX11.cpp b/uppsrc/Painter/FontX11.cpp index a4319ff1d..6f93a0605 100644 --- a/uppsrc/Painter/FontX11.cpp +++ b/uppsrc/Painter/FontX11.cpp @@ -1,151 +1,151 @@ -//---------------------------------------------------------------------------- -// Anti-Grain Geometry - Version 2.4 -// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all coM_PIes. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -//---------------------------------------------------------------------------- -// Contact: mcseem@antigrain.com -// mcseemagg@yahoo.com -// http://www.antigrain.com -//---------------------------------------------------------------------------- - -// Recycled for U++ by Miroslav Fidler 2008 - -#include "Painter.h" - -NAMESPACE_UPP - -#ifdef PLATFORM_X11 - -static inline double ft_dbl(int p) -{ - return double(p) / 64.0; -} - -bool RenderOutline(const FT_Outline& outline, Painter& path, double xx, double yy) -{ - FT_Vector v_last; - FT_Vector v_control; - FT_Vector v_start; - double x1, y1, x2, y2, x3, y3; - FT_Vector* point; - FT_Vector* limit; - char* tags; - int n; // index of contour in outline - char tag; // current point's state - int first = 0; // index of first point in contour - for(n = 0; n < outline.n_contours; n++) { - int last = outline.contours[n]; - limit = outline.points + last; - v_start = outline.points[first]; - v_last = outline.points[last]; - v_control = v_start; - point = outline.points + first; - tags = outline.tags + first; - tag = FT_CURVE_TAG(tags[0]); - if(tag == FT_CURVE_TAG_CUBIC) return false; - if(tag == FT_CURVE_TAG_CONIC) { - if(FT_CURVE_TAG(outline.tags[last]) == FT_CURVE_TAG_ON) { - // start at last point if it is on the curve - v_start = v_last; - limit--; - } - else { - // if both first and last points are conic, - // start at their middle and record its position - // for closure - v_start.x = (v_start.x + v_last.x) / 2; - v_start.y = (v_start.y + v_last.y) / 2; - v_last = v_start; - } - point--; - tags--; - } - path.Move(ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy); - while(point < limit) { - point++; - tags++; - - tag = FT_CURVE_TAG(tags[0]); - switch(tag) { - case FT_CURVE_TAG_ON: - path.Line(ft_dbl(point->x) + xx, -ft_dbl(point->y) + yy); - continue; - case FT_CURVE_TAG_CONIC: - v_control.x = point->x; - v_control.y = point->y; - Do_Conic: - if(point < limit) { - FT_Vector vec; - FT_Vector v_middle; - point++; - tags++; - tag = FT_CURVE_TAG(tags[0]); - vec.x = point->x; - vec.y = point->y; - if(tag == FT_CURVE_TAG_ON) { - path.Quadratic(ft_dbl(v_control.x) + xx, -ft_dbl(v_control.y) + yy, - ft_dbl(vec.x) + xx, -ft_dbl(vec.y) + yy); - continue; - } - if(tag != FT_CURVE_TAG_CONIC) return false; - v_middle.x = (v_control.x + vec.x) / 2; - v_middle.y = (v_control.y + vec.y) / 2; - 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); - v_control = vec; - goto Do_Conic; - } - 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); - goto Close; - - default: - FT_Vector vec1, vec2; - if(point + 1 > limit || FT_CURVE_TAG(tags[1]) != FT_CURVE_TAG_CUBIC) - return false; - vec1.x = point[0].x; - vec1.y = point[0].y; - vec2.x = point[1].x; - vec2.y = point[1].y; - point += 2; - tags += 2; - if(point <= limit) { - FT_Vector vec; - vec.x = point->x; - vec.y = point->y; - path.Cubic(ft_dbl(vec1.x) + xx, -ft_dbl(vec1.y) + yy, - ft_dbl(vec2.x) + xx, -ft_dbl(vec2.y) + yy, - ft_dbl(vec.x) + xx, -ft_dbl(vec.y) + yy); - continue; - } - path.Cubic(ft_dbl(vec1.x) + xx, -ft_dbl(vec1.y) + yy, - ft_dbl(vec2.x) + xx, -ft_dbl(vec2.y) + yy, - ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy); - goto Close; - } - } - Close: - path.Close(); - first = last + 1; - } - return true; -} - -void Painter::CharacterOp(double x, double y, int ch, Font fnt) -{ - FontInfo fi = fnt.Info(); - FT_Face face = XftLockFace(fi.GetXftFont()); - int glyph_index = FT_Get_Char_Index(face, ch); - if(FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT) == 0) - RenderOutline(face->glyph->outline, *this, x, y); - XftUnlockFace(fi.GetXftFont()); -} - -#endif - -END_UPP_NAMESPACE +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all coM_PIes. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mcseem@antigrain.com +// mcseemagg@yahoo.com +// http://www.antigrain.com +//---------------------------------------------------------------------------- + +// Recycled for U++ by Miroslav Fidler 2008 + +#include "Painter.h" + +NAMESPACE_UPP + +#ifdef PLATFORM_X11 + +static inline double ft_dbl(int p) +{ + return double(p) / 64.0; +} + +bool RenderOutline(const FT_Outline& outline, Painter& path, double xx, double yy) +{ + FT_Vector v_last; + FT_Vector v_control; + FT_Vector v_start; + double x1, y1, x2, y2, x3, y3; + FT_Vector* point; + FT_Vector* limit; + char* tags; + int n; // index of contour in outline + char tag; // current point's state + int first = 0; // index of first point in contour + for(n = 0; n < outline.n_contours; n++) { + int last = outline.contours[n]; + limit = outline.points + last; + v_start = outline.points[first]; + v_last = outline.points[last]; + v_control = v_start; + point = outline.points + first; + tags = outline.tags + first; + tag = FT_CURVE_TAG(tags[0]); + if(tag == FT_CURVE_TAG_CUBIC) return false; + if(tag == FT_CURVE_TAG_CONIC) { + if(FT_CURVE_TAG(outline.tags[last]) == FT_CURVE_TAG_ON) { + // start at last point if it is on the curve + v_start = v_last; + limit--; + } + else { + // if both first and last points are conic, + // start at their middle and record its position + // for closure + v_start.x = (v_start.x + v_last.x) / 2; + v_start.y = (v_start.y + v_last.y) / 2; + v_last = v_start; + } + point--; + tags--; + } + path.Move(ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy); + while(point < limit) { + point++; + tags++; + + tag = FT_CURVE_TAG(tags[0]); + switch(tag) { + case FT_CURVE_TAG_ON: + path.Line(ft_dbl(point->x) + xx, -ft_dbl(point->y) + yy); + continue; + case FT_CURVE_TAG_CONIC: + v_control.x = point->x; + v_control.y = point->y; + Do_Conic: + if(point < limit) { + FT_Vector vec; + FT_Vector v_middle; + point++; + tags++; + tag = FT_CURVE_TAG(tags[0]); + vec.x = point->x; + vec.y = point->y; + if(tag == FT_CURVE_TAG_ON) { + path.Quadratic(ft_dbl(v_control.x) + xx, -ft_dbl(v_control.y) + yy, + ft_dbl(vec.x) + xx, -ft_dbl(vec.y) + yy); + continue; + } + if(tag != FT_CURVE_TAG_CONIC) return false; + v_middle.x = (v_control.x + vec.x) / 2; + v_middle.y = (v_control.y + vec.y) / 2; + 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); + v_control = vec; + goto Do_Conic; + } + 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); + goto Close; + + default: + FT_Vector vec1, vec2; + if(point + 1 > limit || FT_CURVE_TAG(tags[1]) != FT_CURVE_TAG_CUBIC) + return false; + vec1.x = point[0].x; + vec1.y = point[0].y; + vec2.x = point[1].x; + vec2.y = point[1].y; + point += 2; + tags += 2; + if(point <= limit) { + FT_Vector vec; + vec.x = point->x; + vec.y = point->y; + path.Cubic(ft_dbl(vec1.x) + xx, -ft_dbl(vec1.y) + yy, + ft_dbl(vec2.x) + xx, -ft_dbl(vec2.y) + yy, + ft_dbl(vec.x) + xx, -ft_dbl(vec.y) + yy); + continue; + } + path.Cubic(ft_dbl(vec1.x) + xx, -ft_dbl(vec1.y) + yy, + ft_dbl(vec2.x) + xx, -ft_dbl(vec2.y) + yy, + ft_dbl(v_start.x) + xx, -ft_dbl(v_start.y) + yy); + goto Close; + } + } + Close: + path.Close(); + first = last + 1; + } + return true; +} + +void Painter::CharacterOp(double x, double y, int ch, Font fnt) +{ + FontInfo fi = fnt.Info(); + FT_Face face = XftLockFace(fi.GetXftFont()); + int glyph_index = FT_Get_Char_Index(face, ch); + if(FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT) == 0) + RenderOutline(face->glyph->outline, *this, x, y + fnt.Info().GetAscent()); + XftUnlockFace(fi.GetXftFont()); +} + +#endif + +END_UPP_NAMESPACE diff --git a/uppsrc/Painter/PaintPainting.icpp b/uppsrc/Painter/PaintPainting.icpp index 382e8ddac..970f0a164 100644 --- a/uppsrc/Painter/PaintPainting.icpp +++ b/uppsrc/Painter/PaintPainting.icpp @@ -30,7 +30,7 @@ void Painter::Paint(const Painting& pic) { StringStream ss(pic.cmd); Pointf p, p1, p2; - Color c, c1; + RGBA c, c1; Value v; int f, ch, n, hasdx; Matrix2D m; @@ -117,6 +117,7 @@ void Painter::Paint(const Painting& pic) sGet(w, ss); sGet(c, ss); Stroke(w, c); + DDUMP((Color)c); break; case PAINTING_STROKE_IMAGE: sGet(w, ss); @@ -206,6 +207,9 @@ void Painter::Paint(const Painting& pic) Dash(dash, r); } break; + case PAINTING_NOAA: + NoAA(ss.Get()); + break; case PAINTING_TRANSFORM: sGet(m, ss); 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); + sw.NoAA(noaa); Sizef psz = p.GetSize(); sw.Translate(-pos.x, -pos.y); sw.Scale(sz.cx / psz.cx, sz.cy / psz.cy); sw.Paint(p); } -void PaintImageBufferDrawingFn(ImageBuffer& ib, const Drawing& iw) +void PaintImageBufferDrawingFn(ImageBuffer& ib, const Drawing& iw, bool noaa) { BufferPainter sw(ib); + sw.NoAA(noaa); Sizef sz = ib.GetSize(); Size isz = iw.GetSize(); sw.Scale(sz.cx / isz.cx, sz.cy / isz.cy); sw.DrawDrawing(0, 0, isz.cx, isz.cy, iw); } -void RegisterPaintingFns__(void (*ig)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos), - void (*iw)(ImageBuffer& ib, const Drawing& p)); +void RegisterPaintingFns__(void (*ig)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos, bool noaa), + void (*iw)(ImageBuffer& ib, const Drawing& p, bool noaa)); INITBLOCK diff --git a/uppsrc/Painter/Painter.cpp b/uppsrc/Painter/Painter.cpp index f20a50e81..14348ec7f 100644 --- a/uppsrc/Painter/Painter.cpp +++ b/uppsrc/Painter/Painter.cpp @@ -42,6 +42,7 @@ bool Painter::ExcludeClipOp(const Rect& r) bool Painter::IntersectClipOp(const Rect& r) { + return true; RectPath(r); Clip(); return true; @@ -123,6 +124,17 @@ void Painter::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, 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) { return Move(x, y, false); diff --git a/uppsrc/Painter/Painter.h b/uppsrc/Painter/Painter.h index fe15543ee..f3f3366a5 100644 --- a/uppsrc/Painter/Painter.h +++ b/uppsrc/Painter/Painter.h @@ -99,6 +99,7 @@ protected: 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, Color ink, int n, const int *dx); + virtual void DrawPaintingOp(const Rect& target, const Painting& w); protected: virtual void ClearOp(const RGBA& color) = 0; @@ -144,6 +145,7 @@ protected: virtual void MiterLimitOp(double l) = 0; virtual void EvenOddOp(bool evenodd) = 0; virtual void DashOp(const Vector& dash, double start = 0) = 0; + virtual void NoAAOp(bool noaa) = 0; virtual void TransformOp(const Matrix2D& m) = 0; @@ -229,6 +231,7 @@ public: Painter& EvenOdd(bool evenodd); Painter& Dash(const Vector& dash, double start = 0); Painter& Dash(const char *dash, double start = 0); + Painter& NoAA(bool noaa = true); void Transform(const Matrix2D& m); diff --git a/uppsrc/Painter/Painter.hpp b/uppsrc/Painter/Painter.hpp index e0df7ede5..e12e55dfc 100644 --- a/uppsrc/Painter/Painter.hpp +++ b/uppsrc/Painter/Painter.hpp @@ -1,185 +1,191 @@ -NAMESPACE_UPP - -inline void Painter::Clear(const RGBA& color) -{ - ClearOp(color); -} - -inline Painter& Painter::Move(double x, double y, bool rel) -{ - MoveOp(x, y, rel); - return *this; -} - -inline Painter& Painter::Line(double x, double y, bool rel) -{ - LineOp(x, y, rel); - return *this; -} - -inline Painter& Painter::Quadratic(double x1, double y1, double x, double y, bool rel) -{ - QuadraticOp(x1, y1, x, y, rel); - return *this; -} - -inline Painter& Painter::Quadratic(double x, double y, bool rel) -{ - QuadraticOp(x, y, rel); - return *this; -} - -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); - return *this; -} - -inline Painter& Painter::Cubic(double x2, double y2, double x, double y, bool rel) -{ - CubicOp(x2, y2, x, y, rel); - return *this; -} - -inline Painter& Painter::Close() -{ - CloseOp(); - return *this; -} - -inline Painter& Painter::Fill(const RGBA& color) -{ - FillOp(color); - return *this; -} - -inline Painter& Painter::Fill(const Image& image, const Matrix2D& transsrc, dword flags) -{ - FillOp(image, transsrc, flags); - return *this; -} - -inline Painter& Painter::Fill(double x1, double y1, const RGBA& color1, - double x2, double y2, const RGBA& color2, int style) -{ - FillOp(x1, y1, color1, x2, y2, color2, style); - return *this; -} - -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); - return *this; -} - -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); -} - -inline Painter& Painter::Stroke(double width, const RGBA& color) -{ - StrokeOp(width, color); - return *this; -} - -inline Painter& Painter::Stroke(double width, const Image& image, const Matrix2D& transsrc, dword flags) -{ - StrokeOp(width, image, transsrc, flags); - return *this; -} - -inline Painter& Painter::Stroke(double width, double x1, double y1, const RGBA& color1, - double x2, double y2, const RGBA& color2, int style) -{ - StrokeOp(width, x1, y1, color1, x2, y2, color2, style); - return *this; -} - -inline Painter& Painter::Stroke(double width, double fx, double fy, const RGBA& color1, - double x1, double y1, double r, const RGBA& color2, int style) -{ - StrokeOp(width, fx, fy, color1, x1, y1, r, color2, style); - return *this; -} - -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); -} - -inline Painter& Painter::Clip() -{ - ClipOp(); - return *this; -} - -inline Painter& Painter::ColorStop(double pos, const RGBA& color) -{ - ColorStopOp(pos, color); - return *this; -} - -inline Painter& Painter::ClearStops() -{ - ClearStopsOp(); - return *this; -} - -inline Painter& Painter::Opacity(double o) -{ - OpacityOp(o); - return *this; -} - -inline Painter& Painter::LineCap(int linecap) -{ - LineCapOp(linecap); - return *this; -} - -inline Painter& Painter::LineJoin(int linejoin) -{ - LineJoinOp(linejoin); - return *this; -} - -inline Painter& Painter::MiterLimit(double l) -{ - MiterLimitOp(l); - return *this; -} - -inline Painter& Painter::EvenOdd(bool evenodd) -{ - EvenOddOp(evenodd); - return *this; -} - -inline Painter& Painter::Dash(const Vector& dash, double start) -{ - DashOp(dash, start); - return *this; -} - -inline void Painter::Transform(const Matrix2D& m) -{ - TransformOp(m); -} - -inline void Painter::Begin() -{ - BeginOp(); -} - -inline void Painter::End() -{ - EndOp(); -} - -inline void Painter::BeginMask() -{ - BeginMaskOp(); -} - -END_UPP_NAMESPACE +NAMESPACE_UPP + +inline void Painter::Clear(const RGBA& color) +{ + ClearOp(color); +} + +inline Painter& Painter::Move(double x, double y, bool rel) +{ + MoveOp(x, y, rel); + return *this; +} + +inline Painter& Painter::Line(double x, double y, bool rel) +{ + LineOp(x, y, rel); + return *this; +} + +inline Painter& Painter::Quadratic(double x1, double y1, double x, double y, bool rel) +{ + QuadraticOp(x1, y1, x, y, rel); + return *this; +} + +inline Painter& Painter::Quadratic(double x, double y, bool rel) +{ + QuadraticOp(x, y, rel); + return *this; +} + +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); + return *this; +} + +inline Painter& Painter::Cubic(double x2, double y2, double x, double y, bool rel) +{ + CubicOp(x2, y2, x, y, rel); + return *this; +} + +inline Painter& Painter::Close() +{ + CloseOp(); + return *this; +} + +inline Painter& Painter::Fill(const RGBA& color) +{ + FillOp(color); + return *this; +} + +inline Painter& Painter::Fill(const Image& image, const Matrix2D& transsrc, dword flags) +{ + FillOp(image, transsrc, flags); + return *this; +} + +inline Painter& Painter::Fill(double x1, double y1, const RGBA& color1, + double x2, double y2, const RGBA& color2, int style) +{ + FillOp(x1, y1, color1, x2, y2, color2, style); + return *this; +} + +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); + return *this; +} + +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); +} + +inline Painter& Painter::Stroke(double width, const RGBA& color) +{ + StrokeOp(width, color); + return *this; +} + +inline Painter& Painter::Stroke(double width, const Image& image, const Matrix2D& transsrc, dword flags) +{ + StrokeOp(width, image, transsrc, flags); + return *this; +} + +inline Painter& Painter::Stroke(double width, double x1, double y1, const RGBA& color1, + double x2, double y2, const RGBA& color2, int style) +{ + StrokeOp(width, x1, y1, color1, x2, y2, color2, style); + return *this; +} + +inline Painter& Painter::Stroke(double width, double fx, double fy, const RGBA& color1, + double x1, double y1, double r, const RGBA& color2, int style) +{ + StrokeOp(width, fx, fy, color1, x1, y1, r, color2, style); + return *this; +} + +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); +} + +inline Painter& Painter::Clip() +{ + ClipOp(); + return *this; +} + +inline Painter& Painter::ColorStop(double pos, const RGBA& color) +{ + ColorStopOp(pos, color); + return *this; +} + +inline Painter& Painter::ClearStops() +{ + ClearStopsOp(); + return *this; +} + +inline Painter& Painter::Opacity(double o) +{ + OpacityOp(o); + return *this; +} + +inline Painter& Painter::LineCap(int linecap) +{ + LineCapOp(linecap); + return *this; +} + +inline Painter& Painter::LineJoin(int linejoin) +{ + LineJoinOp(linejoin); + return *this; +} + +inline Painter& Painter::MiterLimit(double l) +{ + MiterLimitOp(l); + return *this; +} + +inline Painter& Painter::EvenOdd(bool evenodd) +{ + EvenOddOp(evenodd); + return *this; +} + +inline Painter& Painter::Dash(const Vector& dash, double start) +{ + DashOp(dash, start); + return *this; +} + +inline Painter& Painter::NoAA(bool noaa) +{ + NoAAOp(noaa); + return *this; +} + +inline void Painter::Transform(const Matrix2D& m) +{ + TransformOp(m); +} + +inline void Painter::Begin() +{ + BeginOp(); +} + +inline void Painter::End() +{ + EndOp(); +} + +inline void Painter::BeginMask() +{ + BeginMaskOp(); +} + +END_UPP_NAMESPACE diff --git a/uppsrc/Painter/Painting.cpp b/uppsrc/Painter/Painting.cpp index 6ed8a6c3e..f32447785 100644 --- a/uppsrc/Painter/Painting.cpp +++ b/uppsrc/Painter/Painting.cpp @@ -93,6 +93,7 @@ void PaintingPainter::StrokeOp(double width, const RGBA& color) Put(PAINTING_STROKE_SOLID); Putf(width); Put(color); + DDUMP(Color(color)); } 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) { Put(PAINTING_CHARACTER); + Putf(x, y); Put32(ch); Put(fnt); } @@ -204,6 +206,12 @@ void PaintingPainter::DashOp(const Vector& dash, double start) Putf(start); } +void PaintingPainter::NoAAOp(bool noaa) +{ + Put(PAINTING_NOAA); + Put(noaa); +} + void PaintingPainter::TransformOp(const Matrix2D& m) { Put(PAINTING_TRANSFORM); diff --git a/uppsrc/Painter/Painting.h b/uppsrc/Painter/Painting.h index 47b75c166..0def0a2c0 100644 --- a/uppsrc/Painter/Painting.h +++ b/uppsrc/Painter/Painting.h @@ -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 { PAINTING_EOF, PAINTING_CLEAR, @@ -51,6 +39,7 @@ enum { PAINTING_MITERLIMIT, PAINTING_EVENODD, PAINTING_DASH, + PAINTING_NOAA, PAINTING_TRANSFORM, PAINTING_BEGIN, @@ -115,6 +104,7 @@ protected: virtual void MiterLimitOp(double l); virtual void EvenOddOp(bool evenodd); virtual void DashOp(const Vector& dash, double start); + virtual void NoAAOp(bool noaa); virtual void TransformOp(const Matrix2D& m); @@ -136,6 +126,3 @@ public: PaintingPainter(double cx, double cy) { Create(cx, cy); } PaintingPainter(Sizef sz) { Create(sz); } }; - -void PaintImageBuffer(ImageBuffer& ib, const Painting& p, Size sz, Point pos); -void PaintImageBuffer(ImageBuffer& ib, const Drawing& p); diff --git a/uppsrc/Painter/PixFmt.cpp b/uppsrc/Painter/PixFmt.cpp index ee6275d93..b6b8a33be 100644 --- a/uppsrc/Painter/PixFmt.cpp +++ b/uppsrc/Painter/PixFmt.cpp @@ -6,6 +6,8 @@ void BufferPainter::upp_pixfmt::blend_hline(int x, int y, int len, RGBA c, byte { if(c.a == 0) return; RGBA *t = ptr(x, y); + if(noaa) + cover = cover > 127 ? 255 : 0; if((c.a & cover) == 255) { #if 1 while(len >= 16) { @@ -57,6 +59,8 @@ void BufferPainter::upp_pixfmt::blend_solid_hspan(int x, int y, int len, RGBA *e = t + len; while(t < e) { byte cover = *covers++; + if(noaa) + cover = cover > 127 ? 255 : 0; if((cover & c.a) == 255) // is it worth it? *t++ = c; 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 *e = t + len; + if(noaa) + cover = cover > 127 ? 255 : 0; while(t < e) { - if(covers) + if(covers) { cover = *covers++; + if(noaa) + cover = cover > 127 ? 255 : 0; + } if((cover & colors->a) == 255) *t = *colors; else diff --git a/uppsrc/Painter/RadialGradient.cpp b/uppsrc/Painter/RadialGradient.cpp index 5ecb43258..04dc3936b 100644 --- a/uppsrc/Painter/RadialGradient.cpp +++ b/uppsrc/Painter/RadialGradient.cpp @@ -213,6 +213,7 @@ void BufferPainter::FillOp(double fx, double fy, const RGBA& color1, { if(inpath) path.close_polygon(); + pixf.noaa = pathattr.noaa; span_alloc sa; Matrix2D m = pathattr.mtx; m.invert(); diff --git a/uppsrc/Painter/Text.cpp b/uppsrc/Painter/Text.cpp index fcf135bf7..f9254da8d 100644 --- a/uppsrc/Painter/Text.cpp +++ b/uppsrc/Painter/Text.cpp @@ -8,7 +8,6 @@ void Painter::TextOp(double x, double y, const wchar *text, Font fnt, int n, dou FontInfo fi = fnt.Info(); if(n < 0) n = wstrlen(text); - y += fi.GetAscent(); while(n) { int ch = *text++; Character(x, y, ch, fnt);