Author: manolo
Date: 2011-02-01 02:13:54 -0800 (Tue, 01 Feb 2011)
New Revision: 8349
Log:
fl_draw_image() on Mac OS and to a printer requires the image data to be kept
until the
page is finished. Thus, we now duplicate this data when the output is a
printer, so the
caller of the function does not have to take into account this Mac OS
specificity.
Modified:
branches/branch-1.3/FL/Fl_Paged_Device.H
branches/branch-1.3/src/Fl_Paged_Device.cxx
branches/branch-1.3/src/Fl_Quartz_Printer.mm
branches/branch-1.3/src/fl_draw_image_mac.cxx
Modified: branches/branch-1.3/FL/Fl_Paged_Device.H
===================================================================
--- branches/branch-1.3/FL/Fl_Paged_Device.H 2011-02-01 03:27:23 UTC (rev
8348)
+++ branches/branch-1.3/FL/Fl_Paged_Device.H 2011-02-01 10:13:54 UTC (rev
8349)
@@ -107,13 +107,6 @@
/** \brief width, height and name of all elements of the enum \ref
Page_Format.
*/
static const page_format page_formats[NO_PAGE_FORMATS];
-
-#ifdef __APPLE__
- struct chain_elt {
- const uchar *data;
- struct chain_elt *next;
- };
-#endif
private:
void traverse(Fl_Widget *widget); // finds subwindows of widget and prints
them
protected:
@@ -121,11 +114,6 @@
int x_offset;
/** \brief vertical offset to the origin of graphics coordinates */
int y_offset;
-#ifdef __APPLE__
- struct chain_elt *image_list_; // chained list of images used in this page
- void add_image(const uchar *data); // adds an image to the page image list
- void delete_image_list(); // deletes the page image list
-#endif
/** \brief The constructor */
Fl_Paged_Device() : Fl_Surface_Device(NULL) {class_name( class_id);};
/** \brief The destructor */
Modified: branches/branch-1.3/src/Fl_Paged_Device.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Paged_Device.cxx 2011-02-01 03:27:23 UTC (rev
8348)
+++ branches/branch-1.3/src/Fl_Paged_Device.cxx 2011-02-01 10:13:54 UTC (rev
8349)
@@ -141,35 +141,9 @@
save_front->show();
current->set_current();
fl_draw_image(image_data, delta_x, delta_y, w, h, 3);
-#ifdef __APPLE__
- add_image(image_data);
-#else
delete image_data;
-#endif
}
-
-#ifdef __APPLE__
-void Fl_Paged_Device::add_image(const uchar *data)
-{
- struct chain_elt *elt = (struct chain_elt *)calloc(sizeof(struct
chain_elt), 1);
- elt->data = data;
- if (image_list_) { elt->next = image_list_; }
- image_list_ = elt;
-}
-
-void Fl_Paged_Device::delete_image_list()
-{
- while(image_list_) {
- struct chain_elt *next = image_list_->next;
- if (image_list_->data) delete (uchar*) image_list_->data; // msvc6
compilation fix
- free(image_list_);
- image_list_ = next;
- }
-}
-#endif
-
-
/**
@brief Starts a print job.
*
Modified: branches/branch-1.3/src/Fl_Quartz_Printer.mm
===================================================================
--- branches/branch-1.3/src/Fl_Quartz_Printer.mm 2011-02-01 03:27:23 UTC
(rev 8348)
+++ branches/branch-1.3/src/Fl_Quartz_Printer.mm 2011-02-01 10:13:54 UTC
(rev 8349)
@@ -261,7 +261,6 @@
angle = 0;
scale_x = scale_y = 1;
win_scale_x = win_scale_y = 1;
- image_list_ = NULL;
if(orientation == kPMPortrait)
CGContextTranslateCTM(fl_gc, margins.left, margins.bottom + h);
else
@@ -284,7 +283,6 @@
CGContextRestoreGState(fl_gc);
CGContextRestoreGState(fl_gc);
OSStatus status = PMSessionEndPageNoDialog(printSession);
- delete_image_list();
gc = NULL;
return status != noErr;
}
Modified: branches/branch-1.3/src/fl_draw_image_mac.cxx
===================================================================
--- branches/branch-1.3/src/fl_draw_image_mac.cxx 2011-02-01 03:27:23 UTC
(rev 8348)
+++ branches/branch-1.3/src/fl_draw_image_mac.cxx 2011-02-01 10:13:54 UTC
(rev 8349)
@@ -30,6 +30,7 @@
#include <config.h>
#include <FL/Fl.H>
#include <FL/fl_draw.H>
+#include <FL/Fl_Printer.H>
#include <FL/x.H>
#define MAXBUFFER 0x40000 // 256k
@@ -39,7 +40,7 @@
delete[] (uchar *)data;
}
-/**
+/*
* draw an image based on the input parameters
*
* buf: image source data
@@ -63,10 +64,14 @@
const void *array = buf;
uchar *tmpBuf = 0;
- if (cb) {
+ if (cb || Fl_Surface_Device::surface()->class_name() ==
Fl_Printer::class_id) {
tmpBuf = new uchar[ H*W*delta ];
- for (int i=0; i<H; i++) {
- cb(userdata, 0, i, W, tmpBuf+i*W*delta);
+ if (cb) {
+ for (int i=0; i<H; i++) {
+ cb(userdata, 0, i, W, tmpBuf+i*W*delta);
+ }
+ } else {
+ memcpy(tmpBuf, buf, H*W*delta);
}
array = (void*)tmpBuf;
linedelta = W*delta;
@@ -86,7 +91,7 @@
size_t size
);
#endif
- CGDataProviderReleaseDataCallback releaseCB = ( cb ? dataReleaseCB : NULL);
+ CGDataProviderReleaseDataCallback releaseCB = ( tmpBuf ? dataReleaseCB :
NULL);
CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array,
linedelta*H, releaseCB);
CGImageRef img = CGImageCreate( W, H, 8, 8*delta, linedelta,
//lut,
delta&1?kCGImageAlphaNone:kCGImageAlphaNoneSkipLast,
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit