[mcclim-cvs] CVS mcclim/Backends/gtkairo
dlichteblau
dlichteblau at common-lisp.net
Mon Apr 17 18:40:27 UTC 2006
Update of /project/mcclim/cvsroot/mcclim/Backends/gtkairo
In directory clnet:/tmp/cvs-serv14999/Backends/gtkairo
Added Files:
.cvsignore NOTES cairo-ffi.lisp clim-fix.lisp event.lisp
frame-manager.lisp gadgets.lisp graft.lisp gtk-ffi.lisp
keysymdef.lisp medium.lisp package.lisp pixmap.lisp port.lisp
Log Message:
* Backends/gtkairo: New directory: Experimental GTK+ backend.
* mcclim.asd (clim-gtkairo): New system. (clim-looks): Depend on
clim-gtkairo if the gtkairo feature has been set by the user.
* ports.lisp (*server-path-search-order*): s/gtk/gtkairo/
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/.cvsignore 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/.cvsignore 2006/04/17 18:40:27 1.1
*.fasl
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/NOTES 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/NOTES 2006/04/17 18:40:27 1.1
Gilbert Baumann's notes, copied from clim-cairo-2005-03-20/cairo-medium.lisp.
;; - blitting
;;
;; The X11 Cairo backend currently crashes my X server when blittering from
;; one surface to itself. [That is, if we draw to a surface using very same
;; surface as the pattern].
[ Well, no X11 here anywore. Is anything like this still relevant? ]
;; - pixmaps
;;
;; These should be easy to provide.
[ David: done ]
;; - alpha impedance mismatch
;;
;; Cairo uses pre-multiplied alpha while CLIM doesn't. So we need to convert
;; things around as needed.
[ David: ??? ]
;; - real general designs and optimization short cuts
;; - new drawing options:
;; - :transform-glyphs-p
;; - :alu
;; - MEDIUM-DRAW-ELLIPSE*
;; Need to find a good bezier approximation of circles.
;; - MEDIUM-BEEP
[ David: nix is, gepiepe kann ich nicht leiden. ;-) Ein "visual beep" waere
aber schick. Vielleicht kann man da ja was basteln? ]
;; - device text styles
;; - find a substitue for CAIRO-FONT-SET-TRANSFORM
;; - abolish this silly CLIM-INTERNALS::DO-GRAPHICS-WITH-OPTIONS
;; - INVOKE-WITH-DRAWING-OPTIONS
;; - care for the proper text transformations.
;; - we need a systematic overview about what drawing option components are
;; transformed under what circumstances in cairo and in clim.
;; - i believe a "cr" is really nothing more than a kind of graphics context, so
;; this time implement a proper cache for those, so that we spend less time
;; tossing options around.
[ David: Hmm, let's do some profiling before setting up a cache. Cairo
people seem to recommend creating a cairo context for each and every
redraw and then throwing it away, and we only create one for every
medium, so that shouldn't be too slow.
What's important is to not leak the cairo context. Right now I let the
sheet destroy contexts when the mirror is destroyed, is that the right
thing to do? ]
;; - more alu operations in clim
;;
;; For CAD applications it is really handy to have an OR operation. (Which
;; could be approximated in effect with :saturate). We would need to extend
;; the CLIM general design specification to include alu operations. [As
;; currently there really are only the OVER and FLIPPING operators available].
;; - More proper separation of a vanilla Cairo media and specific Cario medium
;; like X11, Glitz, PNG, PDF etc.
;; - a WITH-CAIRO macro which can setup the proper FPU mode to make it break
;; less.
[ David: oh yes, that's what I had to do in WITH-GTK. Terrible. ]
;;;; NOTES
;; RESOURCES, WHO TO FREE IT? -- It seems that if you destroy a window, a Render
;; picture associated with said window is also destroyed.
;; CAIRO-SET-TARGET-DRAWABLE and perhaps CAIRO-DESTROY do want to destroy that
;; picture on their own. So when we destroy a window we need to know all cairo
;; contexts floating around which associate to the window at hand and target
;; them at the root window (or better the spare window, more below) before we
;; destroy a window. And we need to do this recursively. And we need the extra
;; book keeping.
[ David: nix verstehen. Was ist denn ein render picture? Hilfe! ]
;; UNGRAFTED MEDIA -- It happens that an application wants to use a medium
;; before its sheet is grafted. In those situations we'd need a spare window to
;; target the associated cairo medium at. We could use the root window, but bad
;; things happen if the user actually does some drawing instead of merely
;; querying stuff like text extents. So I want to allocate a specific unmapped
;; spare window for those occasions.
;;
;; [There really are two situations: a) using an ungrafted medium, b)
;; using a medium that is grafted to a sheet which itself is not
;; grafted].
[ David: I'm using the root window for text size operations (harmless)
and completely ignore drawing operations otherwise. ]
;; FLIPPING INKS -- Cairo can't and for ideological reasons perhaps never will
;; support flipping inks. I myself hate flipping inks even more so than
;; bit-blittering, but there are still a few ancient applications around, which
;; use it. So we'd need to think about some way to support it. One idea is to
;; render the shape to an A1 temporary pixmap surface and use good old X11 to
;; make that pixmap flip pixels around. This breaks some abtractions established
;; by Cairo and will perhaps stop working around 2012. The fun thing is:
;; Flipping will now turn into a rather slow operation.
[ David: Das ginge auch mit Cairo, ja. ]
;; - flipping ink
;;
;; Below is some example code to make Cairo render the alpha channel to a one
;; bit depth pixmap on the server. This pixmap can then later be used with X
;; Core requests to flip pixels around. Still, in general flipping inks don't
;; play nice when you have an alpha channel.
;;
;; But: A flippink can't be solved by just setting up the proper Cairo pattern
;; to a Cairo context, but drawing the shape itself must happen on our
;; temporary surface.
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/cairo-ffi.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/cairo-ffi.lisp 2006/04/17 18:40:27 1.1
;;; -*- Mode: Lisp; -*-
;;; (c) copyright 2005 by Gilbert Baumann <gilbert at base-engineering.com>
;;; (c) copyright 2006 David Lichteblau (david at lichteblau.com)
;;; Permission is hereby granted, free of charge, to any person obtaining
;;; a copy of this software and associated documentation files (the
;;; "Software"), to deal in the Software without restriction, including
;;; without limitation the rights to use, copy, modify, merge, publish,
;;; distribute, sublicense, and/or sell copies of the Software, and to
;;; permit persons to whom the Software is furnished to do so, subject to
;;; the following conditions:
;;;
;;; The above copyright notice and this permission notice shall be
;;; included in all copies or substantial portions of the Software.
;;;
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
;;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
;;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
;;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
;;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(in-package :clim-gtkairo)
;; user-visible structures
(cffi:defcstruct cairo_text_extents
(x_bearing :double)
(y_bearing :double)
(width :double)
(height :double)
(x_advance :double)
(y_advance :double))
(cffi:defcstruct cairo_font_extents
(ascent :double)
(descent :double)
(height :double)
(max_x_advance :double)
(max_y_advance :double))
(cffi:defcstruct cairo_glyph
(index :unsigned-int)
(x :double)
(y :double))
(cffi:defcstruct cairo_matrix_t
(xx :double)
(yx :double)
(xy :double)
(yy :double)
(x0 :double)
(y0 :double))
;; enums
(cffi:defcenum cairo_format
:argb32 :rgb24 :a8 :a1)
(cffi:defcenum cairo_operator
:clear
:src :over :in :out :atop
:dest :dest_over :dest_in :dest_out :dest_atop
:xor :add :saturate)
(cffi:defcenum cairo_fill_rule
:winding :even_odd)
(cffi:defcenum cairo_line_cap
:butt :round :square)
(cffi:defcenum cairo_line_join
:miter :round :bevel)
(cffi:defcenum cairo_font_slant
:normal :italic :oblique)
(cffi:defcenum cairo_font_weight
:normal :bold)
(cffi:defcenum cairo_status
:success
:no_memory
:invalid_restore
:invalid_pop_group
:no_current_point
:invalid_matrix
:invalid_status
:null_pointer
:invalid_string
:invalid_path_data
:read_error
:write_error
:surface_finished
:surface_type_mismatch
:pattern_type_mismatch
:invalid_content
:invalid_format
:invalid_visual
:file_not_found
:invalid_dash)
(cffi:defcenum cairo_filter
:fast :good :best :nearest :bilinear :gaussian)
(cffi:defcenum cairo_extend
:none :repeat :reflect)
;;; Functions for manipulating state objects
(defcfun "cairo_create"
:pointer
(surface :pointer))
(defcfun "cairo_reference"
:void
(cr :pointer))
(defcfun "cairo_destroy"
:void
(cr :pointer))
(defcfun "cairo_save"
:void
(cr :pointer))
(defcfun "cairo_restore"
:void
(cr :pointer))
;;; XXX: Replace with cairo_current_gstate/cairo_set_gstate
;;;(defcfun "cairo_copy"
;;; :void
;;; (destination :pointer)
;;; (source :pointer))
;;; Modify state
;;;(defcfun "cairo_set_target_surface"
;;; :void
;;; (cr :pointer)
;;; (surface :pointer))
;;;
;;;(defcfun "cairo_set_target_image"
;;; :void
;;; (cr :pointer)
;;; (data :pointer) ;(* (unsigned 8))
;;; (format cairo_format)
;;; (width :int)
;;; (height :int)
;;; (stride :int))
(defcfun "cairo_set_operator"
:void
(cr :pointer)
(op cairo_operator))
;;; Colors
(defcfun "cairo_set_source_rgb"
:void
(cr :pointer)
(red :double)
(green :double)
(blue :double))
(defcfun "cairo_set_source_rgba"
:void
(cr :pointer)
(red :double)
(green :double)
(blue :double)
(alpha :double))
(defcfun "cairo_set_source"
:void
(cr :pointer)
(pattern :pointer))
(defcfun "cairo_set_tolerance"
:void
(cr :pointer)
(tolerance :double))
(defcfun "cairo_set_fill_rule"
:void
(cr :pointer)
(fill_rule cairo_fill_rule))
(defcfun "cairo_set_line_width"
:void
(cr :pointer)
(w :double))
(defcfun "cairo_set_line_cap"
:void
(cr :pointer)
(line_cap cairo_line_cap))
(defcfun "cairo_set_line_join"
:void
(cr :pointer)
(line_join cairo_line_join))
(defcfun "cairo_set_dash"
:void
(cr :pointer)
(dashes :pointer) ;*double
(ndash :int)
(offset :double))
(defcfun "cairo_set_miter_limit"
:int
(cr :pointer)
(limit :double))
;;; Transformations
(defcfun "cairo_translate"
:void
(cr :pointer)
(tx :double)
(ty :double))
(defcfun "cairo_scale"
:void
(cr :pointer)
(sx :double)
(sy :double))
(defcfun "cairo_rotate"
:void
(cr :pointer)
(angle :double))
(defcfun "cairo_set_matrix"
:void
(cr :pointer)
(matrix :pointer))
(defcfun "cairo_identity_matrix"
:void
(cr :pointer))
;;;(defcfun "cairo_transform_point"
;;; :void
;;; (cr :pointer)
;;; (x :pointer) ;*double
;;; (y :pointer) ;*double
;;; )
;;;(defcfun "cairo_transform_distance"
;;; :void
;;; (cr :pointer)
;;; (dx :pointer) ;*double
;;; (dy :pointer) ;*double
;;; )
;;;(defcfun "cairo_inverse_transform_point"
;;; :void
;;; (cr :pointer)
;;; (x :pointer) ;*double
;;; (y :pointer) ;*double
;;; )
;;;
;;;(defcfun "cairo_inverse_transform_distance"
[537 lines skipped]
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/clim-fix.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/clim-fix.lisp 2006/04/17 18:40:27 1.1
[563 lines skipped]
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/event.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/event.lisp 2006/04/17 18:40:27 1.1
[860 lines skipped]
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/frame-manager.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/frame-manager.lisp 2006/04/17 18:40:27 1.1
[967 lines skipped]
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/gadgets.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/gadgets.lisp 2006/04/17 18:40:27 1.1
[1135 lines skipped]
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/graft.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/graft.lisp 2006/04/17 18:40:27 1.1
[1178 lines skipped]
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/gtk-ffi.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/gtk-ffi.lisp 2006/04/17 18:40:27 1.1
[1913 lines skipped]
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/keysymdef.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/keysymdef.lisp 2006/04/17 18:40:27 1.1
[3699 lines skipped]
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/medium.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/medium.lisp 2006/04/17 18:40:27 1.1
[4610 lines skipped]
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/package.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/package.lisp 2006/04/17 18:40:27 1.1
[4616 lines skipped]
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/pixmap.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/pixmap.lisp 2006/04/17 18:40:27 1.1
[4717 lines skipped]
--- /project/mcclim/cvsroot/mcclim/Backends/gtkairo/port.lisp 2006/04/17 18:40:27 NONE
+++ /project/mcclim/cvsroot/mcclim/Backends/gtkairo/port.lisp 2006/04/17 18:40:27 1.1
[5336 lines skipped]
More information about the Mcclim-cvs
mailing list