Skip to content

Commit

Permalink
bugfix for "visiblity optimization" (#80)
Browse files Browse the repository at this point in the history
* fix bug in visibility-check
  • Loading branch information
ptahmose committed Nov 21, 2023
1 parent 6497366 commit 8cd30f6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW) # enable new "MSVC runtime library selection" (https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)

project(libCZI
VERSION 0.55.0
VERSION 0.55.1
HOMEPAGE_URL "https://github.com/ZEISS/libczi"
DESCRIPTION "libCZI is an Open Source Cross-Platform C++ library to read and write CZI")

Expand Down
3 changes: 2 additions & 1 deletion Src/libCZI/Doc/version-history.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ version history {#version_history}
0.54.0 | [71](https://github.com/ZEISS/libczi/pull/71) | introduce 'streamsLib', add curl-based stream class
0.54.2 | [74](https://github.com/ZEISS/libczi/pull/74) | minor bug fix
0.54.3 | [79](https://github.com/ZEISS/libczi/pull/79) | add option _kCurlHttp_FollowLocation_ to follow HTTP redirects tp curl_http_inputstream
0.55.0 | [78](https://github.com/ZEISS/libczi/pull/78) | optimization: for multi-tile-composition, check relevant tiles for visibility before loading them (and do not load/decode non-visible tiles)
0.55.0 | [78](https://github.com/ZEISS/libczi/pull/78) | optimization: for multi-tile-composition, check relevant tiles for visibility before loading them (and do not load/decode non-visible tiles)
0.55.1 | [80](https://github.com/ZEISS/libczi/pull/80) | bugfix for above optimization
2 changes: 1 addition & 1 deletion Src/libCZI/SingleChannelAccessorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ std::vector<int> CSingleChannelAccessorBase::CheckForVisibility(const libCZI::In
{ // some pixels which were not overdrawn by all the previous ones
// this means - when drawing this subblock, some new pixels will be covered which were not covered before,
// so we need to draw this subblock, therefore we add it to our result vector
result.push_back(subblock_index);
result.push_back(i);

covered_pixel_count = new_covered_pixel_count;
if (new_covered_pixel_count == total_pixel_count)
Expand Down
26 changes: 26 additions & 0 deletions Src/libCZI_UnitTests/test_TileAccessorCoverageOptimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,29 @@ TEST(TileAccessorCoverageOptimization, CheckForVisibility_TestCase4)
EXPECT_EQ(indices_of_visible_tiles[0], 1);
EXPECT_EQ(indices_of_visible_tiles[1], 5);
}

TEST(TileAccessorCoverageOptimization, CheckForVisibility_TestCase5)
{
static constexpr array<IntRect, 6> kSubBlocks{ IntRect{0,0,1,1}, IntRect{0,0,1,1}, IntRect{1,0,1,2}, IntRect{2,0,3,3}, IntRect{2,0,1,1}, IntRect{1,0,2,3} };

// the function CheckForVisibilityCore is supposed to return a vector with indices "as they are used to call into
// 'get_subblock_index'-functor" (**not** the subblock-index as returned from this functor). We check this here by
// returning a "non-zero-based"-index from the functor, where we then check that the returned vector contains the
// correct results according to above rule (and the function's documentation).

const auto indices_of_visible_tiles = CSingleChannelAccessorBaseToTestStub::CheckForVisibilityCore(
{ 0, 0, 3, 3 },
kSubBlocks.size(),
[&](int index)->int
{
return index + 10;
},
[&](int subblock_index)->IntRect
{
return kSubBlocks[subblock_index - 10];
});

ASSERT_EQ(indices_of_visible_tiles.size(), 2);
EXPECT_EQ(indices_of_visible_tiles[0], 1);
EXPECT_EQ(indices_of_visible_tiles[1], 5);
}

0 comments on commit 8cd30f6

Please sign in to comment.