mirror of
https://github.com/status-im/qzxing.git
synced 2025-02-18 05:47:03 +00:00
Optimize: Return the matrix reference directly instead of copying it.
This removes another copy of frame data, thereby improving the FPS of the QZXingFilter example noticeably.
This commit is contained in:
parent
449a808972
commit
61508f461a
@ -58,16 +58,16 @@ ArrayRef<byte> GreyscaleLuminanceSource::getRow(int y, ArrayRef<byte> row) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayRef<byte> GreyscaleLuminanceSource::getMatrix() const {
|
ArrayRef<byte> GreyscaleLuminanceSource::getMatrix() const {
|
||||||
int size = getWidth() * getHeight();
|
|
||||||
ArrayRef<byte> result (size);
|
|
||||||
if (left_ == 0 && top_ == 0 && dataWidth_ == getWidth() && dataHeight_ == getHeight()) {
|
if (left_ == 0 && top_ == 0 && dataWidth_ == getWidth() && dataHeight_ == getHeight()) {
|
||||||
memcpy(&result[0], &greyData_[0], size);
|
return greyData_;
|
||||||
} else {
|
} else {
|
||||||
|
int size = getWidth() * getHeight();
|
||||||
|
ArrayRef<byte> result (size);
|
||||||
for (int row = 0; row < getHeight(); row++) {
|
for (int row = 0; row < getHeight(); row++) {
|
||||||
memcpy(&result[row * getWidth()], &greyData_[(top_ + row) * dataWidth_ + left_], getWidth());
|
memcpy(&result[row * getWidth()], &greyData_[(top_ + row) * dataWidth_ + left_], getWidth());
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<LuminanceSource> GreyscaleLuminanceSource::rotateCounterClockwise() const {
|
Ref<LuminanceSource> GreyscaleLuminanceSource::rotateCounterClockwise() const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user