[aseprite] 96/196: Improve image_scale_tpl() performance using an iterator for source image
Tobias Hansen
thansen at moszumanska.debian.org
Wed Apr 20 18:50:06 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit ce02a31c013c3418cc570740fa8addfaaa8ce3b7
Author: David Capello <davidcapello at gmail.com>
Date: Tue Mar 22 18:23:03 2016 -0300
Improve image_scale_tpl() performance using an iterator for source image
---
src/doc/algorithm/rotate.cpp | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/doc/algorithm/rotate.cpp b/src/doc/algorithm/rotate.cpp
index 4f8d8d2..c86b9cc 100644
--- a/src/doc/algorithm/rotate.cpp
+++ b/src/doc/algorithm/rotate.cpp
@@ -47,21 +47,32 @@ static void image_scale_tpl(
{
LockImageBits<ImageTraits> dst_bits(dst, gfx::Rect(dst_x, dst_y, dst_w, dst_h));
typename LockImageBits<ImageTraits>::iterator dst_it = dst_bits.begin();
- fixed x;
+ fixed x, first_x = itofix(src_x);
fixed y = itofix(src_y);
fixed dx = fixdiv(itofix(src_w-1), itofix(dst_w-1));
fixed dy = fixdiv(itofix(src_h-1), itofix(dst_h-1));
+ int old_x, new_x;
for (int v=0; v<dst_h; ++v) {
- x = itofix(src_x);
+ old_x = fixtoi(x = first_x);
+
+ const LockImageBits<ImageTraits> src_bits(src, gfx::Rect(src_x, fixtoi(y), src_w, 1));
+ auto src_it = src_bits.begin();
+
for (int u=0; u<dst_w; ++u) {
ASSERT(dst_it != dst_bits.end());
- color_t src_color = get_pixel_fast<ImageTraits>(src, fixtoi(x), fixtoi(y));
- *dst_it = blend(*dst_it, src_color);
+
+ *dst_it = blend(*dst_it, *src_it);
++dst_it;
x = fixadd(x, dx);
+ new_x = fixtoi(x);
+ if (old_x != new_x) {
+ src_it += (new_x - old_x);
+ old_x = new_x;
+ }
}
+
y = fixadd(y, dy);
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list