summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-02-12 16:17:40 +0000
committerManolo Gouy <Manolo>2016-02-12 16:17:40 +0000
commitbf7c25a1d72b28b6b19a1ac54492be539cb75552 (patch)
tree888b711d4cfad04483b553f170ef5ed933444b29
parentbc83464b642caad491c70e3b54677dd50f6324b2 (diff)
Add Fl_Shared_Image *Fl_Image_Surface::highres_image() to draw into high-resolution bitmap.
Also, change arguments of void Fl_Window::capture_titlebar_and_borders() from Fl_RGB_Image to F_Shared_Image so, in the future, scaled images having a drawing size distinct from a pixel size can be returned, to support high-resolution displays. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11159 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--FL/Fl_Window.H3
-rw-r--r--src/Fl_Paged_Device.cxx23
-rw-r--r--src/Fl_Window.cxx2
-rw-r--r--src/Fl_cocoa.mm15
-rw-r--r--src/Fl_win32.cxx24
-rw-r--r--src/Fl_x.cxx23
6 files changed, 50 insertions, 40 deletions
diff --git a/FL/Fl_Window.H b/FL/Fl_Window.H
index a97b371c4..dc8a1579a 100644
--- a/FL/Fl_Window.H
+++ b/FL/Fl_Window.H
@@ -35,6 +35,7 @@
class Fl_X;
class Fl_RGB_Image;
+class Fl_Shared_Image;
/**
@@ -97,7 +98,7 @@ class FL_EXPORT Fl_Window : public Fl_Group {
// cursor stuff
Fl_Cursor cursor_default;
// Captures the titlebar and borders of the window, if they exist.
- void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
+ void capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right);
protected:
/** Data supporting a non-rectangular window shape */
diff --git a/src/Fl_Paged_Device.cxx b/src/Fl_Paged_Device.cxx
index ee0939b4f..e0a0f1a1b 100644
--- a/src/Fl_Paged_Device.cxx
+++ b/src/Fl_Paged_Device.cxx
@@ -20,6 +20,7 @@
*/
#include <FL/Fl_Paged_Device.H>
+#include <FL/Fl_Shared_Image.H>
#include <FL/Fl.H>
#include <FL/fl_draw.H>
@@ -300,29 +301,25 @@ const Fl_Paged_Device::page_format Fl_Paged_Device::page_formats[NO_PAGE_FORMATS
void Fl_Paged_Device::draw_decorated_window(Fl_Window *win, int x_offset, int y_offset)
{
- Fl_RGB_Image *top, *left, *bottom, *right;
+ Fl_Shared_Image *top, *left, *bottom, *right;
win->capture_titlebar_and_borders(top, left, bottom, right);
int wsides = left ? left->w() : 0;
int toph = top ? top->h() : 0;
if (top) {
-#ifdef __APPLE__ // PORTME: platform paged device
- top->draw(x_offset, y_offset); // draw with transparency
-#else
- fl_draw_image(top->array, x_offset, y_offset, top->w(), top->h(), top->d());
-#endif // __APPLE__ // PORTME: platform paged device
- delete top;
+ top->draw(x_offset, y_offset);
+ top->release();
}
if (left) {
- fl_draw_image(left->array, x_offset, y_offset + toph, left->w(), left->h(), left->d());
- delete left;
+ left->draw(x_offset, y_offset);
+ left->release();
}
if (right) {
- fl_draw_image(right->array, x_offset + win->w() + wsides, y_offset + toph, right->w(), right->h(), right->d());
- delete right;
+ right->draw(x_offset, y_offset);
+ right->release();
}
if (bottom) {
- fl_draw_image(bottom->array, x_offset, y_offset + toph + win->h(), bottom->w(), bottom->h(), bottom->d());
- delete bottom;
+ bottom->draw(x_offset, y_offset);
+ bottom->release();
}
this->print_widget(win, x_offset + wsides, y_offset + toph);
}
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx
index 09f7bc9b9..12f3ef6dd 100644
--- a/src/Fl_Window.cxx
+++ b/src/Fl_Window.cxx
@@ -475,7 +475,7 @@ void Fl_Window::wait_for_expose() {
#if defined(FL_PORTING)
# pragma message "FL_PORTING: implement Fl_Window::capture_titlebar_and_borders"
-void Fl_Window::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right)
+void Fl_Window::capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right)
{
top = left = bottom = right = NULL;
}
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 30e32d780..8a951adeb 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -41,6 +41,7 @@ extern "C" {
#include <FL/Fl_Tooltip.H>
#include <FL/Fl_Printer.H>
#include <FL/Fl_Copy_Surface.H>
+#include <FL/Fl_Shared_Image.H>
#include "drivers/Quartz/Fl_Quartz_Graphics_Driver.h"
#include "drivers/Cocoa/Fl_Cocoa_Screen_Driver.h"
#include <stdio.h>
@@ -4400,7 +4401,7 @@ static void draw_layer_to_context(CALayer *layer, CGContextRef gc, int w, int h)
/* Returns images of the capture of the window title-bar.
On the Mac OS platform, left, bottom and right are returned NULL; top is returned with depth 4.
*/
-void Fl_Window::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right)
+void Fl_Window::capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right)
{
left = bottom = right = NULL;
int htop = decorated_h() - h();
@@ -4409,19 +4410,19 @@ void Fl_Window::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*&
uchar *rgba = new uchar[4 * w() * htop];
CGContextRef auxgc = CGBitmapContextCreate(rgba, w(), htop, 8, 4 * w(), cspace, kCGImageAlphaPremultipliedLast);
CGColorSpaceRelease(cspace);
- CGRect rect = CGRectMake(0, 0, w(), htop);
if (layer) {
draw_layer_to_context(layer, auxgc, w(), htop);
} else {
CGImageRef img = Fl_X::CGImage_from_window_rect(this, 0, -htop, w(), htop);
CGContextSaveGState(auxgc);
Fl_X::clip_to_rounded_corners(auxgc, w(), htop);
- CGContextDrawImage(auxgc, rect, img);
+ CGContextDrawImage(auxgc, CGRectMake(0, 0, w(), htop), img);
CGContextRestoreGState(auxgc);
CFRelease(img);
}
- top = new Fl_RGB_Image(rgba, w(), htop, 4);
- top->alloc_array = 1;
+ Fl_RGB_Image *toprgb = new Fl_RGB_Image(rgba, w(), htop, 4);
+ toprgb->alloc_array = 1;
+ top = Fl_Shared_Image::get(toprgb);
CGContextRelease(auxgc);
}
@@ -4472,12 +4473,12 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset)
fl_gc = NULL;
Fl::check();
// capture the window title bar with no title
- Fl_RGB_Image *top, *left, *bottom, *right;
+ Fl_Shared_Image *top, *left, *bottom, *right;
win->capture_titlebar_and_borders(top, left, bottom, right);
win->label(title); // put back the window title
this->set_current(); // back to the Fl_Paged_Device
top->draw(x_offset, y_offset); // print the title bar
- delete top;
+ top->release();
if (title) { // print the window title
const int skip = 65; // approx width of the zone of the 3 window control buttons
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 6cf154c16..0edf3dd53 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -30,6 +30,7 @@
#include <FL/Enumerations.H>
#include <FL/Fl_Tooltip.H>
#include <FL/Fl_Paged_Device.H>
+#include <FL/Fl_Shared_Image.H>
#include "flstring.h"
#include "Fl_Font.H"
#include <stdio.h>
@@ -2709,8 +2710,9 @@ int Fl_Window::decorated_h()
On the WIN32 platform, this function exploits a feature of fl_read_image() which, when called
with NULL first argument and when fl_gc is set to the screen device context, captures the window decoration.
*/
-void Fl_Window::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right)
+void Fl_Window::capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right)
{
+ Fl_RGB_Image *r_top, *r_left, *r_bottom, *r_right;
top = left = bottom = right = NULL;
if (!shown() || parent() || !border() || !visible()) return;
int wsides, hbottom, bt;
@@ -2730,19 +2732,23 @@ void Fl_Window::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*&
uchar *rgb;
if (htop) {
rgb = fl_read_image(NULL, r.left, r.top, ww, htop);
- top = new Fl_RGB_Image(rgb, ww, htop, 3);
- top->alloc_array = 1;
+ r_top = new Fl_RGB_Image(rgb, ww, htop, 3);
+ r_top->alloc_array = 1;
+ top = Fl_Shared_Image::get(r_top);
}
if (wsides) {
rgb = fl_read_image(NULL, r.left, r.top + htop, wsides, h());
- left = new Fl_RGB_Image(rgb, wsides, h(), 3);
- left->alloc_array = 1;
+ r_left = new Fl_RGB_Image(rgb, wsides, h(), 3);
+ r_left->alloc_array = 1;
+ left = Fl_Shared_Image::get(r_left);
rgb = fl_read_image(NULL, r.right - wsides, r.top + htop, wsides, h());
- right = new Fl_RGB_Image(rgb, wsides, h(), 3);
- right->alloc_array = 1;
+ r_right = new Fl_RGB_Image(rgb, wsides, h(), 3);
+ r_right->alloc_array = 1;
+ right = Fl_Shared_Image::get(r_right);
rgb = fl_read_image(NULL, r.left, r.bottom-hbottom, ww, hbottom);
- bottom = new Fl_RGB_Image(rgb, ww, hbottom, 3);
- bottom->alloc_array = 1;
+ r_bottom = new Fl_RGB_Image(rgb, ww, hbottom, 3);
+ r_bottom->alloc_array = 1;
+ bottom = Fl_Shared_Image::get(r_bottom);
}
ReleaseDC(NULL, fl_gc);
fl_window = save_win;
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index 98d4303d5..8409b893d 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -2981,8 +2981,9 @@ int Fl_Window::decorated_w()
On the X11 platform, this function exploits a feature of fl_read_image() which, when called
with negative 4th argument, captures the window decoration.
*/
-void Fl_Window::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left, Fl_RGB_Image*& bottom, Fl_RGB_Image*& right)
+void Fl_Window::capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right)
{
+ Fl_RGB_Image *r_top, *r_left, *r_bottom, *r_right;
top = left = bottom = right = NULL;
if (decorated_h() == h()) return;
Window from = fl_window;
@@ -3004,19 +3005,23 @@ void Fl_Window::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*&
uchar *rgb;
if (htop) {
rgb = fl_read_image(NULL, 0, 0, - (w() + 2 * wsides), htop);
- top = new Fl_RGB_Image(rgb, w() + 2 * wsides, htop, 3);
- top->alloc_array = 1;
+ r_top = new Fl_RGB_Image(rgb, w() + 2 * wsides, htop, 3);
+ r_top->alloc_array = 1;
+ top = Fl_Shared_Image::get(r_top);
}
if (wsides) {
rgb = fl_read_image(NULL, 0, htop, -wsides, h());
- left = new Fl_RGB_Image(rgb, wsides, h(), 3);
- left->alloc_array = 1;
+ r_left = new Fl_RGB_Image(rgb, wsides, h(), 3);
+ r_left->alloc_array = 1;
+ left = Fl_Shared_Image::get(r_left);
rgb = fl_read_image(NULL, w() + wsides, htop, -wsides, h());
- right = new Fl_RGB_Image(rgb, wsides, h(), 3);
- right->alloc_array = 1;
+ r_right = new Fl_RGB_Image(rgb, wsides, h(), 3);
+ r_right->alloc_array = 1;
+ right = Fl_Shared_Image::get(r_right);
rgb = fl_read_image(NULL, 0, htop + h(), -(w() + 2*wsides), hbottom);
- bottom = new Fl_RGB_Image(rgb, w() + 2*wsides, hbottom, 3);
- bottom->alloc_array = 1;
+ r_bottom = new Fl_RGB_Image(rgb, w() + 2*wsides, hbottom, 3);
+ r_bottom->alloc_array = 1;
+ bottom = Fl_Shared_Image::get(r_bottom);
}
fl_window = from;
previous->Fl_Surface_Device::set_current();