summaryrefslogtreecommitdiffhomepage
path: root/pose-widget/glwidget.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-06-04 19:51:33 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-06-05 09:55:58 +0200
commit74b8483457b51727dba38aa05a5be9bc773d8a28 (patch)
tree2f5f454163057dd4f0f11e7346788231c5788c2a /pose-widget/glwidget.cpp
parentb1c929e63eaf689895359ce7b5a4b86b46439f11 (diff)
octopus, pt, aruco: optimize image copying
Perform less operations in inner loop where pixels are accessed.
Diffstat (limited to 'pose-widget/glwidget.cpp')
-rw-r--r--pose-widget/glwidget.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp
index 0322077b..b444e87e 100644
--- a/pose-widget/glwidget.cpp
+++ b/pose-widget/glwidget.cpp
@@ -145,14 +145,14 @@ void GLWidget::project_quad_texture() {
Triangle(projected[1][0], projected[1][1], projected[1][2])
};
- int orig_pitch = tex.bytesPerLine();
- int dest_pitch = texture.bytesPerLine();
+ const int orig_pitch = tex.bytesPerLine();
+ const int dest_pitch = texture.bytesPerLine();
const unsigned char* orig = tex.bits();
unsigned char* dest = texture.bits();
- int orig_depth = tex.depth() / 8;
- int dest_depth = texture.depth() / 8;
+ const int orig_depth = tex.depth() / 8;
+ const int dest_depth = texture.depth() / 8;
/* image breakage? */
if (orig_depth < 3)
@@ -165,12 +165,13 @@ void GLWidget::project_quad_texture() {
vec2 coords;
if (triangles[i].barycentric_coords(pos, coords))
{
- int px = origs[i][0].x()
+ const int px = origs[i][0].x()
+ coords.x() * (origs[i][2].x() - origs[i][0].x())
+ coords.y() * (origs[i][1].x() - origs[i][0].x());
- int py = origs[i][0].y()
+ const int py = origs[i][0].y()
+ coords.x() * (origs[i][2].y() - origs[i][0].y())
+ coords.y() * (origs[i][1].y() - origs[i][0].y());
+
int r = orig[py * orig_pitch + px * orig_depth + 2];
int g = orig[py * orig_pitch + px * orig_depth + 1];
int b = orig[py * orig_pitch + px * orig_depth + 0];