diff --git a/uppsrc/Core/Path.cpp b/uppsrc/Core/Path.cpp index 9e35e3886..3f905d083 100644 --- a/uppsrc/Core/Path.cpp +++ b/uppsrc/Core/Path.cpp @@ -410,7 +410,11 @@ bool FindFile::Search(const char *name) { handle = UnicodeWin32().FindFirstFileW(ToSystemCharsetW(name), w); else handle = FindFirstFile(ToSystemCharset(name), a); - return handle != INVALID_HANDLE_VALUE; + if(handle == INVALID_HANDLE_VALUE) + return false; + if(!PatternMatch(pattern, GetName())) + return Next(); + return true; } void FindFile::Close() { diff --git a/uppsrc/Draw/Draw.cpp b/uppsrc/Draw/Draw.cpp index 349bbd871..e98cf51b8 100644 --- a/uppsrc/Draw/Draw.cpp +++ b/uppsrc/Draw/Draw.cpp @@ -8,6 +8,43 @@ NAMESPACE_UPP static StaticMutex sDrawLock; +Size Draw::GetNativeDpi() const +{ + return nativeDpi; +} + +int Draw::GetNativeX(int x) const +{ + return inchPixels != nativeDpi ? iscale(x, nativeDpi.cx, 600) : x; +} + +int Draw::GetNativeY(int y) const +{ + return inchPixels != nativeDpi ? iscale(y, nativeDpi.cy, 600) : y; +} + +void Draw::Native(int& x, int& y) const +{ + x = GetNativeX(x); + y = GetNativeY(y); +} + +void Draw::Native(Point& p) const +{ + Native(p.x, p.y); +} + +void Draw::Native(Size& sz) const +{ + Native(sz.cx, sz.cy); +} + +void Draw::Native(Rect& r) const +{ + Native(r.left, r.top); + Native(r.right, r.bottom); +} + #ifdef BENCH static TimingInspector sDrawTiming("DRAW"); #endif @@ -58,11 +95,14 @@ Stream& Draw::PutRect(const Rect& r) void Draw::DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color) { DrawLock __; + BeginNative(); + Native(x, y); + Native(cx, cy); LTIMING("DrawImageOp"); if(IsNull(src)) return; Size sz = Size(cx, cy); - if((cx > 2000 || cy > 2000) && IsNull(color) && (!IsSystem() || IsPrinter())) { + if((cx > 2000 || cy > 1500) && IsNull(color) && IsPrinter()) { int yy = 0; ImageRaster ir(img); RescaleImage rm; @@ -75,14 +115,15 @@ void Draw::DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rec DrawImageBandRLE(*this, x, y + yy, ib, 16); yy += ccy; } - return; } + else if(src.GetSize() == sz) img.PaintImage(*this, x, y, src, color); else { Image h = Rescale(img, Size(cx, cy), src); h.PaintImage(*this, x, y, h.GetSize(), color); } + EndNative(); } // ------------------------------- diff --git a/uppsrc/Draw/Draw.h b/uppsrc/Draw/Draw.h index 6ffdf1654..24fea8c35 100644 --- a/uppsrc/Draw/Draw.h +++ b/uppsrc/Draw/Draw.h @@ -496,8 +496,10 @@ protected: Size pagePixels; Size pageMMs; Size inchPixels; + Size nativeDpi; Size sheetPixels; Point pageOffset; + int native; Draw(); @@ -520,6 +522,7 @@ protected: FontInfo lastFont; Point actual_offset; + Point actual_offset_bak; struct Cloff : Moveable { Point org; #ifdef PLATFORM_WIN32 @@ -571,6 +574,8 @@ protected: void Reset(); void SetOrg(); friend HPALETTE GetQlibPalette(); + void DotsMode(); + static const char *FontScreenSans; static const char *FontScreenSerif; @@ -640,6 +645,17 @@ public: bool Pixels() const { return pixels; } bool Dots() const { return !pixels; } + bool IsNative() const { return native; } + + void BeginNative(); + void EndNative(); + Size GetNativeDpi() const; + int GetNativeX(int x) const; + int GetNativeY(int x) const; + void Native(int& x, int& y) const; + void Native(Point& p) const; + void Native(Size& sz) const; + void Native(Rect& r) const; bool IsPrinter() const { return printer; } bool IsAborted() const { return aborted; } diff --git a/uppsrc/Draw/DrawData.cpp b/uppsrc/Draw/DrawData.cpp index 6c901750c..331b422f0 100644 --- a/uppsrc/Draw/DrawData.cpp +++ b/uppsrc/Draw/DrawData.cpp @@ -29,16 +29,14 @@ One DataDrawer::Create(const String& id) return NULL; } -bool IsEqColumn(const Image& m, int x, RGBA c) +bool IsWhiteColumn(const Image& m, int x) { LTIMING("IsEqColumn"); Size sz = m.GetSize(); const RGBA *s = ~m + x; - if(c.a != 255) - return false; while(sz.cy > 1) { s += sz.cx; - if(*s != c) + if((s->a & s->r & s->g & s->b) != 255) return false; sz.cy--; } @@ -68,14 +66,13 @@ void DrawImageBandRLE(Draw& w, int x, int y, const Image& m, int minp) #endif while(xi < cx) { int xi0 = xi; - RGBA c = m[0][xi0]; - while(w.Dots() && IsEqColumn(m, xi, c) && xi < cx) + while(w.Dots() && IsWhiteColumn(m, xi) && xi < cx) xi++; if(xi - xi0 >= 16) { #ifdef BENCHMARK_RLE sRle += xi - xi0; #endif - w.DrawRect(x + xi0, y, xi - xi0, ccy, c); + w.DrawRect(x + xi0, y, xi - xi0, ccy, White); Fill(~todo + xi0, ~todo + xi, false); } xi++; @@ -87,7 +84,7 @@ void DrawImageBandRLE(Draw& w, int x, int y, const Image& m, int minp) int xi0 = xi; while(xi < cx && todo[xi] && xi - xi0 < 2000) xi++; - w.DrawImage(x + xi0, y, Crop(m, xi0, 0, xi - xi0, ccy)); + m.PaintImage(w, x + xi0, y, RectC(xi0, 0, xi - xi0, ccy), Null); } else xi++; @@ -96,6 +93,9 @@ void DrawImageBandRLE(Draw& w, int x, int y, const Image& m, int minp) void Draw::DrawDataOp(int x, int y, int cx, int cy, const String& data, const char *id) { DrawLock __; + BeginNative(); + Native(x, y); + Native(cx, cy); One dd = DataDrawer::Create(id); if(dd) { dd->Open(data, cx, cy); @@ -115,6 +115,7 @@ void Draw::DrawDataOp(int x, int y, int cx, int cy, const String& data, const ch DrawImage(x, y, m); } } + EndNative(); } DataDrawer::~DataDrawer() {} diff --git a/uppsrc/Draw/DrawWin32.cpp b/uppsrc/Draw/DrawWin32.cpp index 796380fda..91cfa840f 100644 --- a/uppsrc/Draw/DrawWin32.cpp +++ b/uppsrc/Draw/DrawWin32.cpp @@ -190,6 +190,34 @@ Size Draw::GetSizeCaps(int i, int j) const { return Size(GetDeviceCaps(handle, i), GetDeviceCaps(handle, j)); } +void Draw::DotsMode() +{ + ::SetMapMode(handle, MM_ANISOTROPIC); + ::SetViewportExtEx(handle, nativeDpi.cx, nativeDpi.cy, NULL); + ::SetViewportOrgEx(handle, 0, 0, NULL); + ::SetWindowExtEx(handle, 600, 600, NULL); + ::SetWindowOrgEx(handle, 0, 0, NULL); +} + +void Draw::BeginNative() +{ + if(inchPixels != nativeDpi && ++native == 1) { + ::SetMapMode(handle, MM_TEXT); + actual_offset_bak = actual_offset; + Native(actual_offset); + SetOrg(); + } +} + +void Draw::EndNative() +{ + if(inchPixels != nativeDpi && --native == 0) { + DotsMode(); + actual_offset = actual_offset_bak; + SetOrg(); + } +} + void Draw::LoadCaps() { DrawLock __; color16 = false; @@ -198,22 +226,10 @@ void Draw::LoadCaps() { color16 = GetDeviceCaps(handle, SIZEPALETTE) != 256; pagePixels = GetSizeCaps(HORZRES, VERTRES); pageMMs = GetSizeCaps(HORZSIZE, VERTSIZE); - inchPixels = GetSizeCaps(LOGPIXELSX, LOGPIXELSY); + nativeDpi = inchPixels = GetSizeCaps(LOGPIXELSX, LOGPIXELSY); sheetPixels = GetSizeCaps(PHYSICALWIDTH, PHYSICALHEIGHT); pageOffset = GetSizeCaps(PHYSICALOFFSETX, PHYSICALOFFSETY); is_mono = GetDeviceCaps(handle, BITSPIXEL) == 1 && GetDeviceCaps(handle, PLANES) == 1; -/* - if(!is_mono) - { - HBITMAP hbmp = (HBITMAP)GetCurrentObject(handle, OBJ_BITMAP); - if(hbmp) - { - BITMAP bmp; - GetObject(hbmp, sizeof(bmp), &bmp); - is_mono = bmp.bmPlanes == 1 && bmp.bmBitsPixel == 1; - } - } -*/ } void Draw::SetDevice(const char *s) { @@ -390,16 +406,14 @@ void PrintDraw::InitPrinter() Init(); printer = true; pixels = false; - ::SetMapMode(handle, MM_ANISOTROPIC); - ::SetViewportExtEx(handle, inchPixels.cx, inchPixels.cy, NULL); - ::SetViewportOrgEx(handle, 0, 0, NULL); - ::SetWindowExtEx(handle, 600, 600, NULL); - ::SetWindowOrgEx(handle, 0, 0, NULL); + nativeDpi = inchPixels; + DotsMode(); + native = 0; actual_offset = Point(0, 0); - pagePixels.cx=600*pagePixels.cx/inchPixels.cx; - pagePixels.cy=600*pagePixels.cy/inchPixels.cy; - inchPixels.cx=600; - inchPixels.cy=600; + pagePixels.cx = 600 * pagePixels.cx / inchPixels.cx; + pagePixels.cy = 600 * pagePixels.cy / inchPixels.cy; + inchPixels.cx = 600; + inchPixels.cy = 600; } void PrintDraw::StartPage() diff --git a/uppsrc/Draw/DrawX11.cpp b/uppsrc/Draw/DrawX11.cpp index 498cf2204..630cea532 100644 --- a/uppsrc/Draw/DrawX11.cpp +++ b/uppsrc/Draw/DrawX11.cpp @@ -378,6 +378,11 @@ Draw::Draw() Init(); } +void Draw::BeginNative() {} + +void Draw::EndNative() {} + + #ifdef PLATFORM_XFT Draw::Draw(Drawable _dw, GC _gc, XftDraw *_xftdraw, const Vector& _clip) #else diff --git a/uppsrc/Draw/Image.h b/uppsrc/Draw/Image.h index 2752e4ad0..6bfd91b9c 100644 --- a/uppsrc/Draw/Image.h +++ b/uppsrc/Draw/Image.h @@ -175,6 +175,7 @@ private: void PaintImage(Draw& 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); #ifdef PLATFORM_WIN32 #ifndef PLATFORM_WINCE