It had regressed in performance compared to 1.3. This brings it back
up to the same speed.
void ModifiablePixelBuffer::fillRect(const Rect& r, Pixel pix)
{
int stride;
- U8 *buf, pixbuf[4];
+ U8 *buf;
int w, h, b;
- buf = getBufferRW(r, &stride);
w = r.width();
h = r.height();
b = format.bpp/8;
- format.bufferFromPixel(pixbuf, pix);
+ if (h == 0)
+ return;
+
+ buf = getBufferRW(r, &stride);
- while (h--) {
- int w_ = w;
- while (w_--) {
+ if (b == 1) {
+ while (h--) {
+ memset(buf, pix, w);
+ buf += stride * b;
+ }
+ } else {
+ U8 pixbuf[4], *start;
+ int w1;
+
+ start = buf;
+
+ format.bufferFromPixel(pixbuf, pix);
+
+ w1 = w;
+ while (w1--) {
memcpy(buf, pixbuf, b);
buf += b;
}
buf += (stride - w) * b;
+ h--;
+
+ while (h--) {
+ memcpy(buf, start, w * b);
+ buf += stride * b;
+ }
}
commitBufferRW(r);