mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 07:13:02 +04:00
Merge pull request #27599 from chacha21:drawing_stack_alloc
optimize some drawing with stack allocation #27599 Some drawings can try a stack allocation instead of a std::vector ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -2034,9 +2034,12 @@ void fillPoly( InputOutputArray _img, const Point** pts, const int* npts, int nc
|
||||
edges.reserve( total + 1 );
|
||||
for (i = 0; i < ncontours; i++)
|
||||
{
|
||||
if (npts[i] > 0 && pts[i])
|
||||
const Point* currentContour = pts[i];
|
||||
const int currentContourLength = npts[i];
|
||||
if ( (currentContourLength > 0) && currentContour )
|
||||
{
|
||||
std::vector<Point2l> _pts(pts[i], pts[i] + npts[i]);
|
||||
AutoBuffer<Point2l> _pts(currentContourLength);
|
||||
std::copy(currentContour, currentContour+currentContourLength, _pts.data());
|
||||
CollectPolyEdges(img, _pts.data(), npts[i], edges, buf, line_type, shift, offset);
|
||||
}
|
||||
}
|
||||
@@ -2063,8 +2066,11 @@ void polylines( InputOutputArray _img, const Point* const* pts, const int* npts,
|
||||
|
||||
for( int i = 0; i < ncontours; i++ )
|
||||
{
|
||||
std::vector<Point2l> _pts(pts[i], pts[i]+npts[i]);
|
||||
PolyLine( img, _pts.data(), npts[i], isClosed, buf, thickness, line_type, shift );
|
||||
const Point* currentContour = pts[i];
|
||||
const int currentContourLength = npts[i];
|
||||
AutoBuffer<Point2l> _pts(currentContourLength);
|
||||
std::copy(currentContour, currentContour+currentContourLength, _pts.data());
|
||||
PolyLine( img, _pts.data(), currentContourLength, isClosed, buf, thickness, line_type, shift );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user