diff --git a/rainbow/Framebuffer/Ctrl.h b/rainbow/Framebuffer/Ctrl.h index 70b4c56..a5cca2c 100644 Index: rainbow/Framebuffer/Ctrl.h =================================================================== --- rainbow/Framebuffer/Ctrl.h +++ rainbow/Framebuffer/Ctrl.h @@ -1,5 +1,6 @@ //$ class Ctrl { private: +public: static Ptr desktop; static Vector topctrl; static ImageBuffer framebuffer; diff --git a/rainbow/LinuxFb/Win.cpp b/rainbow/LinuxFb/Win.cpp index 0bf45eb..75b2530 100644 Index: rainbow/LinuxFb/Win.cpp =================================================================== --- rainbow/LinuxFb/Win.cpp +++ rainbow/LinuxFb/Win.cpp @@ -225,6 +225,7 @@ void FBUpdate(const Rect& inv) { if(switched_away) return; //backdraw //FIXME accelerate + return; const ImageBuffer& framebuffer = Ctrl::GetFrameBuffer(); memcpy(fbp, ~framebuffer, framebuffer.GetLength() * sizeof(RGBA)); } @@ -265,8 +266,11 @@ void FBInit(const String& fbdevice) } LLOG("The framebuffer device was mapped to memory successfully.\n"); - Size fbsz(vinfo.xres, vinfo.yres); - Ctrl::SetFramebufferSize(fbsz); + Size sz(vinfo.xres, vinfo.yres); +// Ctrl::SetFramebufferSize(sz); + Buffer b((RGBA*)fbp, sizeof(RGBA)*sz.cx*sz.cy); + ImageBuffer ib(b, sz); + Ctrl::framebuffer = ib; //mouse diff --git a/rainbow/SDLFb/Win.cpp b/rainbow/SDLFb/Win.cpp index e1cc5a1..38a78f2 100644 Index: rainbow/SDLFb/Win.cpp =================================================================== --- rainbow/SDLFb/Win.cpp +++ rainbow/SDLFb/Win.cpp @@ -75,7 +75,7 @@ void FBUpdate(const Rect& inv) //The invalidated areas accumulate in the update region until the region is processed when the next WM_PAINT message occurs const ImageBuffer& framebuffer = Ctrl::GetFrameBuffer(); -#if 1 +#if 0 memcpy(screen->pixels, ~framebuffer, framebuffer.GetLength() * sizeof(RGBA)); #endif @@ -131,7 +131,11 @@ void FBInit() screen = CreateScreen(width, height, bpp, videoflags); ASSERT(screen); - Ctrl::SetFramebufferSize(Size(width, height)); +// Ctrl::SetFramebufferSize(Size(width, height)); + Size sz(width, height); + Buffer b((RGBA*)screen->pixels, sizeof(RGBA)*sz.cx*sz.cy); + ImageBuffer ib(b, sz); + Ctrl::framebuffer = ib; } void FBDeInit() diff --git a/uppsrc/Core/Other.h b/uppsrc/Core/Other.h index 8956f88..dcfc2ab 100644 Index: uppsrc/Core/Other.h =================================================================== --- uppsrc/Core/Other.h +++ uppsrc/Core/Other.h @@ -89,6 +89,8 @@ public: template class Buffer : Moveable< Buffer > { mutable T *ptr; + dword sz; + bool own; public: operator T*() { return ptr; } @@ -96,19 +98,20 @@ public: T *operator~() { return ptr; } const T *operator~() const { return ptr; } - void Alloc(int size) { Clear(); ptr = new T[size]; } - void Alloc(int size, const T& in) { Clear(); ptr = new T[size]; + void Alloc(int size) { Clear(); ptr = new T[size]; own = true; sz = size; } + void Alloc(int size, const T& in) { Clear(); ptr = new T[size]; own = true; sz = size; Fill(ptr, ptr + size, in); } + int GetCount() const { return sz; } + void Clear() { if(ptr && own) delete[] ptr; ptr = NULL; } - void Clear() { if(ptr) delete[] ptr; ptr = NULL; } + Buffer() { ptr = NULL; own = true; sz = 0; } + Buffer(int size) { ptr = new T[size]; own = true; sz = size; } + Buffer(int size, const T& init) { ptr = new T[size]; own = true; sz = size; Fill(ptr, ptr + size, init); } + Buffer(T* p, dword size) { ptr = p; own = false; sz = size; } + ~Buffer() { if(ptr && own) delete[] ptr; } - Buffer() { ptr = NULL; } - Buffer(int size) { ptr = new T[size]; } - Buffer(int size, const T& init) { ptr = new T[size]; Fill(ptr, ptr + size, init); } - ~Buffer() { if(ptr) delete[] ptr; } - - void operator=(pick_ Buffer& v) { if(ptr) delete[] ptr; ptr = v.ptr; v.ptr = NULL; } - Buffer(pick_ Buffer& v) { ptr = v.ptr; v.ptr = NULL; } + void operator=(pick_ Buffer& v) { if(ptr && own) delete[] ptr; ptr = v.ptr; v.ptr = NULL; own = v.own; sz = v.sz; } + Buffer(pick_ Buffer& v) { ptr = v.ptr; v.ptr = NULL; own = v.own; sz = v.sz; } }; class Bits : Moveable { diff --git a/uppsrc/Draw/Image.cpp b/uppsrc/Draw/Image.cpp index 92a3c33..84d609f 100644 Index: uppsrc/Draw/Image.cpp =================================================================== --- uppsrc/Draw/Image.cpp +++ uppsrc/Draw/Image.cpp @@ -111,6 +111,27 @@ ImageBuffer::ImageBuffer(ImageBuffer& b) spot2 = b.spot2; } +ImageBuffer::ImageBuffer(Buffer& pb, Size sz) { + ASSERT(sz.cx >= 0 && sz.cy >= 0); + size = sz; + pixels = pb; +#ifdef _DEBUG + RGBA *s = pixels; + RGBA *e = pixels + GetLength(); + byte a = 0; + while(s < e) { + s->a = a; + a = ~a; + s->r = 255; + s->g = s->b = 0; + s++; + } +#endif + kind = IMAGE_UNKNOWN; + spot2 = hotspot = Point(0, 0); + dots = Size(0, 0); +} + void ImageBuffer::SetDPI(Size dpi) { dots.cx = int(600.*size.cx/dpi.cx); diff --git a/uppsrc/Draw/Image.h b/uppsrc/Draw/Image.h index cb3ed23..6dea04a 100644 Index: uppsrc/Draw/Image.h =================================================================== --- uppsrc/Draw/Image.h +++ uppsrc/Draw/Image.h @@ -117,6 +117,7 @@ public: ImageBuffer() { Create(0, 0); } ImageBuffer(int cx, int cy) { Create(cx, cy); } ImageBuffer(Size sz) { Create(sz.cx, sz.cy); } + ImageBuffer(Buffer& pb, Size sz); ImageBuffer(Image& img); ImageBuffer(ImageBuffer& b); // BW, defined in CtrlCore: