diff --git a/uppsrc/Draw/Draw.cpp b/uppsrc/Draw/Draw.cpp index 439f9bf2f..54cad1d40 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, bool noaa); -static void (*sIwfn)(ImageBuffer& ib, const Drawing& p, bool noaa); +static void (*sIgfn)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos, int mode); +static void (*sIwfn)(ImageBuffer& ib, const Drawing& p, int mode); -void RegisterPaintingFns__(void (*ig)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos, bool noaa), - void (*iw)(ImageBuffer& ib, const Drawing& p, bool noaa)) +void RegisterPaintingFns__(void (*ig)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos, int mode), + void (*iw)(ImageBuffer& ib, const Drawing& p, int mode)) { sIgfn = ig; sIwfn = iw; @@ -351,21 +351,21 @@ bool HasPainter() return sIgfn && sIwfn; } -void PaintImageBuffer(ImageBuffer& ib, const Painting& p, Size sz, Point pos, bool noaa) +void PaintImageBuffer(ImageBuffer& ib, const Painting& p, Size sz, Point pos, int mode) { if(sIgfn) - (*sIgfn)(ib, p, sz, pos, noaa); + (*sIgfn)(ib, p, sz, pos, mode); } -void PaintImageBuffer(ImageBuffer& ib, const Painting& p, bool noaa) +void PaintImageBuffer(ImageBuffer& ib, const Painting& p, int mode) { - PaintImageBuffer(ib, p, ib.GetSize(), Point(0, 0), noaa); + PaintImageBuffer(ib, p, ib.GetSize(), Point(0, 0), mode); } -void PaintImageBuffer(ImageBuffer& ib, const Drawing& iw, bool noaa) +void PaintImageBuffer(ImageBuffer& ib, const Drawing& iw, int mode) { if(sIwfn) - (*sIwfn)(ib, iw, noaa); + (*sIwfn)(ib, iw, mode); } void Draw::DrawPaintingOp(const Rect& target, const Painting& pw) diff --git a/uppsrc/Draw/Draw.h b/uppsrc/Draw/Draw.h index ccef906f4..17be0f760 100644 --- a/uppsrc/Draw/Draw.h +++ b/uppsrc/Draw/Draw.h @@ -502,10 +502,16 @@ public: Painting(const Nuller&) { size = Null; } }; +enum { + MODE_ANTIALIASED = 0, + MODE_NOAA = 1, + MODE_SUBPIXEL = 2, +}; + bool HasPainter(); -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); +void PaintImageBuffer(ImageBuffer& ib, const Painting& p, Size sz, Point pos, int mode = MODE_ANTIALIASED); +void PaintImageBuffer(ImageBuffer& ib, const Painting& p, int mode = MODE_ANTIALIASED); +void PaintImageBuffer(ImageBuffer& ib, const Drawing& p, int mode = MODE_ANTIALIASED); class Draw { protected: diff --git a/uppsrc/Painter/BufferPainter.h b/uppsrc/Painter/BufferPainter.h index 0566a435b..5c4ab7632 100644 --- a/uppsrc/Painter/BufferPainter.h +++ b/uppsrc/Painter/BufferPainter.h @@ -302,7 +302,7 @@ public: }; ImageBuffer& ib; - int quality; + int mode; Buffer subpixel; int render_cx; @@ -341,5 +341,5 @@ public: void FinishMask(); public: - BufferPainter(ImageBuffer& ib, int quality = 0); + BufferPainter(ImageBuffer& ib, int mode = 0); }; diff --git a/uppsrc/Painter/Context.cpp b/uppsrc/Painter/Context.cpp index c2de3c2f0..828211e50 100644 --- a/uppsrc/Painter/Context.cpp +++ b/uppsrc/Painter/Context.cpp @@ -98,15 +98,15 @@ void BufferPainter::ClearStopsOp() } } -BufferPainter::BufferPainter(ImageBuffer& ib, int quality_) +BufferPainter::BufferPainter(ImageBuffer& ib, int mode) : ib(ib), - quality(quality_), - rasterizer(quality_ == QUALITY_SUBPIXEL ? 3 * ib.GetWidth() : ib.GetWidth(), ib.GetHeight()) + mode(mode), + rasterizer(mode == MODE_SUBPIXEL ? 3 * ib.GetWidth() : ib.GetWidth(), ib.GetHeight()) { ClearPath(); render_cx = ib.GetWidth(); - if(quality == QUALITY_SUBPIXEL) { + if(mode == MODE_SUBPIXEL) { render_cx *= 3; subpixel.Alloc(render_cx + 30); } diff --git a/uppsrc/Painter/Mask.cpp b/uppsrc/Painter/Mask.cpp index 610dfd035..a3ba1944b 100644 --- a/uppsrc/Painter/Mask.cpp +++ b/uppsrc/Painter/Mask.cpp @@ -30,7 +30,7 @@ static inline byte *sSpan(byte *t, int c, int& len) void BufferPainter::FinishMask() { - Buffer wb(quality == QUALITY_SUBPIXEL ? 6 * ib.GetWidth() : 2 * ib.GetWidth()); + Buffer wb(mode == MODE_SUBPIXEL ? 6 * ib.GetWidth() : 2 * ib.GetWidth()); bool creating = false; if(!attr.hasclip) { clip.Add().Alloc(ib.GetHeight()); @@ -53,7 +53,7 @@ void BufferPainter::FinishMask() if(val == 0) { if(c256) t = sSpan(t, 128, c256); c0++; - if(quality == QUALITY_SUBPIXEL) + if(mode == MODE_SUBPIXEL) c0 += 2; full = false; } @@ -61,7 +61,7 @@ void BufferPainter::FinishMask() if(val == 256) { if(c0) t = sSpan(t, 0, c0); c256++; - if(quality == QUALITY_SUBPIXEL) + if(mode == MODE_SUBPIXEL) c256 += 2; empty = false; } @@ -69,7 +69,7 @@ void BufferPainter::FinishMask() if(c256) t = sSpan(t, 128, c256); if(c0) t = sSpan(t, 0, c0); *t++ = val; - if(quality == QUALITY_SUBPIXEL) { + if(mode == MODE_SUBPIXEL) { *t++ = val; *t++ = val; } diff --git a/uppsrc/Painter/PaintPainting.icpp b/uppsrc/Painter/PaintPainting.icpp index 1eef486c1..0fd015d46 100644 --- a/uppsrc/Painter/PaintPainting.icpp +++ b/uppsrc/Painter/PaintPainting.icpp @@ -235,26 +235,26 @@ void Painter::Paint(const Painting& pic) } } -void PaintImageBufferPaintingFn(ImageBuffer& ib, const Painting& p, Size sz, Point pos, bool noaa) +void PaintImageBufferPaintingFn(ImageBuffer& ib, const Painting& p, Size sz, Point pos, int mode) { - BufferPainter sw(ib, noaa ? QUALITY_NOAA : QUALITY_ANTIALIASED); + BufferPainter sw(ib, mode); 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, bool noaa) +void PaintImageBufferDrawingFn(ImageBuffer& ib, const Drawing& iw, int mode) { - BufferPainter sw(ib, noaa ? QUALITY_NOAA : QUALITY_ANTIALIASED); + BufferPainter sw(ib, mode); 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, bool noaa), - void (*iw)(ImageBuffer& ib, const Drawing& p, bool noaa)); +void RegisterPaintingFns__(void (*ig)(ImageBuffer& ib, const Painting& pw, Size sz, Point pos, int mode), + void (*iw)(ImageBuffer& ib, const Drawing& p, int mode)); INITBLOCK diff --git a/uppsrc/Painter/Painter.h b/uppsrc/Painter/Painter.h index 6ba6291b8..7f3b67623 100644 --- a/uppsrc/Painter/Painter.h +++ b/uppsrc/Painter/Painter.h @@ -57,10 +57,6 @@ enum { GRADIENT_PAD = 0, GRADIENT_REPEAT = 1, GRADIENT_REFLECT = 2, - - QUALITY_NOAA = 0, - QUALITY_ANTIALIASED = 1, - QUALITY_SUBPIXEL = 2, }; class Painter : public Draw { diff --git a/uppsrc/Painter/Render.cpp b/uppsrc/Painter/Render.cpp index d3c8e1391..a451d6aa3 100644 --- a/uppsrc/Painter/Render.cpp +++ b/uppsrc/Painter/Render.cpp @@ -80,7 +80,7 @@ Buffer BufferPainter::RenderPath(double width, SpanSource *ss, const R rg = &solid_filler; } } - if(quality == QUALITY_NOAA) { + if(mode == MODE_NOAA) { noaa_filler.Set(rg); rg = &noaa_filler; }