|
Author: fabien
Date: 2007-04-03 12:21:47 -0400 (Tue, 03 Apr 2007)
New Revision: 5754
Log:
+ Surface / Offscreen impl. first increment
will probably not compile yet ...
Other minor updates to project files and from my recent trunk patch
Added:
branches/fctrunk/fltk/Offscreen.h
branches/fctrunk/fltk/Surface.h
branches/fctrunk/src/Offscreen.cxx
branches/fctrunk/src/Surface.cxx
Modified:
branches/fctrunk/Makefile
branches/fctrunk/TODO
branches/fctrunk/ide/visualc/fltk.lib.dsp
branches/fctrunk/ide/visualc/fltk_images.lib.dsp
branches/fctrunk/src/AnsiWidget.cxx
branches/fctrunk/src/GSave.cxx
Modified: branches/fctrunk/Makefile
===================================================================
--- branches/fctrunk/Makefile 2007-04-03 06:30:16 UTC (rev 5753)
+++ branches/fctrunk/Makefile 2007-04-03 16:21:47 UTC (rev 5754)
@@ -95,7 +95,7 @@
images/*.cxx fluid/*.cxx fluid/*.h test/*.cxx test/*.h Makefile */Makefile
dos2unix:
dos2unix fltk/*.h src/*.cxx src/win32/*.cxx src/*.c images/*.cxx \
- fluid/*.cxx fluid/*.h fluid/*.fl test/*.cxx test/*.h fltk/compat/FL/*.H README*
+ fluid/*.cxx fluid/*.h fluid/*.fl test/*.cxx test/*.h fltk/compat/FL/*.H TODO README*
chmod -x fltk/*.h src/*.cxx src/win32/*.cxx src/*.c images/*.cxx \
fluid/*.cxx fluid/*.h fluid/*.fl test/*.cxx test/*.h
#
Modified: branches/fctrunk/TODO
===================================================================
--- branches/fctrunk/TODO 2007-04-03 06:30:16 UTC (rev 5753)
+++ branches/fctrunk/TODO 2007-04-03 16:21:47 UTC (rev 5754)
@@ -1,11 +1,9 @@
FLTK 2.0 TODO
--------------
+-------------
+ - Check & fix features Broken All Platform
+ (Surface,Image, Image Manip, Fluid widget symbols handling, ...)
+ - Check & fix features Broken Mac Platform Only
- Fix configure script and makefiles.
- - fltk::FloatInput/IntInput doesn't return 1 from handle
- for non-number characters; this means that those
- characters go to other widgets instead.
- WAS: this is done on purpose. You can subclass and return
- 1 if you want.
- fltk::ValueInput buttons don't draw inactive.
- Inactive widgets get engraved label type???
- Selection in fltk::Input/InputBrowser is not drawn
@@ -18,5 +16,4 @@
non-default values, but it may be broken.
- Need to fix labels/etc. of widget panel.
- Don't move checkers so slow.
- - strlcat/strlcpy/etc.
Added: branches/fctrunk/fltk/Offscreen.h
===================================================================
--- branches/fctrunk/fltk/Offscreen.h (rev 0)
+++ branches/fctrunk/fltk/Offscreen.h 2007-04-03 16:21:47 UTC (rev 5754)
@@ -0,0 +1,93 @@
+// "$Id: Offscreen.h"
+//
+// Copyright 1998-2007 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems to "fltk-bugs@fltk.org".
+
+/*! \class fltk::Offscreen
+
+This is an offset drawing class surfaces
+This class will permit to use alpha blending in a 'best effort' way.
+It means that when no alpha blending support is available, simple copy
+operations will be implemented by default
+*/
+
+#if !defined(FLTK_OFFSCREEN_H)
+#define FLTK_OFFSCREEN_H
+
+#include <fltk/Surface.h>
+
+class Window;
+
+namespace fltk {
+
+class FL_API Offscreen : public Surface {
+public:
+ // ---------- Define device dependent type and data --------------------------
+#if defined(WIN32)
+ typedef HBITMAP GraphicData;
+private:
+ int num_saved_dc_; // for cleaning up our offscreen created dc
+
+#elif defined(__APPLE_QUARTZ__) || defined(__APPLE_QD__)
+ typedef GWorldPtr GraphicData;
+
+#else
+ typedef void * GraphicData;
+#endif
+
+public:
+ // fltk Offscreen Surface Construction / Destruction
+ Offscreen(const Rectangle& dim) : Surface(dim) {create();}
+ Offscreen(int w, int h): Surface(Rectangle(w, h)) {create();}
+ Offscreen(int x, int y, int w, int h) : Surface(Rectangle(x,y, w, h)) {create();}
+ Offscreen(GraphicData hgd); // do not create offscreen use this one instead, do not
+ virtual ~Offscreen();
+
+ // Offscreen device dependent overriden method impl. :
+
+ //! Select the offscreen surface for drawing & save previous graphical context
+ bool begin();
+ //! Restore previous graphical context
+ bool end();
+
+ //! Copies the device content to fl gc, return true if done successfully
+ bool copy(int x,int y,int w,int h,int srcx,int srcy);
+ //! Copies the device content to fl gc with alpha if available, return true if done successfully
+ bool copy_with_alpha(int x,int y,int w,int h,int srcx,int srcy);
+
+protected:
+ bool can_do_alpha_blending();
+
+private:
+ void create();
+
+ GraphicData graphic_data_;
+ bool must_cleanup_;
+
+ GSave* context_save_; // for proper begin() / end() context save / restore
+
+};
+
+} // End of fltk namespace
+
+#endif // !defined(FLTK_OFFSCREEN_H)
+
+//
+// End of "$Id"
+//
Added: branches/fctrunk/fltk/Surface.h
===================================================================
--- branches/fctrunk/fltk/Surface.h (rev 0)
+++ branches/fctrunk/fltk/Surface.h 2007-04-03 16:21:47 UTC (rev 5754)
@@ -0,0 +1,76 @@
+// "$Id: Surface.h"
+//
+// Copyright 1998-2007 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems to "fltk-bugs@fltk.org".
+
+/*! \class fltk::Surface
+
+This is generic base class for the Window, Offscreen, Printing 2D Graphic
+surfaces
+This class will permit to use alpha blending in a 'best effort' way.
+It means that when no alpha blending support is available, simple copy
+operations will be implemented by default
+
+*/
+
+#if !defined(FLTK_SURFACE_H)
+#define FLTK_SURFACE_H
+
+#include <fltk/FL_API.h>
+#include <fltk/Rectangle.h>
+
+namespace fltk {
+
+class FL_API Surface
+{
+public:
+ // Construction / Destruction of a Surface
+ //! Creates a surface and makes it the current one
+ Surface(const Rectangle& dim) : dim_(dim) {}
+ Surface(int w, int h) : dim_(Rectangle(w,h)) {}
+ Surface(int x, int y, int w, int h) : dim_(Rectangle(x,y,w,h)) {}
+ Surface() {} // for handling device context with no context creation (using existing context)
+
+ virtual ~Surface();
+
+ // Virtual (device dependent) API
+
+ //! select the surface for drawing save previous graphical context, return true if successful
+ virtual bool begin() {return true;}
+ //! restore previous graphical context, return true if successful
+ virtual bool end() {return true;}
+
+ // copies the device content to fl gc
+ virtual bool copy(int x,int y,int w,int h,int srcx,int srcy)=0;
+ // copies the device content to fl gc
+ virtual bool copy_with_alpha(int x,int y,int w,int h,int srcx,int srcy);
+
+protected:
+ // overrides this to true if device can handle alpha:
+ virtual bool can_do_alpha_blending();
+
+ Rectangle dim_;
+};
+
+} // fltk namespace
+
+#endif // !defined(FLTK_SURFACE_H)
+//
+// End of "$Id"
+//
Property changes on: branches/fctrunk/fltk/Surface.h
___________________________________________________________________
Name: svn:executable
+ *
Modified: branches/fctrunk/ide/visualc/fltk.lib.dsp
===================================================================
(Binary files differ)
Modified: branches/fctrunk/ide/visualc/fltk_images.lib.dsp
===================================================================
(Binary files differ)
Modified: branches/fctrunk/src/AnsiWidget.cxx
===================================================================
--- branches/fctrunk/src/AnsiWidget.cxx 2007-04-03 06:30:16 UTC (rev 5753)
+++ branches/fctrunk/src/AnsiWidget.cxx 2007-04-03 16:21:47 UTC (rev 5754)
@@ -35,6 +35,7 @@
#include <fltk/Font.h>
#include <fltk/Rectangle.h>
#include <fltk/Group.h>
+#include <fltk/ask.h>
#if defined(WIN32)
#include <fltk/win32.h>
@@ -105,7 +106,7 @@
/*! Standard constructor for a widget.
*/
-AnsiWidget::AnsiWidget(int x, int y, int w, int h, float defsize) :
+AnsiWidget::AnsiWidget(int x, int y, int w, int h, int defsize) :
Widget(x, y, w, h, 0) {
labelsize(defsize);
init();
@@ -327,8 +328,9 @@
begin_offscreen();
// needs to return a -ve number to distiguish from basic 16 color values
// unpacked in later calls to ansiToFltk()
- return - (int) ::GetPixel(fl_bitmap_dc, x, y);
-
+ return -::GetPixel(fl_bitmap_dc, x, y);
+#elif defined(__APPLE__)
+ // TODO !
#else
XImage *image =
XGetImage(fltk::xdisplay, xwindow, x, y, 1, 1, AllPlanes, ZPixmap);
@@ -337,20 +339,14 @@
XDestroyImage(image);
return -color;
}
- return 0;
#endif
+ return 0;
}
/*! create audible beep sound
*/
void AnsiWidget::beep() const {
-#ifdef WIN32
- MessageBeep(MB_ICONASTERISK);
-#elif defined(__APPLE__)
- SysBeep(30);
-#else
- XBell(fltk::xdisplay, 100);
-#endif
+ fltk::beep(fltk::BEEP_MESSAGE);
}
/*! Returns the width in pixels using the current font setting
@@ -632,12 +628,12 @@
setcolor(labelcolor());
fillrect(Rectangle(curX, curY, cx, fontHeight));
setcolor(color());
- drawtext((const char*)p, numChars, (float) curX, (float) curY+ascent);
+ drawtext((const char*)p, numChars, curX, curY+ascent);
} else {
setcolor(color());
fillrect(Rectangle(curX, curY, cx, fontHeight));
setcolor(labelcolor());
- drawtext((const char*)p, numChars, (float) curX, (float) curY+ascent);
+ drawtext((const char*)p, numChars, curX, curY+ascent);
}
if (underline) {
Modified: branches/fctrunk/src/GSave.cxx
===================================================================
--- branches/fctrunk/src/GSave.cxx 2007-04-03 06:30:16 UTC (rev 5753)
+++ branches/fctrunk/src/GSave.cxx 2007-04-03 16:21:47 UTC (rev 5754)
@@ -88,7 +88,7 @@
if (data[0]) draw_into((XWindow)(data[0]), fl_clip_w, fl_clip_h);
#elif defined(_WIN32)
dc = (HDC)(data[0]);
- DeleteDC(fl_bitmap_dc);
+ if (fl_bitmap_dc) DeleteDC(fl_bitmap_dc);
fl_bitmap_dc = (HDC)(data[1]);
#elif defined(__APPLE__)
quartz_window = (WindowPtr)data[0];
Added: branches/fctrunk/src/Offscreen.cxx
===================================================================
--- branches/fctrunk/src/Offscreen.cxx (rev 0)
+++ branches/fctrunk/src/Offscreen.cxx 2007-04-03 16:21:47 UTC (rev 5754)
@@ -0,0 +1,333 @@
+//
+// "$Id: Fl_Double_Window.cxx 5679 2007-02-08 20:50:01Z mike $"
+//
+// Double-buffered window code for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2007 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+#include <config.h>
+#include <FL/Fl.H>
+#include <FL/x.H>
+//#include <FL/fl_draw.H>
+#include <fltk/Offscreen.h>
+
+// off-screen pixmaps: create, destroy, draw into, copy to window
+using namespace fltk;
+
+// Construction / Destruction
+Offscreen::Offscreen(GraphicData hgd): Surface() {
+ must_cleanup_ = false;
+}
+
+#ifdef WIN32
+extern HDC fltk::dc;
+
+Offscreen::~Offscreen() {
+ if (must_cleanup_ && this->graphic_data_) {
+ DeleteObject(this->graphic_data_);
+ }
+}
+
+void Offscreen::create() {
+ graphic_data_ = CreateCompatibleBitmap(fltk::dc, dim_.w(), dim_.h());
+ must_cleanup_ = true;
+}
+
+
+// Code used to switch output to an off-screen window. See macros in
+// win32.H which save the old state in local variables.
+
+typedef struct { BYTE a; BYTE b; BYTE c; BYTE d; } FL_BLENDFUNCTION;
+typedef BOOL (WINAPI* fl_alpha_blend_func)
+(HDC,int,int,int,int,HDC,int,int,int,int,FL_BLENDFUNCTION);
+static fl_alpha_blend_func fl_alpha_blend = NULL;
+static FL_BLENDFUNCTION blendfunc = { 0, 0, 255, 1};
+
+/*
+* This function checks if the version of MSWindows that we
+* curently run on supports alpha blending for bitmap transfers
+* and finds the required function if so.
+*/
+bool Offscreen::can_do_alpha_blending() {
+ static bool been_here = false;
+ static bool can_do = false;
+
+ if (been_here) been_here = true; else return can_do;
+
+ // load the library that implements alpha blending
+ HMODULE hMod = LoadLibrary("MSIMG32.DLL");
+ // give up if that doesn't exist (Win95?)
+ if (!hMod) return false;
+ // now find the blending function inside that dll
+ fl_alpha_blend = (fl_alpha_blend_func)GetProcAddress(hMod, "AlphaBlend");
+ // give up if we can't find it (Win95)
+ if (!fl_alpha_blend) return false;
+ // we have the call, but does our display support alpha blending?
+ HDC dc = 0L;//fltk::dc;
+ // get the current or the desktop's device context
+ if (!dc) dc = GetDC(0L);
+ if (!dc) return false;
+ // check the device capabilities flags. However GetDeviceCaps
+ // does not return anything useful, so we have to do it manually:
+
+ HBITMAP bm = CreateCompatibleBitmap(dc, 1, 1);
+ HDC new_gc = CreateCompatibleDC(dc);
+ int save = SaveDC(new_gc);
+ SelectObject(new_gc, bm);
+ COLORREF set = SetPixel(new_gc, 0, 0, 0x01010101);
+ BOOL alpha_ok = fl_alpha_blend(dc, 0, 0, 1, 1, new_gc, 0, 0, 1, 1, blendfunc);
+ RestoreDC(new_gc, save);
+ DeleteDC(new_gc);
+ DeleteObject(bm);
+
+ if (!fltk::dc) ReleaseDC(0L, dc);
+ if (alpha_ok) can_do = true;
+ return can_do;
+}
+
+static HDC fl_makeDC(Offscreen::GraphicData graphical_data) {
+ HDC new_gc = CreateCompatibleDC(fltk::dc);
+ SetTextAlign(new_gc, TA_BASELINE|TA_LEFT);
+ SetBkMode(new_gc, TRANSPARENT);
+
+ // do we need this in fltk 2 ? :
+ //#if USE_COLORMAP
+ // if (fl_palette) SelectPalette(new_gc, fl_palette, FALSE);
+ //#endif
+ SelectObject(new_gc, graphical_data);
+ return new_gc;
+}
+
+
+bool Offscreen::begin() {
+ context_save_ = new GSave(); // push matrix, clip, save context handles (like dc)
+ fltk::dc=fl_makeDC(graphic_data_);
+ num_saved_dc_ = SaveDC(fltk::dc);
+ return true;
+}
+
+bool Offscreen::end() {
+ RestoreDC(fltk::dc, num_saved_dc_);
+ DeleteDC(fltk::dc);
+
+ delete context_save_; // restore prev dc, clip, matrix & context
+ context_save_ = 0;
+
+ return true;
+}
+
+bool Offscreen::copy(int x,int y,int w,int h,int srcx,int srcy) {
+ if (!this->graphic_data_) return false;
+
+ HDC new_gc = CreateCompatibleDC(fltk::dc);
+ int save = SaveDC(new_gc);
+ SelectObject(new_gc, (HBITMAP) this->graphic_data_);
+ BitBlt(fltk::dc, x, y, w, h, new_gc, srcx, srcy, SRCCOPY);
+ RestoreDC(new_gc, save);
+ DeleteDC(new_gc);
+ return true;
+}
+
+bool Offscreen::copy_with_alpha(int x, int y, int w, int h, int srcx, int srcy) {
+ if (!this->graphic_data_) return false;
+
+ HDC new_gc = CreateCompatibleDC(fltk::dc);
+ int save = SaveDC(new_gc);
+ SelectObject(new_gc, this->graphic_data_);
+ BOOL alpha_ok = 0;
+ // first try to alpha blend
+ if (can_do_alpha_blending())
+ alpha_ok = fl_alpha_blend(fltk::dc, x, y, w, h, new_gc, srcx, srcy, w, h, blendfunc);
+ // if that failed (it shouldn,t), still copy the bitmap over, but now alpha is 1
+ if (!alpha_ok)
+ BitBlt(fltk::dc, x, y, w, h, new_gc, srcx, srcy, SRCCOPY);
+ RestoreDC(new_gc, save);
+ DeleteDC(new_gc);
+ return true;
+}
+// end if defined(WIN32)
+#elif defined(__APPLE_QD__)
+
+bool Offscreen::can_do_alpha_blending() {return false;}
+
+void Offscreen::create() {
+ GraphicData gw;
+ Rect bounds;
+ bounds.left=0; bounds.right=dim_.w(); bounds.top=0; bounds.bottom=dim_.h;
+ QDErr err = NewGWorld(&gw, 0, &bounds, 0L, 0L, 0); // 'useTempMem' should not be used (says the Carbon port manual)
+ if ( err == -108 )
+ { }
+ // fl_message( "The application memory is low. Please increase the initial memory assignment.\n" );
+ if (err!=noErr || gw==0L) return 0L;
+}
+
+void Offscreen::copy(int x,int y,int w,int h, int srcx,int srcy) {
+ Rect src;
+ if ( !graphic_data_ ) return;
+ src.top = srcy; src.left = srcx; src.bottom = srcy+h; src.right = srcx+w;
+ Rect dst;
+ GrafPtr dstPort; GetPort(&dstPort);
+ dst.top = y; dst.left = x; dst.bottom = y+h; dst.right = x+w;
+ RGBColor rgb, oldbg, oldfg;
+ GetForeColor(&oldfg);
+ GetBackColor(&oldbg);
+ rgb.red = 0xffff; rgb.green = 0xffff; rgb.blue = 0xffff;
+ RGBBackColor( &rgb );
+ rgb.red = 0x0000; rgb.green = 0x0000; rgb.blue = 0x0000;
+ RGBForeColor( &rgb );
+ CopyBits(GetPortBitMapForCopyBits(graphic_data_), GetPortBitMapForCopyBits(dstPort), &src, &dst, srcCopy, 0L);
+ RGBBackColor(&oldbg);
+ RGBForeColor(&oldfg);
+}
+
+static void fl_delete_offscreen(GraphicData graphic_data) {
+ DisposeGWorld(graphic_data);
+}
+
+static GrafPtr prevPort;
+static GDHandle prevGD;
+
+bool Offscreen::begin() {
+ context_save_ = new GSave(); // push matrix, clip, save context handles (like dc)
+ GetGWorld( &prevPort, &prevGD );
+
+ if ( graphic_data_)
+ {
+ SetGWorld( graphic_data_, 0 ); // sets the correct port
+ PixMapHandle pm = GetGWorldPixMap(graphic_data_);
+ Boolean ret = LockPixels(pm);
+ if ( ret == false )
+ {
+ Rect rect;
+ GetPortBounds( graphic_data_, &rect );
+ UpdateGWorld( &graphic_data_, 0, &rect, 0, 0, 0 );
+ pm = GetGWorldPixMap( graphic_data_ );
+ LockPixels( pm );
+ }
+ fl_window = 0;
+ return true;
+ }
+ return false;
+}
+
+bool Offscreen::end() {
+ GraphicData currPort;
+ GDHandle currGD;
+ GetGWorld( &currPort, &currGD );
+ PixMapHandle pm = GetGWorldPixMap(currPort);
+ UnlockPixels(pm);
+
+ delete this->context_save_;
+ return true;
+}
+
+// end if defined(__APPLE_QD__)
+#elif defined(__APPLE_QUARTZ__)
+bool Offscreen::can_do_alpha_blending() {return true;}
+
+/* no alpha version
+void Offscreen::create () {
+ int w = dim_->w(), h = dim_->h();
+ void *data = calloc(w*h,4);
+ CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
+ CGContextRef graphic_data_ = CGBitmapContextCreate(
+ data, w, h, 8, w*4, lut, kCGImageAlphaNoneSkipLast);
+ CGColorSpaceRelease(lut);
+ //return (GraphicData)graphic_data_;
+}
+*/
+
+void Offscreen::create () {
+ void *data = calloc(w*h,4);
+ CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
+ CGContextRef graphic_data_ = CGBitmapContextCreate(
+ data, w, h, 8, w*4, lut, kCGImageAlphaPremultipliedLast);
+ CGColorSpaceRelease(lut);
+ //return (GraphicData)graphic_data_;
+}
+
+void Offscreen::copy(int x,int y,int w,int h,int srcx,int srcy) {
+ CGContextRef src = (CGContextRef) graphic_data_;
+ void *data = CGBitmapContextGetData(src);
+ int sw = CGBitmapContextGetWidth(src);
+ int sh = CGBitmapContextGetHeight(src);
+ CGImageAlphaInfo alpha = CGBitmapContextGetAlphaInfo(src);
+ CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
+ CGDataProviderRef src_bytes = CGDataProviderCreateWithData( 0L, data, sw*sh*4, 0L);
+ CGImageRef img = CGImageCreate( sw, sh, 8, 4*8, 4*sw, lut, alpha,
+ src_bytes, 0L, false, kCGRenderingIntentDefault);
+ // fl_push_clip();
+ CGRect rect = { { x, y }, { w, h } };
+ Fl_X::q_begin_image(rect, srcx, srcy, sw, sh);
+ CGContextDrawImage(fltk::dc, rect, img);
+ Fl_X::q_end_image();
+ CGImageRelease(img);
+ CGColorSpaceRelease(lut);
+ CGDataProviderRelease(src_bytes);
+}
+
+static void fl_delete_offscreen(GraphicData ctx) {
+ if (!ctx) return;
+ void *data = CGBitmapContextGetData((CGContextRef)ctx);
+ CGContextRelease((CGContextRef)ctx);
+ if (!data) return;
+ free(data);
+}
+
+const int stack_max = 16;
+static int stack_ix = 0;
+static CGContextRef stack_gc[stack_max];
+static Window stack_window[stack_max];
+
+bool Offscreen::begin() {
+ if (stack_ix<stack_max) {
+ stack_gc[stack_ix] = fltk::dc;
+ stack_window[stack_ix] = fl_window;
+ } else
+ fprintf(stderr, "FLTK CGContext Stack overflow error\n");
+ stack_ix++;
+
+ fltk::dc = (CGContextRef)graphic_data_;
+ fl_window = 0;
+ //fl_push_no_clip();
+ CGContextSaveGState(fltk::dc);
+ Fl_X::q_fill_context();
+}
+
+void fl_end_offscreen() {
+ Fl_X::q_release_context();
+ //fl_pop_clip();
+ if (stack_ix>0) flow error\n");
+ if (stack_ix<stack_max) {
+ fltk::dc = stack_gc[stack_ix];
+ fl_window = stack_window[stack_ix];
+ }
+}
+// end if defined(__APPLE_QUARTZ__)
+#else // X11
+// maybe someone feels inclined to implement alpha blending on X11?
+#endif
+
+//
+// End of "$Id"
+//
Property changes on: branches/fctrunk/src/Offscreen.cxx
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/fctrunk/src/Surface.cxx
===================================================================
--- branches/fctrunk/src/Surface.cxx (rev 0)
+++ branches/fctrunk/src/Surface.cxx 2007-04-03 16:21:47 UTC (rev 5754)
@@ -0,0 +1,32 @@
+// Surface.cxx: implementation of the Surface class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "FLTK\Surface.h"
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+using namespace fltk;
+
+Surface::~Surface() {
+ // Derived classes will have the responsibility to destroy
+ // all device dependent data here.
+}
+
+/**
+default behavior for this virtual method is false (= no alpha cap.)
+Override this method to add alpha cap.
+*/
+bool Surface::can_do_alpha_blending() {
+ return false;
+}
+
+/**
+default behavior for this virtual method is calling copy()
+Override this method to add alpha cap.
+*/
+bool Surface::copy_with_alpha(int x,int y,int w,int h,int srcx,int srcy) {
+ return this->copy(x, y, w, h, srcx, srcy);
+}
Property changes on: branches/fctrunk/src/Surface.cxx
___________________________________________________________________
Name: svn:executable
+ *
[ Direct Link to Message ] | |