+void BitmapOutputDev::dbg_newdata(char*newdata)
+{
+ if(0) {
+ char filename1[80];
+ char filename2[80];
+ char filename3[80];
+ sprintf(filename1, "state%03dboolbitmap_after%s.png", dbg_btm_counter, newdata);
+ sprintf(filename2, "state%03dbooltext_after%s.png", dbg_btm_counter, newdata);
+ sprintf(filename3, "state%03dbitmap_after%s.png", dbg_btm_counter, newdata);
+ msg("<verbose> %s %s %s", filename1, filename2, filename3);
+ writeAlpha(stalepolybitmap, filename1);
+ writeAlpha(booltextbitmap, filename2);
+ writeBitmap(rgbdev->getBitmap(), filename3);
+ }
+ dbg_btm_counter++;
+}
+
+GBool BitmapOutputDev::checkNewText(int x1, int y1, int x2, int y2)
+{
+ /* 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);
+
+ GBool ret = false;
+ if(intersection(booltextbitmap, stalepolybitmap, x1,y1,x2,y2)) {
+ if(layerstate==STATE_PARALLEL) {
+ /* the new text is above the bitmap. So record that fact. */
+ msg("<verbose> Text is above current bitmap/polygon data");
+ layerstate=STATE_TEXT_IS_ABOVE;
+ update_bitmap(staletextbitmap, booltextbitmap, x1, y1, x2, y2, 0);
+ } else if(layerstate==STATE_BITMAP_IS_ABOVE) {
+ /* there's a bitmap above the (old) text. So we need
+ to flush out that text, and record that the *new*
+ text is now *above* the bitmap
+ */
+ msg("<verbose> Text is above current bitmap/polygon data (which is above some other text)");
+ flushText();
+ layerstate=STATE_TEXT_IS_ABOVE;
+
+ clearBoolTextDev();
+ /* re-apply the update (which we would otherwise lose) */
+ update_bitmap(staletextbitmap, booltextbitmap, x1, y1, x2, y2, 1);
+ ret = true;
+ } else {
+ /* we already know that the current text section is
+ above the current bitmap section- now just new
+ bitmap data *and* new text data was drawn, and
+ *again* it's above the current bitmap. */
+ msg("<verbose> Text is still above current bitmap/polygon data");
+ update_bitmap(staletextbitmap, booltextbitmap, x1, y1, x2, y2, 0);
+ }
+ } else {
+ update_bitmap(staletextbitmap, booltextbitmap, x1, y1, x2, y2, 0);
+ }
+
+ /* clear the thing we just drew from our temporary drawing bitmap */
+ clearBooleanBitmap(booltextbitmap, x1, y1, x2, y2);
+
+ return ret;
+}
+GBool BitmapOutputDev::checkNewBitmap(int x1, int y1, int x2, int y2)
+{
+ /* similar to checkNewText() above, only in reverse */
+ msg("<trace> Testing new graphics data against current text data, state=%s, counter=%d\n", STATE_NAME[layerstate], dbg_btm_counter);
+
+ GBool ret = false;
+ if(intersection(boolpolybitmap, staletextbitmap, x1,y1,x2,y2)) {
+ if(layerstate==STATE_PARALLEL) {
+ msg("<verbose> Bitmap is above current text data");
+ layerstate=STATE_BITMAP_IS_ABOVE;
+ update_bitmap(stalepolybitmap, boolpolybitmap, x1, y1, x2, y2, 0);
+ } else if(layerstate==STATE_TEXT_IS_ABOVE) {
+ msg("<verbose> Bitmap is above current text data (which is above some bitmap)");
+ flushBitmap();
+ layerstate=STATE_BITMAP_IS_ABOVE;
+ clearBoolPolyDev();
+ update_bitmap(stalepolybitmap, boolpolybitmap, x1, y1, x2, y2, 1);
+ ret = true;
+ } else {
+ msg("<verbose> Bitmap is still above current text data");
+ update_bitmap(stalepolybitmap, boolpolybitmap, x1, y1, x2, y2, 0);