[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-224-g10b0049 |
Date: |
Sat, 09 Apr 2011 07:44:05 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".
The branch, master has been updated
via 10b00498541cf75294e7e7cf3258b6865e8b009c (commit)
from 669164629ae6b9bf1aaf1c2b7af81cd8db1f1490 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=10b00498541cf75294e7e7cf3258b6865e8b009c
commit 10b00498541cf75294e7e7cf3258b6865e8b009c
Author: Benjamin Wolsey <address@hidden>
Date: Sat Apr 9 09:18:30 2011 +0200
Improve floodFill speed considerably.
For large fills this reduces the time spend by about 60% by avoiding
the expensive pixelAt() function and using iterators instead.
diff --git a/libcore/asobj/flash/display/BitmapData_as.cpp
b/libcore/asobj/flash/display/BitmapData_as.cpp
index d3dd6f0..97c27ca 100644
--- a/libcore/asobj/flash/display/BitmapData_as.cpp
+++ b/libcore/asobj/flash/display/BitmapData_as.cpp
@@ -212,6 +212,22 @@ private:
};
+/// Index iterators by x and y position
+//
+/// This is a helper for floodFill to avoid using the expensive
+/// pixelAt() many times.
+struct PixelIndexer
+{
+ PixelIndexer(size_t xpos, size_t ypos, BitmapData_as::iterator p)
+ :
+ x(xpos),
+ y(ypos),
+ pix(p)
+ {}
+ size_t x;
+ size_t y;
+ BitmapData_as::iterator pix;
+};
} // anonymous namespace
@@ -345,18 +361,19 @@ BitmapData_as::floodFill(size_t startx, size_t starty,
boost::uint32_t old,
if (!transparent()) fill |= 0xff000000;
if (old == fill) return;
- std::queue<std::pair<size_t, size_t> > pixelQueue;
- pixelQueue.push(std::make_pair(startx, starty));
+ std::queue<PixelIndexer> pixelQueue;
+ pixelQueue.push(
+ PixelIndexer(startx, starty, pixelAt(*this, startx, starty)));
while (!pixelQueue.empty()) {
- const std::pair<size_t, size_t>& p = pixelQueue.front();
- const size_t x = p.first;
- const size_t y = p.second;
+ const PixelIndexer& p = pixelQueue.front();
+ const size_t x = p.x;
+ const size_t y = p.y;
+ iterator pix = p.pix;
pixelQueue.pop();
- iterator pix = pixelAt(*this, x, y);
assert(pix != end());
if (*pix != old) continue;
@@ -374,10 +391,12 @@ BitmapData_as::floodFill(size_t startx, size_t starty,
boost::uint32_t old,
// Add north pixels
if (y > 0) {
+ iterator north(pix - width());
+ iterator northend(north + edone);
const size_t ny = y - 1;
- for (size_t nx = x; nx != (x + edone); ++nx) {
- if (*pixelAt(*this, nx, ny) == old) {
- pixelQueue.push(std::make_pair(nx, ny));
+ for (size_t nx = x; nx != (x + edone); ++nx, ++north) {
+ if (*north == old) {
+ pixelQueue.push(PixelIndexer(nx, ny, north));
}
}
}
@@ -395,10 +414,12 @@ BitmapData_as::floodFill(size_t startx, size_t starty,
boost::uint32_t old,
// Add south pixels
if (y + 1 < height()) {
+ iterator south(pix + width());
+ iterator southend(south - wdone);
const size_t sy = y + 1;
- for (size_t sx = x; sx != x - wdone; --sx) {
- if (*pixelAt(*this, sx, sy) == old) {
- pixelQueue.push(std::make_pair(sx, sy));
+ for (size_t sx = x; sx != x - wdone; --sx, --south) {
+ if (*south == old) {
+ pixelQueue.push(PixelIndexer(sx, sy, south));
}
}
}
-----------------------------------------------------------------------
Summary of changes:
libcore/asobj/flash/display/BitmapData_as.cpp | 45 ++++++++++++++++++-------
1 files changed, 33 insertions(+), 12 deletions(-)
hooks/post-receive
--
Gnash
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-224-g10b0049,
Benjamin Wolsey <=