mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-16 14:16:09 -06:00
PaintImageBuffer - mode parameter
git-svn-id: svn://ultimatepp.org/upp/trunk@891 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
38a8fbf68f
commit
cbcc62bd8b
8 changed files with 36 additions and 34 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ public:
|
|||
};
|
||||
|
||||
ImageBuffer& ib;
|
||||
int quality;
|
||||
int mode;
|
||||
Buffer<int16> subpixel;
|
||||
int render_cx;
|
||||
|
||||
|
|
@ -341,5 +341,5 @@ public:
|
|||
void FinishMask();
|
||||
|
||||
public:
|
||||
BufferPainter(ImageBuffer& ib, int quality = 0);
|
||||
BufferPainter(ImageBuffer& ib, int mode = 0);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ static inline byte *sSpan(byte *t, int c, int& len)
|
|||
|
||||
void BufferPainter::FinishMask()
|
||||
{
|
||||
Buffer<byte> wb(quality == QUALITY_SUBPIXEL ? 6 * ib.GetWidth() : 2 * ib.GetWidth());
|
||||
Buffer<byte> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ Buffer<ClipLine> 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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue