~ubuntu-branches/ubuntu/trusty/lmms/trusty

« back to all changes in this revision

Viewing changes to plugins/zynaddsubfx/fltk/src/Fl_Double_Window.cxx

  • Committer: Charlie Smotherman
  • Date: 2012-12-05 22:08:38 UTC
  • mfrom: (33.1.7 lmms_0.4.13)
  • Revision ID: cjsmo@cableone.net-20121205220838-09pjfzew9m5023hr
* New  Upstream release.
  - Minor tweaking to ZynAddSubFX, CALF, SWH plugins  and Stefan Fendt's RC
    filters.
  - Added UI fixes: Magnentic effect of knobs and Piano-roll fixes
  - Updated German localization and copyright year
* debian/lmms-common.install:
  - added /usr/share/applications so the lmms.desktop file will correctly
    install (LP: #863366)
  - This should also fix the Software Center not displaying lmms in sound
    and video (LP: #824231)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// "$Id: Fl_Double_Window.cxx 7671 2010-07-09 17:31:33Z manolo $"
 
2
// "$Id: Fl_Double_Window.cxx 8383 2011-02-06 12:20:16Z AlbrechtS $"
3
3
//
4
4
// Double-buffered window code for the Fast Light Tool Kit (FLTK).
5
5
//
6
 
// Copyright 1998-2009 by Bill Spitzak and others.
 
6
// Copyright 1998-2010 by Bill Spitzak and others.
7
7
//
8
8
// This library is free software; you can redistribute it and/or
9
9
// modify it under the terms of the GNU Library General Public
52
52
    int numscreens = 1;
53
53
    XdbeScreenVisualInfo *a = XdbeGetVisualInfo(fl_display,&root,&numscreens);
54
54
    if (!a) return 0;
55
 
    for (int j = 0; j < a->count; j++)
 
55
    for (int j = 0; j < a->count; j++) {
56
56
      if (a->visinfo[j].visual == fl_visual->visualid
57
 
          /*&& a->visinfo[j].perflevel > 0*/) {use_xdbe = 1; break;}
 
57
          /*&& a->visinfo[j].perflevel > 0*/) {
 
58
        use_xdbe = 1; break;
 
59
      }
 
60
    }
58
61
    XdbeFreeVisualInfo(a);
59
62
  }
60
63
  return use_xdbe;
67
70
 
68
71
static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
69
72
 
 
73
/** \addtogroup fl_drawings
 
74
 @{
 
75
 */
 
76
/** Copy a rectangular area of the given offscreen buffer into the current drawing destination.
 
77
 \param x,y     position where to draw the copied rectangle
 
78
 \param w,h     size of the copied rectangle
 
79
 \param pixmap  offscreen buffer containing the rectangle to copy
 
80
 \param srcx,srcy origin in offscreen buffer of rectangle to copy
 
81
 */
70
82
void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
71
 
  if( fl_graphics_driver == fl_display_device->driver()) {
 
83
  if (fl_graphics_driver == Fl_Display_Device::display_device()->driver()) {
72
84
    fl_copy_offscreen_to_display(x, y, w, h, pixmap, srcx, srcy);
73
85
  }
74
86
  else { // when copy is not to the display
76
88
    uchar *img = fl_read_image(NULL, srcx, srcy, w, h, 0);
77
89
    fl_end_offscreen();
78
90
    fl_draw_image(img, x, y, w, h, 3, 0);
79
 
    delete img;
 
91
    delete[] img;
80
92
  }
81
93
}
 
94
/** @} */
82
95
 
83
96
#if defined(USE_X11)
84
97
 
85
98
static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) {
86
 
    XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y);
 
99
  XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y);
87
100
}
88
101
 
89
102
 
170
183
  BOOL alpha_ok = 0;
171
184
  // first try to alpha blend
172
185
  // if to printer, always try alpha_blend
173
 
  int to_display = Fl_Surface_Device::surface()->type() == Fl_Display_Device::device_type; // true iff display output
174
 
  if ( (to_display && fl_can_do_alpha_blending()) || Fl_Surface_Device::surface()->type() == Fl_Printer::device_type) {
 
186
  int to_display = Fl_Surface_Device::surface()->class_name() == Fl_Display_Device::class_id; // true iff display output
 
187
  if ( (to_display && fl_can_do_alpha_blending()) || Fl_Surface_Device::surface()->class_name() == Fl_Printer::class_id) {
175
188
    alpha_ok = fl_alpha_blend(fl_gc, x, y, w, h, new_gc, srcx, srcy, w, h, blendfunc);
176
 
    }
 
189
  }
177
190
  // if that failed (it shouldn't), still copy the bitmap over, but now alpha is 1
178
191
  if (!alpha_ok) {
179
192
    BitBlt(fl_gc, x, y, w, h, new_gc, srcx, srcy, SRCCOPY);
180
 
    }
 
193
  }
181
194
  RestoreDC(new_gc, save);
182
195
  DeleteDC(new_gc);
183
196
}
184
197
 
