- /* called once some new text was drawn on booltextdev, and
- before the same thing is drawn on gfxdev */
-
- msg("<trace> Testing new text data against current bitmap data, state=%s, counter=%d\n", STATE_NAME[layerstate], dbg_btm_counter);
+ if(!(*x1|*y1|*x2|*y2)) {
+ // undefined bbox
+ *x1 = *y1 = 0;
+ *x2 = width;
+ *y2 = height;
+ return gTrue;
+ }
+ if(*x2<=*x1) return gFalse;
+ if(*x2<0) return gFalse;
+ if(*x1<0) *x1 = 0;
+ if(*x1>=width) return gFalse;
+ if(*x2>width) *x2=width;
+
+ if(*y2<=*y1) return gFalse;
+ if(*y2<0) return gFalse;
+ if(*y1<0) *y1 = 0;
+ if(*y1>=height) return gFalse;
+ if(*y2>height) *y2=height;
+ return gTrue;
+}
+
+static void update_bitmap(SplashBitmap*bitmap, SplashBitmap*update, int x1, int y1, int x2, int y2, char overwrite)
+{
+ assert(bitmap->getMode()==splashModeMono1);
+ assert(update->getMode()==splashModeMono1);
+
+ int width8 = (bitmap->getWidth()+7)/8;
+ assert(width8 == bitmap->getRowSize());
+ assert(width8 == update->getRowSize());
+ int height = bitmap->getHeight();
+ assert(height == update->getHeight());
+
+ if(!fixBBox(&x1, &y1, &x2, &y2, bitmap->getWidth(), bitmap->getHeight()))
+ return;
+
+ Guchar*b = bitmap->getDataPtr() + y1*width8 + x1/8;
+ Guchar*u = update->getDataPtr() + y1*width8 + x1/8;
+ int yspan = y2-y1;
+ int xspan = (x2+7)/8 - x1/8;
+ int size = (y2-y1)*width8;
+
+ if(overwrite) {
+ int y;
+ for(y=0;y<yspan;y++) {
+ memcpy(b, u, xspan);
+ b += width8;
+ u += width8;
+ }
+ } else {
+ if(((ptroff_t)b&7)==((ptroff_t)u&7)) {
+ int x,y;
+ for(y=0;y<yspan;y++) {
+ Guchar*e1 = b+xspan-8;
+ Guchar*e2 = b+xspan;
+ while(((ptroff_t)b&7) && b<e1) {
+ *b |= *u;
+ b++;u++;
+ }
+ while(b<e1) {
+ *(long long*)b |= *(long long*)u;
+ b+=8;u+=8;
+ }
+ while(b<e2) {
+ *b |= *u;
+ b++;u++;
+ }
+ b += width8-xspan;
+ u += width8-xspan;
+ }
+ } else {
+ int x,y;
+ for(y=0;y<yspan;y++) {
+ for(x=0;x<xspan;x++) {
+ b[x] |= u[x];
+ }
+ b += width8;
+ u += width8;
+ }
+ }
+ }
+}
+
+static void clearBooleanBitmap(SplashBitmap*btm, int x1, int y1, int x2, int y2)
+{
+ if(!fixBBox(&x1, &y1, &x2, &y2, btm->getWidth(), btm->getHeight()))
+ return;