diff options
author | B. Stack <bgstack15@gmail.com> | 2021-08-18 11:26:25 +0000 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2021-08-18 11:26:25 +0000 |
commit | 3569c0964edd9bb68fe8d360180e087c373bf6cc (patch) | |
tree | ec5580fe98230ce8eb25a5ed6e53b3ec5dfd03f9 /wx+ | |
parent | Merge branch '11.12-fix' into 'master' (diff) | |
parent | add upstream 11.13 (diff) | |
download | FreeFileSync-3569c0964edd9bb68fe8d360180e087c373bf6cc.tar.gz FreeFileSync-3569c0964edd9bb68fe8d360180e087c373bf6cc.tar.bz2 FreeFileSync-3569c0964edd9bb68fe8d360180e087c373bf6cc.zip |
Merge branch 'b11.13' into 'master'11.13
add upstream 11.13
See merge request opensource-tracking/FreeFileSync!37
Diffstat (limited to 'wx+')
-rw-r--r-- | wx+/graph.cpp | 56 | ||||
-rw-r--r-- | wx+/grid.cpp | 2 | ||||
-rw-r--r-- | wx+/image_tools.cpp | 8 |
3 files changed, 34 insertions, 32 deletions
diff --git a/wx+/graph.cpp b/wx+/graph.cpp index 0f9cffef..eb9256f4 100644 --- a/wx+/graph.cpp +++ b/wx+/graph.cpp @@ -588,16 +588,16 @@ void Graph2D::render(wxDC& dc) const double minX = attr_.minX ? *attr_.minX : std::numeric_limits<double>::infinity(); //automatic: ensure values are initialized by first curve double maxX = attr_.maxX ? *attr_.maxX : -std::numeric_limits<double>::infinity(); // for (const auto& [curve, attrib] : curves_) - { - const std::pair<double, double> rangeX = curve.ref().getRangeX(); - assert(rangeX.first <= rangeX.second + 1.0e-9); - //GCC fucks up badly when comparing two *binary identical* doubles and finds "begin > end" with diff of 1e-18 - - if (!attr_.minX) - minX = std::min(minX, rangeX.first); - if (!attr_.maxX) - maxX = std::max(maxX, rangeX.second); - } + { + const std::pair<double, double> rangeX = curve.ref().getRangeX(); + assert(rangeX.first <= rangeX.second + 1.0e-9); + //GCC fucks up badly when comparing two *binary identical* doubles and finds "begin > end" with diff of 1e-18 + + if (!attr_.minX) + minX = std::min(minX, rangeX.first); + if (!attr_.maxX) + maxX = std::max(maxX, rangeX.second); + } if (minX <= maxX && maxX - minX < std::numeric_limits<double>::infinity()) //valid x-range { @@ -619,29 +619,29 @@ void Graph2D::render(wxDC& dc) const std::vector<std::vector<char>> oobMarker (curves_.size()); //effectively a std::vector<bool> marking points that start an out-of-bounds line for (size_t index = 0; index < curves_.size(); ++index) + { + const CurveData& curve = curves_ [index].first.ref(); + std::vector<CurvePoint>& points = curvePoints[index]; + auto& marker = oobMarker [index]; + + points = curve.getPoints(minX, maxX, graphArea.GetSize()); + marker.resize(points.size()); //default value: false + if (!points.empty()) { - const CurveData& curve = curves_ [index].first.ref(); - std::vector<CurvePoint>& points = curvePoints[index]; - auto& marker = oobMarker [index]; + //cut points outside visible x-range now in order to calculate height of visible line fragments only! + const bool doPolygonCut = curves_[index].second.fillMode == CurveFillMode::polygon; //impacts auto minY/maxY!! + cutPointsOutsideX(points, marker, minX, maxX, doPolygonCut); - points = curve.getPoints(minX, maxX, graphArea.GetSize()); - marker.resize(points.size()); //default value: false - if (!points.empty()) + if (!attr_.minY || !attr_.maxY) { - //cut points outside visible x-range now in order to calculate height of visible line fragments only! - const bool doPolygonCut = curves_[index].second.fillMode == CurveFillMode::polygon; //impacts auto minY/maxY!! - cutPointsOutsideX(points, marker, minX, maxX, doPolygonCut); - - if (!attr_.minY || !attr_.maxY) - { - auto itPair = std::minmax_element(points.begin(), points.end(), [](const CurvePoint& lhs, const CurvePoint& rhs) { return lhs.y < rhs.y; }); - if (!attr_.minY) - minY = std::min(minY, itPair.first->y); - if (!attr_.maxY) - maxY = std::max(maxY, itPair.second->y); - } + auto itPair = std::minmax_element(points.begin(), points.end(), [](const CurvePoint& lhs, const CurvePoint& rhs) { return lhs.y < rhs.y; }); + if (!attr_.minY) + minY = std::min(minY, itPair.first->y); + if (!attr_.maxY) + maxY = std::max(maxY, itPair.second->y); } } + } if (minY <= maxY) //valid y-range { diff --git a/wx+/grid.cpp b/wx+/grid.cpp index 80e9d1d6..a32de84e 100644 --- a/wx+/grid.cpp +++ b/wx+/grid.cpp @@ -1761,7 +1761,7 @@ void Grid::onKeyDown(wxKeyEvent& event) const size_t row = std::min(mainWin_->getCursor(), getRowCount()); const int clientPosMainWinY = std::clamp(CalcScrolledPosition(wxPoint(0, rowLabelWin_->getRowHeight() * (row + 1))).y - 1, //logical -> window coordinates - 0, mainWin_->GetClientSize().GetHeight() - 1); + 0, mainWin_->GetClientSize().GetHeight() - 1); const wxPoint mousePos = mainWin_->GetPosition() + wxPoint(0, clientPosMainWinY); //mainWin_-relative to Grid-relative diff --git a/wx+/image_tools.cpp b/wx+/image_tools.cpp index b95a7369..b519aac2 100644 --- a/wx+/image_tools.cpp +++ b/wx+/image_tools.cpp @@ -81,6 +81,7 @@ void copyImageLayover(const wxImage& src, assert(0 <= trgPos.y && trgPos.y + srcHeight <= trg.GetHeight()); //subset of target image! //https://en.wikipedia.org/wiki/Alpha_compositing + //TODO!? gamma correction: https://en.wikipedia.org/wiki/Alpha_compositing#Gamma_correction const unsigned char* srcRgb = src.GetData(); const unsigned char* srcAlpha = src.GetAlpha(); @@ -239,8 +240,8 @@ wxImage zen::createImageFromText(const wxString& text, const wxFont& font, const for (int i = 0; i < pixelCount; ++i) { //black(0,0,0) becomes wxIMAGE_ALPHA_OPAQUE(255), while white(255,255,255) becomes wxIMAGE_ALPHA_TRANSPARENT(0) + //gamma correction? does not seem to apply here! *alpha++ = static_cast<unsigned char>(numeric::intDivRound(3 * 255 - rgb[0] - rgb[1] - rgb[2], 3)); //mixed-mode arithmetics! - *rgb++ = col.Red (); // *rgb++ = col.Green(); //apply actual text color *rgb++ = col.Blue (); // @@ -321,6 +322,7 @@ wxImage zen::bilinearScale(const wxImage& img, int width, int height) const int idx = y * srcWidth + x; const unsigned char* const ptr = rgb + idx * 3; + //TODO!? gamma correction: https://en.wikipedia.org/wiki/Alpha_compositing#Gamma_correction const unsigned char a = alpha[idx]; pix[0] = a; pix[1] = xbrz::premultiply(ptr[0], a); //r @@ -334,8 +336,8 @@ wxImage zen::bilinearScale(const wxImage& img, int width, int height) const auto imgWriter = [rgb = imgOut.GetData(), alpha = imgOut.GetAlpha()](const xbrz::BytePixel& pix) mutable { const unsigned char a = pix[0]; - *alpha++ = a; - *rgb++ = xbrz::demultiply(pix[1], a); //r + * alpha++ = a; + * rgb++ = xbrz::demultiply(pix[1], a); //r *rgb++ = xbrz::demultiply(pix[2], a); //g *rgb++ = xbrz::demultiply(pix[3], a); //b }; |