diff options
-rw-r--r-- | libs/cairo/AUTHORS (renamed from libs/cairo/cairo/AUTHORS) | 0 | ||||
-rw-r--r-- | libs/cairo/COPYING (renamed from libs/cairo/cairo/COPYING) | 0 | ||||
-rw-r--r-- | libs/cairo/README (renamed from libs/cairo/cairo/README) | 0 | ||||
-rw-r--r-- | libs/cairo/cairo/src/cairo-beos-surface.cpp | 949 | ||||
-rw-r--r-- | libs/cairo/cairo/src/cairo-beos.h | 29 | ||||
-rw-r--r-- | libs/cairo/cairo/src/cairo-qt-surface.cpp | 1716 | ||||
-rw-r--r-- | libs/cairo/cairo/src/cairo-qt.h | 53 | ||||
-rw-r--r-- | libs/cairo/cairo/src/cairo-quartz-font.c | 811 | ||||
-rw-r--r-- | libs/cairo/cairo/src/cairo-quartz-image-surface.c | 258 | ||||
-rw-r--r-- | libs/cairo/cairo/src/cairo-quartz-image.h | 33 | ||||
-rw-r--r-- | libs/cairo/cairo/src/cairo-quartz-private.h | 86 | ||||
-rw-r--r-- | libs/cairo/cairo/src/cairo-quartz-surface.c | 3768 | ||||
-rw-r--r-- | libs/cairo/cairo/src/cairo-quartz.h | 81 | ||||
-rw-r--r-- | libs/cairo/cairo/src/moz.build | 266 | ||||
-rw-r--r-- | libs/cairo/moz.build | 199 | ||||
-rw-r--r-- | libs/cairo/src/cairo-analysis-surface-private.h (renamed from libs/cairo/cairo/src/cairo-analysis-surface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-analysis-surface.c (renamed from libs/cairo/cairo/src/cairo-analysis-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-arc-private.h (renamed from libs/cairo/cairo/src/cairo-arc-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-arc.c (renamed from libs/cairo/cairo/src/cairo-arc.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-array.c (renamed from libs/cairo/cairo/src/cairo-array.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-atomic-private.h (renamed from libs/cairo/cairo/src/cairo-atomic-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-atomic.c (renamed from libs/cairo/cairo/src/cairo-atomic.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-base64-stream.c (renamed from libs/cairo/cairo/src/cairo-base64-stream.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-base85-stream.c (renamed from libs/cairo/cairo/src/cairo-base85-stream.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-bentley-ottmann-rectangular.c (renamed from libs/cairo/cairo/src/cairo-bentley-ottmann-rectangular.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-bentley-ottmann-rectilinear.c (renamed from libs/cairo/cairo/src/cairo-bentley-ottmann-rectilinear.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-bentley-ottmann.c (renamed from libs/cairo/cairo/src/cairo-bentley-ottmann.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-botor-scan-converter.c (renamed from libs/cairo/cairo/src/cairo-botor-scan-converter.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-boxes-private.h (renamed from libs/cairo/cairo/src/cairo-boxes-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-boxes.c (renamed from libs/cairo/cairo/src/cairo-boxes.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-cache-private.h (renamed from libs/cairo/cairo/src/cairo-cache-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-cache.c (renamed from libs/cairo/cairo/src/cairo-cache.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-cff-subset.c (renamed from libs/cairo/cairo/src/cairo-cff-subset.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-clip-private.h (renamed from libs/cairo/cairo/src/cairo-clip-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-clip.c (renamed from libs/cairo/cairo/src/cairo-clip.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-color.c (renamed from libs/cairo/cairo/src/cairo-color.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-combsort-private.h (renamed from libs/cairo/cairo/src/cairo-combsort-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-compiler-private.h (renamed from libs/cairo/cairo/src/cairo-compiler-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-composite-rectangles-private.h (renamed from libs/cairo/cairo/src/cairo-composite-rectangles-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-composite-rectangles.c (renamed from libs/cairo/cairo/src/cairo-composite-rectangles.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-d2d-private-fx.h (renamed from libs/cairo/cairo/src/cairo-d2d-private-fx.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-d2d-private.fx (renamed from libs/cairo/cairo/src/cairo-d2d-private.fx) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-d2d-private.h (renamed from libs/cairo/cairo/src/cairo-d2d-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-d2d-surface.cpp (renamed from libs/cairo/cairo/src/cairo-d2d-surface.cpp) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-debug.c (renamed from libs/cairo/cairo/src/cairo-debug.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-deflate-stream.c (renamed from libs/cairo/cairo/src/cairo-deflate-stream.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-deprecated.h (renamed from libs/cairo/cairo/src/cairo-deprecated.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-device-private.h (renamed from libs/cairo/cairo/src/cairo-device-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-device.c (renamed from libs/cairo/cairo/src/cairo-device.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-directfb-surface.c (renamed from libs/cairo/cairo/src/cairo-directfb-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-directfb.h (renamed from libs/cairo/cairo/src/cairo-directfb.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-drm.h (renamed from libs/cairo/cairo/src/cairo-drm.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-dwrite-font.cpp (renamed from libs/cairo/cairo/src/cairo-dwrite-font.cpp) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-dwrite-private.h (renamed from libs/cairo/cairo/src/cairo-dwrite-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-eagle-context.c (renamed from libs/cairo/cairo/src/cairo-eagle-context.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-error-private.h (renamed from libs/cairo/cairo/src/cairo-error-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-features-win32.h (renamed from libs/cairo/cairo/src/cairo-features-win32.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-features.h.in (renamed from libs/cairo/cairo/src/cairo-features.h.in) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-fixed-private.h (renamed from libs/cairo/cairo/src/cairo-fixed-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-fixed-type-private.h (renamed from libs/cairo/cairo/src/cairo-fixed-type-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-fixed.c (renamed from libs/cairo/cairo/src/cairo-fixed.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-font-face-twin-data.c (renamed from libs/cairo/cairo/src/cairo-font-face-twin-data.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-font-face-twin.c (renamed from libs/cairo/cairo/src/cairo-font-face-twin.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-font-face.c (renamed from libs/cairo/cairo/src/cairo-font-face.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-font-options.c (renamed from libs/cairo/cairo/src/cairo-font-options.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-fontconfig-private.h (renamed from libs/cairo/cairo/src/cairo-fontconfig-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-freed-pool-private.h (renamed from libs/cairo/cairo/src/cairo-freed-pool-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-freed-pool.c (renamed from libs/cairo/cairo/src/cairo-freed-pool.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-freelist-private.h (renamed from libs/cairo/cairo/src/cairo-freelist-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-freelist-type-private.h (renamed from libs/cairo/cairo/src/cairo-freelist-type-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-freelist.c (renamed from libs/cairo/cairo/src/cairo-freelist.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-ft-font.c (renamed from libs/cairo/cairo/src/cairo-ft-font.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-ft-private.h (renamed from libs/cairo/cairo/src/cairo-ft-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-ft.h (renamed from libs/cairo/cairo/src/cairo-ft.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-gl-glyphs.c (renamed from libs/cairo/cairo/src/cairo-gl-glyphs.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-gl-private.h (renamed from libs/cairo/cairo/src/cairo-gl-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-gl-shaders.c (renamed from libs/cairo/cairo/src/cairo-gl-shaders.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-gl-surface.c (renamed from libs/cairo/cairo/src/cairo-gl-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-gl.h (renamed from libs/cairo/cairo/src/cairo-gl.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-glitz-private.h (renamed from libs/cairo/cairo/src/cairo-glitz-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-glitz-surface.c (renamed from libs/cairo/cairo/src/cairo-glitz-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-glitz.h (renamed from libs/cairo/cairo/src/cairo-glitz.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-glx-context.c (renamed from libs/cairo/cairo/src/cairo-glx-context.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-gstate-private.h (renamed from libs/cairo/cairo/src/cairo-gstate-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-gstate.c (renamed from libs/cairo/cairo/src/cairo-gstate.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-hash-private.h (renamed from libs/cairo/cairo/src/cairo-hash-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-hash.c (renamed from libs/cairo/cairo/src/cairo-hash.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-hull.c (renamed from libs/cairo/cairo/src/cairo-hull.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-image-info-private.h (renamed from libs/cairo/cairo/src/cairo-image-info-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-image-info.c (renamed from libs/cairo/cairo/src/cairo-image-info.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-image-surface.c (renamed from libs/cairo/cairo/src/cairo-image-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-list-private.h (renamed from libs/cairo/cairo/src/cairo-list-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-lzw.c (renamed from libs/cairo/cairo/src/cairo-lzw.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-malloc-private.h (renamed from libs/cairo/cairo/src/cairo-malloc-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-matrix.c (renamed from libs/cairo/cairo/src/cairo-matrix.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-meta-surface-private.h (renamed from libs/cairo/cairo/src/cairo-meta-surface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-misc.c (renamed from libs/cairo/cairo/src/cairo-misc.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-mutex-impl-private.h (renamed from libs/cairo/cairo/src/cairo-mutex-impl-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-mutex-list-private.h (renamed from libs/cairo/cairo/src/cairo-mutex-list-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-mutex-private.h (renamed from libs/cairo/cairo/src/cairo-mutex-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-mutex-type-private.h (renamed from libs/cairo/cairo/src/cairo-mutex-type-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-mutex.c (renamed from libs/cairo/cairo/src/cairo-mutex.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-no-features.h (renamed from libs/cairo/cairo/src/cairo-no-features.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-observer.c (renamed from libs/cairo/cairo/src/cairo-observer.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-os2-private.h (renamed from libs/cairo/cairo/src/cairo-os2-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-os2-surface.c (renamed from libs/cairo/cairo/src/cairo-os2-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-os2.h (renamed from libs/cairo/cairo/src/cairo-os2.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-output-stream-private.h (renamed from libs/cairo/cairo/src/cairo-output-stream-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-output-stream.c (renamed from libs/cairo/cairo/src/cairo-output-stream.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-paginated-private.h (renamed from libs/cairo/cairo/src/cairo-paginated-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-paginated-surface-private.h (renamed from libs/cairo/cairo/src/cairo-paginated-surface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-paginated-surface.c (renamed from libs/cairo/cairo/src/cairo-paginated-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-path-bounds.c (renamed from libs/cairo/cairo/src/cairo-path-bounds.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-path-fill.c (renamed from libs/cairo/cairo/src/cairo-path-fill.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-path-fixed-private.h (renamed from libs/cairo/cairo/src/cairo-path-fixed-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-path-fixed.c (renamed from libs/cairo/cairo/src/cairo-path-fixed.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-path-in-fill.c (renamed from libs/cairo/cairo/src/cairo-path-in-fill.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-path-private.h (renamed from libs/cairo/cairo/src/cairo-path-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-path-stroke.c (renamed from libs/cairo/cairo/src/cairo-path-stroke.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-path.c (renamed from libs/cairo/cairo/src/cairo-path.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-pattern.c (renamed from libs/cairo/cairo/src/cairo-pattern.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-pdf-operators-private.h (renamed from libs/cairo/cairo/src/cairo-pdf-operators-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-pdf-operators.c (renamed from libs/cairo/cairo/src/cairo-pdf-operators.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-pdf-surface-private.h (renamed from libs/cairo/cairo/src/cairo-pdf-surface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-pdf-surface.c (renamed from libs/cairo/cairo/src/cairo-pdf-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-pdf.h (renamed from libs/cairo/cairo/src/cairo-pdf.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-pen.c (renamed from libs/cairo/cairo/src/cairo-pen.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-platform.h (renamed from libs/cairo/cairo/src/cairo-platform.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-png.c (renamed from libs/cairo/cairo/src/cairo-png.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-polygon.c (renamed from libs/cairo/cairo/src/cairo-polygon.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-private.h (renamed from libs/cairo/cairo/src/cairo-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-ps-surface-private.h (renamed from libs/cairo/cairo/src/cairo-ps-surface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-ps-surface.c (renamed from libs/cairo/cairo/src/cairo-ps-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-ps.h (renamed from libs/cairo/cairo/src/cairo-ps.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-recording-surface-private.h (renamed from libs/cairo/cairo/src/cairo-recording-surface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-recording-surface.c (renamed from libs/cairo/cairo/src/cairo-recording-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-rectangle.c (renamed from libs/cairo/cairo/src/cairo-rectangle.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-rectangular-scan-converter.c (renamed from libs/cairo/cairo/src/cairo-rectangular-scan-converter.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-reference-count-private.h (renamed from libs/cairo/cairo/src/cairo-reference-count-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-region-private.h (renamed from libs/cairo/cairo/src/cairo-region-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-region.c (renamed from libs/cairo/cairo/src/cairo-region.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-rename.h (renamed from libs/cairo/cairo/src/cairo-rename.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-rtree-private.h (renamed from libs/cairo/cairo/src/cairo-rtree-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-rtree.c (renamed from libs/cairo/cairo/src/cairo-rtree.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-scaled-font-private.h (renamed from libs/cairo/cairo/src/cairo-scaled-font-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-scaled-font-subsets-private.h (renamed from libs/cairo/cairo/src/cairo-scaled-font-subsets-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-scaled-font-subsets.c (renamed from libs/cairo/cairo/src/cairo-scaled-font-subsets.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-scaled-font.c (renamed from libs/cairo/cairo/src/cairo-scaled-font.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-script-surface.c (renamed from libs/cairo/cairo/src/cairo-script-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-script.h (renamed from libs/cairo/cairo/src/cairo-script.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-skia.h (renamed from libs/cairo/cairo/src/cairo-skia.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-slope-private.h (renamed from libs/cairo/cairo/src/cairo-slope-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-slope.c (renamed from libs/cairo/cairo/src/cairo-slope.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-spans-private.h (renamed from libs/cairo/cairo/src/cairo-spans-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-spans.c (renamed from libs/cairo/cairo/src/cairo-spans.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-spline.c (renamed from libs/cairo/cairo/src/cairo-spline.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-stroke-style.c (renamed from libs/cairo/cairo/src/cairo-stroke-style.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-supported-features.h (renamed from libs/cairo/cairo/src/cairo-supported-features.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-clipper-private.h (renamed from libs/cairo/cairo/src/cairo-surface-clipper-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-clipper.c (renamed from libs/cairo/cairo/src/cairo-surface-clipper.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-fallback-private.h (renamed from libs/cairo/cairo/src/cairo-surface-fallback-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-fallback.c (renamed from libs/cairo/cairo/src/cairo-surface-fallback.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-offset-private.h (renamed from libs/cairo/cairo/src/cairo-surface-offset-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-offset.c (renamed from libs/cairo/cairo/src/cairo-surface-offset.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-private.h (renamed from libs/cairo/cairo/src/cairo-surface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-snapshot-private.h (renamed from libs/cairo/cairo/src/cairo-surface-snapshot-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-snapshot.c (renamed from libs/cairo/cairo/src/cairo-surface-snapshot.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-subsurface-private.h (renamed from libs/cairo/cairo/src/cairo-surface-subsurface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-subsurface.c (renamed from libs/cairo/cairo/src/cairo-surface-subsurface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-wrapper-private.h (renamed from libs/cairo/cairo/src/cairo-surface-wrapper-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface-wrapper.c (renamed from libs/cairo/cairo/src/cairo-surface-wrapper.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-surface.c (renamed from libs/cairo/cairo/src/cairo-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-svg-surface-private.h (renamed from libs/cairo/cairo/src/cairo-svg-surface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-svg-surface.c (renamed from libs/cairo/cairo/src/cairo-svg-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-svg.h (renamed from libs/cairo/cairo/src/cairo-svg.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-system.c (renamed from libs/cairo/cairo/src/cairo-system.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-tee-surface-private.h (renamed from libs/cairo/cairo/src/cairo-tee-surface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-tee-surface.c (renamed from libs/cairo/cairo/src/cairo-tee-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-tee.h (renamed from libs/cairo/cairo/src/cairo-tee.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-tor-scan-converter.c (renamed from libs/cairo/cairo/src/cairo-tor-scan-converter.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-toy-font-face.c (renamed from libs/cairo/cairo/src/cairo-toy-font-face.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-traps.c (renamed from libs/cairo/cairo/src/cairo-traps.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-truetype-subset-private.h (renamed from libs/cairo/cairo/src/cairo-truetype-subset-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-truetype-subset.c (renamed from libs/cairo/cairo/src/cairo-truetype-subset.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-type1-fallback.c (renamed from libs/cairo/cairo/src/cairo-type1-fallback.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-type1-private.h (renamed from libs/cairo/cairo/src/cairo-type1-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-type1-subset.c (renamed from libs/cairo/cairo/src/cairo-type1-subset.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-type3-glyph-surface-private.h (renamed from libs/cairo/cairo/src/cairo-type3-glyph-surface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-type3-glyph-surface.c (renamed from libs/cairo/cairo/src/cairo-type3-glyph-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-types-private.h (renamed from libs/cairo/cairo/src/cairo-types-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-unicode.c (renamed from libs/cairo/cairo/src/cairo-unicode.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-user-font-private.h (renamed from libs/cairo/cairo/src/cairo-user-font-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-user-font.c (renamed from libs/cairo/cairo/src/cairo-user-font.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-version.c (renamed from libs/cairo/cairo/src/cairo-version.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-version.h (renamed from libs/cairo/cairo/src/cairo-version.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-vg-surface.c (renamed from libs/cairo/cairo/src/cairo-vg-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-vg.h (renamed from libs/cairo/cairo/src/cairo-vg.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-wideint-private.h (renamed from libs/cairo/cairo/src/cairo-wideint-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-wideint-type-private.h (renamed from libs/cairo/cairo/src/cairo-wideint-type-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-wideint.c (renamed from libs/cairo/cairo/src/cairo-wideint.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-win32-font.c (renamed from libs/cairo/cairo/src/cairo-win32-font.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-win32-printing-surface.c (renamed from libs/cairo/cairo/src/cairo-win32-printing-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-win32-private.h (renamed from libs/cairo/cairo/src/cairo-win32-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-win32-refptr.h (renamed from libs/cairo/cairo/src/cairo-win32-refptr.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-win32-surface.c (renamed from libs/cairo/cairo/src/cairo-win32-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-win32.h (renamed from libs/cairo/cairo/src/cairo-win32.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xcb-surface.c (renamed from libs/cairo/cairo/src/cairo-xcb-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xcb-xrender.h (renamed from libs/cairo/cairo/src/cairo-xcb-xrender.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xcb.h (renamed from libs/cairo/cairo/src/cairo-xcb.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xlib-display.c (renamed from libs/cairo/cairo/src/cairo-xlib-display.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xlib-private.h (renamed from libs/cairo/cairo/src/cairo-xlib-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xlib-screen.c (renamed from libs/cairo/cairo/src/cairo-xlib-screen.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xlib-surface-private.h (renamed from libs/cairo/cairo/src/cairo-xlib-surface-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xlib-surface.c (renamed from libs/cairo/cairo/src/cairo-xlib-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xlib-visual.c (renamed from libs/cairo/cairo/src/cairo-xlib-visual.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xlib-xrender-private.h (renamed from libs/cairo/cairo/src/cairo-xlib-xrender-private.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xlib-xrender.h (renamed from libs/cairo/cairo/src/cairo-xlib-xrender.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xlib.h (renamed from libs/cairo/cairo/src/cairo-xlib.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xml-surface.c (renamed from libs/cairo/cairo/src/cairo-xml-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo-xml.h (renamed from libs/cairo/cairo/src/cairo-xml.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo.c (renamed from libs/cairo/cairo/src/cairo.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairo.h (renamed from libs/cairo/cairo/src/cairo.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/cairoint.h (renamed from libs/cairo/cairo/src/cairoint.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/check-has-hidden-symbols.c (renamed from libs/cairo/cairo/src/check-has-hidden-symbols.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/check-link.c (renamed from libs/cairo/cairo/src/check-link.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/filterpublic.awk (renamed from libs/cairo/cairo/src/filterpublic.awk) | 0 | ||||
-rw-r--r-- | libs/cairo/src/pixman-rename.h (renamed from libs/cairo/cairo/src/pixman-rename.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/test-fallback-surface.c (renamed from libs/cairo/cairo/src/test-fallback-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/test-fallback-surface.h (renamed from libs/cairo/cairo/src/test-fallback-surface.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/test-meta-surface.c (renamed from libs/cairo/cairo/src/test-meta-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/test-meta-surface.h (renamed from libs/cairo/cairo/src/test-meta-surface.h) | 0 | ||||
-rw-r--r-- | libs/cairo/src/test-paginated-surface.c (renamed from libs/cairo/cairo/src/test-paginated-surface.c) | 0 | ||||
-rw-r--r-- | libs/cairo/src/test-paginated-surface.h (renamed from libs/cairo/cairo/src/test-paginated-surface.h) | 0 | ||||
-rw-r--r-- | libs/libpixman/moz.build | 4 | ||||
-rw-r--r-- | old-configure.in | 2 |
235 files changed, 200 insertions, 8055 deletions
diff --git a/libs/cairo/cairo/AUTHORS b/libs/cairo/AUTHORS index bdde62a31..bdde62a31 100644 --- a/libs/cairo/cairo/AUTHORS +++ b/libs/cairo/AUTHORS diff --git a/libs/cairo/cairo/COPYING b/libs/cairo/COPYING index 184e603c3..184e603c3 100644 --- a/libs/cairo/cairo/COPYING +++ b/libs/cairo/COPYING diff --git a/libs/cairo/cairo/README b/libs/cairo/README index fc801fee3..fc801fee3 100644 --- a/libs/cairo/cairo/README +++ b/libs/cairo/README diff --git a/libs/cairo/cairo/src/cairo-beos-surface.cpp b/libs/cairo/cairo/src/cairo-beos-surface.cpp deleted file mode 100644 index d52ae1513..000000000 --- a/libs/cairo/cairo/src/cairo-beos-surface.cpp +++ /dev/null @@ -1,949 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// This is a C++ file in order to use the C++ BeOS API - -#include "cairoint.h" - -#include "cairo-beos.h" - -#include <new> - -#include <Bitmap.h> -#include <Region.h> -#if 0 -#include <DirectWindow.h> -#endif -#include <Screen.h> -#include <Window.h> -#include <Locker.h> - -#define CAIRO_INT_STATUS_SUCCESS (cairo_int_status_t)(CAIRO_STATUS_SUCCESS) - -struct cairo_beos_surface_t { - cairo_surface_t base; - - BView* view; - - /* - * A view is either attached to a bitmap, a window, or unattached. - * If it is attached to a window, we can copy data out of it using BScreen. - * If it is attached to a bitmap, we can read the bitmap data. - * If it is not attached, it doesn't draw anything, we need not bother. - * - * Since there doesn't seem to be a way to get the bitmap from a view if it - * is attached to one, we have to use a special surface creation function. - */ - - BBitmap* bitmap; - - - // If true, surface and view should be deleted when this surface is - // destroyed - bool owns_bitmap_view; -}; - -class AutoLockView { - public: - AutoLockView(BView* view) : mView(view) { - mOK = mView->LockLooper(); - } - - ~AutoLockView() { - if (mOK) - mView->UnlockLooper(); - } - - operator bool() { - return mOK; - } - - private: - BView* mView; - bool mOK; -}; - -static cairo_surface_t * -_cairo_beos_surface_create_internal (BView* view, - BBitmap* bmp, - bool owns_bitmap_view = false); - -static BRect -_cairo_rect_to_brect (const cairo_rectangle_int16_t* rect) -{ - // A BRect is one pixel wider than you'd think - return BRect(rect->x, rect->y, rect->x + rect->width - 1, - rect->y + rect->height - 1); -} - -static cairo_rectangle_int16_t -_brect_to_cairo_rect (const BRect& rect) -{ - cairo_rectangle_int16_t retval; - retval.x = int(rect.left + 0.5); - retval.y = int(rect.top + 0.5); - retval.width = rect.IntegerWidth() + 1; - retval.height = rect.IntegerHeight() + 1; - return retval; -} - -static rgb_color -_cairo_color_to_be_color (const cairo_color_t* color) -{ - // This factor ensures a uniform distribution of numbers - const float factor = 256 - 1e-5; - // Using doubles to have non-premultiplied colors - rgb_color be_color = { uint8(color->red * factor), - uint8(color->green * factor), - uint8(color->blue * factor), - uint8(color->alpha * factor) }; - - return be_color; -} - -enum ViewCopyStatus { - OK, - NOT_VISIBLE, // The view or the interest rect is not visible on screen - ERROR // The view was visible, but the rect could not be copied. Probably OOM -}; - -/** - * _cairo_beos_view_to_bitmap: - * @bitmap: [out] The resulting bitmap. - * @rect: [out] The rectangle that was copied, in the view's coordinate system - * @interestRect: If non-null, only this part of the view will be copied (view's coord system). - * - * Gets the contents of the view as a BBitmap*. Caller must delete the bitmap. - **/ -static ViewCopyStatus -_cairo_beos_view_to_bitmap (BView* view, - BBitmap** bitmap, - BRect* rect = NULL, - const BRect* interestRect = NULL) -{ - *bitmap = NULL; - - BWindow* wnd = view->Window(); - // If we have no window, can't do anything - if (!wnd) - return NOT_VISIBLE; - - view->Sync(); - wnd->Sync(); - -#if 0 - // Is it a direct window? - BDirectWindow* directWnd = dynamic_cast<BDirectWindow*>(wnd); - if (directWnd) { - // WRITEME - } -#endif - - // Is it visible? If so, we can copy the content off the screen - if (wnd->IsHidden()) - return NOT_VISIBLE; - - BRect rectToCopy(view->Bounds()); - if (interestRect) - rectToCopy = rectToCopy & *interestRect; - - if (!rectToCopy.IsValid()) - return NOT_VISIBLE; - - BScreen screen(wnd); - BRect screenRect(view->ConvertToScreen(rectToCopy)); - screenRect = screenRect & screen.Frame(); - - if (!screen.IsValid()) - return NOT_VISIBLE; - - if (rect) - *rect = view->ConvertFromScreen(screenRect); - - if (screen.GetBitmap(bitmap, false, &screenRect) == B_OK) - return OK; - - return ERROR; -} - -inline unsigned char -unpremultiply (unsigned char color, - unsigned char alpha) -{ - if (alpha == 0) - return 0; - // plus alpha/2 to round instead of truncate - return (color * 255 + alpha / 2) / alpha; -} - -inline unsigned char -premultiply (unsigned char color, - unsigned char alpha) -{ - // + 127 to round, instead of truncate - return (color * alpha + 127) / 255; -} - -/** - * unpremultiply_rgba: - * - * Takes an input in ABGR premultiplied image data and unmultiplies it. - * The result is stored in retdata. - **/ -static void -unpremultiply_rgba (unsigned char* data, - int width, - int height, - int stride, - unsigned char* retdata) -{ - unsigned char* end = data + stride * height; - for (unsigned char* in = data, *out = retdata; - in < end; - in += stride, out += stride) - { - for (int i = 0; i < width; ++i) { - // XXX for a big-endian platform this'd have to change - int idx = 4 * i; - unsigned char alpha = in[idx + 3]; - out[idx + 0] = unpremultiply(in[idx + 0], alpha); // B - out[idx + 1] = unpremultiply(in[idx + 1], alpha); // G - out[idx + 2] = unpremultiply(in[idx + 2], alpha); // R - out[idx + 3] = in[idx + 3]; // Alpha - } - } -} - -/** - * premultiply_rgba: - * - * Takes an input in ABGR non-premultiplied image data and premultiplies it. - * The returned data must be freed with free(). - **/ -static unsigned char* -premultiply_rgba (unsigned char* data, - int width, - int height, - int stride) -{ - unsigned char* retdata = reinterpret_cast<unsigned char*>(_cairo_malloc_ab(height, stride)); - if (!retdata) - return NULL; - - unsigned char* end = data + stride * height; - for (unsigned char* in = data, *out = retdata; - in < end; - in += stride, out += stride) - { - for (int i = 0; i < width; ++i) { - // XXX for a big-endian platform this'd have to change - int idx = 4 * i; - unsigned char alpha = in[idx + 3]; - out[idx + 0] = premultiply(in[idx + 0], alpha); // B - out[idx + 1] = premultiply(in[idx + 1], alpha); // G - out[idx + 2] = premultiply(in[idx + 2], alpha); // R - out[idx + 3] = in[idx + 3]; // Alpha - } - } - return retdata; -} - -/** - * _cairo_beos_bitmap_to_surface: - * - * Returns an addrefed image surface for a BBitmap. The bitmap need not outlive - * the surface. - **/ -static cairo_image_surface_t* -_cairo_beos_bitmap_to_surface (BBitmap* bitmap) -{ - color_space format = bitmap->ColorSpace(); - if (format != B_RGB32 && format != B_RGBA32) { - BBitmap bmp(bitmap->Bounds(), B_RGB32, true); - BView view(bitmap->Bounds(), "Cairo bitmap drawing view", - B_FOLLOW_ALL_SIDES, 0); - bmp.AddChild(&view); - - view.LockLooper(); - - view.DrawBitmap(bitmap, BPoint(0.0, 0.0)); - view.Sync(); - - cairo_image_surface_t* imgsurf = _cairo_beos_bitmap_to_surface(&bmp); - - view.UnlockLooper(); - bmp.RemoveChild(&view); - return imgsurf; - } - - cairo_format_t cformat = format == B_RGB32 ? CAIRO_FORMAT_RGB24 - : CAIRO_FORMAT_ARGB32; - - BRect bounds(bitmap->Bounds()); - unsigned char* bits = reinterpret_cast<unsigned char*>(bitmap->Bits()); - int width = bounds.IntegerWidth() + 1; - int height = bounds.IntegerHeight() + 1; - unsigned char* premultiplied; - if (cformat == CAIRO_FORMAT_ARGB32) { - premultiplied = premultiply_rgba(bits, width, height, - bitmap->BytesPerRow()); - } else { - premultiplied = reinterpret_cast<unsigned char*>( - _cairo_malloc_ab(bitmap->BytesPerRow(), height)); - if (premultiplied) - memcpy(premultiplied, bits, bitmap->BytesPerRow() * height); - } - if (!premultiplied) - return NULL; - - cairo_image_surface_t* surf = reinterpret_cast<cairo_image_surface_t*> - (cairo_image_surface_create_for_data(premultiplied, - cformat, - width, - height, - bitmap->BytesPerRow())); - if (surf->base.status) - free(premultiplied); - else - _cairo_image_surface_assume_ownership_of_data(surf); - return surf; -} - -/** - * _cairo_image_surface_to_bitmap: - * - * Converts an image surface to a BBitmap. The return value must be freed with - * delete. - **/ -static BBitmap* -_cairo_image_surface_to_bitmap (cairo_image_surface_t* surface) -{ - BRect size(0.0, 0.0, surface->width - 1, surface->height - 1); - switch (surface->format) { - case CAIRO_FORMAT_ARGB32: { - BBitmap* data = new BBitmap(size, B_RGBA32); - unpremultiply_rgba(surface->data, - surface->width, - surface->height, - surface->stride, - reinterpret_cast<unsigned char*>(data->Bits())); - return data; - } - case CAIRO_FORMAT_RGB24: { - BBitmap* data = new BBitmap(size, B_RGB32); - memcpy(data->Bits(), surface->data, surface->height * surface->stride); - return data; - } - default: - assert(0); - return NULL; - } -} - -/** - * _cairo_op_to_be_op: - * - * Converts a cairo drawing operator to a beos drawing_mode. Returns true if - * the operator could be converted, false otherwise. - **/ -static bool -_cairo_op_to_be_op (cairo_operator_t cairo_op, - drawing_mode* beos_op) -{ - switch (cairo_op) { - - case CAIRO_OPERATOR_SOURCE: - *beos_op = B_OP_COPY; - return true; - case CAIRO_OPERATOR_OVER: - *beos_op = B_OP_ALPHA; - return true; - - case CAIRO_OPERATOR_ADD: - // Does not actually work -#if 1 - return false; -#else - *beos_op = B_OP_ADD; - return true; -#endif - - case CAIRO_OPERATOR_CLEAR: - // Does not map to B_OP_ERASE - it replaces the dest with the low - // color, instead of transparency; could be done by setting low - // color appropriately. - - case CAIRO_OPERATOR_IN: - case CAIRO_OPERATOR_OUT: - case CAIRO_OPERATOR_ATOP: - - case CAIRO_OPERATOR_DEST: - case CAIRO_OPERATOR_DEST_OVER: - case CAIRO_OPERATOR_DEST_IN: - case CAIRO_OPERATOR_DEST_OUT: - case CAIRO_OPERATOR_DEST_ATOP: - - case CAIRO_OPERATOR_XOR: - case CAIRO_OPERATOR_SATURATE: - - default: - return false; - }; -} - -static cairo_surface_t * -_cairo_beos_surface_create_similar (void *abstract_surface, - cairo_content_t content, - int width, - int height) -{ - fprintf(stderr, "Creating similar\n"); - - cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>( - abstract_surface); - - if (width <= 0) - width = 1; - if (height <= 0) - height = 1; - - BRect rect(0.0, 0.0, width - 1, height - 1); - BBitmap* bmp; - switch (content) { - case CAIRO_CONTENT_ALPHA: - // Can't support this natively - return _cairo_image_surface_create_with_content(content, width, - height); - case CAIRO_CONTENT_COLOR_ALPHA: - bmp = new BBitmap(rect, B_RGBA32, true); - break; - case CAIRO_CONTENT_COLOR: - // Match the color depth - if (surface->bitmap) { - color_space space = surface->bitmap->ColorSpace(); - // No alpha was requested -> make sure not to return - // a surface with alpha - if (space == B_RGBA32) - space = B_RGB32; - if (space == B_RGBA15) - space = B_RGB15; - bmp = new BBitmap(rect, space, true); - } else { - BScreen scr(surface->view->Window()); - color_space space = B_RGB32; - if (scr.IsValid()) - space = scr.ColorSpace(); - bmp = new BBitmap(rect, space, true); - } - break; - default: - assert(0); - return NULL; - - }; - BView* view = new BView(rect, "Cairo bitmap view", B_FOLLOW_ALL_SIDES, 0); - bmp->AddChild(view); - return _cairo_beos_surface_create_internal(view, bmp, true); -} - -static cairo_status_t -_cairo_beos_surface_finish (void *abstract_surface) -{ - cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>( - abstract_surface); - if (surface->owns_bitmap_view) { - if (surface->bitmap) - surface->bitmap->RemoveChild(surface->view); - - delete surface->view; - delete surface->bitmap; - - surface->view = NULL; - surface->bitmap = NULL; - } - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_beos_surface_acquire_source_image (void *abstract_surface, - cairo_image_surface_t **image_out, - void **image_extra) -{ - fprintf(stderr, "Getting source image\n"); - cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>( - abstract_surface); - AutoLockView locker(surface->view); - if (!locker) - return CAIRO_STATUS_NO_MEMORY; /// XXX not exactly right, but what can we do? - - - surface->view->Sync(); - - if (surface->bitmap) { - *image_out = _cairo_beos_bitmap_to_surface(surface->bitmap); - if (!*image_out) - return CAIRO_STATUS_NO_MEMORY; - - *image_extra = NULL; - return CAIRO_STATUS_SUCCESS; - } - - BBitmap* bmp; - if (_cairo_beos_view_to_bitmap(surface->view, &bmp) != OK) - return CAIRO_STATUS_NO_MEMORY; /// XXX incorrect if the error was NOT_VISIBLE - - *image_out = _cairo_beos_bitmap_to_surface(bmp); - if (!*image_out) { - delete bmp; - return CAIRO_STATUS_NO_MEMORY; - } - *image_extra = bmp; - - return CAIRO_STATUS_SUCCESS; -} - -static void -_cairo_beos_surface_release_source_image (void *abstract_surface, - cairo_image_surface_t *image, - void *image_extra) -{ - cairo_surface_destroy (&image->base); - - BBitmap* bmp = static_cast<BBitmap*>(image_extra); - delete bmp; -} - - - -static cairo_status_t -_cairo_beos_surface_acquire_dest_image (void *abstract_surface, - cairo_rectangle_int16_t *interest_rect, - cairo_image_surface_t **image_out, - cairo_rectangle_int16_t *image_rect, - void **image_extra) -{ - cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>( - abstract_surface); - - AutoLockView locker(surface->view); - if (!locker) { - *image_out = NULL; - *image_extra = NULL; - return CAIRO_STATUS_SUCCESS; - } - - if (surface->bitmap) { - surface->view->Sync(); - *image_out = _cairo_beos_bitmap_to_surface(surface->bitmap); - if (!*image_out) - return CAIRO_STATUS_NO_MEMORY; - - image_rect->x = 0; - image_rect->y = 0; - image_rect->width = (*image_out)->width; - image_rect->height = (*image_out)->height; - - *image_extra = NULL; - return CAIRO_STATUS_SUCCESS; - } - - BRect b_interest_rect(_cairo_rect_to_brect(interest_rect)); - - BRect rect; - BBitmap* bitmap; - ViewCopyStatus status = _cairo_beos_view_to_bitmap(surface->view, &bitmap, - &rect, &b_interest_rect); - if (status == NOT_VISIBLE) { - *image_out = NULL; - *image_extra = NULL; - return CAIRO_STATUS_SUCCESS; - } - if (status == ERROR) - return CAIRO_STATUS_NO_MEMORY; - - *image_rect = _brect_to_cairo_rect(rect); - -#if 0 - fprintf(stderr, "Requested: (cairo rects) (%ix%i) dim (%u, %u) returning (%ix%i) dim (%u, %u)\n", - interest_rect->x, interest_rect->y, interest_rect->width, interest_rect->height, - image_rect->x, image_rect->y, image_rect->width, image_rect->height); -#endif - - *image_out = _cairo_beos_bitmap_to_surface(bitmap); - delete bitmap; - if (!*image_out) - return CAIRO_STATUS_NO_MEMORY; - - *image_extra = NULL; - - return CAIRO_STATUS_SUCCESS; -} - - -static void -_cairo_beos_surface_release_dest_image (void *abstract_surface, - cairo_rectangle_int16_t *intersect_rect, - cairo_image_surface_t *image, - cairo_rectangle_int16_t *image_rect, - void *image_extra) -{ - fprintf(stderr, "Fallback drawing\n"); - - cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>( - abstract_surface); - - AutoLockView locker(surface->view); - if (!locker) - return; - - BBitmap* bitmap_to_draw = _cairo_image_surface_to_bitmap(image); - surface->view->PushState(); - - surface->view->SetDrawingMode(B_OP_COPY); - BRect rect(_cairo_rect_to_brect(image_rect)); - - surface->view->DrawBitmap(bitmap_to_draw, rect); - - surface->view->PopState(); - - delete bitmap_to_draw; - cairo_surface_destroy(&image->base); -} - -static cairo_int_status_t -_cairo_beos_surface_composite (cairo_operator_t op, - cairo_pattern_t *src, - cairo_pattern_t *mask, - void *dst, - int src_x, - int src_y, - int mask_x, - int mask_y, - int dst_x, - int dst_y, - unsigned int width, - unsigned int height) -{ - cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>( - dst); - AutoLockView locker(surface->view); - if (!locker) - return CAIRO_INT_STATUS_SUCCESS; - - drawing_mode mode; - if (!_cairo_op_to_be_op(op, &mode)) - return CAIRO_INT_STATUS_UNSUPPORTED; - - // XXX Masks are not yet supported - if (mask) - return CAIRO_INT_STATUS_UNSUPPORTED; - - // XXX should eventually support the others - if (src->type != CAIRO_PATTERN_TYPE_SURFACE || - src->extend != CAIRO_EXTEND_NONE) - { - return CAIRO_INT_STATUS_UNSUPPORTED; - } - - // Can we maybe support other matrices as well? (scale? if the filter is right) - int itx, ity; - if (!_cairo_matrix_is_integer_translation(&src->matrix, &itx, &ity)) - return CAIRO_INT_STATUS_UNSUPPORTED; - - BRect srcRect(src_x + itx, - src_y + ity, - src_x + itx + width - 1, - src_y + ity + height - 1); - BRect dstRect(dst_x, dst_y, dst_x + width - 1, dst_y + height - 1); - - cairo_surface_t* src_surface = reinterpret_cast<cairo_surface_pattern_t*>(src)-> - surface; - - // Get a bitmap - BBitmap* bmp = NULL; - bool free_bmp = false; - if (_cairo_surface_is_image(src_surface)) { - cairo_image_surface_t* img_surface = - reinterpret_cast<cairo_image_surface_t*>(src_surface); - - bmp = _cairo_image_surface_to_bitmap(img_surface); - free_bmp = true; - } else if (src_surface->backend == surface->base.backend) { - cairo_beos_surface_t *beos_surface = - reinterpret_cast<cairo_beos_surface_t*>(src_surface); - if (beos_surface->bitmap) { - AutoLockView locker(beos_surface->view); - if (locker) - beos_surface->view->Sync(); - bmp = beos_surface->bitmap; - } else { - _cairo_beos_view_to_bitmap(surface->view, &bmp); - free_bmp = true; - } - } - - if (!bmp) - return CAIRO_INT_STATUS_UNSUPPORTED; - - // So, BeOS seems to screw up painting an opaque bitmap onto a - // translucent one (it makes them partly transparent). Just return - // unsupported. - if (bmp->ColorSpace() == B_RGB32 && surface->bitmap && - surface->bitmap->ColorSpace() == B_RGBA32 && - (mode == B_OP_COPY || mode == B_OP_ALPHA)) - { - if (free_bmp) - delete bmp; - return CAIRO_INT_STATUS_UNSUPPORTED; - } - - fprintf(stderr, "Composite\n"); - - // Draw it on screen. - surface->view->PushState(); - - // If our image rect is only a subrect of the desired size, and we - // aren't using B_OP_ALPHA, then we need to fill the rect first. - if (mode == B_OP_COPY && !bmp->Bounds().Contains(srcRect)) { - rgb_color black = { 0, 0, 0, 0 }; - - surface->view->SetDrawingMode(mode); - surface->view->SetHighColor(black); - surface->view->FillRect(dstRect); - } - - if (mode == B_OP_ALPHA && bmp->ColorSpace() == B_RGB32) { - mode = B_OP_COPY; - } - surface->view->SetDrawingMode(mode); - - if (surface->bitmap && surface->bitmap->ColorSpace() == B_RGBA32) - surface->view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); - else - surface->view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); - - surface->view->DrawBitmap(bmp, srcRect, dstRect); - - surface->view->PopState(); - - if (free_bmp) - delete bmp; - - return CAIRO_INT_STATUS_SUCCESS; -} - - -static void -_cairo_beos_surface_fill_rectangle (cairo_beos_surface_t *surface, - cairo_rectangle_int16_t *rect) -{ - BRect brect(_cairo_rect_to_brect(rect)); - surface->view->FillRect(brect); -} - -static cairo_int_status_t -_cairo_beos_surface_fill_rectangles (void *abstract_surface, - cairo_operator_t op, - const cairo_color_t *color, - cairo_rectangle_int16_t *rects, - int num_rects) -{ - fprintf(stderr, "Drawing %i rectangles\n", num_rects); - cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>( - abstract_surface); - - if (num_rects <= 0) - return CAIRO_INT_STATUS_SUCCESS; - - AutoLockView locker(surface->view); - if (!locker) - return CAIRO_INT_STATUS_SUCCESS; - - drawing_mode mode; - if (!_cairo_op_to_be_op(op, &mode)) - return CAIRO_INT_STATUS_UNSUPPORTED; - - rgb_color be_color = _cairo_color_to_be_color(color); - - if (mode == B_OP_ALPHA && be_color.alpha == 0xFF) - mode = B_OP_COPY; - - // For CAIRO_OPERATOR_SOURCE, cairo expects us to use the premultiplied - // color info. This is only relevant when drawing into an rgb24 buffer - // (as for others, we can convert when asked for the image) - if (mode == B_OP_COPY && be_color.alpha != 0xFF && - (!surface->bitmap || surface->bitmap->ColorSpace() != B_RGBA32)) - { - be_color.red = premultiply(be_color.red, be_color.alpha); - be_color.green = premultiply(be_color.green, be_color.alpha); - be_color.blue = premultiply(be_color.blue, be_color.alpha); - } - - surface->view->PushState(); - - surface->view->SetDrawingMode(mode); - surface->view->SetHighColor(be_color); - if (surface->bitmap && surface->bitmap->ColorSpace() == B_RGBA32) - surface->view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE); - else - surface->view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); - - for (int i = 0; i < num_rects; ++i) { - _cairo_beos_surface_fill_rectangle(surface, &rects[i]); - } - - surface->view->PopState(); - - return CAIRO_INT_STATUS_SUCCESS; -} - - - -static cairo_int_status_t -_cairo_beos_surface_set_clip_region (void *abstract_surface, - pixman_region16_t *region) -{ - fprintf(stderr, "Setting clip region\n"); - cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>( - abstract_surface); - AutoLockView locker(surface->view); - if (!locker) - return CAIRO_INT_STATUS_SUCCESS; - - if (region == NULL) { - // No clipping - surface->view->ConstrainClippingRegion(NULL); - return CAIRO_INT_STATUS_SUCCESS; - } - - int count = pixman_region_num_rects(region); - pixman_box16_t* rects = pixman_region_rects(region); - BRegion bregion; - for (int i = 0; i < count; ++i) { - // Have to substract one, because for pixman, the second coordinate - // lies outside the rectangle. - bregion.Include(BRect(rects[i].x1, rects[i].y1, rects[i].x2 - 1, rects[i].y2 - 1)); - } - surface->view->ConstrainClippingRegion(&bregion); - return CAIRO_INT_STATUS_SUCCESS; -} - -static cairo_int_status_t -_cairo_beos_surface_get_extents (void *abstract_surface, - cairo_rectangle_int16_t *rectangle) -{ - cairo_beos_surface_t *surface = reinterpret_cast<cairo_beos_surface_t*>( - abstract_surface); - AutoLockView locker(surface->view); - if (!locker) - return CAIRO_INT_STATUS_UNSUPPORTED; - - BRect size = surface->view->Bounds(); - - *rectangle = _brect_to_cairo_rect(size); - - // Make sure to have our upperleft edge as (0,0) - rectangle->x = 0; - rectangle->y = 0; - - return CAIRO_INT_STATUS_SUCCESS; -} - -static const struct _cairo_surface_backend cairo_beos_surface_backend = { - CAIRO_SURFACE_TYPE_BEOS, - _cairo_beos_surface_create_similar, - _cairo_beos_surface_finish, - _cairo_beos_surface_acquire_source_image, - _cairo_beos_surface_release_source_image, - _cairo_beos_surface_acquire_dest_image, - _cairo_beos_surface_release_dest_image, - NULL, /* clone_similar */ - _cairo_beos_surface_composite, /* composite */ - _cairo_beos_surface_fill_rectangles, - NULL, /* composite_trapezoids */ - NULL, /* create_span_renderer */ - NULL, /* check_span_renderer */ - NULL, /* copy_page */ - NULL, /* show_page */ - _cairo_beos_surface_set_clip_region, - NULL, /* intersect_clip_path */ - _cairo_beos_surface_get_extents, - NULL, /* old_show_glyphs */ - NULL, /* get_font_options */ - NULL, /* flush */ - NULL, /* mark_dirty_rectangle */ - NULL, /* scaled_font_fini */ - NULL, /* scaled_glyph_fini */ - - NULL, /* paint */ - NULL, /* mask */ - NULL, /* stroke */ - NULL, /* fill */ - NULL /* show_glyphs */ -}; - -static cairo_surface_t * -_cairo_beos_surface_create_internal (BView* view, - BBitmap* bmp, - bool owns_bitmap_view) -{ - // Must use malloc, because cairo code will use free() on the surface - cairo_beos_surface_t *surface = static_cast<cairo_beos_surface_t*>( - malloc(sizeof(cairo_beos_surface_t))); - if (surface == NULL) { - _cairo_error (CAIRO_STATUS_NO_MEMORY); - return const_cast<cairo_surface_t*>(&_cairo_surface_nil); - } - - cairo_content_t content = CAIRO_CONTENT_COLOR; - if (bmp && (bmp->ColorSpace() == B_RGBA32 || bmp->ColorSpace() == B_RGBA15)) - content = CAIRO_CONTENT_COLOR_ALPHA; - _cairo_surface_init(&surface->base, &cairo_beos_surface_backend, content); - - surface->view = view; - surface->bitmap = bmp; - surface->owns_bitmap_view = owns_bitmap_view; - - return (cairo_surface_t *) surface; -} - -/** - * cairo_beos_surface_create: - * @view: The view to draw on - * - * Creates a Cairo surface that draws onto a BeOS BView. - * The caller must ensure that the view does not get deleted before the surface. - * If the view is attached to a bitmap rather than an on-screen window, use - * cairo_beos_surface_create_for_bitmap() instead of this function. - **/ -cairo_surface_t * -cairo_beos_surface_create (BView* view) -{ - return cairo_beos_surface_create_for_bitmap(view, NULL); -} - -/** - * cairo_beos_surface_create_for_bitmap: - * @view: The view to draw on - * @bmp: The bitmap to which the view is attached - * - * Creates a Cairo surface that draws onto a BeOS BView which is attached to a - * BBitmap. - * The caller must ensure that the view and the bitmap do not get deleted - * before the surface. - * - * For views that draw to a bitmap (as opposed to a screen), use this function - * rather than cairo_beos_surface_create(). Not using this function WILL lead to - * incorrect behaviour. - * - * For now, only views that draw to the entire area of bmp are supported. - * The view must already be attached to the bitmap. - **/ -cairo_surface_t * -cairo_beos_surface_create_for_bitmap (BView* view, - BBitmap* bmp) -{ - return _cairo_beos_surface_create_internal(view, bmp); -} diff --git a/libs/cairo/cairo/src/cairo-beos.h b/libs/cairo/cairo/src/cairo-beos.h deleted file mode 100644 index 375c930cc..000000000 --- a/libs/cairo/cairo/src/cairo-beos.h +++ /dev/null @@ -1,29 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef CAIRO_BEOS_H -#define CAIRO_BEOS_H - -#include "cairo.h" - -#if CAIRO_HAS_BEOS_SURFACE - -#include <View.h> - -CAIRO_BEGIN_DECLS - -cairo_public cairo_surface_t * -cairo_beos_surface_create (BView* view); - -cairo_public cairo_surface_t * -cairo_beos_surface_create_for_bitmap (BView* view, - BBitmap* bmp); - -CAIRO_END_DECLS - -#else /* CAIRO_HAS_BEOS_SURFACE */ -# error Cairo was not compiled with support for the beos backend -#endif /* CAIRO_HAS_BEOS_SURFACE */ - -#endif /* CAIRO_BEOS_H */ diff --git a/libs/cairo/cairo/src/cairo-qt-surface.cpp b/libs/cairo/cairo/src/cairo-qt-surface.cpp deleted file mode 100644 index 9d73395b7..000000000 --- a/libs/cairo/cairo/src/cairo-qt-surface.cpp +++ /dev/null @@ -1,1716 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Get INT16_MIN etc. as per C99 */ -#define __STDC_LIMIT_MACROS - -#include "cairoint.h" -#include "cairo-types-private.h" -#include "cairo-clip-private.h" -#include "cairo-surface-clipper-private.h" -#include "cairo-region-private.h" - -#include "cairo-ft.h" -#include "cairo-qt.h" -#include "cairo-error-private.h" - -#include <memory> - -#include <QtGui/QPainter> -#include <QtGui/QPaintEngine> -#include <QtGui/QPaintDevice> -#include <QtGui/QImage> -#include <QtGui/QPixmap> -#include <QtGui/QBrush> -#include <QtGui/QPen> -#include <QtCore/QVarLengthArray> - -#include <sys/time.h> - -/* Enable workaround slow regional Qt paths */ -#define ENABLE_FAST_FILL 0 -#define ENABLE_FAST_CLIP 0 - -#if 0 -#define D(x) x -static const char * -_opstr (cairo_operator_t op) -{ - const char *ops[] = { - "CLEAR", - "SOURCE", - "OVER", - "IN", - "OUT", - "ATOP", - "DEST", - "DEST_OVER", - "DEST_IN", - "DEST_OUT", - "DEST_ATOP", - "XOR", - "ADD", - "SATURATE" - }; - - if (op < CAIRO_OPERATOR_CLEAR || op > CAIRO_OPERATOR_SATURATE) - return "(\?\?\?)"; - - return ops[op]; -} -#else -#define D(x) do { } while(0) -#endif - -#ifndef CAIRO_INT_STATUS_SUCCESS -#define CAIRO_INT_STATUS_SUCCESS ((cairo_int_status_t) CAIRO_STATUS_SUCCESS) -#endif - -/* Qt::PenStyle optimization based on the assumption that dots are 1*w and dashes are 3*w. */ -#define DOT_LENGTH 1.0 -#define DASH_LENGTH 3.0 - -struct cairo_qt_surface_t { - cairo_surface_t base; - - cairo_bool_t supports_porter_duff; - - QPainter *p; - - /* The pixmap/image constructors will store their objects here */ - QPixmap *pixmap; - QImage *image; - - QRect window; - - cairo_surface_clipper_t clipper; - - cairo_surface_t *image_equiv; -}; - -/* Will be true if we ever try to create a QPixmap and end - * up with one without an alpha channel. - */ -static cairo_bool_t _qpixmaps_have_no_alpha = FALSE; - -/** - ** Helper methods - **/ - -static QPainter::CompositionMode -_qpainter_compositionmode_from_cairo_op (cairo_operator_t op) -{ - switch (op) { - case CAIRO_OPERATOR_CLEAR: - return QPainter::CompositionMode_Clear; - - case CAIRO_OPERATOR_SOURCE: - return QPainter::CompositionMode_Source; - case CAIRO_OPERATOR_OVER: - return QPainter::CompositionMode_SourceOver; - case CAIRO_OPERATOR_IN: - return QPainter::CompositionMode_SourceIn; - case CAIRO_OPERATOR_OUT: - return QPainter::CompositionMode_SourceOut; - case CAIRO_OPERATOR_ATOP: - return QPainter::CompositionMode_SourceAtop; - - case CAIRO_OPERATOR_DEST: - return QPainter::CompositionMode_Destination; - case CAIRO_OPERATOR_DEST_OVER: - return QPainter::CompositionMode_DestinationOver; - case CAIRO_OPERATOR_DEST_IN: - return QPainter::CompositionMode_DestinationIn; - case CAIRO_OPERATOR_DEST_OUT: - return QPainter::CompositionMode_DestinationOut; - case CAIRO_OPERATOR_DEST_ATOP: - return QPainter::CompositionMode_DestinationAtop; - - case CAIRO_OPERATOR_XOR: - return QPainter::CompositionMode_Xor; - - default: - case CAIRO_OPERATOR_ADD: - case CAIRO_OPERATOR_SATURATE: - case CAIRO_OPERATOR_MULTIPLY: - case CAIRO_OPERATOR_SCREEN: - case CAIRO_OPERATOR_OVERLAY: - case CAIRO_OPERATOR_DARKEN: - case CAIRO_OPERATOR_LIGHTEN: - case CAIRO_OPERATOR_COLOR_DODGE: - case CAIRO_OPERATOR_COLOR_BURN: - case CAIRO_OPERATOR_HARD_LIGHT: - case CAIRO_OPERATOR_SOFT_LIGHT: - case CAIRO_OPERATOR_DIFFERENCE: - case CAIRO_OPERATOR_EXCLUSION: - case CAIRO_OPERATOR_HSL_HUE: - case CAIRO_OPERATOR_HSL_SATURATION: - case CAIRO_OPERATOR_HSL_COLOR: - case CAIRO_OPERATOR_HSL_LUMINOSITY: - ASSERT_NOT_REACHED; - } - return QPainter::CompositionMode_Source; -} - -static bool -_op_is_supported (cairo_qt_surface_t *qs, cairo_operator_t op) -{ - if (qs->supports_porter_duff) { - switch (op) { - case CAIRO_OPERATOR_CLEAR: - case CAIRO_OPERATOR_SOURCE: - case CAIRO_OPERATOR_OVER: - case CAIRO_OPERATOR_IN: - case CAIRO_OPERATOR_OUT: - case CAIRO_OPERATOR_ATOP: - - case CAIRO_OPERATOR_DEST: - case CAIRO_OPERATOR_DEST_OVER: - case CAIRO_OPERATOR_DEST_IN: - case CAIRO_OPERATOR_DEST_OUT: - case CAIRO_OPERATOR_DEST_ATOP: - - case CAIRO_OPERATOR_XOR: - return TRUE; - - default: - ASSERT_NOT_REACHED; - case CAIRO_OPERATOR_ADD: - case CAIRO_OPERATOR_SATURATE: - case CAIRO_OPERATOR_MULTIPLY: - case CAIRO_OPERATOR_SCREEN: - case CAIRO_OPERATOR_OVERLAY: - case CAIRO_OPERATOR_DARKEN: - case CAIRO_OPERATOR_LIGHTEN: - case CAIRO_OPERATOR_COLOR_DODGE: - case CAIRO_OPERATOR_COLOR_BURN: - case CAIRO_OPERATOR_HARD_LIGHT: - case CAIRO_OPERATOR_SOFT_LIGHT: - case CAIRO_OPERATOR_DIFFERENCE: - case CAIRO_OPERATOR_EXCLUSION: - case CAIRO_OPERATOR_HSL_HUE: - case CAIRO_OPERATOR_HSL_SATURATION: - case CAIRO_OPERATOR_HSL_COLOR: - case CAIRO_OPERATOR_HSL_LUMINOSITY: - return FALSE; - - } - } else { - return op == CAIRO_OPERATOR_OVER; - } -} - -static cairo_format_t -_cairo_format_from_qimage_format (QImage::Format fmt) -{ - switch (fmt) { - case QImage::Format_ARGB32_Premultiplied: - return CAIRO_FORMAT_ARGB32; - case QImage::Format_RGB32: - return CAIRO_FORMAT_RGB24; - case QImage::Format_Indexed8: // XXX not quite - return CAIRO_FORMAT_A8; -#ifdef WORDS_BIGENDIAN - case QImage::Format_Mono: -#else - case QImage::Format_MonoLSB: -#endif - return CAIRO_FORMAT_A1; - - case QImage::Format_Invalid: -#ifdef WORDS_BIGENDIAN - case QImage::Format_MonoLSB: -#else - case QImage::Format_Mono: -#endif - case QImage::Format_ARGB32: - case QImage::Format_RGB16: - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_RGB666: - case QImage::Format_ARGB6666_Premultiplied: - case QImage::Format_RGB555: - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_RGB888: - case QImage::Format_RGB444: - case QImage::Format_ARGB4444_Premultiplied: - case QImage::NImageFormats: - default: - ASSERT_NOT_REACHED; - return (cairo_format_t) -1; - } -} - -static QImage::Format -_qimage_format_from_cairo_format (cairo_format_t fmt) -{ - switch (fmt) { - case CAIRO_FORMAT_ARGB32: - return QImage::Format_ARGB32_Premultiplied; - case CAIRO_FORMAT_RGB24: - return QImage::Format_RGB32; - case CAIRO_FORMAT_A8: - return QImage::Format_Indexed8; // XXX not quite - case CAIRO_FORMAT_A1: -#ifdef WORDS_BIGENDIAN - return QImage::Format_Mono; // XXX think we need to choose between this and LSB -#else - return QImage::Format_MonoLSB; -#endif - } - - return QImage::Format_Mono; -} - -static inline QMatrix -_qmatrix_from_cairo_matrix (const cairo_matrix_t& m) -{ - return QMatrix(m.xx, m.yx, m.xy, m.yy, m.x0, m.y0); -} - -/** Path conversion **/ -typedef struct _qpainter_path_transform { - QPainterPath path; - const cairo_matrix_t *ctm_inverse; -} qpainter_path_data; - -/* cairo path -> execute in context */ -static cairo_status_t -_cairo_path_to_qpainterpath_move_to (void *closure, const cairo_point_t *point) -{ - qpainter_path_data *pdata = static_cast <qpainter_path_data *> (closure); - double x = _cairo_fixed_to_double (point->x); - double y = _cairo_fixed_to_double (point->y); - - if (pdata->ctm_inverse) - cairo_matrix_transform_point (pdata->ctm_inverse, &x, &y); - - pdata->path.moveTo(x, y); - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_path_to_qpainterpath_line_to (void *closure, const cairo_point_t *point) -{ - qpainter_path_data *pdata = static_cast <qpainter_path_data *> (closure); - double x = _cairo_fixed_to_double (point->x); - double y = _cairo_fixed_to_double (point->y); - - if (pdata->ctm_inverse) - cairo_matrix_transform_point (pdata->ctm_inverse, &x, &y); - - pdata->path.lineTo(x, y); - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_path_to_qpainterpath_curve_to (void *closure, const cairo_point_t *p0, const cairo_point_t *p1, const cairo_point_t *p2) -{ - qpainter_path_data *pdata = static_cast <qpainter_path_data *> (closure); - double x0 = _cairo_fixed_to_double (p0->x); - double y0 = _cairo_fixed_to_double (p0->y); - double x1 = _cairo_fixed_to_double (p1->x); - double y1 = _cairo_fixed_to_double (p1->y); - double x2 = _cairo_fixed_to_double (p2->x); - double y2 = _cairo_fixed_to_double (p2->y); - - if (pdata->ctm_inverse) { - cairo_matrix_transform_point (pdata->ctm_inverse, &x0, &y0); - cairo_matrix_transform_point (pdata->ctm_inverse, &x1, &y1); - cairo_matrix_transform_point (pdata->ctm_inverse, &x2, &y2); - } - - pdata->path.cubicTo (x0, y0, x1, y1, x2, y2); - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_path_to_qpainterpath_close_path (void *closure) -{ - qpainter_path_data *pdata = static_cast <qpainter_path_data *> (closure); - - pdata->path.closeSubpath(); - - return CAIRO_STATUS_SUCCESS; -} - -static inline QPainterPath -path_to_qt (cairo_path_fixed_t *path, - const cairo_matrix_t *ctm_inverse = NULL) -{ - qpainter_path_data data; - cairo_status_t status; - - if (ctm_inverse && _cairo_matrix_is_identity (ctm_inverse)) - ctm_inverse = NULL; - data.ctm_inverse = ctm_inverse; - - status = _cairo_path_fixed_interpret (path, - CAIRO_DIRECTION_FORWARD, - _cairo_path_to_qpainterpath_move_to, - _cairo_path_to_qpainterpath_line_to, - _cairo_path_to_qpainterpath_curve_to, - _cairo_path_to_qpainterpath_close_path, - &data); - assert (status == CAIRO_STATUS_SUCCESS); - - return data.path; -} - -static inline QPainterPath -path_to_qt (cairo_path_fixed_t *path, - cairo_fill_rule_t fill_rule, - cairo_matrix_t *ctm_inverse = NULL) -{ - QPainterPath qpath = path_to_qt (path, ctm_inverse); - - qpath.setFillRule (fill_rule == CAIRO_FILL_RULE_WINDING ? - Qt::WindingFill : - Qt::OddEvenFill); - - return qpath; -} - -/** - ** Surface backend methods - **/ -static cairo_surface_t * -_cairo_qt_surface_create_similar (void *abstract_surface, - cairo_content_t content, - int width, - int height) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - bool use_pixmap; - - D(fprintf(stderr, "q[%p] create_similar: %d %d [%d] -> ", abstract_surface, width, height, content)); - - use_pixmap = qs->image == NULL; - if (use_pixmap) { - switch (content) { - case CAIRO_CONTENT_ALPHA: - use_pixmap = FALSE; - break; - case CAIRO_CONTENT_COLOR: - break; - case CAIRO_CONTENT_COLOR_ALPHA: - use_pixmap = ! _qpixmaps_have_no_alpha; - break; - } - } - - if (use_pixmap) { - cairo_surface_t *result = - cairo_qt_surface_create_with_qpixmap (content, width, height); - - /* XXX result->content is always content. ??? */ - if (result->content == content) { - D(fprintf(stderr, "qpixmap content: %d\n", content)); - return result; - } - - _qpixmaps_have_no_alpha = TRUE; - cairo_surface_destroy (result); - } - - D(fprintf (stderr, "qimage\n")); - return cairo_qt_surface_create_with_qimage - (_cairo_format_from_content (content), width, height); -} - -static cairo_status_t -_cairo_qt_surface_finish (void *abstract_surface) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - - D(fprintf(stderr, "q[%p] finish\n", abstract_surface)); - - /* Only delete p if we created it */ - if (qs->image || qs->pixmap) - delete qs->p; - else if (qs->p) - qs->p->restore (); - - if (qs->image_equiv) - cairo_surface_destroy (qs->image_equiv); - - _cairo_surface_clipper_reset (&qs->clipper); - - if (qs->image) - delete qs->image; - - if (qs->pixmap) - delete qs->pixmap; - - return CAIRO_STATUS_SUCCESS; -} - -static void -_qimg_destroy (void *closure) -{ - QImage *qimg = (QImage *) closure; - delete qimg; -} - -static cairo_status_t -_cairo_qt_surface_acquire_source_image (void *abstract_surface, - cairo_image_surface_t **image_out, - void **image_extra) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - - D(fprintf(stderr, "q[%p] acquire_source_image\n", abstract_surface)); - - *image_extra = NULL; - - if (qs->image_equiv) { - *image_out = (cairo_image_surface_t*) - cairo_surface_reference (qs->image_equiv); - - return CAIRO_STATUS_SUCCESS; - } - - if (qs->pixmap) { - QImage *qimg = new QImage(qs->pixmap->toImage()); - cairo_surface_t *image; - cairo_status_t status; - - image = cairo_image_surface_create_for_data (qimg->bits(), - _cairo_format_from_qimage_format (qimg->format()), - qimg->width(), qimg->height(), - qimg->bytesPerLine()); - - status = _cairo_user_data_array_set_data (&image->user_data, - (const cairo_user_data_key_t *)&_qimg_destroy, - qimg, - _qimg_destroy); - if (status) { - cairo_surface_destroy (image); - return status; - } - - *image_out = (cairo_image_surface_t *) image; - return CAIRO_STATUS_SUCCESS; - } - - return _cairo_error (CAIRO_STATUS_NO_MEMORY); -} - -static void -_cairo_qt_surface_release_source_image (void *abstract_surface, - cairo_image_surface_t *image, - void *image_extra) -{ - //cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - - D(fprintf(stderr, "q[%p] release_source_image\n", abstract_surface)); - - cairo_surface_destroy (&image->base); -} - -static cairo_status_t -_cairo_qt_surface_acquire_dest_image (void *abstract_surface, - cairo_rectangle_int_t *interest_rect, - cairo_image_surface_t **image_out, - cairo_rectangle_int_t *image_rect, - void **image_extra) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - QImage *qimg = NULL; - - D(fprintf(stderr, "q[%p] acquire_dest_image\n", abstract_surface)); - - *image_extra = NULL; - - if (qs->image_equiv) { - *image_out = (cairo_image_surface_t*) - cairo_surface_reference (qs->image_equiv); - - image_rect->x = qs->window.x(); - image_rect->y = qs->window.y(); - image_rect->width = qs->window.width(); - image_rect->height = qs->window.height(); - - return CAIRO_STATUS_SUCCESS; - } - - QPoint offset; - - if (qs->pixmap) { - qimg = new QImage(qs->pixmap->toImage()); - } else { - // Try to figure out what kind of QPaintDevice we have, and - // how we can grab an image from it - QPaintDevice *pd = qs->p->device(); - if (!pd) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - - QPaintDevice *rpd = QPainter::redirected(pd, &offset); - if (rpd) - pd = rpd; - - if (pd->devType() == QInternal::Image) { - qimg = new QImage(((QImage*) pd)->copy()); - } else if (pd->devType() == QInternal::Pixmap) { - qimg = new QImage(((QPixmap*) pd)->toImage()); - } - } - - if (qimg == NULL) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - - *image_out = (cairo_image_surface_t*) - cairo_image_surface_create_for_data (qimg->bits(), - _cairo_format_from_qimage_format (qimg->format()), - qimg->width(), qimg->height(), - qimg->bytesPerLine()); - *image_extra = qimg; - - image_rect->x = qs->window.x() + offset.x(); - image_rect->y = qs->window.y() + offset.y(); - image_rect->width = qs->window.width() - offset.x(); - image_rect->height = qs->window.height() - offset.y(); - - return CAIRO_STATUS_SUCCESS; -} - -static void -_cairo_qt_surface_release_dest_image (void *abstract_surface, - cairo_rectangle_int_t *interest_rect, - cairo_image_surface_t *image, - cairo_rectangle_int_t *image_rect, - void *image_extra) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - D(fprintf(stderr, "q[%p] release_dest_image\n", abstract_surface)); - - cairo_surface_destroy (&image->base); - - if (image_extra) { - QImage *qimg = (QImage*) image_extra; - - // XXX should I be using setBackgroundMode here instead of setCompositionMode? - if (qs->supports_porter_duff) - qs->p->setCompositionMode (QPainter::CompositionMode_Source); - - qs->p->drawImage (image_rect->x, image_rect->y, *qimg); - - if (qs->supports_porter_duff) - qs->p->setCompositionMode (QPainter::CompositionMode_SourceOver); - - delete qimg; - } -} - -static cairo_status_t -_cairo_qt_surface_clone_similar (void *abstract_surface, - cairo_surface_t *src, - int src_x, - int src_y, - int width, - int height, - int *clone_offset_x, - int *clone_offset_y, - cairo_surface_t **clone_out) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - - if (src->backend == qs->base.backend) { - *clone_offset_x = 0; - *clone_offset_y = 0; - *clone_out = cairo_surface_reference (src); - return CAIRO_STATUS_SUCCESS; - } - - return (cairo_status_t) CAIRO_INT_STATUS_UNSUPPORTED; -} - -static cairo_bool_t -_cairo_qt_surface_get_extents (void *abstract_surface, - cairo_rectangle_int_t *extents) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - - extents->x = qs->window.x(); - extents->y = qs->window.y(); - extents->width = qs->window.width(); - extents->height = qs->window.height(); - - return TRUE; -} - -static cairo_status_t -_cairo_qt_surface_clipper_intersect_clip_path (cairo_surface_clipper_t *clipper, - cairo_path_fixed_t *path, - cairo_fill_rule_t fill_rule, - double tolerance, - cairo_antialias_t antialias) -{ - cairo_qt_surface_t *qs = cairo_container_of (clipper, - cairo_qt_surface_t, - clipper); - - if (path == NULL) { - if (qs->pixmap || qs->image) { - // we own p - qs->p->setClipping (false); - } else { - qs->p->restore (); - qs->p->save (); - } - } else { - // XXX Antialiasing is ignored - qs->p->setClipPath (path_to_qt (path, fill_rule), Qt::IntersectClip); - } - - return CAIRO_STATUS_SUCCESS; -} - -static void -_cairo_qt_surface_set_clip_region (cairo_qt_surface_t *qs, - cairo_region_t *clip_region) -{ - _cairo_surface_clipper_reset (&qs->clipper); - - if (clip_region == NULL) { - // How the clip path is reset depends on whether we own p or not - if (qs->pixmap || qs->image) { - // we own p - qs->p->setClipping (false); - } else { - qs->p->restore (); - qs->p->save (); - } - } else { - QRegion qr; - int num_rects = cairo_region_num_rectangles (clip_region); - for (int i = 0; i < num_rects; ++i) { - cairo_rectangle_int_t rect; - - cairo_region_get_rectangle (clip_region, i, &rect); - - QRect r(rect.x, rect.y, rect.width, rect.height); - qr = qr.united(r); - } - - qs->p->setClipRegion (qr, Qt::IntersectClip); - } -} - -static cairo_int_status_t -_cairo_qt_surface_set_clip (cairo_qt_surface_t *qs, - cairo_clip_t *clip) -{ - cairo_int_status_t status; - - D(fprintf(stderr, "q[%p] intersect_clip_path %s\n", qs, clip ? "(path)" : "(clear)")); - - if (clip == NULL) { - _cairo_surface_clipper_reset (&qs->clipper); - // How the clip path is reset depends on whether we own p or not - if (qs->pixmap || qs->image) { - // we own p - qs->p->setClipping (false); - } else { - qs->p->restore (); - qs->p->save (); - } - - return CAIRO_INT_STATUS_SUCCESS; - } - -#if ENABLE_FAST_CLIP - // Qt will implicitly enable clipping, and will use ReplaceClip - // instead of IntersectClip if clipping was disabled before - - // Note: Qt is really bad at dealing with clip paths. It doesn't - // seem to usefully recognize rectangular paths, instead going down - // extremely slow paths whenever a clip path is set. So, - // we do a bunch of work here to try to get rectangles or regions - // down to Qt for clipping. - - cairo_region_t *clip_region = NULL; - - status = _cairo_clip_get_region (clip, &clip_region); - if (status == CAIRO_INT_STATUS_UNSUPPORTED) { - // We weren't able to extract a region from the traps. - // Just hand the path down to QPainter. - status = (cairo_int_status_t) - _cairo_surface_clipper_set_clip (&qs->clipper, clip); - } else if (status == CAIRO_INT_STATUS_SUCCESS) { - _cairo_qt_surface_set_clip_region (qs, clip_region); - status = CAIRO_INT_STATUS_SUCCESS; - } -#else - status = (cairo_int_status_t) - _cairo_surface_clipper_set_clip (&qs->clipper, clip); -#endif - - return status; -} - -/** - ** Brush conversion - **/ - -struct PatternToBrushConverter { - PatternToBrushConverter (const cairo_pattern_t *pattern) : - mAcquiredImageParent(0), - mAcquiredImage(0), - mAcquiredImageExtra(0) - { - if (pattern->type == CAIRO_PATTERN_TYPE_SOLID) { - cairo_solid_pattern_t *solid = (cairo_solid_pattern_t*) pattern; - QColor color; - color.setRgbF(solid->color.red, - solid->color.green, - solid->color.blue, - solid->color.alpha); - - mBrush = QBrush(color); - } else if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE) { - cairo_surface_pattern_t *spattern = (cairo_surface_pattern_t*) pattern; - cairo_surface_t *surface = spattern->surface; - - if (surface->type == CAIRO_SURFACE_TYPE_QT) { - cairo_qt_surface_t *qs = (cairo_qt_surface_t*) surface; - - if (qs->image) { - mBrush = QBrush(*qs->image); - } else if (qs->pixmap) { - mBrush = QBrush(*qs->pixmap); - } else { - // do something smart - mBrush = QBrush(0xff0000ff); - } - } else { - cairo_image_surface_t *isurf = NULL; - - if (surface->type == CAIRO_SURFACE_TYPE_IMAGE) { - isurf = (cairo_image_surface_t*) surface; - } else { - void *image_extra; - - if (_cairo_surface_acquire_source_image (surface, &isurf, &image_extra) == CAIRO_STATUS_SUCCESS) { - mAcquiredImageParent = surface; - mAcquiredImage = isurf; - mAcquiredImageExtra = image_extra; - } else { - isurf = NULL; - } - } - - if (isurf) { - mBrush = QBrush (QImage ((const uchar *) isurf->data, - isurf->width, - isurf->height, - isurf->stride, - _qimage_format_from_cairo_format (isurf->format))); - } else { - mBrush = QBrush(0x0000ffff); - } - } - } else if (pattern->type == CAIRO_PATTERN_TYPE_LINEAR || - pattern->type == CAIRO_PATTERN_TYPE_RADIAL) - { - QGradient *grad; - cairo_bool_t reverse_stops = FALSE; - cairo_bool_t emulate_reflect = FALSE; - double offset = 0.0; - - cairo_extend_t extend = pattern->extend; - - cairo_gradient_pattern_t *gpat = (cairo_gradient_pattern_t *) pattern; - - if (pattern->type == CAIRO_PATTERN_TYPE_LINEAR) { - cairo_linear_pattern_t *lpat = (cairo_linear_pattern_t *) pattern; - grad = new QLinearGradient (_cairo_fixed_to_double (lpat->p1.x), - _cairo_fixed_to_double (lpat->p1.y), - _cairo_fixed_to_double (lpat->p2.x), - _cairo_fixed_to_double (lpat->p2.y)); - } else if (pattern->type == CAIRO_PATTERN_TYPE_RADIAL) { - cairo_radial_pattern_t *rpat = (cairo_radial_pattern_t *) pattern; - - /* Based on the SVG surface code */ - - cairo_point_t *c0, *c1; - cairo_fixed_t radius0, radius1; - - if (rpat->r1 < rpat->r2) { - c0 = &rpat->c1; - c1 = &rpat->c2; - radius0 = rpat->r1; - radius1 = rpat->r2; - reverse_stops = FALSE; - } else { - c0 = &rpat->c2; - c1 = &rpat->c1; - radius0 = rpat->r2; - radius1 = rpat->r1; - reverse_stops = TRUE; - } - - double x0 = _cairo_fixed_to_double (c0->x); - double y0 = _cairo_fixed_to_double (c0->y); - double r0 = _cairo_fixed_to_double (radius0); - double x1 = _cairo_fixed_to_double (c1->x); - double y1 = _cairo_fixed_to_double (c1->y); - double r1 = _cairo_fixed_to_double (radius1); - - if (rpat->r1 == rpat->r2) { - grad = new QRadialGradient (x1, y1, r1, x1, y1); - } else { - double fx = (r1 * x0 - r0 * x1) / (r1 - r0); - double fy = (r1 * y0 - r0 * y1) / (r1 - r0); - - /* QPainter doesn't support the inner circle and use instead a gradient focal. - * That means we need to emulate the cairo behaviour by processing the - * cairo gradient stops. - * The CAIRO_EXTENT_NONE and CAIRO_EXTENT_PAD modes are quite easy to handle, - * it's just a matter of stop position translation and calculation of - * the corresponding SVG radial gradient focal. - * The CAIRO_EXTENT_REFLECT and CAIRO_EXTEND_REPEAT modes require to compute a new - * radial gradient, with an new outer circle, equal to r1 - r0 in the CAIRO_EXTEND_REPEAT - * case, and 2 * (r1 - r0) in the CAIRO_EXTENT_REFLECT case, and a new gradient stop - * list that maps to the original cairo stop list. - */ - if ((extend == CAIRO_EXTEND_REFLECT || extend == CAIRO_EXTEND_REPEAT) && r0 > 0.0) { - double r_org = r1; - double r, x, y; - - if (extend == CAIRO_EXTEND_REFLECT) { - r1 = 2 * r1 - r0; - emulate_reflect = TRUE; - } - - offset = fmod (r1, r1 - r0) / (r1 - r0) - 1.0; - r = r1 - r0; - - /* New position of outer circle. */ - x = r * (x1 - fx) / r_org + fx; - y = r * (y1 - fy) / r_org + fy; - - x1 = x; - y1 = y; - r1 = r; - r0 = 0.0; - } else { - offset = r0 / r1; - } - - grad = new QRadialGradient (x1, y1, r1, fx, fy); - - if (extend == CAIRO_EXTEND_NONE && r0 != 0.0) - grad->setColorAt (r0 / r1, Qt::transparent); - } - } - - switch (extend) { - case CAIRO_EXTEND_NONE: - case CAIRO_EXTEND_PAD: - grad->setSpread(QGradient::PadSpread); - - grad->setColorAt (0.0, Qt::transparent); - grad->setColorAt (1.0, Qt::transparent); - break; - - case CAIRO_EXTEND_REFLECT: - grad->setSpread(QGradient::ReflectSpread); - break; - - case CAIRO_EXTEND_REPEAT: - grad->setSpread(QGradient::RepeatSpread); - break; - } - - for (unsigned int i = 0; i < gpat->n_stops; i++) { - int index = i; - if (reverse_stops) - index = gpat->n_stops - i - 1; - - double offset = gpat->stops[i].offset; - QColor color; - color.setRgbF (gpat->stops[i].color.red, - gpat->stops[i].color.green, - gpat->stops[i].color.blue, - gpat->stops[i].color.alpha); - - if (emulate_reflect) { - offset = offset / 2.0; - grad->setColorAt (1.0 - offset, color); - } - - grad->setColorAt (offset, color); - } - - mBrush = QBrush(*grad); - - delete grad; - } - - if (mBrush.style() != Qt::NoBrush && - pattern->type != CAIRO_PATTERN_TYPE_SOLID && - ! _cairo_matrix_is_identity (&pattern->matrix)) - { - cairo_matrix_t pm = pattern->matrix; - cairo_status_t status = cairo_matrix_invert (&pm); - assert (status == CAIRO_STATUS_SUCCESS); - mBrush.setMatrix (_qmatrix_from_cairo_matrix (pm)); - } - } - - ~PatternToBrushConverter () { - if (mAcquiredImageParent) - _cairo_surface_release_source_image (mAcquiredImageParent, mAcquiredImage, mAcquiredImageExtra); - } - - operator QBrush& () { - return mBrush; - } - - QBrush mBrush; - - private: - cairo_surface_t *mAcquiredImageParent; - cairo_image_surface_t *mAcquiredImage; - void *mAcquiredImageExtra; -}; - -struct PatternToPenConverter { - PatternToPenConverter (const cairo_pattern_t *source, - const cairo_stroke_style_t *style) : - mBrushConverter(source) - { - Qt::PenJoinStyle join = Qt::MiterJoin; - Qt::PenCapStyle cap = Qt::SquareCap; - - switch (style->line_cap) { - case CAIRO_LINE_CAP_BUTT: - cap = Qt::FlatCap; - break; - case CAIRO_LINE_CAP_ROUND: - cap = Qt::RoundCap; - break; - case CAIRO_LINE_CAP_SQUARE: - cap = Qt::SquareCap; - break; - } - - switch (style->line_join) { - case CAIRO_LINE_JOIN_MITER: - join = Qt::MiterJoin; - break; - case CAIRO_LINE_JOIN_ROUND: - join = Qt::RoundJoin; - break; - case CAIRO_LINE_JOIN_BEVEL: - join = Qt::BevelJoin; - break; - } - - mPen = QPen(mBrushConverter, style->line_width, Qt::SolidLine, cap, join); - mPen.setMiterLimit (style->miter_limit); - - if (style->dash && style->num_dashes) { - Qt::PenStyle pstyle = Qt::NoPen; - - if (style->num_dashes == 2) { - if ((style->dash[0] == style->line_width && - style->dash[1] == style->line_width && style->line_width <= 2.0) || - (style->dash[0] == 0.0 && - style->dash[1] == style->line_width * 2 && cap == Qt::RoundCap)) - { - pstyle = Qt::DotLine; - } else if (style->dash[0] == style->line_width * DASH_LENGTH && - style->dash[1] == style->line_width * DASH_LENGTH && - cap == Qt::FlatCap) - { - pstyle = Qt::DashLine; - } - } - - if (pstyle != Qt::NoPen) { - mPen.setStyle(pstyle); - return; - } - - unsigned int odd_dash = style->num_dashes % 2; - - QVector<qreal> dashes (odd_dash ? style->num_dashes * 2 : style->num_dashes); - for (unsigned int i = 0; i < odd_dash+1; i++) { - for (unsigned int j = 0; j < style->num_dashes; j++) { - // In Qt, the dash lengths are given in units of line width, whereas - // in cairo, they are in user-space units. We'll always apply the CTM, - // so all we have to do here is divide cairo's dash lengths by the line - // width. - dashes.append (style->dash[j] / style->line_width); - } - } - - mPen.setDashPattern(dashes); - mPen.setDashOffset(style->dash_offset / style->line_width); - } - } - - ~PatternToPenConverter() { } - - operator QPen& () { - return mPen; - } - - QPen mPen; - PatternToBrushConverter mBrushConverter; -}; - -/** - ** Core drawing operations - **/ - -static bool -_cairo_qt_fast_fill (cairo_qt_surface_t *qs, - const cairo_pattern_t *source, - cairo_path_fixed_t *path = NULL, - cairo_fill_rule_t fill_rule = CAIRO_FILL_RULE_WINDING, - double tolerance = 0.0, - cairo_antialias_t antialias = CAIRO_ANTIALIAS_NONE) -{ -#if ENABLE_FAST_FILL - QImage *qsSrc_image = NULL; - QPixmap *qsSrc_pixmap = NULL; - std::auto_ptr<QImage> qsSrc_image_d; - - - if (source->type == CAIRO_PATTERN_TYPE_SURFACE) { - cairo_surface_pattern_t *spattern = (cairo_surface_pattern_t*) source; - if (spattern->surface->type == CAIRO_SURFACE_TYPE_QT) { - cairo_qt_surface_t *p = (cairo_qt_surface_t*) spattern->surface; - - qsSrc_image = p->image; - qsSrc_pixmap = p->pixmap; - } else if (spattern->surface->type == CAIRO_SURFACE_TYPE_IMAGE) { - cairo_image_surface_t *p = (cairo_image_surface_t*) spattern->surface; - qsSrc_image = new QImage((const uchar*) p->data, - p->width, - p->height, - p->stride, - _qimage_format_from_cairo_format(p->format)); - qsSrc_image_d.reset(qsSrc_image); - } - } - - if (!qsSrc_image && !qsSrc_pixmap) - return false; - - // We can only drawTiledPixmap; there's no drawTiledImage - if (! qsSrc_pixmap && - (source->extend == CAIRO_EXTEND_REPEAT || - source->extend == CAIRO_EXTEND_REFLECT)) - { - return false; - } - - QMatrix sourceMatrix = _qmatrix_from_cairo_matrix (source->matrix); - - // We can draw this faster by clipping and calling drawImage/drawPixmap. - // Use our own clipping function so that we can get the - // region handling to end up with the fastest possible clip. - // - // XXX Antialiasing will fail pretty hard here, since we can't clip with AA - // with QPainter. - qs->p->save(); - - if (path) { - cairo_int_status_t status; - - cairo_clip_t clip, old_clip = qs->clipper.clip; - - _cairo_clip_init_copy (&clip, &qs->clipper.clip); - status = (cairo_int_status_t) _cairo_clip_clip (&clip, - path, - fill_rule, - tolerance, - antialias); - if (unlikely (status)) { - qs->p->restore(); - return false; - } - - status = _cairo_qt_surface_set_clip (qs, &clip); - if (unlikely (status)) { - qs->p->restore(); - return false; - } - - _cairo_clip_reset (&clip); - qs->clipper.clip = old_clip; - } - - qs->p->setWorldMatrix (sourceMatrix.inverted(), true); - - switch (source->extend) { - case CAIRO_EXTEND_REPEAT: - // XXX handle reflect by tiling 4 times first - case CAIRO_EXTEND_REFLECT: { - assert (qsSrc_pixmap); - - // Render the tiling to cover the entire destination window (because - // it'll be clipped). Transform the window rect by the inverse - // of the current world transform so that the device coordinates - // end up as the right thing. - QRectF dest = qs->p->worldTransform().inverted().mapRect(QRectF(qs->window)); - QPointF origin = sourceMatrix.map(QPointF(0.0, 0.0)); - - qs->p->drawTiledPixmap (dest, *qsSrc_pixmap, origin); - } - break; - case CAIRO_EXTEND_NONE: - case CAIRO_EXTEND_PAD: // XXX not exactly right, but good enough - default: - if (qsSrc_image) - qs->p->drawImage (0, 0, *qsSrc_image); - else if (qsSrc_pixmap) - qs->p->drawPixmap (0, 0, *qsSrc_pixmap); - break; - } - - qs->p->restore(); - - return true; -#else - return false; -#endif -} - -static cairo_int_status_t -_cairo_qt_surface_paint (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_clip_t *clip) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - cairo_int_status_t status; - - D(fprintf(stderr, "q[%p] paint op:%s\n", abstract_surface, _opstr(op))); - - if (!qs->p) - return CAIRO_INT_STATUS_UNSUPPORTED; - - if (! _op_is_supported (qs, op)) - return CAIRO_INT_STATUS_UNSUPPORTED; - - status = _cairo_qt_surface_set_clip (qs, clip); - if (unlikely (status)) - return status; - - if (qs->supports_porter_duff) - qs->p->setCompositionMode (_qpainter_compositionmode_from_cairo_op (op)); - - if (! _cairo_qt_fast_fill (qs, source)) { - PatternToBrushConverter brush (source); - qs->p->fillRect (qs->window, brush); - } - - if (qs->supports_porter_duff) - qs->p->setCompositionMode (QPainter::CompositionMode_SourceOver); - - return CAIRO_INT_STATUS_SUCCESS; -} - -static cairo_int_status_t -_cairo_qt_surface_fill (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_path_fixed_t *path, - cairo_fill_rule_t fill_rule, - double tolerance, - cairo_antialias_t antialias, - cairo_clip_t *clip) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - - D(fprintf(stderr, "q[%p] fill op:%s\n", abstract_surface, _opstr(op))); - - if (!qs->p) - return CAIRO_INT_STATUS_UNSUPPORTED; - - if (! _op_is_supported (qs, op)) - return CAIRO_INT_STATUS_UNSUPPORTED; - - cairo_int_status_t status = _cairo_qt_surface_set_clip (qs, clip); - if (unlikely (status)) - return status; - - if (qs->supports_porter_duff) - qs->p->setCompositionMode (_qpainter_compositionmode_from_cairo_op (op)); - - // XXX Qt4.3, 4.4 misrenders some complex paths if antialiasing is - // enabled - //qs->p->setRenderHint (QPainter::Antialiasing, antialias == CAIRO_ANTIALIAS_NONE ? false : true); - qs->p->setRenderHint (QPainter::SmoothPixmapTransform, source->filter != CAIRO_FILTER_FAST); - - if (! _cairo_qt_fast_fill (qs, source, - path, fill_rule, tolerance, antialias)) - { - PatternToBrushConverter brush(source); - qs->p->fillPath (path_to_qt (path, fill_rule), brush); - } - - if (qs->supports_porter_duff) - qs->p->setCompositionMode (QPainter::CompositionMode_SourceOver); - - return CAIRO_INT_STATUS_SUCCESS; -} - -static cairo_int_status_t -_cairo_qt_surface_stroke (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_path_fixed_t *path, - const cairo_stroke_style_t *style, - const cairo_matrix_t *ctm, - const cairo_matrix_t *ctm_inverse, - double tolerance, - cairo_antialias_t antialias, - cairo_clip_t *clip) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - - D(fprintf(stderr, "q[%p] stroke op:%s\n", abstract_surface, _opstr(op))); - - if (!qs->p) - return CAIRO_INT_STATUS_UNSUPPORTED; - - if (! _op_is_supported (qs, op)) - return CAIRO_INT_STATUS_UNSUPPORTED; - - cairo_int_status_t int_status = _cairo_qt_surface_set_clip (qs, clip); - if (unlikely (int_status)) - return int_status; - - - QMatrix savedMatrix = qs->p->worldMatrix(); - - if (qs->supports_porter_duff) - qs->p->setCompositionMode (_qpainter_compositionmode_from_cairo_op (op)); - - qs->p->setWorldMatrix (_qmatrix_from_cairo_matrix (*ctm), true); - // XXX Qt4.3, 4.4 misrenders some complex paths if antialiasing is - // enabled - //qs->p->setRenderHint (QPainter::Antialiasing, antialias == CAIRO_ANTIALIAS_NONE ? false : true); - qs->p->setRenderHint (QPainter::SmoothPixmapTransform, source->filter != CAIRO_FILTER_FAST); - - PatternToPenConverter pen(source, style); - - qs->p->setPen(pen); - qs->p->drawPath(path_to_qt (path, ctm_inverse)); - qs->p->setPen(Qt::black); - - qs->p->setWorldMatrix (savedMatrix, false); - - if (qs->supports_porter_duff) - qs->p->setCompositionMode (QPainter::CompositionMode_SourceOver); - - return CAIRO_INT_STATUS_SUCCESS; -} - -static cairo_int_status_t -_cairo_qt_surface_show_glyphs (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_glyph_t *glyphs, - int num_glyphs, - cairo_scaled_font_t *scaled_font, - cairo_clip_t *clip, - int *remaining_glyphs) -{ - return CAIRO_INT_STATUS_UNSUPPORTED; -} - -static cairo_int_status_t -_cairo_qt_surface_mask (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - const cairo_pattern_t *mask, - cairo_clip_t *clip) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - - D(fprintf(stderr, "q[%p] mask op:%s\n", abstract_surface, _opstr(op))); - - if (!qs->p) - return CAIRO_INT_STATUS_UNSUPPORTED; - - if (mask->type == CAIRO_PATTERN_TYPE_SOLID) { - cairo_solid_pattern_t *solid_mask = (cairo_solid_pattern_t *) mask; - cairo_int_status_t result; - - qs->p->setOpacity (solid_mask->color.alpha); - - result = _cairo_qt_surface_paint (abstract_surface, op, source, clip); - - qs->p->setOpacity (1.0); - - return result; - } - - // otherwise skip for now - return CAIRO_INT_STATUS_UNSUPPORTED; -} - -static cairo_int_status_t -_cairo_qt_surface_composite (cairo_operator_t op, - const cairo_pattern_t *pattern, - const cairo_pattern_t *mask_pattern, - void *abstract_surface, - int src_x, - int src_y, - int mask_x, - int mask_y, - int dst_x, - int dst_y, - unsigned int width, - unsigned int height, - cairo_region_t *clip_region) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - - if (mask_pattern) - return CAIRO_INT_STATUS_UNSUPPORTED; - - if (! _op_is_supported (qs, op)) - return CAIRO_INT_STATUS_UNSUPPORTED; - - _cairo_qt_surface_set_clip_region (qs, clip_region); - - D(fprintf(stderr, "q[%p] composite op:%s src:%p [%d %d] dst [%d %d] dim [%d %d]\n", - abstract_surface, _opstr(op), (void*)pattern, - src_x, src_y, dst_x, dst_y, width, height)); - - if (pattern->type == CAIRO_PATTERN_TYPE_SOLID) { - cairo_solid_pattern_t *solid = (cairo_solid_pattern_t*) pattern; - - QColor color; - color.setRgbF(solid->color.red, - solid->color.green, - solid->color.blue, - solid->color.alpha); - - if (qs->supports_porter_duff) - qs->p->setCompositionMode (_qpainter_compositionmode_from_cairo_op (op)); - - qs->p->fillRect (dst_x, dst_y, width, height, color); - - if (qs->supports_porter_duff) - qs->p->setCompositionMode (QPainter::CompositionMode_SourceOver); - } else if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE) { - cairo_surface_pattern_t *spattern = (cairo_surface_pattern_t*) pattern; - cairo_surface_t *surface = spattern->surface; - - QImage *qimg = NULL; - QPixmap *qpixmap = NULL; - std::auto_ptr<QImage> qimg_d; - - if (surface->type == CAIRO_SURFACE_TYPE_IMAGE) { - cairo_image_surface_t *isurf = (cairo_image_surface_t*) surface; - qimg = new QImage ((const uchar *) isurf->data, - isurf->width, - isurf->height, - isurf->stride, - _qimage_format_from_cairo_format (isurf->format)); - qimg_d.reset(qimg); - } - - if (surface->type == CAIRO_SURFACE_TYPE_QT) { - cairo_qt_surface_t *qsrc = (cairo_qt_surface_t*) surface; - - if (qsrc->image) - qimg = qsrc->image; - else if (qsrc->pixmap) - qpixmap = qsrc->pixmap; - } - - if (!qimg && !qpixmap) - return CAIRO_INT_STATUS_UNSUPPORTED; - - QMatrix savedMatrix = qs->p->worldMatrix(); - if (! _cairo_matrix_is_identity (&pattern->matrix)) { - cairo_matrix_t pm = pattern->matrix; - cairo_status_t status; - - status = cairo_matrix_invert (&pm); - assert (status == CAIRO_STATUS_SUCCESS); - qs->p->setWorldMatrix(_qmatrix_from_cairo_matrix (pm), true); - } - - if (qs->supports_porter_duff) - qs->p->setCompositionMode (_qpainter_compositionmode_from_cairo_op (op)); - - if (qimg) - qs->p->drawImage (dst_x, dst_y, *qimg, src_x, src_y, width, height); - else if (qpixmap) - qs->p->drawPixmap (dst_x, dst_y, *qpixmap, src_x, src_y, width, height); - - if (qs->supports_porter_duff) - qs->p->setCompositionMode (QPainter::CompositionMode_SourceOver); - } else { - return CAIRO_INT_STATUS_UNSUPPORTED; - } - - return CAIRO_INT_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_qt_surface_mark_dirty (void *abstract_surface, - int x, int y, - int width, int height) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; - - if (qs->p && !(qs->image || qs->pixmap)) - qs->p->save (); - - return CAIRO_STATUS_SUCCESS; -} - -/** - ** Backend struct - **/ - -static const cairo_surface_backend_t cairo_qt_surface_backend = { - CAIRO_SURFACE_TYPE_QT, - _cairo_qt_surface_create_similar, - _cairo_qt_surface_finish, - _cairo_qt_surface_acquire_source_image, - _cairo_qt_surface_release_source_image, - _cairo_qt_surface_acquire_dest_image, - _cairo_qt_surface_release_dest_image, - _cairo_qt_surface_clone_similar, - - _cairo_qt_surface_composite, - NULL, /* fill_rectangles */ - NULL, /* composite_trapezoids */ - NULL, /* create_span_renderer */ - NULL, /* check_span_renderer */ - NULL, /* copy_page */ - NULL, /* show_page */ - _cairo_qt_surface_get_extents, - NULL, /* old_show_glyphs */ - NULL, /* get_font_options */ - NULL, /* flush */ - _cairo_qt_surface_mark_dirty, - NULL, /* scaled_font_fini */ - NULL, /* scaled_glyph_fini */ - - _cairo_qt_surface_paint, - _cairo_qt_surface_mask, - _cairo_qt_surface_stroke, - _cairo_qt_surface_fill, - _cairo_qt_surface_show_glyphs, - - NULL, /* snapshot */ - NULL, /* is_similar */ - NULL, /* fill_stroke */ - NULL, /* create_solid_pattern_surface */ - NULL, /* can_repaint_solid_pattern_surface */ - NULL, /* has_show_text_glyphs */ - NULL, /* show_text_glyphs */ -}; - -cairo_surface_t * -cairo_qt_surface_create (QPainter *painter) -{ - cairo_qt_surface_t *qs; - - qs = (cairo_qt_surface_t *) malloc (sizeof(cairo_qt_surface_t)); - if (qs == NULL) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); - - memset (qs, 0, sizeof(cairo_qt_surface_t)); - - _cairo_surface_init (&qs->base, - &cairo_qt_surface_backend, - NULL, - CAIRO_CONTENT_COLOR_ALPHA); - - _cairo_surface_clipper_init (&qs->clipper, - _cairo_qt_surface_clipper_intersect_clip_path); - - qs->p = painter; - if (qs->p->paintEngine()) - qs->supports_porter_duff = qs->p->paintEngine()->hasFeature(QPaintEngine::PorterDuff); - else - qs->supports_porter_duff = FALSE; - - // Save so that we can always get back to the original state - qs->p->save(); - - qs->window = painter->window(); - - D(fprintf(stderr, "qpainter_surface_create: window: [%d %d %d %d] pd:%d\n", - qs->window.x(), qs->window.y(), qs->window.width(), qs->window.height(), - qs->supports_porter_duff)); - - return &qs->base; -} - -cairo_surface_t * -cairo_qt_surface_create_with_qimage (cairo_format_t format, - int width, - int height) -{ - cairo_qt_surface_t *qs; - - qs = (cairo_qt_surface_t *) malloc (sizeof(cairo_qt_surface_t)); - if (qs == NULL) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); - - memset (qs, 0, sizeof(cairo_qt_surface_t)); - - _cairo_surface_init (&qs->base, - &cairo_qt_surface_backend, - NULL, - _cairo_content_from_format (format)); - - _cairo_surface_clipper_init (&qs->clipper, - _cairo_qt_surface_clipper_intersect_clip_path); - - if (CAIRO_FORMAT_A8 == format) { - qs->image = NULL; - qs->image_equiv = cairo_image_surface_create(format, - width, height); - qs->p = NULL; - qs->supports_porter_duff = false; - qs->window = QRect(0, 0, width, height); - return &qs->base; - } - - QImage *image = new QImage (width, height, - _qimage_format_from_cairo_format (format)); - - qs->image = image; - - if (!image->isNull()) { - qs->p = new QPainter(image); - qs->supports_porter_duff = qs->p->paintEngine()->hasFeature(QPaintEngine::PorterDuff); - } - - qs->image_equiv = cairo_image_surface_create_for_data (image->bits(), - format, - width, height, - image->bytesPerLine()); - - qs->window = QRect(0, 0, width, height); - - D(fprintf(stderr, "qpainter_surface_create: qimage: [%d %d %d %d] pd:%d\n", - qs->window.x(), qs->window.y(), qs->window.width(), qs->window.height(), - qs->supports_porter_duff)); - - return &qs->base; -} - -cairo_surface_t * -cairo_qt_surface_create_with_qpixmap (cairo_content_t content, - int width, - int height) -{ - cairo_qt_surface_t *qs; - - if ((content & CAIRO_CONTENT_COLOR) == 0) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_CONTENT)); - - qs = (cairo_qt_surface_t *) malloc (sizeof(cairo_qt_surface_t)); - if (qs == NULL) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); - - memset (qs, 0, sizeof(cairo_qt_surface_t)); - - QPixmap *pixmap = new QPixmap (width, height); - if (pixmap == NULL) { - free (qs); - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); - } - - // By default, a QPixmap is opaque; however, if it's filled - // with a color with a transparency component, it is converted - // to a format that preserves transparency. - if (content == CAIRO_CONTENT_COLOR_ALPHA) - pixmap->fill(Qt::transparent); - - _cairo_surface_init (&qs->base, &cairo_qt_surface_backend, NULL, content); - - _cairo_surface_clipper_init (&qs->clipper, - _cairo_qt_surface_clipper_intersect_clip_path); - - qs->pixmap = pixmap; - - if (!pixmap->isNull()) { - qs->p = new QPainter(pixmap); - qs->supports_porter_duff = qs->p->paintEngine()->hasFeature(QPaintEngine::PorterDuff); - } - - qs->window = QRect(0, 0, width, height); - - D(fprintf(stderr, "qpainter_surface_create: qpixmap: [%d %d %d %d] pd:%d\n", - qs->window.x(), qs->window.y(), qs->window.width(), qs->window.height(), - qs->supports_porter_duff)); - - return &qs->base; -} - -QPainter * -cairo_qt_surface_get_qpainter (cairo_surface_t *surface) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t*) surface; - - if (surface->type != CAIRO_SURFACE_TYPE_QT) - return NULL; - - return qs->p; -} - -QImage * -cairo_qt_surface_get_qimage (cairo_surface_t *surface) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t*) surface; - - if (surface->type != CAIRO_SURFACE_TYPE_QT) - return NULL; - - return qs->image; -} - -cairo_surface_t * -cairo_qt_surface_get_image (cairo_surface_t *surface) -{ - cairo_qt_surface_t *qs = (cairo_qt_surface_t*) surface; - - if (surface->type != CAIRO_SURFACE_TYPE_QT) - return NULL; - - return qs->image_equiv; -} - -/* - * TODO: - * - * - Figure out why QBrush isn't working with non-repeated images - * - * - Correct repeat mode; right now, every surface source is ExtendMode::REPEAT - * - implement EXTEND_NONE (?? probably need to clip to the extents of the source) - * - implement ExtendMode::REFLECT (create temporary and copy 4x, then ExtendMode::REPEAT that) - * - * - stroke-image failure - * - * - Implement mask() with non-solid masks (probably will need to use a temporary and use IN) - * - * - Implement gradient sources - * - * - Make create_similar smarter -- create QPixmaps in more circumstances - * (e.g. if the pixmap can have alpha) - * - * - Implement show_glyphs() in terms of Qt - * - */ diff --git a/libs/cairo/cairo/src/cairo-qt.h b/libs/cairo/cairo/src/cairo-qt.h deleted file mode 100644 index 9bb6cd0e3..000000000 --- a/libs/cairo/cairo/src/cairo-qt.h +++ /dev/null @@ -1,53 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef CAIRO_QT_H -#define CAIRO_QT_H - -#include "cairo.h" - -#if CAIRO_HAS_QT_SURFACE - -#include <QtGui/QImage> -#include <QtGui/QPainter> - -CAIRO_BEGIN_DECLS - -cairo_public cairo_surface_t * -cairo_qt_surface_create (QPainter *painter); - -cairo_public cairo_surface_t * -cairo_qt_surface_create_with_qimage (cairo_format_t format, - int width, - int height); - -cairo_public cairo_surface_t * -cairo_qt_surface_create_with_qpixmap (cairo_content_t content, - int width, - int height); - -cairo_public QPainter * -cairo_qt_surface_get_qpainter (cairo_surface_t *surface); - -/* XXX needs hooking to generic surface layer, my vote is for -cairo_public cairo_surface_t * -cairo_surface_map_image (cairo_surface_t *surface); -cairo_public void -cairo_surface_unmap_image (cairo_surface_t *surface, cairo_surface_t *image); -*/ -cairo_public cairo_surface_t * -cairo_qt_surface_get_image (cairo_surface_t *surface); - -cairo_public QImage * -cairo_qt_surface_get_qimage (cairo_surface_t *surface); - -CAIRO_END_DECLS - -#else /* CAIRO_HAS_QT_SURFACE */ - -# error Cairo was not compiled with support for the Qt backend - -#endif /* CAIRO_HAS_QT_SURFACE */ - -#endif /* CAIRO_QT_H */ diff --git a/libs/cairo/cairo/src/cairo-quartz-font.c b/libs/cairo/cairo/src/cairo-quartz-font.c deleted file mode 100644 index e58ae0559..000000000 --- a/libs/cairo/cairo/src/cairo-quartz-font.c +++ /dev/null @@ -1,811 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "cairoint.h" - -#include <dlfcn.h> - -#include "cairo-quartz.h" -#include "cairo-quartz-private.h" - -#include "cairo-error-private.h" - -/** - * SECTION:cairo-quartz-fonts - * @Title: Quartz (CGFont) Fonts - * @Short_Description: Font support via CGFont on OS X - * @See_Also: #cairo_font_face_t - * - * The Quartz font backend is primarily used to render text on Apple - * MacOS X systems. The CGFont API is used for the internal - * implementation of the font backend methods. - */ - -/** - * CAIRO_HAS_QUARTZ_FONT: - * - * Defined if the Quartz font backend is available. - * This macro can be used to conditionally compile backend-specific code. - */ - -/* CreateWithFontName exists in 10.5, but not in 10.4; CreateWithName isn't public in 10.4 */ -static CGFontRef (*CGFontCreateWithFontNamePtr) (CFStringRef) = NULL; -static CGFontRef (*CGFontCreateWithNamePtr) (const char *) = NULL; - -/* These aren't public before 10.5, and some have different names in 10.4 */ -static int (*CGFontGetUnitsPerEmPtr) (CGFontRef) = NULL; -static bool (*CGFontGetGlyphAdvancesPtr) (CGFontRef, const CGGlyph[], size_t, int[]) = NULL; -static bool (*CGFontGetGlyphBBoxesPtr) (CGFontRef, const CGGlyph[], size_t, CGRect[]) = NULL; -static CGRect (*CGFontGetFontBBoxPtr) (CGFontRef) = NULL; - -/* Not public, but present */ -static void (*CGFontGetGlyphsForUnicharsPtr) (CGFontRef, const UniChar[], const CGGlyph[], size_t) = NULL; -static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL; -static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL; - -/* CGFontGetHMetrics isn't public, but the other functions are public/present in 10.5 */ -typedef struct { - int ascent; - int descent; - int leading; -} quartz_CGFontMetrics; -static quartz_CGFontMetrics* (*CGFontGetHMetricsPtr) (CGFontRef fontRef) = NULL; -static int (*CGFontGetAscentPtr) (CGFontRef fontRef) = NULL; -static int (*CGFontGetDescentPtr) (CGFontRef fontRef) = NULL; -static int (*CGFontGetLeadingPtr) (CGFontRef fontRef) = NULL; - -/* CTFontCreateWithGraphicsFont is not public until 10.5. */ -typedef const struct __CTFontDescriptor *CTFontDescriptorRef; -static CTFontRef (*CTFontCreateWithGraphicsFontPtr) (CGFontRef, CGFloat, const CGAffineTransform *, CTFontDescriptorRef) = NULL; - -static cairo_bool_t _cairo_quartz_font_symbol_lookup_done = FALSE; -static cairo_bool_t _cairo_quartz_font_symbols_present = FALSE; - -static void -quartz_font_ensure_symbols(void) -{ - if (_cairo_quartz_font_symbol_lookup_done) - return; - - /* Look for the 10.5 versions first */ - CGFontGetGlyphBBoxesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphBBoxes"); - if (!CGFontGetGlyphBBoxesPtr) - CGFontGetGlyphBBoxesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphBoundingBoxes"); - - CGFontGetGlyphsForUnicharsPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphsForUnichars"); - if (!CGFontGetGlyphsForUnicharsPtr) - CGFontGetGlyphsForUnicharsPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphsForUnicodes"); - - CGFontGetFontBBoxPtr = dlsym(RTLD_DEFAULT, "CGFontGetFontBBox"); - - /* We just need one of these two */ - CGFontCreateWithFontNamePtr = dlsym(RTLD_DEFAULT, "CGFontCreateWithFontName"); - CGFontCreateWithNamePtr = dlsym(RTLD_DEFAULT, "CGFontCreateWithName"); - - /* These have the same name in 10.4 and 10.5 */ - CGFontGetUnitsPerEmPtr = dlsym(RTLD_DEFAULT, "CGFontGetUnitsPerEm"); - CGFontGetGlyphAdvancesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphAdvances"); - - CGFontGetHMetricsPtr = dlsym(RTLD_DEFAULT, "CGFontGetHMetrics"); - CGFontGetAscentPtr = dlsym(RTLD_DEFAULT, "CGFontGetAscent"); - CGFontGetDescentPtr = dlsym(RTLD_DEFAULT, "CGFontGetDescent"); - CGFontGetLeadingPtr = dlsym(RTLD_DEFAULT, "CGFontGetLeading"); - - CGContextGetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing"); - CGContextSetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextSetAllowsFontSmoothing"); - - CTFontCreateWithGraphicsFontPtr = dlsym(RTLD_DEFAULT, "CTFontCreateWithGraphicsFont"); - - if ((CGFontCreateWithFontNamePtr || CGFontCreateWithNamePtr) && - CGFontGetGlyphBBoxesPtr && - CGFontGetGlyphsForUnicharsPtr && - CGFontGetUnitsPerEmPtr && - CGFontGetGlyphAdvancesPtr && - (CGFontGetHMetricsPtr || (CGFontGetAscentPtr && CGFontGetDescentPtr && CGFontGetLeadingPtr))) - _cairo_quartz_font_symbols_present = TRUE; - - _cairo_quartz_font_symbol_lookup_done = TRUE; -} - -typedef struct _cairo_quartz_font_face cairo_quartz_font_face_t; -typedef struct _cairo_quartz_scaled_font cairo_quartz_scaled_font_t; - -struct _cairo_quartz_scaled_font { - cairo_scaled_font_t base; -}; - -struct _cairo_quartz_font_face { - cairo_font_face_t base; - - CGFontRef cgFont; - CTFontRef ctFont; -}; - -/* - * font face backend - */ - -static cairo_status_t -_cairo_quartz_font_face_create_for_toy (cairo_toy_font_face_t *toy_face, - cairo_font_face_t **font_face) -{ - const char *family; - char *full_name; - CFStringRef cgFontName = NULL; - CGFontRef cgFont = NULL; - int loop; - - quartz_font_ensure_symbols(); - if (! _cairo_quartz_font_symbols_present) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - - family = toy_face->family; - full_name = malloc (strlen (family) + 64); // give us a bit of room to tack on Bold, Oblique, etc. - /* handle CSS-ish faces */ - if (!strcmp(family, "serif") || !strcmp(family, "Times Roman")) - family = "Times"; - else if (!strcmp(family, "sans-serif") || !strcmp(family, "sans")) - family = "Helvetica"; - else if (!strcmp(family, "cursive")) - family = "Apple Chancery"; - else if (!strcmp(family, "fantasy")) - family = "Papyrus"; - else if (!strcmp(family, "monospace") || !strcmp(family, "mono")) - family = "Courier"; - - /* Try to build up the full name, e.g. "Helvetica Bold Oblique" first, - * then drop the bold, then drop the slant, then drop both.. finally - * just use "Helvetica". And if Helvetica doesn't exist, give up. - */ - for (loop = 0; loop < 5; loop++) { - if (loop == 4) - family = "Helvetica"; - - strcpy (full_name, family); - - if (loop < 3 && (loop & 1) == 0) { - if (toy_face->weight == CAIRO_FONT_WEIGHT_BOLD) - strcat (full_name, " Bold"); - } - - if (loop < 3 && (loop & 2) == 0) { - if (toy_face->slant == CAIRO_FONT_SLANT_ITALIC) - strcat (full_name, " Italic"); - else if (toy_face->slant == CAIRO_FONT_SLANT_OBLIQUE) - strcat (full_name, " Oblique"); - } - - if (CGFontCreateWithFontNamePtr) { - cgFontName = CFStringCreateWithCString (NULL, full_name, kCFStringEncodingASCII); - cgFont = CGFontCreateWithFontNamePtr (cgFontName); - CFRelease (cgFontName); - } else { - cgFont = CGFontCreateWithNamePtr (full_name); - } - - if (cgFont) - break; - } - - if (!cgFont) { - /* Give up */ - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - } - - *font_face = cairo_quartz_font_face_create_for_cgfont (cgFont); - CGFontRelease (cgFont); - - return CAIRO_STATUS_SUCCESS; -} - -static void -_cairo_quartz_font_face_destroy (void *abstract_face) -{ - cairo_quartz_font_face_t *font_face = (cairo_quartz_font_face_t*) abstract_face; - - if (font_face->ctFont) { - CFRelease (font_face->ctFont); - } - - CGFontRelease (font_face->cgFont); -} - -static const cairo_scaled_font_backend_t _cairo_quartz_scaled_font_backend; - -static cairo_status_t -_cairo_quartz_font_face_scaled_font_create (void *abstract_face, - const cairo_matrix_t *font_matrix, - const cairo_matrix_t *ctm, - const cairo_font_options_t *options, - cairo_scaled_font_t **font_out) -{ - cairo_quartz_font_face_t *font_face = abstract_face; - cairo_quartz_scaled_font_t *font = NULL; - cairo_status_t status; - cairo_font_extents_t fs_metrics; - double ems; - CGRect bbox; - - quartz_font_ensure_symbols(); - if (!_cairo_quartz_font_symbols_present) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - - font = malloc(sizeof(cairo_quartz_scaled_font_t)); - if (font == NULL) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - - memset (font, 0, sizeof(cairo_quartz_scaled_font_t)); - - status = _cairo_scaled_font_init (&font->base, - &font_face->base, font_matrix, ctm, options, - &_cairo_quartz_scaled_font_backend); - if (status) - goto FINISH; - - ems = CGFontGetUnitsPerEmPtr (font_face->cgFont); - - /* initialize metrics */ - if (CGFontGetFontBBoxPtr && CGFontGetAscentPtr) { - fs_metrics.ascent = (CGFontGetAscentPtr (font_face->cgFont) / ems); - fs_metrics.descent = - (CGFontGetDescentPtr (font_face->cgFont) / ems); - fs_metrics.height = fs_metrics.ascent + fs_metrics.descent + - (CGFontGetLeadingPtr (font_face->cgFont) / ems); - - bbox = CGFontGetFontBBoxPtr (font_face->cgFont); - fs_metrics.max_x_advance = CGRectGetMaxX(bbox) / ems; - fs_metrics.max_y_advance = 0.0; - } else { - CGGlyph wGlyph; - UniChar u; - - quartz_CGFontMetrics *m; - m = CGFontGetHMetricsPtr (font_face->cgFont); - - /* On OX 10.4, GetHMetricsPtr sometimes returns NULL for unknown reasons */ - if (!m) { - status = _cairo_error(CAIRO_STATUS_NULL_POINTER); - goto FINISH; - } - - fs_metrics.ascent = (m->ascent / ems); - fs_metrics.descent = - (m->descent / ems); - fs_metrics.height = fs_metrics.ascent + fs_metrics.descent + (m->leading / ems); - - /* We kind of have to guess here; W's big, right? */ - u = (UniChar) 'W'; - CGFontGetGlyphsForUnicharsPtr (font_face->cgFont, &u, &wGlyph, 1); - if (wGlyph && CGFontGetGlyphBBoxesPtr (font_face->cgFont, &wGlyph, 1, &bbox)) { - fs_metrics.max_x_advance = CGRectGetMaxX(bbox) / ems; - fs_metrics.max_y_advance = 0.0; - } else { - fs_metrics.max_x_advance = 0.0; - fs_metrics.max_y_advance = 0.0; - } - } - - status = _cairo_scaled_font_set_metrics (&font->base, &fs_metrics); - -FINISH: - if (status != CAIRO_STATUS_SUCCESS) { - free (font); - } else { - *font_out = (cairo_scaled_font_t*) font; - } - - return status; -} - -const cairo_font_face_backend_t _cairo_quartz_font_face_backend = { - CAIRO_FONT_TYPE_QUARTZ, - _cairo_quartz_font_face_create_for_toy, - _cairo_quartz_font_face_destroy, - _cairo_quartz_font_face_scaled_font_create -}; - -/** - * cairo_quartz_font_face_create_for_cgfont - * @font: a #CGFontRef obtained through a method external to cairo. - * - * Creates a new font for the Quartz font backend based on a - * #CGFontRef. This font can then be used with - * cairo_set_font_face() or cairo_scaled_font_create(). - * - * Return value: a newly created #cairo_font_face_t. Free with - * cairo_font_face_destroy() when you are done using it. - * - * Since: 1.6 - */ -cairo_font_face_t * -cairo_quartz_font_face_create_for_cgfont (CGFontRef font) -{ - cairo_quartz_font_face_t *font_face; - - quartz_font_ensure_symbols(); - - font_face = malloc (sizeof (cairo_quartz_font_face_t)); - if (!font_face) { - cairo_status_t ignore_status; - ignore_status = _cairo_error (CAIRO_STATUS_NO_MEMORY); - return (cairo_font_face_t *)&_cairo_font_face_nil; - } - - font_face->cgFont = CGFontRetain (font); - - if (CTFontCreateWithGraphicsFontPtr) { - font_face->ctFont = CTFontCreateWithGraphicsFontPtr (font, 1.0, NULL, NULL); - } else { - font_face->ctFont = NULL; - } - - _cairo_font_face_init (&font_face->base, &_cairo_quartz_font_face_backend); - - return &font_face->base; -} - -/* - * scaled font backend - */ - -static cairo_quartz_font_face_t * -_cairo_quartz_scaled_to_face (void *abstract_font) -{ - cairo_quartz_scaled_font_t *sfont = (cairo_quartz_scaled_font_t*) abstract_font; - cairo_font_face_t *font_face = sfont->base.font_face; - assert (font_face->backend->type == CAIRO_FONT_TYPE_QUARTZ); - return (cairo_quartz_font_face_t*) font_face; -} - -static void -_cairo_quartz_scaled_font_fini(void *abstract_font) -{ -} - -#define INVALID_GLYPH 0x00 - -static inline CGGlyph -_cairo_quartz_scaled_glyph_index (cairo_scaled_glyph_t *scaled_glyph) { - unsigned long index = _cairo_scaled_glyph_index (scaled_glyph); - if (index > 0xffff) - return INVALID_GLYPH; - return (CGGlyph) index; -} - -static cairo_int_status_t -_cairo_quartz_init_glyph_metrics (cairo_quartz_scaled_font_t *font, - cairo_scaled_glyph_t *scaled_glyph) -{ - cairo_int_status_t status = CAIRO_STATUS_SUCCESS; - - cairo_quartz_font_face_t *font_face = _cairo_quartz_scaled_to_face(font); - cairo_text_extents_t extents = {0, 0, 0, 0, 0, 0}; - CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph); - int advance; - CGRect bbox; - double emscale = CGFontGetUnitsPerEmPtr (font_face->cgFont); - double xscale, yscale; - double xmin, ymin, xmax, ymax; - - if (glyph == INVALID_GLYPH) - goto FAIL; - - if (!CGFontGetGlyphAdvancesPtr (font_face->cgFont, &glyph, 1, &advance) || - !CGFontGetGlyphBBoxesPtr (font_face->cgFont, &glyph, 1, &bbox)) - goto FAIL; - - /* broken fonts like Al Bayan return incorrect bounds for some null characters, - see https://bugzilla.mozilla.org/show_bug.cgi?id=534260 */ - if (unlikely (bbox.origin.x == -32767 && - bbox.origin.y == -32767 && - bbox.size.width == 65534 && - bbox.size.height == 65534)) { - bbox.origin.x = bbox.origin.y = 0; - bbox.size.width = bbox.size.height = 0; - } - - status = _cairo_matrix_compute_basis_scale_factors (&font->base.scale, - &xscale, &yscale, 1); - if (status) - goto FAIL; - - bbox = CGRectMake (bbox.origin.x / emscale, - bbox.origin.y / emscale, - bbox.size.width / emscale, - bbox.size.height / emscale); - - /* Should we want to always integer-align glyph extents, we can do so in this way */ -#if 0 - { - CGAffineTransform textMatrix; - textMatrix = CGAffineTransformMake (font->base.scale.xx, - -font->base.scale.yx, - -font->base.scale.xy, - font->base.scale.yy, - 0.0f, 0.0f); - - bbox = CGRectApplyAffineTransform (bbox, textMatrix); - bbox = CGRectIntegral (bbox); - bbox = CGRectApplyAffineTransform (bbox, CGAffineTransformInvert (textMatrix)); - } -#endif - -#if 0 - fprintf (stderr, "[0x%04x] bbox: %f %f %f %f\n", glyph, - bbox.origin.x / emscale, bbox.origin.y / emscale, - bbox.size.width / emscale, bbox.size.height / emscale); -#endif - - xmin = CGRectGetMinX(bbox); - ymin = CGRectGetMinY(bbox); - xmax = CGRectGetMaxX(bbox); - ymax = CGRectGetMaxY(bbox); - - extents.x_bearing = xmin; - extents.y_bearing = - ymax; - extents.width = xmax - xmin; - extents.height = ymax - ymin; - - extents.x_advance = (double) advance / emscale; - extents.y_advance = 0.0; - -#if 0 - fprintf (stderr, "[0x%04x] extents: bearings: %f %f dim: %f %f adv: %f\n\n", glyph, - extents.x_bearing, extents.y_bearing, extents.width, extents.height, extents.x_advance); -#endif - - FAIL: - _cairo_scaled_glyph_set_metrics (scaled_glyph, - &font->base, - &extents); - - return status; -} - -static void -_cairo_quartz_path_apply_func (void *info, const CGPathElement *el) -{ - cairo_path_fixed_t *path = (cairo_path_fixed_t *) info; - cairo_status_t status; - - switch (el->type) { - case kCGPathElementMoveToPoint: - status = _cairo_path_fixed_move_to (path, - _cairo_fixed_from_double(el->points[0].x), - _cairo_fixed_from_double(el->points[0].y)); - assert(!status); - break; - case kCGPathElementAddLineToPoint: - status = _cairo_path_fixed_line_to (path, - _cairo_fixed_from_double(el->points[0].x), - _cairo_fixed_from_double(el->points[0].y)); - assert(!status); - break; - case kCGPathElementAddQuadCurveToPoint: { - cairo_fixed_t fx, fy; - double x, y; - if (!_cairo_path_fixed_get_current_point (path, &fx, &fy)) - fx = fy = 0; - x = _cairo_fixed_to_double (fx); - y = _cairo_fixed_to_double (fy); - - status = _cairo_path_fixed_curve_to (path, - _cairo_fixed_from_double((x + el->points[0].x * 2.0) / 3.0), - _cairo_fixed_from_double((y + el->points[0].y * 2.0) / 3.0), - _cairo_fixed_from_double((el->points[0].x * 2.0 + el->points[1].x) / 3.0), - _cairo_fixed_from_double((el->points[0].y * 2.0 + el->points[1].y) / 3.0), - _cairo_fixed_from_double(el->points[1].x), - _cairo_fixed_from_double(el->points[1].y)); - } - assert(!status); - break; - case kCGPathElementAddCurveToPoint: - status = _cairo_path_fixed_curve_to (path, - _cairo_fixed_from_double(el->points[0].x), - _cairo_fixed_from_double(el->points[0].y), - _cairo_fixed_from_double(el->points[1].x), - _cairo_fixed_from_double(el->points[1].y), - _cairo_fixed_from_double(el->points[2].x), - _cairo_fixed_from_double(el->points[2].y)); - assert(!status); - break; - case kCGPathElementCloseSubpath: - status = _cairo_path_fixed_close_path (path); - assert(!status); - break; - } -} - -static cairo_int_status_t -_cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font, - cairo_scaled_glyph_t *scaled_glyph) -{ - cairo_quartz_font_face_t *font_face = _cairo_quartz_scaled_to_face(font); - CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph); - CGAffineTransform textMatrix; - CGPathRef glyphPath; - CTFontRef ctFont; - cairo_path_fixed_t *path; - - if (glyph == INVALID_GLYPH) { - _cairo_scaled_glyph_set_path (scaled_glyph, &font->base, _cairo_path_fixed_create()); - return CAIRO_STATUS_SUCCESS; - } - - /* scale(1,-1) * font->base.scale */ - textMatrix = CGAffineTransformMake (font->base.scale.xx, - font->base.scale.yx, - -font->base.scale.xy, - -font->base.scale.yy, - 0, 0); - - ctFont = CTFontCreateWithGraphicsFont (font_face->cgFont, 1.0, NULL, NULL); - glyphPath = CTFontCreatePathForGlyph (ctFont, glyph, &textMatrix); - CFRelease (ctFont); - if (!glyphPath) - return CAIRO_INT_STATUS_UNSUPPORTED; - - path = _cairo_path_fixed_create (); - if (!path) { - CGPathRelease (glyphPath); - return _cairo_error(CAIRO_STATUS_NO_MEMORY); - } - - CGPathApply (glyphPath, path, _cairo_quartz_path_apply_func); - - CGPathRelease (glyphPath); - - _cairo_scaled_glyph_set_path (scaled_glyph, &font->base, path); - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_int_status_t -_cairo_quartz_init_glyph_surface (cairo_quartz_scaled_font_t *font, - cairo_scaled_glyph_t *scaled_glyph) -{ - cairo_int_status_t status = CAIRO_STATUS_SUCCESS; - - cairo_quartz_font_face_t *font_face = _cairo_quartz_scaled_to_face(font); - - cairo_image_surface_t *surface = NULL; - - CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph); - - int advance; - CGRect bbox; - double width, height; - double xscale, yscale; - double emscale = CGFontGetUnitsPerEmPtr (font_face->cgFont); - - CGContextRef cgContext = NULL; - CGAffineTransform textMatrix; - CGRect glyphRect, glyphRectInt; - CGPoint glyphOrigin; - - //fprintf (stderr, "scaled_glyph: %p surface: %p\n", scaled_glyph, scaled_glyph->surface); - - /* Create blank 2x2 image if we don't have this character. - * Maybe we should draw a better missing-glyph slug or something, - * but this is ok for now. - */ - if (glyph == INVALID_GLYPH) { - surface = (cairo_image_surface_t*) cairo_image_surface_create (CAIRO_FORMAT_A8, 2, 2); - status = cairo_surface_status ((cairo_surface_t *) surface); - if (status) - return status; - - _cairo_scaled_glyph_set_surface (scaled_glyph, - &font->base, - surface); - return CAIRO_STATUS_SUCCESS; - } - - if (!CGFontGetGlyphAdvancesPtr (font_face->cgFont, &glyph, 1, &advance) || - !CGFontGetGlyphBBoxesPtr (font_face->cgFont, &glyph, 1, &bbox)) - { - return CAIRO_INT_STATUS_UNSUPPORTED; - } - - status = _cairo_matrix_compute_basis_scale_factors (&font->base.scale, - &xscale, &yscale, 1); - if (status) - return status; - - /* scale(1,-1) * font->base.scale * scale(1,-1) */ - textMatrix = CGAffineTransformMake (font->base.scale.xx, - -font->base.scale.yx, - -font->base.scale.xy, - font->base.scale.yy, - 0, -0); - glyphRect = CGRectMake (bbox.origin.x / emscale, - bbox.origin.y / emscale, - bbox.size.width / emscale, - bbox.size.height / emscale); - - glyphRect = CGRectApplyAffineTransform (glyphRect, textMatrix); - - /* Round the rectangle outwards, so that we don't have to deal - * with non-integer-pixel origins or dimensions. - */ - glyphRectInt = CGRectIntegral (glyphRect); - -#if 0 - fprintf (stderr, "glyphRect[o]: %f %f %f %f\n", - glyphRect.origin.x, glyphRect.origin.y, glyphRect.size.width, glyphRect.size.height); - fprintf (stderr, "glyphRectInt: %f %f %f %f\n", - glyphRectInt.origin.x, glyphRectInt.origin.y, glyphRectInt.size.width, glyphRectInt.size.height); -#endif - - glyphOrigin = glyphRectInt.origin; - - //textMatrix = CGAffineTransformConcat (textMatrix, CGAffineTransformInvert (ctm)); - - width = glyphRectInt.size.width; - height = glyphRectInt.size.height; - - //fprintf (stderr, "glyphRect[n]: %f %f %f %f\n", glyphRect.origin.x, glyphRect.origin.y, glyphRect.size.width, glyphRect.size.height); - - surface = (cairo_image_surface_t*) cairo_image_surface_create (CAIRO_FORMAT_A8, width, height); - if (surface->base.status) - return surface->base.status; - - if (surface->width != 0 && surface->height != 0) { - cgContext = CGBitmapContextCreate (surface->data, - surface->width, - surface->height, - 8, - surface->stride, - NULL, - kCGImageAlphaOnly); - - if (cgContext == NULL) { - cairo_surface_destroy (&surface->base); - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - } - - CGContextSetFont (cgContext, font_face->cgFont); - CGContextSetFontSize (cgContext, 1.0); - CGContextSetTextMatrix (cgContext, textMatrix); - - switch (font->base.options.antialias) { - case CAIRO_ANTIALIAS_SUBPIXEL: - CGContextSetShouldAntialias (cgContext, TRUE); - CGContextSetShouldSmoothFonts (cgContext, TRUE); - if (CGContextSetAllowsFontSmoothingPtr && - !CGContextGetAllowsFontSmoothingPtr (cgContext)) - CGContextSetAllowsFontSmoothingPtr (cgContext, TRUE); - break; - case CAIRO_ANTIALIAS_NONE: - CGContextSetShouldAntialias (cgContext, FALSE); - break; - case CAIRO_ANTIALIAS_GRAY: - CGContextSetShouldAntialias (cgContext, TRUE); - CGContextSetShouldSmoothFonts (cgContext, FALSE); - break; - case CAIRO_ANTIALIAS_DEFAULT: - default: - /* Don't do anything */ - break; - } - - CGContextSetAlpha (cgContext, 1.0); - CGContextShowGlyphsAtPoint (cgContext, - glyphOrigin.x, - glyphOrigin.y, &glyph, 1); - - CGContextRelease (cgContext); - } - - cairo_surface_set_device_offset (&surface->base, - - glyphOrigin.x, - height + glyphOrigin.y); - - _cairo_scaled_glyph_set_surface (scaled_glyph, &font->base, surface); - - return status; -} - -static cairo_int_status_t -_cairo_quartz_scaled_glyph_init (void *abstract_font, - cairo_scaled_glyph_t *scaled_glyph, - cairo_scaled_glyph_info_t info) -{ - cairo_quartz_scaled_font_t *font = (cairo_quartz_scaled_font_t *) abstract_font; - cairo_int_status_t status = CAIRO_STATUS_SUCCESS; - - if (!status && (info & CAIRO_SCALED_GLYPH_INFO_METRICS)) - status = _cairo_quartz_init_glyph_metrics (font, scaled_glyph); - - if (!status && (info & CAIRO_SCALED_GLYPH_INFO_PATH)) - status = _cairo_quartz_init_glyph_path (font, scaled_glyph); - - if (!status && (info & CAIRO_SCALED_GLYPH_INFO_SURFACE)) - status = _cairo_quartz_init_glyph_surface (font, scaled_glyph); - - return status; -} - -static unsigned long -_cairo_quartz_ucs4_to_index (void *abstract_font, - uint32_t ucs4) -{ - cairo_quartz_scaled_font_t *font = (cairo_quartz_scaled_font_t*) abstract_font; - cairo_quartz_font_face_t *ffont = _cairo_quartz_scaled_to_face(font); - UniChar u = (UniChar) ucs4; - CGGlyph glyph; - - CGFontGetGlyphsForUnicharsPtr (ffont->cgFont, &u, &glyph, 1); - - return glyph; -} - -static const cairo_scaled_font_backend_t _cairo_quartz_scaled_font_backend = { - CAIRO_FONT_TYPE_QUARTZ, - _cairo_quartz_scaled_font_fini, - _cairo_quartz_scaled_glyph_init, - NULL, /* text_to_glyphs */ - _cairo_quartz_ucs4_to_index, - NULL, /* show_glyphs */ - NULL, /* load_truetype_table */ - NULL, /* map_glyphs_to_unicode */ -}; - -/* - * private methods that the quartz surface uses - */ - -CGFontRef -_cairo_quartz_scaled_font_get_cg_font_ref (cairo_scaled_font_t *abstract_font) -{ - cairo_quartz_font_face_t *ffont = _cairo_quartz_scaled_to_face(abstract_font); - - return ffont->cgFont; -} - -CTFontRef -_cairo_quartz_scaled_font_get_ct_font_ref (cairo_scaled_font_t *abstract_font) -{ - cairo_quartz_font_face_t *ffont = _cairo_quartz_scaled_to_face(abstract_font); - - return ffont->ctFont; -} - -#if !defined(__LP64__) && !TARGET_OS_IPHONE -/* - * compat with old ATSUI backend - */ - -/** - * cairo_quartz_font_face_create_for_atsu_font_id - * @font_id: an ATSUFontID for the font. - * - * Creates a new font for the Quartz font backend based on an - * #ATSUFontID. This font can then be used with - * cairo_set_font_face() or cairo_scaled_font_create(). - * - * Return value: a newly created #cairo_font_face_t. Free with - * cairo_font_face_destroy() when you are done using it. - * - * Since: 1.6 - **/ -cairo_font_face_t * -cairo_quartz_font_face_create_for_atsu_font_id (ATSUFontID font_id) -{ - ATSFontRef atsFont = FMGetATSFontRefFromFont (font_id); - CGFontRef cgFont = CGFontCreateWithPlatformFont (&atsFont); - cairo_font_face_t *ff; - - ff = cairo_quartz_font_face_create_for_cgfont (cgFont); - - CGFontRelease (cgFont); - - return ff; -} - -/* This is the old name for the above function, exported for compat purposes */ -cairo_font_face_t *cairo_atsui_font_face_create_for_atsu_font_id (ATSUFontID font_id); - -cairo_font_face_t * -cairo_atsui_font_face_create_for_atsu_font_id (ATSUFontID font_id) -{ - return cairo_quartz_font_face_create_for_atsu_font_id (font_id); -} -#endif diff --git a/libs/cairo/cairo/src/cairo-quartz-image-surface.c b/libs/cairo/cairo/src/cairo-quartz-image-surface.c deleted file mode 100644 index 155ec494f..000000000 --- a/libs/cairo/cairo/src/cairo-quartz-image-surface.c +++ /dev/null @@ -1,258 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "cairoint.h" - -#include "cairo-quartz-image.h" -#include "cairo-quartz-private.h" - -#include "cairo-error-private.h" - -#define SURFACE_ERROR_NO_MEMORY (_cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_NO_MEMORY))) -#define SURFACE_ERROR_TYPE_MISMATCH (_cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_SURFACE_TYPE_MISMATCH))) -#define SURFACE_ERROR_INVALID_SIZE (_cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_INVALID_SIZE))) -#define SURFACE_ERROR_INVALID_FORMAT (_cairo_surface_create_in_error(_cairo_error(CAIRO_STATUS_INVALID_FORMAT))) - -static void -DataProviderReleaseCallback (void *info, const void *data, size_t size) -{ - cairo_surface_t *surface = (cairo_surface_t *) info; - cairo_surface_destroy (surface); -} - -static cairo_surface_t * -_cairo_quartz_image_surface_create_similar (void *asurface, - cairo_content_t content, - int width, - int height) -{ - cairo_surface_t *result; - cairo_surface_t *isurf = - _cairo_image_surface_create_with_content (content, width, height); - if (cairo_surface_status(isurf)) - return isurf; - - result = cairo_quartz_image_surface_create (isurf); - cairo_surface_destroy (isurf); - - return result; -} - -static cairo_status_t -_cairo_quartz_image_surface_finish (void *asurface) -{ - cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t *) asurface; - - /* the imageSurface will be destroyed by the data provider's release callback */ - CGImageRelease (surface->image); - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_quartz_image_surface_acquire_source_image (void *asurface, - cairo_image_surface_t **image_out, - void **image_extra) -{ - cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t *) asurface; - - *image_out = surface->imageSurface; - *image_extra = NULL; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_quartz_image_surface_acquire_dest_image (void *asurface, - cairo_rectangle_int_t *interest_rect, - cairo_image_surface_t **image_out, - cairo_rectangle_int_t *image_rect, - void **image_extra) -{ - cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t *) asurface; - - *image_out = surface->imageSurface; - *image_rect = surface->extents; - *image_extra = NULL; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_bool_t -_cairo_quartz_image_surface_get_extents (void *asurface, - cairo_rectangle_int_t *extents) -{ - cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t *) asurface; - - *extents = surface->extents; - return TRUE; -} - -/* we assume some drawing happened to the image buffer; make sure it's - * represented in the CGImage on flush() - */ - -static cairo_status_t -_cairo_quartz_image_surface_flush (void *asurface) -{ - cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t *) asurface; - CGImageRef oldImage = surface->image; - CGImageRef newImage = NULL; - - /* To be released by the ReleaseCallback */ - cairo_surface_reference ((cairo_surface_t*) surface->imageSurface); - - newImage = _cairo_quartz_create_cgimage (surface->imageSurface->format, - surface->imageSurface->width, - surface->imageSurface->height, - surface->imageSurface->stride, - surface->imageSurface->data, - TRUE, - NULL, - DataProviderReleaseCallback, - surface->imageSurface); - - surface->image = newImage; - CGImageRelease (oldImage); - - surface->base.is_clear = surface->imageSurface->base.is_clear; - - return CAIRO_STATUS_SUCCESS; -} - -static const cairo_surface_backend_t cairo_quartz_image_surface_backend = { - CAIRO_SURFACE_TYPE_QUARTZ_IMAGE, - _cairo_quartz_image_surface_create_similar, - _cairo_quartz_image_surface_finish, - _cairo_quartz_image_surface_acquire_source_image, - NULL, /* release_source_image */ - _cairo_quartz_image_surface_acquire_dest_image, - NULL, /* release_dest_image */ - NULL, /* clone_similar */ - NULL, /* composite */ - NULL, /* fill_rectangles */ - NULL, /* composite_trapezoids */ - NULL, /* create_span_renderer */ - NULL, /* check_span_renderer */ - NULL, /* copy_page */ - NULL, /* show_page */ - _cairo_quartz_image_surface_get_extents, - NULL, /* old_show_glyphs */ - NULL, /* get_font_options */ - _cairo_quartz_image_surface_flush, - NULL, /* mark_dirty_rectangle */ - NULL, /* scaled_font_fini */ - NULL, /* scaled_glyph_fini */ - - NULL, /* paint */ - NULL, /* mask */ - NULL, /* stroke */ - NULL, /* fill */ - NULL, /* surface_show_glyphs */ - NULL, /* snapshot */ - NULL, /* is_similar */ - NULL /* fill_stroke */ - -}; - -/** - * cairo_quartz_image_surface_create - * @surface: a cairo image surface to wrap with a quartz image surface - * - * Creates a Quartz surface backed by a CGImageRef that references the - * given image surface. The resulting surface can be rendered quickly - * when used as a source when rendering to a #cairo_quartz_surface. If - * the data in the image surface is ever updated, cairo_surface_flush() - * must be called on the #cairo_quartz_image_surface to ensure that the - * CGImageRef refers to the updated data. - * - * Return value: the newly created surface. - * - * Since: 1.6 - */ -cairo_surface_t * -cairo_quartz_image_surface_create (cairo_surface_t *surface) -{ - cairo_quartz_image_surface_t *qisurf; - - CGImageRef image; - - cairo_image_surface_t *image_surface; - int width, height, stride; - cairo_format_t format; - unsigned char *data; - - if (cairo_surface_get_type(surface) != CAIRO_SURFACE_TYPE_IMAGE) - return SURFACE_ERROR_TYPE_MISMATCH; - - image_surface = (cairo_image_surface_t*) surface; - width = image_surface->width; - height = image_surface->height; - stride = image_surface->stride; - format = image_surface->format; - data = image_surface->data; - - if (!_cairo_quartz_verify_surface_size(width, height)) - return SURFACE_ERROR_INVALID_SIZE; - - if (width == 0 || height == 0) - return SURFACE_ERROR_INVALID_SIZE; - - if (format != CAIRO_FORMAT_ARGB32 && format != CAIRO_FORMAT_RGB24) - return SURFACE_ERROR_INVALID_FORMAT; - - qisurf = malloc(sizeof(cairo_quartz_image_surface_t)); - if (qisurf == NULL) - return SURFACE_ERROR_NO_MEMORY; - - memset (qisurf, 0, sizeof(cairo_quartz_image_surface_t)); - - /* In case the create_cgimage fails, this ref will - * be released via the callback (which will be called in - * case of failure.) - */ - cairo_surface_reference (surface); - - image = _cairo_quartz_create_cgimage (format, - width, height, - stride, - data, - TRUE, - NULL, - DataProviderReleaseCallback, - image_surface); - - if (!image) { - free (qisurf); - return SURFACE_ERROR_NO_MEMORY; - } - - _cairo_surface_init (&qisurf->base, - &cairo_quartz_image_surface_backend, - NULL, /* device */ - _cairo_content_from_format (format)); - - qisurf->extents.x = qisurf->extents.y = 0; - qisurf->extents.width = width; - qisurf->extents.height = height; - - qisurf->image = image; - qisurf->imageSurface = image_surface; - - qisurf->base.is_clear = image_surface->base.is_clear; - - return &qisurf->base; -} - - -cairo_surface_t * -cairo_quartz_image_surface_get_image (cairo_surface_t *asurface) -{ - cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t*) asurface; - - if (cairo_surface_get_type(asurface) != CAIRO_SURFACE_TYPE_QUARTZ_IMAGE) - return NULL; - - return (cairo_surface_t*) surface->imageSurface; -} diff --git a/libs/cairo/cairo/src/cairo-quartz-image.h b/libs/cairo/cairo/src/cairo-quartz-image.h deleted file mode 100644 index fffc1ee86..000000000 --- a/libs/cairo/cairo/src/cairo-quartz-image.h +++ /dev/null @@ -1,33 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef CAIRO_QUARTZ_IMAGE_H -#define CAIRO_QUARTZ_IMAGE_H - -#include "cairo.h" - -#if CAIRO_HAS_QUARTZ_IMAGE_SURFACE -#include "TargetConditionals.h" - -#if !TARGET_OS_IPHONE -#include <Carbon/Carbon.h> -#else -#include <CoreGraphics/CoreGraphics.h> -#endif - -CAIRO_BEGIN_DECLS - -cairo_public cairo_surface_t * -cairo_quartz_image_surface_create (cairo_surface_t *image_surface); - -cairo_public cairo_surface_t * -cairo_quartz_image_surface_get_image (cairo_surface_t *surface); - -CAIRO_END_DECLS - -#else /* CAIRO_HAS_QUARTZ_IMAGE_SURFACE */ -# error Cairo was not compiled with support for the quartz-image backend -#endif /* CAIRO_HAS_QUARTZ_IMAGE_SURFACE */ - -#endif /* CAIRO_QUARTZ_IMAGE_H */ diff --git a/libs/cairo/cairo/src/cairo-quartz-private.h b/libs/cairo/cairo/src/cairo-quartz-private.h deleted file mode 100644 index c0dcf3b91..000000000 --- a/libs/cairo/cairo/src/cairo-quartz-private.h +++ /dev/null @@ -1,86 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef CAIRO_QUARTZ_PRIVATE_H -#define CAIRO_QUARTZ_PRIVATE_H - -#include "cairoint.h" - -#if CAIRO_HAS_QUARTZ_SURFACE -#include "cairo-quartz.h" -#include "cairo-surface-clipper-private.h" - -#ifdef CGFLOAT_DEFINED -typedef CGFloat cairo_quartz_float_t; -#else -typedef float cairo_quartz_float_t; -#endif - -/* define CTFontRef for pre-10.5 SDKs */ -typedef const struct __CTFont *CTFontRef; - -typedef struct cairo_quartz_surface { - cairo_surface_t base; - - CGContextRef cgContext; - CGAffineTransform cgContextBaseCTM; - - void *imageData; - cairo_surface_t *imageSurfaceEquiv; - - cairo_surface_clipper_t clipper; - - /** - * If non-null, this is a CGImage representing the contents of the surface. - * We clear this out before any painting into the surface, so that we - * don't force a copy to be created. - */ - CGImageRef bitmapContextImage; - - /** - * If non-null, this is the CGLayer for the surface. - */ - CGLayerRef cgLayer; - - cairo_rectangle_int_t extents; - - cairo_bool_t ownsData; -} cairo_quartz_surface_t; - -typedef struct cairo_quartz_image_surface { - cairo_surface_t base; - - cairo_rectangle_int_t extents; - - CGImageRef image; - cairo_image_surface_t *imageSurface; -} cairo_quartz_image_surface_t; - -cairo_bool_t -_cairo_quartz_verify_surface_size(int width, int height); - -CGImageRef -_cairo_quartz_create_cgimage (cairo_format_t format, - unsigned int width, - unsigned int height, - unsigned int stride, - void *data, - cairo_bool_t interpolate, - CGColorSpaceRef colorSpaceOverride, - CGDataProviderReleaseDataCallback releaseCallback, - void *releaseInfo); - -CGFontRef -_cairo_quartz_scaled_font_get_cg_font_ref (cairo_scaled_font_t *sfont); - -CTFontRef -_cairo_quartz_scaled_font_get_ct_font_ref (cairo_scaled_font_t *sfont); - -#else - -# error Cairo was not compiled with support for the quartz backend - -#endif /* CAIRO_HAS_QUARTZ_SURFACE */ - -#endif /* CAIRO_QUARTZ_PRIVATE_H */ diff --git a/libs/cairo/cairo/src/cairo-quartz-surface.c b/libs/cairo/cairo/src/cairo-quartz-surface.c deleted file mode 100644 index d5a5ffd92..000000000 --- a/libs/cairo/cairo/src/cairo-quartz-surface.c +++ /dev/null @@ -1,3768 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE /* required for RTLD_DEFAULT */ -#endif -#include "cairoint.h" - -#include "cairo-quartz-private.h" - -#include "cairo-error-private.h" -#include "cairo-surface-clipper-private.h" -#include "cairo-gstate-private.h" -#include "cairo-private.h" - -#include <dlfcn.h> - -#ifndef RTLD_DEFAULT -#define RTLD_DEFAULT ((void *) 0) -#endif - -#include <limits.h> - -#undef QUARTZ_DEBUG - -#ifdef QUARTZ_DEBUG -#define ND(_x) fprintf _x -#else -#define ND(_x) do {} while(0) -#endif - -#define IS_EMPTY(s) ((s)->extents.width == 0 || (s)->extents.height == 0) - -/** - * SECTION:cairo-quartz - * @Title: Quartz Surfaces - * @Short_Description: Rendering to Quartz surfaces - * @See_Also: #cairo_surface_t - * - * The Quartz surface is used to render cairo graphics targeting the - * Apple OS X Quartz rendering system. - */ - -/** - * CAIRO_HAS_QUARTZ_SURFACE: - * - * Defined if the Quartz surface backend is available. - * This macro can be used to conditionally compile backend-specific code. - */ - -/* Here are some of the differences between cairo and CoreGraphics - - cairo has only a single source active at once vs. CoreGraphics having - separate sources for stroke and fill -*/ - -/* This method is private, but it exists. Its params are are exposed - * as args to the NS* method, but not as CG. - */ -enum PrivateCGCompositeMode { - kPrivateCGCompositeClear = 0, - kPrivateCGCompositeCopy = 1, - kPrivateCGCompositeSourceOver = 2, - kPrivateCGCompositeSourceIn = 3, - kPrivateCGCompositeSourceOut = 4, - kPrivateCGCompositeSourceAtop = 5, - kPrivateCGCompositeDestinationOver = 6, - kPrivateCGCompositeDestinationIn = 7, - kPrivateCGCompositeDestinationOut = 8, - kPrivateCGCompositeDestinationAtop = 9, - kPrivateCGCompositeXOR = 10, - kPrivateCGCompositePlusDarker = 11, // (max (0, (1-d) + (1-s))) - kPrivateCGCompositePlusLighter = 12, // (min (1, s + d)) -}; -typedef enum PrivateCGCompositeMode PrivateCGCompositeMode; -CG_EXTERN void CGContextSetCompositeOperation (CGContextRef, PrivateCGCompositeMode); -CG_EXTERN void CGContextSetCTM (CGContextRef, CGAffineTransform); - -/* We need to work with the 10.3 SDK as well (and 10.3 machines; luckily, 10.3.9 - * has all the stuff we care about, just some of it isn't exported in the SDK. - */ -#ifndef kCGBitmapByteOrder32Host -#define USE_10_3_WORKAROUNDS -#define kCGBitmapAlphaInfoMask 0x1F -#define kCGBitmapByteOrderMask 0x7000 -#define kCGBitmapByteOrder32Host 0 - -typedef uint32_t CGBitmapInfo; - -/* public in 10.4, present in 10.3.9 */ -CG_EXTERN void CGContextReplacePathWithStrokedPath (CGContextRef); -CG_EXTERN CGImageRef CGBitmapContextCreateImage (CGContextRef); -#endif - -/* Some of these are present in earlier versions of the OS than where - * they are public; others are not public at all (CGContextCopyPath, - * CGContextReplacePathWithClipPath, many of the getters, etc.) - */ -static void (*CGContextClipToMaskPtr) (CGContextRef, CGRect, CGImageRef) = NULL; -static void (*CGContextDrawTiledImagePtr) (CGContextRef, CGRect, CGImageRef) = NULL; -static unsigned int (*CGContextGetTypePtr) (CGContextRef) = NULL; -static void (*CGContextSetShouldAntialiasFontsPtr) (CGContextRef, bool) = NULL; -static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL; -static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL; -static CGPathRef (*CGContextCopyPathPtr) (CGContextRef) = NULL; -static CGFloat (*CGContextGetAlphaPtr) (CGContextRef) = NULL; - -/* CTFontDrawGlyphs is not available until 10.7 */ -static void (*CTFontDrawGlyphsPtr) (CTFontRef, const CGGlyph[], const CGPoint[], size_t, CGContextRef) = NULL; - -static SInt32 _cairo_quartz_osx_version = 0x0; - -static cairo_bool_t _cairo_quartz_symbol_lookup_done = FALSE; - -/* - * Utility functions - */ - -#ifdef QUARTZ_DEBUG -static void quartz_surface_to_png (cairo_quartz_surface_t *nq, char *dest); -static void quartz_image_to_png (CGImageRef, char *dest); -#endif - -static cairo_quartz_surface_t * -_cairo_quartz_surface_create_internal (CGContextRef cgContext, - cairo_content_t content, - unsigned int width, - unsigned int height); - -static cairo_bool_t -_cairo_surface_is_quartz (const cairo_surface_t *surface); - -/* Load all extra symbols */ -static void quartz_ensure_symbols(void) -{ - if (_cairo_quartz_symbol_lookup_done) - return; - - CGContextClipToMaskPtr = dlsym(RTLD_DEFAULT, "CGContextClipToMask"); - CGContextDrawTiledImagePtr = dlsym(RTLD_DEFAULT, "CGContextDrawTiledImage"); - CGContextGetTypePtr = dlsym(RTLD_DEFAULT, "CGContextGetType"); - CGContextSetShouldAntialiasFontsPtr = dlsym(RTLD_DEFAULT, "CGContextSetShouldAntialiasFonts"); - CGContextCopyPathPtr = dlsym(RTLD_DEFAULT, "CGContextCopyPath"); - CGContextGetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing"); - CGContextSetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextSetAllowsFontSmoothing"); - CGContextGetAlphaPtr = dlsym(RTLD_DEFAULT, "CGContextGetAlpha"); - - CTFontDrawGlyphsPtr = dlsym(RTLD_DEFAULT, "CTFontDrawGlyphs"); - -#if !TARGET_OS_IPHONE - if (Gestalt(gestaltSystemVersion, &_cairo_quartz_osx_version) != noErr) { - // assume 10.5 - _cairo_quartz_osx_version = 0x1050; - } -#else - //TODO: this is not great - _cairo_quartz_osx_version = 0x1050; -#endif - - _cairo_quartz_symbol_lookup_done = TRUE; -} - -CGImageRef -_cairo_quartz_create_cgimage (cairo_format_t format, - unsigned int width, - unsigned int height, - unsigned int stride, - void *data, - cairo_bool_t interpolate, - CGColorSpaceRef colorSpaceOverride, - CGDataProviderReleaseDataCallback releaseCallback, - void *releaseInfo) -{ - CGImageRef image = NULL; - CGDataProviderRef dataProvider = NULL; - CGColorSpaceRef colorSpace = colorSpaceOverride; - CGBitmapInfo bitinfo = kCGBitmapByteOrder32Host; - int bitsPerComponent, bitsPerPixel; - - switch (format) { - case CAIRO_FORMAT_ARGB32: - if (colorSpace == NULL) - colorSpace = CGColorSpaceCreateDeviceRGB(); - bitinfo |= kCGImageAlphaPremultipliedFirst; - bitsPerComponent = 8; - bitsPerPixel = 32; - break; - - case CAIRO_FORMAT_RGB24: - if (colorSpace == NULL) - colorSpace = CGColorSpaceCreateDeviceRGB(); - bitinfo |= kCGImageAlphaNoneSkipFirst; - bitsPerComponent = 8; - bitsPerPixel = 32; - break; - - case CAIRO_FORMAT_A8: - bitsPerComponent = 8; - bitsPerPixel = 8; - break; - - case CAIRO_FORMAT_A1: -#ifdef WORDS_BIGENDIAN - bitsPerComponent = 1; - bitsPerPixel = 1; - break; -#endif - - case CAIRO_FORMAT_RGB16_565: - case CAIRO_FORMAT_INVALID: - default: - return NULL; - } - - dataProvider = CGDataProviderCreateWithData (releaseInfo, - data, - height * stride, - releaseCallback); - - if (!dataProvider) { - // manually release - if (releaseCallback) - releaseCallback (releaseInfo, data, height * stride); - goto FINISH; - } - - if (format == CAIRO_FORMAT_A8 || format == CAIRO_FORMAT_A1) { - cairo_quartz_float_t decode[] = {1.0, 0.0}; - image = CGImageMaskCreate (width, height, - bitsPerComponent, - bitsPerPixel, - stride, - dataProvider, - decode, - interpolate); - } else - image = CGImageCreate (width, height, - bitsPerComponent, - bitsPerPixel, - stride, - colorSpace, - bitinfo, - dataProvider, - NULL, - interpolate, - kCGRenderingIntentDefault); - -FINISH: - - CGDataProviderRelease (dataProvider); - - if (colorSpace != colorSpaceOverride) - CGColorSpaceRelease (colorSpace); - - return image; -} - -static inline cairo_bool_t -_cairo_quartz_is_cgcontext_bitmap_context (CGContextRef cgc) { - if (cgc == NULL) - return FALSE; - - if (CGContextGetTypePtr) { - /* 4 is the type value of a bitmap context */ - if (CGContextGetTypePtr(cgc) == 4) - return TRUE; - return FALSE; - } - - /* This will cause a (harmless) warning to be printed if called on a non-bitmap context */ - return CGBitmapContextGetBitsPerPixel(cgc) != 0; -} - -/* CoreGraphics limitation with flipped CTM surfaces: height must be less than signed 16-bit max */ - -#define CG_MAX_HEIGHT SHRT_MAX -#define CG_MAX_WIDTH USHRT_MAX - -/* is the desired size of the surface within bounds? */ -cairo_bool_t -_cairo_quartz_verify_surface_size(int width, int height) -{ - /* hmmm, allow width, height == 0 ? */ - if (width < 0 || height < 0) { - return FALSE; - } - - if (width > CG_MAX_WIDTH || height > CG_MAX_HEIGHT) { - return FALSE; - } - - return TRUE; -} - -/* - * Cairo path -> Quartz path conversion helpers - */ - -/* cairo path -> execute in context */ -static cairo_status_t -_cairo_path_to_quartz_context_move_to (void *closure, - const cairo_point_t *point) -{ - //ND((stderr, "moveto: %f %f\n", _cairo_fixed_to_double(point->x), _cairo_fixed_to_double(point->y))); - double x = _cairo_fixed_to_double (point->x); - double y = _cairo_fixed_to_double (point->y); - - CGContextMoveToPoint (closure, x, y); - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_path_to_quartz_context_line_to (void *closure, - const cairo_point_t *point) -{ - //ND((stderr, "lineto: %f %f\n", _cairo_fixed_to_double(point->x), _cairo_fixed_to_double(point->y))); - double x = _cairo_fixed_to_double (point->x); - double y = _cairo_fixed_to_double (point->y); - - CGContextAddLineToPoint (closure, x, y); - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_path_to_quartz_context_curve_to (void *closure, - const cairo_point_t *p0, - const cairo_point_t *p1, - const cairo_point_t *p2) -{ - //ND( (stderr, "curveto: %f,%f %f,%f %f,%f\n", - // _cairo_fixed_to_double(p0->x), _cairo_fixed_to_double(p0->y), - // _cairo_fixed_to_double(p1->x), _cairo_fixed_to_double(p1->y), - // _cairo_fixed_to_double(p2->x), _cairo_fixed_to_double(p2->y))); - double x0 = _cairo_fixed_to_double (p0->x); - double y0 = _cairo_fixed_to_double (p0->y); - double x1 = _cairo_fixed_to_double (p1->x); - double y1 = _cairo_fixed_to_double (p1->y); - double x2 = _cairo_fixed_to_double (p2->x); - double y2 = _cairo_fixed_to_double (p2->y); - - CGContextAddCurveToPoint (closure, - x0, y0, x1, y1, x2, y2); - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_path_to_quartz_context_close_path (void *closure) -{ - //ND((stderr, "closepath\n")); - CGContextClosePath (closure); - return CAIRO_STATUS_SUCCESS; -} - -static void -_cairo_quartz_cairo_path_to_quartz_context (cairo_path_fixed_t *path, - CGContextRef closure) -{ - cairo_status_t status; - - CGContextBeginPath (closure); - status = _cairo_path_fixed_interpret (path, - CAIRO_DIRECTION_FORWARD, - _cairo_path_to_quartz_context_move_to, - _cairo_path_to_quartz_context_line_to, - _cairo_path_to_quartz_context_curve_to, - _cairo_path_to_quartz_context_close_path, - closure); - - assert (status == CAIRO_STATUS_SUCCESS); -} - -/* - * Misc helpers/callbacks - */ - -static PrivateCGCompositeMode -_cairo_quartz_cairo_operator_to_quartz_composite (cairo_operator_t op) -{ - switch (op) { - case CAIRO_OPERATOR_CLEAR: - return kPrivateCGCompositeClear; - case CAIRO_OPERATOR_SOURCE: - return kPrivateCGCompositeCopy; - case CAIRO_OPERATOR_OVER: - return kPrivateCGCompositeSourceOver; - case CAIRO_OPERATOR_IN: - return kPrivateCGCompositeSourceIn; - case CAIRO_OPERATOR_OUT: - return kPrivateCGCompositeSourceOut; - case CAIRO_OPERATOR_ATOP: - return kPrivateCGCompositeSourceAtop; - case CAIRO_OPERATOR_DEST_OVER: - return kPrivateCGCompositeDestinationOver; - case CAIRO_OPERATOR_DEST_IN: - return kPrivateCGCompositeDestinationIn; - case CAIRO_OPERATOR_DEST_OUT: - return kPrivateCGCompositeDestinationOut; - case CAIRO_OPERATOR_DEST_ATOP: - return kPrivateCGCompositeDestinationAtop; - case CAIRO_OPERATOR_XOR: - return kPrivateCGCompositeXOR; - case CAIRO_OPERATOR_ADD: - return kPrivateCGCompositePlusLighter; - - case CAIRO_OPERATOR_DEST: - case CAIRO_OPERATOR_SATURATE: - case CAIRO_OPERATOR_MULTIPLY: - case CAIRO_OPERATOR_SCREEN: - case CAIRO_OPERATOR_OVERLAY: - case CAIRO_OPERATOR_DARKEN: - case CAIRO_OPERATOR_LIGHTEN: - case CAIRO_OPERATOR_COLOR_DODGE: - case CAIRO_OPERATOR_COLOR_BURN: - case CAIRO_OPERATOR_HARD_LIGHT: - case CAIRO_OPERATOR_SOFT_LIGHT: - case CAIRO_OPERATOR_DIFFERENCE: - case CAIRO_OPERATOR_EXCLUSION: - case CAIRO_OPERATOR_HSL_HUE: - case CAIRO_OPERATOR_HSL_SATURATION: - case CAIRO_OPERATOR_HSL_COLOR: - case CAIRO_OPERATOR_HSL_LUMINOSITY: - default: - assert (0); - return kPrivateCGCompositeClear; - } -} - -static cairo_int_status_t -_cairo_quartz_surface_set_cairo_operator (cairo_quartz_surface_t *surface, cairo_operator_t op) -{ - ND((stderr, "%p _cairo_quartz_surface_set_cairo_operator %d\n", surface, op)); - - if (surface->base.content == CAIRO_CONTENT_ALPHA) { - /* For some weird reason, some compositing operators are - swapped when operating on masks */ - switch (op) { - case CAIRO_OPERATOR_CLEAR: - case CAIRO_OPERATOR_SOURCE: - case CAIRO_OPERATOR_OVER: - case CAIRO_OPERATOR_DEST_IN: - case CAIRO_OPERATOR_DEST_OUT: - case CAIRO_OPERATOR_ADD: - CGContextSetCompositeOperation (surface->cgContext, _cairo_quartz_cairo_operator_to_quartz_composite (op)); - return CAIRO_STATUS_SUCCESS; - - case CAIRO_OPERATOR_IN: - CGContextSetCompositeOperation (surface->cgContext, kPrivateCGCompositeDestinationAtop); - return CAIRO_STATUS_SUCCESS; - - case CAIRO_OPERATOR_DEST_OVER: - case CAIRO_OPERATOR_MULTIPLY: - case CAIRO_OPERATOR_SCREEN: - case CAIRO_OPERATOR_OVERLAY: - case CAIRO_OPERATOR_DARKEN: - case CAIRO_OPERATOR_LIGHTEN: - case CAIRO_OPERATOR_COLOR_DODGE: - case CAIRO_OPERATOR_COLOR_BURN: - case CAIRO_OPERATOR_HARD_LIGHT: - case CAIRO_OPERATOR_SOFT_LIGHT: - case CAIRO_OPERATOR_DIFFERENCE: - case CAIRO_OPERATOR_EXCLUSION: - case CAIRO_OPERATOR_HSL_HUE: - case CAIRO_OPERATOR_HSL_SATURATION: - case CAIRO_OPERATOR_HSL_COLOR: - case CAIRO_OPERATOR_HSL_LUMINOSITY: - CGContextSetCompositeOperation (surface->cgContext, kPrivateCGCompositeSourceOver); - return CAIRO_STATUS_SUCCESS; - - case CAIRO_OPERATOR_DEST_ATOP: - CGContextSetCompositeOperation (surface->cgContext, kPrivateCGCompositeSourceIn); - return CAIRO_STATUS_SUCCESS; - - case CAIRO_OPERATOR_SATURATE: - CGContextSetCompositeOperation (surface->cgContext, kPrivateCGCompositePlusLighter); - return CAIRO_STATUS_SUCCESS; - - - case CAIRO_OPERATOR_ATOP: - /* - CGContextSetCompositeOperation (surface->cgContext, kPrivateCGCompositeDestinationOver); - return CAIRO_STATUS_SUCCESS; - */ - case CAIRO_OPERATOR_DEST: - return CAIRO_INT_STATUS_NOTHING_TO_DO; - - case CAIRO_OPERATOR_OUT: - case CAIRO_OPERATOR_XOR: - default: - return CAIRO_INT_STATUS_UNSUPPORTED; - } - } else { - switch (op) { - case CAIRO_OPERATOR_CLEAR: - case CAIRO_OPERATOR_SOURCE: - case CAIRO_OPERATOR_OVER: - case CAIRO_OPERATOR_IN: - case CAIRO_OPERATOR_OUT: - case CAIRO_OPERATOR_ATOP: - case CAIRO_OPERATOR_DEST_OVER: - case CAIRO_OPERATOR_DEST_IN: - case CAIRO_OPERATOR_DEST_OUT: - case CAIRO_OPERATOR_DEST_ATOP: - case CAIRO_OPERATOR_XOR: - case CAIRO_OPERATOR_ADD: - CGContextSetCompositeOperation (surface->cgContext, _cairo_quartz_cairo_operator_to_quartz_composite (op)); - return CAIRO_STATUS_SUCCESS; - - case CAIRO_OPERATOR_DEST: - return CAIRO_INT_STATUS_NOTHING_TO_DO; - - case CAIRO_OPERATOR_SATURATE: - /* TODO: the following are mostly supported by CGContextSetBlendMode*/ - case CAIRO_OPERATOR_MULTIPLY: - case CAIRO_OPERATOR_SCREEN: - case CAIRO_OPERATOR_OVERLAY: - case CAIRO_OPERATOR_DARKEN: - case CAIRO_OPERATOR_LIGHTEN: - case CAIRO_OPERATOR_COLOR_DODGE: - case CAIRO_OPERATOR_COLOR_BURN: - case CAIRO_OPERATOR_HARD_LIGHT: - case CAIRO_OPERATOR_SOFT_LIGHT: - case CAIRO_OPERATOR_DIFFERENCE: - case CAIRO_OPERATOR_EXCLUSION: - case CAIRO_OPERATOR_HSL_HUE: - case CAIRO_OPERATOR_HSL_SATURATION: - case CAIRO_OPERATOR_HSL_COLOR: - case CAIRO_OPERATOR_HSL_LUMINOSITY: - default: - return CAIRO_INT_STATUS_UNSUPPORTED; - } - } -} - -static inline CGLineCap -_cairo_quartz_cairo_line_cap_to_quartz (cairo_line_cap_t ccap) -{ - switch (ccap) { - case CAIRO_LINE_CAP_BUTT: return kCGLineCapButt; break; - case CAIRO_LINE_CAP_ROUND: return kCGLineCapRound; break; - case CAIRO_LINE_CAP_SQUARE: return kCGLineCapSquare; break; - } - - return kCGLineCapButt; -} - -static inline CGLineJoin -_cairo_quartz_cairo_line_join_to_quartz (cairo_line_join_t cjoin) -{ - switch (cjoin) { - case CAIRO_LINE_JOIN_MITER: return kCGLineJoinMiter; break; - case CAIRO_LINE_JOIN_ROUND: return kCGLineJoinRound; break; - case CAIRO_LINE_JOIN_BEVEL: return kCGLineJoinBevel; break; - } - - return kCGLineJoinMiter; -} - -static inline CGInterpolationQuality -_cairo_quartz_filter_to_quartz (cairo_filter_t filter) -{ - switch (filter) { - case CAIRO_FILTER_NEAREST: - return kCGInterpolationNone; - - case CAIRO_FILTER_FAST: - return kCGInterpolationLow; - - case CAIRO_FILTER_BEST: - case CAIRO_FILTER_GOOD: - case CAIRO_FILTER_BILINEAR: - case CAIRO_FILTER_GAUSSIAN: - return kCGInterpolationDefault; - } - - return kCGInterpolationDefault; -} - -static inline void -_cairo_quartz_cairo_matrix_to_quartz (const cairo_matrix_t *src, - CGAffineTransform *dst) -{ - dst->a = src->xx; - dst->b = src->yx; - dst->c = src->xy; - dst->d = src->yy; - dst->tx = src->x0; - dst->ty = src->y0; -} - -typedef struct { - bool isClipping; - CGGlyph *cg_glyphs; - union { - CGSize *cg_advances; - CGPoint *cg_positions; - } u; - size_t nglyphs; - CGAffineTransform textTransform; - cairo_scaled_font_t *scaled_font; - CGPoint origin; -} unbounded_show_glyphs_t; - -typedef struct { - CGPathRef cgPath; - cairo_fill_rule_t fill_rule; -} unbounded_stroke_fill_t; - -typedef struct { - CGImageRef mask; - CGAffineTransform maskTransform; -} unbounded_mask_t; - -typedef enum { - UNBOUNDED_STROKE_FILL, - UNBOUNDED_SHOW_GLYPHS, - UNBOUNDED_MASK -} unbounded_op_t; - -typedef struct { - unbounded_op_t op; - union { - unbounded_stroke_fill_t stroke_fill; - unbounded_show_glyphs_t show_glyphs; - unbounded_mask_t mask; - } u; -} unbounded_op_data_t; - -static void -_cairo_quartz_fixup_unbounded_operation (cairo_quartz_surface_t *surface, - unbounded_op_data_t *op, - cairo_antialias_t antialias) -{ - CGRect clipBox, clipBoxRound; - CGContextRef cgc; - CGImageRef maskImage; - - /* TODO: handle failure */ - if (!CGContextClipToMaskPtr) - return; - - clipBox = CGContextGetClipBoundingBox (surface->cgContext); - clipBoxRound = CGRectIntegral (clipBox); - - cgc = CGBitmapContextCreate (NULL, - clipBoxRound.size.width, - clipBoxRound.size.height, - 8, - (((size_t) clipBoxRound.size.width) + 15) & (~15), - NULL, - kCGImageAlphaOnly); - - if (!cgc) - return; - - CGContextSetCompositeOperation (cgc, kPrivateCGCompositeCopy); - /* We want to mask out whatever we just rendered, so we fill the - * surface opaque, and then we'll render transparent. - */ - CGContextSetAlpha (cgc, 1.0f); - CGContextFillRect (cgc, CGRectMake (0, 0, clipBoxRound.size.width, clipBoxRound.size.height)); - - CGContextSetCompositeOperation (cgc, kPrivateCGCompositeClear); - CGContextSetShouldAntialias (cgc, (antialias != CAIRO_ANTIALIAS_NONE)); - - CGContextTranslateCTM (cgc, -clipBoxRound.origin.x, -clipBoxRound.origin.y); - - /* We need to either render the path that was given to us, or the glyph op */ - if (op->op == UNBOUNDED_STROKE_FILL) { - CGContextBeginPath (cgc); - CGContextAddPath (cgc, op->u.stroke_fill.cgPath); - - if (op->u.stroke_fill.fill_rule == CAIRO_FILL_RULE_WINDING) - CGContextFillPath (cgc); - else - CGContextEOFillPath (cgc); - } else if (op->op == UNBOUNDED_SHOW_GLYPHS) { - if (op->u.show_glyphs.isClipping) { - /* Note that the comment in show_glyphs about kCGTextClip - * and the text transform still applies here; however, the - * cg_advances we have were already transformed, so we - * don't have to do anything. */ - CGContextSetTextDrawingMode (cgc, kCGTextClip); - CGContextSaveGState (cgc); - } - CGContextTranslateCTM (cgc, op->u.show_glyphs.origin.x, op->u.show_glyphs.origin.y); - CGContextConcatCTM (cgc, op->u.show_glyphs.textTransform); - if (CTFontDrawGlyphsPtr) { - CTFontDrawGlyphsPtr (_cairo_quartz_scaled_font_get_ct_font_ref (op->u.show_glyphs.scaled_font), - op->u.show_glyphs.cg_glyphs, - op->u.show_glyphs.u.cg_positions, - op->u.show_glyphs.nglyphs, - cgc); - } else { - CGContextSetFont (cgc, _cairo_quartz_scaled_font_get_cg_font_ref (op->u.show_glyphs.scaled_font)); - CGContextSetFontSize (cgc, 1.0); - CGContextSetTextMatrix (cgc, CGAffineTransformIdentity); - - CGContextShowGlyphsWithAdvances (cgc, - op->u.show_glyphs.cg_glyphs, - op->u.show_glyphs.u.cg_advances, - op->u.show_glyphs.nglyphs); - - } - if (op->u.show_glyphs.isClipping) { - CGContextClearRect (cgc, clipBoxRound); - CGContextRestoreGState (cgc); - } - } else if (op->op == UNBOUNDED_MASK) { - CGAffineTransform ctm = CGContextGetCTM (cgc); - CGContextSaveGState (cgc); - CGContextConcatCTM (cgc, op->u.mask.maskTransform); - CGContextClipToMask (cgc, CGRectMake (0.0f, 0.0f, - CGImageGetWidth(op->u.mask.mask), CGImageGetHeight(op->u.mask.mask)), - op->u.mask.mask); - CGContextSetCTM (cgc, ctm); - CGContextClearRect (cgc, clipBoxRound); - CGContextRestoreGState (cgc); - } - - /* Also mask out the portion of the clipbox that we rounded out, if any */ - if (!CGRectEqualToRect (clipBox, clipBoxRound)) { - CGContextBeginPath (cgc); - CGContextAddRect (cgc, clipBoxRound); - CGContextAddRect (cgc, clipBox); - CGContextEOFillPath (cgc); - } - - maskImage = CGBitmapContextCreateImage (cgc); - CGContextRelease (cgc); - - if (!maskImage) - return; - - /* Then render with the mask */ - CGContextSaveGState (surface->cgContext); - - CGContextSetCompositeOperation (surface->cgContext, kPrivateCGCompositeCopy); - CGContextClipToMaskPtr (surface->cgContext, clipBoxRound, maskImage); - CGImageRelease (maskImage); - - /* Finally, clear out the entire clipping region through our mask */ - CGContextClearRect (surface->cgContext, clipBoxRound); - - CGContextRestoreGState (surface->cgContext); -} - -/* - * Source -> Quartz setup and finish functions - */ - -static void -ComputeGradientValue (void *info, - const cairo_quartz_float_t *in, - cairo_quartz_float_t *out) -{ - double fdist = *in; - const cairo_gradient_pattern_t *grad = (cairo_gradient_pattern_t*) info; - unsigned int i; - - /* Put fdist back in the 0.0..1.0 range if we're doing - * REPEAT/REFLECT - */ - if (grad->base.extend == CAIRO_EXTEND_REPEAT) { - fdist = fdist - floor(fdist); - } else if (grad->base.extend == CAIRO_EXTEND_REFLECT) { - fdist = fmod(fabs(fdist), 2.0); - if (fdist > 1.0) { - fdist = 2.0 - fdist; - } - } - - for (i = 0; i < grad->n_stops; i++) { - if (grad->stops[i].offset > fdist) - break; - } - - if (i == 0 || i == grad->n_stops) { - if (i == grad->n_stops) - --i; - out[0] = grad->stops[i].color.red; - out[1] = grad->stops[i].color.green; - out[2] = grad->stops[i].color.blue; - out[3] = grad->stops[i].color.alpha; - } else { - cairo_quartz_float_t ax = grad->stops[i-1].offset; - cairo_quartz_float_t bx = grad->stops[i].offset - ax; - cairo_quartz_float_t bp = (fdist - ax)/bx; - cairo_quartz_float_t ap = 1.0 - bp; - - out[0] = - grad->stops[i-1].color.red * ap + - grad->stops[i].color.red * bp; - out[1] = - grad->stops[i-1].color.green * ap + - grad->stops[i].color.green * bp; - out[2] = - grad->stops[i-1].color.blue * ap + - grad->stops[i].color.blue * bp; - out[3] = - grad->stops[i-1].color.alpha * ap + - grad->stops[i].color.alpha * bp; - } -} - -static const cairo_quartz_float_t gradient_output_value_ranges[8] = { - 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f -}; -static const CGFunctionCallbacks gradient_callbacks = { - 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy -}; -/* Quartz will clamp input values to the input range. - - Our stops are all in the range 0.0 to 1.0. However, the color before the - beginning of the gradient line is obtained by Quartz computing a negative - position on the gradient line, clamping it to the input range we specified - for our color function, and then calling our color function (actually it - pre-samples the color function into an array, but that doesn't matter just - here). Therefore if we set the lower bound to 0.0, a negative position - on the gradient line will pass 0.0 to ComputeGradientValue, which will - select the last color stop with position 0, although it should select - the first color stop (this matters when there are multiple color stops with - position 0). - - Therefore we pass a small negative number as the lower bound of the input - range, so this value gets passed into ComputeGradientValue, which will - return the color of the first stop. The number should be small because - as far as I can tell, Quartz pre-samples the entire input range of the color - function into an array of fixed size, so if the input range is larger - than needed, the resolution of the gradient will be unnecessarily low. -*/ -static const cairo_quartz_float_t nonrepeating_gradient_input_value_range[2] = { -0.001f, 1.f }; - -static CGFunctionRef -CreateGradientFunction (const cairo_gradient_pattern_t *gpat) -{ - cairo_pattern_t *pat; - - if (_cairo_pattern_create_copy (&pat, &gpat->base)) - /* quartz doesn't deal very well with malloc failing, so there's - * not much point in us trying either */ - return NULL; - - return CGFunctionCreate (pat, - 1, - nonrepeating_gradient_input_value_range, - 4, - gradient_output_value_ranges, - &gradient_callbacks); -} - -static void -UpdateLinearParametersToIncludePoint(double *min_t, double *max_t, CGPoint *start, - double dx, double dy, - double x, double y) -{ - /* Compute a parameter t such that a line perpendicular to the (dx,dy) - vector, passing through (start->x + dx*t, start->y + dy*t), also - passes through (x,y). - - Let px = x - start->x, py = y - start->y. - t is given by - (px - dx*t)*dx + (py - dy*t)*dy = 0 - - Solving for t we get - numerator = dx*px + dy*py - denominator = dx^2 + dy^2 - t = numerator/denominator - - In CreateRepeatingLinearGradientFunction we know the length of (dx,dy) - is not zero. (This is checked in _cairo_quartz_setup_linear_source.) - */ - double px = x - start->x; - double py = y - start->y; - double numerator = dx*px + dy*py; - double denominator = dx*dx + dy*dy; - double t = numerator/denominator; - - if (*min_t > t) { - *min_t = t; - } - if (*max_t < t) { - *max_t = t; - } -} - -static CGFunctionRef -CreateRepeatingLinearGradientFunction (cairo_quartz_surface_t *surface, - const cairo_gradient_pattern_t *gpat, - CGPoint *start, CGPoint *end, - cairo_rectangle_int_t *extents) -{ - cairo_pattern_t *pat; - cairo_quartz_float_t input_value_range[2]; - double t_min = 0.; - double t_max = 0.; - double dx = end->x - start->x; - double dy = end->y - start->y; - double bounds_x1, bounds_x2, bounds_y1, bounds_y2; - - if (!extents) { - extents = &surface->extents; - } - bounds_x1 = extents->x; - bounds_y1 = extents->y; - bounds_x2 = extents->x + extents->width; - bounds_y2 = extents->y + extents->height; - _cairo_matrix_transform_bounding_box (&gpat->base.matrix, - &bounds_x1, &bounds_y1, - &bounds_x2, &bounds_y2, - NULL); - - UpdateLinearParametersToIncludePoint(&t_min, &t_max, start, dx, dy, - bounds_x1, bounds_y1); - UpdateLinearParametersToIncludePoint(&t_min, &t_max, start, dx, dy, - bounds_x2, bounds_y1); - UpdateLinearParametersToIncludePoint(&t_min, &t_max, start, dx, dy, - bounds_x2, bounds_y2); - UpdateLinearParametersToIncludePoint(&t_min, &t_max, start, dx, dy, - bounds_x1, bounds_y2); - - /* Move t_min and t_max to the nearest usable integer to try to avoid - subtle variations due to numerical instability, especially accidentally - cutting off a pixel. Extending the gradient repetitions is always safe. */ - t_min = floor (t_min); - t_max = ceil (t_max); - end->x = start->x + dx*t_max; - end->y = start->y + dy*t_max; - start->x = start->x + dx*t_min; - start->y = start->y + dy*t_min; - - // set the input range for the function -- the function knows how to - // map values outside of 0.0 .. 1.0 to that range for REPEAT/REFLECT. - input_value_range[0] = t_min; - input_value_range[1] = t_max; - - if (_cairo_pattern_create_copy (&pat, &gpat->base)) - /* quartz doesn't deal very well with malloc failing, so there's - * not much point in us trying either */ - return NULL; - - return CGFunctionCreate (pat, - 1, - input_value_range, - 4, - gradient_output_value_ranges, - &gradient_callbacks); -} - -static void -UpdateRadialParameterToIncludePoint(double *max_t, CGPoint *center, - double dr, double dx, double dy, - double x, double y) -{ - /* Compute a parameter t such that a circle centered at - (center->x + dx*t, center->y + dy*t) with radius dr*t contains the - point (x,y). - - Let px = x - center->x, py = y - center->y. - Parameter values for which t is on the circle are given by - (px - dx*t)^2 + (py - dy*t)^2 = (t*dr)^2 - - Solving for t using the quadratic formula, and simplifying, we get - numerator = dx*px + dy*py +- - sqrt( dr^2*(px^2 + py^2) - (dx*py - dy*px)^2 ) - denominator = dx^2 + dy^2 - dr^2 - t = numerator/denominator - - In CreateRepeatingRadialGradientFunction we know the outer circle - contains the inner circle. Therefore the distance between the circle - centers plus the radius of the inner circle is less than the radius of - the outer circle. (This is checked in _cairo_quartz_setup_radial_source.) - Therefore - dx^2 + dy^2 < dr^2 - So the denominator is negative and the larger solution for t is given by - numerator = dx*px + dy*py - - sqrt( dr^2*(px^2 + py^2) - (dx*py - dy*px)^2 ) - denominator = dx^2 + dy^2 - dr^2 - t = numerator/denominator - dx^2 + dy^2 < dr^2 also ensures that the operand of sqrt is positive. - */ - double px = x - center->x; - double py = y - center->y; - double dx_py_minus_dy_px = dx*py - dy*px; - double numerator = dx*px + dy*py - - sqrt (dr*dr*(px*px + py*py) - dx_py_minus_dy_px*dx_py_minus_dy_px); - double denominator = dx*dx + dy*dy - dr*dr; - double t = numerator/denominator; - - if (*max_t < t) { - *max_t = t; - } -} - -/* This must only be called when one of the circles properly contains the other */ -static CGFunctionRef -CreateRepeatingRadialGradientFunction (cairo_quartz_surface_t *surface, - const cairo_gradient_pattern_t *gpat, - CGPoint *start, double *start_radius, - CGPoint *end, double *end_radius, - cairo_rectangle_int_t *extents) -{ - cairo_pattern_t *pat; - cairo_quartz_float_t input_value_range[2]; - CGPoint *inner; - double *inner_radius; - CGPoint *outer; - double *outer_radius; - /* minimum and maximum t-parameter values that will make our gradient - cover the clipBox */ - double t_min, t_max, t_temp; - /* outer minus inner */ - double dr, dx, dy; - double bounds_x1, bounds_x2, bounds_y1, bounds_y2; - - if (!extents) { - extents = &surface->extents; - } - bounds_x1 = extents->x; - bounds_y1 = extents->y; - bounds_x2 = extents->x + extents->width; - bounds_y2 = extents->y + extents->height; - _cairo_matrix_transform_bounding_box (&gpat->base.matrix, - &bounds_x1, &bounds_y1, - &bounds_x2, &bounds_y2, - NULL); - - if (*start_radius < *end_radius) { - /* end circle contains start circle */ - inner = start; - outer = end; - inner_radius = start_radius; - outer_radius = end_radius; - } else { - /* start circle contains end circle */ - inner = end; - outer = start; - inner_radius = end_radius; - outer_radius = start_radius; - } - - dr = *outer_radius - *inner_radius; - dx = outer->x - inner->x; - dy = outer->y - inner->y; - - /* We can't round or fudge t_min here, it has to be as accurate as possible. */ - t_min = -(*inner_radius/dr); - inner->x += t_min*dx; - inner->y += t_min*dy; - *inner_radius = 0.; - - t_temp = 0.; - UpdateRadialParameterToIncludePoint(&t_temp, inner, dr, dx, dy, - bounds_x1, bounds_y1); - UpdateRadialParameterToIncludePoint(&t_temp, inner, dr, dx, dy, - bounds_x2, bounds_y1); - UpdateRadialParameterToIncludePoint(&t_temp, inner, dr, dx, dy, - bounds_x2, bounds_y2); - UpdateRadialParameterToIncludePoint(&t_temp, inner, dr, dx, dy, - bounds_x1, bounds_y2); - /* UpdateRadialParameterToIncludePoint assumes t=0 means radius 0. - But for the parameter values we use with Quartz, t_min means radius 0. - Since the circles are alway expanding and contain the earlier circles, - it's safe to extend t_max/t_temp as much as we want, so round t_temp up - to the nearest integer. This may help us give stable results. */ - t_temp = ceil (t_temp); - t_max = t_min + t_temp; - outer->x = inner->x + t_temp*dx; - outer->y = inner->y + t_temp*dy; - *outer_radius = t_temp*dr; - - /* set the input range for the function -- the function knows how to - map values outside of 0.0 .. 1.0 to that range for REPEAT/REFLECT. */ - if (*start_radius < *end_radius) { - input_value_range[0] = t_min; - input_value_range[1] = t_max; - } else { - input_value_range[0] = 1 - t_max; - input_value_range[1] = 1 - t_min; - } - - if (_cairo_pattern_create_copy (&pat, &gpat->base)) - /* quartz doesn't deal very well with malloc failing, so there's - * not much point in us trying either */ - return NULL; - - return CGFunctionCreate (pat, - 1, - input_value_range, - 4, - gradient_output_value_ranges, - &gradient_callbacks); -} - -/* Obtain a CGImageRef from a #cairo_surface_t * */ - -typedef struct { - cairo_surface_t *surface; - cairo_image_surface_t *image_out; - void *image_extra; -} quartz_source_image_t; - -static void -DataProviderReleaseCallback (void *info, const void *data, size_t size) -{ - quartz_source_image_t *source_img = info; - _cairo_surface_release_source_image (source_img->surface, source_img->image_out, source_img->image_extra); - cairo_surface_destroy (source_img->surface); - free (source_img); -} - -static cairo_status_t -_cairo_surface_to_cgimage (cairo_surface_t *source, - CGImageRef *image_out) -{ - cairo_status_t status; - quartz_source_image_t *source_img; - - if (source->backend && source->backend->type == CAIRO_SURFACE_TYPE_QUARTZ_IMAGE) { - cairo_quartz_image_surface_t *surface = (cairo_quartz_image_surface_t *) source; - *image_out = CGImageRetain (surface->image); - return CAIRO_STATUS_SUCCESS; - } - - if (_cairo_surface_is_quartz (source)) { - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) source; - if (IS_EMPTY(surface)) { - *image_out = NULL; - return CAIRO_STATUS_SUCCESS; - } - - if (_cairo_quartz_is_cgcontext_bitmap_context (surface->cgContext)) { - if (!surface->bitmapContextImage) { - surface->bitmapContextImage = - CGBitmapContextCreateImage (surface->cgContext); - } - if (surface->bitmapContextImage) { - *image_out = CGImageRetain (surface->bitmapContextImage); - return CAIRO_STATUS_SUCCESS; - } - } - } - - source_img = malloc (sizeof (quartz_source_image_t)); - if (source_img == NULL) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - - source_img->surface = cairo_surface_reference(source); - - status = _cairo_surface_acquire_source_image (source_img->surface, &source_img->image_out, &source_img->image_extra); - if (status) { - cairo_surface_destroy (source_img->surface); - free (source_img); - return status; - } - - if (source_img->image_out->width == 0 || source_img->image_out->height == 0) { - *image_out = NULL; - DataProviderReleaseCallback (source_img, - source_img->image_out->data, - source_img->image_out->height * source_img->image_out->stride); - } else { - *image_out = _cairo_quartz_create_cgimage (source_img->image_out->format, - source_img->image_out->width, - source_img->image_out->height, - source_img->image_out->stride, - source_img->image_out->data, - TRUE, - NULL, - DataProviderReleaseCallback, - source_img); - - /* TODO: differentiate memory error and unsupported surface type */ - if (*image_out == NULL) - status = CAIRO_INT_STATUS_UNSUPPORTED; - } - - return status; -} - -/* Generic #cairo_pattern_t -> CGPattern function */ - -typedef struct { - CGImageRef image; - CGRect imageBounds; - cairo_bool_t do_reflect; -} SurfacePatternDrawInfo; - -static void -SurfacePatternDrawFunc (void *ainfo, CGContextRef context) -{ - SurfacePatternDrawInfo *info = (SurfacePatternDrawInfo*) ainfo; - - CGContextTranslateCTM (context, 0, info->imageBounds.size.height); - CGContextScaleCTM (context, 1, -1); - - CGContextDrawImage (context, info->imageBounds, info->image); - if (info->do_reflect) { - /* draw 3 more copies of the image, flipped. - * DrawImage draws the image according to the current Y-direction into the rectangle given - * (imageBounds); at the time of the first DrawImage above, the origin is at the bottom left - * of the base image position, and the Y axis is extending upwards. - */ - - /* Make the y axis extend downwards, and draw a flipped image below */ - CGContextScaleCTM (context, 1, -1); - CGContextDrawImage (context, info->imageBounds, info->image); - - /* Shift over to the right, and flip vertically (translation is 2x, - * since we'll be flipping and thus rendering the rectangle "backwards" - */ - CGContextTranslateCTM (context, 2 * info->imageBounds.size.width, 0); - CGContextScaleCTM (context, -1, 1); - CGContextDrawImage (context, info->imageBounds, info->image); - - /* Then unflip the Y-axis again, and draw the image above the point. */ - CGContextScaleCTM (context, 1, -1); - CGContextDrawImage (context, info->imageBounds, info->image); - } -} - -static void -SurfacePatternReleaseInfoFunc (void *ainfo) -{ - SurfacePatternDrawInfo *info = (SurfacePatternDrawInfo*) ainfo; - - CGImageRelease (info->image); - free (info); -} - -static cairo_int_status_t -_cairo_quartz_cairo_repeating_surface_pattern_to_quartz (cairo_quartz_surface_t *dest, - const cairo_pattern_t *apattern, - CGPatternRef *cgpat) -{ - cairo_surface_pattern_t *spattern; - cairo_surface_t *pat_surf; - cairo_rectangle_int_t extents; - - CGImageRef image; - CGRect pbounds; - CGAffineTransform ptransform, stransform; - CGPatternCallbacks cb = { 0, - SurfacePatternDrawFunc, - SurfacePatternReleaseInfoFunc }; - SurfacePatternDrawInfo *info; - cairo_quartz_float_t rw, rh; - cairo_status_t status; - cairo_bool_t is_bounded; - - cairo_matrix_t m; - - /* SURFACE is the only type we'll handle here */ - if (apattern->type != CAIRO_PATTERN_TYPE_SURFACE) - return CAIRO_INT_STATUS_UNSUPPORTED; - - spattern = (cairo_surface_pattern_t *) apattern; - pat_surf = spattern->surface; - - is_bounded = _cairo_surface_get_extents (pat_surf, &extents); - assert (is_bounded); - - status = _cairo_surface_to_cgimage (pat_surf, &image); - if (status) - return status; - if (image == NULL) - return CAIRO_INT_STATUS_NOTHING_TO_DO; - - info = malloc(sizeof(SurfacePatternDrawInfo)); - if (!info) - return CAIRO_STATUS_NO_MEMORY; - - /* XXX -- if we're printing, we may need to call CGImageCreateCopy to make sure - * that the data will stick around for this image when the printer gets to it. - * Otherwise, the underlying data store may disappear from under us! - * - * _cairo_surface_to_cgimage will copy when it converts non-Quartz surfaces, - * since the Quartz surfaces have a higher chance of sticking around. If the - * source is a quartz image surface, then it's set up to retain a ref to the - * image surface that it's backed by. - */ - info->image = image; - info->imageBounds = CGRectMake (0, 0, extents.width, extents.height); - info->do_reflect = FALSE; - - pbounds.origin.x = 0; - pbounds.origin.y = 0; - - if (spattern->base.extend == CAIRO_EXTEND_REFLECT) { - pbounds.size.width = 2.0 * extents.width; - pbounds.size.height = 2.0 * extents.height; - info->do_reflect = TRUE; - } else { - pbounds.size.width = extents.width; - pbounds.size.height = extents.height; - } - rw = pbounds.size.width; - rh = pbounds.size.height; - - m = spattern->base.matrix; - cairo_matrix_invert(&m); - _cairo_quartz_cairo_matrix_to_quartz (&m, &stransform); - - /* The pattern matrix is relative to the bottom left, again; the - * incoming cairo pattern matrix is relative to the upper left. - * So we take the pattern matrix and the original context matrix, - * which gives us the correct base translation/y flip. - */ - ptransform = CGAffineTransformConcat(stransform, dest->cgContextBaseCTM); - -#ifdef QUARTZ_DEBUG - ND((stderr, " pbounds: %f %f %f %f\n", pbounds.origin.x, pbounds.origin.y, pbounds.size.width, pbounds.size.height)); - ND((stderr, " pattern xform: t: %f %f xx: %f xy: %f yx: %f yy: %f\n", ptransform.tx, ptransform.ty, ptransform.a, ptransform.b, ptransform.c, ptransform.d)); - CGAffineTransform xform = CGContextGetCTM(dest->cgContext); - ND((stderr, " context xform: t: %f %f xx: %f xy: %f yx: %f yy: %f\n", xform.tx, xform.ty, xform.a, xform.b, xform.c, xform.d)); -#endif - - *cgpat = CGPatternCreate (info, - pbounds, - ptransform, - rw, rh, - kCGPatternTilingConstantSpacing, /* kCGPatternTilingNoDistortion, */ - TRUE, - &cb); - - return CAIRO_STATUS_SUCCESS; -} - -typedef enum { - DO_SOLID, - DO_SHADING, - DO_PATTERN, - DO_IMAGE, - DO_TILED_IMAGE, - DO_LAYER, - DO_UNSUPPORTED, - DO_NOTHING -} cairo_quartz_action_t; - -/* State used during a drawing operation. */ -typedef struct { - CGContextRef context; - cairo_quartz_action_t action; - - // Used with DO_SHADING, DO_IMAGE, DO_TILED_IMAGE and DO_LAYER - CGAffineTransform transform; - - // Used with DO_IMAGE and DO_TILED_IMAGE - CGImageRef image; - cairo_surface_t *imageSurface; - - // Used with DO_IMAGE, DO_TILED_IMAGE and DO_LAYER - CGRect imageRect; - - // Used with DO_LAYER - CGLayerRef layer; - - // Used with DO_SHADING - CGShadingRef shading; - - // Used with DO_PATTERN - CGPatternRef pattern; -} cairo_quartz_drawing_state_t; - -static void -_cairo_quartz_setup_fallback_source (cairo_quartz_surface_t *surface, - const cairo_pattern_t *source, - cairo_quartz_drawing_state_t *state) -{ - CGRect clipBox = CGContextGetClipBoundingBox (state->context); - double x0, y0, w, h; - - cairo_surface_t *fallback; - CGImageRef img; - - cairo_status_t status; - - if (clipBox.size.width == 0.0f || - clipBox.size.height == 0.0f) { - state->action = DO_NOTHING; - return; - } - - x0 = floor(clipBox.origin.x); - y0 = floor(clipBox.origin.y); - w = ceil(clipBox.origin.x + clipBox.size.width) - x0; - h = ceil(clipBox.origin.y + clipBox.size.height) - y0; - - /* Create a temporary the size of the clip surface, and position - * it so that the device origin coincides with the original surface */ - fallback = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, (int) w, (int) h); - cairo_surface_set_device_offset (fallback, -x0, -y0); - -#if 0 - { - cairo_t *fallback_cr; - cairo_pattern_t *source_copy; - - /* Paint the source onto our temporary */ - fallback_cr = cairo_create (fallback); - cairo_set_operator (fallback_cr, CAIRO_OPERATOR_SOURCE); - - /* Use a copy of the pattern because it is const and could be allocated - * on the stack */ - status = _cairo_pattern_create_copy (&source_copy, source); - cairo_set_source (fallback_cr, source_copy); - cairo_pattern_destroy (source_copy); - - cairo_paint (fallback_cr); - cairo_destroy (fallback_cr); - } -#else - { - cairo_pattern_union_t pattern; - - _cairo_pattern_init_static_copy (&pattern.base, source); - _cairo_pattern_transform (&pattern.base, - &fallback->device_transform_inverse); - status = _cairo_surface_paint (fallback, - CAIRO_OPERATOR_SOURCE, - &pattern.base, NULL); - } -#endif - - status = _cairo_surface_to_cgimage (fallback, &img); - if (status) { - state->action = DO_UNSUPPORTED; - return; - } - if (img == NULL) { - state->action = DO_NOTHING; - return; - } - - state->imageRect = CGRectMake (0.0, 0.0, w, h); - state->image = img; - state->imageSurface = fallback; - state->transform = CGAffineTransformMakeTranslation (x0, y0); - state->action = DO_IMAGE; -} - -/* -Quartz does not support repeating radients. We handle repeating gradients -by manually extending the gradient and repeating color stops. We need to -minimize the number of repetitions since Quartz seems to sample our color -function across the entire range, even if part of that range is not needed -for the visible area of the gradient, and it samples with some fixed resolution, -so if the gradient range is too large it samples with very low resolution and -the gradient is very coarse. CreateRepeatingLinearGradientFunction and -CreateRepeatingRadialGradientFunction compute the number of repetitions needed -based on the extents of the object (the clip region cannot be used here since -we don't want the rasterization of the entire gradient to depend on the -clip region). -*/ -static void -_cairo_quartz_setup_linear_source (cairo_quartz_surface_t *surface, - const cairo_linear_pattern_t *lpat, - cairo_rectangle_int_t *extents, - cairo_quartz_drawing_state_t *state) -{ - const cairo_pattern_t *abspat = &lpat->base.base; - cairo_matrix_t mat; - CGPoint start, end; - CGFunctionRef gradFunc; - CGColorSpaceRef rgb; - bool extend = abspat->extend == CAIRO_EXTEND_PAD; - - if (lpat->base.n_stops == 0) { - CGContextSetRGBStrokeColor (state->context, 0., 0., 0., 0.); - CGContextSetRGBFillColor (state->context, 0., 0., 0., 0.); - state->action = DO_SOLID; - return; - } - - if (lpat->p1.x == lpat->p2.x && - lpat->p1.y == lpat->p2.y) { - /* Quartz handles cases where the vector has no length very - * differently from pixman. - * Whatever the correct behaviour is, let's at least have only pixman's - * implementation to worry about. - */ - _cairo_quartz_setup_fallback_source (surface, abspat, state); - return; - } - - mat = abspat->matrix; - cairo_matrix_invert (&mat); - _cairo_quartz_cairo_matrix_to_quartz (&mat, &state->transform); - - rgb = CGColorSpaceCreateDeviceRGB(); - - start = CGPointMake (_cairo_fixed_to_double (lpat->p1.x), - _cairo_fixed_to_double (lpat->p1.y)); - end = CGPointMake (_cairo_fixed_to_double (lpat->p2.x), - _cairo_fixed_to_double (lpat->p2.y)); - - if (abspat->extend == CAIRO_EXTEND_NONE || - abspat->extend == CAIRO_EXTEND_PAD) - { - gradFunc = CreateGradientFunction (&lpat->base); - } else { - gradFunc = CreateRepeatingLinearGradientFunction (surface, - &lpat->base, - &start, &end, - extents); - } - - state->shading = CGShadingCreateAxial (rgb, - start, end, - gradFunc, - extend, extend); - - CGColorSpaceRelease(rgb); - CGFunctionRelease(gradFunc); - - state->action = DO_SHADING; -} - -static void -_cairo_quartz_setup_radial_source (cairo_quartz_surface_t *surface, - const cairo_radial_pattern_t *rpat, - cairo_rectangle_int_t *extents, - cairo_quartz_drawing_state_t *state) -{ - const cairo_pattern_t *abspat = &rpat->base.base; - cairo_matrix_t mat; - CGPoint start, end; - CGFunctionRef gradFunc; - CGColorSpaceRef rgb; - bool extend = abspat->extend == CAIRO_EXTEND_PAD; - double c1x = _cairo_fixed_to_double (rpat->c1.x); - double c1y = _cairo_fixed_to_double (rpat->c1.y); - double c2x = _cairo_fixed_to_double (rpat->c2.x); - double c2y = _cairo_fixed_to_double (rpat->c2.y); - double r1 = _cairo_fixed_to_double (rpat->r1); - double r2 = _cairo_fixed_to_double (rpat->r2); - double dx = c1x - c2x; - double dy = c1y - c2y; - double centerDistance = sqrt (dx*dx + dy*dy); - - if (rpat->base.n_stops == 0) { - CGContextSetRGBStrokeColor (state->context, 0., 0., 0., 0.); - CGContextSetRGBFillColor (state->context, 0., 0., 0., 0.); - state->action = DO_SOLID; - return; - } - - if (r2 <= centerDistance + r1 + 1e-6 && /* circle 2 doesn't contain circle 1 */ - r1 <= centerDistance + r2 + 1e-6) { /* circle 1 doesn't contain circle 2 */ - /* Quartz handles cases where neither circle contains the other very - * differently from pixman. - * Whatever the correct behaviour is, let's at least have only pixman's - * implementation to worry about. - * Note that this also catches the cases where r1 == r2. - */ - _cairo_quartz_setup_fallback_source (surface, abspat, state); - return; - } - - mat = abspat->matrix; - cairo_matrix_invert (&mat); - _cairo_quartz_cairo_matrix_to_quartz (&mat, &state->transform); - - rgb = CGColorSpaceCreateDeviceRGB(); - - start = CGPointMake (c1x, c1y); - end = CGPointMake (c2x, c2y); - - if (abspat->extend == CAIRO_EXTEND_NONE || - abspat->extend == CAIRO_EXTEND_PAD) - { - gradFunc = CreateGradientFunction (&rpat->base); - } else { - gradFunc = CreateRepeatingRadialGradientFunction (surface, - &rpat->base, - &start, &r1, - &end, &r2, - extents); - } - - state->shading = CGShadingCreateRadial (rgb, - start, - r1, - end, - r2, - gradFunc, - extend, extend); - - CGColorSpaceRelease(rgb); - CGFunctionRelease(gradFunc); - - state->action = DO_SHADING; -} - -static void -_cairo_quartz_setup_surface_source (cairo_quartz_surface_t *surface, - const cairo_surface_pattern_t *spat, - cairo_rectangle_int_t *extents, - cairo_quartz_drawing_state_t *state) -{ - const cairo_pattern_t *source = &spat->base; - CGContextRef context = state->context; - - if (source->extend == CAIRO_EXTEND_NONE || source->extend == CAIRO_EXTEND_PAD || - (CGContextDrawTiledImagePtr && source->extend == CAIRO_EXTEND_REPEAT)) - { - cairo_surface_t *pat_surf = spat->surface; - CGImageRef img; - cairo_matrix_t m = spat->base.matrix; - cairo_rectangle_int_t extents; - CGAffineTransform xform; - CGRect srcRect; - cairo_fixed_t fw, fh; - cairo_bool_t is_bounded; - cairo_bool_t repeat = source->extend == CAIRO_EXTEND_REPEAT; - cairo_status_t status; - - cairo_matrix_invert(&m); - _cairo_quartz_cairo_matrix_to_quartz (&m, &state->transform); - - /* Draw nonrepeating CGLayer surface using DO_LAYER */ - if (!repeat && cairo_surface_get_type (pat_surf) == CAIRO_SURFACE_TYPE_QUARTZ) { - cairo_quartz_surface_t *quartz_surf = (cairo_quartz_surface_t *) pat_surf; - if (quartz_surf->cgLayer) { - state->imageRect = CGRectMake (0, 0, quartz_surf->extents.width, quartz_surf->extents.height); - state->layer = quartz_surf->cgLayer; - state->action = DO_LAYER; - return; - } - } - - status = _cairo_surface_to_cgimage (pat_surf, &img); - if (status) { - state->action = DO_UNSUPPORTED; - return; - } - if (img == NULL) { - state->action = DO_NOTHING; - return; - } - - /* XXXroc what is this for? */ - CGContextSetRGBFillColor (surface->cgContext, 0, 0, 0, 1); - - state->image = img; - - is_bounded = _cairo_surface_get_extents (pat_surf, &extents); - assert (is_bounded); - - if (!repeat) { - state->imageRect = CGRectMake (0, 0, extents.width, extents.height); - state->action = DO_IMAGE; - return; - } - - /* Quartz seems to tile images at pixel-aligned regions only -- this - * leads to seams if the image doesn't end up scaling to fill the - * space exactly. The CGPattern tiling approach doesn't have this - * problem. Check if we're going to fill up the space (within some - * epsilon), and if not, fall back to the CGPattern type. - */ - - xform = CGAffineTransformConcat (CGContextGetCTM (context), - state->transform); - - srcRect = CGRectMake (0, 0, extents.width, extents.height); - srcRect = CGRectApplyAffineTransform (srcRect, xform); - - fw = _cairo_fixed_from_double (srcRect.size.width); - fh = _cairo_fixed_from_double (srcRect.size.height); - - if ((fw & CAIRO_FIXED_FRAC_MASK) <= CAIRO_FIXED_EPSILON && - (fh & CAIRO_FIXED_FRAC_MASK) <= CAIRO_FIXED_EPSILON) - { - /* We're good to use DrawTiledImage, but ensure that - * the math works out */ - - srcRect.size.width = round(srcRect.size.width); - srcRect.size.height = round(srcRect.size.height); - - xform = CGAffineTransformInvert (xform); - - srcRect = CGRectApplyAffineTransform (srcRect, xform); - - state->imageRect = srcRect; - state->action = DO_TILED_IMAGE; - return; - } - - /* Fall through to generic SURFACE case */ - } - - CGFloat patternAlpha = 1.0f; - CGColorSpaceRef patternSpace; - CGPatternRef pattern; - cairo_int_status_t status; - - status = _cairo_quartz_cairo_repeating_surface_pattern_to_quartz (surface, source, &pattern); - if (status == CAIRO_INT_STATUS_NOTHING_TO_DO) { - state->action = DO_NOTHING; - return; - } - if (status) { - state->action = DO_UNSUPPORTED; - return; - } - - patternSpace = CGColorSpaceCreatePattern (NULL); - CGContextSetFillColorSpace (context, patternSpace); - CGContextSetFillPattern (context, pattern, &patternAlpha); - CGContextSetStrokeColorSpace (context, patternSpace); - CGContextSetStrokePattern (context, pattern, &patternAlpha); - CGColorSpaceRelease (patternSpace); - - /* Quartz likes to munge the pattern phase (as yet unexplained - * why); force it to 0,0 as we've already baked in the correct - * pattern translation into the pattern matrix - */ - CGContextSetPatternPhase (context, CGSizeMake(0,0)); - - state->pattern = pattern; - state->action = DO_PATTERN; - return; -} - -/** - * Call this before any operation that can modify the contents of a - * cairo_quartz_surface_t. - */ -static void -_cairo_quartz_surface_will_change (cairo_quartz_surface_t *surface) -{ - if (surface->bitmapContextImage) { - CGImageRelease (surface->bitmapContextImage); - surface->bitmapContextImage = NULL; - } -} - -/** - * Sets up internal state to be used to draw the source mask, stored in - * cairo_quartz_state_t. Guarantees to call CGContextSaveGState on - * surface->cgContext. - */ -static cairo_quartz_drawing_state_t -_cairo_quartz_setup_state (cairo_quartz_surface_t *surface, - const cairo_pattern_t *source, - cairo_operator_t op, - cairo_rectangle_int_t *extents) -{ - CGContextRef context = surface->cgContext; - cairo_quartz_drawing_state_t state; - cairo_status_t status; - - state.context = context; - state.image = NULL; - state.imageSurface = NULL; - state.layer = NULL; - state.shading = NULL; - state.pattern = NULL; - - _cairo_quartz_surface_will_change (surface); - - // Save before we change the pattern, colorspace, etc. so that - // we can restore and make sure that quartz releases our - // pattern (which may be stack allocated) - CGContextSaveGState(context); - - CGContextSetInterpolationQuality (context, _cairo_quartz_filter_to_quartz (source->filter)); - - status = _cairo_quartz_surface_set_cairo_operator (surface, op); - if (status == CAIRO_INT_STATUS_NOTHING_TO_DO) { - state.action = DO_NOTHING; - return state; - } - if (status) { - state.action = DO_UNSUPPORTED; - return state; - } - - if (source->type == CAIRO_PATTERN_TYPE_SOLID) { - cairo_solid_pattern_t *solid = (cairo_solid_pattern_t *) source; - - CGContextSetRGBStrokeColor (context, - solid->color.red, - solid->color.green, - solid->color.blue, - solid->color.alpha); - CGContextSetRGBFillColor (context, - solid->color.red, - solid->color.green, - solid->color.blue, - solid->color.alpha); - - state.action = DO_SOLID; - return state; - } - - if (source->type == CAIRO_PATTERN_TYPE_LINEAR) { - const cairo_linear_pattern_t *lpat = (const cairo_linear_pattern_t *)source; - _cairo_quartz_setup_linear_source (surface, lpat, extents, &state); - return state; - } - - if (source->type == CAIRO_PATTERN_TYPE_RADIAL) { - const cairo_radial_pattern_t *rpat = (const cairo_radial_pattern_t *)source; - _cairo_quartz_setup_radial_source (surface, rpat, extents, &state); - return state; - } - - if (source->type == CAIRO_PATTERN_TYPE_SURFACE) { - if (op == CAIRO_OPERATOR_OVER && _cairo_pattern_is_opaque (source, NULL) && - CGContextGetAlphaPtr && - CGContextGetAlphaPtr (surface->cgContext) == 1.0) { - // Quartz won't touch pixels outside the bounds of the - // source surface, so we can just go ahead and use Copy here - // to accelerate things. - // Quartz won't necessarily be able to do this optimization internally; - // for CGLayer surfaces, we can know all the pixels are opaque - // (because it's CONTENT_COLOR), but Quartz won't know. - CGContextSetCompositeOperation (context, kPrivateCGCompositeCopy); - } - - const cairo_surface_pattern_t *spat = (const cairo_surface_pattern_t *) source; - _cairo_quartz_setup_surface_source (surface, spat, extents, &state); - return state; - } - - state.action = DO_UNSUPPORTED; - return state; -} - -/** - * 1) Tears down internal state used to draw the source - * 2) Does CGContextRestoreGState(state->context) - */ -static void -_cairo_quartz_teardown_state (cairo_quartz_drawing_state_t *state) -{ - if (state->image) { - CGImageRelease(state->image); - } - - if (state->imageSurface) { - cairo_surface_destroy(state->imageSurface); - } - - if (state->shading) { - CGShadingRelease(state->shading); - } - - if (state->pattern) { - CGPatternRelease(state->pattern); - } - - CGContextRestoreGState(state->context); -} - - -static void -_cairo_quartz_draw_image (cairo_quartz_drawing_state_t *state, cairo_operator_t op) -{ - assert (state && - ((state->image && (state->action == DO_IMAGE || state->action == DO_TILED_IMAGE)) || - (state->layer && state->action == DO_LAYER))); - - CGContextConcatCTM (state->context, state->transform); - CGContextTranslateCTM (state->context, 0, state->imageRect.size.height); - CGContextScaleCTM (state->context, 1, -1); - - if (state->action == DO_TILED_IMAGE) { - CGContextDrawTiledImagePtr (state->context, state->imageRect, state->image); - /* no need to worry about unbounded operators, since tiled images - fill the entire clip region */ - } else { - if (state->action == DO_LAYER) { - /* Note that according to Apple docs it's completely legal - * to draw a CGLayer to any CGContext, even one it wasn't - * created for. - */ - CGContextDrawLayerAtPoint (state->context, state->imageRect.origin, - state->layer); - } else { - CGContextDrawImage (state->context, state->imageRect, state->image); - } - - /* disable this EXTEND_NONE correctness code because we use this path - * for both EXTEND_NONE and EXTEND_PAD */ - if (0 && !_cairo_operator_bounded_by_source (op)) { - CGContextBeginPath (state->context); - CGContextAddRect (state->context, state->imageRect); - CGContextAddRect (state->context, CGContextGetClipBoundingBox (state->context)); - CGContextSetRGBFillColor (state->context, 0, 0, 0, 0); - CGContextEOFillPath (state->context); - } - } -} - - -/* - * get source/dest image implementation - */ - -/* Read the image from the surface's front buffer */ -static cairo_int_status_t -_cairo_quartz_get_image (cairo_quartz_surface_t *surface, - cairo_image_surface_t **image_out) -{ - unsigned char *imageData; - cairo_image_surface_t *isurf; - - if (IS_EMPTY(surface)) { - *image_out = (cairo_image_surface_t*) cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 0, 0); - return CAIRO_STATUS_SUCCESS; - } - - if (surface->imageSurfaceEquiv) { - CGContextFlush(surface->cgContext); - *image_out = (cairo_image_surface_t*) cairo_surface_reference(surface->imageSurfaceEquiv); - return CAIRO_STATUS_SUCCESS; - } - - if (_cairo_quartz_is_cgcontext_bitmap_context(surface->cgContext)) { - unsigned int stride; - unsigned int bitinfo; - unsigned int bpc, bpp; - CGColorSpaceRef colorspace; - unsigned int color_comps; - - CGContextFlush(surface->cgContext); - imageData = (unsigned char *) CGBitmapContextGetData(surface->cgContext); - -#ifdef USE_10_3_WORKAROUNDS - bitinfo = CGBitmapContextGetAlphaInfo (surface->cgContext); -#else - bitinfo = CGBitmapContextGetBitmapInfo (surface->cgContext); -#endif - stride = CGBitmapContextGetBytesPerRow (surface->cgContext); - bpp = CGBitmapContextGetBitsPerPixel (surface->cgContext); - bpc = CGBitmapContextGetBitsPerComponent (surface->cgContext); - - // let's hope they don't add YUV under us - colorspace = CGBitmapContextGetColorSpace (surface->cgContext); - color_comps = CGColorSpaceGetNumberOfComponents(colorspace); - - // XXX TODO: We can handle all of these by converting to - // pixman masks, including non-native-endian masks - if (bpc != 8) - return CAIRO_INT_STATUS_UNSUPPORTED; - - if (bpp != 32 && bpp != 8) - return CAIRO_INT_STATUS_UNSUPPORTED; - - if (color_comps != 3 && color_comps != 1) - return CAIRO_INT_STATUS_UNSUPPORTED; - - if (bpp == 32 && color_comps == 3 && - (bitinfo & kCGBitmapAlphaInfoMask) == kCGImageAlphaPremultipliedFirst && - (bitinfo & kCGBitmapByteOrderMask) == kCGBitmapByteOrder32Host) - { - isurf = (cairo_image_surface_t *) - cairo_image_surface_create_for_data (imageData, - CAIRO_FORMAT_ARGB32, - surface->extents.width, - surface->extents.height, - stride); - } else if (bpp == 32 && color_comps == 3 && - (bitinfo & kCGBitmapAlphaInfoMask) == kCGImageAlphaNoneSkipFirst && - (bitinfo & kCGBitmapByteOrderMask) == kCGBitmapByteOrder32Host) - { - isurf = (cairo_image_surface_t *) - cairo_image_surface_create_for_data (imageData, - CAIRO_FORMAT_RGB24, - surface->extents.width, - surface->extents.height, - stride); - } else if (bpp == 8 && color_comps == 1) - { - isurf = (cairo_image_surface_t *) - cairo_image_surface_create_for_data (imageData, - CAIRO_FORMAT_A8, - surface->extents.width, - surface->extents.height, - stride); - } else { - return CAIRO_INT_STATUS_UNSUPPORTED; - } - } else { - return CAIRO_INT_STATUS_UNSUPPORTED; - } - - *image_out = isurf; - return CAIRO_STATUS_SUCCESS; -} - -/* - * Cairo surface backend implementations - */ - -static cairo_status_t -_cairo_quartz_surface_finish (void *abstract_surface) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - - ND((stderr, "_cairo_quartz_surface_finish[%p] cgc: %p\n", surface, surface->cgContext)); - - if (IS_EMPTY(surface)) - return CAIRO_STATUS_SUCCESS; - - /* Restore our saved gstate that we use to reset clipping */ - CGContextRestoreGState (surface->cgContext); - _cairo_surface_clipper_reset (&surface->clipper); - - CGContextRelease (surface->cgContext); - - surface->cgContext = NULL; - - if (surface->bitmapContextImage) { - CGImageRelease (surface->bitmapContextImage); - surface->bitmapContextImage = NULL; - } - - if (surface->imageSurfaceEquiv) { - if (surface->ownsData) - _cairo_image_surface_assume_ownership_of_data (surface->imageSurfaceEquiv); - cairo_surface_destroy (surface->imageSurfaceEquiv); - surface->imageSurfaceEquiv = NULL; - } else if (surface->imageData && surface->ownsData) { - free (surface->imageData); - } - - surface->imageData = NULL; - - if (surface->cgLayer) { - CGLayerRelease (surface->cgLayer); - } - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_quartz_surface_acquire_image (void *abstract_surface, - cairo_image_surface_t **image_out, - void **image_extra) -{ - cairo_int_status_t status; - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - - *image_extra = NULL; - - /* ND((stderr, "%p _cairo_quartz_surface_acquire_image\n", surface)); */ - - status = _cairo_quartz_get_image (surface, image_out); - - if (status == CAIRO_INT_STATUS_UNSUPPORTED && surface->cgLayer) { - /* copy the layer into a Quartz bitmap context so we can get the data */ - cairo_surface_t *tmp = - cairo_quartz_surface_create (CAIRO_FORMAT_ARGB32, - surface->extents.width, - surface->extents.height); - cairo_quartz_surface_t *tmp_surface = (cairo_quartz_surface_t *) tmp; - - /* if surface creation failed, we won't have a Quartz surface here */ - if (cairo_surface_get_type (tmp) == CAIRO_SURFACE_TYPE_QUARTZ && - tmp_surface->imageSurfaceEquiv) { - CGContextSaveGState (tmp_surface->cgContext); - CGContextTranslateCTM (tmp_surface->cgContext, 0, surface->extents.height); - CGContextScaleCTM (tmp_surface->cgContext, 1, -1); - /* Note that according to Apple docs it's completely legal - * to draw a CGLayer to any CGContext, even one it wasn't - * created for. - */ - CGContextDrawLayerAtPoint (tmp_surface->cgContext, - CGPointMake (0.0, 0.0), - surface->cgLayer); - CGContextRestoreGState (tmp_surface->cgContext); - - *image_out = (cairo_image_surface_t*) - cairo_surface_reference(tmp_surface->imageSurfaceEquiv); - *image_extra = tmp; - status = CAIRO_STATUS_SUCCESS; - } else { - cairo_surface_destroy (tmp); - } - } - - if (status) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - - return CAIRO_STATUS_SUCCESS; -} - -static void -_cairo_quartz_surface_release_source_image (void *abstract_surface, - cairo_image_surface_t *image, - void *image_extra) -{ - cairo_surface_destroy ((cairo_surface_t *) image); - - if (image_extra) { - cairo_surface_destroy ((cairo_surface_t *) image_extra); - } -} - - -static cairo_status_t -_cairo_quartz_surface_acquire_dest_image (void *abstract_surface, - cairo_rectangle_int_t *interest_rect, - cairo_image_surface_t **image_out, - cairo_rectangle_int_t *image_rect, - void **image_extra) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - - ND((stderr, "%p _cairo_quartz_surface_acquire_dest_image\n", surface)); - - *image_rect = surface->extents; - *image_extra = NULL; - - _cairo_quartz_surface_will_change (surface); - - return _cairo_quartz_surface_acquire_image (abstract_surface, - image_out, image_extra); -} - -static void -_cairo_quartz_surface_release_dest_image (void *abstract_surface, - cairo_rectangle_int_t *interest_rect, - cairo_image_surface_t *image, - cairo_rectangle_int_t *image_rect, - void *image_extra) -{ - /* ND((stderr, "%p _cairo_quartz_surface_release_dest_image\n", surface)); */ - - cairo_surface_destroy ((cairo_surface_t *) image); - - if (image_extra) { - /* we need to write the data from the temp surface back to the layer */ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_quartz_surface_t *tmp_surface = (cairo_quartz_surface_t *) image_extra; - CGImageRef img; - cairo_status_t status = _cairo_surface_to_cgimage (&tmp_surface->base, &img); - if (status) { - cairo_surface_destroy (&tmp_surface->base); - return; - } - - CGContextSaveGState (surface->cgContext); - CGContextTranslateCTM (surface->cgContext, 0, surface->extents.height); - CGContextScaleCTM (surface->cgContext, 1, -1); - CGContextDrawImage (surface->cgContext, - CGRectMake (0.0, 0.0, surface->extents.width, surface->extents.height), - img); - CGContextRestoreGState (surface->cgContext); - - cairo_surface_destroy (&tmp_surface->base); - } -} - -static cairo_surface_t * -_cairo_quartz_surface_create_similar (void *abstract_surface, - cairo_content_t content, - int width, - int height) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_format_t format; - - if (surface->cgLayer) - return cairo_quartz_surface_create_cg_layer (abstract_surface, content, - width, height); - - if (content == CAIRO_CONTENT_COLOR_ALPHA) - format = CAIRO_FORMAT_ARGB32; - else if (content == CAIRO_CONTENT_COLOR) - format = CAIRO_FORMAT_RGB24; - else if (content == CAIRO_CONTENT_ALPHA) - format = CAIRO_FORMAT_A8; - else - return NULL; - - // verify width and height of surface - if (!_cairo_quartz_verify_surface_size(width, height)) { - return _cairo_surface_create_in_error (_cairo_error - (CAIRO_STATUS_INVALID_SIZE)); - } - - return cairo_quartz_surface_create (format, width, height); -} - -static cairo_status_t -_cairo_quartz_surface_clone_similar (void *abstract_surface, - cairo_surface_t *src, - int src_x, - int src_y, - int width, - int height, - int *clone_offset_x, - int *clone_offset_y, - cairo_surface_t **clone_out) -{ - cairo_quartz_surface_t *new_surface = NULL; - cairo_format_t new_format; - CGImageRef quartz_image = NULL; - cairo_status_t status; - - *clone_out = NULL; - - // verify width and height of surface - if (!_cairo_quartz_verify_surface_size(width, height)) { - return CAIRO_INT_STATUS_UNSUPPORTED; - } - - if (width == 0 || height == 0) { - *clone_out = (cairo_surface_t*) - _cairo_quartz_surface_create_internal (NULL, CAIRO_CONTENT_COLOR_ALPHA, - width, height); - *clone_offset_x = 0; - *clone_offset_y = 0; - return CAIRO_STATUS_SUCCESS; - } - - if (_cairo_surface_is_quartz (src)) { - cairo_quartz_surface_t *qsurf = (cairo_quartz_surface_t *) src; - - if (IS_EMPTY(qsurf)) { - *clone_out = (cairo_surface_t*) - _cairo_quartz_surface_create_internal (NULL, CAIRO_CONTENT_COLOR_ALPHA, - qsurf->extents.width, qsurf->extents.height); - *clone_offset_x = 0; - *clone_offset_y = 0; - return CAIRO_STATUS_SUCCESS; - } - } - - status = _cairo_surface_to_cgimage (src, &quartz_image); - if (status) - return CAIRO_INT_STATUS_UNSUPPORTED; - - new_format = CAIRO_FORMAT_ARGB32; /* assumed */ - if (_cairo_surface_is_image (src)) { - new_format = ((cairo_image_surface_t *) src)->format; - } - - new_surface = (cairo_quartz_surface_t *) - cairo_quartz_surface_create (new_format, width, height); - - if (quartz_image == NULL) - goto FINISH; - - if (!new_surface || new_surface->base.status) { - CGImageRelease (quartz_image); - return CAIRO_INT_STATUS_UNSUPPORTED; - } - - CGContextSaveGState (new_surface->cgContext); - - CGContextSetCompositeOperation (new_surface->cgContext, - kPrivateCGCompositeCopy); - - CGContextTranslateCTM (new_surface->cgContext, -src_x, -src_y); - CGContextDrawImage (new_surface->cgContext, - CGRectMake (0, 0, CGImageGetWidth(quartz_image), CGImageGetHeight(quartz_image)), - quartz_image); - - CGContextRestoreGState (new_surface->cgContext); - - CGImageRelease (quartz_image); - -FINISH: - *clone_offset_x = src_x; - *clone_offset_y = src_y; - *clone_out = (cairo_surface_t*) new_surface; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_bool_t -_cairo_quartz_surface_get_extents (void *abstract_surface, - cairo_rectangle_int_t *extents) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - - *extents = surface->extents; - return TRUE; -} - -static cairo_int_status_t -_cairo_quartz_surface_paint_cg (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_clip_t *clip) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_int_status_t rv = CAIRO_STATUS_SUCCESS; - cairo_quartz_drawing_state_t state; - - ND((stderr, "%p _cairo_quartz_surface_paint op %d source->type %d\n", surface, op, source->type)); - - if (IS_EMPTY(surface)) - return CAIRO_STATUS_SUCCESS; - - rv = _cairo_surface_clipper_set_clip (&surface->clipper, clip); - if (unlikely (rv)) - return rv; - - state = _cairo_quartz_setup_state (surface, source, op, NULL); - - if (state.action == DO_SOLID || state.action == DO_PATTERN) { - CGContextFillRect (state.context, CGRectMake(surface->extents.x, - surface->extents.y, - surface->extents.width, - surface->extents.height)); - } else if (state.action == DO_SHADING) { - CGContextConcatCTM (state.context, state.transform); - CGContextDrawShading (state.context, state.shading); - } else if (state.action == DO_IMAGE || state.action == DO_TILED_IMAGE || - state.action == DO_LAYER) { - _cairo_quartz_draw_image (&state, op); - } else if (state.action != DO_NOTHING) { - rv = CAIRO_INT_STATUS_UNSUPPORTED; - } - - _cairo_quartz_teardown_state (&state); - - ND((stderr, "-- paint\n")); - return rv; -} - -static cairo_bool_t -_cairo_quartz_source_needs_extents (const cairo_pattern_t *source) -{ - /* For repeating gradients we need to manually extend the gradient and - repeat stops, since Quartz doesn't support repeating gradients natively. - We need to minimze the number of repeated stops, and since rasterization - depends on the number of repetitions we use (even if some of the - repetitions go beyond the extents of the object or outside the clip - region), it's important to use the same number of repetitions when - rendering an object no matter what the clip region is. So the - computation of the repetition count cannot depended on the clip region, - and should only depend on the object extents, so we need to compute - the object extents for repeating gradients. */ - return (source->type == CAIRO_PATTERN_TYPE_LINEAR || - source->type == CAIRO_PATTERN_TYPE_RADIAL) && - (source->extend == CAIRO_EXTEND_REPEAT || - source->extend == CAIRO_EXTEND_REFLECT); -} - -static cairo_int_status_t -_cairo_quartz_surface_paint (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_clip_t *clip) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_int_status_t rv; - cairo_image_surface_t *image; - - rv = _cairo_quartz_surface_paint_cg (abstract_surface, - op, - source, - clip); - - if (likely (rv != CAIRO_INT_STATUS_UNSUPPORTED)) - return rv; - - rv = _cairo_quartz_get_image (surface, &image); - if (rv == CAIRO_STATUS_SUCCESS) { - rv = _cairo_surface_paint (&image->base, op, source, clip); - cairo_surface_destroy (&image->base); - } - - return rv; -} - -static cairo_int_status_t -_cairo_quartz_surface_fill_cg (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_path_fixed_t *path, - cairo_fill_rule_t fill_rule, - double tolerance, - cairo_antialias_t antialias, - cairo_clip_t *clip) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_int_status_t rv = CAIRO_STATUS_SUCCESS; - cairo_quartz_drawing_state_t state; - CGPathRef path_for_unbounded = NULL; - - ND((stderr, "%p _cairo_quartz_surface_fill op %d source->type %d\n", surface, op, source->type)); - - if (IS_EMPTY(surface)) - return CAIRO_STATUS_SUCCESS; - - rv = _cairo_surface_clipper_set_clip (&surface->clipper, clip); - if (unlikely (rv)) - return rv; - - if (_cairo_quartz_source_needs_extents (source)) - { - /* We don't need precise extents since these are only used to - compute the number of gradient reptitions needed to cover the - object. */ - cairo_rectangle_int_t path_extents; - _cairo_path_fixed_approximate_fill_extents (path, &path_extents); - state = _cairo_quartz_setup_state (surface, source, op, &path_extents); - } else { - state = _cairo_quartz_setup_state (surface, source, op, NULL); - } - - CGContextSetShouldAntialias (state.context, (antialias != CAIRO_ANTIALIAS_NONE)); - - _cairo_quartz_cairo_path_to_quartz_context (path, state.context); - - if (!_cairo_operator_bounded_by_mask(op) && CGContextCopyPathPtr) - path_for_unbounded = CGContextCopyPathPtr (state.context); - - if (state.action == DO_SOLID || state.action == DO_PATTERN) { - if (fill_rule == CAIRO_FILL_RULE_WINDING) - CGContextFillPath (state.context); - else - CGContextEOFillPath (state.context); - } else if (state.action == DO_SHADING) { - - // we have to clip and then paint the shading; we can't fill - // with the shading - if (fill_rule == CAIRO_FILL_RULE_WINDING) - CGContextClip (state.context); - else - CGContextEOClip (state.context); - - CGContextConcatCTM (state.context, state.transform); - CGContextDrawShading (state.context, state.shading); - } else if (state.action == DO_IMAGE || state.action == DO_TILED_IMAGE || - state.action == DO_LAYER) { - if (fill_rule == CAIRO_FILL_RULE_WINDING) - CGContextClip (state.context); - else - CGContextEOClip (state.context); - - _cairo_quartz_draw_image (&state, op); - } else if (state.action != DO_NOTHING) { - rv = CAIRO_INT_STATUS_UNSUPPORTED; - } - - _cairo_quartz_teardown_state (&state); - - if (path_for_unbounded) { - unbounded_op_data_t ub; - ub.op = UNBOUNDED_STROKE_FILL; - ub.u.stroke_fill.cgPath = path_for_unbounded; - ub.u.stroke_fill.fill_rule = fill_rule; - - _cairo_quartz_fixup_unbounded_operation (surface, &ub, antialias); - CGPathRelease (path_for_unbounded); - } - - ND((stderr, "-- fill\n")); - return rv; -} - -static cairo_int_status_t -_cairo_quartz_surface_fill (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_path_fixed_t *path, - cairo_fill_rule_t fill_rule, - double tolerance, - cairo_antialias_t antialias, - cairo_clip_t *clip) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_int_status_t rv; - cairo_image_surface_t *image; - - rv = _cairo_quartz_surface_fill_cg (abstract_surface, - op, - source, - path, - fill_rule, - tolerance, - antialias, - clip); - - if (likely (rv != CAIRO_INT_STATUS_UNSUPPORTED)) - return rv; - - rv = _cairo_quartz_get_image (surface, &image); - if (rv == CAIRO_STATUS_SUCCESS) { - rv = _cairo_surface_fill (&image->base, op, source, - path, fill_rule, tolerance, antialias, - clip); - cairo_surface_destroy (&image->base); - } - - return rv; -} - -static cairo_int_status_t -_cairo_quartz_surface_stroke_cg (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_path_fixed_t *path, - const cairo_stroke_style_t *style, - const cairo_matrix_t *ctm, - const cairo_matrix_t *ctm_inverse, - double tolerance, - cairo_antialias_t antialias, - cairo_clip_t *clip) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_int_status_t rv = CAIRO_STATUS_SUCCESS; - cairo_quartz_drawing_state_t state; - CGAffineTransform origCTM, strokeTransform; - CGPathRef path_for_unbounded = NULL; - - ND((stderr, "%p _cairo_quartz_surface_stroke op %d source->type %d\n", surface, op, source->type)); - - if (IS_EMPTY(surface)) - return CAIRO_STATUS_SUCCESS; - - rv = _cairo_surface_clipper_set_clip (&surface->clipper, clip); - if (unlikely (rv)) - return rv; - - rv = _cairo_quartz_surface_set_cairo_operator (surface, op); - if (unlikely (rv)) - return rv == CAIRO_INT_STATUS_NOTHING_TO_DO ? CAIRO_STATUS_SUCCESS : rv; - - if (_cairo_quartz_source_needs_extents (source)) - { - cairo_rectangle_int_t path_extents; - _cairo_path_fixed_approximate_stroke_extents (path, style, ctm, &path_extents); - state = _cairo_quartz_setup_state (surface, source, op, &path_extents); - } else { - state = _cairo_quartz_setup_state (surface, source, op, NULL); - } - - // Turning antialiasing off used to cause misrendering with - // single-pixel lines (e.g. 20,10.5 -> 21,10.5 end up being rendered as 2 pixels). - // That's been since fixed in at least 10.5, and in the latest 10.4 dot releases. - CGContextSetShouldAntialias (state.context, (antialias != CAIRO_ANTIALIAS_NONE)); - CGContextSetLineWidth (state.context, style->line_width); - CGContextSetLineCap (state.context, _cairo_quartz_cairo_line_cap_to_quartz (style->line_cap)); - CGContextSetLineJoin (state.context, _cairo_quartz_cairo_line_join_to_quartz (style->line_join)); - CGContextSetMiterLimit (state.context, style->miter_limit); - - origCTM = CGContextGetCTM (state.context); - - if (style->dash && style->num_dashes) { -#define STATIC_DASH 32 - cairo_quartz_float_t sdash[STATIC_DASH]; - cairo_quartz_float_t *fdash = sdash; - unsigned int max_dashes = style->num_dashes; - unsigned int k; - - bool set_line_dash = false; - if (style->num_dashes % 2 == 0) { - for (k = 1; k < max_dashes; k++) { - if (style->dash[k]) { - set_line_dash = true; - break; - } - } - } else - set_line_dash = true; - - if (set_line_dash) { - if (style->num_dashes%2) - max_dashes *= 2; - if (max_dashes > STATIC_DASH) - fdash = _cairo_malloc_ab (max_dashes, sizeof (cairo_quartz_float_t)); - if (fdash == NULL) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - - for (k = 0; k < max_dashes; k++) - fdash[k] = (cairo_quartz_float_t) style->dash[k % style->num_dashes]; - - CGContextSetLineDash (surface->cgContext, style->dash_offset, fdash, max_dashes); - if (fdash != sdash) - free (fdash); - } else - CGContextSetLineDash (state.context, 0, NULL, 0); - } else - CGContextSetLineDash (state.context, 0, NULL, 0); - - - _cairo_quartz_cairo_path_to_quartz_context (path, state.context); - - _cairo_quartz_cairo_matrix_to_quartz (ctm, &strokeTransform); - CGContextConcatCTM (state.context, strokeTransform); - - if (!_cairo_operator_bounded_by_mask (op) && CGContextCopyPathPtr) - path_for_unbounded = CGContextCopyPathPtr (state.context); - - if (state.action == DO_SOLID || state.action == DO_PATTERN) { - CGContextStrokePath (state.context); - } else if (state.action == DO_IMAGE || state.action == DO_TILED_IMAGE || - state.action == DO_LAYER) { - CGContextReplacePathWithStrokedPath (state.context); - CGContextClip (state.context); - - CGContextSetCTM (state.context, origCTM); - _cairo_quartz_draw_image (&state, op); - } else if (state.action == DO_SHADING) { - CGContextReplacePathWithStrokedPath (state.context); - CGContextClip (state.context); - - CGContextSetCTM (state.context, origCTM); - - CGContextConcatCTM (state.context, state.transform); - CGContextDrawShading (state.context, state.shading); - } else if (state.action != DO_NOTHING) { - rv = CAIRO_INT_STATUS_UNSUPPORTED; - goto BAIL; - } - - if (path_for_unbounded) { - unbounded_op_data_t ub; - ub.op = UNBOUNDED_STROKE_FILL; - ub.u.stroke_fill.fill_rule = CAIRO_FILL_RULE_WINDING; - - CGContextBeginPath (state.context); - CGContextAddPath (state.context, path_for_unbounded); - CGPathRelease (path_for_unbounded); - - CGContextSaveGState (state.context); - CGContextConcatCTM (state.context, strokeTransform); - CGContextReplacePathWithStrokedPath (state.context); - CGContextRestoreGState (state.context); - - ub.u.stroke_fill.cgPath = CGContextCopyPathPtr (state.context); - - _cairo_quartz_fixup_unbounded_operation (surface, &ub, antialias); - CGPathRelease (ub.u.stroke_fill.cgPath); - } - - BAIL: - _cairo_quartz_teardown_state (&state); - - ND((stderr, "-- stroke\n")); - return rv; -} - -static cairo_int_status_t -_cairo_quartz_surface_stroke (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_path_fixed_t *path, - const cairo_stroke_style_t *style, - const cairo_matrix_t *ctm, - const cairo_matrix_t *ctm_inverse, - double tolerance, - cairo_antialias_t antialias, - cairo_clip_t *clip) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_int_status_t rv; - cairo_image_surface_t *image; - - rv = _cairo_quartz_surface_stroke_cg (abstract_surface, op, source, - path, style, ctm, ctm_inverse, - tolerance, antialias, - clip); - - if (likely (rv != CAIRO_INT_STATUS_UNSUPPORTED)) - return rv; - - rv = _cairo_quartz_get_image (surface, &image); - if (rv == CAIRO_STATUS_SUCCESS) { - rv = _cairo_surface_stroke (&image->base, op, source, - path, style, ctm, ctm_inverse, - tolerance, antialias, - clip); - cairo_surface_destroy (&image->base); - } - - return rv; -} - -#if CAIRO_HAS_QUARTZ_FONT -static cairo_int_status_t -_cairo_quartz_surface_show_glyphs_cg (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_glyph_t *glyphs, - int num_glyphs, - cairo_scaled_font_t *scaled_font, - cairo_clip_t *clip, - int *remaining_glyphs) -{ - CGAffineTransform textTransform, ctm, invTextTransform; -#define STATIC_BUF_SIZE 64 - CGGlyph glyphs_static[STATIC_BUF_SIZE]; - CGSize cg_advances_static[STATIC_BUF_SIZE]; - CGGlyph *cg_glyphs = &glyphs_static[0]; - /* We'll use the cg_advances array for either advances or positions, - depending which API we're using to actually draw. The types involved - have the same size, so this is safe. */ - CGSize *cg_advances = &cg_advances_static[0]; - - cairo_rectangle_int_t glyph_extents; - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_int_status_t rv = CAIRO_STATUS_SUCCESS; - cairo_quartz_drawing_state_t state; - cairo_quartz_float_t xprev, yprev; - int i; - CGFontRef cgfref = NULL; - - cairo_bool_t isClipping = FALSE; - cairo_bool_t didForceFontSmoothing = FALSE; - cairo_antialias_t effective_antialiasing; - - if (IS_EMPTY(surface)) - return CAIRO_STATUS_SUCCESS; - - if (num_glyphs <= 0) - return CAIRO_STATUS_SUCCESS; - - if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_QUARTZ) - return CAIRO_INT_STATUS_UNSUPPORTED; - - rv = _cairo_surface_clipper_set_clip (&surface->clipper, clip); - if (unlikely (rv)) - return rv; - - if (_cairo_quartz_source_needs_extents (source) && - !_cairo_scaled_font_glyph_device_extents (scaled_font, glyphs, num_glyphs, - &glyph_extents, NULL)) - { - state = _cairo_quartz_setup_state (surface, source, op, &glyph_extents); - } else { - state = _cairo_quartz_setup_state (surface, source, op, NULL); - } - - if (state.action == DO_SOLID || state.action == DO_PATTERN) { - CGContextSetTextDrawingMode (state.context, kCGTextFill); - } else if (state.action == DO_IMAGE || state.action == DO_TILED_IMAGE || - state.action == DO_SHADING || state.action == DO_LAYER) { - CGContextSetTextDrawingMode (state.context, kCGTextClip); - isClipping = TRUE; - } else { - if (state.action != DO_NOTHING) - rv = CAIRO_INT_STATUS_UNSUPPORTED; - goto BAIL; - } - - /* this doesn't addref */ - cgfref = _cairo_quartz_scaled_font_get_cg_font_ref (scaled_font); - CGContextSetFont (state.context, cgfref); - CGContextSetFontSize (state.context, 1.0); - - effective_antialiasing = scaled_font->options.antialias; - if (effective_antialiasing == CAIRO_ANTIALIAS_SUBPIXEL && - !surface->base.permit_subpixel_antialiasing) { - effective_antialiasing = CAIRO_ANTIALIAS_GRAY; - } - - switch (scaled_font->options.antialias) { - case CAIRO_ANTIALIAS_SUBPIXEL: - CGContextSetShouldAntialias (state.context, TRUE); - CGContextSetShouldSmoothFonts (state.context, TRUE); - if (CGContextSetAllowsFontSmoothingPtr && - !CGContextGetAllowsFontSmoothingPtr (state.context)) - { - didForceFontSmoothing = TRUE; - CGContextSetAllowsFontSmoothingPtr (state.context, TRUE); - } - break; - case CAIRO_ANTIALIAS_NONE: - CGContextSetShouldAntialias (state.context, FALSE); - break; - case CAIRO_ANTIALIAS_GRAY: - CGContextSetShouldAntialias (state.context, TRUE); - CGContextSetShouldSmoothFonts (state.context, FALSE); - break; - case CAIRO_ANTIALIAS_DEFAULT: - /* Don't do anything */ - break; - } - - if (num_glyphs > STATIC_BUF_SIZE) { - cg_glyphs = (CGGlyph*) _cairo_malloc_ab (num_glyphs, sizeof(CGGlyph)); - if (cg_glyphs == NULL) { - rv = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto BAIL; - } - - cg_advances = (CGSize*) _cairo_malloc_ab (num_glyphs, sizeof(CGSize)); - if (cg_advances == NULL) { - rv = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto BAIL; - } - } - - /* scale(1,-1) * scaled_font->scale */ - textTransform = CGAffineTransformMake (scaled_font->scale.xx, - scaled_font->scale.yx, - -scaled_font->scale.xy, - -scaled_font->scale.yy, - 0, 0); - - /* scaled_font->scale_inverse * scale(1,-1) */ - invTextTransform = CGAffineTransformMake (scaled_font->scale_inverse.xx, - -scaled_font->scale_inverse.yx, - scaled_font->scale_inverse.xy, - -scaled_font->scale_inverse.yy, - 0.0, 0.0); - - CGContextSetTextMatrix (state.context, CGAffineTransformIdentity); - - /* Translate to the first glyph's position before drawing */ - ctm = CGContextGetCTM (state.context); - CGContextTranslateCTM (state.context, glyphs[0].x, glyphs[0].y); - CGContextConcatCTM (state.context, textTransform); - - if (CTFontDrawGlyphsPtr) { - /* If CTFontDrawGlyphs is available (i.e. OS X 10.7 or later), we want to use - * that in preference to CGContextShowGlyphsWithAdvances so that colored-bitmap - * fonts like Apple Color Emoji will render properly. - * For this, we need to convert our glyph positions to Core Graphics's CGPoint. - * We borrow the cg_advances array, as CGPoint and CGSize are the same size. */ - - CGPoint *cg_positions = (CGPoint*) cg_advances; - cairo_quartz_float_t origin_x = glyphs[0].x; - cairo_quartz_float_t origin_y = glyphs[0].y; - - for (i = 0; i < num_glyphs; i++) { - CGPoint pt = CGPointMake (glyphs[i].x - origin_x, glyphs[i].y - origin_y); - cg_positions[i] = CGPointApplyAffineTransform (pt, invTextTransform); - cg_glyphs[i] = glyphs[i].index; - } - - CTFontDrawGlyphsPtr (_cairo_quartz_scaled_font_get_ct_font_ref (scaled_font), - cg_glyphs, cg_positions, num_glyphs, state.context); - } else { - /* Convert our glyph positions to glyph advances. We need n-1 advances, - * since the advance at index 0 is applied after glyph 0. */ - xprev = glyphs[0].x; - yprev = glyphs[0].y; - - cg_glyphs[0] = glyphs[0].index; - - for (i = 1; i < num_glyphs; i++) { - cairo_quartz_float_t xf = glyphs[i].x; - cairo_quartz_float_t yf = glyphs[i].y; - cg_glyphs[i] = glyphs[i].index; - cg_advances[i - 1] = CGSizeApplyAffineTransform(CGSizeMake (xf - xprev, yf - yprev), invTextTransform); - xprev = xf; - yprev = yf; - } - - CGContextShowGlyphsWithAdvances (state.context, - cg_glyphs, - cg_advances, - num_glyphs); - } - - CGContextSetCTM (state.context, ctm); - - if (state.action == DO_IMAGE || state.action == DO_TILED_IMAGE || - state.action == DO_LAYER) { - _cairo_quartz_draw_image (&state, op); - } else if (state.action == DO_SHADING) { - CGContextConcatCTM (state.context, state.transform); - CGContextDrawShading (state.context, state.shading); - } - -BAIL: - if (didForceFontSmoothing) - CGContextSetAllowsFontSmoothingPtr (state.context, FALSE); - - _cairo_quartz_teardown_state (&state); - - if (rv == CAIRO_STATUS_SUCCESS && - cgfref && - !_cairo_operator_bounded_by_mask (op)) - { - unbounded_op_data_t ub; - ub.op = UNBOUNDED_SHOW_GLYPHS; - - ub.u.show_glyphs.isClipping = isClipping; - ub.u.show_glyphs.cg_glyphs = cg_glyphs; - if (CTFontDrawGlyphsPtr) { - /* we're using Core Text API: the cg_advances array was - reused (above) for glyph positions */ - CGPoint *cg_positions = (CGPoint*) cg_advances; - ub.u.show_glyphs.u.cg_positions = cg_positions; - } else { - ub.u.show_glyphs.u.cg_advances = cg_advances; - } - ub.u.show_glyphs.nglyphs = num_glyphs; - ub.u.show_glyphs.textTransform = textTransform; - ub.u.show_glyphs.scaled_font = scaled_font; - ub.u.show_glyphs.origin = CGPointMake (glyphs[0].x, glyphs[0].y); - - _cairo_quartz_fixup_unbounded_operation (surface, &ub, scaled_font->options.antialias); - } - - - if (cg_advances != &cg_advances_static[0]) { - free (cg_advances); - } - - if (cg_glyphs != &glyphs_static[0]) { - free (cg_glyphs); - } - - return rv; -} -#endif /* CAIRO_HAS_QUARTZ_FONT */ - -static cairo_int_status_t -_cairo_quartz_surface_show_glyphs (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_glyph_t *glyphs, - int num_glyphs, - cairo_scaled_font_t *scaled_font, - cairo_clip_t *clip, - int *remaining_glyphs) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_int_status_t rv = CAIRO_INT_STATUS_UNSUPPORTED; - cairo_image_surface_t *image; - -#if CAIRO_HAS_QUARTZ_FONT - rv = _cairo_quartz_surface_show_glyphs_cg (abstract_surface, op, source, - glyphs, num_glyphs, - scaled_font, clip, remaining_glyphs); - - if (likely (rv != CAIRO_INT_STATUS_UNSUPPORTED)) - return rv; - -#endif - - rv = _cairo_quartz_get_image (surface, &image); - if (rv == CAIRO_STATUS_SUCCESS) { - rv = _cairo_surface_show_text_glyphs (&image->base, op, source, - NULL, 0, - glyphs, num_glyphs, - NULL, 0, 0, - scaled_font, clip); - cairo_surface_destroy (&image->base); - } - - return rv; -} - -static cairo_int_status_t -_cairo_quartz_surface_mask_with_surface (cairo_quartz_surface_t *surface, - cairo_operator_t op, - const cairo_pattern_t *source, - const cairo_surface_pattern_t *mask, - cairo_clip_t *clip) -{ - CGRect rect; - CGImageRef img; - cairo_surface_t *pat_surf = mask->surface; - cairo_status_t status = CAIRO_STATUS_SUCCESS; - CGAffineTransform ctm, mask_matrix; - - status = _cairo_surface_to_cgimage (pat_surf, &img); - if (status) - return status; - if (img == NULL) { - if (!_cairo_operator_bounded_by_mask (op)) - CGContextClearRect (surface->cgContext, CGContextGetClipBoundingBox (surface->cgContext)); - return CAIRO_STATUS_SUCCESS; - } - - rect = CGRectMake (0.0f, 0.0f, CGImageGetWidth (img) , CGImageGetHeight (img)); - - CGContextSaveGState (surface->cgContext); - - /* ClipToMask is essentially drawing an image, so we need to flip the CTM - * to get the image to appear oriented the right way */ - ctm = CGContextGetCTM (surface->cgContext); - - _cairo_quartz_cairo_matrix_to_quartz (&mask->base.matrix, &mask_matrix); - mask_matrix = CGAffineTransformInvert(mask_matrix); - mask_matrix = CGAffineTransformTranslate (mask_matrix, 0.0, CGImageGetHeight (img)); - mask_matrix = CGAffineTransformScale (mask_matrix, 1.0, -1.0); - - CGContextConcatCTM (surface->cgContext, mask_matrix); - CGContextClipToMaskPtr (surface->cgContext, rect, img); - - CGContextSetCTM (surface->cgContext, ctm); - - status = _cairo_quartz_surface_paint_cg (surface, op, source, clip); - - CGContextRestoreGState (surface->cgContext); - - if (!_cairo_operator_bounded_by_mask (op)) { - unbounded_op_data_t ub; - ub.op = UNBOUNDED_MASK; - ub.u.mask.mask = img; - ub.u.mask.maskTransform = mask_matrix; - _cairo_quartz_fixup_unbounded_operation (surface, &ub, CAIRO_ANTIALIAS_NONE); - } - - CGImageRelease (img); - - return status; -} - -/* This is somewhat less than ideal, but it gets the job done; - * it would be better to avoid calling back into cairo. This - * creates a temporary surface to use as the mask. - */ -static cairo_int_status_t -_cairo_quartz_surface_mask_with_generic (cairo_quartz_surface_t *surface, - cairo_operator_t op, - const cairo_pattern_t *source, - const cairo_pattern_t *mask, - cairo_clip_t *clip) -{ - int width = surface->extents.width; - int height = surface->extents.height; - - cairo_surface_t *gradient_surf = NULL; - cairo_surface_pattern_t surface_pattern; - cairo_int_status_t status; - - /* Render the gradient to a surface */ - gradient_surf = cairo_quartz_surface_create (CAIRO_FORMAT_A8, - width, - height); - - status = _cairo_quartz_surface_paint (gradient_surf, CAIRO_OPERATOR_SOURCE, mask, NULL); - if (status) - goto BAIL; - - _cairo_pattern_init_for_surface (&surface_pattern, gradient_surf); - - status = _cairo_quartz_surface_mask_with_surface (surface, op, source, &surface_pattern, clip); - - _cairo_pattern_fini (&surface_pattern.base); - - BAIL: - if (gradient_surf) - cairo_surface_destroy (gradient_surf); - - return status; -} - -static cairo_int_status_t -_cairo_quartz_surface_mask_cg (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - const cairo_pattern_t *mask, - cairo_clip_t *clip) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_int_status_t rv = CAIRO_STATUS_SUCCESS; - - ND((stderr, "%p _cairo_quartz_surface_mask op %d source->type %d mask->type %d\n", surface, op, source->type, mask->type)); - - if (IS_EMPTY(surface)) - return CAIRO_STATUS_SUCCESS; - - rv = _cairo_surface_clipper_set_clip (&surface->clipper, clip); - if (unlikely (rv)) - return rv; - - /* Using CGContextSetAlpha to implement mask alpha doesn't work for all operators. */ - if (mask->type == CAIRO_PATTERN_TYPE_SOLID && - op == CAIRO_OPERATOR_OVER) { - /* This is easy; we just need to paint with the alpha. */ - cairo_solid_pattern_t *solid_mask = (cairo_solid_pattern_t *) mask; - - CGContextSetAlpha (surface->cgContext, solid_mask->color.alpha); - rv = _cairo_quartz_surface_paint_cg (surface, op, source, clip); - CGContextSetAlpha (surface->cgContext, 1.0); - - return rv; - } - - /* If we have CGContextClipToMask, we can do more complex masks */ - if (CGContextClipToMaskPtr) { - /* For these, we can skip creating a temporary surface, since we already have one */ - /* For some reason this doesn't work reliably on OS X 10.5. See bug 721663. */ - if (_cairo_quartz_osx_version >= 0x1060 && mask->type == CAIRO_PATTERN_TYPE_SURFACE && - mask->extend == CAIRO_EXTEND_NONE) { - return _cairo_quartz_surface_mask_with_surface (surface, op, source, (cairo_surface_pattern_t *) mask, clip); - } - - return _cairo_quartz_surface_mask_with_generic (surface, op, source, mask, clip); - } - - /* So, CGContextClipToMask is not present in 10.3.9, so we're - * doomed; if we have imageData, we can do fallback, otherwise - * just pretend success. - */ - if (surface->imageData) - return CAIRO_INT_STATUS_UNSUPPORTED; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_int_status_t -_cairo_quartz_surface_mask (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - const cairo_pattern_t *mask, - cairo_clip_t *clip) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - cairo_int_status_t rv; - cairo_image_surface_t *image; - - rv = _cairo_quartz_surface_mask_cg (abstract_surface, - op, - source, - mask, - clip); - - if (likely (rv != CAIRO_INT_STATUS_UNSUPPORTED)) - return rv; - - rv = _cairo_quartz_get_image (surface, &image); - if (rv == CAIRO_STATUS_SUCCESS) { - rv = _cairo_surface_mask (&image->base, op, source, mask, clip); - cairo_surface_destroy (&image->base); - } - - return rv; -} - -static cairo_status_t -_cairo_quartz_surface_clipper_intersect_clip_path (cairo_surface_clipper_t *clipper, - cairo_path_fixed_t *path, - cairo_fill_rule_t fill_rule, - double tolerance, - cairo_antialias_t antialias) -{ - cairo_quartz_surface_t *surface = - cairo_container_of (clipper, cairo_quartz_surface_t, clipper); - - ND((stderr, "%p _cairo_quartz_surface_intersect_clip_path path: %p\n", surface, path)); - - if (IS_EMPTY(surface)) - return CAIRO_STATUS_SUCCESS; - - if (path == NULL) { - /* If we're being asked to reset the clip, we can only do it - * by restoring the gstate to our previous saved one, and - * saving it again. - * - * Note that this assumes that ALL quartz surface creation - * functions will do a SaveGState first; we do this in create_internal. - */ - CGContextRestoreGState (surface->cgContext); - CGContextSaveGState (surface->cgContext); - } else { - CGContextSetShouldAntialias (surface->cgContext, (antialias != CAIRO_ANTIALIAS_NONE)); - - _cairo_quartz_cairo_path_to_quartz_context (path, surface->cgContext); - - if (fill_rule == CAIRO_FILL_RULE_WINDING) - CGContextClip (surface->cgContext); - else - CGContextEOClip (surface->cgContext); - } - - ND((stderr, "-- intersect_clip_path\n")); - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_cairo_quartz_surface_mark_dirty_rectangle (void *abstract_surface, - int x, int y, - int width, int height) -{ - cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface; - _cairo_quartz_surface_will_change (surface); - return CAIRO_STATUS_SUCCESS; -} - - -// XXXtodo implement show_page; need to figure out how to handle begin/end - -static const struct _cairo_surface_backend cairo_quartz_surface_backend = { - CAIRO_SURFACE_TYPE_QUARTZ, - _cairo_quartz_surface_create_similar, - _cairo_quartz_surface_finish, - _cairo_quartz_surface_acquire_image, - _cairo_quartz_surface_release_source_image, - _cairo_quartz_surface_acquire_dest_image, - _cairo_quartz_surface_release_dest_image, - _cairo_quartz_surface_clone_similar, - NULL, /* composite */ - NULL, /* fill_rectangles */ - NULL, /* composite_trapezoids */ - NULL, /* create_span_renderer */ - NULL, /* check_span_renderer */ - NULL, /* copy_page */ - NULL, /* show_page */ - _cairo_quartz_surface_get_extents, - NULL, /* old_show_glyphs */ - NULL, /* get_font_options */ - NULL, /* flush */ - _cairo_quartz_surface_mark_dirty_rectangle, - NULL, /* scaled_font_fini */ - NULL, /* scaled_glyph_fini */ - - _cairo_quartz_surface_paint, - _cairo_quartz_surface_mask, - _cairo_quartz_surface_stroke, - _cairo_quartz_surface_fill, - _cairo_quartz_surface_show_glyphs, - - NULL, /* snapshot */ - NULL, /* is_similar */ - NULL /* fill_stroke */ -}; - -cairo_quartz_surface_t * -_cairo_quartz_surface_create_internal (CGContextRef cgContext, - cairo_content_t content, - unsigned int width, - unsigned int height) -{ - cairo_quartz_surface_t *surface; - - quartz_ensure_symbols(); - - /* Init the base surface */ - surface = malloc(sizeof(cairo_quartz_surface_t)); - if (surface == NULL) - return (cairo_quartz_surface_t*) _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); - - memset(surface, 0, sizeof(cairo_quartz_surface_t)); - - _cairo_surface_init (&surface->base, - &cairo_quartz_surface_backend, - NULL, /* device */ - content); - - _cairo_surface_clipper_init (&surface->clipper, - _cairo_quartz_surface_clipper_intersect_clip_path); - - /* Save our extents */ - surface->extents.x = surface->extents.y = 0; - surface->extents.width = width; - surface->extents.height = height; - - if (IS_EMPTY(surface)) { - surface->cgContext = NULL; - surface->cgContextBaseCTM = CGAffineTransformIdentity; - surface->imageData = NULL; - return surface; - } - - /* Save so we can always get back to a known-good CGContext -- this is - * required for proper behaviour of intersect_clip_path(NULL) - */ - CGContextSaveGState (cgContext); - - surface->cgContext = cgContext; - surface->cgContextBaseCTM = CGContextGetCTM (cgContext); - - surface->imageData = NULL; - surface->imageSurfaceEquiv = NULL; - surface->bitmapContextImage = NULL; - surface->cgLayer = NULL; - surface->ownsData = TRUE; - - return surface; -} - -/** - * cairo_quartz_surface_create_for_cg_context - * @cgContext: the existing CGContext for which to create the surface - * @width: width of the surface, in pixels - * @height: height of the surface, in pixels - * - * Creates a Quartz surface that wraps the given CGContext. The - * CGContext is assumed to be in the standard Cairo coordinate space - * (that is, with the origin at the upper left and the Y axis - * increasing downward). If the CGContext is in the Quartz coordinate - * space (with the origin at the bottom left), then it should be - * flipped before this function is called. The flip can be accomplished - * using a translate and a scale; for example: - * - * <informalexample><programlisting> - * CGContextTranslateCTM (cgContext, 0.0, height); - * CGContextScaleCTM (cgContext, 1.0, -1.0); - * </programlisting></informalexample> - * - * All Cairo operations are implemented in terms of Quartz operations, - * as long as Quartz-compatible elements are used (such as Quartz fonts). - * - * Return value: the newly created Cairo surface. - * - * Since: 1.4 - **/ - -cairo_surface_t * -cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext, - unsigned int width, - unsigned int height) -{ - cairo_quartz_surface_t *surf; - - CGContextRetain (cgContext); - - surf = _cairo_quartz_surface_create_internal (cgContext, CAIRO_CONTENT_COLOR_ALPHA, - width, height); - if (surf->base.status) { - CGContextRelease (cgContext); - // create_internal will have set an error - return (cairo_surface_t*) surf; - } - - return (cairo_surface_t *) surf; -} - -/** - * cairo_quartz_cglayer_surface_create_similar - * @surface: The returned surface can be efficiently drawn into this - * destination surface (if tiling is not used)." - * @content: the content type of the surface - * @width: width of the surface, in pixels - * @height: height of the surface, in pixels - * - * Creates a Quartz surface backed by a CGLayer, if the given surface - * is a Quartz surface; the CGLayer is created to match the surface's - * Quartz context. Otherwise just calls cairo_surface_create_similar. - * The returned surface can be efficiently blitted to the given surface, - * but tiling and 'extend' modes other than NONE are not so efficient. - * - * Return value: the newly created surface. - * - * Since: 1.10 - **/ -cairo_surface_t * -cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface, - cairo_content_t content, - unsigned int width, - unsigned int height) -{ - cairo_quartz_surface_t *surf; - CGLayerRef layer; - CGContextRef ctx; - CGContextRef cgContext; - - cgContext = cairo_quartz_surface_get_cg_context (surface); - if (!cgContext) - return cairo_surface_create_similar (surface, content, - width, height); - - if (!_cairo_quartz_verify_surface_size(width, height)) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); - - /* If we pass zero width or height into CGLayerCreateWithContext below, - * it will fail. - */ - if (width == 0 || height == 0) { - return (cairo_surface_t*) - _cairo_quartz_surface_create_internal (NULL, content, - width, height); - } - - layer = CGLayerCreateWithContext (cgContext, - CGSizeMake (width, height), - NULL); - if (!layer) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); - - ctx = CGLayerGetContext (layer); - /* Flip it when we draw into it, so that when we finally composite it - * to a flipped target, the directions match and Quartz will optimize - * the composition properly - */ - CGContextTranslateCTM (ctx, 0, height); - CGContextScaleCTM (ctx, 1, -1); - - CGContextRetain (ctx); - surf = _cairo_quartz_surface_create_internal (ctx, content, - width, height); - if (surf->base.status) { - CGLayerRelease (layer); - // create_internal will have set an error - return (cairo_surface_t*) surf; - } - surf->cgLayer = layer; - - return (cairo_surface_t *) surf; -} - -/** - * cairo_quartz_surface_create - * @format: format of pixels in the surface to create - * @width: width of the surface, in pixels - * @height: height of the surface, in pixels - * - * Creates a Quartz surface backed by a CGBitmap. The surface is - * created using the Device RGB (or Device Gray, for A8) color space. - * All Cairo operations, including those that require software - * rendering, will succeed on this surface. - * - * Return value: the newly created surface. - * - * Since: 1.4 - **/ -cairo_surface_t * -cairo_quartz_surface_create (cairo_format_t format, - unsigned int width, - unsigned int height) -{ - int stride; - unsigned char *data; - - if (!_cairo_quartz_verify_surface_size(width, height)) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); - - if (width == 0 || height == 0) { - return (cairo_surface_t*) _cairo_quartz_surface_create_internal (NULL, _cairo_content_from_format (format), - width, height); - } - - if (format == CAIRO_FORMAT_ARGB32 || - format == CAIRO_FORMAT_RGB24) - { - stride = width * 4; - } else if (format == CAIRO_FORMAT_A8) { - stride = width; - } else if (format == CAIRO_FORMAT_A1) { - /* I don't think we can usefully support this, as defined by - * cairo_format_t -- these are 1-bit pixels stored in 32-bit - * quantities. - */ - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); - } else { - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); - } - - /* The Apple docs say that for best performance, the stride and the data - * pointer should be 16-byte aligned. malloc already aligns to 16-bytes, - * so we don't have to anything special on allocation. - */ - stride = (stride + 15) & ~15; - - data = _cairo_malloc_ab (height, stride); - if (!data) { - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); - } - - /* zero the memory to match the image surface behaviour */ - memset (data, 0, height * stride); - - cairo_quartz_surface_t *surf; - surf = (cairo_quartz_surface_t *) cairo_quartz_surface_create_for_data - (data, format, width, height, stride); - if (surf->base.status) { - free (data); - return (cairo_surface_t *) surf; - } - - // We created this data, so we can delete it. - surf->ownsData = TRUE; - - return (cairo_surface_t *) surf; -} - -/** - * cairo_quartz_surface_create_for_data - * @data: a pointer to a buffer supplied by the application in which - * to write contents. This pointer must be suitably aligned for any - * kind of variable, (for example, a pointer returned by malloc). - * @format: format of pixels in the surface to create - * @width: width of the surface, in pixels - * @height: height of the surface, in pixels - * - * Creates a Quartz surface backed by a CGBitmap. The surface is - * created using the Device RGB (or Device Gray, for A8) color space. - * All Cairo operations, including those that require software - * rendering, will succeed on this surface. - * - * Return value: the newly created surface. - * - * Since: 1.12 - **/ -cairo_surface_t * -cairo_quartz_surface_create_for_data (unsigned char *data, - cairo_format_t format, - unsigned int width, - unsigned int height, - unsigned int stride) -{ - cairo_quartz_surface_t *surf; - CGContextRef cgc; - CGColorSpaceRef cgColorspace; - CGBitmapInfo bitinfo; - void *imageData = data; - int bitsPerComponent; - unsigned int i; - - // verify width and height of surface - if (!_cairo_quartz_verify_surface_size(width, height)) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE)); - - if (width == 0 || height == 0) { - return (cairo_surface_t*) _cairo_quartz_surface_create_internal (NULL, _cairo_content_from_format (format), - width, height); - } - - if (format == CAIRO_FORMAT_ARGB32 || - format == CAIRO_FORMAT_RGB24) - { - cgColorspace = CGColorSpaceCreateDeviceRGB(); - bitinfo = kCGBitmapByteOrder32Host; - if (format == CAIRO_FORMAT_ARGB32) - bitinfo |= kCGImageAlphaPremultipliedFirst; - else - bitinfo |= kCGImageAlphaNoneSkipFirst; - bitsPerComponent = 8; - } else if (format == CAIRO_FORMAT_A8) { - cgColorspace = NULL; - bitinfo = kCGImageAlphaOnly; - bitsPerComponent = 8; - } else if (format == CAIRO_FORMAT_A1) { - /* I don't think we can usefully support this, as defined by - * cairo_format_t -- these are 1-bit pixels stored in 32-bit - * quantities. - */ - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); - } else { - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT)); - } - - cgc = CGBitmapContextCreate (imageData, - width, - height, - bitsPerComponent, - stride, - cgColorspace, - bitinfo); - CGColorSpaceRelease (cgColorspace); - - if (!cgc) { - free (imageData); - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); - } - - /* flip the Y axis */ - CGContextTranslateCTM (cgc, 0.0, height); - CGContextScaleCTM (cgc, 1.0, -1.0); - - surf = _cairo_quartz_surface_create_internal (cgc, _cairo_content_from_format (format), - width, height); - if (surf->base.status) { - CGContextRelease (cgc); - free (imageData); - // create_internal will have set an error - return (cairo_surface_t*) surf; - } - - surf->imageData = imageData; - - cairo_surface_t* tmpImageSurfaceEquiv = - cairo_image_surface_create_for_data (imageData, format, - width, height, stride); - - if (cairo_surface_status (tmpImageSurfaceEquiv)) { - // Tried & failed to create an imageSurfaceEquiv! - cairo_surface_destroy (tmpImageSurfaceEquiv); - surf->imageSurfaceEquiv = NULL; - } else { - surf->imageSurfaceEquiv = tmpImageSurfaceEquiv; - surf->ownsData = FALSE; - } - - return (cairo_surface_t *) surf; -} - -/** - * cairo_quartz_surface_get_cg_context - * @surface: the Cairo Quartz surface - * - * Returns the CGContextRef that the given Quartz surface is backed - * by. - * - * Return value: the CGContextRef for the given surface. - * - * Since: 1.4 - **/ -CGContextRef -cairo_quartz_surface_get_cg_context (cairo_surface_t *surface) -{ - if (surface && _cairo_surface_is_quartz (surface)) { - cairo_quartz_surface_t *quartz = (cairo_quartz_surface_t *) surface; - return quartz->cgContext; - } else - return NULL; -} - -static cairo_bool_t -_cairo_surface_is_quartz (const cairo_surface_t *surface) -{ - return surface->backend == &cairo_quartz_surface_backend; -} - -CGContextRef -cairo_quartz_get_cg_context_with_clip (cairo_t *cr) -{ - - cairo_surface_t *surface = cr->gstate->target; - cairo_clip_t *clip = &cr->gstate->clip; - cairo_status_t status; - - cairo_quartz_surface_t *quartz = (cairo_quartz_surface_t*)surface; - - if (cairo_surface_get_type(surface) != CAIRO_SURFACE_TYPE_QUARTZ) - return NULL; - - if (!clip->path) { - if (clip->all_clipped) { - /* Save the state before we set an empty clip rect so that - * our previous clip will be restored */ - - /* _cairo_surface_clipper_set_clip doesn't deal with - * clip->all_clipped because drawing is normally discarded earlier */ - CGRect empty = {{0,0}, {0,0}}; - CGContextClipToRect (quartz->cgContext, empty); - CGContextSaveGState (quartz->cgContext); - - return quartz->cgContext; - } - - /* an empty clip is represented by NULL */ - clip = NULL; - } - - status = _cairo_surface_clipper_set_clip (&quartz->clipper, clip); - - /* Save the state after we set the clip so that it persists - * after we restore */ - CGContextSaveGState (quartz->cgContext); - - if (unlikely (status)) - return NULL; - - return quartz->cgContext; -} - -void -cairo_quartz_finish_cg_context_with_clip (cairo_t *cr) -{ - cairo_surface_t *surface = cr->gstate->target; - - cairo_quartz_surface_t *quartz = (cairo_quartz_surface_t*)surface; - - if (cairo_surface_get_type(surface) != CAIRO_SURFACE_TYPE_QUARTZ) - return; - - CGContextRestoreGState (quartz->cgContext); -} - -cairo_surface_t * -cairo_quartz_surface_get_image (cairo_surface_t *surface) -{ - cairo_quartz_surface_t *quartz = (cairo_quartz_surface_t *)surface; - cairo_image_surface_t *image; - - if (_cairo_quartz_get_image(quartz, &image)) - return NULL; - - return (cairo_surface_t *)image; -} - -/* Debug stuff */ - -#ifdef QUARTZ_DEBUG - -#include <Movies.h> - -void ExportCGImageToPNGFile(CGImageRef inImageRef, char* dest) -{ - Handle dataRef = NULL; - OSType dataRefType; - CFStringRef inPath = CFStringCreateWithCString(NULL, dest, kCFStringEncodingASCII); - - GraphicsExportComponent grex = 0; - unsigned long sizeWritten; - - ComponentResult result; - - // create the data reference - result = QTNewDataReferenceFromFullPathCFString(inPath, kQTNativeDefaultPathStyle, - 0, &dataRef, &dataRefType); - - if (NULL != dataRef && noErr == result) { - // get the PNG exporter - result = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypePNG, - &grex); - - if (grex) { - // tell the exporter where to find its source image - result = GraphicsExportSetInputCGImage(grex, inImageRef); - - if (noErr == result) { - // tell the exporter where to save the exporter image - result = GraphicsExportSetOutputDataReference(grex, dataRef, - dataRefType); - - if (noErr == result) { - // write the PNG file - result = GraphicsExportDoExport(grex, &sizeWritten); - } - } - - // remember to close the component - CloseComponent(grex); - } - - // remember to dispose of the data reference handle - DisposeHandle(dataRef); - } -} - -void -quartz_image_to_png (CGImageRef imgref, char *dest) -{ - static int sctr = 0; - char sptr[] = "/Users/vladimir/Desktop/barXXXXX.png"; - - if (dest == NULL) { - fprintf (stderr, "** Writing %p to bar%d\n", imgref, sctr); - sprintf (sptr, "/Users/vladimir/Desktop/bar%d.png", sctr); - sctr++; - dest = sptr; - } - - ExportCGImageToPNGFile(imgref, dest); -} - -void -quartz_surface_to_png (cairo_quartz_surface_t *nq, char *dest) -{ - static int sctr = 0; - char sptr[] = "/Users/vladimir/Desktop/fooXXXXX.png"; - - if (nq->base.type != CAIRO_SURFACE_TYPE_QUARTZ) { - fprintf (stderr, "** quartz_surface_to_png: surface %p isn't quartz!\n", nq); - return; - } - - if (dest == NULL) { - fprintf (stderr, "** Writing %p to foo%d\n", nq, sctr); - sprintf (sptr, "/Users/vladimir/Desktop/foo%d.png", sctr); - sctr++; - dest = sptr; - } - - CGImageRef imgref = CGBitmapContextCreateImage (nq->cgContext); - if (imgref == NULL) { - fprintf (stderr, "quartz surface at %p is not a bitmap context!\n", nq); - return; - } - - ExportCGImageToPNGFile(imgref, dest); - - CGImageRelease(imgref); -} - -#endif /* QUARTZ_DEBUG */ diff --git a/libs/cairo/cairo/src/cairo-quartz.h b/libs/cairo/cairo/src/cairo-quartz.h deleted file mode 100644 index 699a4e7ce..000000000 --- a/libs/cairo/cairo/src/cairo-quartz.h +++ /dev/null @@ -1,81 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef CAIRO_QUARTZ_H -#define CAIRO_QUARTZ_H - -#include "cairo.h" - -#if CAIRO_HAS_QUARTZ_SURFACE -#include "TargetConditionals.h" - -#if !TARGET_OS_IPHONE -#include <ApplicationServices/ApplicationServices.h> -#else -#include <CoreGraphics/CoreGraphics.h> -#include <CoreText/CoreText.h> -#endif - -CAIRO_BEGIN_DECLS - -cairo_public cairo_surface_t * -cairo_quartz_surface_create (cairo_format_t format, - unsigned int width, - unsigned int height); - -cairo_public cairo_surface_t * -cairo_quartz_surface_create_for_data (unsigned char *data, - cairo_format_t format, - unsigned int width, - unsigned int height, - unsigned int stride); - -cairo_public cairo_surface_t * -cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface, - cairo_content_t content, - unsigned int width, - unsigned int height); - -cairo_public cairo_surface_t * -cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext, - unsigned int width, - unsigned int height); - -cairo_public CGContextRef -cairo_quartz_surface_get_cg_context (cairo_surface_t *surface); - -cairo_public CGContextRef -cairo_quartz_get_cg_context_with_clip (cairo_t *cr); - -cairo_public void -cairo_quartz_finish_cg_context_with_clip (cairo_t *cr); - -cairo_public cairo_surface_t * -cairo_quartz_surface_get_image (cairo_surface_t *surface); - -#if CAIRO_HAS_QUARTZ_FONT - -/* - * Quartz font support - */ - -cairo_public cairo_font_face_t * -cairo_quartz_font_face_create_for_cgfont (CGFontRef font); - -#if !defined(__LP64__) && !TARGET_OS_IPHONE -cairo_public cairo_font_face_t * -cairo_quartz_font_face_create_for_atsu_font_id (ATSUFontID font_id); -#endif - -#endif /* CAIRO_HAS_QUARTZ_FONT */ - -CAIRO_END_DECLS - -#else - -# error Cairo was not compiled with support for the quartz backend - -#endif /* CAIRO_HAS_QUARTZ_SURFACE */ - -#endif /* CAIRO_QUARTZ_H */ diff --git a/libs/cairo/cairo/src/moz.build b/libs/cairo/cairo/src/moz.build deleted file mode 100644 index 6d6f7c9d5..000000000 --- a/libs/cairo/cairo/src/moz.build +++ /dev/null @@ -1,266 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -CONFIGURE_SUBST_FILES += ['cairo-features.h'] - -EXPORTS.cairo += [ - '!cairo-features.h', - 'cairo-deprecated.h', - 'cairo-platform.h', - 'cairo-rename.h', - 'cairo-tee.h', - 'cairo-version.h', - 'cairo.h', - 'pixman-rename.h', -] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] not in ('uikit'): - EXPORTS.cairo += [ - 'cairo-pdf.h', - ] - SOURCES += [ - 'cairo-base85-stream.c', - 'cairo-cff-subset.c', - 'cairo-deflate-stream.c', - 'cairo-pdf-operators.c', - 'cairo-pdf-surface.c', - 'cairo-truetype-subset.c', - # cairo-type1-subset.c should be here, but it's only supported on freetype platforms - 'cairo-type1-fallback.c', - 'cairo-type3-glyph-surface.c', - ] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': - EXPORTS.cairo += [ - 'cairo-win32.h', - ] - if CONFIG['MOZ_ENABLE_DWRITE_FONT']: - SOURCES += [ - 'cairo-dwrite-font.cpp', - ] - if CONFIG['MOZ_ENABLE_D2D_SURFACE']: - SOURCES += [ - 'cairo-d2d-surface.cpp', - ] - SOURCES += [ - 'cairo-win32-font.c', - 'cairo-win32-surface.c', - ] - DEFINES['DISABLE_SOME_FLOATING_POINT'] = True - DEFINES['CAIRO_WIN32_STATIC_BUILD'] = True - if CONFIG['NS_PRINTING']: - SOURCES += [ - 'cairo-win32-printing-surface.c', - ] - else: - DEFINES['CAIRO_OMIT_WIN32_PRINTING'] = True -elif CONFIG['MOZ_WIDGET_TOOLKIT'] in {'uikit'}: - EXPORTS.cairo += [ - 'cairo-quartz-image.h', - 'cairo-quartz.h', - ] - SOURCES += [ - 'cairo-quartz-font.c', - 'cairo-quartz-image-surface.c', - 'cairo-quartz-surface.c', - ] -elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'beos': - EXPORTS.cairo += [ - 'cairo-beos.h', - ] - SOURCES += [ - 'cairo-beos-surface.cpp', - ] -elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: - EXPORTS.cairo += [ - 'cairo-ps.h', - ] - SOURCES += [ - 'cairo-ps-surface.c', - ] - -if CONFIG['MOZ_X11']: - EXPORTS.cairo += [ - 'cairo-xlib-xrender.h', - 'cairo-xlib.h', - ] - SOURCES += [ - 'cairo-xlib-display.c', - 'cairo-xlib-screen.c', - 'cairo-xlib-surface.c', - 'cairo-xlib-visual.c', - ] - -if CONFIG['MOZ_ENABLE_CAIRO_FT']: - EXPORTS.cairo += [ - 'cairo-ft.h', - ] - SOURCES += [ - 'cairo-ft-font.c', - 'cairo-type1-subset.c', - ] - -SOURCES += [ - 'cairo-bentley-ottmann-rectangular.c', # redefinition of '_cairo_bo_trap' - 'cairo-bentley-ottmann-rectilinear.c', # redefinition of '_cairo_bo_trap' - 'cairo-bentley-ottmann.c', # redefinition of '_cairo_bo_trap' - 'cairo-surface-wrapper.c', # redefinition of '_copy_transformed_pattern' -] - -SOURCES += [ - 'cairo-analysis-surface.c', - 'cairo-arc.c', - 'cairo-array.c', - 'cairo-atomic.c', - 'cairo-base64-stream.c', - 'cairo-botor-scan-converter.c', - 'cairo-boxes.c', - 'cairo-cache.c', - 'cairo-clip.c', - 'cairo-color.c', - 'cairo-composite-rectangles.c', - 'cairo-debug.c', - 'cairo-device.c', - 'cairo-fixed.c', - 'cairo-font-face-twin-data.c', - 'cairo-font-face-twin.c', - 'cairo-font-face.c', - 'cairo-font-options.c', - 'cairo-freed-pool.c', - 'cairo-freelist.c', - 'cairo-gstate.c', - 'cairo-hash.c', - 'cairo-hull.c', - 'cairo-image-info.c', - 'cairo-image-surface.c', - 'cairo-lzw.c', - 'cairo-matrix.c', - 'cairo-misc.c', - 'cairo-mutex.c', - 'cairo-observer.c', - 'cairo-output-stream.c', - 'cairo-paginated-surface.c', - 'cairo-path-bounds.c', - 'cairo-path-fill.c', - 'cairo-path-fixed.c', - 'cairo-path-in-fill.c', - 'cairo-path-stroke.c', - 'cairo-path.c', - 'cairo-pattern.c', - 'cairo-pen.c', - 'cairo-polygon.c', - 'cairo-recording-surface.c', - 'cairo-rectangle.c', - 'cairo-rectangular-scan-converter.c', - 'cairo-region.c', - 'cairo-scaled-font-subsets.c', - 'cairo-scaled-font.c', - 'cairo-slope.c', - 'cairo-spans.c', - 'cairo-spline.c', - 'cairo-stroke-style.c', - 'cairo-surface-clipper.c', - 'cairo-surface-fallback.c', - 'cairo-surface-offset.c', - 'cairo-surface-snapshot.c', - 'cairo-surface-subsurface.c', - 'cairo-surface.c', - 'cairo-tee-surface.c', - 'cairo-tor-scan-converter.c', - 'cairo-toy-font-face.c', - 'cairo-traps.c', - 'cairo-unicode.c', - 'cairo-user-font.c', - 'cairo-version.c', - 'cairo-wideint.c', - 'cairo.c', -] - -# We allow warnings for third-party code that can be updated from upstream. -ALLOW_COMPILER_WARNINGS = True - -FINAL_LIBRARY = 'gkmedias' - -DEFINES['PACKAGE_VERSION'] = '"moz"' -DEFINES['PACKAGE_BUGREPORT'] = '"http://bugzilla.mozilla.org/"' - -for var in ('CAIRO_HAS_PTHREAD', '_GNU_SOURCE'): - DEFINES[var] = True - -for var in ('MOZ_TREE_CAIRO', 'MOZ_TREE_PIXMAN'): - if CONFIG[var]: - DEFINES[var] = True - -if CONFIG['GNU_CC']: - DEFINES['HAVE_CXX11_ATOMIC_PRIMITIVES'] = True - # We would normally use autoconf to set these up, using AC_CHECK_SIZEOF. - # But AC_CHECK_SIZEOF requires running programs to determine the sizes, - # and that doesn't work so well with cross-compiling. So instead we - # use these magic macros, available since at least GCC 4.3, to define - # the preprocessor macros cairo wanted from autoconf. - DEFINES['SIZEOF_VOID_P'] = '__SIZEOF_POINTER__' - DEFINES['SIZEOF_INT'] = '__SIZEOF_INT__' - DEFINES['SIZEOF_LONG'] = '__SIZEOF_LONG__' - DEFINES['SIZEOF_LONG_LONG'] = '__SIZEOF_LONG_LONG__' - -# Normally determined by cairo's configure script. -DEFINES['HAVE_UINT64_T'] = True - -if CONFIG['MOZ_TREE_FREETYPE']: - DEFINES['HAVE_FT_LIBRARY_SETLCDFILTER'] = True - DEFINES['FT_LCD_FILTER_H'] = '%s/modules/freetype2/include/freetype/ftlcdfil.h' % TOPSRCDIR - -# Suppress warnings in third-party code. -if CONFIG['_MSC_VER']: - CFLAGS += [ - '-wd4005', # 'WIN32_LEAN_AND_MEAN' : macro redefinition - '-wd4018', # '>' : signed/unsigned mismatch - '-wd4047', # different levels of indirection - '-wd4101', # unreferenced local variable - '-wd4133', # 'function' : incompatible types - '-wd4146', # unary minus operator applied to unsigned type - '-wd4311', # 'variable' : pointer truncation from 'type' to 'type' - '-wd4477', # format string '%s' requires an argument of type 'type' - '-wd4996', # The compiler encountered a deprecated declaration. - ] - CXXFLAGS += [ - '-wd4005', # 'WIN32_LEAN_AND_MEAN' : macro redefinition - '-wd4018', # '>' : signed/unsigned mismatch - '-wd4146', # unary minus operator applied to unsigned type - '-wd4828', # illegal in the current source character set - '-wd4838', # requires a narrowing conversion -] -if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']: - CFLAGS += [ - '-Wno-enum-compare', - '-Wno-int-to-pointer-cast', - '-Wno-sign-compare', - '-Wno-type-limits', - '-Wno-missing-field-initializers', - '-Wno-conversion', - '-Wno-unused-but-set-variable', - ] - -if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']: - CFLAGS += [ - '-Wno-incompatible-pointer-types', - '-Wno-tautological-compare', - '-Wno-tautological-constant-out-of-range-compare', - '-Wno-error=uninitialized', - ] - -if CONFIG['CLANG_CL']: - CFLAGS += [ - '-Wno-deprecated-register', - '-Wno-macro-redefined', - '-Wno-unused-variable', - ] - -if CONFIG['MOZ_X11']: - CFLAGS += CONFIG['XCFLAGS'] - -if CONFIG['MOZ_ENABLE_CAIRO_FT']: - CFLAGS += CONFIG['CAIRO_FT_CFLAGS'] - CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS'] diff --git a/libs/cairo/moz.build b/libs/cairo/moz.build index 2aed0f42f..347846347 100644 --- a/libs/cairo/moz.build +++ b/libs/cairo/moz.build @@ -3,4 +3,201 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -DIRS += ['cairo/src'] +CONFIGURE_SUBST_FILES += ['src/cairo-features.h'] + +DEFINES['PACKAGE_VERSION'] = '"moz"' +DEFINES['PACKAGE_BUGREPORT'] = '"http://bugzilla.mozilla.org/"' + +for var in ('CAIRO_HAS_PTHREAD', '_GNU_SOURCE'): + DEFINES[var] = True + +for var in ('MOZ_TREE_CAIRO', 'MOZ_TREE_PIXMAN'): + if CONFIG[var]: + DEFINES[var] = True + +# Normally determined by cairo's configure script. +DEFINES['HAVE_UINT64_T'] = True + +if CONFIG['MOZ_TREE_FREETYPE']: + DEFINES['HAVE_FT_LIBRARY_SETLCDFILTER'] = True + DEFINES['FT_LCD_FILTER_H'] = '%s/modules/freetype2/include/freetype/ftlcdfil.h' % TOPSRCDIR + +EXPORTS.cairo += [ + '!src/cairo-features.h', + 'src/cairo-deprecated.h', + 'src/cairo-pdf.h', + 'src/cairo-platform.h', + 'src/cairo-rename.h', + 'src/cairo-tee.h', + 'src/cairo-version.h', + 'src/cairo.h', + 'src/pixman-rename.h', +] + +SOURCES += [ + 'src/cairo-analysis-surface.c', + 'src/cairo-arc.c', + 'src/cairo-array.c', + 'src/cairo-atomic.c', + 'src/cairo-base64-stream.c', + 'src/cairo-base85-stream.c', + 'src/cairo-bentley-ottmann-rectangular.c', # redefinition of '_cairo_bo_trap' + 'src/cairo-bentley-ottmann-rectilinear.c', # redefinition of '_cairo_bo_trap' + 'src/cairo-bentley-ottmann.c', # redefinition of '_cairo_bo_trap' + 'src/cairo-botor-scan-converter.c', + 'src/cairo-boxes.c', + 'src/cairo-cache.c', + 'src/cairo-cff-subset.c', + 'src/cairo-clip.c', + 'src/cairo-color.c', + 'src/cairo-composite-rectangles.c', + 'src/cairo-debug.c', + 'src/cairo-deflate-stream.c', + 'src/cairo-device.c', + 'src/cairo-fixed.c', + 'src/cairo-font-face-twin-data.c', + 'src/cairo-font-face-twin.c', + 'src/cairo-font-face.c', + 'src/cairo-font-options.c', + 'src/cairo-freed-pool.c', + 'src/cairo-freelist.c', + 'src/cairo-gstate.c', + 'src/cairo-hash.c', + 'src/cairo-hull.c', + 'src/cairo-image-info.c', + 'src/cairo-image-surface.c', + 'src/cairo-lzw.c', + 'src/cairo-matrix.c', + 'src/cairo-misc.c', + 'src/cairo-mutex.c', + 'src/cairo-observer.c', + 'src/cairo-output-stream.c', + 'src/cairo-paginated-surface.c', + 'src/cairo-path-bounds.c', + 'src/cairo-path-fill.c', + 'src/cairo-path-fixed.c', + 'src/cairo-path-in-fill.c', + 'src/cairo-path-stroke.c', + 'src/cairo-path.c', + 'src/cairo-pattern.c', + 'src/cairo-pdf-operators.c', + 'src/cairo-pdf-surface.c', + 'src/cairo-pen.c', + 'src/cairo-polygon.c', + 'src/cairo-recording-surface.c', + 'src/cairo-rectangle.c', + 'src/cairo-rectangular-scan-converter.c', + 'src/cairo-region.c', + 'src/cairo-scaled-font-subsets.c', + 'src/cairo-scaled-font.c', + 'src/cairo-slope.c', + 'src/cairo-spans.c', + 'src/cairo-spline.c', + 'src/cairo-stroke-style.c', + 'src/cairo-surface-clipper.c', + 'src/cairo-surface-fallback.c', + 'src/cairo-surface-offset.c', + 'src/cairo-surface-snapshot.c', + 'src/cairo-surface-subsurface.c', + 'src/cairo-surface-wrapper.c', # redefinition of '_copy_transformed_pattern' + 'src/cairo-surface.c', + 'src/cairo-tee-surface.c', + 'src/cairo-tor-scan-converter.c', + 'src/cairo-toy-font-face.c', + 'src/cairo-traps.c', + 'src/cairo-truetype-subset.c', + 'src/cairo-type1-fallback.c', +# 'src/cairo-type1-subset.c', should be here, but it's only supported on freetype platforms + 'src/cairo-type3-glyph-surface.c', + 'src/cairo-unicode.c', + 'src/cairo-user-font.c', + 'src/cairo-version.c', + 'src/cairo-wideint.c', + 'src/cairo.c', +] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + EXPORTS.cairo += ['src/cairo-win32.h'] + DEFINES['DISABLE_SOME_FLOATING_POINT'] = True + DEFINES['CAIRO_WIN32_STATIC_BUILD'] = True + SOURCES += [ + 'src/cairo-win32-font.c', + 'src/cairo-win32-surface.c', + ] + if CONFIG['_MSC_VER']: + CFLAGS += [ + '-wd4005', # 'WIN32_LEAN_AND_MEAN' : macro redefinition + '-wd4018', # '>' : signed/unsigned mismatch + '-wd4047', # different levels of indirection + '-wd4101', # unreferenced local variable + '-wd4133', # 'function' : incompatible types + '-wd4146', # unary minus operator applied to unsigned type + '-wd4311', # 'variable' : pointer truncation from 'type' to 'type' + '-wd4477', # format string '%s' requires an argument of type 'type' + '-wd4996', # The compiler encountered a deprecated declaration. + ] + CXXFLAGS += [ + '-wd4005', # 'WIN32_LEAN_AND_MEAN' : macro redefinition + '-wd4018', # '>' : signed/unsigned mismatch + '-wd4146', # unary minus operator applied to unsigned type + '-wd4828', # illegal in the current source character set + '-wd4838', # requires a narrowing conversion + ] + if CONFIG['MOZ_ENABLE_DWRITE_FONT']: + SOURCES += ['src/cairo-dwrite-font.cpp'] + if CONFIG['MOZ_ENABLE_D2D_SURFACE']: + SOURCES += ['src/cairo-d2d-surface.cpp'] + if CONFIG['NS_PRINTING']: + SOURCES += ['src/cairo-win32-printing-surface.c'] + else: + DEFINES['CAIRO_OMIT_WIN32_PRINTING'] = True +elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: + EXPORTS.cairo += ['src/cairo-ps.h'] + SOURCES += ['src/cairo-ps-surface.c'] + if CONFIG['GNU_CC']: + DEFINES['HAVE_CXX11_ATOMIC_PRIMITIVES'] = True + # We would normally use autoconf to set these up, using AC_CHECK_SIZEOF. + # But AC_CHECK_SIZEOF requires running programs to determine the sizes, + # and that doesn't work so well with cross-compiling. So instead we + # use these magic macros, available since at least GCC 4.3, to define + # the preprocessor macros cairo wanted from autoconf. + DEFINES['SIZEOF_VOID_P'] = '__SIZEOF_POINTER__' + DEFINES['SIZEOF_INT'] = '__SIZEOF_INT__' + DEFINES['SIZEOF_LONG'] = '__SIZEOF_LONG__' + DEFINES['SIZEOF_LONG_LONG'] = '__SIZEOF_LONG_LONG__' + CFLAGS += [ + '-Wno-enum-compare', + '-Wno-int-to-pointer-cast', + '-Wno-sign-compare', + '-Wno-type-limits', + '-Wno-missing-field-initializers', + '-Wno-conversion', + '-Wno-unused-but-set-variable', + ] + if CONFIG['MOZ_X11']: + EXPORTS.cairo += [ + 'src/cairo-xlib-xrender.h', + 'src/cairo-xlib.h', + ] + SOURCES += [ + 'src/cairo-xlib-display.c', + 'src/cairo-xlib-screen.c', + 'src/cairo-xlib-surface.c', + 'src/cairo-xlib-visual.c', + ] + CFLAGS += CONFIG['XCFLAGS'] + if CONFIG['MOZ_ENABLE_CAIRO_FT']: + EXPORTS.cairo += ['src/cairo-ft.h'] + SOURCES += [ + 'src/cairo-ft-font.c', + 'src/cairo-type1-subset.c', + ] + CFLAGS += CONFIG['CAIRO_FT_CFLAGS'] + CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS'] + +LOCAL_INCLUDES += ['!src'] + +# We allow warnings for third-party code that can be updated from upstream. +ALLOW_COMPILER_WARNINGS = True + +FINAL_LIBRARY = 'gkmedias' diff --git a/libs/cairo/cairo/src/cairo-analysis-surface-private.h b/libs/cairo/src/cairo-analysis-surface-private.h index 81832126c..81832126c 100644 --- a/libs/cairo/cairo/src/cairo-analysis-surface-private.h +++ b/libs/cairo/src/cairo-analysis-surface-private.h diff --git a/libs/cairo/cairo/src/cairo-analysis-surface.c b/libs/cairo/src/cairo-analysis-surface.c index 2be419994..2be419994 100644 --- a/libs/cairo/cairo/src/cairo-analysis-surface.c +++ b/libs/cairo/src/cairo-analysis-surface.c diff --git a/libs/cairo/cairo/src/cairo-arc-private.h b/libs/cairo/src/cairo-arc-private.h index e8dcc1394..e8dcc1394 100644 --- a/libs/cairo/cairo/src/cairo-arc-private.h +++ b/libs/cairo/src/cairo-arc-private.h diff --git a/libs/cairo/cairo/src/cairo-arc.c b/libs/cairo/src/cairo-arc.c index 54a0723d0..54a0723d0 100644 --- a/libs/cairo/cairo/src/cairo-arc.c +++ b/libs/cairo/src/cairo-arc.c diff --git a/libs/cairo/cairo/src/cairo-array.c b/libs/cairo/src/cairo-array.c index 442540c58..442540c58 100644 --- a/libs/cairo/cairo/src/cairo-array.c +++ b/libs/cairo/src/cairo-array.c diff --git a/libs/cairo/cairo/src/cairo-atomic-private.h b/libs/cairo/src/cairo-atomic-private.h index e14c5fdaf..e14c5fdaf 100644 --- a/libs/cairo/cairo/src/cairo-atomic-private.h +++ b/libs/cairo/src/cairo-atomic-private.h diff --git a/libs/cairo/cairo/src/cairo-atomic.c b/libs/cairo/src/cairo-atomic.c index fd5ee930b..fd5ee930b 100644 --- a/libs/cairo/cairo/src/cairo-atomic.c +++ b/libs/cairo/src/cairo-atomic.c diff --git a/libs/cairo/cairo/src/cairo-base64-stream.c b/libs/cairo/src/cairo-base64-stream.c index 02ca8bd45..02ca8bd45 100644 --- a/libs/cairo/cairo/src/cairo-base64-stream.c +++ b/libs/cairo/src/cairo-base64-stream.c diff --git a/libs/cairo/cairo/src/cairo-base85-stream.c b/libs/cairo/src/cairo-base85-stream.c index ba19ff4a2..ba19ff4a2 100644 --- a/libs/cairo/cairo/src/cairo-base85-stream.c +++ b/libs/cairo/src/cairo-base85-stream.c diff --git a/libs/cairo/cairo/src/cairo-bentley-ottmann-rectangular.c b/libs/cairo/src/cairo-bentley-ottmann-rectangular.c index 4736f4f41..4736f4f41 100644 --- a/libs/cairo/cairo/src/cairo-bentley-ottmann-rectangular.c +++ b/libs/cairo/src/cairo-bentley-ottmann-rectangular.c diff --git a/libs/cairo/cairo/src/cairo-bentley-ottmann-rectilinear.c b/libs/cairo/src/cairo-bentley-ottmann-rectilinear.c index b00d2823b..b00d2823b 100644 --- a/libs/cairo/cairo/src/cairo-bentley-ottmann-rectilinear.c +++ b/libs/cairo/src/cairo-bentley-ottmann-rectilinear.c diff --git a/libs/cairo/cairo/src/cairo-bentley-ottmann.c b/libs/cairo/src/cairo-bentley-ottmann.c index c333becaa..c333becaa 100644 --- a/libs/cairo/cairo/src/cairo-bentley-ottmann.c +++ b/libs/cairo/src/cairo-bentley-ottmann.c diff --git a/libs/cairo/cairo/src/cairo-botor-scan-converter.c b/libs/cairo/src/cairo-botor-scan-converter.c index ae060dc31..ae060dc31 100644 --- a/libs/cairo/cairo/src/cairo-botor-scan-converter.c +++ b/libs/cairo/src/cairo-botor-scan-converter.c diff --git a/libs/cairo/cairo/src/cairo-boxes-private.h b/libs/cairo/src/cairo-boxes-private.h index e61a64d7c..e61a64d7c 100644 --- a/libs/cairo/cairo/src/cairo-boxes-private.h +++ b/libs/cairo/src/cairo-boxes-private.h diff --git a/libs/cairo/cairo/src/cairo-boxes.c b/libs/cairo/src/cairo-boxes.c index e29dd7e13..e29dd7e13 100644 --- a/libs/cairo/cairo/src/cairo-boxes.c +++ b/libs/cairo/src/cairo-boxes.c diff --git a/libs/cairo/cairo/src/cairo-cache-private.h b/libs/cairo/src/cairo-cache-private.h index 06940a63a..06940a63a 100644 --- a/libs/cairo/cairo/src/cairo-cache-private.h +++ b/libs/cairo/src/cairo-cache-private.h diff --git a/libs/cairo/cairo/src/cairo-cache.c b/libs/cairo/src/cairo-cache.c index 021b012fd..021b012fd 100644 --- a/libs/cairo/cairo/src/cairo-cache.c +++ b/libs/cairo/src/cairo-cache.c diff --git a/libs/cairo/cairo/src/cairo-cff-subset.c b/libs/cairo/src/cairo-cff-subset.c index 6a5060047..6a5060047 100644 --- a/libs/cairo/cairo/src/cairo-cff-subset.c +++ b/libs/cairo/src/cairo-cff-subset.c diff --git a/libs/cairo/cairo/src/cairo-clip-private.h b/libs/cairo/src/cairo-clip-private.h index 04d80afc7..04d80afc7 100644 --- a/libs/cairo/cairo/src/cairo-clip-private.h +++ b/libs/cairo/src/cairo-clip-private.h diff --git a/libs/cairo/cairo/src/cairo-clip.c b/libs/cairo/src/cairo-clip.c index cbbf4d2ce..cbbf4d2ce 100644 --- a/libs/cairo/cairo/src/cairo-clip.c +++ b/libs/cairo/src/cairo-clip.c diff --git a/libs/cairo/cairo/src/cairo-color.c b/libs/cairo/src/cairo-color.c index b9dae237e..b9dae237e 100644 --- a/libs/cairo/cairo/src/cairo-color.c +++ b/libs/cairo/src/cairo-color.c diff --git a/libs/cairo/cairo/src/cairo-combsort-private.h b/libs/cairo/src/cairo-combsort-private.h index 3400a681c..3400a681c 100644 --- a/libs/cairo/cairo/src/cairo-combsort-private.h +++ b/libs/cairo/src/cairo-combsort-private.h diff --git a/libs/cairo/cairo/src/cairo-compiler-private.h b/libs/cairo/src/cairo-compiler-private.h index 34cfe0956..34cfe0956 100644 --- a/libs/cairo/cairo/src/cairo-compiler-private.h +++ b/libs/cairo/src/cairo-compiler-private.h diff --git a/libs/cairo/cairo/src/cairo-composite-rectangles-private.h b/libs/cairo/src/cairo-composite-rectangles-private.h index ddbe6bb1a..ddbe6bb1a 100644 --- a/libs/cairo/cairo/src/cairo-composite-rectangles-private.h +++ b/libs/cairo/src/cairo-composite-rectangles-private.h diff --git a/libs/cairo/cairo/src/cairo-composite-rectangles.c b/libs/cairo/src/cairo-composite-rectangles.c index a7b499cf4..a7b499cf4 100644 --- a/libs/cairo/cairo/src/cairo-composite-rectangles.c +++ b/libs/cairo/src/cairo-composite-rectangles.c diff --git a/libs/cairo/cairo/src/cairo-d2d-private-fx.h b/libs/cairo/src/cairo-d2d-private-fx.h index 1756c57f6..1756c57f6 100644 --- a/libs/cairo/cairo/src/cairo-d2d-private-fx.h +++ b/libs/cairo/src/cairo-d2d-private-fx.h diff --git a/libs/cairo/cairo/src/cairo-d2d-private.fx b/libs/cairo/src/cairo-d2d-private.fx index 8f05d693b..8f05d693b 100644 --- a/libs/cairo/cairo/src/cairo-d2d-private.fx +++ b/libs/cairo/src/cairo-d2d-private.fx diff --git a/libs/cairo/cairo/src/cairo-d2d-private.h b/libs/cairo/src/cairo-d2d-private.h index 00244b497..00244b497 100644 --- a/libs/cairo/cairo/src/cairo-d2d-private.h +++ b/libs/cairo/src/cairo-d2d-private.h diff --git a/libs/cairo/cairo/src/cairo-d2d-surface.cpp b/libs/cairo/src/cairo-d2d-surface.cpp index 6aa8a3503..6aa8a3503 100644 --- a/libs/cairo/cairo/src/cairo-d2d-surface.cpp +++ b/libs/cairo/src/cairo-d2d-surface.cpp diff --git a/libs/cairo/cairo/src/cairo-debug.c b/libs/cairo/src/cairo-debug.c index 49bf31594..49bf31594 100644 --- a/libs/cairo/cairo/src/cairo-debug.c +++ b/libs/cairo/src/cairo-debug.c diff --git a/libs/cairo/cairo/src/cairo-deflate-stream.c b/libs/cairo/src/cairo-deflate-stream.c index b6d10b12a..b6d10b12a 100644 --- a/libs/cairo/cairo/src/cairo-deflate-stream.c +++ b/libs/cairo/src/cairo-deflate-stream.c diff --git a/libs/cairo/cairo/src/cairo-deprecated.h b/libs/cairo/src/cairo-deprecated.h index 04b5d264d..04b5d264d 100644 --- a/libs/cairo/cairo/src/cairo-deprecated.h +++ b/libs/cairo/src/cairo-deprecated.h diff --git a/libs/cairo/cairo/src/cairo-device-private.h b/libs/cairo/src/cairo-device-private.h index 371f66714..371f66714 100644 --- a/libs/cairo/cairo/src/cairo-device-private.h +++ b/libs/cairo/src/cairo-device-private.h diff --git a/libs/cairo/cairo/src/cairo-device.c b/libs/cairo/src/cairo-device.c index d24dba94c..d24dba94c 100644 --- a/libs/cairo/cairo/src/cairo-device.c +++ b/libs/cairo/src/cairo-device.c diff --git a/libs/cairo/cairo/src/cairo-directfb-surface.c b/libs/cairo/src/cairo-directfb-surface.c index 6387fee94..6387fee94 100644 --- a/libs/cairo/cairo/src/cairo-directfb-surface.c +++ b/libs/cairo/src/cairo-directfb-surface.c diff --git a/libs/cairo/cairo/src/cairo-directfb.h b/libs/cairo/src/cairo-directfb.h index 029b43ef7..029b43ef7 100644 --- a/libs/cairo/cairo/src/cairo-directfb.h +++ b/libs/cairo/src/cairo-directfb.h diff --git a/libs/cairo/cairo/src/cairo-drm.h b/libs/cairo/src/cairo-drm.h index bbdb28ba2..bbdb28ba2 100644 --- a/libs/cairo/cairo/src/cairo-drm.h +++ b/libs/cairo/src/cairo-drm.h diff --git a/libs/cairo/cairo/src/cairo-dwrite-font.cpp b/libs/cairo/src/cairo-dwrite-font.cpp index 391f2e8a7..391f2e8a7 100644 --- a/libs/cairo/cairo/src/cairo-dwrite-font.cpp +++ b/libs/cairo/src/cairo-dwrite-font.cpp diff --git a/libs/cairo/cairo/src/cairo-dwrite-private.h b/libs/cairo/src/cairo-dwrite-private.h index 1eaa46113..1eaa46113 100644 --- a/libs/cairo/cairo/src/cairo-dwrite-private.h +++ b/libs/cairo/src/cairo-dwrite-private.h diff --git a/libs/cairo/cairo/src/cairo-eagle-context.c b/libs/cairo/src/cairo-eagle-context.c index 5f59f5239..5f59f5239 100644 --- a/libs/cairo/cairo/src/cairo-eagle-context.c +++ b/libs/cairo/src/cairo-eagle-context.c diff --git a/libs/cairo/cairo/src/cairo-error-private.h b/libs/cairo/src/cairo-error-private.h index c7a9f7098..c7a9f7098 100644 --- a/libs/cairo/cairo/src/cairo-error-private.h +++ b/libs/cairo/src/cairo-error-private.h diff --git a/libs/cairo/cairo/src/cairo-features-win32.h b/libs/cairo/src/cairo-features-win32.h index ef202fc14..ef202fc14 100644 --- a/libs/cairo/cairo/src/cairo-features-win32.h +++ b/libs/cairo/src/cairo-features-win32.h diff --git a/libs/cairo/cairo/src/cairo-features.h.in b/libs/cairo/src/cairo-features.h.in index 9692c7cb7..9692c7cb7 100644 --- a/libs/cairo/cairo/src/cairo-features.h.in +++ b/libs/cairo/src/cairo-features.h.in diff --git a/libs/cairo/cairo/src/cairo-fixed-private.h b/libs/cairo/src/cairo-fixed-private.h index a00e99cf3..a00e99cf3 100644 --- a/libs/cairo/cairo/src/cairo-fixed-private.h +++ b/libs/cairo/src/cairo-fixed-private.h diff --git a/libs/cairo/cairo/src/cairo-fixed-type-private.h b/libs/cairo/src/cairo-fixed-type-private.h index d2bf6cb66..d2bf6cb66 100644 --- a/libs/cairo/cairo/src/cairo-fixed-type-private.h +++ b/libs/cairo/src/cairo-fixed-type-private.h diff --git a/libs/cairo/cairo/src/cairo-fixed.c b/libs/cairo/src/cairo-fixed.c index 75805f3d3..75805f3d3 100644 --- a/libs/cairo/cairo/src/cairo-fixed.c +++ b/libs/cairo/src/cairo-fixed.c diff --git a/libs/cairo/cairo/src/cairo-font-face-twin-data.c b/libs/cairo/src/cairo-font-face-twin-data.c index ff09cb2be..ff09cb2be 100644 --- a/libs/cairo/cairo/src/cairo-font-face-twin-data.c +++ b/libs/cairo/src/cairo-font-face-twin-data.c diff --git a/libs/cairo/cairo/src/cairo-font-face-twin.c b/libs/cairo/src/cairo-font-face-twin.c index da85cb08e..da85cb08e 100644 --- a/libs/cairo/cairo/src/cairo-font-face-twin.c +++ b/libs/cairo/src/cairo-font-face-twin.c diff --git a/libs/cairo/cairo/src/cairo-font-face.c b/libs/cairo/src/cairo-font-face.c index ab17a8cb2..ab17a8cb2 100644 --- a/libs/cairo/cairo/src/cairo-font-face.c +++ b/libs/cairo/src/cairo-font-face.c diff --git a/libs/cairo/cairo/src/cairo-font-options.c b/libs/cairo/src/cairo-font-options.c index 17a892160..17a892160 100644 --- a/libs/cairo/cairo/src/cairo-font-options.c +++ b/libs/cairo/src/cairo-font-options.c diff --git a/libs/cairo/cairo/src/cairo-fontconfig-private.h b/libs/cairo/src/cairo-fontconfig-private.h index 110304b18..110304b18 100644 --- a/libs/cairo/cairo/src/cairo-fontconfig-private.h +++ b/libs/cairo/src/cairo-fontconfig-private.h diff --git a/libs/cairo/cairo/src/cairo-freed-pool-private.h b/libs/cairo/src/cairo-freed-pool-private.h index c23e5a03a..c23e5a03a 100644 --- a/libs/cairo/cairo/src/cairo-freed-pool-private.h +++ b/libs/cairo/src/cairo-freed-pool-private.h diff --git a/libs/cairo/cairo/src/cairo-freed-pool.c b/libs/cairo/src/cairo-freed-pool.c index c65f4626d..c65f4626d 100644 --- a/libs/cairo/cairo/src/cairo-freed-pool.c +++ b/libs/cairo/src/cairo-freed-pool.c diff --git a/libs/cairo/cairo/src/cairo-freelist-private.h b/libs/cairo/src/cairo-freelist-private.h index 703181b56..703181b56 100644 --- a/libs/cairo/cairo/src/cairo-freelist-private.h +++ b/libs/cairo/src/cairo-freelist-private.h diff --git a/libs/cairo/cairo/src/cairo-freelist-type-private.h b/libs/cairo/src/cairo-freelist-type-private.h index 4dd056461..4dd056461 100644 --- a/libs/cairo/cairo/src/cairo-freelist-type-private.h +++ b/libs/cairo/src/cairo-freelist-type-private.h diff --git a/libs/cairo/cairo/src/cairo-freelist.c b/libs/cairo/src/cairo-freelist.c index d596eab81..d596eab81 100644 --- a/libs/cairo/cairo/src/cairo-freelist.c +++ b/libs/cairo/src/cairo-freelist.c diff --git a/libs/cairo/cairo/src/cairo-ft-font.c b/libs/cairo/src/cairo-ft-font.c index 1a2799b86..1a2799b86 100644 --- a/libs/cairo/cairo/src/cairo-ft-font.c +++ b/libs/cairo/src/cairo-ft-font.c diff --git a/libs/cairo/cairo/src/cairo-ft-private.h b/libs/cairo/src/cairo-ft-private.h index 42a1776ed..42a1776ed 100644 --- a/libs/cairo/cairo/src/cairo-ft-private.h +++ b/libs/cairo/src/cairo-ft-private.h diff --git a/libs/cairo/cairo/src/cairo-ft.h b/libs/cairo/src/cairo-ft.h index 2f584066f..2f584066f 100644 --- a/libs/cairo/cairo/src/cairo-ft.h +++ b/libs/cairo/src/cairo-ft.h diff --git a/libs/cairo/cairo/src/cairo-gl-glyphs.c b/libs/cairo/src/cairo-gl-glyphs.c index 883883fbf..883883fbf 100644 --- a/libs/cairo/cairo/src/cairo-gl-glyphs.c +++ b/libs/cairo/src/cairo-gl-glyphs.c diff --git a/libs/cairo/cairo/src/cairo-gl-private.h b/libs/cairo/src/cairo-gl-private.h index 96a2a1b5b..96a2a1b5b 100644 --- a/libs/cairo/cairo/src/cairo-gl-private.h +++ b/libs/cairo/src/cairo-gl-private.h diff --git a/libs/cairo/cairo/src/cairo-gl-shaders.c b/libs/cairo/src/cairo-gl-shaders.c index d0edffa88..d0edffa88 100644 --- a/libs/cairo/cairo/src/cairo-gl-shaders.c +++ b/libs/cairo/src/cairo-gl-shaders.c diff --git a/libs/cairo/cairo/src/cairo-gl-surface.c b/libs/cairo/src/cairo-gl-surface.c index 458300050..458300050 100644 --- a/libs/cairo/cairo/src/cairo-gl-surface.c +++ b/libs/cairo/src/cairo-gl-surface.c diff --git a/libs/cairo/cairo/src/cairo-gl.h b/libs/cairo/src/cairo-gl.h index 17c5b03f1..17c5b03f1 100644 --- a/libs/cairo/cairo/src/cairo-gl.h +++ b/libs/cairo/src/cairo-gl.h diff --git a/libs/cairo/cairo/src/cairo-glitz-private.h b/libs/cairo/src/cairo-glitz-private.h index 144eff4a5..144eff4a5 100644 --- a/libs/cairo/cairo/src/cairo-glitz-private.h +++ b/libs/cairo/src/cairo-glitz-private.h diff --git a/libs/cairo/cairo/src/cairo-glitz-surface.c b/libs/cairo/src/cairo-glitz-surface.c index bd176d056..bd176d056 100644 --- a/libs/cairo/cairo/src/cairo-glitz-surface.c +++ b/libs/cairo/src/cairo-glitz-surface.c diff --git a/libs/cairo/cairo/src/cairo-glitz.h b/libs/cairo/src/cairo-glitz.h index b74e887bc..b74e887bc 100644 --- a/libs/cairo/cairo/src/cairo-glitz.h +++ b/libs/cairo/src/cairo-glitz.h diff --git a/libs/cairo/cairo/src/cairo-glx-context.c b/libs/cairo/src/cairo-glx-context.c index 1ceab6cc3..1ceab6cc3 100644 --- a/libs/cairo/cairo/src/cairo-glx-context.c +++ b/libs/cairo/src/cairo-glx-context.c diff --git a/libs/cairo/cairo/src/cairo-gstate-private.h b/libs/cairo/src/cairo-gstate-private.h index e8127d770..e8127d770 100644 --- a/libs/cairo/cairo/src/cairo-gstate-private.h +++ b/libs/cairo/src/cairo-gstate-private.h diff --git a/libs/cairo/cairo/src/cairo-gstate.c b/libs/cairo/src/cairo-gstate.c index 6ba6f0b1d..6ba6f0b1d 100644 --- a/libs/cairo/cairo/src/cairo-gstate.c +++ b/libs/cairo/src/cairo-gstate.c diff --git a/libs/cairo/cairo/src/cairo-hash-private.h b/libs/cairo/src/cairo-hash-private.h index 0c2759dbf..0c2759dbf 100644 --- a/libs/cairo/cairo/src/cairo-hash-private.h +++ b/libs/cairo/src/cairo-hash-private.h diff --git a/libs/cairo/cairo/src/cairo-hash.c b/libs/cairo/src/cairo-hash.c index 7e24d930d..7e24d930d 100644 --- a/libs/cairo/cairo/src/cairo-hash.c +++ b/libs/cairo/src/cairo-hash.c diff --git a/libs/cairo/cairo/src/cairo-hull.c b/libs/cairo/src/cairo-hull.c index a9cb27982..a9cb27982 100644 --- a/libs/cairo/cairo/src/cairo-hull.c +++ b/libs/cairo/src/cairo-hull.c diff --git a/libs/cairo/cairo/src/cairo-image-info-private.h b/libs/cairo/src/cairo-image-info-private.h index 1107fa4f9..1107fa4f9 100644 --- a/libs/cairo/cairo/src/cairo-image-info-private.h +++ b/libs/cairo/src/cairo-image-info-private.h diff --git a/libs/cairo/cairo/src/cairo-image-info.c b/libs/cairo/src/cairo-image-info.c index 5269ce25f..5269ce25f 100644 --- a/libs/cairo/cairo/src/cairo-image-info.c +++ b/libs/cairo/src/cairo-image-info.c diff --git a/libs/cairo/cairo/src/cairo-image-surface.c b/libs/cairo/src/cairo-image-surface.c index cc496ece5..cc496ece5 100644 --- a/libs/cairo/cairo/src/cairo-image-surface.c +++ b/libs/cairo/src/cairo-image-surface.c diff --git a/libs/cairo/cairo/src/cairo-list-private.h b/libs/cairo/src/cairo-list-private.h index ca4e368fc..ca4e368fc 100644 --- a/libs/cairo/cairo/src/cairo-list-private.h +++ b/libs/cairo/src/cairo-list-private.h diff --git a/libs/cairo/cairo/src/cairo-lzw.c b/libs/cairo/src/cairo-lzw.c index e98e613bc..e98e613bc 100644 --- a/libs/cairo/cairo/src/cairo-lzw.c +++ b/libs/cairo/src/cairo-lzw.c diff --git a/libs/cairo/cairo/src/cairo-malloc-private.h b/libs/cairo/src/cairo-malloc-private.h index 765fb65b4..765fb65b4 100644 --- a/libs/cairo/cairo/src/cairo-malloc-private.h +++ b/libs/cairo/src/cairo-malloc-private.h diff --git a/libs/cairo/cairo/src/cairo-matrix.c b/libs/cairo/src/cairo-matrix.c index b9691b8ee..b9691b8ee 100644 --- a/libs/cairo/cairo/src/cairo-matrix.c +++ b/libs/cairo/src/cairo-matrix.c diff --git a/libs/cairo/cairo/src/cairo-meta-surface-private.h b/libs/cairo/src/cairo-meta-surface-private.h index c1f6c40f2..c1f6c40f2 100644 --- a/libs/cairo/cairo/src/cairo-meta-surface-private.h +++ b/libs/cairo/src/cairo-meta-surface-private.h diff --git a/libs/cairo/cairo/src/cairo-misc.c b/libs/cairo/src/cairo-misc.c index 6aa793f61..6aa793f61 100644 --- a/libs/cairo/cairo/src/cairo-misc.c +++ b/libs/cairo/src/cairo-misc.c diff --git a/libs/cairo/cairo/src/cairo-mutex-impl-private.h b/libs/cairo/src/cairo-mutex-impl-private.h index 72086036c..72086036c 100644 --- a/libs/cairo/cairo/src/cairo-mutex-impl-private.h +++ b/libs/cairo/src/cairo-mutex-impl-private.h diff --git a/libs/cairo/cairo/src/cairo-mutex-list-private.h b/libs/cairo/src/cairo-mutex-list-private.h index 3f2e44119..3f2e44119 100644 --- a/libs/cairo/cairo/src/cairo-mutex-list-private.h +++ b/libs/cairo/src/cairo-mutex-list-private.h diff --git a/libs/cairo/cairo/src/cairo-mutex-private.h b/libs/cairo/src/cairo-mutex-private.h index e9359ef55..e9359ef55 100644 --- a/libs/cairo/cairo/src/cairo-mutex-private.h +++ b/libs/cairo/src/cairo-mutex-private.h diff --git a/libs/cairo/cairo/src/cairo-mutex-type-private.h b/libs/cairo/src/cairo-mutex-type-private.h index eac1d48e6..eac1d48e6 100644 --- a/libs/cairo/cairo/src/cairo-mutex-type-private.h +++ b/libs/cairo/src/cairo-mutex-type-private.h diff --git a/libs/cairo/cairo/src/cairo-mutex.c b/libs/cairo/src/cairo-mutex.c index d859e28d9..d859e28d9 100644 --- a/libs/cairo/cairo/src/cairo-mutex.c +++ b/libs/cairo/src/cairo-mutex.c diff --git a/libs/cairo/cairo/src/cairo-no-features.h b/libs/cairo/src/cairo-no-features.h index 9b3d86be2..9b3d86be2 100644 --- a/libs/cairo/cairo/src/cairo-no-features.h +++ b/libs/cairo/src/cairo-no-features.h diff --git a/libs/cairo/cairo/src/cairo-observer.c b/libs/cairo/src/cairo-observer.c index c8ce5eea2..c8ce5eea2 100644 --- a/libs/cairo/cairo/src/cairo-observer.c +++ b/libs/cairo/src/cairo-observer.c diff --git a/libs/cairo/cairo/src/cairo-os2-private.h b/libs/cairo/src/cairo-os2-private.h index e47efd316..e47efd316 100644 --- a/libs/cairo/cairo/src/cairo-os2-private.h +++ b/libs/cairo/src/cairo-os2-private.h diff --git a/libs/cairo/cairo/src/cairo-os2-surface.c b/libs/cairo/src/cairo-os2-surface.c index c0464f62b..c0464f62b 100644 --- a/libs/cairo/cairo/src/cairo-os2-surface.c +++ b/libs/cairo/src/cairo-os2-surface.c diff --git a/libs/cairo/cairo/src/cairo-os2.h b/libs/cairo/src/cairo-os2.h index 16a4fc564..16a4fc564 100644 --- a/libs/cairo/cairo/src/cairo-os2.h +++ b/libs/cairo/src/cairo-os2.h diff --git a/libs/cairo/cairo/src/cairo-output-stream-private.h b/libs/cairo/src/cairo-output-stream-private.h index 8f3cb3c6b..8f3cb3c6b 100644 --- a/libs/cairo/cairo/src/cairo-output-stream-private.h +++ b/libs/cairo/src/cairo-output-stream-private.h diff --git a/libs/cairo/cairo/src/cairo-output-stream.c b/libs/cairo/src/cairo-output-stream.c index 5f8d774cd..5f8d774cd 100644 --- a/libs/cairo/cairo/src/cairo-output-stream.c +++ b/libs/cairo/src/cairo-output-stream.c diff --git a/libs/cairo/cairo/src/cairo-paginated-private.h b/libs/cairo/src/cairo-paginated-private.h index 5687cf85c..5687cf85c 100644 --- a/libs/cairo/cairo/src/cairo-paginated-private.h +++ b/libs/cairo/src/cairo-paginated-private.h diff --git a/libs/cairo/cairo/src/cairo-paginated-surface-private.h b/libs/cairo/src/cairo-paginated-surface-private.h index 0b4e81f23..0b4e81f23 100644 --- a/libs/cairo/cairo/src/cairo-paginated-surface-private.h +++ b/libs/cairo/src/cairo-paginated-surface-private.h diff --git a/libs/cairo/cairo/src/cairo-paginated-surface.c b/libs/cairo/src/cairo-paginated-surface.c index febcd05fa..febcd05fa 100644 --- a/libs/cairo/cairo/src/cairo-paginated-surface.c +++ b/libs/cairo/src/cairo-paginated-surface.c diff --git a/libs/cairo/cairo/src/cairo-path-bounds.c b/libs/cairo/src/cairo-path-bounds.c index c752fbca1..c752fbca1 100644 --- a/libs/cairo/cairo/src/cairo-path-bounds.c +++ b/libs/cairo/src/cairo-path-bounds.c diff --git a/libs/cairo/cairo/src/cairo-path-fill.c b/libs/cairo/src/cairo-path-fill.c index 40d41157a..40d41157a 100644 --- a/libs/cairo/cairo/src/cairo-path-fill.c +++ b/libs/cairo/src/cairo-path-fill.c diff --git a/libs/cairo/cairo/src/cairo-path-fixed-private.h b/libs/cairo/src/cairo-path-fixed-private.h index 69972505a..69972505a 100644 --- a/libs/cairo/cairo/src/cairo-path-fixed-private.h +++ b/libs/cairo/src/cairo-path-fixed-private.h diff --git a/libs/cairo/cairo/src/cairo-path-fixed.c b/libs/cairo/src/cairo-path-fixed.c index 3ba5f75e0..3ba5f75e0 100644 --- a/libs/cairo/cairo/src/cairo-path-fixed.c +++ b/libs/cairo/src/cairo-path-fixed.c diff --git a/libs/cairo/cairo/src/cairo-path-in-fill.c b/libs/cairo/src/cairo-path-in-fill.c index c303d8596..c303d8596 100644 --- a/libs/cairo/cairo/src/cairo-path-in-fill.c +++ b/libs/cairo/src/cairo-path-in-fill.c diff --git a/libs/cairo/cairo/src/cairo-path-private.h b/libs/cairo/src/cairo-path-private.h index c28612a32..c28612a32 100644 --- a/libs/cairo/cairo/src/cairo-path-private.h +++ b/libs/cairo/src/cairo-path-private.h diff --git a/libs/cairo/cairo/src/cairo-path-stroke.c b/libs/cairo/src/cairo-path-stroke.c index 6d1d6f205..6d1d6f205 100644 --- a/libs/cairo/cairo/src/cairo-path-stroke.c +++ b/libs/cairo/src/cairo-path-stroke.c diff --git a/libs/cairo/cairo/src/cairo-path.c b/libs/cairo/src/cairo-path.c index 49b479a99..49b479a99 100644 --- a/libs/cairo/cairo/src/cairo-path.c +++ b/libs/cairo/src/cairo-path.c diff --git a/libs/cairo/cairo/src/cairo-pattern.c b/libs/cairo/src/cairo-pattern.c index 502344f3c..502344f3c 100644 --- a/libs/cairo/cairo/src/cairo-pattern.c +++ b/libs/cairo/src/cairo-pattern.c diff --git a/libs/cairo/cairo/src/cairo-pdf-operators-private.h b/libs/cairo/src/cairo-pdf-operators-private.h index d0051433b..d0051433b 100644 --- a/libs/cairo/cairo/src/cairo-pdf-operators-private.h +++ b/libs/cairo/src/cairo-pdf-operators-private.h diff --git a/libs/cairo/cairo/src/cairo-pdf-operators.c b/libs/cairo/src/cairo-pdf-operators.c index 4da9d573c..4da9d573c 100644 --- a/libs/cairo/cairo/src/cairo-pdf-operators.c +++ b/libs/cairo/src/cairo-pdf-operators.c diff --git a/libs/cairo/cairo/src/cairo-pdf-surface-private.h b/libs/cairo/src/cairo-pdf-surface-private.h index ab5befa52..ab5befa52 100644 --- a/libs/cairo/cairo/src/cairo-pdf-surface-private.h +++ b/libs/cairo/src/cairo-pdf-surface-private.h diff --git a/libs/cairo/cairo/src/cairo-pdf-surface.c b/libs/cairo/src/cairo-pdf-surface.c index 3dcf58859..3dcf58859 100644 --- a/libs/cairo/cairo/src/cairo-pdf-surface.c +++ b/libs/cairo/src/cairo-pdf-surface.c diff --git a/libs/cairo/cairo/src/cairo-pdf.h b/libs/cairo/src/cairo-pdf.h index 0e85e9804..0e85e9804 100644 --- a/libs/cairo/cairo/src/cairo-pdf.h +++ b/libs/cairo/src/cairo-pdf.h diff --git a/libs/cairo/cairo/src/cairo-pen.c b/libs/cairo/src/cairo-pen.c index 751b5dc3a..751b5dc3a 100644 --- a/libs/cairo/cairo/src/cairo-pen.c +++ b/libs/cairo/src/cairo-pen.c diff --git a/libs/cairo/cairo/src/cairo-platform.h b/libs/cairo/src/cairo-platform.h index 9d4bc4d1f..9d4bc4d1f 100644 --- a/libs/cairo/cairo/src/cairo-platform.h +++ b/libs/cairo/src/cairo-platform.h diff --git a/libs/cairo/cairo/src/cairo-png.c b/libs/cairo/src/cairo-png.c index bbab2c2ae..bbab2c2ae 100644 --- a/libs/cairo/cairo/src/cairo-png.c +++ b/libs/cairo/src/cairo-png.c diff --git a/libs/cairo/cairo/src/cairo-polygon.c b/libs/cairo/src/cairo-polygon.c index fd71319e9..fd71319e9 100644 --- a/libs/cairo/cairo/src/cairo-polygon.c +++ b/libs/cairo/src/cairo-polygon.c diff --git a/libs/cairo/cairo/src/cairo-private.h b/libs/cairo/src/cairo-private.h index 33b049678..33b049678 100644 --- a/libs/cairo/cairo/src/cairo-private.h +++ b/libs/cairo/src/cairo-private.h diff --git a/libs/cairo/cairo/src/cairo-ps-surface-private.h b/libs/cairo/src/cairo-ps-surface-private.h index 96da53554..96da53554 100644 --- a/libs/cairo/cairo/src/cairo-ps-surface-private.h +++ b/libs/cairo/src/cairo-ps-surface-private.h diff --git a/libs/cairo/cairo/src/cairo-ps-surface.c b/libs/cairo/src/cairo-ps-surface.c index 5696d6cb7..5696d6cb7 100644 --- a/libs/cairo/cairo/src/cairo-ps-surface.c +++ b/libs/cairo/src/cairo-ps-surface.c diff --git a/libs/cairo/cairo/src/cairo-ps.h b/libs/cairo/src/cairo-ps.h index 3d609c9d1..3d609c9d1 100644 --- a/libs/cairo/cairo/src/cairo-ps.h +++ b/libs/cairo/src/cairo-ps.h diff --git a/libs/cairo/cairo/src/cairo-recording-surface-private.h b/libs/cairo/src/cairo-recording-surface-private.h index c21a93205..c21a93205 100644 --- a/libs/cairo/cairo/src/cairo-recording-surface-private.h +++ b/libs/cairo/src/cairo-recording-surface-private.h diff --git a/libs/cairo/cairo/src/cairo-recording-surface.c b/libs/cairo/src/cairo-recording-surface.c index 8230ac375..8230ac375 100644 --- a/libs/cairo/cairo/src/cairo-recording-surface.c +++ b/libs/cairo/src/cairo-recording-surface.c diff --git a/libs/cairo/cairo/src/cairo-rectangle.c b/libs/cairo/src/cairo-rectangle.c index ab043c1bc..ab043c1bc 100644 --- a/libs/cairo/cairo/src/cairo-rectangle.c +++ b/libs/cairo/src/cairo-rectangle.c diff --git a/libs/cairo/cairo/src/cairo-rectangular-scan-converter.c b/libs/cairo/src/cairo-rectangular-scan-converter.c index 6c21f5fd5..6c21f5fd5 100644 --- a/libs/cairo/cairo/src/cairo-rectangular-scan-converter.c +++ b/libs/cairo/src/cairo-rectangular-scan-converter.c diff --git a/libs/cairo/cairo/src/cairo-reference-count-private.h b/libs/cairo/src/cairo-reference-count-private.h index c05d4c910..c05d4c910 100644 --- a/libs/cairo/cairo/src/cairo-reference-count-private.h +++ b/libs/cairo/src/cairo-reference-count-private.h diff --git a/libs/cairo/cairo/src/cairo-region-private.h b/libs/cairo/src/cairo-region-private.h index 32c1e82ab..32c1e82ab 100644 --- a/libs/cairo/cairo/src/cairo-region-private.h +++ b/libs/cairo/src/cairo-region-private.h diff --git a/libs/cairo/cairo/src/cairo-region.c b/libs/cairo/src/cairo-region.c index 3e8ac1248..3e8ac1248 100644 --- a/libs/cairo/cairo/src/cairo-region.c +++ b/libs/cairo/src/cairo-region.c diff --git a/libs/cairo/cairo/src/cairo-rename.h b/libs/cairo/src/cairo-rename.h index db20352ea..db20352ea 100644 --- a/libs/cairo/cairo/src/cairo-rename.h +++ b/libs/cairo/src/cairo-rename.h diff --git a/libs/cairo/cairo/src/cairo-rtree-private.h b/libs/cairo/src/cairo-rtree-private.h index 295f48ced..295f48ced 100644 --- a/libs/cairo/cairo/src/cairo-rtree-private.h +++ b/libs/cairo/src/cairo-rtree-private.h diff --git a/libs/cairo/cairo/src/cairo-rtree.c b/libs/cairo/src/cairo-rtree.c index 059edff75..059edff75 100644 --- a/libs/cairo/cairo/src/cairo-rtree.c +++ b/libs/cairo/src/cairo-rtree.c diff --git a/libs/cairo/cairo/src/cairo-scaled-font-private.h b/libs/cairo/src/cairo-scaled-font-private.h index 5d426494a..5d426494a 100644 --- a/libs/cairo/cairo/src/cairo-scaled-font-private.h +++ b/libs/cairo/src/cairo-scaled-font-private.h diff --git a/libs/cairo/cairo/src/cairo-scaled-font-subsets-private.h b/libs/cairo/src/cairo-scaled-font-subsets-private.h index 246dbdcfd..246dbdcfd 100644 --- a/libs/cairo/cairo/src/cairo-scaled-font-subsets-private.h +++ b/libs/cairo/src/cairo-scaled-font-subsets-private.h diff --git a/libs/cairo/cairo/src/cairo-scaled-font-subsets.c b/libs/cairo/src/cairo-scaled-font-subsets.c index ba769d509..ba769d509 100644 --- a/libs/cairo/cairo/src/cairo-scaled-font-subsets.c +++ b/libs/cairo/src/cairo-scaled-font-subsets.c diff --git a/libs/cairo/cairo/src/cairo-scaled-font.c b/libs/cairo/src/cairo-scaled-font.c index 37806bc63..37806bc63 100644 --- a/libs/cairo/cairo/src/cairo-scaled-font.c +++ b/libs/cairo/src/cairo-scaled-font.c diff --git a/libs/cairo/cairo/src/cairo-script-surface.c b/libs/cairo/src/cairo-script-surface.c index 50214aa19..50214aa19 100644 --- a/libs/cairo/cairo/src/cairo-script-surface.c +++ b/libs/cairo/src/cairo-script-surface.c diff --git a/libs/cairo/cairo/src/cairo-script.h b/libs/cairo/src/cairo-script.h index a9d1540cf..a9d1540cf 100644 --- a/libs/cairo/cairo/src/cairo-script.h +++ b/libs/cairo/src/cairo-script.h diff --git a/libs/cairo/cairo/src/cairo-skia.h b/libs/cairo/src/cairo-skia.h index 89bd2713e..89bd2713e 100644 --- a/libs/cairo/cairo/src/cairo-skia.h +++ b/libs/cairo/src/cairo-skia.h diff --git a/libs/cairo/cairo/src/cairo-slope-private.h b/libs/cairo/src/cairo-slope-private.h index bccc955d3..bccc955d3 100644 --- a/libs/cairo/cairo/src/cairo-slope-private.h +++ b/libs/cairo/src/cairo-slope-private.h diff --git a/libs/cairo/cairo/src/cairo-slope.c b/libs/cairo/src/cairo-slope.c index fe93d66f6..fe93d66f6 100644 --- a/libs/cairo/cairo/src/cairo-slope.c +++ b/libs/cairo/src/cairo-slope.c diff --git a/libs/cairo/cairo/src/cairo-spans-private.h b/libs/cairo/src/cairo-spans-private.h index aecc9b976..aecc9b976 100644 --- a/libs/cairo/cairo/src/cairo-spans-private.h +++ b/libs/cairo/src/cairo-spans-private.h diff --git a/libs/cairo/cairo/src/cairo-spans.c b/libs/cairo/src/cairo-spans.c index f556d6b2a..f556d6b2a 100644 --- a/libs/cairo/cairo/src/cairo-spans.c +++ b/libs/cairo/src/cairo-spans.c diff --git a/libs/cairo/cairo/src/cairo-spline.c b/libs/cairo/src/cairo-spline.c index 2fc99dfcb..2fc99dfcb 100644 --- a/libs/cairo/cairo/src/cairo-spline.c +++ b/libs/cairo/src/cairo-spline.c diff --git a/libs/cairo/cairo/src/cairo-stroke-style.c b/libs/cairo/src/cairo-stroke-style.c index e068e9dec..e068e9dec 100644 --- a/libs/cairo/cairo/src/cairo-stroke-style.c +++ b/libs/cairo/src/cairo-stroke-style.c diff --git a/libs/cairo/cairo/src/cairo-supported-features.h b/libs/cairo/src/cairo-supported-features.h index aacbab781..aacbab781 100644 --- a/libs/cairo/cairo/src/cairo-supported-features.h +++ b/libs/cairo/src/cairo-supported-features.h diff --git a/libs/cairo/cairo/src/cairo-surface-clipper-private.h b/libs/cairo/src/cairo-surface-clipper-private.h index d8750e642..d8750e642 100644 --- a/libs/cairo/cairo/src/cairo-surface-clipper-private.h +++ b/libs/cairo/src/cairo-surface-clipper-private.h diff --git a/libs/cairo/cairo/src/cairo-surface-clipper.c b/libs/cairo/src/cairo-surface-clipper.c index 21c6fb1d5..21c6fb1d5 100644 --- a/libs/cairo/cairo/src/cairo-surface-clipper.c +++ b/libs/cairo/src/cairo-surface-clipper.c diff --git a/libs/cairo/cairo/src/cairo-surface-fallback-private.h b/libs/cairo/src/cairo-surface-fallback-private.h index 3c6324815..3c6324815 100644 --- a/libs/cairo/cairo/src/cairo-surface-fallback-private.h +++ b/libs/cairo/src/cairo-surface-fallback-private.h diff --git a/libs/cairo/cairo/src/cairo-surface-fallback.c b/libs/cairo/src/cairo-surface-fallback.c index 09ab644a7..09ab644a7 100644 --- a/libs/cairo/cairo/src/cairo-surface-fallback.c +++ b/libs/cairo/src/cairo-surface-fallback.c diff --git a/libs/cairo/cairo/src/cairo-surface-offset-private.h b/libs/cairo/src/cairo-surface-offset-private.h index 94525a689..94525a689 100644 --- a/libs/cairo/cairo/src/cairo-surface-offset-private.h +++ b/libs/cairo/src/cairo-surface-offset-private.h diff --git a/libs/cairo/cairo/src/cairo-surface-offset.c b/libs/cairo/src/cairo-surface-offset.c index a5070617d..a5070617d 100644 --- a/libs/cairo/cairo/src/cairo-surface-offset.c +++ b/libs/cairo/src/cairo-surface-offset.c diff --git a/libs/cairo/cairo/src/cairo-surface-private.h b/libs/cairo/src/cairo-surface-private.h index 96cd4a371..96cd4a371 100644 --- a/libs/cairo/cairo/src/cairo-surface-private.h +++ b/libs/cairo/src/cairo-surface-private.h diff --git a/libs/cairo/cairo/src/cairo-surface-snapshot-private.h b/libs/cairo/src/cairo-surface-snapshot-private.h index a9520332a..a9520332a 100644 --- a/libs/cairo/cairo/src/cairo-surface-snapshot-private.h +++ b/libs/cairo/src/cairo-surface-snapshot-private.h diff --git a/libs/cairo/cairo/src/cairo-surface-snapshot.c b/libs/cairo/src/cairo-surface-snapshot.c index 030636056..030636056 100644 --- a/libs/cairo/cairo/src/cairo-surface-snapshot.c +++ b/libs/cairo/src/cairo-surface-snapshot.c diff --git a/libs/cairo/cairo/src/cairo-surface-subsurface-private.h b/libs/cairo/src/cairo-surface-subsurface-private.h index 3fe48f83b..3fe48f83b 100644 --- a/libs/cairo/cairo/src/cairo-surface-subsurface-private.h +++ b/libs/cairo/src/cairo-surface-subsurface-private.h diff --git a/libs/cairo/cairo/src/cairo-surface-subsurface.c b/libs/cairo/src/cairo-surface-subsurface.c index b9d8eacd6..b9d8eacd6 100644 --- a/libs/cairo/cairo/src/cairo-surface-subsurface.c +++ b/libs/cairo/src/cairo-surface-subsurface.c diff --git a/libs/cairo/cairo/src/cairo-surface-wrapper-private.h b/libs/cairo/src/cairo-surface-wrapper-private.h index c6d2bbe91..c6d2bbe91 100644 --- a/libs/cairo/cairo/src/cairo-surface-wrapper-private.h +++ b/libs/cairo/src/cairo-surface-wrapper-private.h diff --git a/libs/cairo/cairo/src/cairo-surface-wrapper.c b/libs/cairo/src/cairo-surface-wrapper.c index 902e717cb..902e717cb 100644 --- a/libs/cairo/cairo/src/cairo-surface-wrapper.c +++ b/libs/cairo/src/cairo-surface-wrapper.c diff --git a/libs/cairo/cairo/src/cairo-surface.c b/libs/cairo/src/cairo-surface.c index c80ea8553..c80ea8553 100644 --- a/libs/cairo/cairo/src/cairo-surface.c +++ b/libs/cairo/src/cairo-surface.c diff --git a/libs/cairo/cairo/src/cairo-svg-surface-private.h b/libs/cairo/src/cairo-svg-surface-private.h index eea51cbbf..eea51cbbf 100644 --- a/libs/cairo/cairo/src/cairo-svg-surface-private.h +++ b/libs/cairo/src/cairo-svg-surface-private.h diff --git a/libs/cairo/cairo/src/cairo-svg-surface.c b/libs/cairo/src/cairo-svg-surface.c index b18527f0c..b18527f0c 100644 --- a/libs/cairo/cairo/src/cairo-svg-surface.c +++ b/libs/cairo/src/cairo-svg-surface.c diff --git a/libs/cairo/cairo/src/cairo-svg.h b/libs/cairo/src/cairo-svg.h index 2c07aeedf..2c07aeedf 100644 --- a/libs/cairo/cairo/src/cairo-svg.h +++ b/libs/cairo/src/cairo-svg.h diff --git a/libs/cairo/cairo/src/cairo-system.c b/libs/cairo/src/cairo-system.c index 22e4934c7..22e4934c7 100644 --- a/libs/cairo/cairo/src/cairo-system.c +++ b/libs/cairo/src/cairo-system.c diff --git a/libs/cairo/cairo/src/cairo-tee-surface-private.h b/libs/cairo/src/cairo-tee-surface-private.h index dd8aeda4d..dd8aeda4d 100644 --- a/libs/cairo/cairo/src/cairo-tee-surface-private.h +++ b/libs/cairo/src/cairo-tee-surface-private.h diff --git a/libs/cairo/cairo/src/cairo-tee-surface.c b/libs/cairo/src/cairo-tee-surface.c index 755a0b7ee..755a0b7ee 100644 --- a/libs/cairo/cairo/src/cairo-tee-surface.c +++ b/libs/cairo/src/cairo-tee-surface.c diff --git a/libs/cairo/cairo/src/cairo-tee.h b/libs/cairo/src/cairo-tee.h index c60cb5327..c60cb5327 100644 --- a/libs/cairo/cairo/src/cairo-tee.h +++ b/libs/cairo/src/cairo-tee.h diff --git a/libs/cairo/cairo/src/cairo-tor-scan-converter.c b/libs/cairo/src/cairo-tor-scan-converter.c index 0dc20fef5..0dc20fef5 100644 --- a/libs/cairo/cairo/src/cairo-tor-scan-converter.c +++ b/libs/cairo/src/cairo-tor-scan-converter.c diff --git a/libs/cairo/cairo/src/cairo-toy-font-face.c b/libs/cairo/src/cairo-toy-font-face.c index 92045ba3e..92045ba3e 100644 --- a/libs/cairo/cairo/src/cairo-toy-font-face.c +++ b/libs/cairo/src/cairo-toy-font-face.c diff --git a/libs/cairo/cairo/src/cairo-traps.c b/libs/cairo/src/cairo-traps.c index c3f1d2e35..c3f1d2e35 100644 --- a/libs/cairo/cairo/src/cairo-traps.c +++ b/libs/cairo/src/cairo-traps.c diff --git a/libs/cairo/cairo/src/cairo-truetype-subset-private.h b/libs/cairo/src/cairo-truetype-subset-private.h index fee112b97..fee112b97 100644 --- a/libs/cairo/cairo/src/cairo-truetype-subset-private.h +++ b/libs/cairo/src/cairo-truetype-subset-private.h diff --git a/libs/cairo/cairo/src/cairo-truetype-subset.c b/libs/cairo/src/cairo-truetype-subset.c index 219adbeb6..219adbeb6 100644 --- a/libs/cairo/cairo/src/cairo-truetype-subset.c +++ b/libs/cairo/src/cairo-truetype-subset.c diff --git a/libs/cairo/cairo/src/cairo-type1-fallback.c b/libs/cairo/src/cairo-type1-fallback.c index cc3a26966..cc3a26966 100644 --- a/libs/cairo/cairo/src/cairo-type1-fallback.c +++ b/libs/cairo/src/cairo-type1-fallback.c diff --git a/libs/cairo/cairo/src/cairo-type1-private.h b/libs/cairo/src/cairo-type1-private.h index 0634b7061..0634b7061 100644 --- a/libs/cairo/cairo/src/cairo-type1-private.h +++ b/libs/cairo/src/cairo-type1-private.h diff --git a/libs/cairo/cairo/src/cairo-type1-subset.c b/libs/cairo/src/cairo-type1-subset.c index 7abcb10cb..7abcb10cb 100644 --- a/libs/cairo/cairo/src/cairo-type1-subset.c +++ b/libs/cairo/src/cairo-type1-subset.c diff --git a/libs/cairo/cairo/src/cairo-type3-glyph-surface-private.h b/libs/cairo/src/cairo-type3-glyph-surface-private.h index b101431fc..b101431fc 100644 --- a/libs/cairo/cairo/src/cairo-type3-glyph-surface-private.h +++ b/libs/cairo/src/cairo-type3-glyph-surface-private.h diff --git a/libs/cairo/cairo/src/cairo-type3-glyph-surface.c b/libs/cairo/src/cairo-type3-glyph-surface.c index e0ad08032..e0ad08032 100644 --- a/libs/cairo/cairo/src/cairo-type3-glyph-surface.c +++ b/libs/cairo/src/cairo-type3-glyph-surface.c diff --git a/libs/cairo/cairo/src/cairo-types-private.h b/libs/cairo/src/cairo-types-private.h index 00b9269c7..00b9269c7 100644 --- a/libs/cairo/cairo/src/cairo-types-private.h +++ b/libs/cairo/src/cairo-types-private.h diff --git a/libs/cairo/cairo/src/cairo-unicode.c b/libs/cairo/src/cairo-unicode.c index 3a60ff611..3a60ff611 100644 --- a/libs/cairo/cairo/src/cairo-unicode.c +++ b/libs/cairo/src/cairo-unicode.c diff --git a/libs/cairo/cairo/src/cairo-user-font-private.h b/libs/cairo/src/cairo-user-font-private.h index c5995978f..c5995978f 100644 --- a/libs/cairo/cairo/src/cairo-user-font-private.h +++ b/libs/cairo/src/cairo-user-font-private.h diff --git a/libs/cairo/cairo/src/cairo-user-font.c b/libs/cairo/src/cairo-user-font.c index 9219a7301..9219a7301 100644 --- a/libs/cairo/cairo/src/cairo-user-font.c +++ b/libs/cairo/src/cairo-user-font.c diff --git a/libs/cairo/cairo/src/cairo-version.c b/libs/cairo/src/cairo-version.c index 5b7fa6827..5b7fa6827 100644 --- a/libs/cairo/cairo/src/cairo-version.c +++ b/libs/cairo/src/cairo-version.c diff --git a/libs/cairo/cairo/src/cairo-version.h b/libs/cairo/src/cairo-version.h index ace09244c..ace09244c 100644 --- a/libs/cairo/cairo/src/cairo-version.h +++ b/libs/cairo/src/cairo-version.h diff --git a/libs/cairo/cairo/src/cairo-vg-surface.c b/libs/cairo/src/cairo-vg-surface.c index 3a3d83e96..3a3d83e96 100644 --- a/libs/cairo/cairo/src/cairo-vg-surface.c +++ b/libs/cairo/src/cairo-vg-surface.c diff --git a/libs/cairo/cairo/src/cairo-vg.h b/libs/cairo/src/cairo-vg.h index 7f1097d04..7f1097d04 100644 --- a/libs/cairo/cairo/src/cairo-vg.h +++ b/libs/cairo/src/cairo-vg.h diff --git a/libs/cairo/cairo/src/cairo-wideint-private.h b/libs/cairo/src/cairo-wideint-private.h index a1ae4dce8..a1ae4dce8 100644 --- a/libs/cairo/cairo/src/cairo-wideint-private.h +++ b/libs/cairo/src/cairo-wideint-private.h diff --git a/libs/cairo/cairo/src/cairo-wideint-type-private.h b/libs/cairo/src/cairo-wideint-type-private.h index d7f0319a2..d7f0319a2 100644 --- a/libs/cairo/cairo/src/cairo-wideint-type-private.h +++ b/libs/cairo/src/cairo-wideint-type-private.h diff --git a/libs/cairo/cairo/src/cairo-wideint.c b/libs/cairo/src/cairo-wideint.c index 90809c005..90809c005 100644 --- a/libs/cairo/cairo/src/cairo-wideint.c +++ b/libs/cairo/src/cairo-wideint.c diff --git a/libs/cairo/cairo/src/cairo-win32-font.c b/libs/cairo/src/cairo-win32-font.c index ccdd16187..ccdd16187 100644 --- a/libs/cairo/cairo/src/cairo-win32-font.c +++ b/libs/cairo/src/cairo-win32-font.c diff --git a/libs/cairo/cairo/src/cairo-win32-printing-surface.c b/libs/cairo/src/cairo-win32-printing-surface.c index 56cf3242b..56cf3242b 100644 --- a/libs/cairo/cairo/src/cairo-win32-printing-surface.c +++ b/libs/cairo/src/cairo-win32-printing-surface.c diff --git a/libs/cairo/cairo/src/cairo-win32-private.h b/libs/cairo/src/cairo-win32-private.h index 571b7547c..571b7547c 100644 --- a/libs/cairo/cairo/src/cairo-win32-private.h +++ b/libs/cairo/src/cairo-win32-private.h diff --git a/libs/cairo/cairo/src/cairo-win32-refptr.h b/libs/cairo/src/cairo-win32-refptr.h index 8c0ec3338..8c0ec3338 100644 --- a/libs/cairo/cairo/src/cairo-win32-refptr.h +++ b/libs/cairo/src/cairo-win32-refptr.h diff --git a/libs/cairo/cairo/src/cairo-win32-surface.c b/libs/cairo/src/cairo-win32-surface.c index 2d7395590..2d7395590 100644 --- a/libs/cairo/cairo/src/cairo-win32-surface.c +++ b/libs/cairo/src/cairo-win32-surface.c diff --git a/libs/cairo/cairo/src/cairo-win32.h b/libs/cairo/src/cairo-win32.h index a1d45c19a..a1d45c19a 100644 --- a/libs/cairo/cairo/src/cairo-win32.h +++ b/libs/cairo/src/cairo-win32.h diff --git a/libs/cairo/cairo/src/cairo-xcb-surface.c b/libs/cairo/src/cairo-xcb-surface.c index 7f53e630f..7f53e630f 100644 --- a/libs/cairo/cairo/src/cairo-xcb-surface.c +++ b/libs/cairo/src/cairo-xcb-surface.c diff --git a/libs/cairo/cairo/src/cairo-xcb-xrender.h b/libs/cairo/src/cairo-xcb-xrender.h index ff81706c4..ff81706c4 100644 --- a/libs/cairo/cairo/src/cairo-xcb-xrender.h +++ b/libs/cairo/src/cairo-xcb-xrender.h diff --git a/libs/cairo/cairo/src/cairo-xcb.h b/libs/cairo/src/cairo-xcb.h index de72b4f04..de72b4f04 100644 --- a/libs/cairo/cairo/src/cairo-xcb.h +++ b/libs/cairo/src/cairo-xcb.h diff --git a/libs/cairo/cairo/src/cairo-xlib-display.c b/libs/cairo/src/cairo-xlib-display.c index 7967d6027..7967d6027 100644 --- a/libs/cairo/cairo/src/cairo-xlib-display.c +++ b/libs/cairo/src/cairo-xlib-display.c diff --git a/libs/cairo/cairo/src/cairo-xlib-private.h b/libs/cairo/src/cairo-xlib-private.h index e575b2704..e575b2704 100644 --- a/libs/cairo/cairo/src/cairo-xlib-private.h +++ b/libs/cairo/src/cairo-xlib-private.h diff --git a/libs/cairo/cairo/src/cairo-xlib-screen.c b/libs/cairo/src/cairo-xlib-screen.c index 9663ddb7b..9663ddb7b 100644 --- a/libs/cairo/cairo/src/cairo-xlib-screen.c +++ b/libs/cairo/src/cairo-xlib-screen.c diff --git a/libs/cairo/cairo/src/cairo-xlib-surface-private.h b/libs/cairo/src/cairo-xlib-surface-private.h index cd7e79d69..cd7e79d69 100644 --- a/libs/cairo/cairo/src/cairo-xlib-surface-private.h +++ b/libs/cairo/src/cairo-xlib-surface-private.h diff --git a/libs/cairo/cairo/src/cairo-xlib-surface.c b/libs/cairo/src/cairo-xlib-surface.c index 36b696eaa..36b696eaa 100644 --- a/libs/cairo/cairo/src/cairo-xlib-surface.c +++ b/libs/cairo/src/cairo-xlib-surface.c diff --git a/libs/cairo/cairo/src/cairo-xlib-visual.c b/libs/cairo/src/cairo-xlib-visual.c index f70db3a77..f70db3a77 100644 --- a/libs/cairo/cairo/src/cairo-xlib-visual.c +++ b/libs/cairo/src/cairo-xlib-visual.c diff --git a/libs/cairo/cairo/src/cairo-xlib-xrender-private.h b/libs/cairo/src/cairo-xlib-xrender-private.h index 6372787a0..6372787a0 100644 --- a/libs/cairo/cairo/src/cairo-xlib-xrender-private.h +++ b/libs/cairo/src/cairo-xlib-xrender-private.h diff --git a/libs/cairo/cairo/src/cairo-xlib-xrender.h b/libs/cairo/src/cairo-xlib-xrender.h index 996983e4e..996983e4e 100644 --- a/libs/cairo/cairo/src/cairo-xlib-xrender.h +++ b/libs/cairo/src/cairo-xlib-xrender.h diff --git a/libs/cairo/cairo/src/cairo-xlib.h b/libs/cairo/src/cairo-xlib.h index fdcff769c..fdcff769c 100644 --- a/libs/cairo/cairo/src/cairo-xlib.h +++ b/libs/cairo/src/cairo-xlib.h diff --git a/libs/cairo/cairo/src/cairo-xml-surface.c b/libs/cairo/src/cairo-xml-surface.c index f1c3c3ed6..f1c3c3ed6 100644 --- a/libs/cairo/cairo/src/cairo-xml-surface.c +++ b/libs/cairo/src/cairo-xml-surface.c diff --git a/libs/cairo/cairo/src/cairo-xml.h b/libs/cairo/src/cairo-xml.h index 0367076a3..0367076a3 100644 --- a/libs/cairo/cairo/src/cairo-xml.h +++ b/libs/cairo/src/cairo-xml.h diff --git a/libs/cairo/cairo/src/cairo.c b/libs/cairo/src/cairo.c index e4a90b57f..e4a90b57f 100644 --- a/libs/cairo/cairo/src/cairo.c +++ b/libs/cairo/src/cairo.c diff --git a/libs/cairo/cairo/src/cairo.h b/libs/cairo/src/cairo.h index 3a34e80bf..3a34e80bf 100644 --- a/libs/cairo/cairo/src/cairo.h +++ b/libs/cairo/src/cairo.h diff --git a/libs/cairo/cairo/src/cairoint.h b/libs/cairo/src/cairoint.h index 2f638f2d7..2f638f2d7 100644 --- a/libs/cairo/cairo/src/cairoint.h +++ b/libs/cairo/src/cairoint.h diff --git a/libs/cairo/cairo/src/check-has-hidden-symbols.c b/libs/cairo/src/check-has-hidden-symbols.c index 120412776..120412776 100644 --- a/libs/cairo/cairo/src/check-has-hidden-symbols.c +++ b/libs/cairo/src/check-has-hidden-symbols.c diff --git a/libs/cairo/cairo/src/check-link.c b/libs/cairo/src/check-link.c index 66ca1b241..66ca1b241 100644 --- a/libs/cairo/cairo/src/check-link.c +++ b/libs/cairo/src/check-link.c diff --git a/libs/cairo/cairo/src/filterpublic.awk b/libs/cairo/src/filterpublic.awk index 98846102b..98846102b 100644 --- a/libs/cairo/cairo/src/filterpublic.awk +++ b/libs/cairo/src/filterpublic.awk diff --git a/libs/cairo/cairo/src/pixman-rename.h b/libs/cairo/src/pixman-rename.h index 431cd92e9..431cd92e9 100644 --- a/libs/cairo/cairo/src/pixman-rename.h +++ b/libs/cairo/src/pixman-rename.h diff --git a/libs/cairo/cairo/src/test-fallback-surface.c b/libs/cairo/src/test-fallback-surface.c index ff07bc81e..ff07bc81e 100644 --- a/libs/cairo/cairo/src/test-fallback-surface.c +++ b/libs/cairo/src/test-fallback-surface.c diff --git a/libs/cairo/cairo/src/test-fallback-surface.h b/libs/cairo/src/test-fallback-surface.h index c2534c184..c2534c184 100644 --- a/libs/cairo/cairo/src/test-fallback-surface.h +++ b/libs/cairo/src/test-fallback-surface.h diff --git a/libs/cairo/cairo/src/test-meta-surface.c b/libs/cairo/src/test-meta-surface.c index 305174eb5..305174eb5 100644 --- a/libs/cairo/cairo/src/test-meta-surface.c +++ b/libs/cairo/src/test-meta-surface.c diff --git a/libs/cairo/cairo/src/test-meta-surface.h b/libs/cairo/src/test-meta-surface.h index 78b7a5752..78b7a5752 100644 --- a/libs/cairo/cairo/src/test-meta-surface.h +++ b/libs/cairo/src/test-meta-surface.h diff --git a/libs/cairo/cairo/src/test-paginated-surface.c b/libs/cairo/src/test-paginated-surface.c index 5d09308f4..5d09308f4 100644 --- a/libs/cairo/cairo/src/test-paginated-surface.c +++ b/libs/cairo/src/test-paginated-surface.c diff --git a/libs/cairo/cairo/src/test-paginated-surface.h b/libs/cairo/src/test-paginated-surface.h index 5f2d1d593..5f2d1d593 100644 --- a/libs/cairo/cairo/src/test-paginated-surface.h +++ b/libs/cairo/src/test-paginated-surface.h diff --git a/libs/libpixman/moz.build b/libs/libpixman/moz.build index f8f60a5e1..2cdffd8cd 100644 --- a/libs/libpixman/moz.build +++ b/libs/libpixman/moz.build @@ -60,9 +60,7 @@ SOURCES += [ ALLOW_COMPILER_WARNINGS = True FINAL_LIBRARY = 'gkmedias' -LOCAL_INCLUDES += [ - '../cairo/cairo/src', -] +LOCAL_INCLUDES += ['../cairo/src'] if CONFIG['MOZ_USE_PTHREADS']: DEFINES['HAVE_PTHREADS'] = True diff --git a/old-configure.in b/old-configure.in index 3e0a377a4..407ea75bb 100644 --- a/old-configure.in +++ b/old-configure.in @@ -4423,7 +4423,7 @@ if test "$MOZ_TREE_CAIRO"; then MOZ_CAIRO_OSLIBS="$MOZ_CAIRO_OSLIBS $XLDFLAGS -lXrender" fi - CAIRO_FEATURES_H=libs/cairo/cairo/src/cairo-features.h + CAIRO_FEATURES_H=libs/cairo/src/cairo-features.h else PKG_CHECK_MODULES(CAIRO, cairo >= $CAIRO_VERSION) MOZ_CAIRO_CFLAGS="$CAIRO_CFLAGS" |