diff --git a/rainbow/Framebuffer/After.h b/rainbow/Framebuffer/After.h index 07ca00ceb..6c4079d1b 100644 --- a/rainbow/Framebuffer/After.h +++ b/rainbow/Framebuffer/After.h @@ -1,7 +1,9 @@ -class ViewDraw : public NilDraw { +class ViewDraw : public SystemDraw { + ImageBuffer ib; + public: - ViewDraw(Ctrl *ctrl); - ~ViewDraw(); + ViewDraw(Ctrl *ctrl) : SystemDraw(ib) { _DBG_ } + ~ViewDraw() {} }; class DHCtrl : Ctrl {}; diff --git a/rainbow/Framebuffer/Draw.cpp b/rainbow/Framebuffer/Draw.cpp index a9493bbd6..d7796dc86 100644 --- a/rainbow/Framebuffer/Draw.cpp +++ b/rainbow/Framebuffer/Draw.cpp @@ -12,6 +12,7 @@ NAMESPACE_UPP GuiLock __; }*/ +/* void BackDraw::Destroy() { GuiLock __; @@ -24,6 +25,7 @@ void BackDraw::Create(SystemDraw& w, int cx, int cy) { void BackDraw::Put(SystemDraw& w, int x, int y) { GuiLock __; } +*/ END_UPP_NAMESPACE diff --git a/rainbow/Framebuffer/Framebuffer.h b/rainbow/Framebuffer/Framebuffer.h index bf3819c88..2a738caea 100644 --- a/rainbow/Framebuffer/Framebuffer.h +++ b/rainbow/Framebuffer/Framebuffer.h @@ -6,28 +6,37 @@ NAMESPACE_UPP class SystemDraw : public BufferPainter { public: - Point GetOffset() const { return Point(0, 0); } - bool CanSetSurface() { return false; } - static void Flush() {} + Point GetOffset() const { return Point(0, 0); } + bool CanSetSurface() { return false; } + bool Clip(const Rect& r) { return Draw::Clip(r); } + bool Clip(int x, int y, int cx, int cy) { return Draw::Clip(x, y, cx, cy); } + static void Flush() {} SystemDraw(ImageBuffer& ib, int mode = MODE_ANTIALIASED) : BufferPainter(ib, mode) {} }; -class BackDraw : public SystemDraw { +struct BackDraw__ : public SystemDraw { + ImageBuffer h; + + BackDraw__() : SystemDraw(h) {} +}; + +class BackDraw : public BackDraw__ { // Dummy only, as we are running in GlobalBackBuffer mode Size size; Draw *painting; Point painting_offset; + ImageBuffer ib; public: virtual bool IsPaintingOp(const Rect& r) const; public: - void Put(SystemDraw& w, int x, int y); + void Put(SystemDraw& w, int x, int y) {} void Put(SystemDraw& w, Point p) { Put(w, p.x, p.y); } - void Create(SystemDraw& w, int cx, int cy); + void Create(SystemDraw& w, int cx, int cy) {} void Create(SystemDraw& w, Size sz) { Create(w, sz.cx, sz.cy); } - void Destroy(); + void Destroy() {} void SetPaintingDraw(Draw& w, Point off) { painting = &w; painting_offset = off; } @@ -35,29 +44,29 @@ public: ~BackDraw(); }; -class ImageDraw__ { +struct ImageDraw__ { ImageBuffer image; ImageBuffer alpha; ImageDraw__(int cx, int cy) : image(cx, cy), alpha(cx, cy) {} }; -class ImageDraw : public BufferPainter, private ImageDraw__ { - Size size; +class ImageDraw : private ImageDraw__, public BufferPainter { BufferPainter alpha_painter; bool has_alpha; + Image Get(bool pm) const; + public: Draw& Alpha(); - operator Image() const; + operator Image() const { return Get(true); } - Image GetStraight() const; + Image GetStraight() const { return Get(false); } ImageDraw(Size sz); ImageDraw(int cx, int cy); - ~ImageDraw(); -} +}; void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2, const Rect& clip, int n, Color color, uint64 pattern); @@ -84,7 +93,7 @@ bool FBEndSession(); // } -class PrinterJob { +class PrinterJob { // Dummy only... NilDraw nil; Vector pages; diff --git a/rainbow/Framebuffer/Image.cpp b/rainbow/Framebuffer/Image.cpp index d533f3995..d1fa84115 100644 --- a/rainbow/Framebuffer/Image.cpp +++ b/rainbow/Framebuffer/Image.cpp @@ -49,42 +49,54 @@ void Image::Data::PaintImp(SystemDraw& w, int x, int y, const Rect& src, Color c SystemData& sd = Sys(); } +Image ImageDraw::Get(bool pm) const +{ + ImageBuffer result(image.GetSize()); + const RGBA *e = image.End(); + const RGBA *p = ~image; + RGBA *t = ~result; + if(has_alpha) { + const RGBA *a = ~alpha; + while(p < e) { + *t = *p++; + (t++)->a = (a++)->r; + } + if(pm) + Premultiply(result); + result.SetKind(IMAGE_ALPHA); + } + else { + while(p < e) { + *t = *p++; + (t++)->a = 255; + } + } + return result; +} + Draw& ImageDraw::Alpha() { has_alpha = true; - return alpha; + return alpha_painter; } -ImageDraw::operator Image() const -{ - Image image; - - return GetResult(); -} - -Image ImageDraw::GetStraight() const -{ - return GetResult(); -} ImageDraw::ImageDraw(Size sz) -: BufferPainter(sz.cx, sz.cy), - alpha(sz.cx, sz.cy) +: ImageDraw__(sz.cx, sz.cy), + BufferPainter(image), + alpha_painter(alpha) { has_alpha = false; } ImageDraw::ImageDraw(int cx, int cy) -: BufferPainter(image, cx, cy), - alpha(alpha, cx, cy) +: ImageDraw__(cx, cy), + BufferPainter(image), + alpha_painter(alpha) { has_alpha = false; } -ImageDraw::~ImageDraw() -{ -} - Image Image::Arrow() { return Null; } Image Image::Wait() { return Null; } Image Image::IBeam() { return Null; } diff --git a/rainbow/Framebuffer/Wnd.cpp b/rainbow/Framebuffer/Wnd.cpp index 2d93ff626..c96887ade 100644 --- a/rainbow/Framebuffer/Wnd.cpp +++ b/rainbow/Framebuffer/Wnd.cpp @@ -30,6 +30,7 @@ void Ctrl::RefreshFBAll() void Ctrl::InitFB() { + Ctrl::GlobalBackBuffer(); Ctrl::InitTimer(); framebuffer.Create(1000, 1000); } @@ -366,16 +367,6 @@ Rect Ctrl::GetDefaultWindowRect() { return Rect(0, 0, 100, 100); } -ViewDraw::ViewDraw(Ctrl *ctrl) -{ - EnterGuiMutex(); -} - -ViewDraw::~ViewDraw() -{ - LeaveGuiMutex(); -} - Vector SplitCmdLine__(const char *cmd) { Vector out;