From 931bf5b92fe7ae0527c8ff65f0a88f478eae5161 Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 9 Jul 2011 19:33:19 +0000 Subject: [PATCH] .developing rainbow git-svn-id: svn://ultimatepp.org/upp/trunk@3628 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- rainbow/DrawDragRect/DrawDragRect.upp | 11 +++ rainbow/DrawDragRect/init | 6 ++ rainbow/DrawDragRect/main.cpp | 70 +++++++++++++++++ rainbow/Framebuffer/After.h | 16 ++-- rainbow/Framebuffer/Clip.cpp | 58 ++++++++------ rainbow/Framebuffer/Ctrl.h | 14 ++-- rainbow/Framebuffer/Draw.cpp | 14 +++- rainbow/Framebuffer/Event.cpp | 16 ++-- rainbow/Framebuffer/Framebuffer.h | 13 ++- rainbow/Framebuffer/Util.cpp | 30 ++++++- rainbow/Framebuffer/Wnd.cpp | 109 ++++++++++++++++++++------ rainbow/Paint/Draw.cpp | 12 +++ rainbow/Paint/Paint.upp | 3 +- rainbow/WinFb/Proc.cpp | 8 +- rainbow/WinFb/Win.cpp | 16 +++- rainbow/WinGl/After.h | 2 - 16 files changed, 317 insertions(+), 81 deletions(-) create mode 100644 rainbow/DrawDragRect/DrawDragRect.upp create mode 100644 rainbow/DrawDragRect/init create mode 100644 rainbow/DrawDragRect/main.cpp diff --git a/rainbow/DrawDragRect/DrawDragRect.upp b/rainbow/DrawDragRect/DrawDragRect.upp new file mode 100644 index 000000000..e45928b6f --- /dev/null +++ b/rainbow/DrawDragRect/DrawDragRect.upp @@ -0,0 +1,11 @@ +uses + CtrlLib, + Framebuffer, + WinFb; + +file + main.cpp; + +mainconfig + "" = "GUI SSE2 WINFB"; + diff --git a/rainbow/DrawDragRect/init b/rainbow/DrawDragRect/init new file mode 100644 index 000000000..590b63c7a --- /dev/null +++ b/rainbow/DrawDragRect/init @@ -0,0 +1,6 @@ +#ifndef _DrawDragRect_icpp_init_stub +#define _DrawDragRect_icpp_init_stub +#include "CtrlLib/init" +#include "Framebuffer/init" +#include "WinFb/init" +#endif diff --git a/rainbow/DrawDragRect/main.cpp b/rainbow/DrawDragRect/main.cpp new file mode 100644 index 000000000..7a4bba933 --- /dev/null +++ b/rainbow/DrawDragRect/main.cpp @@ -0,0 +1,70 @@ +#include +#include + +using namespace Upp; + +struct App : public Ctrl { + uint64 pattern; + int pos; + int a; + int dir; + + void Paint(Draw& w) + { + DDUMP(pattern); + Size sz = GetSize(); + w.DrawRect(sz, White()); + DrawDragRect((SystemDraw&)w, + Rect(0, 0, 0, 0), + RectC(10, 10, a, a / 3), + Size(800, 600), + 1, + Black(), + pattern); + } + + void Animate() { + pattern = I64(0xf0f0) >> (pos++ & 7); + if(Random() % 100 == 0) + dir = (int)Random() % 3 - 1; + a += dir; + if(a < 0) { + a = 0; + dir = -dir; + } + if(a > 1000) { + a = 1000; + dir = -dir; + } +// if(++a > 900) +// a = 0; + DrawDragRect(*this, + Rect(0, 0, 0, 0), + RectC(10, 10, a, a / 3), + Size(800, 600), + 1, + Black(), + pattern); + PostCallback(THISBACK(Animate)); + } + + typedef App CLASSNAME; + + App() + { + pattern = I64(9732030564846854595); + pos = 0; + a = 200; + dir = 1; + PostCallback(THISBACK(Animate)); + SetCaret(0, 0, 20, 20); + } +}; + +GUI_APP_MAIN +{ + App app; + Ctrl::SetDesktop(app); + app.SetFocus(); + Ctrl::EventLoop(); +} diff --git a/rainbow/Framebuffer/After.h b/rainbow/Framebuffer/After.h index 531ace95a..11cd4fcc4 100644 --- a/rainbow/Framebuffer/After.h +++ b/rainbow/Framebuffer/After.h @@ -1,13 +1,17 @@ class ViewDraw : public SystemDraw { - ImageBuffer ib; - - Vector dummy_invalid; - public: - ViewDraw(Ctrl *ctrl) : SystemDraw(ib, dummy_invalid) { _DBG_ } - ~ViewDraw() {} + ViewDraw(Ctrl *ctrl); + ~ViewDraw(); }; + +/* +class ViewDraw : public SystemDraw { + Vector dummy; +public: + ViewDraw(Ctrl *) : SystemDraw(Ctrl::framebuffer, dummy) { dummy.Add(Rect(10, 10, 100, 100)); } +}; +*/ class DHCtrl : Ctrl {}; #include FRAMEBUFFER_INCLUDE diff --git a/rainbow/Framebuffer/Clip.cpp b/rainbow/Framebuffer/Clip.cpp index 0e165961a..5b81c425e 100644 --- a/rainbow/Framebuffer/Clip.cpp +++ b/rainbow/Framebuffer/Clip.cpp @@ -6,36 +6,44 @@ NAMESPACE_UPP #define LLOG(x) // LOG(x) +static VectorMap fbClipboard; + void ClearClipboard() { GuiLock __; -} - -void AppendClipboard(int format, const byte *data, int length) -{ - GuiLock __; -} - -void AppendClipboard(const char *format, const byte *data, int length) -{ - GuiLock __; -} - -void AppendClipboard(const char *format, const String& data) -{ - GuiLock __; - AppendClipboard(format, data, data.GetLength()); + fbClipboard.Clear(); } void AppendClipboard(const char *format, const Value& data, String (*render)(const Value&)) { GuiLock __; + ClipData& cd = fbClipboard.GetAdd(format); + cd.data = data; + cd.render = render; +} + +static String sRawRender(const Value& v) +{ + return v; +} + +void AppendClipboard(const char *format, const String& data) +{ + GuiLock __; + AppendClipboard(format, data, sRawRender); +} + +void AppendClipboard(const char *format, const byte *data, int length) +{ + GuiLock __; + AppendClipboard(format, String(data, length)); } String ReadClipboard(const char *format) { GuiLock __; - return Null; + int q = fbClipboard.Find(format); + return q >= 0 ? (*fbClipboard[q].render)(fbClipboard[q].data) : String(); } void AppendClipboardText(const String& s) @@ -125,22 +133,26 @@ String GetTextClip(const String& text, const String& fmt) String ReadClipboardText() { - return ReadClipboardUnicodeText().ToString(); + String w = ReadClipboard("text"); + return w.GetCount() ? w : ReadClipboardUnicodeText().ToString(); } WString ReadClipboardUnicodeText() { - return Null; + String w = ReadClipboard("wtext"); + if(w.GetCount()) + return WString(~w, w.GetLength() / 2); + return ReadClipboard("text").ToWString(); } bool IsClipboardAvailable(const char *id) { - return false; + return fbClipboard.Find(id) >= 0; } bool IsClipboardAvailableText() { - return false; + return IsClipboardAvailable("text") || IsClipboardAvailable("wtext"); } const char *ClipFmtsImage() @@ -223,12 +235,12 @@ Vector GetFiles(PasteClip& clip) bool PasteClip::IsAvailable(const char *fmt) const { - return false; + return IsClipboardAvailable(fmt); } String PasteClip::Get(const char *fmt) const { - return Null; + return ReadClipboard(fmt); } void PasteClip::GuiPlatformConstruct() diff --git a/rainbow/Framebuffer/Ctrl.h b/rainbow/Framebuffer/Ctrl.h index 0f92eee1e..820f17bb4 100644 --- a/rainbow/Framebuffer/Ctrl.h +++ b/rainbow/Framebuffer/Ctrl.h @@ -1,11 +1,9 @@ //$ class Ctrl { private: - static void AddInvalid(const Rect& rect); - static Ptr desktop; static Vector topctrl; static ImageBuffer framebuffer; - static Vector invalid; + static Vector invalid, update; static Point fbCursorPos; static Image fbCursorImage; @@ -28,15 +26,19 @@ private: int FindTopCtrl() const; static Rect GetClipBound(const Vector& inv, const Rect& r); - static void DoPaint(const Vector& invalid); + static void DoPaint(); + static void DoUpdate(); static void SyncTopWindows(); - + + static void AddInvalid(const Rect& rect); + void NewTop() { top = new Top; top->owner_window = NULL; } void PutForeground(); static void MouseEventFB(Ptr t, int event, Point p, int zdelta); friend struct PaintProxy__; friend class TopWindowFrame; + friend class SystemDraw; public: static void DoMouseFB(int event, Point p, int zdelta = 0); @@ -56,4 +58,6 @@ public: static void SetRenderingMode(int mode); + static void AddUpdate(const Rect& rect); + //$ }; diff --git a/rainbow/Framebuffer/Draw.cpp b/rainbow/Framebuffer/Draw.cpp index ca4fae472..bca6767da 100644 --- a/rainbow/Framebuffer/Draw.cpp +++ b/rainbow/Framebuffer/Draw.cpp @@ -7,6 +7,16 @@ NAMESPACE_UPP #define LLOG(x) // LOG(x) #define LTIMING(x) // RTIMING(x) +SystemDraw::SystemDraw() +: BufferPainter(Ctrl::framebuffer, Ctrl::renderingMode) +{ +} + +SystemDraw::~SystemDraw() +{ +} + + void SystemDraw::Push() { Point p = GetOffset(); @@ -64,8 +74,8 @@ bool SystemDraw::ClipoffOp(const Rect& r) bool SystemDraw::IsPaintingOp(const Rect& r) const { Rect rr = r + GetOffset(); - for(int i = 0; i < invalid.GetCount(); i++) - if(invalid[i].Intersects(rr)) + for(int i = 0; i < Ctrl::invalid.GetCount(); i++) + if(Ctrl::invalid[i].Intersects(rr)) return true; return true; } diff --git a/rainbow/Framebuffer/Event.cpp b/rainbow/Framebuffer/Event.cpp index 663d15790..2d5d28b6e 100644 --- a/rainbow/Framebuffer/Event.cpp +++ b/rainbow/Framebuffer/Event.cpp @@ -34,7 +34,7 @@ void Ctrl::DoMouseFB(int event, Point p, int zdelta) else if(a == Ctrl::DOWN && ignoreclick) return; - LLOG("Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl)); + LLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl)); if(captureCtrl) MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta); else @@ -80,7 +80,7 @@ void Ctrl::RemoveCursor() { if(!IsNull(fbCursorBakPos)) { Copy(framebuffer, fbCursorBakPos, fbCursorBak, fbCursorBak.GetSize()); - AddInvalid(Rect(fbCursorBakPos, fbCursorBak.GetSize())); + AddUpdate(Rect(fbCursorBakPos, fbCursorBak.GetSize())); } fbCursorPos = fbCursorBakPos = Null; fbCursorBak = Null; @@ -90,7 +90,7 @@ void Ctrl::RemoveCaret() { if(!IsNull(fbCaretRect)) { Copy(framebuffer, fbCaretRect.TopLeft(), fbCaretBak, fbCaretBak.GetSize()); - AddInvalid(fbCaretRect); + AddUpdate(fbCaretRect); } fbCaretRect = Null; fbCaretBak = Null; @@ -113,12 +113,15 @@ void Ctrl::SyncCaret() { void Ctrl::CursorSync() { + DLOG("@ CursorSync"); Point p = GetMousePos() - fbCursorImage.GetHotSpot(); Rect cr = Null; if(focusCtrl && (((GetTickCount() - fbCaretTm) / 500) & 1) == 0) cr = (RectC(focusCtrl->caretx, focusCtrl->carety, focusCtrl->caretcx, focusCtrl->caretcy) + focusCtrl->GetScreenView().TopLeft()) & focusCtrl->GetScreenView(); + DDUMP(GetTickCount()); if(fbCursorPos != p || cr != fbCaretRect) { + DDUMP(fbCaretRect); RemoveCursor(); RemoveCaret(); @@ -128,9 +131,9 @@ void Ctrl::CursorSync() fbCursorBak = GetBak(tr); fbCursorBakPos = tr.TopLeft(); + fbCaretRect = cr; if(!cr.IsEmpty()) { fbCaretBak = GetBak(cr); - fbCaretRect = cr; for(int y = cr.top; y < cr.bottom; y++) { RGBA *s = framebuffer[y] + cr.left; const RGBA *e = framebuffer[y] + cr.right; @@ -141,11 +144,12 @@ void Ctrl::CursorSync() s++; } } - AddInvalid(fbCaretRect); + AddUpdate(fbCaretRect); } Over(framebuffer, p, fbCursorImage, sz); - AddInvalid(tr); + DLOG("Cursor: " << p << ", rect " << tr); + AddUpdate(tr); } } diff --git a/rainbow/Framebuffer/Framebuffer.h b/rainbow/Framebuffer/Framebuffer.h index eb5b2ff14..a2c8190a3 100644 --- a/rainbow/Framebuffer/Framebuffer.h +++ b/rainbow/Framebuffer/Framebuffer.h @@ -19,7 +19,6 @@ public: private: Vector offset; - const Vector& invalid; void Push(); void Pop(); @@ -29,18 +28,15 @@ public: 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, const Vector& invalid, int mode = MODE_ANTIALIASED) - : BufferPainter(ib, mode), invalid(invalid) {} + SystemDraw(); + ~SystemDraw(); }; struct BackDraw__ : public SystemDraw { - ImageBuffer h; - Vector dummy_invalid; - - BackDraw__() : SystemDraw(h, dummy_invalid) {} + BackDraw__() : SystemDraw() {} }; class BackDraw : public BackDraw__ { // Dummy only, as we are running in GlobalBackBuffer mode @@ -110,6 +106,7 @@ bool FBProcessEvent(bool *quit); void FBSleep(int ms); bool FBEndSession(); void FBUpdate(const Rect& area); +void FBFlush(); // } diff --git a/rainbow/Framebuffer/Util.cpp b/rainbow/Framebuffer/Util.cpp index a1f9e4c63..22a616801 100644 --- a/rainbow/Framebuffer/Util.cpp +++ b/rainbow/Framebuffer/Util.cpp @@ -4,8 +4,36 @@ NAMESPACE_UPP -void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2, const Rect& clip, int n, Color color, uint64 pattern) +static void sRenderLine(SystemDraw& w, int x, int y, int dx, int dy, int cx, int cy, int len, byte pattern) { + DLOG(len); + for(int i = 0; i < len; i++) + if((128 >> (i & 7)) & pattern) + w.DrawRect(x + dx * i, y + dy * i, cx, cy, Black); + DDUMP("~sRenderLine"); +} + +static void sRenderRect(SystemDraw& w, const Rect& r, int n, byte pattern) +{ + sRenderLine(w, r.left, r.top, 1, 0, 1, n, r.GetWidth(), pattern); + sRenderLine(w, r.left, r.bottom - 1, 1, 0, 1, n, r.GetWidth(), pattern); + sRenderLine(w, r.left, r.top, 0, 1, n, 1, r.GetHeight(), pattern); + sRenderLine(w, r.right - 1, r.top, 0, 1, n, 1, r.GetHeight(), pattern); +} + +void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2, + const Rect& clip, int n, Color color, uint64 pattern) +{ + DLOG("@ DrawDragRect " << rect1 << " " << rect2 << ", clip: " << clip << ", pattern: " << pattern); + TIMING("DrawDrawRect"); + w.Clip(clip); + w.Invert(); + sRenderRect(w, rect1, n, (byte)pattern); + sRenderRect(w, rect2, n, (byte)pattern); + Ctrl::AddUpdate((rect1 | rect2).Offseted(w.GetOffset())); +// MemoryProfile mem; +// DDUMP(mem); + w.End(); } /* diff --git a/rainbow/Framebuffer/Wnd.cpp b/rainbow/Framebuffer/Wnd.cpp index 56ca3e9ab..137bbde81 100644 --- a/rainbow/Framebuffer/Wnd.cpp +++ b/rainbow/Framebuffer/Wnd.cpp @@ -8,6 +8,7 @@ NAMESPACE_UPP ImageBuffer Ctrl::framebuffer; Vector Ctrl::invalid; +Vector Ctrl::update; Ptr Ctrl::desktop; Vector Ctrl::topctrl; @@ -151,8 +152,15 @@ bool Ctrl::IsWaitingEvent() return FBIsWaitingEvent(); } +void Ctrl::AddUpdate(const Rect& rect) +{ + DLOG("@AddUpdate " << rect); + AddRefreshRect(update, rect); +} + void Ctrl::AddInvalid(const Rect& rect) { + DLOG("@AddInvalid " << rect); AddRefreshRect(invalid, rect); } @@ -167,6 +175,7 @@ void Ctrl::SyncTopWindows() bool Ctrl::ProcessEvent(bool *quit) { + DLOG("@ ProcessEvent"); ASSERT(IsMainThread()); if(DoCall()) { SyncTopWindows(); @@ -174,11 +183,12 @@ bool Ctrl::ProcessEvent(bool *quit) } if(FBEndSession()) { if(quit) *quit = true; - return false; + return false; } if(!GetMouseLeft() && !GetMouseRight() && !GetMouseMiddle()) ReleaseCtrlCapture(); if(FBProcessEvent(quit)) { + DLOG("FBProcesEvent returned true"); SyncTopWindows(); DefferedFocusSync(); SyncCaret(); @@ -198,47 +208,107 @@ Rect Ctrl::GetClipBound(const Vector& inv, const Rect& r) return ri; } -void Ctrl::DoPaint(const Vector& invalid) + +ViewDraw::ViewDraw(Ctrl *ctrl) { + if(Ctrl::invalid.GetCount()) + Ctrl::DoPaint(); + Ctrl::invalid.Clear(); + Ctrl::RemoveCursor(); + Ctrl::RemoveCaret(); + Rect r = ctrl->GetScreenView(); + Ctrl::invalid.Add(r); + Ctrl::AddUpdate(r); + for(int i = max(ctrl->GetTopCtrl()->FindTopCtrl() + 1, 0); i < Ctrl::topctrl.GetCount(); i++) { + Rect rr = Ctrl::topctrl[i]->GetScreenRect(); + ExcludeClip(rr); + Subtract(Ctrl::invalid, rr); + } + Offset(r.TopLeft()); +} + +ViewDraw::~ViewDraw() +{ + Ctrl::invalid.Clear(); +} + +void Ctrl::DoUpdate() +{ + DLOG("DoUpdate"); + invalid.Clear(); + CursorSync(); + DDUMPC(update); +#if 0 + FBUpdate(framebuffer.GetSize()); +#else + for(int i = 0; i < update.GetCount(); i++) { + DDUMP(update[i]); + FBUpdate(update[i]); + } +#endif + update.Clear(); + FBFlush(); +// Sleep(1000); +} + +void Ctrl::DoPaint() +{ + DLOG("@ DoPaint"); if(invalid.GetCount() && desktop) { + DLOG("DoPaint invalid"); + DDUMPC(invalid); RemoveCursor(); RemoveCaret(); - SystemDraw painter(framebuffer, invalid, renderingMode); + SystemDraw painter; painter.Begin(); - for(int i = 0; i < invalid.GetCount(); i++) + for(int i = 0; i < invalid.GetCount(); i++) { painter.RectPath(invalid[i]); + AddUpdate(invalid[i]); + } painter.Painter::Clip(); - Vector inv; - inv <<= invalid; for(int i = topctrl.GetCount() - 1; i >= 0; i--) { Rect r = topctrl[i]->GetRect(); - Rect ri = GetClipBound(inv, r); + Rect ri = GetClipBound(invalid, r); if(!IsNull(ri)) { - painter.Offset(r.TopLeft()); + painter.Clipoff(r); topctrl[i]->UpdateArea(painter, ri - r.TopLeft()); painter.End(); - Subtract(inv, r); + Subtract(invalid, r); painter.ExcludeClip(r); } } - Rect ri = GetClipBound(inv, framebuffer.GetSize()); + Rect ri = GetClipBound(invalid, framebuffer.GetSize()); if(!IsNull(ri)) desktop->UpdateArea(painter, ri); } - CursorSync(); - for(int i = 0; i < invalid.GetCount(); i++) - FBUpdate(invalid[i]); + DoUpdate(); +} + +void Ctrl::WndUpdate0r(const Rect& r) +{ + GuiLock __; + Rect rr = r + GetRect().TopLeft(); + bool dummy; + Vector h; + h <<= invalid; + invalid = Intersect(invalid, rr, dummy); + DoPaint(); + invalid <<= h; + Subtract(invalid, rr); + FBFlush(); } bool Ctrl::ProcessEvents(bool *quit) { + DLOG("ProcessEvents " << LOG_BEGIN); if(!ProcessEvent(quit)) return false; while(ProcessEvent(quit) && (!LoopCtrl || LoopCtrl->InLoop()) && !FBEndSession()); TimerProc(GetTickCount()); SweepMkImageCache(); - DoPaint(invalid); - invalid.Clear(); + DoPaint(); + FBFlush(); + DLOG(LOG_END); return true; } @@ -476,15 +546,6 @@ void Ctrl::WndSetPos0(const Rect& rect) invalid.Add(rect); } -void Ctrl::WndUpdate0r(const Rect& r) -{ - GuiLock __; - Rect rr = r + GetRect().TopLeft(); - bool dummy; - DoPaint(Intersect(invalid, rr, dummy)); - invalid = Subtract(invalid, rr, dummy); -} - void Ctrl::WndScrollView0(const Rect& r, int dx, int dy) { GuiLock __; diff --git a/rainbow/Paint/Draw.cpp b/rainbow/Paint/Draw.cpp index bbef05998..523b746bc 100644 --- a/rainbow/Paint/Draw.cpp +++ b/rainbow/Paint/Draw.cpp @@ -29,6 +29,14 @@ struct App : public Ctrl { w.Clipoff(200, 50, 95, 100); w.DrawText(0, 80, "CLIPPED", Roman(25)); w.End(); + + DrawDragRect((SystemDraw&)w, + Rect(0, 0, 0, 0), + Rect(23, 165, 672, 301), + Size(1163, 513), + 1, + Black(), + MAKEQWORD(Random(), Random())); } void LeftDown(Point p, dword) @@ -85,6 +93,7 @@ GUI_APP_MAIN { #if EDITOR RichEditWithToolBar app; + app.SetQTF(LoadFile(ConfigFile("test.qtf"))); #else App app; app.popup.PopUp(); @@ -107,4 +116,7 @@ GUI_APP_MAIN top.Open(); #endif Ctrl::EventLoop(); +#if EDITOR + SaveFile(ConfigFile("test.qtf"), app.GetQTF()); +#endif } diff --git a/rainbow/Paint/Paint.upp b/rainbow/Paint/Paint.upp index 7e71851e7..2f59d408d 100644 --- a/rainbow/Paint/Paint.upp +++ b/rainbow/Paint/Paint.upp @@ -13,7 +13,8 @@ uses(SDLFB) SDLFb; uses(WINGL) WinGl; file - Draw.cpp; + Draw.cpp, + U:\h.txt; mainconfig "" = "GUI WINFB", diff --git a/rainbow/WinFb/Proc.cpp b/rainbow/WinFb/Proc.cpp index ba4feaad8..391be114a 100644 --- a/rainbow/WinFb/Proc.cpp +++ b/rainbow/WinFb/Proc.cpp @@ -2,7 +2,7 @@ NAMESPACE_UPP -#define LLOG(x) // LOG(x) +#define LLOG(x) LOG(x) bool GetShift() { return !!(GetKeyState(VK_SHIFT) & 0x8000); } bool GetCtrl() { return !!(GetKeyState(VK_CONTROL) & 0x8000); } @@ -58,6 +58,12 @@ LRESULT CALLBACK fbWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa PAINTSTRUCT ps; HDC dc = BeginPaint(hwnd, &ps); fbUpdate(dc, ps.rcPaint); + #if 0 + Rect r = ps.rcPaint; + ::PatBlt(dc, r.left, r.top, r.GetWidth(), r.GetHeight(), DSTINVERT); + Sleep(40); + ::PatBlt(dc, r.left, r.top, r.GetWidth(), r.GetHeight(), DSTINVERT); + #endif EndPaint(hwnd, &ps); } return 0L; diff --git a/rainbow/WinFb/Win.cpp b/rainbow/WinFb/Win.cpp index e33f508be..02883dcbf 100644 --- a/rainbow/WinFb/Win.cpp +++ b/rainbow/WinFb/Win.cpp @@ -33,7 +33,9 @@ bool FBProcessEvent(bool *quit) void FBSleep(int ms) { + TimeStop tm; MsgWaitForMultipleObjects(0, NULL, FALSE, ms, QS_ALLINPUT); + DLOG("@ FBSleep " << tm.Elapsed()); } void FBInit(HINSTANCE hInstance) @@ -60,10 +62,13 @@ void FBInit(HINSTANCE hInstance) // Csizeinit(); } -void fbUpdate(HDC hdc, const Rect& r) +void fbUpdate(HDC hdc, const Rect& r_) { const ImageBuffer& framebuffer = Ctrl::GetFrameBuffer(); Size sz = framebuffer.GetSize(); + Rect r = sz; +// Rect r = r_; + DLOG("fbUpdate " << r); Buffer data; data.Alloc(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256); BITMAPINFOHEADER *hi = (BITMAPINFOHEADER *) ~data;; @@ -84,7 +89,7 @@ void fbUpdate(HDC hdc, const Rect& r) void FBUpdate(const Rect& r) { - LLOG("FBUpdate " << r); + DLOG("FBUpdate " << r); if(fbHWND) { HDC hdc = GetDC(fbHWND); fbUpdate(hdc, r); @@ -95,6 +100,13 @@ void FBUpdate(const Rect& r) #endif ReleaseDC(fbHWND, hdc); } +// ::InvalidateRect(fbHWND, NULL, false); +} + +void FBFlush() +{ + ::UpdateWindow(fbHWND); + GdiFlush(); } END_UPP_NAMESPACE diff --git a/rainbow/WinGl/After.h b/rainbow/WinGl/After.h index ded4ae703..02f13bdc7 100644 --- a/rainbow/WinGl/After.h +++ b/rainbow/WinGl/After.h @@ -2,8 +2,6 @@ #define _WinGl_After_h_ class ViewDraw : public SystemDraw { - ImageBuffer ib; - public: ViewDraw(Ctrl *ctrl) {} ~ViewDraw() {}