diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 1941d720b..07d3c811d 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -39,6 +39,8 @@ Size GetScreenSize(); typedef ImageDraw SystemImageDraw; +void StdDrawImage(SystemDraw& w, int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color); + void DrawDragRect(SystemDraw& w, const Rect& rect1, const Rect& rect2, const Rect& clip, int n, Color color, uint64 pattern); @@ -466,6 +468,7 @@ private: static bool mouseinview; static bool mouseinframe; static bool globalbackpaint; + static bool globalbackbuffer; static bool painting; static int LoopLevel; static Ctrl *LoopCtrl; @@ -1196,6 +1199,7 @@ public: static void GlobalBackPaint(bool b = true); static void GlobalBackPaintHint(); + static void GlobalBackBuffer(bool b = true); String Name() const; diff --git a/uppsrc/CtrlCore/CtrlDraw.cpp b/uppsrc/CtrlCore/CtrlDraw.cpp index 40ed62869..0dca4640a 100644 --- a/uppsrc/CtrlCore/CtrlDraw.cpp +++ b/uppsrc/CtrlCore/CtrlDraw.cpp @@ -6,6 +6,7 @@ NAMESPACE_UPP #define LTIMING(x) // TIMING(x) bool Ctrl::globalbackpaint; +bool Ctrl::globalbackbuffer; void Ctrl::RefreshFrame(const Rect& r) { GuiLock __; @@ -468,6 +469,11 @@ void Ctrl::UpdateArea0(SystemDraw& draw, const Rect& clip, int backpaint) GuiLock __; LTIMING("UpdateArea"); LLOG("========== UPDATE AREA " << UPP::Name(this) << " =========="); + if(globalbackbuffer) { + CtrlPaint(draw, clip); + LLOG("========== END (TARGET IS BACKBUFFER)"); + return; + } if(backpaint == FULLBACKPAINT || globalbackpaint && !hasdhctrl && !dynamic_cast(this)) { ShowRepaintRect(draw, clip, LtRed()); BackDraw bw; @@ -657,4 +663,10 @@ void Ctrl::GlobalBackPaintHint() GlobalBackPaint(); } +void Ctrl::GlobalBackBuffer(bool b) +{ + GuiLock __; + globalbackbuffer = b; +} + END_UPP_NAMESPACE diff --git a/uppsrc/CtrlCore/DrawOpWin32.cpp b/uppsrc/CtrlCore/DrawOpWin32.cpp index 25e0f50fc..abd865532 100644 --- a/uppsrc/CtrlCore/DrawOpWin32.cpp +++ b/uppsrc/CtrlCore/DrawOpWin32.cpp @@ -145,6 +145,12 @@ void SystemDraw::DrawLineOp(int x1, int y1, int x2, int y2, int width, Color col ::LineTo(handle, x2, y2); } +void SystemDraw::DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color) +{ + GuiLock __; + StdDrawImage(*this, x, y, cx, cy, img, src, color); +} + #ifndef PLATFORM_WINCE void SystemDraw::DrawPolyPolylineOp(const Point *vertices, int vertex_count, diff --git a/uppsrc/CtrlCore/DrawOpX11.cpp b/uppsrc/CtrlCore/DrawOpX11.cpp index 46d165d0a..36cc03bc4 100644 --- a/uppsrc/CtrlCore/DrawOpX11.cpp +++ b/uppsrc/CtrlCore/DrawOpX11.cpp @@ -144,6 +144,12 @@ void SystemDraw::DrawLineOp(int x1, int y1, int x2, int y2, int width, Color col x2 + actual_offset.x, y2 + actual_offset.y); } +void SystemDraw::DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color) +{ + GuiLock __; + StdDrawImage(*this, x, y, cx, cy, img, src, color); +} + void SystemDraw::DrawPolyPolylineOp(const Point *vertices, int vertex_count, const int *counts, int count_count, int width, Color color, Color doxor) diff --git a/uppsrc/CtrlCore/ImageWin32.cpp b/uppsrc/CtrlCore/ImageWin32.cpp index e3d0ffeee..2d681293e 100644 --- a/uppsrc/CtrlCore/ImageWin32.cpp +++ b/uppsrc/CtrlCore/ImageWin32.cpp @@ -400,6 +400,15 @@ void ImageDraw::Init() has_alpha = false; } +Draw& ImageDraw::Alpha() +{ + if(!has_alpha) { + alpha.DrawRect(size, GrayColor(0)); + has_alpha = true; + } + return alpha; +} + Image ImageDraw::Get(bool pm) const { ImageBuffer b(size); diff --git a/uppsrc/CtrlCore/ImageX11.cpp b/uppsrc/CtrlCore/ImageX11.cpp index 00b94ee14..09547a05f 100644 --- a/uppsrc/CtrlCore/ImageX11.cpp +++ b/uppsrc/CtrlCore/ImageX11.cpp @@ -388,6 +388,15 @@ ImageDraw::~ImageDraw() XFreeGC(Xdisplay, alpha.gc); } +Draw& ImageDraw::Alpha() +{ + if(!has_alpha) { + alpha.DrawRect(size, GrayColor(0)); + has_alpha = true; + } + return alpha; +} + Image X11Cursor(int c) { ImageBuffer b(32, 32); diff --git a/uppsrc/CtrlCore/SystemDraw.cpp b/uppsrc/CtrlCore/SystemDraw.cpp index 50b9131f8..1d93626e1 100644 --- a/uppsrc/CtrlCore/SystemDraw.cpp +++ b/uppsrc/CtrlCore/SystemDraw.cpp @@ -4,18 +4,17 @@ NAMESPACE_UPP #define LTIMING(x) -void SystemDraw::DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color) +void StdDrawImage(SystemDraw& w, int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color) { - GuiLock __; LTIMING("DrawImageOp"); - bool tonative = !IsNative(); + bool tonative = !w.IsNative(); if(tonative) { - BeginNative(); - Native(x, y); - Native(cx, cy); + w.BeginNative(); + w.Native(x, y); + w.Native(cx, cy); } Size sz = Size(cx, cy); - if((cx > 2000 || cy > 1500) && IsNull(color) && IsPrinter()) { + if((cx > 2000 || cy > 1500) && IsNull(color) && w.IsPrinter()) { int yy = 0; ImageRaster ir(img); RescaleImage rm; @@ -25,29 +24,19 @@ void SystemDraw::DrawImageOp(int x, int y, int cx, int cy, const Image& img, con ImageBuffer ib(cx, ccy); for(int q = 0; q < ccy; q++) rm.Get(ib[q]); - DrawImageBandRLE(*this, x, y + yy, ib, 16); + DrawImageBandRLE(w, x, y + yy, ib, 16); yy += ccy; } } else if(src.GetSize() == sz) - img.PaintImage(*this, x, y, src, color); + img.PaintImage(w, x, y, src, color); else { Image h = Rescale(img, Size(cx, cy), src); - h.PaintImage(*this, x, y, h.GetSize(), color); + h.PaintImage(w, x, y, h.GetSize(), color); } if(tonative) - EndNative(); -} - - -Draw& ImageDraw::Alpha() -{ - if(!has_alpha) { - alpha.DrawRect(size, GrayColor(0)); - has_alpha = true; - } - return alpha; + w.EndNative(); } ImageBuffer::ImageBuffer(ImageDraw& iw) diff --git a/uppsrc/Draw/Draw.h b/uppsrc/Draw/Draw.h index 1382414e6..b6d8d1e6c 100644 --- a/uppsrc/Draw/Draw.h +++ b/uppsrc/Draw/Draw.h @@ -584,7 +584,7 @@ public: Color ink = DefaultInk, const int *dx = NULL); static void SinCos(int angle, double& sina, double& cosa); - + // deprecated: static void SetStdFont(Font font) { UPP::SetStdFont(font); } static Font GetStdFont() { return UPP::GetStdFont(); } diff --git a/uppsrc/Draw/Image.h b/uppsrc/Draw/Image.h index 9b2178ad4..5439682ef 100644 --- a/uppsrc/Draw/Image.h +++ b/uppsrc/Draw/Image.h @@ -101,6 +101,10 @@ public: operator RGBA*() { return pixels; } const RGBA *operator~() const { return pixels; } operator const RGBA*() const { return pixels; } + RGBA *Begin() { return pixels; } + const RGBA *Begin() const { return pixels; } + RGBA *End() { return pixels + GetLength(); } + const RGBA *End() const { return pixels + GetLength(); } void Create(int cx, int cy); void Create(Size sz) { Create(sz.cx, sz.cy); } @@ -187,10 +191,6 @@ private: friend class ImageBuffer; friend struct Data; - friend class SystemDraw; - - void PaintImage(SystemDraw& w, int x, int y, const Rect& src, Color c) const; - friend void SetPaintOnly___(Image& m); friend void DrawImageBandRLE(Draw& w, int x, int y, const Image& m, int minp); friend void InstallSystemImage(); @@ -254,6 +254,7 @@ public: Image(ImageBuffer& b); ~Image(); + void PaintImage(SystemDraw& w, int x, int y, const Rect& src, Color c) const; static Image Arrow(); static Image Wait(); diff --git a/uppsrc/Painter/BufferPainter.h b/uppsrc/Painter/BufferPainter.h index 6a2039fba..399d79f33 100644 --- a/uppsrc/Painter/BufferPainter.h +++ b/uppsrc/Painter/BufferPainter.h @@ -357,5 +357,8 @@ private: enum { FILL = -1, CLIP = -2, ONPATH = -3 }; public: + ImageBuffer& GetBuffer() { return ib; } + const ImageBuffer& GetBuffer() const { return ib; } + BufferPainter(ImageBuffer& ib, int mode = MODE_ANTIALIASED); };