From c6f1cfbae88e15844f187fdf589c7dbccbd7fac7 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Sat, 22 Sep 2018 12:45:43 -0400 Subject: [PATCH 01/12] adding -std=c++0x flag to linux pymod builds --- .travis.yml | 226 ++++++++++++++++++++++++++-------------------------- setup.py | 7 +- 2 files changed, 117 insertions(+), 116 deletions(-) diff --git a/.travis.yml b/.travis.yml index d6397e35d..dbd60d0d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,68 +1,68 @@ matrix: include: - # python 2 osx + # # python 2 osx - - name: "klayout python2 osx10.13" - os: osx - osx_image: xcode9.4 # macOS 10.13 - env: - - MATRIX_EVAL="" - - ARCHFLAGS="-std=c++11" - - PIP_UPDATE="1" - - PYTHON_BUILD=true - - BREW_BUNDLE=false + # - name: "klayout python2 osx10.13" + # os: osx + # osx_image: xcode9.4 # macOS 10.13 + # env: + # - MATRIX_EVAL="" + # - ARCHFLAGS="-std=c++11" + # - PIP_UPDATE="1" + # - PYTHON_BUILD=true + # - BREW_BUNDLE=false - - name: "klayout python2 osx10.12" - os: osx - osx_image: xcode8.3 # macOS 10.12 - env: - - MATRIX_EVAL="brew install python2 || brew link --overwrite python@2" # deficient python2 in travis's xcode8.3 (no ssl) - - ARCHFLAGS="-std=c++11" - - PIP_UPDATE="1" - - PYTHON_BUILD=true - - BREW_BUNDLE=false + # - name: "klayout python2 osx10.12" + # os: osx + # osx_image: xcode8.3 # macOS 10.12 + # env: + # - MATRIX_EVAL="brew install python2 || brew link --overwrite python@2" # deficient python2 in travis's xcode8.3 (no ssl) + # - ARCHFLAGS="-std=c++11" + # - PIP_UPDATE="1" + # - PYTHON_BUILD=true + # - BREW_BUNDLE=false - - name: "klayout python2 osx10.11" - os: osx - osx_image: xcode8 # macOS 10.11 - env: - - MATRIX_EVAL="" - - ARCHFLAGS="-std=c++11" - - PIP_UPDATE="1" - - PYTHON_BUILD=true - - BREW_BUNDLE=false + # - name: "klayout python2 osx10.11" + # os: osx + # osx_image: xcode8 # macOS 10.11 + # env: + # - MATRIX_EVAL="" + # - ARCHFLAGS="-std=c++11" + # - PIP_UPDATE="1" + # - PYTHON_BUILD=true + # - BREW_BUNDLE=false - # python 3 osx + # # python 3 osx - - name: "klayout python3 osx10.13" - os: osx - osx_image: xcode9.4 # macOS 10.13 - env: - - MATRIX_EVAL="shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" - - ARCHFLAGS="-std=c++11" - - PIP_UPDATE="1" - - PYTHON_BUILD=true - - BREW_BUNDLE=true + # - name: "klayout python3 osx10.13" + # os: osx + # osx_image: xcode9.4 # macOS 10.13 + # env: + # - MATRIX_EVAL="shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" + # - ARCHFLAGS="-std=c++11" + # - PIP_UPDATE="1" + # - PYTHON_BUILD=true + # - BREW_BUNDLE=true - - name: "klayout python3 osx10.12" - os: osx - osx_image: xcode8.3 # macOS 10.12 - env: - - MATRIX_EVAL="shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" - - ARCHFLAGS="-std=c++11" - - PIP_UPDATE="1" - - PYTHON_BUILD=true - - BREW_BUNDLE=true + # - name: "klayout python3 osx10.12" + # os: osx + # osx_image: xcode8.3 # macOS 10.12 + # env: + # - MATRIX_EVAL="shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" + # - ARCHFLAGS="-std=c++11" + # - PIP_UPDATE="1" + # - PYTHON_BUILD=true + # - BREW_BUNDLE=true - - name: "klayout python3 osx10.11" - os: osx - osx_image: xcode8 # macOS 10.11 - env: - - MATRIX_EVAL="shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" - - ARCHFLAGS="-std=c++11" - - PIP_UPDATE="1" - - PYTHON_BUILD=true - - BREW_BUNDLE=true + # - name: "klayout python3 osx10.11" + # os: osx + # osx_image: xcode8 # macOS 10.11 + # env: + # - MATRIX_EVAL="shopt -s expand_aliases; alias python='python3'; alias pip='pip3';" + # - ARCHFLAGS="-std=c++11" + # - PIP_UPDATE="1" + # - PYTHON_BUILD=true + # - BREW_BUNDLE=true - name: "klayout python3.6 package" os: linux @@ -136,68 +136,68 @@ matrix: - PYTHON_BUILD=true - BREW_BUNDLE=false - # KLayout builds for mac - # Python 3 - - name: "KLayout macOS 10.13 with py3.7" - os: osx - osx_image: xcode9.4 # macOS 10.13 - env: - - MATRIX_EVAL="" - - PYTHON_VERSION=B37 - - MACOS_VERSION=HighSierra - - KLAYOUT_BUILD=true - - BREW_BUNDLE=true + # # KLayout builds for mac + # # Python 3 + # - name: "KLayout macOS 10.13 with py3.7" + # os: osx + # osx_image: xcode9.4 # macOS 10.13 + # env: + # - MATRIX_EVAL="" + # - PYTHON_VERSION=B37 + # - MACOS_VERSION=HighSierra + # - KLAYOUT_BUILD=true + # - BREW_BUNDLE=true - - name: "KLayout macOS 10.12 with py3.7" - os: osx - osx_image: xcode8.3 # macOS 10.12 - env: - - MATRIX_EVAL="" - - PYTHON_VERSION=B37 - - MACOS_VERSION=Sierra - - KLAYOUT_BUILD=true - - BREW_BUNDLE=true + # - name: "KLayout macOS 10.12 with py3.7" + # os: osx + # osx_image: xcode8.3 # macOS 10.12 + # env: + # - MATRIX_EVAL="" + # - PYTHON_VERSION=B37 + # - MACOS_VERSION=Sierra + # - KLAYOUT_BUILD=true + # - BREW_BUNDLE=true - - name: "KLayout macOS 10.11 with py3.7" - os: osx - osx_image: xcode8 # macOS 10.11 - env: - - MATRIX_EVAL="" - - PYTHON_VERSION=B37 - - MACOS_VERSION=ElCapitan - - KLAYOUT_BUILD=true - - BREW_BUNDLE=true + # - name: "KLayout macOS 10.11 with py3.7" + # os: osx + # osx_image: xcode8 # macOS 10.11 + # env: + # - MATRIX_EVAL="" + # - PYTHON_VERSION=B37 + # - MACOS_VERSION=ElCapitan + # - KLAYOUT_BUILD=true + # - BREW_BUNDLE=true - # Python 2 - - name: "KLayout macOS 10.13 with py2.7" - os: osx - osx_image: xcode9.4 # macOS 10.13 - env: - - MATRIX_EVAL="" - - PYTHON_VERSION=Sys - - MACOS_VERSION=HighSierra - - KLAYOUT_BUILD=true - - BREW_BUNDLE=true + # # Python 2 + # - name: "KLayout macOS 10.13 with py2.7" + # os: osx + # osx_image: xcode9.4 # macOS 10.13 + # env: + # - MATRIX_EVAL="" + # - PYTHON_VERSION=Sys + # - MACOS_VERSION=HighSierra + # - KLAYOUT_BUILD=true + # - BREW_BUNDLE=true - - name: "KLayout macOS 10.12 with py2.7" - os: osx - osx_image: xcode8.3 # macOS 10.12 - env: - - MATRIX_EVAL="" - - PYTHON_VERSION=Sys - - MACOS_VERSION=Sierra - - KLAYOUT_BUILD=true - - BREW_BUNDLE=true + # - name: "KLayout macOS 10.12 with py2.7" + # os: osx + # osx_image: xcode8.3 # macOS 10.12 + # env: + # - MATRIX_EVAL="" + # - PYTHON_VERSION=Sys + # - MACOS_VERSION=Sierra + # - KLAYOUT_BUILD=true + # - BREW_BUNDLE=true - - name: "KLayout macOS 10.11 with py2.7" - os: osx - osx_image: xcode8 # macOS 10.11 - env: - - MATRIX_EVAL="" - - PYTHON_VERSION=Sys - - MACOS_VERSION=ElCapitan - - KLAYOUT_BUILD=true - - BREW_BUNDLE=true + # - name: "KLayout macOS 10.11 with py2.7" + # os: osx + # osx_image: xcode8 # macOS 10.11 + # env: + # - MATRIX_EVAL="" + # - PYTHON_VERSION=Sys + # - MACOS_VERSION=ElCapitan + # - KLAYOUT_BUILD=true + # - BREW_BUNDLE=true before_install: - env diff --git a/setup.py b/setup.py index f817cf5b0..bf862b4e1 100644 --- a/setup.py +++ b/setup.py @@ -148,8 +148,9 @@ class Config(object): elif platform.system() == "Darwin": return [] else: - # Avoids many "type-punned pointer" warnings - return ["-Wno-strict-aliasing"] + return ["-Wno-strict-aliasing", # Avoids many "type-punned pointer" warnings + "-std=c++0x", # because we use unordered_map/unordered_set + ] def link_args(self, mod): """ @@ -173,7 +174,7 @@ class Config(object): # build path and the loader will fail. args = [] args += ['-Wl,-soname,' + self.libname_of(mod)] - if not '_dbpi' in mod: + if '_dbpi' not in mod: loader_path = '$ORIGIN' else: loader_path = '$ORIGIN/..' From ff6e818da8a84d7ae78318aad785c0130067095f Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Sat, 22 Sep 2018 13:49:18 -0400 Subject: [PATCH 02/12] [skip ci] minor change in deploy folder name --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f0816d2d0..5c7841c51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -222,8 +222,8 @@ script: python setup.py build; python setup.py bdist_wheel; python setup.py install; - mkdir -p deploy/dist; - cp -a dist deploy/dist; + mkdir -p deploy/dist-pymod; + cp -a dist/ deploy/dist-pymod; python -c 'import klayout.db as db; print(dir(db))'; python -c 'import klayout.rdb as rdb; print(dir(rdb))'; python -c 'import klayout.tl as tl; print(dir(tl))'; From 186d7c3ddcf078d3ff9ddcec1388b2a87bb807b2 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Sat, 22 Sep 2018 15:42:55 -0400 Subject: [PATCH 03/12] reorganizing dropbox folder to deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION) --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index beb2faf49..1654c3d96 100644 --- a/Makefile +++ b/Makefile @@ -36,16 +36,16 @@ test: dropbox-deploy: @echo "Preparing for dropbox deployment $(MACOS_VERSION) $(GITCOMMIT)" - mkdir -p deploy; \ + mkdir -p deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION); \ pwd; \ ls -lah; \ touch build.txt; \ - cp build.txt deploy/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).log.txt; \ + cp build.txt deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).log.txt; \ hdiutil convert macbuild/Resources/klayoutDMGTemplate.dmg -format UDRW -o work-KLayout.dmg; \ hdiutil resize -size 500m work-KLayout.dmg; \ hdiutil attach work-KLayout.dmg -readwrite -noverify -quiet -mountpoint tempKLayout -noautoopen; \ cp -a qt5.pkg.macos-$(MACOS_VERSION)-release/ tempKLayout/; \ hdiutil detach tempKLayout; \ - hdiutil convert work-KLayout.dmg -format UDZO -imagekey zlib-level=9 -o deploy/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg; \ - md5 -q deploy/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg > deploy/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg.md5; \ + hdiutil convert work-KLayout.dmg -format UDZO -imagekey zlib-level=9 -o deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg; \ + md5 -q deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg > deploy/$(MACOS_VERSION)/$(PYTHON_VERSION)/$(KLAYOUT_VERSION)/qt5.pkg.macos-$(MACOS_VERSION)-$(PYTHON_VERSION)-release-$(KLAYOUT_VERSION)-$(GITCOMMIT).dmg.md5; \ rm work-KLayout.dmg From 6ddecb1020d9f16b69012a8b9c1b88205c4f5cd6 Mon Sep 17 00:00:00 2001 From: Thomas Ferreira de Lima Date: Sat, 22 Sep 2018 19:38:25 -0400 Subject: [PATCH 04/12] travis bugfix: cp -a behaves differently in macs and linux --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5c7841c51..42f0d13f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -223,7 +223,7 @@ script: python setup.py bdist_wheel; python setup.py install; mkdir -p deploy/dist-pymod; - cp -a dist/ deploy/dist-pymod; + cp -a dist/* deploy/dist-pymod/; python -c 'import klayout.db as db; print(dir(db))'; python -c 'import klayout.rdb as rdb; print(dir(rdb))'; python -c 'import klayout.tl as tl; print(dir(tl))'; From ca6a46dabea79d87bd602822d657490c59e580e1 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 26 Sep 2018 22:19:02 +0200 Subject: [PATCH 05/12] COPYRIGHT file updated for Debian packager --- COPYRIGHT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/COPYRIGHT b/COPYRIGHT index 4d49b0a1b..11c6389d8 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,6 +1,6 @@ klayout is packaged by Peter C.S. Scholtens and Matthias Köfferlein -and was obtained from https://www.klayout.org/downloads/source/klayout-0.25.4.tar.gz +and was obtained from https://www.klayout.org/downloads/source/klayout-0.25.5.tar.gz Authors: Matthias Köfferlein From 1ff34fc1e2fd3b5cb4f7058d2fab47c3339cb470 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 27 Sep 2018 21:58:16 +0200 Subject: [PATCH 06/12] Fixed build.bat - wasn't properly exiting and did not really perform a build without install (the latter is important for producing the unit test runner binary --- build.bat | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build.bat b/build.bat index bdee5a50a..64dcc84ce 100644 --- a/build.bat +++ b/build.bat @@ -250,6 +250,11 @@ echo on "HAVE_64BIT_COORD=%HAVE_64BIT_COORD%" ^ "PREFIX=%option-bin%" ^ "BITS_PATH=%option-bits%\%compiler%\%arch%" ^ - %inst_path%\src\klayout.pro ^ -&& nmake %MAKE_OPT% ^ -&& nmake install + %inst_path%\src\klayout.pro || exit /b 1 + +rem start the build +nmake %MAKE_OPT% || exit /b 2 + +rem install the binaries +nmake install || exit /b 3 + From ad7154c6cf0e8747d558f2e699d335d1ab37bc1a Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 29 Sep 2018 23:35:30 +0200 Subject: [PATCH 07/12] Basic performance improvement in the bitmap to image area Empty bitmaps are skipped now --- src/laybasic/laybasic/layBitmapsToImage.cc | 97 +++++++++++++--------- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/src/laybasic/laybasic/layBitmapsToImage.cc b/src/laybasic/laybasic/layBitmapsToImage.cc index 2d8d7e3eb..07dc74fee 100644 --- a/src/laybasic/laybasic/layBitmapsToImage.cc +++ b/src/laybasic/laybasic/layBitmapsToImage.cc @@ -386,13 +386,18 @@ render_scanline_cross (const uint32_t *dp, unsigned int ds, const lay::Bitmap *p } } -static void create_precursor_bitmaps (const std::vector &view_ops_in, const std::vector &pbitmaps_in, const lay::LineStyles &ls, unsigned int width, unsigned int height, std::map &precursors, QMutex *mutex) +static void create_precursor_bitmaps (const std::vector &view_ops_in, const std::vector &vo_map, const std::vector &pbitmaps_in, const std::vector &bm_map, const lay::LineStyles &ls, unsigned int width, unsigned int height, std::map &precursors, QMutex *mutex) { + tl_assert (bm_map.size () == vo_map.size ()); + // Styled lines with width > 1 are not rendered directly, but through an intermediate step. // We prepare the necessary precursor bitmaps now - for (unsigned int i = 0; i < view_ops_in.size (); ++i) { + for (unsigned int i = 0; i < vo_map.size (); ++i) { - const ViewOp &op = view_ops_in [i]; + unsigned int vo_index = vo_map [i]; + unsigned int bm_index = bm_map [i]; + + const ViewOp &op = view_ops_in [vo_index]; if (op.width () > 1 && ls.style (op.line_style_index ()).width () > 0) { // lock bitmaps against change by the redraw thread @@ -400,12 +405,12 @@ static void create_precursor_bitmaps (const std::vector &view_ops_i mutex->lock (); } - lay::Bitmap &bp = precursors.insert (std::make_pair (i, lay::Bitmap (width, height, 1.0))).first->second; + lay::Bitmap &bp = precursors.insert (std::make_pair (bm_index, lay::Bitmap (width, height, 1.0))).first->second; LineStyleInfo ls_info = ls.style (op.line_style_index ()); ls_info.scale_pattern (op.width ()); for (unsigned int y = 0; y < height; y++) { - render_scanline_std_edge (ls_info.pattern (), ls_info.pattern_stride (), pbitmaps_in [i], y, width, height, bp.scanline (y)); + render_scanline_std_edge (ls_info.pattern (), ls_info.pattern_stride (), pbitmaps_in [bm_index], y, width, height, bp.scanline (y)); } if (mutex) { @@ -418,7 +423,7 @@ static void create_precursor_bitmaps (const std::vector &view_ops_i } static void -bitmaps_to_image_rgb (const std::vector &view_ops_in, +bitmaps_to_image_rgb (const std::vector &view_ops_in, const std::vector &pbitmaps_in, const lay::DitherPattern &dp, const lay::LineStyles &ls, @@ -427,29 +432,33 @@ bitmaps_to_image_rgb (const std::vector &view_ops_in, bool transparent, QMutex *mutex) { - unsigned int n_in = view_ops_in.size (); - std::vector bm_map; std::vector vo_map; - vo_map.reserve (n_in); - for (unsigned int i = 0; i < n_in; ++i) { - vo_map.push_back (i); - } + vo_map.reserve (view_ops_in.size ()); + bm_map.reserve (view_ops_in.size ()); + unsigned int n_in = 0; - if (! use_bitmap_index) { - bm_map = vo_map; - } else { - bm_map.reserve (n_in); - for (unsigned int i = 0; i < n_in; ++i) { - bm_map.push_back (view_ops_in [i].bitmap_index () < 0 ? i : view_ops_in [i].bitmap_index ()); + // drop invisible and empty bitmaps, build bitmap mask + for (unsigned int i = 0; i < view_ops_in.size (); ++i) { + + const lay::ViewOp &vop = view_ops_in [i]; + + unsigned int bi = (use_bitmap_index && vop.bitmap_index () >= 0) ? (unsigned int) vop.bitmap_index () : i; + const lay::Bitmap *pb = bi < pbitmaps_in.size () ? pbitmaps_in [bi] : 0; + + if ((vop.ormask () | ~vop.andmask ()) != 0 && pb && ! pb->empty ()) { + vo_map.push_back (i); + bm_map.push_back (bi); + ++n_in; } + } // Styled lines with width > 1 are not rendered directly, but through an intermediate step. // We prepare the necessary precursor bitmaps now std::map precursors; - create_precursor_bitmaps (view_ops_in, pbitmaps_in, ls, width, height, precursors, mutex); + create_precursor_bitmaps (view_ops_in, vo_map, pbitmaps_in, bm_map, ls, width, height, precursors, mutex); std::vector view_ops; std::vector pbitmaps; @@ -489,18 +498,19 @@ bitmaps_to_image_rgb (const std::vector &view_ops_in, unsigned int w = vop.width (); const lay::Bitmap *pb = 0; + unsigned int bm_index = bm_map[i]; if (bm_map [i] < pbitmaps_in.size ()) { if (w > 1 && ls.style (vop.line_style_index ()).width () > 0) { - tl_assert (precursors.find (i) != precursors.end ()); - pb = &precursors [i]; + tl_assert (precursors.find (bm_index) != precursors.end ()); + pb = &precursors [bm_index]; } else { - pb = pbitmaps_in [bm_map[i]]; + pb = pbitmaps_in [bm_index]; } } if (pb != 0 && w > 0 - && ((pb->first_scanline () < y + slice && pb->last_scanline () > y) || w > 1) + && (pb->first_scanline () + w - 1 < y + slice && pb->last_scanline () > y + w - 1) && (vop.ormask () | ~vop.andmask ()) != 0) { uint32_t non_empty_sl = 0; @@ -660,29 +670,33 @@ bitmaps_to_image_mono (const std::vector &view_ops_in, bool use_bitmap_index, QMutex *mutex) { - unsigned int n_in = view_ops_in.size (); - std::vector bm_map; std::vector vo_map; - vo_map.reserve (n_in); - for (unsigned int i = 0; i < n_in; ++i) { - vo_map.push_back (i); - } + vo_map.reserve (view_ops_in.size ()); + bm_map.reserve (view_ops_in.size ()); + unsigned int n_in = 0; - if (! use_bitmap_index) { - bm_map = vo_map; - } else { - bm_map.reserve (n_in); - for (unsigned int i = 0; i < n_in; ++i) { - bm_map.push_back (view_ops_in [i].bitmap_index () < 0 ? i : view_ops_in [i].bitmap_index ()); + // drop invisible and empty bitmaps, build bitmap mask + for (unsigned int i = 0; i < view_ops_in.size (); ++i) { + + const lay::ViewOp &vop = view_ops_in [i]; + + unsigned int bi = (use_bitmap_index && vop.bitmap_index () >= 0) ? (unsigned int) vop.bitmap_index () : i; + const lay::Bitmap *pb = bi < pbitmaps_in.size () ? pbitmaps_in [bi] : 0; + + if ((vop.ormask () | ~vop.andmask ()) != 0 && pb && ! pb->empty ()) { + vo_map.push_back (i); + bm_map.push_back (bi); + ++n_in; } + } // Styled lines with width > 1 are not rendered directly, but through an intermediate step. // We prepare the necessary precursor bitmaps now std::map precursors; - create_precursor_bitmaps (view_ops_in, pbitmaps_in, ls, width, height, precursors, mutex); + create_precursor_bitmaps (view_ops_in, vo_map, pbitmaps_in, bm_map, ls, width, height, precursors, mutex); std::vector view_ops; std::vector pbitmaps; @@ -722,18 +736,19 @@ bitmaps_to_image_mono (const std::vector &view_ops_in, unsigned int w = vop.width (); const lay::Bitmap *pb = 0; + unsigned int bm_index = bm_map[i]; if (bm_map [i] < pbitmaps_in.size ()) { if (w > 1 && ls.style (vop.line_style_index ()).width () > 0) { - tl_assert (precursors.find (i) != precursors.end ()); - pb = &precursors [i]; + tl_assert (precursors.find (bm_index) != precursors.end ()); + pb = &precursors [bm_index]; } else { - pb = pbitmaps_in [bm_map[i]]; + pb = pbitmaps_in [bm_index]; } } - if (pb != 0 + if (pb != 0 && w > 0 - && ((pb->first_scanline () < y + slice && pb->last_scanline () > y) || w > 1) + && (pb->first_scanline () + w - 1 < y + slice && pb->last_scanline () > y + w - 1) && (vop.ormask () | ~vop.andmask ()) != 0) { uint32_t non_empty_sl = 0; From c342bca584c26c5cf94f27002de9afaf3459a869 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 30 Sep 2018 00:16:19 +0200 Subject: [PATCH 08/12] WIP: updated solution * Reverted first solution partially because it lead to drawing errors. * Redraw thread will fire workers only for layers that really need to be drawn --- src/laybasic/laybasic/layBitmapsToImage.cc | 4 ++-- src/laybasic/laybasic/layRedrawLayerInfo.h | 15 ++++++++++++--- src/laybasic/laybasic/layRedrawThread.cc | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/laybasic/laybasic/layBitmapsToImage.cc b/src/laybasic/laybasic/layBitmapsToImage.cc index 07dc74fee..67558c4e8 100644 --- a/src/laybasic/laybasic/layBitmapsToImage.cc +++ b/src/laybasic/laybasic/layBitmapsToImage.cc @@ -510,7 +510,7 @@ bitmaps_to_image_rgb (const std::vector &view_ops_in, if (pb != 0 && w > 0 - && (pb->first_scanline () + w - 1 < y + slice && pb->last_scanline () > y + w - 1) + && ((pb->first_scanline () < y + slice && pb->last_scanline () > y) || w > 1) && (vop.ormask () | ~vop.andmask ()) != 0) { uint32_t non_empty_sl = 0; @@ -748,7 +748,7 @@ bitmaps_to_image_mono (const std::vector &view_ops_in, if (pb != 0 && w > 0 - && (pb->first_scanline () + w - 1 < y + slice && pb->last_scanline () > y + w - 1) + && ((pb->first_scanline () < y + slice && pb->last_scanline () > y) || w > 1) && (vop.ormask () | ~vop.andmask ()) != 0) { uint32_t non_empty_sl = 0; diff --git a/src/laybasic/laybasic/layRedrawLayerInfo.h b/src/laybasic/laybasic/layRedrawLayerInfo.h index 3befe4c33..60865b241 100644 --- a/src/laybasic/laybasic/layRedrawLayerInfo.h +++ b/src/laybasic/laybasic/layRedrawLayerInfo.h @@ -74,9 +74,10 @@ struct RedrawLayerInfo /** * @brief The layer index * - * The logical layer to draw. If this member is <0 and the cellview_index is <0, it is an invalid layer, - * which is ignored. If the cellview_index is >=0, it denotes a "cell frame" pseudo - * layer. It is set by the constructor. + * The logical layer to draw. The layer index can be <0 which indicates a + * layer with not layout source (cell_frame may be true to indicate a + * pseudo layer then). + * This attribute is set by the constructor. */ int layer_index; @@ -115,6 +116,14 @@ struct RedrawLayerInfo * This member is set by the constructor. */ bool inverse_prop_sel; + + /** + * @brief Returns true, if the layer needs to be drawn + */ + bool needs_drawing () const + { + return visible && enabled && (cell_frame || layer_index >= 0) && cellview_index >= 0; + } }; } diff --git a/src/laybasic/laybasic/layRedrawThread.cc b/src/laybasic/laybasic/layRedrawThread.cc index ec2233de7..4ed200192 100644 --- a/src/laybasic/laybasic/layRedrawThread.cc +++ b/src/laybasic/laybasic/layRedrawThread.cc @@ -307,7 +307,7 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v } for (int i = 0; i < m_nlayers; ++i) { - if (m_layers [i].visible && m_layers [i].enabled) { + if (m_layers [i].needs_drawing ()) { schedule (new RedrawThreadTask (i)); } } From c08f0a1fdae400e4934b9cc5e5d21fd452d6f531 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 30 Sep 2018 10:27:44 +0200 Subject: [PATCH 09/12] Fixed #176 by introducing a separate bitmap for text drawing optimization. --- .../laybasic/layRedrawThreadWorker.cc | 26 +++++++++++++------ src/laybasic/laybasic/layRedrawThreadWorker.h | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.cc b/src/laybasic/laybasic/layRedrawThreadWorker.cc index 93d8ce130..c0df55ba7 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.cc +++ b/src/laybasic/laybasic/layRedrawThreadWorker.cc @@ -1232,20 +1232,26 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c vertex = m_planes[3 + plane_group * (planes_per_layer / 3)]; // do not draw, if there is nothing to draw - if (mp_layout->cells () <= ci || vp.empty ()) { + if (mp_layout->cells () <= ci || vp.empty () || mp_layout->cell (ci).bbox (m_layer).empty ()) { return; } if (cell_var_cached (ci, trans)) { return; } + std::auto_ptr opt_bitmap; + lay::Bitmap *vertex_bitmap = dynamic_cast (vertex); + if (m_text_lazy_rendering && vertex_bitmap) { + opt_bitmap.reset (new lay::Bitmap (vertex_bitmap->width (), vertex_bitmap->height (), vertex_bitmap->resolution ())); + } + for (std::vector::const_iterator b = vp.begin (); b != vp.end (); ++b) { - draw_text_layer (drawing_context, ci, trans, *b, level, fill, frame, vertex, text); + draw_text_layer (drawing_context, ci, trans, *b, level, fill, frame, vertex, text, opt_bitmap.get ()); } } void -RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &vp, int level, CanvasPlane *fill, CanvasPlane *frame, CanvasPlane *vertex, CanvasPlane *text) +RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &vp, int level, CanvasPlane *fill, CanvasPlane *frame, CanvasPlane *vertex, CanvasPlane *text, lay::Bitmap *opt_bitmap) { test_snapshot (0); @@ -1283,6 +1289,9 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c // paint the simplified box if (anything) { r.draw (trans * bbox, 0, frame, vertex, 0); + if (opt_bitmap) { + r.draw (trans * bbox, 0, 0, opt_bitmap, 0); + } } // do not dive further into hierarchy @@ -1318,6 +1327,9 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c test_snapshot (0); r.draw (*shape, trans, fill, frame, vertex, text); + if (opt_bitmap) { + r.draw (*shape, trans, 0, 0, opt_bitmap, 0); + } ++shape; --ntexts; @@ -1355,8 +1367,6 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c // dive down into the hierarchy .. if (need_to_dive) { - const lay::Bitmap *vertex_bitmap = dynamic_cast (vertex); - // create a set of boxes to look into std::vector vv = search_regions (cell_bbox, vp, level); @@ -1377,7 +1387,7 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c bool skip = false; if (m_text_lazy_rendering && qid != current_quad_id) { current_quad_id = qid; - skip = vertex_bitmap && skip_quad (inst.quad_box () & bbox, vertex_bitmap, trans); + skip = opt_bitmap && skip_quad (inst.quad_box () & bbox, opt_bitmap, trans); } if (skip) { @@ -1448,7 +1458,7 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c db::ICplxTrans t (cell_inst.complex_trans (*p)); db::Box new_vp = db::Box (t.inverted () * *v); - draw_text_layer (drawing_context, new_ci, trans * t, new_vp, level + 1, fill, frame, vertex, text); + draw_text_layer (drawing_context, new_ci, trans * t, new_vp, level + 1, fill, frame, vertex, text, opt_bitmap); } @@ -1648,7 +1658,7 @@ RedrawThreadWorker::draw_layer_wo_cache (int from_level, int to_level, db::cell_ // skip this quad if we have drawn something here already size_t qid = inst.quad_id (); bool skip = false; - if (m_text_lazy_rendering && qid != current_quad_id) { + if (qid != current_quad_id) { current_quad_id = qid; skip = skip_quad (inst.quad_box () & bbox, vertex_bitmap, trans); } diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.h b/src/laybasic/laybasic/layRedrawThreadWorker.h index 0b49a44d3..ea2a90a11 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.h +++ b/src/laybasic/laybasic/layRedrawThreadWorker.h @@ -180,7 +180,7 @@ private: void draw_layer (int from_level, int to_level, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &redraw_box, int level, lay::CanvasPlane *fill, lay::CanvasPlane *frame, lay::CanvasPlane *vertex, lay::CanvasPlane *text, const UpdateSnapshotCallback *update_snapshot); void draw_layer_wo_cache (int from_level, int to_level, db::cell_index_type ci, const db::CplxTrans &trans, const std::vector &vv, int level, lay::CanvasPlane *fill, lay::CanvasPlane *frame, lay::CanvasPlane *vertex, lay::CanvasPlane *text, const UpdateSnapshotCallback *update_snapshot); void draw_text_layer (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const std::vector &redraw_regions, int level); - void draw_text_layer (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &redraw_region, int level, lay::CanvasPlane *fill, lay::CanvasPlane *frame, lay::CanvasPlane *vertex, lay::CanvasPlane *text); + void draw_text_layer (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &redraw_region, int level, lay::CanvasPlane *fill, lay::CanvasPlane *frame, lay::CanvasPlane *vertex, lay::CanvasPlane *text, Bitmap *opt_bitmap); void draw_boxes (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const std::vector &redraw_regions, int level); void draw_boxes (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const db::Box &redraw_region, int level); void draw_box_properties (bool drawing_context, db::cell_index_type ci, const db::CplxTrans &trans, const std::vector &redraw_regions, int level); From 330dac8c74fc707cb81684cf48fce209e23539a6 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 30 Sep 2018 20:26:25 +0200 Subject: [PATCH 10/12] Updated Changelog. --- Changelog | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index df9613b49..3b7cbfe4a 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,4 @@ -0.25.5 (2018-09-26): +0.25.5 (2018-09-30): * Bugfix: https://github.com/klayoutmatthias/klayout/issues/162 GDS2 LIBNAME was not maintained on "File/Save". @@ -6,6 +6,10 @@ Internal error when writing GDS files (breaking of polygons) * Bugfix: https://github.com/klayoutmatthias/klayout/issues/172 DEF reader did not pull vias from LEF +* Bugfix: https://github.com/klayoutmatthias/klayout/issues/174 + Performance issue with many layers with width >1 +* Bugfix: https://github.com/klayoutmatthias/klayout/issues/175 + Painting issue with texts * Bugfix: some potential memory corruption issues fixed During the efforts for making the code base compatible with MSVC, some potential candidates for memory corruption From 28ddc02b18d1054909dbfbfd96b292036458854b Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 30 Sep 2018 23:04:09 +0200 Subject: [PATCH 11/12] Updated Debian changelog (for sync with next release) --- Changelog.Debian | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.Debian b/Changelog.Debian index 2075bc6af..01d8e502a 100644 --- a/Changelog.Debian +++ b/Changelog.Debian @@ -3,7 +3,7 @@ klayout (0.25.5-1) unstable; urgency=low * New features and bugfixes - See changelog - -- Matthias Köfferlein Wed, 19 Sep 2018 22:04:35 +0200 + -- Matthias Köfferlein Sun, 30 Sep 2018 23:02:44 +0200 klayout (0.25.4-1) unstable; urgency=low From 9dd603bbd55b0c6f6b9ad56b3f729466225b22f0 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 30 Sep 2018 23:27:25 +0200 Subject: [PATCH 12/12] Fixed a typo (issue number in changelog) --- Changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 3b7cbfe4a..67682c951 100644 --- a/Changelog +++ b/Changelog @@ -8,7 +8,7 @@ DEF reader did not pull vias from LEF * Bugfix: https://github.com/klayoutmatthias/klayout/issues/174 Performance issue with many layers with width >1 -* Bugfix: https://github.com/klayoutmatthias/klayout/issues/175 +* Bugfix: https://github.com/klayoutmatthias/klayout/issues/176 Painting issue with texts * Bugfix: some potential memory corruption issues fixed During the efforts for making the code base compatible