185
198
extern void fl_restore_clip();
186
199
 
187
 
#elif defined(__APPLE_QUARTZ__)
 
200
#elif defined(__APPLE_QUARTZ__) || defined(FL_DOXYGEN)
188
201
 
189
202
char fl_can_do_alpha_blending() {
190
203
  return 1;
191
204
}
192
205
 
 
206
Fl_Offscreen fl_create_offscreen_with_alpha(int w, int h) {
 
207
  void *data = calloc(w*h,4);
 
208
  CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
 
209
  CGContextRef ctx = CGBitmapContextCreate(
 
210
    data, w, h, 8, w*4, lut, kCGImageAlphaPremultipliedLast);
 
211
  CGColorSpaceRelease(lut);
 
212
  return (Fl_Offscreen)ctx;
 
213
}
 
214
 
 
215
/** \addtogroup fl_drawings
 
216
 @{
 
217
 */
 
218
 
 
219
/** 
 
220
  Creation of an offscreen graphics buffer.
 
221
 \param w,h     width and height in pixels of the buffer.
 
222
 \return    the created graphics buffer.
 
223
 */
193
224
Fl_Offscreen fl_create_offscreen(int w, int h) {
194
225
  void *data = calloc(w*h,4);
195
226
  CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
199
230
  return (Fl_Offscreen)ctx;
200
231
}
201
232
 
202
 
Fl_Offscreen fl_create_offscreen_with_alpha(int w, int h) {
203
 
  void *data = calloc(w*h,4);
204
 
  CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
205
 
  CGContextRef ctx = CGBitmapContextCreate(
206
 
    data, w, h, 8, w*4, lut, kCGImageAlphaPremultipliedLast);
207
 
  CGColorSpaceRelease(lut);
208
 
  return (Fl_Offscreen)ctx;
209
 
}
210
 
 
211
 
static void bmProviderRelease (void *src, const void *data, size_t size)
212
 
{
 
233
static void bmProviderRelease (void *src, const void *data, size_t size) {
213
234
  CFIndex count = CFGetRetainCount(src);
214
235
  CFRelease(src);
215
236
  if(count == 1) free((void*)data);
238
259
  CGDataProviderRelease(src_bytes);
239
260
}
240
261
 
 
262
/**  Deletion of an offscreen graphics buffer.
 
263
 \param ctx     the buffer to be deleted.
 
264
 */
241
265
void fl_delete_offscreen(Fl_Offscreen ctx) {
242
266
  if (!ctx) return;
243
267
  void *data = CGBitmapContextGetData((CGContextRef)ctx);
252
276
static Window stack_window[stack_max];
253
277
static Fl_Surface_Device *_ss;
254
278
 
 
279
/**  Send all subsequent drawing commands to this offscreen buffer.
 
280
 \param ctx     the offscreen buffer.
 
281
 */
255
282
void fl_begin_offscreen(Fl_Offscreen ctx) {
256
 
  _ss = fl_surface; 
257
 
  fl_display_device->set_current();
 
283
  _ss = Fl_Surface_Device::surface(); 
 
284
  Fl_Display_Device::display_device()->set_current();
258
285
  if (stack_ix<stack_max) {
259
286
    stack_gc[stack_ix] = fl_gc;
260
287
    stack_window[stack_ix] = fl_window;
268
295
  fl_push_no_clip();
269
296
}
270
297
 
 
298
/** Quit sending drawing commands to the current offscreen buffer.
 
299
 */
271
300
void fl_end_offscreen() {
272
301
  Fl_X::q_release_context();
273
302
  fl_pop_clip();
282
311
  _ss->set_current();
283
312
}
284
313
 
 
314
/** @} */
 
315
 
285
316
extern void fl_restore_clip();
286
317
 
287
318
#else
307
338
  if (!myi->other_xid) {
308
339
#if USE_XDBE
309
340
    if (can_xdbe()) {
310
 
      myi->other_xid =
311
 
        XdbeAllocateBackBufferName(fl_display, fl_xid(this), XdbeCopied);
 
341
      myi->other_xid = XdbeAllocateBackBufferName(fl_display, fl_xid(this), XdbeCopied);
312
342
      myi->backbuffer_bad = 1;
313
343
    } else
314
344
#endif
360
390
    RestoreDC(fl_gc, save);
361
391
    DeleteDC(fl_gc);
362
392
    fl_gc = _sgc;
363
 
    //# if defined(USE_CAIRO)
 
393
    //# if defined(FLTK_USE_CAIRO)
364
394
    //if Fl::cairo_autolink_context() Fl::cairo_make_current(this); // capture gc changes automatically to update the cairo context adequately
365
395
    //# endif
366
396
#elif defined(__APPLE__)
428
458
}
429
459
 
430
460
//
431
 
// End of "$Id: Fl_Double_Window.cxx 7671 2010-07-09 17:31:33Z manolo $".
 
461
// End of "$Id: Fl_Double_Window.cxx 8383 2011-02-06 12:20:16Z AlbrechtS $".
432
462
//