mirror of https://github.com/fltk/fltk
Simpler code to support drawing to high-resolution Fl_Image_Surface object.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11162 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
df0b1dcb07
commit
8deac1e6ba
|
@ -32,25 +32,6 @@
|
|||
#else
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
class Fl_Quartz_Scaled_Graphics_Driver_ : public Fl_Quartz_Graphics_Driver {
|
||||
protected:
|
||||
virtual void push_clip(int x, int y, int w, int h) {
|
||||
push_no_clip();
|
||||
CGContextClipToRect(fl_gc, CGRectMake(x, y, w, h));
|
||||
}
|
||||
virtual void push_no_clip() {
|
||||
CGContextRestoreGState(fl_gc);
|
||||
CGContextSaveGState(fl_gc);
|
||||
CGContextTranslateCTM(fl_gc, 0, CGBitmapContextGetHeight(fl_gc)/2);
|
||||
CGContextScaleCTM(fl_gc, 1.0f, -1.0f);
|
||||
}
|
||||
virtual void pop_clip() {
|
||||
push_no_clip();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
const char *Fl_Image_Surface::class_id = "Fl_Image_Surface";
|
||||
|
||||
/** Constructor with optional high resolution.
|
||||
|
@ -68,8 +49,6 @@ Fl_Image_Surface::Fl_Image_Surface(int w, int h, int highres) : Fl_Surface_Devic
|
|||
offscreen = fl_create_offscreen(highres ? 2*w : w, highres ? 2*h : h);
|
||||
helper = new Fl_Quartz_Flipped_Surface_(width, height);
|
||||
if (highres) {
|
||||
delete helper->driver();
|
||||
helper->driver(new Fl_Quartz_Scaled_Graphics_Driver_);
|
||||
CGContextScaleCTM(offscreen, 2, 2);
|
||||
}
|
||||
driver(helper->driver());
|
||||
|
|
|
@ -3310,10 +3310,14 @@ extern void fl_quartz_restore_line_style_();
|
|||
void Fl_X::q_fill_context() {
|
||||
if (!fl_gc) return;
|
||||
if ( ! fl_window) { // a bitmap context
|
||||
size_t hgt = CGBitmapContextGetHeight(fl_gc);
|
||||
CGFloat hgt = CGBitmapContextGetHeight(fl_gc);
|
||||
CGAffineTransform at = CGContextGetCTM(fl_gc);
|
||||
if (at.a != 1 && at.a == at.d && at.b == 0 && at.c == 0) { // proportional scaling, no rotation
|
||||
hgt /= at.a;
|
||||
}
|
||||
CGContextTranslateCTM(fl_gc, 0.5, hgt-0.5f);
|
||||
CGContextScaleCTM(fl_gc, 1.0f, -1.0f); // now 0,0 is top-left point of the context
|
||||
}
|
||||
}
|
||||
fl_color(fl_graphics_driver->color());
|
||||
fl_quartz_restore_line_style_();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue