summaryrefslogtreecommitdiffstats
path: root/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'gfx')
-rw-r--r--gfx/cairo/README256
-rw-r--r--gfx/cairo/add-a-stash-of-cairo_t-s.patch75
-rw-r--r--gfx/cairo/avoid-extend-none.patch39
-rw-r--r--gfx/cairo/bgr.patch104
-rw-r--r--gfx/cairo/buggy-repeat.patch39
-rw-r--r--gfx/cairo/cache-size.patch19
-rw-r--r--gfx/cairo/cairo-clamp-boundary.patch71
-rw-r--r--gfx/cairo/cairo-mask-extends-bug.patch41
-rw-r--r--gfx/cairo/cairo-qt-compile.patch21
-rw-r--r--gfx/cairo/cairo-region-clip.patch34
-rw-r--r--gfx/cairo/cairo-version-fixes.patch26
-rw-r--r--gfx/cairo/cairo-x-visual.patch160
-rw-r--r--gfx/cairo/cairo/COPYING24
-rw-r--r--gfx/cairo/cairo/COPYING-LGPL-2.1510
-rw-r--r--gfx/cairo/cairo/COPYING-MPL-1.1470
-rw-r--r--gfx/cairo/cairo/INSTALL187
-rw-r--r--gfx/cairo/cairo/NEWS5121
-rw-r--r--gfx/cairo/cairo/README5
-rw-r--r--gfx/cairo/cairo/src/cairo-analysis-surface-private.h36
-rw-r--r--gfx/cairo/cairo/src/cairo-analysis-surface.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-arc-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-arc.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-array.c39
-rw-r--r--gfx/cairo/cairo/src/cairo-atomic-private.h40
-rw-r--r--gfx/cairo/cairo/src/cairo-atomic.c35
-rw-r--r--gfx/cairo/cairo/src/cairo-base64-stream.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-base85-stream.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-bentley-ottmann-rectangular.c39
-rw-r--r--gfx/cairo/cairo/src/cairo-bentley-ottmann-rectilinear.c39
-rw-r--r--gfx/cairo/cairo/src/cairo-bentley-ottmann.c39
-rw-r--r--gfx/cairo/cairo/src/cairo-beos-surface.cpp38
-rw-r--r--gfx/cairo/cairo/src/cairo-beos.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-botor-scan-converter.c43
-rw-r--r--gfx/cairo/cairo/src/cairo-boxes-private.h35
-rw-r--r--gfx/cairo/cairo/src/cairo-boxes.c35
-rw-r--r--gfx/cairo/cairo/src/cairo-cache-private.h40
-rw-r--r--gfx/cairo/cairo/src/cairo-cache.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-cff-subset.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-clip-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-clip.c43
-rw-r--r--gfx/cairo/cairo/src/cairo-color.c39
-rw-r--r--gfx/cairo/cairo/src/cairo-combsort-private.h36
-rw-r--r--gfx/cairo/cairo/src/cairo-compiler-private.h39
-rw-r--r--gfx/cairo/cairo/src/cairo-composite-rectangles-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-composite-rectangles.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-d2d-private.h39
-rw-r--r--gfx/cairo/cairo/src/cairo-d2d-surface.cpp39
-rw-r--r--gfx/cairo/cairo/src/cairo-debug.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-deflate-stream.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-deprecated.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-device-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-device.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-directfb-surface.c39
-rw-r--r--gfx/cairo/cairo/src/cairo-directfb.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-drm.h34
-rw-r--r--gfx/cairo/cairo/src/cairo-dwrite-font.cpp38
-rw-r--r--gfx/cairo/cairo/src/cairo-dwrite-private.h39
-rw-r--r--gfx/cairo/cairo/src/cairo-eagle-context.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-error-private.h39
-rw-r--r--gfx/cairo/cairo/src/cairo-features.h.in42
-rw-r--r--gfx/cairo/cairo/src/cairo-fixed-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-fixed-type-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-fixed.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-font-face-twin.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-font-face.c42
-rw-r--r--gfx/cairo/cairo/src/cairo-font-options.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-fontconfig-private.h43
-rw-r--r--gfx/cairo/cairo/src/cairo-freed-pool-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-freed-pool.c39
-rw-r--r--gfx/cairo/cairo/src/cairo-ft-font.c42
-rw-r--r--gfx/cairo/cairo/src/cairo-ft-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-ft.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-gl-glyphs.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-gl-private.h43
-rw-r--r--gfx/cairo/cairo/src/cairo-gl-shaders.c41
-rw-r--r--gfx/cairo/cairo/src/cairo-gl-surface.c42
-rw-r--r--gfx/cairo/cairo/src/cairo-gl.h35
-rw-r--r--gfx/cairo/cairo/src/cairo-glitz-private.h34
-rw-r--r--gfx/cairo/cairo/src/cairo-glitz-surface.c28
-rw-r--r--gfx/cairo/cairo/src/cairo-glitz.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-glx-context.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-gstate-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-gstate.c39
-rw-r--r--gfx/cairo/cairo/src/cairo-hash-private.h40
-rw-r--r--gfx/cairo/cairo/src/cairo-hash.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-hull.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-image-info-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-image-info.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-image-surface.c41
-rw-r--r--gfx/cairo/cairo/src/cairo-list-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-lzw.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-malloc-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-matrix.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-meta-surface-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-misc.c42
-rw-r--r--gfx/cairo/cairo/src/cairo-mutex-impl-private.h47
-rw-r--r--gfx/cairo/cairo/src/cairo-mutex-list-private.h35
-rw-r--r--gfx/cairo/cairo/src/cairo-mutex-private.h42
-rw-r--r--gfx/cairo/cairo/src/cairo-mutex-type-private.h42
-rw-r--r--gfx/cairo/cairo/src/cairo-mutex.c35
-rw-r--r--gfx/cairo/cairo/src/cairo-observer.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-os2-private.h39
-rw-r--r--gfx/cairo/cairo/src/cairo-os2-surface.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-os2.h40
-rw-r--r--gfx/cairo/cairo/src/cairo-output-stream-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-output-stream.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-paginated-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-paginated-surface-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-paginated-surface.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-path-bounds.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-path-fill.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-path-fixed-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-path-fixed.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-path-in-fill.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-path-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-path-stroke.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-path.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-pattern.c32
-rw-r--r--gfx/cairo/cairo/src/cairo-pdf-operators-private.h43
-rw-r--r--gfx/cairo/cairo/src/cairo-pdf-operators.c43
-rw-r--r--gfx/cairo/cairo/src/cairo-pdf-surface-private.h43
-rw-r--r--gfx/cairo/cairo/src/cairo-pdf-surface.c43
-rw-r--r--gfx/cairo/cairo/src/cairo-pdf.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-pen.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-platform.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-png.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-polygon.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-ps-surface-private.h42
-rw-r--r--gfx/cairo/cairo/src/cairo-ps-surface.c45
-rw-r--r--gfx/cairo/cairo/src/cairo-ps.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-qt-surface.cpp38
-rw-r--r--gfx/cairo/cairo/src/cairo-qt.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-quartz-font.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-quartz-image-surface.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-quartz-image.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-quartz-private.h39
-rw-r--r--gfx/cairo/cairo/src/cairo-quartz-surface.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-quartz.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-recording-surface-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-recording-surface.c41
-rw-r--r--gfx/cairo/cairo/src/cairo-rectangle.c41
-rw-r--r--gfx/cairo/cairo/src/cairo-rectangular-scan-converter.c35
-rw-r--r--gfx/cairo/cairo/src/cairo-reference-count-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-region-private.h40
-rw-r--r--gfx/cairo/cairo/src/cairo-region.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-rtree-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-rtree.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-scaled-font-private.h39
-rw-r--r--gfx/cairo/cairo/src/cairo-scaled-font-subsets-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-scaled-font-subsets.c44
-rw-r--r--gfx/cairo/cairo/src/cairo-scaled-font.c42
-rw-r--r--gfx/cairo/cairo/src/cairo-script-surface.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-script.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-skia.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-slope-private.h39
-rw-r--r--gfx/cairo/cairo/src/cairo-slope.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-spans-private.h1
-rw-r--r--gfx/cairo/cairo/src/cairo-spans.c1
-rw-r--r--gfx/cairo/cairo/src/cairo-spline.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-stroke-style.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-clipper-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-clipper.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-fallback-private.h40
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-fallback.c42
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-offset-private.h40
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-offset.c39
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-private.h39
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-snapshot-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-snapshot.c41
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-subsurface-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-subsurface.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-wrapper-private.h40
-rw-r--r--gfx/cairo/cairo/src/cairo-surface-wrapper.c39
-rw-r--r--gfx/cairo/cairo/src/cairo-surface.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-svg-surface-private.h42
-rw-r--r--gfx/cairo/cairo/src/cairo-svg-surface.c43
-rw-r--r--gfx/cairo/cairo/src/cairo-svg.h33
-rw-r--r--gfx/cairo/cairo/src/cairo-system.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-tee-surface-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-tee-surface.c39
-rw-r--r--gfx/cairo/cairo/src/cairo-tee.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-tor-scan-converter.c3
-rw-r--r--gfx/cairo/cairo/src/cairo-toy-font-face.c43
-rw-r--r--gfx/cairo/cairo/src/cairo-traps.c41
-rw-r--r--gfx/cairo/cairo/src/cairo-truetype-subset-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-truetype-subset.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-type1-fallback.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-type1-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-type1-subset.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-type3-glyph-surface-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-type3-glyph-surface.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-types-private.h40
-rw-r--r--gfx/cairo/cairo/src/cairo-unicode.c44
-rw-r--r--gfx/cairo/cairo/src/cairo-user-font-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-user-font.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-version.c40
-rw-r--r--gfx/cairo/cairo/src/cairo-vg-surface.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-vg.h40
-rw-r--r--gfx/cairo/cairo/src/cairo-wideint-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-wideint-type-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-wideint.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-win32-font.c65
-rw-r--r--gfx/cairo/cairo/src/cairo-win32-printing-surface.c53
-rw-r--r--gfx/cairo/cairo/src/cairo-win32-private.h37
-rw-r--r--gfx/cairo/cairo/src/cairo-win32-refptr.h39
-rw-r--r--gfx/cairo/cairo/src/cairo-win32-surface.c72
-rw-r--r--gfx/cairo/cairo/src/cairo-win32.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-xcb-surface.c42
-rw-r--r--gfx/cairo/cairo/src/cairo-xcb-xrender.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-xcb.h40
-rw-r--r--gfx/cairo/cairo/src/cairo-xlib-display.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-xlib-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-xlib-screen.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-xlib-surface-private.h34
-rw-r--r--gfx/cairo/cairo/src/cairo-xlib-surface.c43
-rw-r--r--gfx/cairo/cairo/src/cairo-xlib-visual.c37
-rw-r--r--gfx/cairo/cairo/src/cairo-xlib-xrender-private.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-xlib-xrender.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-xlib.h38
-rw-r--r--gfx/cairo/cairo/src/cairo-xml-surface.c38
-rw-r--r--gfx/cairo/cairo/src/cairo-xml.h37
-rw-r--r--gfx/cairo/cairo/src/cairo.c40
-rw-r--r--gfx/cairo/cairo/src/cairo.h39
-rw-r--r--gfx/cairo/cairo/src/cairoint.h39
-rw-r--r--gfx/cairo/cairo/src/test-fallback-surface.c37
-rw-r--r--gfx/cairo/cairo/src/test-fallback-surface.h37
-rw-r--r--gfx/cairo/cairo/src/test-meta-surface.c37
-rw-r--r--gfx/cairo/cairo/src/test-meta-surface.h37
-rw-r--r--gfx/cairo/cairo/src/test-paginated-surface.c37
-rw-r--r--gfx/cairo/cairo/src/test-paginated-surface.h37
-rw-r--r--gfx/cairo/cairo_qt_a8_fallback.diff68
-rw-r--r--gfx/cairo/cairo_qt_glyphs.patch256
-rw-r--r--gfx/cairo/clip-invariant.patch1255
-rw-r--r--gfx/cairo/clip-rects-surface-extents.patch163
-rw-r--r--gfx/cairo/copyarea-with-alpha.patch110
-rw-r--r--gfx/cairo/d2d-gradient-ensure-stops.patch32
-rw-r--r--gfx/cairo/d2d-repeating-gradients.patch271
-rw-r--r--gfx/cairo/d2d.patch465
-rw-r--r--gfx/cairo/dasharray-zero-gap.patch60
-rw-r--r--gfx/cairo/disable-previous-scaled-font-cache.patch16
-rw-r--r--gfx/cairo/disable-printing.patch27
-rw-r--r--gfx/cairo/disable-server-gradients.patch21
-rw-r--r--gfx/cairo/disable-subpixel-antialiasing.patch519
-rw-r--r--gfx/cairo/dwrite-font-match-robustness.patch26
-rw-r--r--gfx/cairo/dwrite-font-printing.patch157
-rw-r--r--gfx/cairo/dwrite-glyph-extents.patch44
-rw-r--r--gfx/cairo/empty-clip-extents.patch59
-rw-r--r--gfx/cairo/empty-clip-rectangles.patch28
-rw-r--r--gfx/cairo/ensure-text-flushed.patch16
-rw-r--r--gfx/cairo/expose-snapshot.patch528
-rw-r--r--gfx/cairo/fix-build-with-Werror=return-type.patch21
-rw-r--r--gfx/cairo/fix-cairo-surface-wrapper-flush-build-warning.patch19
-rw-r--r--gfx/cairo/fix-cairo-win32-print-gdi-error.diff26
-rw-r--r--gfx/cairo/fix-clip-copy.patch30
-rw-r--r--gfx/cairo/fix-clip-region-simplification.patch1
-rw-r--r--gfx/cairo/fix-clip-test.patch15
-rw-r--r--gfx/cairo/fix-ps-output.patch19
-rw-r--r--gfx/cairo/fix-unnecessary-fallback.patch14
-rw-r--r--gfx/cairo/fix-win32-font-assertion.patch27
-rw-r--r--gfx/cairo/fix-win32-show-glyphs-clipping.patch19
-rw-r--r--gfx/cairo/fix-xcopyarea-with-clips.patch38
-rw-r--r--gfx/cairo/fix-zero-length-gradient.patch1
-rw-r--r--gfx/cairo/fixup-unbounded.patch22
-rw-r--r--gfx/cairo/ft-no-subpixel-if-surface-disables.patch46
-rw-r--r--gfx/cairo/gdi-RGB24-ARGB32.patch141
-rw-r--r--gfx/cairo/handle-a1.patch25
-rw-r--r--gfx/cairo/handle-multi-path-clip.patch57
-rw-r--r--gfx/cairo/ignore-rank0.patch20
-rw-r--r--gfx/cairo/libpixman/AUTHORS18
-rw-r--r--gfx/cairo/libpixman/COPYING37
-rw-r--r--gfx/cairo/lround-c99-only.patch46
-rw-r--r--gfx/cairo/max-font-size.patch28
-rw-r--r--gfx/cairo/missing-cairo-clip-init.diff21
-rw-r--r--gfx/cairo/native-clipping.patch189
-rw-r--r--gfx/cairo/no-pixman-image-reuse-across-threads.patch242
-rw-r--r--gfx/cairo/nonfatal-assertions.patch17
-rw-r--r--gfx/cairo/on-edge.patch70
-rw-r--r--gfx/cairo/pattern_get_surface-no-error.patch29
-rw-r--r--gfx/cairo/pixman-16-bit-pipeline.patch1242
-rw-r--r--gfx/cairo/pixman-8888-over-565.patch712
-rw-r--r--gfx/cairo/pixman-android-cpu-detect.patch29
-rw-r--r--gfx/cairo/pixman-bilinear-fastpath.patch287
-rw-r--r--gfx/cairo/pixman-component-alpha.patch34
-rw-r--r--gfx/cairo/pixman-dither.patch310
-rw-r--r--gfx/cairo/pixman-enable-altivec-acceleration.patch38
-rw-r--r--gfx/cairo/pixman-export.patch37
-rw-r--r--gfx/cairo/pixman-image-transform.patch52
-rw-r--r--gfx/cairo/pixman-limits.patch18
-rw-r--r--gfx/cairo/pixman-lowres-interp.patch222
-rw-r--r--gfx/cairo/pixman-rename-and-endian.patch22
-rw-r--r--gfx/cairo/pixman-xp-dll-workaround27
-rw-r--r--gfx/cairo/premultiply-alpha-solid-gradients.patch46
-rw-r--r--gfx/cairo/quartz-cache-CGImageRef.patch173
-rw-r--r--gfx/cairo/quartz-cg-layers-fix-fallback.patch42
-rw-r--r--gfx/cairo/quartz-cglayers.patch715
-rw-r--r--gfx/cairo/quartz-check-imageSurfaceEquiv.patch36
-rw-r--r--gfx/cairo/quartz-const-globals.patch134
-rw-r--r--gfx/cairo/quartz-create-for-data.patch309
-rw-r--r--gfx/cairo/quartz-fallback.patch70
-rw-r--r--gfx/cairo/quartz-first-stop.patch57
-rw-r--r--gfx/cairo/quartz-fix-PAD.patch64
-rw-r--r--gfx/cairo/quartz-get-image-performance.patch43
-rw-r--r--gfx/cairo/quartz-get-image.patch127
-rw-r--r--gfx/cairo/quartz-glyph-extents.patch19
-rw-r--r--gfx/cairo/quartz-is-clear.patch28
-rw-r--r--gfx/cairo/quartz-layers-content.patch125
-rw-r--r--gfx/cairo/quartz-mark-dirty.patch56
-rw-r--r--gfx/cairo/quartz-mask-non-OVER.patch80
-rw-r--r--gfx/cairo/quartz-minimize-gradient-repeat.patch561
-rw-r--r--gfx/cairo/quartz-optimize-OVER.patch71
-rw-r--r--gfx/cairo/quartz-refactor-surface-setup.patch290
-rw-r--r--gfx/cairo/quartz-remove-snapshot.patch62
-rw-r--r--gfx/cairo/quartz-repeating-radial-gradients.patch305
-rw-r--r--gfx/cairo/quartz-state.patch1190
-rw-r--r--gfx/cairo/quartz-support-color-emoji-font.patch432
-rw-r--r--gfx/cairo/quartz-surface-mask-patch79
-rw-r--r--gfx/cairo/setlcdfilter_in_tree.patch30
-rw-r--r--gfx/cairo/support-new-style-atomic-primitives.patch121
-rw-r--r--gfx/cairo/surface-clipper.patch26
-rw-r--r--gfx/cairo/tee-surfaces-pointwise.patch278
-rw-r--r--gfx/cairo/text-path-filling-threshold.patch90
-rw-r--r--gfx/cairo/unicode-printing.patch333
-rw-r--r--gfx/cairo/use-show-text-glyphs-if-glyph-path-fails.patch42
-rw-r--r--gfx/cairo/win32-ExtCreatePen-zero-size.patch85
-rw-r--r--gfx/cairo/win32-avoid-extend-pad-fallback.patch109
-rw-r--r--gfx/cairo/win32-canvas-glyph-position.patch31
-rw-r--r--gfx/cairo/win32-cleartype-clipping.patch23
-rw-r--r--gfx/cairo/win32-composite-src-mod.patch44
-rw-r--r--gfx/cairo/win32-d3dsurface9.patch465
-rw-r--r--gfx/cairo/win32-ddb-dib.patch181
-rw-r--r--gfx/cairo/win32-ffs-gcc.patch25
-rw-r--r--gfx/cairo/win32-gdi-font-cache-no-HFONT.patch145
-rw-r--r--gfx/cairo/win32-gdi-font-cache.patch375
-rw-r--r--gfx/cairo/win32-inline-cpp-keyword.patch24
-rw-r--r--gfx/cairo/win32-logical-font-scale.patch12
-rw-r--r--gfx/cairo/win32-printing-axis-swap.patch292
-rw-r--r--gfx/cairo/win32-raster.patch262
-rw-r--r--gfx/cairo/win32-transparent-surface.patch129
-rw-r--r--gfx/cairo/win32-vertically-offset-glyph.patch23
-rw-r--r--gfx/cairo/wrap-source_image.patch105
-rw-r--r--gfx/cairo/xlib-flush-glyphs.patch66
-rw-r--r--gfx/cairo/xlib-glyph-clip-region.patch40
-rw-r--r--gfx/cairo/xlib-initialize-members.patch19
-rw-r--r--gfx/cairo/zero-sized.patch39
-rw-r--r--gfx/cairo/zombie-face.patch119
-rw-r--r--gfx/ots/LICENSE54
-rw-r--r--gfx/ots/README.mozilla5
-rw-r--r--gfx/ots/include/opentype-sanitiser.h36
-rw-r--r--gfx/ots/include/ots-memory-stream.h2
-rw-r--r--gfx/ots/ots-lz4.patch74
-rw-r--r--gfx/ots/ots-visibility.patch19
-rw-r--r--gfx/ots/src/avar.cc109
-rw-r--r--gfx/ots/src/avar.h42
-rw-r--r--gfx/ots/src/cff.cc1375
-rw-r--r--gfx/ots/src/cff.h61
-rw-r--r--gfx/ots/src/cff_charstring.cc (renamed from gfx/ots/src/cff_type2_charstring.cc)392
-rw-r--r--gfx/ots/src/cff_charstring.h (renamed from gfx/ots/src/cff_type2_charstring.h)18
-rw-r--r--gfx/ots/src/cmap.cc342
-rw-r--r--gfx/ots/src/cmap.h21
-rw-r--r--gfx/ots/src/cvar.cc56
-rw-r--r--gfx/ots/src/cvar.h31
-rw-r--r--gfx/ots/src/cvt.cc47
-rw-r--r--gfx/ots/src/cvt.h13
-rw-r--r--gfx/ots/src/feat.cc193
-rw-r--r--gfx/ots/src/feat.h61
-rw-r--r--gfx/ots/src/fpgm.cc43
-rw-r--r--gfx/ots/src/fpgm.h13
-rw-r--r--gfx/ots/src/fvar.cc164
-rw-r--r--gfx/ots/src/fvar.h63
-rw-r--r--gfx/ots/src/gasp.cc85
-rw-r--r--gfx/ots/src/gasp.h12
-rw-r--r--gfx/ots/src/gdef.cc269
-rw-r--r--gfx/ots/src/gdef.h34
-rw-r--r--gfx/ots/src/glat.cc459
-rw-r--r--gfx/ots/src/glat.h172
-rw-r--r--gfx/ots/src/gloc.cc108
-rw-r--r--gfx/ots/src/gloc.h36
-rw-r--r--gfx/ots/src/glyf.cc328
-rw-r--r--gfx/ots/src/glyf.h22
-rw-r--r--gfx/ots/src/gpos.cc277
-rw-r--r--gfx/ots/src/gpos.h22
-rw-r--r--gfx/ots/src/graphite.h96
-rw-r--r--gfx/ots/src/gsub.cc209
-rw-r--r--gfx/ots/src/gsub.h22
-rw-r--r--gfx/ots/src/gvar.cc158
-rw-r--r--gfx/ots/src/gvar.h31
-rw-r--r--gfx/ots/src/hdmx.cc125
-rw-r--r--gfx/ots/src/hdmx.h13
-rw-r--r--gfx/ots/src/head.cc139
-rw-r--r--gfx/ots/src/head.h13
-rw-r--r--gfx/ots/src/hhea.cc44
-rw-r--r--gfx/ots/src/hhea.h11
-rw-r--r--gfx/ots/src/hmtx.cc43
-rw-r--r--gfx/ots/src/hmtx.h12
-rw-r--r--gfx/ots/src/hvar.cc85
-rw-r--r--gfx/ots/src/hvar.h31
-rw-r--r--gfx/ots/src/kern.cc131
-rw-r--r--gfx/ots/src/kern.h13
-rw-r--r--gfx/ots/src/layout.cc249
-rw-r--r--gfx/ots/src/layout.h21
-rw-r--r--gfx/ots/src/loca.cc72
-rw-r--r--gfx/ots/src/loca.h11
-rw-r--r--gfx/ots/src/ltsh.cc78
-rw-r--r--gfx/ots/src/ltsh.h13
-rw-r--r--gfx/ots/src/math.cc209
-rw-r--r--gfx/ots/src/math_.h60
-rw-r--r--gfx/ots/src/maxp.cc128
-rw-r--r--gfx/ots/src/maxp.h11
-rw-r--r--gfx/ots/src/metrics.cc180
-rw-r--r--gfx/ots/src/metrics.h40
-rw-r--r--gfx/ots/src/moz.build47
-rw-r--r--gfx/ots/src/mvar.cc105
-rw-r--r--gfx/ots/src/mvar.h31
-rw-r--r--gfx/ots/src/name.cc150
-rw-r--r--gfx/ots/src/name.h15
-rw-r--r--gfx/ots/src/os2.cc384
-rw-r--r--gfx/ots/src/os2.h15
-rw-r--r--gfx/ots/src/ots.cc628
-rw-r--r--gfx/ots/src/ots.h220
-rw-r--r--gfx/ots/src/post.cc145
-rw-r--r--gfx/ots/src/post.h12
-rw-r--r--gfx/ots/src/prep.cc44
-rw-r--r--gfx/ots/src/prep.h17
-rw-r--r--gfx/ots/src/sile.cc74
-rw-r--r--gfx/ots/src/sile.h36
-rw-r--r--gfx/ots/src/silf.cc977
-rw-r--r--gfx/ots/src/silf.h196
-rw-r--r--gfx/ots/src/sill.cc159
-rw-r--r--gfx/ots/src/sill.h53
-rw-r--r--gfx/ots/src/stat.cc347
-rw-r--r--gfx/ots/src/stat.h155
-rw-r--r--gfx/ots/src/variations.cc261
-rw-r--r--gfx/ots/src/variations.h26
-rw-r--r--gfx/ots/src/vdmx.cc125
-rw-r--r--gfx/ots/src/vdmx.h13
-rw-r--r--gfx/ots/src/vhea.cc49
-rw-r--r--gfx/ots/src/vhea.h12
-rw-r--r--gfx/ots/src/vmtx.cc46
-rw-r--r--gfx/ots/src/vmtx.h13
-rw-r--r--gfx/ots/src/vorg.cc82
-rw-r--r--gfx/ots/src/vorg.h13
-rw-r--r--gfx/ots/src/vvar.cc95
-rw-r--r--gfx/ots/src/vvar.h31
-rwxr-xr-xgfx/ots/sync.sh11
-rw-r--r--gfx/ots/tests/cff_charstring_test.cc1588
-rw-r--r--gfx/ots/tests/layout_common_table_test.cc770
-rw-r--r--gfx/thebes/gfxUserFontSet.cpp11
448 files changed, 11705 insertions, 34985 deletions
diff --git a/gfx/cairo/README b/gfx/cairo/README
deleted file mode 100644
index 91e2d1982..000000000
--- a/gfx/cairo/README
+++ /dev/null
@@ -1,256 +0,0 @@
-Snapshots of cairo and glitz for mozilla usage.
-
-We only include the relevant parts of each release (generally, src/*.[ch]),
-as we have Makefile.in's that integrate into the Mozilla build system. For
-documentation and similar, please see the official tarballs at
-http://www.cairographics.org/.
-
-VERSIONS:
-
- cairo (12d521df8acc483b2daa844d4f05dc2fe2765ba6)
- pixman (0.24.2)
-
-==== Patches ====
-
-Some specific things:
-
-max-font-size.patch: Clamp freetype font size to 1000 to avoid overflow issues
-
-win32-logical-font-scale.patch: set CAIRO_WIN32_LOGICAL_FONT_SCALE to 1
-
-nonfatal-assertions.patch: Make assertions non-fatal
-
-buggy-repeat.patch: Unconditionally turn on buggy-repeat handling to bandaid bug 413583.
-
-cairo-version-fixes.patch: fix up cairo-version.c/cairo-version.h for in-place builds
-
-win32-ddb-dib.patch: fix for bug 455513; not upstream yet pending feebdack
-
-win32-vertically-offset-glyph.patch: bug 454098; vertical positioning errors when drawing glyph runs including delta-y offsets on screen via GDI
-
-ignore-rank0.patch: bug 474886; Not redrawing the background when changing page on flickr
-
-win32-canvas-glyph-position.patch: bug 475092; horizontal positioning errors when drawing glyph runs with delta-y offsets to canvas through win32-font
-
-win32-cleartype-clipping.patch: bug 445087; some glyphs are clipped, mainly on right-hand edge, when ClearType is enabled and drawing to RGBA canvas
-
-on-edge.patch: reverts the in-fill semantic change.
-
-wrap-source_image.patch: make sure we don't free the source image until we're done with it.
-
-zero-sized.patch: deal with zero sized surface in ways less likely to crash.
-
-text-path-filling-threshold.patch: use path filling instead of platform glyph rasterization at a smaller size threshold of 256 device pixels, if the backend supports native filling (which we assume will be fast).
-
-zombie-face.patch: bug 486974; leak and possible crash with @font-face{src:url()}. Upstream commit: 0238fe2cafea2e1ed19bb222117bd73ee6898d4d
-
-win32-raster.patch: bug 498689; use scanline rasterizer on win32
-
-quartz-falback.patch: try to fix Quartz fallback-to-pixman path; possiby incorrect and obsoleted by Andrea Canciani patch
-
-quartz-repeating-radial-gradients.patch: use Quartz to render repeating radial gradients instead of falling back
-
-quartz-const-globals.patch: make some Quartz color function data const globals instead of local variables
-
-quartz-minimze-gradient-repeat.patch: reduce the number of gradient stop repetitions we use, to improve quality of Quartz's gradient rendering
-
-quartz-first-stop.patch: return the first stop for negative positions on the gradient line of a nonrepeating linear gradient
-
-quartz-glyph-extents.patch: bug 534260; work around incorrect glyph extents returned by quartz for anomalous empty glyphs
-
-quartz-state.patch: bug 522859; refactor cairo-quartz-surface so that state local to a drawing operation is stored in a cairo_quartz_drawing_state_t instead of the surface
-
-quartz-cache-CGImageRef.patch: cache CGImageRef for a CGBitmapContext; when we reuse it, Quartz will cache stuff, improving performance
-
-quartz-remove-snapshot.patch: remove broken implementation of backend snapshot
-
-quartz-cglayers.patch: add support for cairo surfaces backed by CGLayers
-
-quartz-cglayers-fix-fallback.patch: Bug 572912; fix bug in fallback code in previous patch
-
-quartz-get-image.patch: Bug 575521; add a way to get the image surface associated with a surface
-
-quartz-create-for-data.patch: Bug 575521; add a way to create quartz surfaces backed with application-provided data
-
-premultiply-alpha-solid-gradients.patch: bug 539165; multiply the solid color by the alpha component before using it for a solid surface
-
-xlib-initialize-members.path: bug 548793; initialize XRender version if the server doesn't have the extension
-
-remove-comma: remove a comma from enum
-
-d2d.patch: add d2d support
-
-fix-zero-len-graident.patch: fix zero length gradients
-
-fix-clip-copy.patch: fix clip copying
-
-fix-clip-region-simplification.patch: fixes a bug in clip region simplifications
-
-expand-in-stroke-limits.patch: expand the in-stroke limits to avoid a bug
-
-d2d-dwrite.patch: update the d2d/dwrite stuff
-
-add-a-stash-of-cairo_t-s.patch: use the stash to avoid malloc/freeing cairo_t's
-
-bgr.patch: fix image wrapping
-
-disable-server-graidents.patch: disable server-side gradients
-
-clip-invariant.patch: make rasterization closer to being clip invariant
-
-fix-unnecessary-fallback.patch: avoid unnecessary fallback
-
-handle-a1-upload.patch: handle a1 image uploads through converter
-
-surface-clipper.patch: remove an incorrect optimization
-
-fix-win32-show-glyphs-clipping.patch: fix a clipping bug
-
-native-clipping.patch: Add support for a native clipping api
-
-quartz-is-clear.patch: Propagate the quartz is_clear flag.
-
-cairo-qt-compile.patch: Fix compile error, return not reached, and clone_similar interface
-
-dwrite-glyph-extents.patch: Add padding to extents of antialiased glyphs, to avoid unwanted clipping. (bug 568191)
-
-fix-ps-output.patch: PS: Add missing 'q' when resetting clip path (42b5cac7668625c9761113ff72b47af5cfd10377)
-
-ensure-text-flushed.patch: PDF-operators: ensure text operations flushed before emitting clip (42b5cac7668625c9761113ff72b47af5cfd10377)
-
-fix-xcopyarea-with-clips.patch: 5d07307b691afccccbb15f773d5231669ba44f5a
-
-cairo-x-visual.patch: make valid visua for cairo_xlib_surface_create_with_xrender_format (55037bfb2454a671332d961e061c712ab5471580)
-
-win32-transparent-surface.patch: add API so we can create a win32 surface for an HDC and indicate the surface has an alpha channel
-
-cairo_qt_glyphs.patch: Drop X surface from Qt surface, add support for new qt glyphs api
-
-empty-clip-rectangles.patch: f2fa15680ec3ac95cb68d4957557f06561a7dc55
-
-empty-clip-extents.patch: b79ea8a6cab8bd28aebecf6e1e8229d5ac017264
-
-clip-rects-surface-extents.patch: 108b1c7825116ed3f93aa57384bbd3290cdc9181
-
-disable-previous-scaled-font-cache.patch: Disable the previous-scaled-font-cache until we figure out our ctm handling (#583035)
-
-copyarea-with-alpha.patch: support simple overlapping self copies in (some) color_alpha xlib surfaces. https://bugs.freedesktop.org/show_bug.cgi?id=29250
-
-fix-clip-test.patch: Use y 498c10032ea3f8631a928cd7df96766f2c8ddca4
-
-quartz-refactor-surface-setup.patch: Extract the surface-source setup chunk of _cairo_quartz_setup_state into its own function
-
-quartz-fix-PAD.patch: Treat PAD like NONE instead of REPEAT
-
-quartz-mask-non-OVER.patch: Don't use CGContextSetAlpha to optimize alpha masking for non-OVER operators
-
-quartz-layers-content.patch: Store cairo content type in CGLayer surfaces
-
-quartz-optimize-OVER.patch: Optimize OVER to SOURCE for opaque patterns
-
-quartz-check-imageSurfaceEquiv.patch: Drop cairo_quartz_surface_t's "imageSurfaceEquiv" member variable if we have problems creating it
-
-disable-subpixel-antialiasing.patch: Add API to disable subpixel antialiasing completely for a target surface
-
-tee-surfaces-pointwise.patch: Composite tee subsurfaces pointwise if possible
-
-pattern_get_surface-no-error.patch: Don't put a pattern into error if cairo_pattern_get_surface fails
-
-missing-cairo-clip-init.diff: Missing cairo_clip_init call in cairo_gstate_show_text_glyphs lead to crash
-
-fix-cairo-win32-print-gdi-error.diff: Don't use fwprintf with char* format. Flush stderr so that all error messages appears before exit.
-
-pixman-image-transform.patch: Reset the transform on pixman images when using them as destinations.
-
-fix-cairo-surface-wrapper-flush-build-warning.patch: Ensures that _cairo_surface_wrapper_flush always returns a status, to silence the build warning
-
-fixup-unbounded.patch: Hack to work around bad assumption.
-
-quartz-get-image-performance: Make cairo_quartz_get_image faster in the failure case by not flushing unless we are going to succeed.
-
-lround-c99-only.patch: Only use lround in C99 programs.
-
-unicode-printing.patch: Print as unicode (bug 454532)
-
-quartz-mark-dirty.patch: Add a quartz implementation of mark_dirty_rectangle (bug 715704)
-
-expose-snapshot.patch: Make functions to add snapshots public, as well as allow creating null surfaces publically. (bug 715658)
-
-fix-build-with-Werror=return-type.patch: Fix builds with -Werror=return-type (bug 737909)
-
-avoid-extend-none.patch: Avoid incorrectly using EXTEND_NONE (bug 751668)
-
-win32-ExtCreatePen-zero-size.patch: Don't pass zero width or dash lengths to ExtCreatePen (bug 768348)
-
-d2d-repeating-gradients.patch: Minimize number of gradient stops added to handle repeating with path fills (bug 768775)
-
-xlib-glyph-clip-region.patch: bug 709477, addressed upstream by be1ff2f45fdbc69537e513834fcffa0435e63073
-
-gdi-RGB24-ARGB32.patch: bug 788794
-
-dwrite-font-printing.patch: bug 468568; don't substitute a GDI font for a DWrite font if the name tables aren't equal
-
-d2d-gradient-ensure-stops.patch: bug 792903, ensure we don't set num_stops to 0
-
-setlcdfilter_in_tree.patch: bug 790139; force cairo to use FT_Library_SetLcdFilter from our in tree library rather than picking it up from the system
-
-dwrite-font-match-robustness.patch: bug 717178, don't crash when _name_tables_match is passed a nil scaled-font
-
-handle-multi-path-clip.patch: bug 813124, handle multiple clip paths correctly
-
-win32-gdi-font-cache.patch: Bug 717178, cache GDI font faces to reduce usage of GDI resources
-
-win32-gdi-font-cache-no-HFONT.patch: Bug 717178, don't cache GDI font faces when an HFONT belonging to the caller is passed in
-
-fix-win32-font-assertion.patch: Bug 838617, fix assertion from bug 717178 that was in the wrong place
-
-xlib-flush-glyphs.patch: bug 839745, flush glyphs when necessary
-
-dasharray-zero-gap.patch: bug 885585, ensure strokes get painted when the gaps in a dash array are all zero length
-
-cairo-mask-extends-bug.patch: bug 918671, sometimes when building a mask we wouldn't clear it properly. This is fixed in cairo 1.12
-
-ft-no-subpixel-if-surface-disables.patch: bug 929451, don't use subpixel aa for ft fonts on surfaces that don't support it
-
-win32-printing-axis-swap.patch: bug 1205854, workaround for Windows printer drivers that can't handle swapped X and Y axes
-
-no-pixman-image-reuse-across-threads.patch: bug 1273701, picked from 71e8a4c23019b01aa43b334fcb2784c70daae9b5
-
-==== pixman patches ====
-
-pixman-android-cpu-detect.patch: Add CPU detection support for Android, where we can't reliably access /proc/self/auxv.
-
-pixman-rename-and-endian.patch: include cairo-platform.h for renaming of external symbols and endian macros
-
-NOTE: we previously supported ARM assembler on MSVC, this has been removed because of the maintenance burden
-
-pixman-export.patch: use cairo_public for PIXMAN_EXPORT to make sure pixman symbols are not exported in libxul
-
-pixman-limits.patch: include limits.h for SIZE_MAX
-
-pixman-lowres-interp.patch: Use lower quality interpolation for more speed.
-
-pixman-bilinear-fastpath.patch: Bilinear fast paths for non-neon
-
-pixman-16-bit-pipeline.patch: 16 bit pipeline for dithering
-
-pixman-dither.patch: Add dithering of 16 bit gradients
-
-quartz-support-color-emoji-font.patch: support Apple Color Emoji font in cairo-quartz backend
-
-use-show-text-glyphs-if-glyph-path-fails.patch: fall back to show_text_glyphs even at huge sizes if scaled_font_glyph_path didn't work
-
-pixman-enable-altivec-acceleration.patch: enable building the altivec acceleration
-
-win32-d3dsurface9.patch: Create a win32 d3d9 surface to support LockRect
-
-win32-avoid-extend-pad-fallback: Avoid falling back to pixman when using EXTEND_PAD
-
-support-new-style-atomic-primitives.patch: Support the __atomic_* primitives for atomic operations
-
-==== disable printing patch ====
-
-disable-printing.patch: allows us to use NS_PRINTING to disable printing.
-
-==== cairo clamp bounday patch ====
-cairo-clamp-boundary.patch: don't call pixman_fill with negative starts or negative sizes
diff --git a/gfx/cairo/add-a-stash-of-cairo_t-s.patch b/gfx/cairo/add-a-stash-of-cairo_t-s.patch
deleted file mode 100644
index c6fcdd9d8..000000000
--- a/gfx/cairo/add-a-stash-of-cairo_t-s.patch
+++ /dev/null
@@ -1,75 +0,0 @@
-commit dfec2c249915560cedd2b49326c6629ad8a0b0f2
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Tue Mar 2 16:01:41 2010 -0500
-
- add a stash of cairo_t's
-
-diff --git a/src/cairo.c b/src/cairo.c
-index 3c9d892..4b27b83 100644
---- a/src/cairo.c
-+++ b/src/cairo.c
-@@ -119,7 +119,63 @@ _cairo_set_error (cairo_t *cr, cairo_status_t status)
- _cairo_status_set_error (&cr->status, _cairo_error (status));
- }
-
--#if HAS_ATOMIC_OPS
-+#if defined(_MSC_VER)
-+#pragma intrinsic(_BitScanForward)
-+static __forceinline int
-+ffs(int x)
-+{
-+ unsigned long i;
-+
-+ if (_BitScanForward(&i, x) != 0)
-+ return i + 1;
-+
-+ return 0;
-+}
-+#endif
-+
-+
-+#if CAIRO_NO_MUTEX
-+/* We keep a small stash of contexts to reduce malloc pressure */
-+#define CAIRO_STASH_SIZE 4
-+static struct {
-+ cairo_t pool[CAIRO_STASH_SIZE];
-+ int occupied;
-+} _context_stash;
-+
-+static cairo_t *
-+_context_get (void)
-+{
-+ int avail, old, new;
-+
-+ old = _context_stash.occupied;
-+ avail = ffs (~old) - 1;
-+ if (avail >= CAIRO_STASH_SIZE)
-+ return malloc (sizeof (cairo_t));
-+
-+ new = old | (1 << avail);
-+ _context_stash.occupied = new;
-+
-+ return &_context_stash.pool[avail];
-+}
-+
-+static void
-+_context_put (cairo_t *cr)
-+{
-+ int old, new, avail;
-+
-+ if (cr < &_context_stash.pool[0] ||
-+ cr >= &_context_stash.pool[CAIRO_STASH_SIZE])
-+ {
-+ free (cr);
-+ return;
-+ }
-+
-+ avail = ~(1 << (cr - &_context_stash.pool[0]));
-+ old = _context_stash.occupied;
-+ new = old & avail;
-+ _context_stash.occupied = new;
-+}
-+#elif HAS_ATOMIC_OPS
- /* We keep a small stash of contexts to reduce malloc pressure */
- #define CAIRO_STASH_SIZE 4
- static struct {
diff --git a/gfx/cairo/avoid-extend-none.patch b/gfx/cairo/avoid-extend-none.patch
deleted file mode 100644
index b3606cc2e..000000000
--- a/gfx/cairo/avoid-extend-none.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-changeset: 93076:25d0c8a38d7d
-tag: none
-tag: qbase
-tag: qtip
-tag: tip
-user: Jeff Muizelaar <jmuizelaar@mozilla.com>
-date: Thu May 03 15:21:52 2012 -0400
-summary: Bug 751668. Avoid incorrectly using EXTEND_NONE. r=joe
-
-diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c
---- a/gfx/cairo/cairo/src/cairo-image-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-image-surface.c
-@@ -1390,25 +1390,16 @@ static pixman_image_t *
- cairo_image_surface_t *source = (cairo_image_surface_t *) pattern->surface;
- cairo_surface_type_t type;
-
- if (source->base.backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT)
- source = (cairo_image_surface_t *) ((cairo_surface_snapshot_t *) pattern->surface)->target;
-
- type = source->base.backend->type;
- if (type == CAIRO_SURFACE_TYPE_IMAGE) {
-- if (extend != CAIRO_EXTEND_NONE &&
-- sample.x >= 0 &&
-- sample.y >= 0 &&
-- sample.x + sample.width <= source->width &&
-- sample.y + sample.height <= source->height)
-- {
-- extend = CAIRO_EXTEND_NONE;
-- }
--
- if (sample.width == 1 && sample.height == 1) {
- if (sample.x < 0 ||
- sample.y < 0 ||
- sample.x >= source->width ||
- sample.y >= source->height)
- {
- if (extend == CAIRO_EXTEND_NONE)
- return _pixman_transparent_image ();
-
diff --git a/gfx/cairo/bgr.patch b/gfx/cairo/bgr.patch
deleted file mode 100644
index af72fa237..000000000
--- a/gfx/cairo/bgr.patch
+++ /dev/null
@@ -1,104 +0,0 @@
-commit d2120bdb06c9aacc470bb346d6bc2071c2e0749d
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Fri Mar 12 15:32:09 2010 -0500
-
- BGR
-
-diff --git a/src/cairo-surface.c b/src/cairo-surface.c
-index 332e3ab..4a1d6a0 100644
---- a/src/cairo-surface.c
-+++ b/src/cairo-surface.c
-@@ -1501,7 +1501,9 @@ static void
- _wrap_release_source_image (void *data)
- {
- struct acquire_source_image_data *acquire_data = data;
-- _cairo_surface_release_source_image (acquire_data->src, acquire_data->image, acquire_data->image_extra);
-+ _cairo_surface_release_source_image (acquire_data->src,
-+ acquire_data->image,
-+ acquire_data->image_extra);
- free(data);
- }
-
-@@ -1515,42 +1517,47 @@ _wrap_image (cairo_surface_t *src,
- cairo_image_surface_t *surface;
- cairo_status_t status;
-
-- struct acquire_source_image_data *data = malloc(sizeof(*data));
-+ struct acquire_source_image_data *data = malloc (sizeof (*data));
-+ if (unlikely (data == NULL))
-+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- data->src = src;
- data->image = image;
- data->image_extra = image_extra;
-
-- surface = (cairo_image_surface_t*)cairo_image_surface_create_for_data (image->data,
-- image->format,
-- image->width,
-- image->height,
-- image->stride);
-+ surface = (cairo_image_surface_t*)
-+ _cairo_image_surface_create_with_pixman_format (image->data,
-+ image->pixman_format,
-+ image->width,
-+ image->height,
-+ image->stride);
- status = surface->base.status;
-- if (status)
-+ if (status) {
-+ free (data);
- return status;
-+ }
-
- status = _cairo_user_data_array_set_data (&surface->base.user_data,
-- &wrap_image_key,
-- data,
-- _wrap_release_source_image);
-+ &wrap_image_key,
-+ data,
-+ _wrap_release_source_image);
- if (status) {
- cairo_surface_destroy (&surface->base);
-+ free (data);
- return status;
- }
--/*
-- pixman_image_set_component_alpha (surface->pixman_image,
-- pixman_image_get_component_alpha (image->pixman_image));
--*/
-+
-+ pixman_image_set_component_alpha (
-+ surface->pixman_image,
-+ pixman_image_get_component_alpha (image->pixman_image));
-+
- *out = surface;
- return CAIRO_STATUS_SUCCESS;
- }
-
--
- /**
- * _cairo_surface_clone_similar:
- * @surface: a #cairo_surface_t
- * @src: the source image
-- * @content: target content mask
- * @src_x: extent for the rectangle in src we actually care about
- * @src_y: extent for the rectangle in src we actually care about
- * @width: extent for the rectangle in src we actually care about
-@@ -1627,12 +1634,12 @@ _cairo_surface_clone_similar (cairo_surface_t *surface,
- _cairo_surface_release_source_image (src, image, image_extra);
- } else {
- status =
-- surface->backend->clone_similar (surface, &image->base,
-- src_x, src_y,
-- width, height,
-- clone_offset_x,
-- clone_offset_y,
-- clone_out);
-+ surface->backend->clone_similar (surface, &image->base,
-+ src_x, src_y,
-+ width, height,
-+ clone_offset_x,
-+ clone_offset_y,
-+ clone_out);
- cairo_surface_destroy(&image->base);
- }
- }
diff --git a/gfx/cairo/buggy-repeat.patch b/gfx/cairo/buggy-repeat.patch
deleted file mode 100644
index 3d27b8f9b..000000000
--- a/gfx/cairo/buggy-repeat.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-xlib-display.c b/gfx/cairo/cairo/src/cairo-xlib-display.c
---- a/gfx/cairo/cairo/src/cairo-xlib-display.c
-+++ b/gfx/cairo/cairo/src/cairo-xlib-display.c
-@@ -216,6 +216,8 @@ _cairo_xlib_display_get (Display *dpy)
- XExtCodes *codes;
- int major_unused, minor_unused;
-
-+ static int buggy_repeat_force = -1;
-+
- /* There is an apparent deadlock between this mutex and the
- * mutex for the display, but it's actually safe. For the
- * app to call XCloseDisplay() while any other thread is
-@@ -308,6 +310,26 @@ _cairo_xlib_display_get (Display *dpy)
- if (VendorRelease (dpy) <= 40500000)
- display->buggy_repeat = TRUE;
- }
-+
-+ /* XXX workaround; see https://bugzilla.mozilla.org/show_bug.cgi?id=413583 */
-+ /* If buggy_repeat_force == -1, then initialize.
-+ * - set to -2, meaning "nothing was specified", and we trust the above detection.
-+ * - if MOZ_CAIRO_BUGGY_REPEAT is '0' (exactly), then force buggy repeat off
-+ * - if MOZ_CAIRO_BUGGY_REPEAT is '1' (exactly), then force buggy repeat on
-+ */
-+ if (buggy_repeat_force == -1) {
-+ const char *flag = getenv("MOZ_CAIRO_FORCE_BUGGY_REPEAT");
-+
-+ buggy_repeat_force = -2;
-+
-+ if (flag && flag[0] == '0')
-+ buggy_repeat_force = 0;
-+ else if (flag && flag[0] == '1')
-+ buggy_repeat_force = 1;
-+ }
-+
-+ if (buggy_repeat_force != -2)
-+ display->buggy_repeat = (buggy_repeat_force == 1);
-
- display->next = _cairo_xlib_display_list;
- _cairo_xlib_display_list = display;
diff --git a/gfx/cairo/cache-size.patch b/gfx/cairo/cache-size.patch
deleted file mode 100644
index 2371046aa..000000000
--- a/gfx/cairo/cache-size.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit c32b57b9ada7a57ec20648629ecb83de5688682a
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Mon Mar 23 11:28:12 2009 -0400
-
- shrink cache size
-
-diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
-index 249ab6c..aa7fc11 100644
---- a/src/cairo-scaled-font.c
-+++ b/src/cairo-scaled-font.c
-@@ -63,7 +63,7 @@
- */
-
- /* XXX: This number is arbitrary---we've never done any measurement of this. */
--#define MAX_GLYPH_PAGES_CACHED 512
-+#define MAX_GLYPH_PAGES_CACHED 256
- static cairo_cache_t *cairo_scaled_glyph_page_cache;
-
- #define CAIRO_SCALED_GLYPH_PAGE_SIZE 32
diff --git a/gfx/cairo/cairo-clamp-boundary.patch b/gfx/cairo/cairo-clamp-boundary.patch
deleted file mode 100644
index 990f1161a..000000000
--- a/gfx/cairo/cairo-clamp-boundary.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-# HG changeset patch
-# User Milan Sreckovic <msreckovic@mozilla.com>
-# Date 1362078121 18000
-# Node ID e9e6d97b153d8ec17ee03bb1deef1dec24c7a17c
-# Parent c65d59d33aa86b7e75bc420ea3beda6201e0aceb
-Bug 825721: clamp negative box starts and disallow negative sizes. r=jmuizelaar
-
-diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c
---- a/gfx/cairo/cairo/src/cairo-image-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-image-surface.c
-@@ -1846,16 +1846,20 @@ static cairo_status_t
- if (likely (status == CAIRO_STATUS_SUCCESS)) {
- for (chunk = &clear.chunks; chunk != NULL; chunk = chunk->next) {
- for (i = 0; i < chunk->count; i++) {
- int x1 = _cairo_fixed_integer_part (chunk->base[i].p1.x);
- int y1 = _cairo_fixed_integer_part (chunk->base[i].p1.y);
- int x2 = _cairo_fixed_integer_part (chunk->base[i].p2.x);
- int y2 = _cairo_fixed_integer_part (chunk->base[i].p2.y);
-
-+ x1 = (x1 < 0 ? 0 : x1);
-+ y1 = (y1 < 0 ? 0 : y1);
-+ if (x2 <= x1 || y2 <= y1)
-+ continue;
- pixman_fill ((uint32_t *) dst->data, dst->stride / sizeof (uint32_t),
- PIXMAN_FORMAT_BPP (dst->pixman_format),
- x1, y1, x2 - x1, y2 - y1,
- 0);
- }
- }
- }
-
-@@ -2669,16 +2673,18 @@ static cairo_status_t
- const cairo_box_t *box = chunk->base;
-
- for (i = 0; i < chunk->count; i++) {
- int x1 = _cairo_fixed_integer_ceil (box[i].p1.x);
- int y1 = _cairo_fixed_integer_ceil (box[i].p1.y);
- int x2 = _cairo_fixed_integer_floor (box[i].p2.x);
- int y2 = _cairo_fixed_integer_floor (box[i].p2.y);
-
-+ x1 = (x1 < 0 ? 0 : x1);
-+ y1 = (y1 < 0 ? 0 : y1);
- if (x2 > x1 && y2 > y1) {
- cairo_box_t b;
-
- pixman_fill ((uint32_t *) dst->data,
- dst->stride / sizeof (uint32_t),
- PIXMAN_FORMAT_BPP (dst->pixman_format),
- x1, y1, x2 - x1, y2 - y1,
- pixel);
-@@ -2929,17 +2935,19 @@ static cairo_status_t
- cairo_box_t *box = chunk->base;
-
- for (i = 0; i < chunk->count; i++) {
- int x1 = _cairo_fixed_integer_round_down (box[i].p1.x);
- int y1 = _cairo_fixed_integer_round_down (box[i].p1.y);
- int x2 = _cairo_fixed_integer_round_down (box[i].p2.x);
- int y2 = _cairo_fixed_integer_round_down (box[i].p2.y);
-
-- if (x2 == x1 || y2 == y1)
-+ x1 = (x1 < 0 ? 0 : x1);
-+ y1 = (y1 < 0 ? 0 : y1);
-+ if (x2 <= x1 || y2 <= y1)
- continue;
-
- pixman_fill ((uint32_t *) dst->data, dst->stride / sizeof (uint32_t),
- PIXMAN_FORMAT_BPP (dst->pixman_format),
- x1, y1, x2 - x1, y2 - y1,
- pixel);
- }
- }
diff --git a/gfx/cairo/cairo-mask-extends-bug.patch b/gfx/cairo/cairo-mask-extends-bug.patch
deleted file mode 100644
index 325772d82..000000000
--- a/gfx/cairo/cairo-mask-extends-bug.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c
---- a/gfx/cairo/cairo/src/cairo-image-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-image-surface.c
-@@ -1788,18 +1788,35 @@ static cairo_status_t
- cairo_boxes_t *boxes)
- {
- cairo_boxes_t clear;
- cairo_box_t box;
- cairo_status_t status;
- struct _cairo_boxes_chunk *chunk;
- int i;
-
-- if (boxes->num_boxes < 1 && clip_region == NULL)
-- return _cairo_image_surface_fixup_unbounded (dst, extents, NULL);
-+ // If we have no boxes then we need to clear the entire extents
-+ // because we have nothing to draw.
-+ if (boxes->num_boxes < 1 && clip_region == NULL) {
-+ int x = extents->unbounded.x;
-+ int y = extents->unbounded.y;
-+ int width = extents->unbounded.width;
-+ int height = extents->unbounded.height;
-+
-+ pixman_color_t color = { 0 };
-+ pixman_box32_t box = { x, y, x + width, y + height };
-+
-+ if (! pixman_image_fill_boxes (PIXMAN_OP_CLEAR,
-+ dst->pixman_image,
-+ &color,
-+ 1, &box)) {
-+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-+ }
-+ return CAIRO_STATUS_SUCCESS;
-+ }
-
- _cairo_boxes_init (&clear);
-
- box.p1.x = _cairo_fixed_from_int (extents->unbounded.x + extents->unbounded.width);
- box.p1.y = _cairo_fixed_from_int (extents->unbounded.y);
- box.p2.x = _cairo_fixed_from_int (extents->unbounded.x);
- box.p2.y = _cairo_fixed_from_int (extents->unbounded.y + extents->unbounded.height);
-
diff --git a/gfx/cairo/cairo-qt-compile.patch b/gfx/cairo/cairo-qt-compile.patch
deleted file mode 100644
index f839c7988..000000000
--- a/gfx/cairo/cairo-qt-compile.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-# HG changeset patch
-# Parent 2563fa2763b0ea83394e785340afa4c564ceab57
-diff -r 2563fa2763b0 -r 9ab15e95a354 gfx/cairo/cairo/src/cairo-qt-surface.cpp
---- a/gfx/cairo/cairo/src/cairo-qt-surface.cpp Thu Apr 29 06:55:11 2010 +0300
-+++ b/gfx/cairo/cairo/src/cairo-qt-surface.cpp Thu Apr 29 06:55:51 2010 +0300
-@@ -204,6 +204,7 @@
- case CAIRO_OPERATOR_HSL_LUMINOSITY:
- ASSERT_NOT_REACHED;
- }
-+ return QPainter::CompositionMode_Source;
- }
-
- static bool
-@@ -668,7 +669,6 @@
- static cairo_status_t
- _cairo_qt_surface_clone_similar (void *abstract_surface,
- cairo_surface_t *src,
-- cairo_content_t content,
- int src_x,
- int src_y,
- int width,
diff --git a/gfx/cairo/cairo-region-clip.patch b/gfx/cairo/cairo-region-clip.patch
deleted file mode 100644
index a0eb2d265..000000000
--- a/gfx/cairo/cairo-region-clip.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-# HG changeset patch
-# User Matt Woodrow <mwoodrow@mozilla.com>
-# Date 1408674084 -43200
-# Fri Aug 22 14:21:24 2014 +1200
-# Node ID 2b819b882c3b26c02d821e8d713591a9b56f1728
-# Parent ffd1fc7e7d5a85e4823b5f2067b4a24d358a0e41
-Bug 1050788 - Fix cairo clip path region construction when the first path generates no traps. r=jrmuizel
-
-diff --git a/gfx/cairo/cairo/src/cairo-clip.c b/gfx/cairo/cairo/src/cairo-clip.c
---- a/gfx/cairo/cairo/src/cairo-clip.c
-+++ b/gfx/cairo/cairo/src/cairo-clip.c
-@@ -590,16 +590,22 @@ static cairo_int_status_t
- status = _cairo_path_fixed_fill_rectilinear_to_traps (&clip_path->path,
- clip_path->fill_rule,
- &traps);
- if (unlikely (_cairo_status_is_error (status)))
- return status;
- if (status == CAIRO_INT_STATUS_UNSUPPORTED)
- goto UNSUPPORTED;
-
-+ if (unlikely (traps.num_traps == 0)) {
-+ clip_path->region = cairo_region_create ();
-+ clip_path->flags |= CAIRO_CLIP_PATH_HAS_REGION;
-+ return CAIRO_STATUS_SUCCESS;
-+ }
-+
- if (traps.num_traps > ARRAY_LENGTH (stack_boxes)) {
- boxes = _cairo_malloc_ab (traps.num_traps, sizeof (cairo_box_t));
- if (unlikely (boxes == NULL))
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- }
-
- for (n = 0; n < traps.num_traps; n++) {
- boxes[n].p1.x = traps.traps[n].left.p1.x;
diff --git a/gfx/cairo/cairo-version-fixes.patch b/gfx/cairo/cairo-version-fixes.patch
deleted file mode 100644
index f55e85731..000000000
--- a/gfx/cairo/cairo-version-fixes.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-version.c b/gfx/cairo/cairo/src/cairo-version.c
---- a/gfx/cairo/cairo/src/cairo-version.c
-+++ b/gfx/cairo/cairo/src/cairo-version.c
-@@ -42,7 +42,7 @@
-
- /* get the "real" version info instead of dummy cairo-version.h */
- #undef CAIRO_VERSION_H
--#include "../cairo-version.h"
-+#include "cairo-features.h"
-
- /**
- * cairo_version:
-diff --git a/gfx/cairo/cairo/src/cairo-version.h b/gfx/cairo/cairo/src/cairo-version.h
---- a/gfx/cairo/cairo/src/cairo-version.h
-+++ b/gfx/cairo/cairo/src/cairo-version.h
-@@ -7,8 +7,10 @@
- #ifndef CAIRO_VERSION_H
- #define CAIRO_VERSION_H
-
-+#if 0
- #define CAIRO_VERSION_MAJOR USE_cairo_version_OR_cairo_version_string_INSTEAD
- #define CAIRO_VERSION_MINOR USE_cairo_version_OR_cairo_version_string_INSTEAD
- #define CAIRO_VERSION_MICRO USE_cairo_version_OR_cairo_version_string_INSTEAD
-+#endif
-
- #endif
diff --git a/gfx/cairo/cairo-x-visual.patch b/gfx/cairo/cairo-x-visual.patch
deleted file mode 100644
index 29f6c737e..000000000
--- a/gfx/cairo/cairo-x-visual.patch
+++ /dev/null
@@ -1,160 +0,0 @@
-diff -r c1195334f839 gfx/cairo/cairo/src/cairo-xlib-surface.c
---- a/gfx/cairo/cairo/src/cairo-xlib-surface.c Fri May 21 17:42:55 2010 +0300
-+++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c Fri May 21 19:12:29 2010 +0300
-@@ -189,16 +189,57 @@ static const XTransform identity = { {
-
- #define CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS(surface) CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 11)
-
- #define CAIRO_SURFACE_RENDER_SUPPORTS_OPERATOR(surface, op) \
- ((op) <= CAIRO_OPERATOR_SATURATE || \
- (CAIRO_SURFACE_RENDER_HAS_PDF_OPERATORS(surface) && \
- (op) <= CAIRO_OPERATOR_HSL_LUMINOSITY))
-
-+static Visual *
-+_visual_for_xrender_format(Screen *screen,
-+ XRenderPictFormat *xrender_format)
-+{
-+ int d, v;
-+ for (d = 0; d < screen->ndepths; d++) {
-+ Depth *d_info = &screen->depths[d];
-+ if (d_info->depth != xrender_format->depth)
-+ continue;
-+
-+ for (v = 0; v < d_info->nvisuals; v++) {
-+ Visual *visual = &d_info->visuals[v];
-+
-+ switch (visual->class) {
-+ case TrueColor:
-+ if (xrender_format->type != PictTypeDirect)
-+ continue;
-+ break;
-+ case DirectColor:
-+ /* Prefer TrueColor to DirectColor.
-+ (XRenderFindVisualFormat considers both TrueColor and
-+ DirectColor Visuals to match the same PictFormat.) */
-+ continue;
-+ case StaticGray:
-+ case GrayScale:
-+ case StaticColor:
-+ case PseudoColor:
-+ if (xrender_format->type != PictTypeIndexed)
-+ continue;
-+ break;
-+ }
-+
-+ if (xrender_format ==
-+ XRenderFindVisualFormat (DisplayOfScreen(screen), visual))
-+ return visual;
-+ }
-+ }
-+
-+ return NULL;
-+}
-+
- static cairo_status_t
- _cairo_xlib_surface_set_clip_region (cairo_xlib_surface_t *surface,
- cairo_region_t *region)
- {
- cairo_bool_t had_clip_rects = surface->clip_region != NULL;
-
- if (had_clip_rects == FALSE && region == NULL)
- return CAIRO_STATUS_SUCCESS;
-@@ -313,16 +354,19 @@ _cairo_xlib_surface_create_similar (void
- * visual/depth etc. as possible. */
- pix = XCreatePixmap (src->dpy, src->drawable,
- width <= 0 ? 1 : width, height <= 0 ? 1 : height,
- xrender_format->depth);
-
- visual = NULL;
- if (xrender_format == src->xrender_format)
- visual = src->visual;
-+ else
-+ visual = _visual_for_xrender_format(src->screen->screen,
-+ xrender_format);
-
- surface = (cairo_xlib_surface_t *)
- _cairo_xlib_surface_create_internal (src->screen, pix,
- visual,
- xrender_format,
- width, height,
- xrender_format->depth);
- }
-@@ -3178,28 +3222,32 @@ cairo_xlib_surface_create_with_xrender_f
- Screen *scr,
- XRenderPictFormat *format,
- int width,
- int height)
- {
- cairo_xlib_screen_t *screen;
- cairo_surface_t *surface;
- cairo_status_t status;
-+ Visual *visual;
-
- if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX)
- return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE);
-
- status = _cairo_xlib_screen_get (dpy, scr, &screen);
- if (unlikely (status))
- return _cairo_surface_create_in_error (status);
-
- X_DEBUG ((dpy, "create_with_xrender_format (drawable=%x)", (unsigned int) drawable));
-
-+ if (format)
-+ visual = _visual_for_xrender_format (scr, format);
-+
- surface = _cairo_xlib_surface_create_internal (screen, drawable,
-- NULL, format,
-+ visual, format,
- width, height, 0);
- _cairo_xlib_screen_destroy (screen);
-
- return surface;
- }
- slim_hidden_def (cairo_xlib_surface_create_with_xrender_format);
-
- /**
-@@ -3413,33 +3461,37 @@ cairo_xlib_surface_get_screen (cairo_sur
-
- return surface->screen->screen;
- }
-
- /**
- * cairo_xlib_surface_get_visual:
- * @surface: a #cairo_xlib_surface_t
- *
-- * Get the X Visual used for underlying X Drawable.
-+ * Gets the X Visual associated with @surface, suitable for use with the
-+ * underlying X Drawable. If @surface was created by
-+ * cairo_xlib_surface_create(), the return value is the Visual passed to that
-+ * constructor.
- *
-- * Return value: the visual.
-+ * Return value: the Visual or %NULL if there is no appropriate Visual for
-+ * @surface.
- *
- * Since: 1.2
- **/
- Visual *
--cairo_xlib_surface_get_visual (cairo_surface_t *abstract_surface)
-+cairo_xlib_surface_get_visual (cairo_surface_t *surface)
- {
-- cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
--
-- if (! _cairo_surface_is_xlib (abstract_surface)) {
-+ cairo_xlib_surface_t *xlib_surface = (cairo_xlib_surface_t *) surface;
-+
-+ if (! _cairo_surface_is_xlib (surface)) {
- _cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
- return NULL;
- }
-
-- return surface->visual;
-+ return xlib_surface->visual;
- }
-
- /**
- * cairo_xlib_surface_get_depth:
- * @surface: a #cairo_xlib_surface_t
- *
- * Get the number of bits used to represent each pixel value.
- *
diff --git a/gfx/cairo/cairo/COPYING b/gfx/cairo/cairo/COPYING
index 145e62966..184e603c3 100644
--- a/gfx/cairo/cairo/COPYING
+++ b/gfx/cairo/cairo/COPYING
@@ -1,17 +1,11 @@
Cairo is free software.
-Every source file in the implementation of cairo is available to be
-redistributed and/or modified under the terms of either the GNU Lesser
-General Public License (LGPL) version 2.1 or the Mozilla Public
-License (MPL) version 1.1. Some files are available under more
-liberal terms, but we believe that in all cases, each file may be used
-under either the LGPL or the MPL.
-
-See the following files in this directory for the precise terms and
-conditions of either license:
-
- COPYING-LGPL-2.1
- COPYING-MPL-1.1
-
-Please see each file in the implementation for Copyright and licensing
-information.
+This (modified) version of the cairo implementation is available to be
+redistributed and/or modified under the terms the Mozilla Public License
+(MPL) version 2.0. Some files in the original cairo source code are
+available under more liberal terms, but we believe that in all cases,
+each file may be used under the MPL 2.0.
+
+Where the original code was not explicitly MPL licensed, the original
+more liberal license information and copyright has been retained for
+clarity of licensing and authorship.
diff --git a/gfx/cairo/cairo/COPYING-LGPL-2.1 b/gfx/cairo/cairo/COPYING-LGPL-2.1
deleted file mode 100644
index b124cf581..000000000
--- a/gfx/cairo/cairo/COPYING-LGPL-2.1
+++ /dev/null
@@ -1,510 +0,0 @@
-
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations
-below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it
-becomes a de-facto standard. To achieve this, non-free programs must
-be allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control
-compilation and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at least
- three years, to give the same user the materials specified in
- Subsection 6a, above, for a charge no more than the cost of
- performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply, and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License
-may add an explicit geographical distribution limitation excluding those
-countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms
-of the ordinary General Public License).
-
- To apply these terms, attach the following notices to the library.
-It is safest to attach them to the start of each source file to most
-effectively convey the exclusion of warranty; and each file should
-have at least the "copyright" line and a pointer to where the full
-notice is found.
-
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the library,
-if necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James
- Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/gfx/cairo/cairo/COPYING-MPL-1.1 b/gfx/cairo/cairo/COPYING-MPL-1.1
deleted file mode 100644
index 7714141d1..000000000
--- a/gfx/cairo/cairo/COPYING-MPL-1.1
+++ /dev/null
@@ -1,470 +0,0 @@
- MOZILLA PUBLIC LICENSE
- Version 1.1
-
- ---------------
-
-1. Definitions.
-
- 1.0.1. "Commercial Use" means distribution or otherwise making the
- Covered Code available to a third party.
-
- 1.1. "Contributor" means each entity that creates or contributes to
- the creation of Modifications.
-
- 1.2. "Contributor Version" means the combination of the Original
- Code, prior Modifications used by a Contributor, and the Modifications
- made by that particular Contributor.
-
- 1.3. "Covered Code" means the Original Code or Modifications or the
- combination of the Original Code and Modifications, in each case
- including portions thereof.
-
- 1.4. "Electronic Distribution Mechanism" means a mechanism generally
- accepted in the software development community for the electronic
- transfer of data.
-
- 1.5. "Executable" means Covered Code in any form other than Source
- Code.
-
- 1.6. "Initial Developer" means the individual or entity identified
- as the Initial Developer in the Source Code notice required by Exhibit
- A.
-
- 1.7. "Larger Work" means a work which combines Covered Code or
- portions thereof with code not governed by the terms of this License.
-
- 1.8. "License" means this document.
-
- 1.8.1. "Licensable" means having the right to grant, to the maximum
- extent possible, whether at the time of the initial grant or
- subsequently acquired, any and all of the rights conveyed herein.
-
- 1.9. "Modifications" means any addition to or deletion from the
- substance or structure of either the Original Code or any previous
- Modifications. When Covered Code is released as a series of files, a
- Modification is:
- A. Any addition to or deletion from the contents of a file
- containing Original Code or previous Modifications.
-
- B. Any new file that contains any part of the Original Code or
- previous Modifications.
-
- 1.10. "Original Code" means Source Code of computer software code
- which is described in the Source Code notice required by Exhibit A as
- Original Code, and which, at the time of its release under this
- License is not already Covered Code governed by this License.
-
- 1.10.1. "Patent Claims" means any patent claim(s), now owned or
- hereafter acquired, including without limitation, method, process,
- and apparatus claims, in any patent Licensable by grantor.
-
- 1.11. "Source Code" means the preferred form of the Covered Code for
- making modifications to it, including all modules it contains, plus
- any associated interface definition files, scripts used to control
- compilation and installation of an Executable, or source code
- differential comparisons against either the Original Code or another
- well known, available Covered Code of the Contributor's choice. The
- Source Code can be in a compressed or archival form, provided the
- appropriate decompression or de-archiving software is widely available
- for no charge.
-
- 1.12. "You" (or "Your") means an individual or a legal entity
- exercising rights under, and complying with all of the terms of, this
- License or a future version of this License issued under Section 6.1.
- For legal entities, "You" includes any entity which controls, is
- controlled by, or is under common control with You. For purposes of
- this definition, "control" means (a) the power, direct or indirect,
- to cause the direction or management of such entity, whether by
- contract or otherwise, or (b) ownership of more than fifty percent
- (50%) of the outstanding shares or beneficial ownership of such
- entity.
-
-2. Source Code License.
-
- 2.1. The Initial Developer Grant.
- The Initial Developer hereby grants You a world-wide, royalty-free,
- non-exclusive license, subject to third party intellectual property
- claims:
- (a) under intellectual property rights (other than patent or
- trademark) Licensable by Initial Developer to use, reproduce,
- modify, display, perform, sublicense and distribute the Original
- Code (or portions thereof) with or without Modifications, and/or
- as part of a Larger Work; and
-
- (b) under Patents Claims infringed by the making, using or
- selling of Original Code, to make, have made, use, practice,
- sell, and offer for sale, and/or otherwise dispose of the
- Original Code (or portions thereof).
-
- (c) the licenses granted in this Section 2.1(a) and (b) are
- effective on the date Initial Developer first distributes
- Original Code under the terms of this License.
-
- (d) Notwithstanding Section 2.1(b) above, no patent license is
- granted: 1) for code that You delete from the Original Code; 2)
- separate from the Original Code; or 3) for infringements caused
- by: i) the modification of the Original Code or ii) the
- combination of the Original Code with other software or devices.
-
- 2.2. Contributor Grant.
- Subject to third party intellectual property claims, each Contributor
- hereby grants You a world-wide, royalty-free, non-exclusive license
-
- (a) under intellectual property rights (other than patent or
- trademark) Licensable by Contributor, to use, reproduce, modify,
- display, perform, sublicense and distribute the Modifications
- created by such Contributor (or portions thereof) either on an
- unmodified basis, with other Modifications, as Covered Code
- and/or as part of a Larger Work; and
-
- (b) under Patent Claims infringed by the making, using, or
- selling of Modifications made by that Contributor either alone
- and/or in combination with its Contributor Version (or portions
- of such combination), to make, use, sell, offer for sale, have
- made, and/or otherwise dispose of: 1) Modifications made by that
- Contributor (or portions thereof); and 2) the combination of
- Modifications made by that Contributor with its Contributor
- Version (or portions of such combination).
-
- (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
- effective on the date Contributor first makes Commercial Use of
- the Covered Code.
-
- (d) Notwithstanding Section 2.2(b) above, no patent license is
- granted: 1) for any code that Contributor has deleted from the
- Contributor Version; 2) separate from the Contributor Version;
- 3) for infringements caused by: i) third party modifications of
- Contributor Version or ii) the combination of Modifications made
- by that Contributor with other software (except as part of the
- Contributor Version) or other devices; or 4) under Patent Claims
- infringed by Covered Code in the absence of Modifications made by
- that Contributor.
-
-3. Distribution Obligations.
-
- 3.1. Application of License.
- The Modifications which You create or to which You contribute are
- governed by the terms of this License, including without limitation
- Section 2.2. The Source Code version of Covered Code may be
- distributed only under the terms of this License or a future version
- of this License released under Section 6.1, and You must include a
- copy of this License with every copy of the Source Code You
- distribute. You may not offer or impose any terms on any Source Code
- version that alters or restricts the applicable version of this
- License or the recipients' rights hereunder. However, You may include
- an additional document offering the additional rights described in
- Section 3.5.
-
- 3.2. Availability of Source Code.
- Any Modification which You create or to which You contribute must be
- made available in Source Code form under the terms of this License
- either on the same media as an Executable version or via an accepted
- Electronic Distribution Mechanism to anyone to whom you made an
- Executable version available; and if made available via Electronic
- Distribution Mechanism, must remain available for at least twelve (12)
- months after the date it initially became available, or at least six
- (6) months after a subsequent version of that particular Modification
- has been made available to such recipients. You are responsible for
- ensuring that the Source Code version remains available even if the
- Electronic Distribution Mechanism is maintained by a third party.
-
- 3.3. Description of Modifications.
- You must cause all Covered Code to which You contribute to contain a
- file documenting the changes You made to create that Covered Code and
- the date of any change. You must include a prominent statement that
- the Modification is derived, directly or indirectly, from Original
- Code provided by the Initial Developer and including the name of the
- Initial Developer in (a) the Source Code, and (b) in any notice in an
- Executable version or related documentation in which You describe the
- origin or ownership of the Covered Code.
-
- 3.4. Intellectual Property Matters
- (a) Third Party Claims.
- If Contributor has knowledge that a license under a third party's
- intellectual property rights is required to exercise the rights
- granted by such Contributor under Sections 2.1 or 2.2,
- Contributor must include a text file with the Source Code
- distribution titled "LEGAL" which describes the claim and the
- party making the claim in sufficient detail that a recipient will
- know whom to contact. If Contributor obtains such knowledge after
- the Modification is made available as described in Section 3.2,
- Contributor shall promptly modify the LEGAL file in all copies
- Contributor makes available thereafter and shall take other steps
- (such as notifying appropriate mailing lists or newsgroups)
- reasonably calculated to inform those who received the Covered
- Code that new knowledge has been obtained.
-
- (b) Contributor APIs.
- If Contributor's Modifications include an application programming
- interface and Contributor has knowledge of patent licenses which
- are reasonably necessary to implement that API, Contributor must
- also include this information in the LEGAL file.
-
- (c) Representations.
- Contributor represents that, except as disclosed pursuant to
- Section 3.4(a) above, Contributor believes that Contributor's
- Modifications are Contributor's original creation(s) and/or
- Contributor has sufficient rights to grant the rights conveyed by
- this License.
-
- 3.5. Required Notices.
- You must duplicate the notice in Exhibit A in each file of the Source
- Code. If it is not possible to put such notice in a particular Source
- Code file due to its structure, then You must include such notice in a
- location (such as a relevant directory) where a user would be likely
- to look for such a notice. If You created one or more Modification(s)
- You may add your name as a Contributor to the notice described in
- Exhibit A. You must also duplicate this License in any documentation
- for the Source Code where You describe recipients' rights or ownership
- rights relating to Covered Code. You may choose to offer, and to
- charge a fee for, warranty, support, indemnity or liability
- obligations to one or more recipients of Covered Code. However, You
- may do so only on Your own behalf, and not on behalf of the Initial
- Developer or any Contributor. You must make it absolutely clear than
- any such warranty, support, indemnity or liability obligation is
- offered by You alone, and You hereby agree to indemnify the Initial
- Developer and every Contributor for any liability incurred by the
- Initial Developer or such Contributor as a result of warranty,
- support, indemnity or liability terms You offer.
-
- 3.6. Distribution of Executable Versions.
- You may distribute Covered Code in Executable form only if the
- requirements of Section 3.1-3.5 have been met for that Covered Code,
- and if You include a notice stating that the Source Code version of
- the Covered Code is available under the terms of this License,
- including a description of how and where You have fulfilled the
- obligations of Section 3.2. The notice must be conspicuously included
- in any notice in an Executable version, related documentation or
- collateral in which You describe recipients' rights relating to the
- Covered Code. You may distribute the Executable version of Covered
- Code or ownership rights under a license of Your choice, which may
- contain terms different from this License, provided that You are in
- compliance with the terms of this License and that the license for the
- Executable version does not attempt to limit or alter the recipient's
- rights in the Source Code version from the rights set forth in this
- License. If You distribute the Executable version under a different
- license You must make it absolutely clear that any terms which differ
- from this License are offered by You alone, not by the Initial
- Developer or any Contributor. You hereby agree to indemnify the
- Initial Developer and every Contributor for any liability incurred by
- the Initial Developer or such Contributor as a result of any such
- terms You offer.
-
- 3.7. Larger Works.
- You may create a Larger Work by combining Covered Code with other code
- not governed by the terms of this License and distribute the Larger
- Work as a single product. In such a case, You must make sure the
- requirements of this License are fulfilled for the Covered Code.
-
-4. Inability to Comply Due to Statute or Regulation.
-
- If it is impossible for You to comply with any of the terms of this
- License with respect to some or all of the Covered Code due to
- statute, judicial order, or regulation then You must: (a) comply with
- the terms of this License to the maximum extent possible; and (b)
- describe the limitations and the code they affect. Such description
- must be included in the LEGAL file described in Section 3.4 and must
- be included with all distributions of the Source Code. Except to the
- extent prohibited by statute or regulation, such description must be
- sufficiently detailed for a recipient of ordinary skill to be able to
- understand it.
-
-5. Application of this License.
-
- This License applies to code to which the Initial Developer has
- attached the notice in Exhibit A and to related Covered Code.
-
-6. Versions of the License.
-
- 6.1. New Versions.
- Netscape Communications Corporation ("Netscape") may publish revised
- and/or new versions of the License from time to time. Each version
- will be given a distinguishing version number.
-
- 6.2. Effect of New Versions.
- Once Covered Code has been published under a particular version of the
- License, You may always continue to use it under the terms of that
- version. You may also choose to use such Covered Code under the terms
- of any subsequent version of the License published by Netscape. No one
- other than Netscape has the right to modify the terms applicable to
- Covered Code created under this License.
-
- 6.3. Derivative Works.
- If You create or use a modified version of this License (which you may
- only do in order to apply it to code which is not already Covered Code
- governed by this License), You must (a) rename Your license so that
- the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
- "MPL", "NPL" or any confusingly similar phrase do not appear in your
- license (except to note that your license differs from this License)
- and (b) otherwise make it clear that Your version of the license
- contains terms which differ from the Mozilla Public License and
- Netscape Public License. (Filling in the name of the Initial
- Developer, Original Code or Contributor in the notice described in
- Exhibit A shall not of themselves be deemed to be modifications of
- this License.)
-
-7. DISCLAIMER OF WARRANTY.
-
- COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
- DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
- THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
- IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
- YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
- COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
- OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
- ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
-
-8. TERMINATION.
-
- 8.1. This License and the rights granted hereunder will terminate
- automatically if You fail to comply with terms herein and fail to cure
- such breach within 30 days of becoming aware of the breach. All
- sublicenses to the Covered Code which are properly granted shall
- survive any termination of this License. Provisions which, by their
- nature, must remain in effect beyond the termination of this License
- shall survive.
-
- 8.2. If You initiate litigation by asserting a patent infringement
- claim (excluding declatory judgment actions) against Initial Developer
- or a Contributor (the Initial Developer or Contributor against whom
- You file such action is referred to as "Participant") alleging that:
-
- (a) such Participant's Contributor Version directly or indirectly
- infringes any patent, then any and all rights granted by such
- Participant to You under Sections 2.1 and/or 2.2 of this License
- shall, upon 60 days notice from Participant terminate prospectively,
- unless if within 60 days after receipt of notice You either: (i)
- agree in writing to pay Participant a mutually agreeable reasonable
- royalty for Your past and future use of Modifications made by such
- Participant, or (ii) withdraw Your litigation claim with respect to
- the Contributor Version against such Participant. If within 60 days
- of notice, a reasonable royalty and payment arrangement are not
- mutually agreed upon in writing by the parties or the litigation claim
- is not withdrawn, the rights granted by Participant to You under
- Sections 2.1 and/or 2.2 automatically terminate at the expiration of
- the 60 day notice period specified above.
-
- (b) any software, hardware, or device, other than such Participant's
- Contributor Version, directly or indirectly infringes any patent, then
- any rights granted to You by such Participant under Sections 2.1(b)
- and 2.2(b) are revoked effective as of the date You first made, used,
- sold, distributed, or had made, Modifications made by that
- Participant.
-
- 8.3. If You assert a patent infringement claim against Participant
- alleging that such Participant's Contributor Version directly or
- indirectly infringes any patent where such claim is resolved (such as
- by license or settlement) prior to the initiation of patent
- infringement litigation, then the reasonable value of the licenses
- granted by such Participant under Sections 2.1 or 2.2 shall be taken
- into account in determining the amount or value of any payment or
- license.
-
- 8.4. In the event of termination under Sections 8.1 or 8.2 above,
- all end user license agreements (excluding distributors and resellers)
- which have been validly granted by You or any distributor hereunder
- prior to termination shall survive termination.
-
-9. LIMITATION OF LIABILITY.
-
- UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
- (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
- DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
- OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
- ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
- CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
- WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
- COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
- INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
- LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
- RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
- PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
- EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
- THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
-
-10. U.S. GOVERNMENT END USERS.
-
- The Covered Code is a "commercial item," as that term is defined in
- 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
- software" and "commercial computer software documentation," as such
- terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
- C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
- all U.S. Government End Users acquire Covered Code with only those
- rights set forth herein.
-
-11. MISCELLANEOUS.
-
- This License represents the complete agreement concerning subject
- matter hereof. If any provision of this License is held to be
- unenforceable, such provision shall be reformed only to the extent
- necessary to make it enforceable. This License shall be governed by
- California law provisions (except to the extent applicable law, if
- any, provides otherwise), excluding its conflict-of-law provisions.
- With respect to disputes in which at least one party is a citizen of,
- or an entity chartered or registered to do business in the United
- States of America, any litigation relating to this License shall be
- subject to the jurisdiction of the Federal Courts of the Northern
- District of California, with venue lying in Santa Clara County,
- California, with the losing party responsible for costs, including
- without limitation, court costs and reasonable attorneys' fees and
- expenses. The application of the United Nations Convention on
- Contracts for the International Sale of Goods is expressly excluded.
- Any law or regulation which provides that the language of a contract
- shall be construed against the drafter shall not apply to this
- License.
-
-12. RESPONSIBILITY FOR CLAIMS.
-
- As between Initial Developer and the Contributors, each party is
- responsible for claims and damages arising, directly or indirectly,
- out of its utilization of rights under this License and You agree to
- work with Initial Developer and Contributors to distribute such
- responsibility on an equitable basis. Nothing herein is intended or
- shall be deemed to constitute any admission of liability.
-
-13. MULTIPLE-LICENSED CODE.
-
- Initial Developer may designate portions of the Covered Code as
- "Multiple-Licensed". "Multiple-Licensed" means that the Initial
- Developer permits you to utilize portions of the Covered Code under
- Your choice of the NPL or the alternative licenses, if any, specified
- by the Initial Developer in the file described in Exhibit A.
-
-EXHIBIT A -Mozilla Public License.
-
- ``The contents of this file are subject to the Mozilla Public License
- Version 1.1 (the "License"); you may not use this file except in
- compliance with the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS"
- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- License for the specific language governing rights and limitations
- under the License.
-
- The Original Code is ______________________________________.
-
- The Initial Developer of the Original Code is ________________________.
- Portions created by ______________________ are Copyright (C) ______
- _______________________. All Rights Reserved.
-
- Contributor(s): ______________________________________.
-
- Alternatively, the contents of this file may be used under the terms
- of the _____ license (the "[___] License"), in which case the
- provisions of [______] License are applicable instead of those
- above. If you wish to allow use of your version of this file only
- under the terms of the [____] License and not to allow others to use
- your version of this file under the MPL, indicate your decision by
- deleting the provisions above and replace them with the notice and
- other provisions required by the [___] License. If you do not delete
- the provisions above, a recipient may use your version of this file
- under either the MPL or the [___] License."
-
- [NOTE: The text of this Exhibit A may differ slightly from the text of
- the notices in the Source Code files of the Original Code. You should
- use the text of this Exhibit A rather than the text found in the
- Original Code Source Code for Your Modifications.]
-
diff --git a/gfx/cairo/cairo/INSTALL b/gfx/cairo/cairo/INSTALL
deleted file mode 100644
index dfff8bebb..000000000
--- a/gfx/cairo/cairo/INSTALL
+++ /dev/null
@@ -1,187 +0,0 @@
-Quick-start build instructions
-------------------------------
-1) Configure the package:
-
- ./configure
-
-2) Compile it:
-
- make
-
-3) Install it:
-
- make install
-
-This final step may require temporary root access (eg. with sudo) if
-you don't have write permission to the directory in which cairo will
-be installed.
-
-NOTE: If you are working with source from git/cvs rather than from a tar
-file, then you should use ./autogen.sh in place of ./configure
-anywhere it is mentioned in these instructions.
-
-More detailed build instructions
---------------------------------
-1) Configure the package
-
- The first step in building cairo is to configure the package by
- running the configure script. [Note: if you don't have a configure
- script, skip down below to the Extremely detailed build
- instructions.]
-
- The configure script attempts to automatically detect as much as
- possible about your system. So, you should primarily just accept
- its defaults by running:
-
- ./configure
-
- The configure script does accept a large number of options for
- fine-tuning its behavior. See "./configure --help" for a complete
- list. The most commonly used options are discussed here.
-
- --prefix=PREFIX
-
- This option specifies the directory under which the software
- should be installed. By default configure will choose a
- directory such as /usr/local. If you would like to install
- cairo to some other location, pass the director to configure
- with the --prefix option. For example:
-
- ./configure --prefix=/opt/cairo
-
- would install cairo into the /opt/cairo directory. You could
- also choose a prefix directory within your home directory if
- you don't have write access to any system-wide directory.
-
- After installing into a custom prefix, you will need to set
- some environment variables to allow the software to be
- found. Assuming the /opt/cairo prefix and assuming you are
- using the bash shell, the following environment variables
- should be set:
-
- PKG_CONFIG_PATH=/opt/cairo/lib/pkgconfig
- LD_LIBRARY_PATH=/opt/cairo/lib
- export PKG_CONFIG_PATH LD_LIBRARY_PATH
-
- (NOTE: On Mac OS X, at least, use DYLD_LIBRARY_PATH in place
- of LD_LIBRARY_PATH above.)
-
- --enable-quartz
- --enable-atsui
- --enable-xcb
- --enable-glitz
- --enable-beos
- --enable-os2
- --enable-directfb
-
- Some of cairo's backends are marked as experimental and will
- not be built by default. If you would like to build and
- experiment with these backends, you will need to pass one of
- the above options to the configure script. You may need to
- have certain libraries installed first as discussed in the
- dependencies section of the README file.
-
- --disable-xlib
- --disable-win32
- --disable-png
- --disable-freetype
- --disable-ps
- --disable-pdf
- --disable-svg
-
- Cairo's configure script detects the libraries needed to build
- each stable backend, and when it finds them, enables each
- backend. If you would like to override this detection and
- disable a backend, (even when it would be possible to build
- it), use one of the options above to disable the backend.
-
-2) Compile the package:
-
- This step is very simple. Just:
-
- make
-
- The Makefiles included with cairo are designed to work on as many
- different systems as possible.
-
- When cairo is compiled, you can also run some automated tests of
- cairo with:
-
- make check
-
- NOTE: Some versions of X servers will cause the -xlib tests to
- report failures in make check even when cairo is working just
- fine. If you see failures in nothing but -xlib tests, please
- examine the corresponding -xlib-out.png images and compare them to
- the -ref.png reference images (the -xlib-diff.png images might also
- be useful). If the results seem "close enough" please do not report
- a bug against cairo as the "failures" you are seeing are just due
- to subtle variations in X server implementations.
-
-3) Install the package:
-
- The final step is to install the package with:
-
- make install
-
- If you are installing to a system-wide location you may need to
- temporarily acquire root access in order to perform this
- operation. A good way to do this is to use the sudo program:
-
- sudo make install
-
-Extremely detailed build instructions
--------------------------------------
-So you want to build cairo but it didn't come with a configure
-script. This is probably because you have checked out the latest
-in-development code via git. If you need to be on the bleeding edge,
-(for example, because you're wanting to develop some aspect of cairo
-itself), then you're in the right place and should read on.
-
-However, if you don't need such a bleeding-edge version of cairo, then
-you might prefer to start by building the latest stable cairo release:
-
- http://cairographics.org/releases
-
-or perhaps the latest (unstable) development snapshot:
-
- http://cairographics.org/snapshots
-
-There you'll find nicely packaged tar files that include a configure
-script so you can go back the the simpler instructions above.
-
-But you're still reading, so you're someone that loves to
-learn. Excellent! We hope you'll learn enough to make some excellent
-contributions to cairo. Since you're not using a packaged tar file,
-you're going to need some additional tools beyond just a C compiler in
-order to compile cairo. Specifically, you need the following utilities:
-
- automake (1.8 or newer)
- autoconf
- libtool
-
-Hopefully your platform of choice has packages readily available so
-that you can easily install things with your system's package
-management tool, (such as "apt-get install automake" on Debian or "yum
-install automake" on Fedora, etc.). Note that Mac OS X ships with it's
-own utility called libtool which is not what you want, (the one you do
-want goes by the name of glibtool).
-
-Once you have all of those packages installed, the next step is to run
-the autogen.sh script. That can be as simple as:
-
- ./autogen.sh
-
-Or, if you're using Mac OS X, you'll have to let it know to use
-glibtool by instead doing:
-
- LIBTOOLIZE=glibtoolize ./autogen.sh
-
-But before you run that command, note that the autogen.sh script
-accepts all the same arguments as the configure script, (and in fact,
-will generate the configure script and run it with the arguments you
-provide). So go back up to step (1) above and see what additional
-arguments you might want to pass, (such as prefix). Then continue with
-the instructions, simply using ./autogen.sh in place of ./configure.
-
-Happy hacking!
diff --git a/gfx/cairo/cairo/NEWS b/gfx/cairo/cairo/NEWS
deleted file mode 100644
index 9be4062ca..000000000
--- a/gfx/cairo/cairo/NEWS
+++ /dev/null
@@ -1,5121 +0,0 @@
-Release 1.6.4 (2008-04-11 Carl Worth <cworth@cworth.org>)
-=========================================================
-The cairo community is wildly embarrassed to announce the 1.6.4
-release of the cairo graphics library. This release reverts the xlib
-locking change introduced in 1.6.4, (and the application crashes that
-it caused). The community would be glad to sack its current release
-manager and is accepting applications for someone who could do the job
-with more discipline.
-
-Revert 'add missing locking in cairo-xlib'
-------------------------------------------
-This change was introduced in cairo 1.6.2, but also introduced a bug
-which causes many cairo-xlib applications to crash, (with a
-segmentation fault inside of XSetClipMask). Instead of attempting
-another fix for the broken fix, the change in 1.6.2 has been
-reverted. The original bug which the change was addressing has been
-present since at least cairo 1.4, so it is not expected that leaving
-this bug unfixed will cause any new problems for applications moving
-from cairo 1.4 to cairo 1.6.
-
-At this point, the code of cairo 1.6.4 differs from cairo 1.6.0 only
-in the fix for the PostScript-printer crashes.
-
-Tweak build to avoid linking with g++
--------------------------------------
-Cairo 1.6.4 avoids a quirk in automake that was causing the cairo
-library to be linked with g++ and linked against libstdc++ even when
-only C source files were compiled for the library.
-
-Release 1.6.2 (2008-04-11 Carl Worth <cworth@cworth.org>)
-=========================================================
-The cairo community is pleased (but somewhat sheepish) to announce the
-1.6.2 release of the cairo graphics library. This is an update to
-yesterday's 1.6.0 release with an important fix to prevent cairo's
-PostScript output from crashing some printers. This release also
-includes a locking fix for cairo's xlib backend to improve thread
-safety. There are no changes beyond these two fixes.
-
-Fix for PostScript printer crash
---------------------------------
-Adrian Johnson discovered that cairo 1.6.0 was being a bit hard on
-PostScript printers, by changing the font matrix very frequently. This
-causes some PostScript interpreters to allocate new font objects every
-few glyphs, eventually exhausting available resources. The fix
-involves leaving translational components of the font matrix as zero,
-so that the PostScript interpreter sees an identical font matrix
-repeatedly, and can more easily share internal font object resources.
-
-This fix has been tested to resolve the bugs posted here, (for both
-Xerox and Dell printers):
-
- Printing some PDFs from evince is crashing our Xerox printer
- http://bugs.freedesktop.org/show_bug.cgi?id=15348
-
- Cairo-generated postscript blocks Dell 5100cn
- http://bugs.freedesktop.org/show_bug.cgi?id=15445
-
-Add missing locking in cairo-xlib
----------------------------------
-Chris Wilson noticed that cairo 1.6.0 was manipulating an internal
-cache of GC object within cairo's Xlib backend without proper
-locking. The missing locking could cause failures for multi-threaded
-applications. He fixed this in 1.6.2 by adding the missing locks.
-
-Release 1.6.0 (2008-04-10 Carl Worth <cworth@cworth.org>)
-=========================================================
-The cairo community is quite pleased to announce the 1.6.0 release of
-the cairo graphics library. This is a major update to cairo, with new
-features and enhanced functionality which maintains compatibility for
-applications written using cairo 1.4, 1.2, or 1.0. We recommend that
-anybody using a previous version of cairo upgrade to cairo 1.6.0.
-
-The most significant new features in this release are dramatically
-improved PDF and PostScript[*] output, support for arbitrary X server
-visuals (including PseudoColor), a new Quartz backend, and and a new
-"win32 printing" backend. See below for more details on these and
-other new features.
-
-New dependency on external pixman library (Thanks, Søren!)
-----------------------------------------------------------
-As of cairo 1.6, cairo now depends on the pixman library, for which
-the latest release can be obtained alongside cairo:
-
- http://cairographics.org/releases/pixman-0.10.0.tar.gz
-
-This library provides all software rendering for cairo, (the
-implementation of the image backend as well as any image fallbacks
-required for other backends). This is the same code that was
-previously included as part of cairo itself, but is now an external
-library so that it can be shared by both cairo and by the X server,
-(which is where the code originated).
-
-Improved PDF, PostScript, and SVG output (Thanks, Adrian!)
-----------------------------------------------------------
-Users of the cairo-pdf, cairo-ps, and cairo-svg should see a dramatic
-improvement from cairo 1.2/1.4 to 1.6. With this release there are now
-almost no operations that will result in unnecessary rasterization in
-the PDF and PostScript. Rasterized "image fallbacks" are restricted
-only to minimal portions of the document where something is being
-drawn with cairo that is beyond the native capabilities of the
-document, (this is rare for PDF or SVG, but occurs when blending
-translucent objects for PostScript).
-
-This means that the final output will be of higher quality, and will
-also be much smaller, and therefore will print more quickly. The
-machinery for doing analysis and minimal fallbacks also benefits the
-win32-printing surface described below.
-
-In addition to doing less rasterization, the PostScript and PDF output
-also has several other improvements to make the output more efficient
-and more compatible with specifications.
-
-[*] Note: Just before this release, a bug has been reported that the
-PostScript output from cairo can crash some printers, (so far the
-following models have been reported as problematic Xerox Workcentre
-7228 or 7328 and Dell 5100cn). We will implement a workaround as soon
-as we can learn exactly what in cairo's output these printers object
-to, (and we could use help from users that have access to misbehaving
-printers). This bug is being tracked here:
-
- Printing some PDFs from evince is crashing our Xerox printer
- http://bugs.freedesktop.org/show_bug.cgi?id=15348
-
-New support for arbitrary X server visuals (Thanks, Keith and Behdad!)
-----------------------------------------------------------------------
-As of cairo 1.6, cairo should now work with an arbitrary TrueColor or
-8-bit PseudoColor X server visual. Previous versions of cairo did not
-support these X servers and refused to draw anything. We're pleased to
-announce that this limitation has been lifted and people stuck with
-ancient display systems need no longer be stuck with ancient software
-just because of cairo.
-
-New, supported Quartz backend for Mac OS X (Thanks, Brian and Vladimir!)
-------------------------------------------------------------------------
-As of cairo 1.6, the cairo-quartz backend is now marked as "supported"
-rather than "experimental" as in previous cairo releases. Its API now
-has guarantees of API stability into future cairo releases, and its
-output quality is comparable to other backends. There have been
-significant improvements to cairo-quartz since 1.4. It now uses many
-fewer image fallbacks, (meaning better performance), and has greatly
-improved text rendering.
-
-New, "win32 printing" backend (Thanks, Adrian and Vladimir!)
-------------------------------------------------------------
-A new win32-printing surface has been added with an interface very
-similar to the original win32 surface, (both accept an HDC
-parameter). But this new surface should only be called with a printing
-DC, and will result in all drawing commands being stored into a
-meta-surface and emitted after each page is complete. This allows
-cairo to analyze the contents, (as it does with PDF, PostScript, and
-SVG backends), and to do minimal image-based fallbacks as
-necessary. The analysis keeps things as efficient as possible, while
-the presence of fallbacks, (when necessary), ensure the consistent,
-high-quality output expected from cairo.
-
-Robustness fixes (Thanks, Chris!)
----------------------------------
-There has been a tremendous number of improvements to cairo's
-robustness. Areas that have been improved include:
-
- * Proper reporting of errors
-
- * Responding correctly to invalid input
-
- * Avoiding integer overflows
-
- * Avoiding memory leaks on error-recovery paths
-
- * Making reference counting thread safe
-
- * Exhaustive testing of memory allocation points
-
-Other fixes (Thanks, everybody!)
---------------------------------
-Cairo's internal fixed-point representation has been changed from
-16.16 to 24.8. This has a direct impact on applications as it allows
-much larger objects to be drawn before internal limits in cairo make
-the drawing not work.
-
-The CAIRO_EXTEND_PAD mode is now fully supported by surface
-patterns. This mode allows applications to use cairo_rectangle and
-cairo_fill to draw scaled images with high-quality bilinear filtering
-for the internal of the image, but without any objectionably blurry
-edges, (as would happen with the default EXTEND_NONE and cairo_paint).
-
-Rendering with CAIRO_ANTIALIAS_NONE has been fixed to be more
-predictable, (previously image rendering and geometry rendering would
-be slightly misaligned with respect to each other).
-
-The reference manual at http://cairographics.org/manual now documents
-100% of the functions and types in cairo's public API.
-
-API additions
--------------
-Several small features have been added to cairo with new API functions:
-
-cairo_format_stride_for_width
-
- Must be called to compute a properly aligned stride value before
- calling cairo_image_surface_create_for_data.
-
-cairo_has_current_point
-
- Allows querying if there is a current point defined for the
- current path.
-
-cairo_path_extents
-
- Allows querying for path extents, (independent of any fill or
- stroke parameters).
-
-cairo_surface_copy_page
-cairo_surface_show_page
-
- Allow beginning a new document page without requiring a cairo_t
- object.
-
-cairo_ps_surface_restrict_to_level
-cairo_ps_get_levels
-cairo_ps_level_to_string
-cairo_ps_surface_set_eps
-
- Allow controlling the Post PostScript level, (2 or 3), to
- target, as well as to generate Encapsulated PostScript (EPS).
-
-cairo_quartz_font_face_create_for_cgfont
-
- Create a quartz-specific cairo_font_face_t from a CGFontRef.
-
-cairo_win32_font_face_create_for_logfontw_hfont
-
- Create a win32-specific cairo_font_face from a LOGFONTW and an
- HFONT together.
-
-Thanks, Everyone!
------------------
-I've accounted for 32 distinct people with attributed code added to
-cairo between 1.4.14 and 1.6.0, (their names are below). That's an
-impressive number, but there are certainly dozens more that
-contributed with testing, suggestions, clarifying questions, and
-encouragement. I'm grateful for the friendships that have developed as
-we have worked on cairo together. Thanks to everyone for making this
-all so much fun!
-
-Adrian Johnson, Alp Toker, Antoine Azar, Behdad Esfahbod,
-Benjamin Otte, Bernardo Innocenti, Bertram Felgenhauer,
-Boying Lu, Brian Ewins, Carl Worth, Chris Heath, Chris Wilson,
-Claudio Ciccani, Emmanuel Pacaud, Jeff Muizelaar, Jeremy Huddleston,
-Jim Meyering, Jinghua Luo, Jody Goldberg, Jonathan Gramain,
-Keith Packard, Ken Herron, Kouhei Sutou, Kristian Høgsberg,
-Larry Ewing, Martin Ejdestig, Nis Martensen, Peter Weilbacher,
-Richard Hult, Shailendra Jain, Søren Sandmann Pedersen,
-Vladimir Vukicevic
-
-Snapshot 1.5.20 (2008-04-04 Carl Worth <cworth@cworth.org>)
-===========================================================
-This is the tenth snapshot in cairo's unstable 1.5 series. It comes
-just two days (and only one working day) after the 1.5.18
-snapshot. The quick snapshot is due to two embarrassing bugs (both
-affecting cairo-xlib) that had been introduced in the 1.5.18
-snapshot. The fixes for these are described below along with a few
-other fixes, (which hopefully aren't introducing new bugs this time).
-
-cairo-xlib
-----------
-Revert fix from 1.5.18 to allow pattern expansion based on the filter
-mode. This fix seemed so boring, (the use case it addresses is almost
-never used in practice), that it didn't even get mentioned in the
-1.5.18 release notes. However, the "fix" happened to break rendering
-that is always used resulting in corrupt image rendering in mozilla,
-evolution, and probably everything else that uses cairo.
-
-Fix to avoid BadMatch errors in cairo_surface_create_similar. These
-were introduced, (inadvertently, of course), as part of the fix in
-1.5.18 for creating similar surfaces without the Render
-extension. Again, thanks to mozilla, (and Vladimir Vukicevic in
-particular), for noticing our mistake.
-
-general
--------
-Correctly handle an in-error surface in
-cairo_surface_write_to_png. Previously this function would cause an
-assertion failure if you gave it a finished surface. Now it cleanly
-returns a CAIRO_STATUS_SURFACE_FINISHED result instead.
-
-Avoid potentially infinite wandering through memory inside
-_cairo_hull_prev_valid. Thanks to Jonathan Watt for noticing this
-problem:
-
- https://bugzilla.mozilla.org/show_bug.cgi?id=306649#c21
-
-cairo-pdf
----------
-Fix generation of "soft" masks made by drawing to a similar surface
-and then calling cairo_mask_surface() with it.
-
-cairo-svg
----------
-Fix for code that uses cairo_mask() on an intermediate surface which
-is later passed to cairo_mask_surface().
-
-Snapshot 1.5.18 (2008-04-05 Carl Worth <cworth@cworth.org>)
-===========================================================
-This is the ninth snapshot in cairo's unstable 1.5 series. It comes
-just 4 days after the 1.5.16 snapshot. We had hoped to not need
-another snapshot before the final 1.6.0 release, but several critical
-bugs were found and fixed in the last few days, so we thought it
-important to let people test the fixes with this snapshot. See below
-for details.
-
-documentation
--------------
-The README now lists necessary dependencies.
-
-Various graphics state defaults are now documented, (source pattern is
-opaque black, line width is 2.0, line join is miter, line cap is butt,
-miter limit is 10.0, etc.).
-
-general
--------
-Several cleanups have been made along many error-path returns,
-(carefully propagating up the original error status values, cleaning
-up memory leaks during error recovery, etc.). This is yet another in
-Chris "ickle" Wilson's long series of error-handling cleanups during
-the 1.5 series.
-
-Avoid undesired clipping when drawing scaled surface patterns with
-bilinear filtering.
-
-cairo-pdf
----------
-Fix emission of 1-bit alpha masks in PDF output.
-
-Fix a bug that would cause glyphs to be misplaced along the Y axis:
-
- http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%23474136
-
- Originally, an issue about a crash, but later leading to the
- misplaced glyphs issue being discovered.
-
-cairo-ps
---------
-Fix misplaced glyphs in cairo's PostScript output.
-
- This issue occurs when consecutive glyphs are placed far
- apart. This case is exercised by the new ft-show-glyphs-table test
- case, which was originally inspired by the Debian bug #23474136
- mentioned above.
-
-Fix more misplaced glyphs in cairo's PostScript output:
-
- The issue here showed up under very particular circumstance, (when
- converting a PDF file with a CFF font with CID Identity-H encoding
- and using glyph 0, (defined by the CFF specification as .notdef)
- as a space instead). More concretely, this problem appeared when
- converting the UbuntuDesktop.pdf file mentioned in this bug
- report:
-
- https://bugs.freedesktop.org/show_bug.cgi?id=15348#c3
-
- As usual with arcane font-encoding-specific bugs like this, many
- thanks to Adrian Johnson for his magical ability to dive into
- specifications and emerge almost instantaneously with fixes. And
- thanks to Sebastien Bacher for bringing the bug to our attention.
-
-cairo-xlib
-----------
-Fix serious failure on X servers without the Render extension.
-
- Since the 1.5.14 snapshot (with support for PseudoColor visuals),
- any application attempting to create a "similar" xlib surface would
- fail on an X server without the Render extension. Thanks to
- Frederic Crozat for pointing out that cairo's test suite was
- entirely failing when run against Xvfb.
-
-Avoid crashing cairo-xlib applications for too-large glyphs
-
- Naively sending glyphs of any size to the X server will eventually
- violate the X limit on maximum request sizes. We now properly
- detect when a glyph would be too large and use existing fallbacks
- to render the glyph rather than trying to send it to the X server.
-
-Enable the buggy_repeat workaround for Xorg servers < 1.4
-
- We have determined that Xorg 1.3.0 (as packaged in Fedora 8 at
- least) has a bug that can result in an X server crash when cairo
- uses certain X Render repeat operations, (as exercised by cairo's
- extend-reflect test). We avoid this crash by using fallbacks
- whenever a repeating surface is needed for any Xorg server with a
- version less than 1.4. This is slower, but should prevent the
- crash.
-
- (Meanwhile, there appears to be a separate bug where some X
- servers or specific X-server drivers will use random pixmap data
- when asked to draw a repeating surface. The buggy_repeat
- workaround would also avoid those problems, but we have not yet
- characterized whether the new "version < 1.4" is a good
- characterization of those problems or not.)
-
-cairo-quartz-font
------------------
-Implement cairo_font_extents for this backend.
-
-The cairo-quartz-font implementation added in the 1.5.14 snapshot was
-entirely missing support for the cairo_font_extents function. Thanks to
-Richard Hult for pointing out this obvious shortcoming, (and obvious
-lack of coverage in our test suite):
-
- CGFont backend returns 0 font extents
- https://bugs.freedesktop.org/show_bug.cgi?id=15319
-
-Snapshot 1.5.16 (2008-04-01 Carl Worth <cworth@cworth.org>)
-===========================================================
-This is the eighth snapshot in cairo's unstable 1.5 series. It comes
-less than two weeks after the 1.5.14 snapshot and it really is a
-legitimate snapshot, (in spite of sharing this date with that of many
-bogus announcements). The major change in this snapshot is that the
-cairo-quartz backend is now officially "supported", including new API
-to construct a font face from a CGFontRef . Also several bug fixes
-have been fixed in many backends. See below for details.
-
-general
--------
-Cairo now depends on pixman 0.10.0 which was recently released. The
-latest pixman release can always be found alongside cairo releases at:
-
- http://cairographics.org/releases
-
-Increase the precision of color stops for gradients. This fixes a
-regression in gradient rendering that had been present since the
-1.5.12 snapshot.
-
-paginated (all of ps, pdf, svg, and win32-printing)
----------------------------------------------------
-Fix assertion failure when some drawing elements are outside the page
-boundaries, (this bug was noticed when using Inkscape to print a
-drawing with landscape orientation to a portrait-oriented piece of
-paper).
-
-cairo-ps
---------
-Fix of bug causing incorrect glyph positioning.
-
-Fix handling of CAIRO_OPERATOR_SOURCE.
-
-cairo-pdf
----------
-More reduction of unnecessary digits of precision in PDF output.
-
-Fix handling of CAIRO_OPERATOR_SOURCE.
-
-cairo-svg
----------
-Fix bug in usage of libpng that was preventing cairo_mask from working
-with the svg backend.
-
-Fix transformation of source pattern for cairo_stroke().
-
-cairo-win32-printing
---------------------
-Fix fallback resolution, (thanks again to inkscape users/developers
-for helping us find this one).
-
-cairo-quartz
-------------
-Mark the cairo-quartz backend as "supported" rather than
-"experimental". This means the following:
-
- * The backend will now be built by default (if possible).
-
- * We are committing that the backend-specific API (as published in
- cairo-quartz.h) are stable and will be supported in all future
- cairo 1.x releases.
-
- * We are committing that the output quality of this backend
- compares favorably with other cairo backends, (and that quality
- is ensured by good results from the cairo test suite).
-
- * We recommend that distributions build and distribute this
- backend when possible.
-
-Note that the cairo_quartz_image API (in cairo-quartz-image.h) is
-still experimental, will not build by default, (pass
---enable-quartz-image to configure to build it), and may see API
-changes before it is marked as "supported" in a future release.
-
-Put the CAIRO_FONT_TYPE_ATSUI name back into
-cairo-deprecated.h. Without this, the cairo 1.5.14 snapshot broke all
-builds for applications using the C++ cairomm bindings (and perhaps
-others) which have the CAIRO_FONT_TYPE_ATSUI name in their header
-files. This breakage happened even for applications not using
-cairo-quartz at all.
-
- Note: Even though the CAIRO_FONT_TYPE_ATSUI name is provided to
- avoid this build breakage, we still recommend that bindings and
- applications move to the new, and more accurate,
- CAIRO_FONT_TYPE_QUARTZ name.
-
-Replace the implementation of cairo-quartz-font to use CFFont instead
-of ATSUI. The CGFont API is a better fit than ATSUI, and this new
-implementation is also more correct than the old one as well.
-
-This also adds the following new API call:
-
- cairo_public cairo_font_face_t *
- cairo_quartz_font_face_create_for_cgfont (CGFontRef font);
-
-The previous cairo_quartz_font_face_create_for_atsu_font_id function
-continues to exist and is part of the supported API going
-forward. (However, the old name of that same function, which was
-cairo_atsui_font_face_create_for_atsu_font_id is officially
-deprecated. Any source code using the old name should be updated to
-use the new name.)
-
-Fix transformation of source pattern for cairo_stroke().
-
-cairo-win32
------------
-Avoid crash in create_similar is cairo_win32_surface_create fails.
-
-Snapshot 1.5.14 (2008-03-20 Carl Worth <cworth@cworth.org>)
-===========================================================
-This is the seventh snapshot in cairo's unstable 1.5 series. It comes
-3 weeks after the 1.5.12 snapshot. This snapshot includes support for
-arbitrary X server visuals, (including PseudoColor), which was the
-final remaining cairo-specific item on the cairo 1.6 roadmap. It also
-includes a huge number of improvements to the cairo-quartz backend. So
-this is effectively a cairo 1.6 release candidate. We expect very few
-changes from now until 1.6 and only for specific bug fixes.
-
-API Change
-----------
-Rename ATSUI font backend to Quartz font backend. This affects the
-following usage:
-
- --enable-atsui -> --enable-quartz-font
- CAIRO_HAS_ATSUI_FONT -> CAIRO_HAS_QUARTZ_FONT
- CAIRO_FONT_TYPE_ATSUI -> CAIRO_FONT_TYPE_QUARTZ
-
- cairo_atsui_font_face_create_for_atsu_font_id ->
- cairo_quartz_font_font_create_for_atsu_font_id
-
-This API change is justified by the cairo-quartz backend still be
-marked as "experimental" rather than "supported", (though this is one
-step toward making the change to "supported" before 1.6). Cairo will
-still provide ABI compatibility with the old symbol name, however.
-
-paginated (all of ps, pdf, svg, and win32-printing)
----------------------------------------------------
-Optimize by not analyzing an image surface for transparency more than
-once, (previously all images were analyzed twice).
-
-cairo-ps and cairo-pdf
-----------------------
-Avoiding emitting a matrix into the stroke output when unnecessary,
-(making output size more efficient).
-
-Reduce rounding error of path shapes by factoring large scale factors
-out of the path matrix, (ensuring that a fixed-number of printed
-digits for path coordinates contains as much information as possible).
-
-Reduce excess digits for text position coordinates. This makes the
-output file size much smaller without making the result any less
-correct.
-
-cairo-ps
---------
-Eliminate bug causing extraneous text repetition on Linux PostScript
-output in some cases.
-
- See: Mozilla Bug 419917 – Printed page contents are reflected
- inside bordered tables (Linux-only)
-
- https://bugzilla.mozilla.org/show_bug.cgi?id=419917
-
-Optimize output when EXTEND_PAD is used.
-
-cairo-pdf
----------
-Fix to not use fill-stroke operator with transparent fill, (else PDF
-output doesn't match the cairo-defined correct result). See:
-
- https://bugs.launchpad.net/inkscape/+bug/202096
-
-cairo-svg
----------
-Fix stroke of path with a non-solid-color source pattern:
-
- http://bugs.freedesktop.org/show_bug.cgi?id=14556
-
-cairo-quartz
-------------
-Fix text rendering with gradient or image source pattern.
-
-Handling antialiasing correctly for cairo_stroke(), cairo_clip(), and
-cairo_show_text()/cairo_show_glyphs().
-
-Correctly handle gradients with non-identity transformations:
-
- Fixes http://bugs.freedesktop.org/show_bug.cgi?id=14248
-
-Add native implementation of REPEAT and REFLECT extend modes for
-gradients.
-
-Fix implementation for the "unbounded" operators, (CAIRO_OPERATOR_OUT,
-_IN, _DEST_IN, and _DEST_ATOP).
-
-Correctly handle endiannees in multi-architecture compiles on Mac OS
-X.
-
-Avoid behavior which would cause Core Graphics to print warnings to
-the console in some cases.
-
-cairo-win32
------------
-Fix handling of miter limit.
-
-cairo-win32-printing
---------------------
-Fix to not use a 1bpp temporary surface in some cases while printing,
-(so grayscale data is preserved rather than just becoming black and
-white).
-
-cairo-xlib
-----------
-Add support for rendering to arbitrary TrueColor X server
-visuals. This fixes at least the following bugs:
-
- cairo doesn't support 8-bit truecolor visuals
- https://bugs.freedesktop.org/show_bug.cgi?id=7735
-
- cairo doesn't support 655 xlib format
- https://bugs.freedesktop.org/show_bug.cgi?id=9719
-
-Add support for rendering to 8-bit PseudoColor X server visuals. This
-fixes the following bug:
-
- Cairo doesn't support 8-bit pseudocolor visuals
- https://bugs.freedesktop.org/show_bug.cgi?id=4945
-
-Snapshot 1.5.12 (2008-02-28 Carl Worth <cworth@cworth.org>)
-===========================================================
-This is the sixth snapshot in cairo's unstable 1.5 series. It comes 1
-week after the 1.5.10 snapshot. This snapshot includes the
-long-awaited change from 16.16 to 24.8 fixed-point values, (see below
-for why you should care). It also includes several backend-specific
-bug fixes.
-
-24.8 fixed-point format
------------------------
-Cairo has always converted path coordinates to a fixed-point
-representation very early in its processing. Historically, this has
-been a 32-bit representation with 16 bits of integer for the
-device-pixel grid and 16 bits of sub-pixel positioning. The choice of
-16 bits for the integer coordinate space was based on the 16-bit limit
-for X Window drawables.
-
-This 16-bit limit has proven problematic for many applications. It's
-an especially vexing problem when targeting non-X backends that don't
-have any 16-bit restriction. But even when targeting cairo-xlib, it's
-often desirable to draw a large shape, (say a background rectangle),
-that extends beyond the surface bounds and expect it to fill the
-surface completely, (rather than overflowing and triggering random
-behavior).
-
-Meanwhile, nobody has ever really needed 16 bits of sub-pixel
-precision.
-
-With this snapshot, the fixed-point system is still in place and is
-still using a 32-bit representation, (future versions of cairo might
-move entirely to floating-point when targeting PDF output for
-example). But the representation now provides 24 bits of pixel
-addressing and only 8 bits of sub-pixel positioning. This should give
-a much less stifling space to many applications.
-
-However, the underlying pixman library still has 16-bit limitations in
-many places, (it has its roots in the X server as well). Until those
-are also fixed, applications targeting cairo image surfaces, or
-hitting software fallbacks when targeting other surfaces will still
-encounter problems with device-space values needing more than 16
-integer bits.
-
-generic fixes
--------------
-Add a few tests to the test suite to increase coverage.
-
-Cleanup a few error-handling paths, (propagate error correctly).
-
-cairo-ft
---------
-Fix handling of font sizes smaller than 1 device pixel.
-
-cairo-pdf
----------
-Fix to properly save/restore clip when analyzing meta-surface
-patterns, (fixing a couple of test-suite failures).
-
-Implement native support for CAIRO_OPERATOR_SOURCE when the source
-pattern is opaque.
-
-Emit rectangles as PDF rectangles ("re" operator) rather than as
-general paths.
-
-cairo-ps
---------
-Fix to work properly with the 16.16->24.8 change.
-
-cairo-svg
----------
-Fix CAIRO_EXTEND_REFLECT by using an image fallback, (there's no
-direct SVG support for reflected patterns).
-
-Fix the use of alpha-only masks, (such as CAIRO_FORMAT_A8).
-
-cairo-quartz
-------------
-Add new API for efficiently using image data as a source:
-
- cairo_surface_t *
- cairo_quartz_image_surface_create (cairo_surface_t *image_surface);
-
- cairo_surface_t *
- cairo_quartz_image_surface_get_image (cairo_surface_t *surface);
-
-For full documentation, see:
-
- http://cairographics.org/manual/cairo-Quartz-Surfaces.html#cairo-quartz-image-surface-create
-
-Several fixes for cairo_mask().
-
-cairo-atsui
------------
-Change default from from Monaco to Helvetica to be more consistent
-with other font backends.
-
-Snapshot 1.5.10 (2008-02-20 Carl Worth <cworth@cworth.org>)
-===========================================================
-This is the fifth snapshot in cairo's unstable 1.5 series. It comes 3
-weeks after the 1.5.8 snapshot. This snapshot adds one new API
-function, (cairo_has_current_point), and the usual mix of
-improvements, (more efficient PostScript/PDF output, optimized
-stroking), and fixes (more robust error-handling, etc.). See below for
-details.
-
-New API
--------
-Add a new function to query if there is a current point:
-
- cairo_bool_t
- cairo_has_current_point (cairo_t *cr);
-
-There is no current point immediately after cairo_create(), nor after
-cairo_new_path() or cairo_new_sub_path(). There is a current point
-after any of the path-creation functions, (cairo_move_to,
-cairo_line_to, cairo_curve_to, etc.).
-
-With this new function, we also revert the change of the return type
-of cairo_get_current_point from cairo 1.5.8, (it's now a void function
-again).
-
-Optimizations
--------------
-Optimize stroking code to avoid repeated calculation of redundant
-values, (particularly significant for very large, offscreen paths).
-
-General fixes
--------------
-Patch a few more potential buffer overruns, (due to integer
-overflow).
-
-Many fixes and improvements to cairo's error-handling, (ensure that
-correct error values are returned, clean up memory leaks on
-error-handling paths, etc.).
-
-Fix a potential infinite loop when stroking a spline with a pen that
-has been transformed to a line segment.
-
-Remove treating NULL as a synonym for a valid cairo_font_options_t*
-with default values, (a change that had been introduced as of cairo
-1.5.8).
-
-Remove the altered handling of tolerance and fallback-resolution that
-had been introduced as of cairo 1.5.4.
-
-cairo-xlib
-----------
-Pass the original Drawable, (as opposed to the root window), to
-XCreatePixmap when creating a similar surface. This gives the X server
-more information so that it can be clever and efficient.
-
-cairo-pdf
----------
-Fix the rendering of repeating and reflecting patterns.
-
-Ensure miter limit is always >= 1, (smaller limits are not meaningful,
-but they can cause some PDF viewers to fail to display pages).
-
-Generate more efficient output when the same path is used for both
-fill and stroke.
-
-cairo-ps
---------
-Start sharing much of the cairo-pdf code rather than implementing very
-similar code in cairo-ps.
-
-Implement native support for repeating and reflecting linear
-gradients.
-
-Implement reflected surface patterns.
-
-Ensure miter limit is always >= 1, (smaller limits are not meaningful,
-but they can cause some PostScript viewers to crash).
-
-Generate PostScript that will perform more efficiently and use less
-memory on printers, (use currentfile instead of a giant string array
-for image data, and avoid using PostScript patterns for paint() and
-fill() when possible).
-
-cairo-svg
----------
-Avoid unnecessary rasterization when copying a "similar" surface to
-another svg surface, (allow the SOURCE operator to be implemented with
-all-vector operations if there are no underlying objects).
-
-cairo-atsui
------------
-Eliminate infinite loop when attempting to render an empty string.
-
-Snapshot 1.5.8 (2008-01-30 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the fourth snapshot in cairo's unstable 1.5 series. It comes 2
-weeks after the 1.5.6 snapshot. It adds a few new API functions. Most
-notably all callers of cairo_image_surface_create_for_data should now
-be calling cairo_format_stride_for_width to compute a legal stride
-value. See below for more details.
-
-New API in cairo 1.5.8
-----------------------
-We've added a new function that should be called to compute a legal
-stride value before allocating data to be used with
-cairo_image_surface_create_for_data:
-
- int
- cairo_format_stride_for_width (cairo_format_t format,
- int width);
-
-We've also added a new cairo_path_extents function that can be used to
-compute a bounding box for geometry such as a single line segment,
-(contrast with cairo_path_extents and cairo_stroke_extents):
-
- void
- cairo_path_extents (cairo_t *cr,
- double *x1, double *y1,
- double *x2, double *y2);
-
-And finally, we've added a function to allow for querying the
-XRenderPictFormat of a cairo-xlib surface:
-
- XRenderPictFormat *
- cairo_xlib_surface_get_xrender_format (cairo_surface_t *surface);
-
-API changes
------------
-Fix return types of cairo_surface_show_page and
-cairo_surface_copy_page. This is an API change to functions that are
-new in the 1.5 series, so not an API break compared to any stable
-cairo release, (1.0.x, 1.2.x, 1.4.x).
-
-Change the return type of cairo_get_current_point() from void to
-cairo_status_t. This allows the caller to receive a
-CAIRO_STATUS_NO_CURRENT_POINT value to distinguish the a current point
-at the origin from no current point existing.
-
-Performance improvement
------------------------
-Improve performance of clipping by using an optimized code path
-internally, (with the ADD operator instead of IN).
-
-General bug fixes
------------------
-Fix various cairo_*_extents functions to initialize the return-value
-variables even in the case of a cairo_t in error.
-
-Treat NULL as a legitimate value for cairo_font_options_t*. [NOTE:
-On discussion afterwards, we decided against this change so it has
-been removed as of cairo 1.5.10.]
-
-Fix rendering with CAIRO_ANTIALIAS_NONE to be more predictable, (that
-is, to avoid seams appearing when geometry and imagery share an
-identical edge). Portions of this fix are in the pixman library and
-will appear in a future release of that library.
-
-Avoid triggering an error for a font size of 0.
-
-Miscellaneous changes
----------------------
-Require pixman >= 0.9.6.
-
-There has been a tremendous amount improvement to cairo's
-documentation. We're delighted that 100% of the public API has at
-least some documentation in the API reference manual. Many thanks to
-Behdad Esfahbod and Nis Martensen for leading this effort.
-
-cairo-pdf and cairo-ps
-----------------------
-Eliminate failure when a Type 1 font is embedded with an explicit
-glyph 0.
-
-cairo-pdf
----------
-Implement a more correct and more efficient approach for patterns with
-an extend mode of CAIRO_EXTEND_REFLECT.
-
-cairo-ps
---------
-Fix image masks to properly pack and pad mask bits.
-
-cairo-quartz
-------------
-Take care to only use DrawTiledImage for integer-aligned images, (and
-use slower paths to get the correct result in other cases).
-
-cairo-win32
------------
-Fix for older versions of mingw.
-
-Improve the handling of the clipping with the win32 and win32-printing
-surfaces.
-
-Fix rendering of non black/white text.
-
-Snapshot 1.5.6 (2008-01-15 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the third snapshot in cairo's unstable 1.5 series. It comes
-about 6 weeks after the 1.5.4 snapshot. The only API addition compared
-to 1.5.4 is very minor, (a new value CAIRO_STATUS_TEMP_FILE_ERROR).
-The remainder of the changes are the usual accumulation of bug fixes
-and improvements. See below for details.
-
-General bug fixes
------------------
-Fix handling of fonts that contain a mixture of outline and bitmapped
-glyphs. There was a change in this handling in 1.5.4 that improved
-some cases and also regressed other cases. Now, all cases should be
-handled quite well.
-
-Fix alignment issues that were causing SIGBUS failures on SPARC.
-
-Fix a regression (which first appeared in 1.5.2) where stroking under
-a large scale would sometimes incorrectly replace a miter join with a
-bevel join. (Thanks to Keith Packard.)
-
-Fix reporting of zero-sized extents to be {0,0} rather than
-{INT_MAX,INT_MIN}. This avoids several integer overflow and
-allocations of massive regions in some cases.
-
-Fix failures of gradients with no stops, (quartz, ps, and pdf).
-
-Fix handling of Type 1 fonts on Windows platforms.
-
-Fix handling of Type 1 fonts with no specific family name in the font
-itself, (generate a CairoFont-x-y name).
-
-Handle NULL string values in cairo_show_text, cairo_show_glyphs, and
-friends.
-
-Many robustness improvements along error-handling paths, (thanks as
-always, to Chris "ickle" Wilson).
-
-Various other minor fixes.
-
-Paginated backends (PDF/PostScript/win32-printing)
---------------------------------------------------
-Avoid unnecessary rasterization when using a paginated surface as a
-source, (such as drawing from one pdf surface to another).
-
-Fix replaying of paginated surface with more than one level of push/pop
-group.
-
-cairo-xlib
-----------
-Fix xlib backend to not consider recent X server release as having a
-buggy repeat implementation in the Render extension.
-
-cairo-pdf
----------
-Fix PDF output to avoid triggering very slow rendering in PDF viewers,
-(avoid starting and stopping the content stream for each pattern
-emission).
-
-Support CAIRO_OPERATOR_SOURCE in cases where there is nothing below
-the object being drawn.
-
-Fix to avoid seams appearing between multiple fallback regions.
-
-cairo-ps (PostScript)
----------------------
-Use correct bounding box in Type 3 fonts.
-
-Fix several bugs in cairo's PostScript output. These include making
-the PostScript output more compatible with recent versions of
-ghostscript that are more strict about Type 3 fonts, for
-example.
-
-Fix for win32 to not attempt to create temporary files in the root
-directory, (where the user may not have write permission).
-
-Avoid generating Level 3 PostScript if Level 2 is sufficient. Also,
-add code in output documents to alert the user if Level 3 PostScript
-is handed to a device that cannot handle PostScript beyond Level
-2.
-
-cairo-directfb
---------------
-Various performance optimizations.
-
-Fixed support for small surfaces (less than 8x8).
-
-Provide support for environment variables CAIRO_DIRECTFB_NO_ACCEL to
-disable acceleration and CAIRO_DIRECTFB_ARGB_FONT to enable ARGB fonts
-instead of A8.
-
-cairo-os2
----------
-Allow OS/2 APIs instead of C library allocation functions.
-
-Snapshot 1.5.4 (2007-12-05 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the second snapshot in cairo's unstable 1.5 series. It comes
-just over 1 month after the 1.5.2 snapshot. There are no API changes
-or additions in 1.5.4 compared to 1.5.2, but there are several bug
-fixes, and some optimizations. Most of these apply to particular
-backends. See below for details.
-
-General improvements
---------------------
-Use less memory for spline approximation calculations.
-
-Change how the tolerance value is interpreted with regard to
-fallback-resolution. [Note: On further discussion, we decided against
-this change for now. It is removed as of cairo 1.5.10.]
-
-Fix precision of floating-point values in vector-output backends to
-avoid rounding errors with very small numbers.
-
-Xlib improvements
------------------
-Fix bug in glyph rendering with xlib, (due to everything being clipped
-out). This was a regression in the 1.5.2 snapshot that was visible in
-the GIMP, for example. See:
-
- cairo 1.5.2 causes font problems in GIMP 2.4 status bar and evolution 2.12.1
- https://bugs.freedesktop.org/show_bug.cgi?id=13084
-
-PostScript improvements
------------------------
-Fix bug leading to invalid PostScript files when rendering
-text, (need "0 0 xyshow" instead of "0 xyshow").
-
-Fix many issues with Type 3 fonts, including making the resulting text
-extractable.
-
-Quartz improvements
--------------------
-Fix font metrics height value for ATSUI, (helps webkit on GTK+ OS X
-layout nicely).
-
-Fix gradients.
-
-Fix EXTEND_NONE mode for patterns.
-
-Fix cairo_quartz_surface_create to properly clear the new surface
-in cairo_quartz_surface_create.
-
-Fix to correctly handle 0x0 sized surfaces.
-
-Optimize drawing of ExtendMode::REPEAT patterns for OS X 10.5.
-
-Snapshot 1.5.2 (2007-10-30 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the first snapshot in cairo's unstable 1.5 series. It comes 4
-months after the 1.4.10 release. This snapshot includes significant
-improvements to PDF and PostScript output, which is one of the things
-in which we're most interested in getting feedback. There are a couple
-of minor API additions, and several optimizations, (primarily in the
-"print/vector" backends). And there are dozens of bug fixes and
-robustness improvements.
-
-New dependency on external pixman library
------------------------------------------
-A significant change in this snapshot compared to all previous cairo
-releases is that cairo now depends on an external "pixman" library for
-its software rendering. Previously this same code was compiled
-internally as part of cairo, but now the code is separate so that both
-cairo and the X server can now share common code, (thanks very much to
-Søren Sandmann for his work on separating pixman and maintaining it).
-
-So users will need to acquire and build pixman before being able to
-build cairo. The current release is 0.9.6 and can be obtained from
-here:
-
- http://cairographics.org/releases/pixman-0.9.6.tar.gz
-
- which can be verified with:
-
- http://cairographics.org/releases/pixman-0.9.6.tar.gz.sha1
- 66f01a682c64403a3d7a855ba5aa609ed93bcb9e pixman-0.9.6.tar.gz
-
- http://cairographics.org/releases/pixman-0.9.6.tar.gz.sha1.asc
- (signed by Carl Worth)
-
-Major PDF/PostScript improvements
----------------------------------
-Adrian Johnson has done some long-awaited work to make cairo's PDF and
-PostScript output more interesting than ever before. First, many
-operations that previously triggered image fallbacks will now be
-rendered as native vectors. These operations include:
-
- PDF: cairo_push_group, cairo_surface_create_similar,
- cairo_mask, A8/A1 surface sources, repeating/reflecting linear
- gradients.
-
- PostScript: cairo_push_group, cairo_surface_create_similar,
- gradients, bilevel alpha masks, (for example, all values either 0 or
- 255 for an A8 mask).
-
-Not only that, but when an image fallback is required, it will now be
-limited to only the necessary region. For example, a tiny translucent
-image overlaying a small portion of text would previously caused an
-entire PostScript page to be rendered as a giant image. Now, the
-majority of that page will be nice text, and there will only be a tiny
-image in the output.
-
-Additionally, the PostScript output now carefully encodes text so that
-if it is subsequently converted to PDF, the text will be
-selectable.
-
-This is very exciting progress, and we're hoping to hear from users
-during the 1.5 series about how things have improved, (for example,
-inkscape users doing cairo-based PDF export: please let us know how
-things look). And feel free to pass your thanks along to Adrian for his excellent work.
-
-NOTE: This much improved PDF output makes more sophisticated use of
-functionality in the PDF specification. This means that cairo's output
-will sometimes expose bugs in some free software PDF viewers, (evince,
-poppler, and xpdf, for example), that are not yet ready for such PDF
-files. We're working with the poppler maintainers to get these bugs
-fixed as quickly as possible. In the meantime, please double-check
-with other PDF viewers if cairo-generated PDF files are not being
-rendered correctly. It may be due to a bug in the viewer rather than
-in the PDF file that cairo has created.
-
-Robustness improvements
------------------------
-Chris Wilson has made the largest contribution by far to cairo 1.5.2,
-(in number of commits). His more than 150 commits include a huge
-number of fixes to increase cairo's robustness. These fixes make cairo
-more robust against invalid and degenerate input, (NaN, empty path,
-etc.), against size-0 malloc calls, against memory leaks on
-error-recovery paths, and against other failures during error
-handling. He also implemented atomic operations to cairo, and used
-them to fix cairo's previously non-thread-safe reference counting,
-again improving robustness.
-
-Chris has put a tremendous amount of time and effort into writing
-analysis tools for this work, and in running those tools and fixing
-the problems they report. We're very grateful for this work, and hope
-that all cairo users appreciate the more robust implementation that
-results from it.
-
-This work is largely thankless, so it might make sense to notice
-sometime that cairo has been running quite smoothly for you, and when
-you do, send a quick "thank you" off to Chris Wilson, since it
-is all definitely running smoother thanks to his work.
-
-New API
--------
-There are no major additions to cairo's core API. The only new,
-generic functions are:
-
- void
- cairo_surface_copy_page (cairo_surface_t *surface);
-
- void
- cairo_surface_show_page (cairo_surface_t *surface);
-
-which can now be used much more conveniently than the existing
-cairo_copy_page and cairo_show_page functions in some
-situations. These functions act identically, but require only a
-cairo_surface_t* and not a cairo_t*.
-
-All other API additions are specific to particular backends.
-
-New cairo-win32 API (new font face function and "win32 printing" surface)
--------------------------------------------------------------------------
-There is a new function for creating a win32 font face for both a
-logfontw and an hfont together. This complements the existing
-functions for creating a font face from one or the other:
-
- cairo_font_face_t *
- cairo_win32_font_face_create_for_logfontw_hfont (LOGFONTW *logfont,
- HFONT font);
-
-There is also a new "win32 printing" surface:
-
- cairo_surface_t *
- cairo_win32_printing_surface_create (HDC hdc);
-
-This interface looks identical to the original
-cairo_win32_surface_create, (both accept and HDC), but the behavior of
-this new surface is very different. It should only be called with a
-printing DC, and will result in all drawing commands being stored into
-a meta-surface and emitted after each page is complete, with analysis
-to do as minimal image-based fallbacks as necessary. The behavior and
-implementation shares much with the PDF and PostScript backends.
-
-New cairo-ps API (EPS and PostScript level control)
----------------------------------------------------
-An often requested feature has been the ability to generate
-Encapsulated PostScript (EPS) with cairo. We have that now with the
-following very simple API. Just do cairo_ps_surface_create as usual
-then call this function with a true value:
-
- void
- cairo_ps_surface_set_eps (cairo_surface_t *surface,
- cairo_bool_t eps);
-
-[NOTE: As always with snapshots, it's possible---though not very
-likely---that the API could still be modified before a final
-release. For example, this is the first public cairo function that
-accepts a Boolean parameter. I'm generally opposed to Boolean
-parameters, but this is probably the one case where I'm willing to
-accept one, (namely a "set" function that accepts a single Boolean).]
-
-Also, it is now possible to control what PostScript level to target,
-(either level 2 or level 3), with the following new API:
-
- typedef enum _cairo_ps_level {
- CAIRO_PS_LEVEL_2,
- CAIRO_PS_LEVEL_3
- } cairo_ps_level_t;
-
- void
- cairo_ps_surface_restrict_to_level (cairo_surface_t *surface,
- cairo_ps_level_t level);
-
- void
- cairo_ps_get_levels (cairo_ps_level_t const **levels,
- int *num_levels);
-
- const char *
- cairo_ps_level_to_string (cairo_ps_level_t level);
-
-Improvement for cairo-quartz
-----------------------------
-Brian Ewins had contributed several improvements to cairo-quartz. These
-include an implementation of EXTEND_NONE for linear and radial
-gradients, (so this extend mode will no longer trigger image fallbacks
-for these gradients), as well as native surface-mask clipping, (only
-on OS X 10.4+ where the CGContextClipToMask function is available).
-
-He also fixed a semantic mismatch between cairo and quartz for dashing
-with an odd number of entries in the dash array.
-
-We're grateful for Brian since not many quartz-specific improvements
-to cairo would be happening without him.
-
-Optimizations
--------------
-Optimize SVG output for when the same path is both filled and stroked,
-and avoid unnecessary identity matrix in SVG output. (Emmanuel Pacaud).
-
-Optimize PS output to take less space (Ken Herron).
-
-Make PS output more compliant with DSC recommendations (avoid initclip
-and copy_page) (Adrian Johnson).
-
-Make PDF output more compact (Adrian Johnson).
-
-Release glyph surfaces after uploading them to the X server, (should
-save some memory for many xlib-using cairo application). (Behdad
-Esfahbod).
-
-Optimize cairo-win32 to use fewer GDI objects (Vladimir Vukicevic).
-
-win32-printing: Avoid falling back to images when alpha == 255
-everywhere. (Adrian Johnson).
-
-win32-printing: Avoid falling back for cairo_push_group and
-cairo_surface_create_similar. (Adrian Johnson)
-
-Bug fixes
----------
-Avoid potential integer overflows when allocating large buffers
-(Vladimir Vukicevic).
-
-Preparations to allow the 16.16 fixed-point format to change to
-24.8 (Vladimir Vukicevic).
-
-Fix bugs for unsupported X server visuals (rgb565, rgb555, bgr888, and
-abgr8888). (Carl Worth and Vladimir Vukicevic)
-
-Fix bugs in PDF gradients (Adrian Johnson).
-
-Fix cairo-xlib to build without requiring Xrender header
-files (Behdad Esfahbod).
-
-Make cairo more resilient in the case of glyphs not being available in
-the current font. (Behdad Esfahbod)
-
-Prevent crashes when both atsui and ft font backends are compiled in
-(Brian Ewins).
-
-Make font subsetting code more robust against fonts that don't include
-optional tables (Adrian Johnson).
-
-Fix CFF subsetting bug, (which manifested by generating PDF files that
-Apple's Preview viewer could not read) (Adrian Johnson).
-
-Fixed error handling for quartz and ATSUI backends (Brian Ewins).
-
-Avoid rounding problems by pre-transforming to avoid integer-only
-restrictions on transformation in GDI (Adrian Johnson).
-
-Fixed an obscure bug (#7245) computing extents for some stroked
-paths (Carl Worth).
-
-Fix crashes due to extreme transformation of the pen, (seems to show
-up in many .swf files for some reason) (Carl Worth).
-
-Release 1.4.10 (2007-06-27 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the fifth update in cairo's stable 1.4 series. It comes
-roughly three weeks after the 1.4.8 release. The most significant
-change in this release is a fix to avoid an X error in certain cases,
-(that were causing OpenOffice.org to crash in Fedora). There is also a
-semantic change to include child window contents when using an xlib
-surface as a source, an optimization when drawing many rectangles, and
-several minor fixes.
-
-Eliminate X errors that were killing OO.o (Chris Wilson)
---------------------------------------------------------
-Cairo is fixed to avoid the X errors propagated when cleaning up
-Render Pictures after the application had already destroyed the
-Drawable they reference. (It would be nice if the X server wouldn't
-complain that some cleanup work is already done, but there you have
-it.) This fixes the bug causing OpenOffice.org to crash as described
-here:
-
- XError on right click menus in OOo.
- https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=243811
-
-Use IncludeInferiors when using xlib surface as a source (Ryan Lortie)
-----------------------------------------------------------------------
-When an xlib surface is used as the source of a draw operation the
-contents of child windows are now included in the source data. The
-semantics of drawing to xlib surfaces are unchanged (ie: draws are
-still clipped by child windows overlapping the destination window).
-
-Optimize drawing of many rectangles (Vladimir Vukicevic)
---------------------------------------------------------
-Avoid O(N*N) loop when filling many axis-aligned rectangles, (either
-many rectangles as separate sub-paths or due to dashing).
-
-Miscellaneous fixes
--------------------
-Fix cairo-perf on Solaris by linking to librt. (Behdad Esfahbod)
-
-Fix make check for systems that require executable files to have a
-particular extension. (Behdad Esfahbod)
-
-Eliminate some warnings in cairo-quartz. (Brian Ewins)
-
-Fix build-breaking typo for cairo-directfb. (Chris Wilson)
-
-Release 1.4.8 (2007-06-07 Carl Worth <cworth@cworth.org>)
-=========================================================
-This is the fourth update in cairo's stable 1.4 series. It comes just
-over five weeks after the 1.4.6 release. This release includes a
-thread-safe surface-cache for solid patterns which significantly
-improves text rendering with the xlib backend. Also, dozens of error
-paths in cairo have been fixed thanks to extensive fault-injection
-testing by Chris Wilson.
-
-Surface cache for solid patterns
---------------------------------
-Originally written by Jorn Baayen, the introduction of a small cache
-for surfaces created for solid patterns improves performance
-dramatically. For example, this reduces the volume of X requests
-during text rendering to the same level as Xft.
-
-This cache first made its appearance in a 1.3.x snapshot, but was
-removed before appearing in any previous major release due to
-complications with multi-threaded programs. For example, programs like
-evince that would carefully restrict usage of cairo-xlib to a single
-thread were unpleasantly surprised to find that using cairo-image in a
-separate thread could trigger X requests.
-
-Behdad Esfahbod designed a fix which was implemented by Chris
-Wilson. Now, the necessary X requests are queued up until the next
-time the application directly operates on an xlib surface.
-
-Improved error handling paths
-------------------------------
-Chris Wilson continued the excellent work he started in cairo 1.4.4 to
-make cairo much more robust against out-of-memory and other errors. He
-applied his memory allocation fault injection cairo's main test suite,
-(previously he had applied it to cairo's performance suite).
-
-Chris's testing found dozens of bugs which he fixed. Many of these
-bugs had perhaps never been hit by any users. But at least one was
-hit by the gnome-about program which resulted in dozens of duplicated
-bug reports against that program:
-
- http://bugzilla.gnome.org/show_bug.cgi?id=431990
-
-We were very pleasantly surprised to see this bug get fixed as a
-side-effect of Chris's work. Well done, Chris!
-
-Other fixes
------------
-Cleanup of mutex declarations (Behdad Esfahbod)
-
-Remove unnecessary clip region from SVG output (Emmanuel Pacaud)
-
-Remove Xsun from the buggy_repeat blacklist (Elaine Xiong)
-
-ATSUI: Fix glyph measurement: faster and more correct (Brian Ewins)
-
-Quartz: fixed 'extend' behaviour for patterns, improved pattern performance,
-and a few smaller correctness fixes. (Brian Ewins, Vladimir Vukicevic)
-
-Release 1.4.6 (2007-05-01 Carl Worth <cworth@cworth.org>)
-=========================================================
-This is the third update in cairo's stable 1.4 series. It comes a
-little less than three weeks since the 1.4.4 release. This release
-fixes the broken mutex initialization that made cairo 1.4.4 unusable
-on win32, OS/2, and BeOS systems. This release also adds significant
-improvements to cairo's PDF backend, (native gradients!), and a couple
-of performance optimizations, (one of which is very significant for
-users of the xlib backend). See below for more details.
-
-Repaired mutex initialization
------------------------------
-We apologize that cairo 1.4.4 did little more than crash on many
-platforms which are less-frequently used by the most regular cairo
-maintainers, (win32, OS/2, and BeOS). The mutex initialization
-problems that caused those crashes should be fixed now. And to avoid
-similar problems in the future, we've now started posting pre-release
-snapshots to get better testing, (subscribe to cairo@cairographics.org
-if you're interested in getting notified of those and testing them).
-
-PDF Improvements
-----------------
-Thanks to Adrian Johnson, (cairo PDF hacker extraordinaire), we have
-several improvements to cairo's PDF backend to announce:
-
-Native gradients:
-
- As of cairo 1.4.6, cairo will now generate native PDF gradients in
- many cases, (previously, the presence of a gradient on any page
- would force rasterized output for that page). Currently, only
- gradients with extend types of PAD (the default) or NONE will
- generate native PDF gradients---others will still trigger
- rasterization, (but look for support for other extend modes in a
- future release). Many thanks to Miklós Erdélyi as well, who did the
- initial work for this support.
-
-Better compatibility with PDF viewers:
-
- The PDF output from cairo should now be displayed correctly by a
- wider range of PDF viewers. Adrian tested cairo's PDF output against
- many PDF viewers, identified a common bug in many of those viewers
- (ignoring the CTM matrix in some cases), and modified cairo's output
- to avoid triggering that bugs (pre-transforming coordinates and
- using an identity matrix).
-
-Better OpenType/CFF subsetting:
-
- Cairo will now embed CFF and TrueType fonts as CID fonts.
-
-Performance optimizations
--------------------------
-Faster cairo_paint_with_alpha:
-
- The cairo_paint_with_alpha call is used to apply a uniform alpha
- mask to a pattern. For example, it can be used to gradually fade an
- image out or in. Jeff Muizelaar fixed some missing/broken
- optimizations within the implementation of this function resulting
- in cairo_paint_with_alpha being up to 4 times faster when using
- cairo's image backend.
-
-Optimize rendering of "off-screen" geometry:
-
- Something that applications often do is to ask cairo to render
- things that are either partially or wholly outside the current clip
- region. Since 1.4.0 the image backend has been fixed to not waste
- too much time in this case. But other backends have still been
- suffering.
-
- In particular, the xlib backend has often performed quite badly in
- this situation. This is due to a bug in the implementation of
- trapezoid rasterization in many X servers.
-
- Now, in cairo 1.4.6 there is a higher-level fix for this
- situation. Cairo now eliminates or clips trapezoids that are wholly
- or partially outside the clip region before handing the trapezoids
- to the backend. This means that the X server's performance bug is
- avoided in almost all cases.
-
- The net result is that doing an extreme zoom-in of vector-based
- objects drawn with cairo might have previously brought the X server
- to its knees as it allocated buffers large enough to fit all of the
- geometry, (whether visible or not). But now the memory usage should
- be bounded and performance should be dramatically better.
-
-Miscellaneous
--------------
-Behdad contributed an impressively long series of changes that
-organizes cairo's internals in several ways that will be very
-beneficial to cairo developers. Thanks, Behdad!
-
-Behdad has also provided a utility for generating malloc statistics,
-(which was used during the great malloc purges of 1.4.2 and
-1.4.4). This utility isn't specific to cairo so may be of benefit to
-others. It is found in cairo/util/malloc-stats.c and here are Behdad's
-notes on using it:
-
- To build, do:
-
- make malloc-stats.so
-
- inside util/, and to use, run:
-
- LD_PRELOAD=malloc-stats.so some-program
-
- For binaries managed by libtool, eg, cairo-perf, do:
-
- ../libtool --mode=execute /bin/true ./cairo-perf
- LD_PRELOAD="../util/malloc-stats.so" .libs/lt-cairo-perf
-
-Finally, the cairo-perf-diff-files utility was enhanced to allow for
-generating performance reports from several runs of the same backend
-while some system variables were changed. For example, this is now
-being used to allow cairo-perf to measure the performance of various
-different acceleration architectures and configuration options of the
-X.org X server.
-
-Release 1.4.4 (2007-04-13 Carl Worth <cworth@cworth.org>)
-=========================================================
-This is the second update release in cairo's stable 1.4 series. It
-comes just less than a month after 1.4.2. The changes since 1.4.2
-consist primarily of bug fixes, but also include at least one
-optimization. See below for details.
-
-Of all the work that went into the 1.4.4 release
-
-There have been lots of individuals doing lots of great work on cairo,
-but two efforts during the 1.4.4 series deserve particular mention:
-
-Internal cleanup of error handling, (Chris Wilson)
---------------------------------------------------
-Chris contributed a tremendous series of patches (74 patches!) to
-improve cairo's handling of out-of-memory and other errors. He began
-by adding gcc's warn_unused_attribute to as many functions as
-possible, and then launched into the ambitious efforts of adding
-correct code to quiet the dozens of resulting warnings.
-
-Chris also wrote a custom valgrind skin to systematically inject
-malloc failures into cairo, and did all the work necessary to verify
-that cairo's performance test suite runs to completion without
-crashing.
-
-The end result is a much more robust implementation. Previously, many
-error conditions would have gone unnoticed and would have led to
-assertion failures, segmentation faults, or other harder-to-diagnose
-problems. Now, more than ever, cairo should cleanly let the user know
-of problems through cairo_status and other similar status
-functions. Well done, Chris!
-
-More malloc reduction, (Mathias Hasselmann)
--------------------------------------------
-After 1.4.0, Behdad launched an effort to chase down excessive calls
-to malloc within the implementation of cairo. He fixed a lot of
-malloc-happy objects for 1.4.2, but one of the worst offenders,
-(pixman regions), was left around. Mathias contributed an excellent
-series of 15 patches to finish off this effort.
-
-The end result is a cairo that calls malloc much less often than it
-did before. Compared to 1.4.2, 55% of the calls to malloc have been
-eliminate, (and 60% have been eliminated compared to 1.4.0). Well
-done, Mathias!
-
-Other improvements since 1.4.2
-------------------------------
-• Centralize mutex declarations (will reduce future build breaks),
- (Mathias Hasselmann)
-
-• Reduce malloc by caching recently freed pattern objects (Chris
- Wilson)
-
-• Fix some broken composite operations (David Reveman)
- https://bugs.freedesktop.org/show_bug.cgi?id=5777
-
-Backend-specific fixes
-----------------------
-PDF:
- • Use TJ operator for more compact representation of glyphs (Adrian
- Johnson)
-
- • Fix glyph positioning bug when glyphs are not horizontal
- http://lists.freedesktop.org/archives/cairo/2007-April/010337.html
-
-win32:
- • Fix crash when rendering with bitmap fonts (Carl Worth)
- https://bugzilla.mozilla.org/show_bug.cgi?id=376498
-
-xlib:
- • Turn metrics-hinting on by default (Behdad Esfahbod)
-
- • Fix edge-effect problem with transformed images drawn to xlib
- (Behdad Esfahbod)
- https://bugs.freedesktop.org/show_bug.cgi?id=10508
-
- • Avoid dereferencing a NULL screen. (Chris Wilson)
- https://bugs.freedesktop.org/show_bug.cgi?id=10517
-
-Quartz/ATSUI:
- • Fix scaling of glyph surfaces
- (Brian Ewins)
- https://bugs.freedesktop.org/show_bug.cgi?id=9568
-
- • Fix compilation failure when both xlib and quartz enabled
- (Brian Ewins)
-
- • Fix rounding bug leading to incorrectly positioned glyphs
- (Robert O'Callahan)
- https://bugs.freedesktop.org/show_bug.cgi?id=10531
-
-Release 1.4.2 (2007-03-19 Carl Worth <cworth@cworth.org>)
-=========================================================
-This is the first update release in cairo's stable 1.4 series. It
-comes just less than 2 weeks after 1.4.0. We hadn't anticipated an
-update this early, but we've managed to collect some important fixes
-that we wanted to get out to cairo users as soon as possible, (6 fixes
-for crashes, 1 case where graphical elements would not be drawn at
-all, a handful of backend-specific bugs, and several important build
-fixes).
-
-There's almost nothing but bug fixes in this release, (see below one
-optimization that Behdad did sneak in), so we recommend that everyone
-upgrade to this release when possible.
-
-Thanks to the many people that worked to fix these bugs, and those
-that did the work to report them and to test the fixes, (wherever
-possible both names are credited below).
-
-Critical fixes
---------------
-• Fix a crash due to a LOCK vs. UNLOCK typo (M. Drochner fixing Carl
- Worth's embarrassing typo).
-
- http://bugs.freedesktop.org/show_bug.cgi?id=10235
-
-• Fix potential buffer overflow, which on some systems with a checking
- variant of snprintf would lead to a crash (Adrian Johnson, Stanislav
- Brabec, and sangu).
-
- https://bugs.freedesktop.org/show_bug.cgi?id=10267
- https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=232576
-
-• Fix a crash in cairo_stroke_extents or cairo_in_stroke when line
- width is 0.0. (Carl Worth and Sebastien Bacher)
-
- https://bugs.freedesktop.org/show_bug.cgi?id=10231
-
-• Fix a crash on certain combinations of X server/video drivers (Carl
- Worth and Tomas Carnecky).
-
- https://bugs.freedesktop.org/show_bug.cgi?id=10250
-
-• Fix a crash due to mishandling of invalid user input (Carl Worth and
- Alexander Darovsky).
-
- https://bugs.freedesktop.org/show_bug.cgi?id=9844
-
-• xlib: Cleanup server-side glyph caches on XCloseDisplay. This
- eliminated a crash detected by the perf suite, (and that
- applications could have run into as well). (Chris Wilson)
-
-Other bug fixes
----------------
-• Fix for some geometry which simply disappeared under some
- transformations---a stroked line with an extreme skew in X, for
- example (Carl Worth and Jonathan Watt).
-
- https://bugzilla.mozilla.org/show_bug.cgi?id=373632
-
-• SVG: Fix radial gradients for CAIRO_EXTEND_REFLECT and when r0 > r1
- (Emmanuel Pacaud).
-
-• PDF: Set page group color space to DeviceRGB.
-
- This fixes incorrect (muddy) transparent colors when rendering cairo
- PDF output in some viewers. (Adrian Johnson, Adam Goode, and
- MenTaLguY).
-
- http://lists.freedesktop.org/archives/cairo/2006-November/008551.html
-
-• win32: Return correct metrics when hinting is off, and fix font
- descent computation (Behdad Esfahbod).
-
-• quartz: Fix glyph interfaces to correctly return user-space rather
- than device-space coordinates (Brian Ewins).
-
- https://bugs.freedesktop.org/show_bug.cgi?id=9568
-
-• xcb: Fix parameter-order confusion with xcb_create_pixmap, which now
- makes all tests that pass with xlib now pass with xcb (Carl Worth,
- Jamey Sharp).
-
-• Fix some memory leaks in the perf suite (Chris Wilson).
-
-• Fix perf suite to consider changes in pixman/src (Mathias
- Hasselmann).
-
-Build fixes
------------
-• Don't include pre-generated cairo-features.h file. This was causing
- build failures when building with the directfb backend enabled
- (Behdad Esfahbod).
-
- https://bugs.freedesktop.org/show_bug.cgi?id=10189
-
-• Eliminate use of maintainer mode from cairo's automake/configure
- script. This means that updates to files such as Makefile.am will
- take effect, (by rerunning automake and friends as necessary) when
- invoking make rather than being silently ignored. (Behdad Esfahbod)
-
-• Don't compile cairo-deflate-stream.c, which depends on zlib, unless
- building the pdf backend which requires it. (Carl Worth, Tor
- Lillqvist)
-
- https://bugs.freedesktop.org/show_bug.cgi?id=10202
-
-• Don't make the ps backend link against zlib anymore, since it
- doesn't require it (Carl Worth).
-
-• Use "find !" rather than "find -not" for better portability (Thomas
- Klausner).
-
- https://bugs.freedesktop.org/show_bug.cgi?id=10226
-
-• Don't use unsupported visibility attribute "hidden" on Solaris
- (Gilles Dauphin, Thomas Klausner).
-
- https://bugs.freedesktop.org/show_bug.cgi?id=10227
-
-Optimization
-------------
-• It was Behdad that suggested we focus strictly on bug fixes now that
- we shipped so many performance improvements in 1.4.0, but it was
- also Behdad that got distracted by the chance to remove a lot of
- mallocs from cairo. Paths, gstates, trapezoids, splines, polygons,
- and gradient color stops will now use small, stack-allocated buffers
- in the most common cases rather than calling malloc as
- often. (Behdad Esfahbod). And look for more from Mathias Hasselmann
- soon.
-
-Release 1.4.0 (2007-03-06 Carl Worth <cworth@cworth.org>)
-=========================================================
-The many people[*] who have been working hard on cairo are very
-pleased to announce the long-awaited release of cairo 1.4. This
-release comes 4 months after the last stable update release (1.2.6)
-and 9 months since the initial release of 1.2.0.
-
-The release notes below are intended to capture the highlights of the
-changes that have occurred from the 1.2 series to the new 1.4.0
-release.
-
-Performance improvements
-------------------------
-Within the cairo project, the last 6 months or so has seen an intense
-effort focusing on the performance of cairo itself. That effort has
-paid off considerably, as can be seen in the following highlights of
-some of the performance differences from cairo 1.2.6 to cairo 1.4.0.
-
-(Note: The performance results reported here were measured on an x86
-laptop. Many of the improvements in 1.4---particular those involving
-text rendering---are even more dramatic on embedded platforms without
-hardware floating-point units. Such devices played an important part
-of many of the optimizations that found their way into cairo over the
-last few months.)
-
-• Dramatic improvement when drawing objects that are mostly off-screen
- with the image backend (with the xlib backend this case is still
- slow due to an X server bug):
-
- image-rgba long-lines-uncropped-100 479.64 -> 4.98: 96.24x speedup
- ███████████████████████████████████████████████▋
-
-• Dramatic improvement when copying a small fraction of an image
- surface to an xlib surface:
-
- xlib-rgba subimage_copy-512 3.93 -> 0.07: 54.52x speedup
- ██████████████████████████▊
-
-• Dramatic improvement to tessellation speed for complex objects:
-
- image-rgb tessellate-256-100 874.16 -> 34.79: 25.13x speedup
- ████████████â–
- xlib-rgba zrusin_another_fill-415 148.40 -> 13.85: 10.72x speedup
- ████▉
- xlib-rgb world_map-800 680.20 -> 345.54: 1.97x speedup
- ▌
-
-• Dramatic improvement to the speed of stroking rectilinear shapes,
- (such as the outline of a rectangle or "box"):
-
- image-rgb box-outline-stroke-100 0.18 -> 0.01: 24.22x speedup
- ███████████▋
- xlib-rgb box-outline-stroke-100 0.46 -> 0.06: 8.05x speedup
- ███▌
-
-
-• Dramatic improvements to text rendering speeds:
-
- xlib-rgba text_image_rgba_over-256 63.12 -> 9.61: 6.57x speedup
- ██▊
-
-• 3x improvements to floating-point to fixed-point conversion speeds:
-
- image-rgba pattern_create_radial-16 9.29 -> 3.44: 2.70x speedup
- â–‰
-
-• 2x improvements to linear gradient computation:
-
- image-rgb paint_linear_rgb_source-512 26.22 -> 11.61: 2.26x speedup
- â–‹
-
-• 2x improvement to a case common in PDF rendering:
-
- image-rgb unaligned_clip-100 0.10 -> 0.06: 1.81x speedup
- â–
-
-• 1.3x improvement to rectangle filling speed (note: this improvement
- is new since 1.3.16---previously this test case was a 1.3x slowdown
- compared to 1.2.6):
-
- image-rgba rectangles-512 6.19 -> 4.37: 1.42x speedup
- â–Ž
- xlib-rgba rectangles-512 7.48 -> 5.58: 1.34x speedup
- â–
-
-NOTE: In spite of our best efforts, there are some measurable
-performance regressions in 1.4 compared to 1.2. It appears that the
-primary problem is the increased overhead of the new tessellator when
-drawing many, very simple shapes. The following test cases capture
-some of that slowdown:
-
- image-rgba mosaic_tessellate_lines-800 11.03 -> 14.29: 1.30x slowdown
- â–
- image-rgba box-outline-fill-100 0.01 -> 0.01: 1.26x slowdown
- â–
- image-rgba fill_solid_rgb_over-64 0.20 -> 0.22: 1.12x slowdown
-
- image-rgba fill_image_rgba_over-64 0.23 -> 0.25: 1.10x slowdown
-
- xlib-rgb paint_image_rgba_source-256 3.24 -> 3.47: 1.07x slowdown
-
-We did put some special effort into eliminating this slowdown for the
-very common case of drawing axis-aligned rectangles with an identity
-matrix (see the box-outline-stroke and rectangles speedup numbers
-above). Eliminating the rest of this slowdown will be a worthwhile
-project going forward.
-
-Also note that the "box-outline-fill" case is a slowdown while
-"box-outline-stroke" is a (huge) speedup. These two test cases
-resulted from the fact that some GTK+ theme authors were filling
-between two rectangles to avoid slow performance from the more natural
-means of achieving the same shape by stroking a single rectangle. With
-1.4 that workaround should definitely be eliminated as it will now
-cause things to perform more slowly.
-
-Greatly improved PDF output
----------------------------
-We are very happy to be able to announce that cairo-generated PDF
-output will now have text that can be selected, cut-and-pasted, and
-searched with most capable PDF viewer applications. This is something
-that was not ever possible with cairo 1.2.
-
-Also, the PDF output now has much more compact encoding of text than
-before. Cairo is now much more careful to not embed multiple copies of
-the same font at different sizes. It also compresses text and font
-streams within the PDF output.
-
-API additions
--------------
-There are several new functions available in 1.4 that were not
-available in 1.2. Curiously, almost all of the new functions simply
-allow the user to query state that has been set in cairo (many new
-"get" functions) rather than providing any fundamentally new
-operations. The new functionality is:
-
-• Getting information about the current clip region
-
- cairo_clip_extents
- cairo_copy_clip_rectangle_list
- cairo_rectangle_list_destroy
-
-• Getting information about the current dash setting
-
- cairo_get_dash_count
- cairo_get_dash
-
-• Getting information from a pattern
-
- cairo_pattern_get_rgba
- cairo_pattern_get_surface
- cairo_pattern_get_color_stop_rgba
- cairo_pattern_get_color_stop_count
- cairo_pattern_get_linear_points
- cairo_pattern_get_radial_circles
-
-• Getting the current scaled font
-
- cairo_get_scaled_font
-
-• Getting reference counts
-
- cairo_get_reference_count
- cairo_surface_get_reference_count
- cairo_pattern_get_reference_count
- cairo_font_face_get_reference_count
- cairo_scaled_font_get_reference_count
-
-• Setting/getting user data on objects
-
- cairo_set_user_data
- cairo_get_user_data
- cairo_pattern_set_user_data
- cairo_pattern_get_user_data
- cairo_scaled_font_set_user_data
- cairo_scaled_font_get_user_data
-
-• New cairo-win32 functions:
-
- cairo_win32_surface_create_with_ddb
- cairo_win32_surface_get_image
- cairo_win32_scaled_font_get_logical_to_device
- cairo_win32_scaled_font_get_device_to_logical
-
-API deprecation
----------------
-The CAIRO_FORMAT_RGB16_565 enum value has been deprecated. It never
-worked as a format value for cairo_image_surface_create, and it wasn't
-necessary for supporting 16-bit 565 X server visuals.
-
-A sampling of bug fixes in cairo 1.4
-------------------------------------
- • Fixed radial gradients
- • Fixed dashing (degenerate and "leaky" cases)
- • Fixed transformed images in PDF/PS output (eliminate bogus repeating)
- • Eliminate errors from CAIRO_EXTEND_REFLECT and CAIRO_EXTEND_PAD
- • cairo_show_page no longer needed for single-page output
- • SVG: Fix bug preventing text from appearing in many viewers
- • cairo-ft: Return correct metrics when hinting is off
- • Eliminate crash in cairo_create_similar if nil surface is returned
- • Eliminate crash after INVALID_RESTORE error
- • Fix many bugs related to multi-threaded use and locking
- • Fix for glyph spacing 32 times larger than desired (cairo-win32)
- • Fixed several problems in cairo-atsui (assertion failures)
- • Fix PDF output to avoid problems when printing from Acrobat Reader
- • Fix segfault on Mac OS X (measuring a zero-length string)
- • Fix text extents to not include the size of non-inked characters
- • Fix for glyph cache race condition in glitz backend (Jinghua Luo)
- • Fix make check to work on OPD platforms (IA64 or PPC64)
- • Fix compilation problems of cairo "wideint" code on some platforms
- • Many, many others...
-
-Experimental backends (quartz, XCB, OS/2, BeOS, directfb)
----------------------------------------------------------
-None of cairo's experimental backends are graduating to "supported"
-status with 1.4.0, but two of them in particular (quartz and xcb), are
-very close.
-
-The quartz baceknd has been entirely rewritten and is now much more
-efficient. The XCB backend has been updated to track the latest XCB
-API (which recently had a 1.0 release).
-
-We hope to see these backends become supported in a future release,
-(once they are passing all the tests in cairo's test suite).
-
-The experimental OS/2 backend is new in cairo 1.4 compared to cairo
-1.2.
-
-Documentation improvements
---------------------------
-We have added documentation for several functions and types that
-were previously undocumented, and improved documentation on other
-ones. As of this release, there remain only two undocumented
-symbols: cairo_filter_t and cairo_operator_t.
-
-[*]Thanks to everyone
----------------------
-I've accounted for 41 distinct people with attributed code added to
-cairo between 1.2.6 and 1.4.0, (their names are below). That's an
-impressive number, but there are certainly dozens more that
-contributed with testing, suggestions, clarifying questions, and
-encouragement. I'm grateful for the friendships that have developed as
-we have worked on cairo together. Thanks to everyone for making this
-all so much fun!
-
-Adrian Johnson, Alfred Peng, Alp Toker, Behdad Esfahbod,
-Benjamin Otte, Brian Ewins, Carl Worth, Christian Biesinger,
-Christopher (Monty) Montgomery, Daniel Amelang, Dan Williams,
-Dave Yeo, David Turner, Emmanuel Pacaud, Eugeniy Meshcheryakov,
-Frederic Crozat, Hans Breuer, Ian Osgood, Jamey Sharp, Jeff Muizelaar,
-Jeff Smith, Jinghua Luo, Jonathan Watt, Joonas Pihlaja, Jorn Baayen,
-Kalle Vahlman, Kjartan Maraas, Kristian Høgsberg, M Joonas Pihlaja,
-Mathias Hasselmann, Mathieu Lacage, Michael Emmel, Nicholas Miell,
-Pavel Roskin, Peter Weilbacher, Robert O'Callahan,
-Soren Sandmann Pedersen, Stuart Parmenter, T Rowley,
-Vladimir Vukicevic
-
-Snapshot 1.3.16 (2007-03-02 Carl Worth <cworth@cworth.org>)
-===========================================================
-New API functions
------------------
-A few new public functions have been added to the cairo API since the
-1.3.14 snapshot. These include a function to query the current scaled
-font:
-
- cairo_get_scaled_font
-
-New functions to query the reference count of all cairo objects:
-
- cairo_get_reference_count
-
- cairo_surface_get_reference_count
- cairo_pattern_get_reference_count
-
- cairo_font_face_get_reference_count
- cairo_scaled_font_get_reference_count
-
-And new functions to allow the use of user_data with any cairo object,
-(previously these were only available on cairo_surface_t and
-cairo_font_face_t objects):
-
- cairo_set_user_data
- cairo_get_user_data
-
- cairo_pattern_set_user_data
- cairo_pattern_get_user_data
-
- cairo_scaled_font_set_user_data
- cairo_scaled_font_get_user_data
-
-Usability improvement for PDF/PS/SVG generation
------------------------------------------------
-In previous versions of cairo, generating single-page output with the
-cairo-pdf, cairo-ps, or cairo-svg backends required a final call to
-cairo_show_page. This was often quite confusing as people would port
-functional code from a non-paginated backend and be totally mystified
-as to why the output was blank until they learned to add this call.
-
-Now that call to cairo_show_page is optional, (it will be generated
-implicitly if the user does not call it). So cairo_show_page is only
-needed to explicitly separate multiple pages.
-
-Greatly improved PDF output
----------------------------
-We are very happy to be able to announce that cairo-generated PDF
-output will now have text that can be selected, cut-and-paste, and
-searched with most capable PDF viewer applications. This is something
-that was not ever possible with cairo 1.2.
-
-Also, the PDF output now has much more compact encoding of text than
-before. Cairo is now much more careful to not embed multiple copies of
-the same font at different sizes. It also compresses text and font
-streams within the PDF output.
-
-Major bug fixes
----------------
- • Fixed radial gradients
-
- The rendering of radial gradients has been greatly improved. In
- the cairo 1.2 series, there was a serious regression affecting
- radial gradients---results would be very incorrect unless one of
- the gradient circles had a radius of 0.0 and a center point within
- the other circle. These bugs have now been fixed.
-
- • Fixed dashing
-
- Several fixes have been made to the implementation of dashed
- stroking. Previously, some dashed, stroked rectangles would
- mis-render and fill half of the rectangle with a large triangular
- shape. This bug has now been fixed.
-
- • Fixed transformed images in PDF/PS output
-
- In previous versions of cairo, painting with an image-based source
- surface pattern to the PDF or PS backends would cause many kinds
- of incorrect results. One of the most common problems was that an
- image would be repeated many times even when the user had
- explicitly requested no repetition with CAIRO_EXTEND_NONE. These
- bugs have now been fixed.
-
- • Eliminate errors from CAIRO_EXTEND_REFLECT and CAIRO_EXTEND_PAD
-
- In the 1.2 version of cairo any use of CAIRO_EXTEND_REFLECT or
- CAIRO_EXTEND_PAD with a surface-based pattern resulted in an
- error, (cairo would stop rendering). This bug has now been
- fixed.
-
- Now, CAIRO_EXTEND_REFLECT should work properly with surface
- patterns.
-
- CAIRO_EXTEND_PAD is still not working correctly, but it will now
- simply behave as CAIRO_EXTEND_NONE rather than triggering the
- error.
-
-New rewrite of quartz backend (still experimental)
---------------------------------------------------
-Cairo's quartz backend has been entirely rewritten and is now much
-more efficient. This backend is still marked as experimental, not
-supported, but it is now much closer to becoming an officially
-supported backend. (For people that used the experimental nquartz
-backend in previous snapshots, that implementation has now been
-renamed from "nquartz" to "quartz" and has replaced the old quartz
-backend.)
-
-Documentation improvements
---------------------------
-We have added documentation for several functions and types that
-were previously undocumented, and improved documentation on other
-ones. As of this release, there remain only two undocumented
-symbols: cairo_filter_t and cairo_operator_t.
-
-Other bug fixes
----------------
- • cairo-svg: Fix bug that was preventing text from appearing in many
- viewers
-
- • cairo-ft: Return correct metrics when hinting is off
-
- • Cairo 1.3.14 deadlocks in cairo_scaled_font_glyph_extents or
- _cairo_ft_unscaled_font_lock_face
-
- https://bugs.freedesktop.org/show_bug.cgi?id=10035
-
- • cairo crashes in cairo_create_similar if nil surface returned by
- other->backend->create_similar
-
- https://bugs.freedesktop.org/show_bug.cgi?id=9844
-
- • evolution crash in _cairo_gstate_backend_to_user()
- https://bugs.freedesktop.org/show_bug.cgi?id=9906
-
- • Fix memory leak in rectilinear stroking code
-
-Things not in this release
---------------------------
- • Solid-surface-pattern cache: This patch had been applied during
- the 1.3.x series, but it was reverted due to some inter-thread
- problems it caused. The patch is interesting since it made a big
- benefit for text rendering performance---so we'll work to bring a
- corrected version of this patch back as soon as possible.
-
-Snapshot 1.3.14 (2006-02-13 Carl Worth <cworth@cworth.org>)
-===========================================================
-This is the seventh development snapshot in the 1.3 series, (and there
-likely won't be many more before the 1.4.0 release). It comes just
-over 3 weeks after the 1.3.12 snapshot.
-
-Since we're so close to the 1.4.0 release, there are not a lot of new
-features nor even a lot of new performance improvements in this
-snapshot. Instead, there are a great number of bug fixes. Some are
-long-standing bugs that we're glad to say goodbye to, and several are
-fixes for regressions that were introduced as part of the optimization
-efforts during the 1.3.x series.
-
-PDF text selection fixed
-------------------------
-The inability to correctly select text in cairo-generated PDF has been
-a defect ever since the initial support for the PDF backend in the
-cairo 1.2.0 release. With the 1.3.14 snapshot, in most situations, and
-with most PDF viewer applications, the PDF generated by cairo will
-allow text to be correctly selected for copy-and-paste, (as well as
-searching).
-
-We're very excited about this new functionality, (and very grateful to
-Adrian Johnson, Behdad Esfahbod, and others that have put a lot of
-work into this lately). Please test this new ability and give feedback
-on the cairo@cairographics.org list.
-
-Many thread-safety issues fixed
--------------------------------
-We've discovered that no release of cairo has ever provided safe text
-rendering from a multi-threaded application. With the 1.3.14 snapshot
-a huge number of the bugs in this area have been fixed, and multiple
-application dvelopers have now reported success at writing
-multi-threaded applications with cairo.
-
-Other fixes
------------
-Fixed a bug that was causing glyph spacing to be 32 times larger than
-desired when using cairo-win32.
-
-Fixed a regression in the rendering of linear gradients that had been
-present since the 1.3.8 snapshot.
-
-Fixed several problems in cairo-atsui that were leading to assertion
-failures when rendering text.
-
-Fix corrupted results when rendering a transformed source image
-surface to an xlib surface. This was a regression that had been
-present since the 1.3.2 snapshot.
-
-Fixed PDF output to prevent problems printing from some versions of
-Acrobat Reader, (a single glyph was being substituted for every
-glyph).
-
-And many other fixes as well, (see the logs for details).
-
-Snapshot 1.3.12 (2007-01-20 Carl Worth <cworth@cworth.org>)
-===========================================================
-The relentless march toward the cairo 1.4 release continues, (even if
-slightly late out of the starting blocks in 2007). This is the sixth
-development snapshot in the 1.3 series. It comes 4 weeks after the
-1.3.10 snapshot.
-
-Performance
------------
-As usual, this snapshot has some fun performance improvements to show
-off:
-
-image-rgba long-lines-uncropped-100 470.08 -> 4.95: 94.91x speedup
-███████████████████████████████████████████████
-image-rgb long-lines-uncropped-100 461.60 -> 4.96: 93.02x speedup
-██████████████████████████████████████████████
-
-This 100x improvement, (and yes, that's 100x, not 100%), in the image
-backend occurs when drawing large shapes where only a fraction of the
-shape actually appears in the final result, (the rest being outside
-the bounds of the destination surface). Many applications should see
-speedups here, and the actual amount of speedup depends on the ratio
-of non-visible to visible portions of geometry.
-
-[Note: There remains a similar performance bug when drawing mostly
-non-visible objects with the xlib backend. This is due to a similar
-bug in the X server itself, but we hope a future cairo snapshot will
-workaround that bug to get a similar speedup with the xlib backend.]
-
-image-rgba unaligned_clip-100 0.09 -> 0.06: 1.67x speedup
-â–
-image-rgb unaligned_clip-100 0.09 -> 0.06: 1.66x speedup
-â–
-
-This speedup is due to further MMX optimization by Soeren Sandmann for
-a case commonly hit when rendering PDF files, (and thanks to Jeff
-Muizelaar for writing code to extract the test case for us).
-
-There's another MMX optimization in this snapshot (without a fancy
-speedup chart) by Dan Williams which improves compositing performance
-specifically for the OLPC machine.
-
-Thanks to Adrian Johnson, cairo's PDF output is now much more
-efficient in the way it encodes text output. By reducing redundant
-information and adding compression to text output streams, Adrian
-achieved a ~25x improvement in the efficiency of encoding text in PDF
-files, (was ~45 bytes per glyph and is now ~1.6 bytes per glyph).
-
-Bug fixes
----------
-In addition to those performance improvements, this snapshot includes
-several bug fixes:
-
- * A huge number of bug fixes for cairo-atsui text rendering, (for mac
- OS X). These bugs affect font selection, glyph positioning, glyph
- rendering, etc. One noteworthy bug fixes is that
- cairo_select_font_face will no longer arbitrarily select bold nor
- italic when not requested, (at least not when using a standard CSS2
- font family name such as "serif", "sans-serif", "monospace", etc.).
- All these fixes are thanks to Brian Ewins who continues to do a
- great job as the new cairo-atsui maintainer.
-
- * Fix PDF output so that images that are scaled down no longer
- mysteriously repeat (Carl Worth).
-
- * Fix segfault on Mac OS X dues to attempt to measure extents of a
- zero-length string (Behdad Esfahbod).
-
- * Fix text extents to not include the size of initial/trailing
- non-inked characters (Behdad Esfahbod).
-
-API tweaks
-----------
-Three functions have had API changes to improve consistency. Note that
-the API functions being changed here are all functions that were
-introduced as new functions during these 1.3.x snapshots. As always,
-there will not be any API changes to functions included in a major
-release (1.2.x, 1.4.x, etc.) of cairo.
-
-The changes are as follows:
-
- * Rename of cairo_copy_clip_rectangles to cairo_copy_clip_rectangle_list.
-
- * Change cairo_get_dash_count to return an int rather than accepting a
- pointer to an int for the return value.
-
- * Change cairo_get_dash to have a void return type rather than
- returning cairo_status_t.
-
-It's possible there will be one more round of changes to these
-functions, (and perhaps cairo_get_color_stop as well), as we seek to
-establish a unifying convention for returning lists of values.
-
-Snapshot 1.3.10 (2006-12-23 Carl Worth <cworth@cworth.org>)
-===========================================================
-Santa Claus is coming just a little bit early this year, and he's
-bringing a shiny new cairo snapshot for all the good little boys and
-girls to play with.
-
-This is the fifth development snapshot in the 1.3 series. It comes 9
-days after the 1.3.8 snapshot, and still well within our goal of
-having a new snapshot every week, (though don't expect one next
-week---we'll all be too stuffed with sugar plums).
-
-Speaking of sugar plums, there's a sweet treat waiting in this cairo
-snapshot---greatly improved performance for stroking rectilinear
-shapes, like the ever common rectangle:
-
-image-rgb box-outline-stroke-100 0.18 -> 0.01: 25.58x speedup
-████████████████████████▋
-image-rgba box-outline-stroke-100 0.18 -> 0.01: 25.57x speedup
-████████████████████████▋
-xlib-rgb box-outline-stroke-100 0.49 -> 0.06: 8.67x speedup
-███████▋
-xlib-rgba box-outline-stroke-100 0.22 -> 0.04: 5.39x speedup
-████â–
-
-In past releases of cairo, some people had noticed that using
-cairo_stroke to draw rectilinear shapes could be awfully slow. Many
-people had worked around this by using cairo_fill with a more complex
-path and gotten a 5-15x performance benefit from that.
-
-If you're one of those people, please rip that workaround out, as now
-the more natural use of cairo_stroke should be 1.2-2x faster than the
-unnatural use of cairo_fill.
-
-And if you hadn't ever implemented that workaround, then you just
-might get to see your stroked rectangles now get drawn 5-25x faster.
-
-Beyond that performance fix, there are a handful of bug fixes in this
-snapshot:
-
- * Fix for glyph cache race condition in glitz backend (Jinghua Luo)
-
- * Many fixes for ATSUI text rendering (Brian Ewins)
-
- * Un-break recent optimization-triggered regression in rendering text
- with a translation in the font matrix (Behdad Esfahbod)
-
- * Fix make check to work on OPD platforms (IA64 or PPC64)
- (Frederic Crozat)
-
- * Fix a couple of character spacing issues on Windows
- (Jonathan Watt)
-
-Have fun with that, everybody, and we'll be back for more in the new
-year, (with a plan to add the last of our performance improvements in
-this round, fix a few bad, lingering bugs, and then finish off a nice,
-stable 1.4 release before the end of January).
-
--Carl
-
-Snapshot 1.3.8 (2006-12-14 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the fourth development snapshot in the 1.3 series. It comes
-just slightly more than one week after the 1.3.6 snapshot.
-
-After the bug fixes in 1.3.6, we're back to our original program of
-weekly snapshots, each one faster than the one from the week
-before. Cairo 1.3.8 brings a 2x improvement in the speed of rendering
-linear gradients (thanks to David Turner), and a significant reduction
-in X traffic when rendering text (thanks to Xan Lopez and Behdad
-Esfahbod), making cairo behave very much like Xft does.
-
-A few other things in the 1.3.8 snapshot worth noting include a more
-forgiving image comparator in the test suite, (using the "perceptual
-diff" metric and GPL implementation by Hector Yee[*]), a bug fix for
-broken linking on x86_64 (thanks to M Joonas Pihlaja) and an even
-better implementation of _cairo_lround, (not faster, but supporting a
-more complete input range), from Daniel Amelang.
-
-[*] http://pdiff.sourceforge.net/
-
-Snapshot 1.3.6 (2006-12-06 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the third development snapshot in the 1.3 series. It comes two
-weeks after the 1.3.4 snapshot.
-
-We don't have fancy performance charts this week as the primary
-changes in this snapshot are bug fixes. The performance work continues
-and the next snapshot (planned for one week from today) should include
-several improvements. The bug fixes in this snapshot include:
-
- * Fix undesirable rounding in glyph positioning (Dan Amelang)
-
- This bug was noticed by several users, most commonly by seeing
- improper text spacing or scrambled glyphs as drawn by nautilus. For
- example:
-
- Update to cairo-1.3.4 worsen font rendering
- https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=217819
-
- * Fix reduced range of valid input coordinates to tessellator
- (M Joonas Pihlaja)
-
- This bug was causing lots of assertion failures in mozilla as
- mentioned here:
-
- CAIRO_BO_GUARD_BITS and coordinate space?
- http://lists.freedesktop.org/archives/cairo/2006-December/008743.html
-
- * Fix several regressions in new tessellator (M Joonas Pihlaja)
-
- Joonas just had a good eye for detail here. I don't think any
- external cairo users had noticed any of these bugs yet.
-
- * Fix compilation problems of cairo "wideint" code on some platforms
- (Mathieu Lacage)
-
- * Fix failed configure due to broken grep (Dan Amelang)
-
- This bug was reported here:
-
- AX_C_FLOAT_WORDS_BIGENDIAN doesn't work because grep doesn't
- work with binary file
- https://bugs.freedesktop.org/show_bug.cgi?id=9124
-
- * Remove the pkg-config minimum version requirement (Behdad Esfahbod)
-
- Some systems ship with pkg-config 0.15 and there was really no good
- reason for cairo to insist on having version 0.19 before it would
- build.
-
-There is also one new (but inert) feature in this snapshot. There's a
-new option that can be passed to cairo's configure script:
-
- --disable-some-floating-point
-
- Disable certain code paths that rely heavily on double precision
- floating-point calculation. This option can improve
- performance on systems without a double precision floating-point
- unit, but might degrade performance on those that do.
-
-As of this snapshot, this option does not make any change to cairo,
-but it is possible that future versions of cairo will respect this
-option and change the implementation of various functions as
-appropriate.
-
-Snapshot 1.3.4 (2006-11-22 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the second development snapshot in the 1.3 series. It comes
-one week after the 1.3.2 snapshot.
-
-This snapshot has a couple of significant performance improvements,
-and also adds new support for producing multi-page SVG output, (when
-targeting SVG 1.2)---thanks to Emmanuel Pacaud. The details of the
-performance improvements are as follows:
-
-1. The long-awaited "new tessellator".
-
- The credit for this being an improvement goes to Joonas Pihlaja. He
- took my really slow code and really put it through its paces to get
- the dramatic performance improvement seen below (up to 38x faster
- on realistic cases, and more than 10x faster for the zrusin_another
- test).
-
- His own writeup of the work he did is quite thorough, but more than
- can be quoted here. Please see his post for the interesting details:
-
- http://lists.freedesktop.org/archives/cairo/2006-November/008483.html
-
- (Though note that this snapshot also includes some additional,
- significant improvements that were only sketched out in that
- email---see "Generating fewer trapezoids").
-
-2. More floating-point improvements
-
- Daniel Amelang continues to work the magic he began in the 1.3.2
- snapshot. This time he short-circuits floating-point
- transformations by identity matrices and applies the earlier
- floating-to-fixed-point technique to the problem of rounding.
-
- The improvements here will primarily benefit text performance, and
- will benefit platforms without hardware floating-point more than
- those that have it, (some text tests show 20% improvement on an x86
- machine and closer to 80% improvement on arm).
-
-The performance chart comparing 1.3.2 to 1.3.4 really speaks for
-itself, (this is on an x86 laptop). This is quite a lot of progress
-for one week:
-
- xlib-rgb stroke_similar_rgba_over-256 74.99 1.45% -> 2.03 68.38%: 36.86x speedup
-███████████████████████████████████▉
- xlib-rgb stroke_similar_rgba_source-256 78.23 1.43% -> 3.30 67.05%: 23.71x speedup
-██████████████████████▊
- xlib-rgba tessellate-256-100 820.42 0.15% -> 35.06 2.84%: 23.40x speedup
-██████████████████████â–
-image-rgba tessellate-256-100 819.55 0.32% -> 35.04 3.56%: 23.39x speedup
-██████████████████████â–
- xlib-rgb stroke_image_rgba_over-256 78.10 1.43% -> 4.33 65.56%: 18.04x speedup
-█████████████████
- xlib-rgb stroke_image_rgba_source-256 80.11 1.63% -> 5.75 63.99%: 13.94x speedup
-█████████████
- xlib-rgba zrusin_another_tessellate-415 89.22 0.35% -> 8.38 5.23%: 10.65x speedup
-█████████▋
-image-rgba zrusin_another_tessellate-415 87.38 0.89% -> 8.37 5.22%: 10.44x speedup
-█████████â–
-image-rgba zrusin_another_fill-415 117.67 1.34% -> 12.88 2.77%: 9.14x speedup
-████████â–
- xlib-rgba zrusin_another_fill-415 140.52 1.57% -> 15.79 2.88%: 8.90x speedup
-███████▉
-image-rgba tessellate-64-100 9.68 3.42% -> 1.42 0.60%: 6.82x speedup
-█████▉
- xlib-rgba tessellate-64-100 9.78 4.35% -> 1.45 0.83%: 6.72x speedup
-█████▊
- xlib-rgb stroke_linear_rgba_over-256 46.01 2.44% -> 7.74 54.51%: 5.94x speedup
-█████
- xlib-rgb stroke_linear_rgba_source-256 48.09 2.15% -> 9.14 53.00%: 5.26x speedup
-████▎
- xlib-rgb stroke_radial_rgba_over-256 50.96 2.34% -> 12.46 47.99%: 4.09x speedup
-███â–
- xlib-rgb stroke_radial_rgba_source-256 53.06 1.57% -> 13.96 46.57%: 3.80x speedup
-██▊
-image-rgba paint_similar_rgba_source-256 0.12 1.57% -> 0.08 9.92%: 1.42x speedup
-â–
-image-rgba paint_image_rgba_source-256 0.12 2.49% -> 0.08 10.70%: 1.41x speedup
-â–
-image-rgba world_map-800 356.28 0.46% -> 275.72 1.15%: 1.29x speedup
-â–Ž
- xlib-rgba world_map-800 456.81 0.39% -> 357.95 1.39%: 1.28x speedup
-â–Ž
-image-rgb tessellate-16-100 0.09 0.57% -> 0.07 3.43%: 1.23x speedup
-â–Ž
-image-rgba tessellate-16-100 0.09 0.06% -> 0.07 2.46%: 1.23x speedup
-â–Ž
-image-rgba text_solid_rgb_over-256 5.39 4.01% -> 4.47 0.70%: 1.21x speedup
-â–Ž
-image-rgba text_solid_rgba_over-256 5.37 0.82% -> 4.45 0.75%: 1.21x speedup
-â–Ž
-image-rgba text_image_rgb_over-64 0.78 0.10% -> 0.65 0.74%: 1.20x speedup
-â–Ž
-image-rgba text_image_rgba_over-64 0.78 0.29% -> 0.65 0.68%: 1.19x speedup
-â–Ž
-image-rgb text_solid_rgb_over-64 0.76 2.45% -> 0.63 0.81%: 1.19x speedup
-â–Ž
-image-rgba text_solid_rgba_over-64 0.76 0.33% -> 0.64 0.66%: 1.19x speedup
-â–Ž
-image-rgba text_similar_rgba_over-256 5.99 4.72% -> 5.04 1.09%: 1.19x speedup
-â–Ž
-
-We should point out that there is some potential for slowdown in this
-snapshot. The following are the worst slowdowns reported by the cairo
-performance suite when comparing 1.3.2 to 1.3.4:
-
-image-rgba subimage_copy-256 0.01 0.87% -> 0.01 3.61%: 1.45x slowdown
-▌
- xlib-rgb paint_solid_rgb_over-256 0.31 10.23% -> 0.38 0.33%: 1.26x slowdown
-â–Ž
-image-rgba box-outline-fill-100 0.01 0.30% -> 0.01 2.52%: 1.21x slowdown
-â–Ž
-image-rgba fill_solid_rgb_over-64 0.20 1.22% -> 0.22 1.59%: 1.12x slowdown
-â–
-image-rgb fill_similar_rgb_over-64 0.21 1.04% -> 0.24 1.06%: 1.11x slowdown
-â–
-image-rgba fill_image_rgb_over-64 0.21 1.19% -> 0.24 0.72%: 1.11x slowdown
-â–
-image-rgba fill_similar_rgb_over-64 0.21 0.18% -> 0.24 0.30%: 1.11x slowdown
-â–
-image-rgb fill_solid_rgba_over-64 0.22 1.66% -> 0.24 1.15%: 1.11x slowdown
-â–
-image-rgb fill_image_rgb_over-64 0.21 0.14% -> 0.24 0.80%: 1.11x slowdown
-â–
-image-rgba fill_image_rgba_over-64 0.22 1.34% -> 0.25 0.20%: 1.11x slowdown
-â–
-image-rgba fill_solid_rgba_over-64 0.22 1.48% -> 0.24 0.95%: 1.11x slowdown
-â–
-image-rgb fill_similar_rgba_over-64 0.22 1.13% -> 0.25 1.25%: 1.10x slowdown
-â–
-
-The 45% slowdown for subimage_copy is an extreme case. It's unlikely
-to hit many applications unless they often use cairo_rectangle;
-cairo_fill to copy a single pixel at a time. In any case, it shows a
-worst-case impact of the overhead of the new tessellator. The other
-slowdowns (~ 10%) are probably more realistic, and still very
-concerning.
-
-We will work to ensure that performance regressions like these are not
-present from one major release of cairo to the next, (for example,
-from 1.2 to 1.4).
-
-But we're putting this 1.3.4 snapshot out there now, even with this
-potential slowdown so that people can experiment with it. If you've
-got complex geometry, we hope you will see some benefit from the new
-tessellator. If you've got primarily simple geometry, we hope things
-won't slowdown too much, but please let us know what slowdown you see,
-if any, so we can calibrate our performance suite against real-world
-impacts.
-
-Thanks, and have fun with cairo!
-
-Snapshot 1.3.2 (2006-11-14 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the first development snapshot since the 1.2 stable series
-branched off shortly after the 1.2.4 release in August 2006.
-
-This snapshot includes all the bug fixes from the 1.2.6 release,
-(since they originated here on the 1.3 branch first and were
-cherry-picked over to 1.2). But more importantly, it contains some new
-API in preparation for a future 1.4 release, and most importantly, it
-contains several performance improvements.
-
-The bug fixes will not be reviewed here, as most of them are already
-described in the 1.2.6 release notes. But details for the new API and
-some performance improvements are included here.
-
-As with all snapshots, this is experimental code, and the new API
-added here is still experimental and is not guaranteed to appear
-unchanged in any future release of cairo.
-
-API additions
--------------
-Several new API additions are available in this release. There is a
-common theme among all the additions in that they allow cairo to
-advertise information about its state that it was refusing to
-volunteer earlier. So this isn't groundbreaking new functionality, but
-it is essential for easily achieving several tasks.
-
-The new functions can be divided into three categories:
-
- Getting information about the current clip region
- -------------------------------------------------
- cairo_clip_extents
- cairo_copy_clip_rectangles
- cairo_rectangle_list_destroy
-
- Getting information about the current dash setting
- --------------------------------------------------
- cairo_get_dash_count
- cairo_get_dash
-
- Getting information from a pattern
- ----------------------------------
- cairo_pattern_get_rgba
- cairo_pattern_get_surface
- cairo_pattern_get_color_stop_rgba
- cairo_pattern_get_color_stop_count
- cairo_pattern_get_linear_points
- cairo_pattern_get_radial_circles
-
-In each of these areas, we have new API for providing a list of
-uniform values from cairo. The closest thing we had to this before was
-cairo_copy_path, (which is rather unique in providing a list of
-non-uniform data).
-
-The copy_clip_rectangles/rectangle_list_destroy functions follow a
-style similar to that of cairo_copy_path. Meanwhile, the dash and
-pattern color stop functions introduce a new style in which there is a
-single call to return the number of elements available (get_dash_count
-and get_color_stop_count) and then a function to be called once to get
-each element (get_dash and get_color_stop_rgba).
-
-I'm interested in hearing feedback from users of these new API
-functions, particularly from people writing language bindings. One
-open question is whether the clip "getter" functionality should adopt
-a style similar to that of the new dash and color_stop interfaces.
-
-API deprecation
----------------
-The CAIRO_FORMAT_RGB16_565 enum value has been deprecated. It never
-worked as a format value for cairo_image_surface_create, and it wasn't
-necessary for supporting 16-bit 565 X server visuals.
-
-XCB backend changes
--------------------
-The XCB backend has been updated to track the latest XCB API (which
-recently had a 1.0 release).
-
-New quartz backend
-------------------
-Vladimir Vukicevic has written a new "native quartz" backend which
-will eventually replace the current "image-surface wrapping" quartz
-backend. For now, both backends are available, (the old one is
-"quartz" and the new one is "nquartz"). But it is anticipated that the
-new backend will replace the old one and take on the "quartz" name
-before this backend is marked as supported in a release of cairo.
-
-New OS/2 backend
-----------------
-Doodle and Peter Weilbacher have contributed a new, experimental
-backend for using cairo on OS/2 systems.
-
-Performance improvements
-------------------------
-Here are some highlights from cairo's performance suite showing
-improvements from cairo 1.2.6 to cairo 1.3.2. The command used to
-generate this data is:
-
- ./cairo-perf-diff 1.2.6 HEAD
-
-available in the perf/ directory of a recent checkout of cairo's
-source, (the cairo-perf-diff script does require a git checkout and
-will not work from a tar file---though ./cairo-perf can still be used
-to generate a single report there and ./cairo-perf-diff-files can be
-used to compare two reports).
-
-Results are described below both for an x86 laptop (with an old Radeon
-video card, recent X.org build, XAA, free software drivers), as well
-as for a Nokia 770. First the x86 results with comments on each, (all
-times are reported in milliseconds).
-
-Copying subsets of an image surface to an xlib surface (much faster)
---------------------------------------------------------------------
- xlib-rgba subimage_copy-512 10.50 -> : 53.97x speedup
-█████████████████████████████████████████████████████
-
-Thanks to Christopher (Monty) Montgomery for this big performance
-improvement. Any application which has a large image surface and is
-copying small pieces of it at a time to an xlib surface, (imagine an
-application that loads a single image containing all the "sprites" for
-that application), will benefit from this fix. The larger the ratio of
-the image surface to the portion being copied, the larger the benefit.
-
-Floating-point conversion (3x faster)
--------------------------------------
- xlib-rgba pattern_create_radial-16 27.75 -> 3.93 : 2.94x speedup
-██
-image-rgb pattern_create_radial-16 26.06 -> 3.74 : 2.90x speedup
-█▉
-
-Thanks to Daniel Amelang, (and others who had contributed the idea
-earlier), for this nice improvement in the speed of converting
-floating-point values to fixed-point.
-
-Text rendering (1.3 - 2x faster)
-------------------------------
- xlib-rgba text_image_rgba_source-256 319.73 -> 62.40 : 2.13x speedup
-â–ˆâ–
-image-rgb text_solid_rgba_over-64 2.85 -> 0.88 : 1.35x speedup
-â–
-
-I don't think we've ever set out to improve text performance
-specifically, but we did it a bit anyway. I believe the extra
-improvement in the xlib backend is due to Monty's image copying fix
-above, and the rest is due to the floating-point conversion speedup.
-
-Thin stroke improvements (1.5x faster)
----------------------------------------------
-image-rgb world_map-800 1641.09 -> 414.77 : 1.65x speedup
-â–‹
- xlib-rgba world_map-800 1939.66 -> 529.94 : 1.52x speedup
-▌
-
-The most modest stuff to announce in this release is the 50%
-improvement I made in the world_map case. This is in improvement that
-should help basically anything that is doing strokes with many
-straight line segments, (and the thinner the better, since that makes
-tessellation dominate rasterization). The fixes here are to use a
-custom quadrilateral tessellator rather than the generic tessellator
-for straight line segments and the miter joins.
-
-Performance results from the Nokia 770
---------------------------------------
- xlib-rgba subimage_copy-512 55.88 -> 2.04 : 27.34x speedup
-██████████████████████████â–
- xlib-rgb text_image_rgb_over-256 1487.58 -> 294.43 : 5.05x speedup
-████
-image-rgb pattern_create_radial-16 187.13 -> 91.86 : 2.04x speedup
-â–ˆ
- xlib-rgba world_map-800 21261.41 -> 15628.02 : 1.36x speedup
-â–
-
-Here we see that the subimage_copy improvement was only about half as
-large as the corresponding improvement on my laptop, (27x faster
-compared to 54x) and the floating-point conversion fix also was quite
-as significant, (2x compared to 3x). Oddly the improvement to text
-rendering performance was more than twice as good (5x compared to
-2x). I don't know what the reason for that is, but I don't think it's
-anything anybody should complain about.
-
-Release 1.2.6 (2006-11-02 Behdad Esfahbod <behdad@behdad.org>)
-==============================================================
-This is the third bug fix release in the 1.2 series, coming less than
-two months after the 1.2.4 release made on August 18.
-
-The 1.2.4 release turned out to be a pretty solid one, except for a crasher
-bug when forwarding an X connection where the client and the server have
-varying byte orders, eg. from a PPC to an i686. Other than that, various
-other small bugs have been fixed.
-
-Various improvements have been made in the testing infrastructure to prevent
-false positives, and to make sure the generated cairo shared object behaves as
-expected in terms of exported symbols and relocations.
-
-There were a total of 89 changes since 1.2.4. The following list the most
-important ones:
-
-Common fixes
-------------
-- Avoid unsigned loop control variable to eliminate infinite,
- memory-scribbling loop. (#7593)
-- Fix cairo_image_surface_create to report INVALID_FORMAT errors.
- Previously the detected error was being lost and a nil surface was
- returned that erroneously reported CAIRO_STATUS_NO_MEMORY.
-- Change _cairo_color_compute_shorts to not rely on any particular
- floating-point epsilon value. (#7497)
-- Fix infinite-join test case (bug #8379)
-- Pass correct surface to create_similar in _cairo_clip_init_deep_copy().
-
-PS/PDF fixes
-------------
-- Fix Type 1 embedding in PDF.
-- Correct the value of /LastChar in the PDF Type 1 font dictionary.
-- Improve error checking in TrueType subsetting.
-- Compute right index when looking up left side bearing. (bug #8180)
-- Correct an unsigned to signed conversion problem in truetype subsetting
- bbox.
-- Type1 subsetting: Don't put .notdef in Encoding when there are 256 glyphs.
-- Add cairo version to PS header / PDF document info dictionary.
-- Set CTM before path construction.
-
-Win32 fixes
------------
-- Get correct unhinted outlines on win32. (bug 7603)
-- Make cairo as a win32 static library possible.
-- Use CAIRO_FORMAT_RGB24 for BITSPIXEL==32 surfaces too.
-
-Build system fixes
-------------------
-- Define WINVER if it's not defined. (bug 6456)
-- Fix the AMD64 final link by removing SLIM from pixman.
-- Misc win32 compilation fixes.
-- Add Sun Pro C definition of pixman_private.
-- Use pixman_private consistently as prefix not suffix.
-- Added three tests check-plt.sh, check-def.sh, and check-header.sh that check
- that the shared object, the .def file, and the public headers agree about
- the exported symbols.
-- Require pkg-config 0.19. (#8686)
-
-
-Release 1.2.4 (2006-08-18 Carl Worth <cworth@cworth.org>)
-=========================================================
-This is the second bug fix release in the 1.2 series, coming less than
-two weeks after the 1.2.2 release made on August 8.
-
-The big motivation for a quick release was that there were a log of
-build system snags that people ran into with the 1.2.2 release. But,
-by the time we got those all done, we found that we had a bunch of
-fixes for cairo's rendering as well. So there's a lot of goodness in
-here for such a short time period.
-
-Rendering fixes
----------------
-Fix image surfaces to not be clipped when used as a source (Vladimir Vukicevic)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=72e25648c4c4bc82ddd938aa4e05887a293f0d8b
-
-Fix a couple of corner cases in dashing degenerate paths (Jeff Muizelaar)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=fbb1758ba8384650157b2bbbc93d161b0c2a05f0
-
-Fix support for type1 fonts on win32 (Adrian Johnson)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=da1019c9138695cb838a54f8b871bbfd0e8996d7
-
-Fix assertion failure when rotating bitmap fonts (Carl Worth)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=0bfa6d4f33b8ddb5dc55bbe419c15df4af856ff9
-
-Fix assertion failure when calling cairo_text_path with bitmap fonts (Carl Worth)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=9878a033531e6b96b5f27e69e10e90dee7440cd9
-
-Fix mis-handling of cairo_close_path in some situations (Tim Rowley, Carl Worth)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=53f74e59faf1af78f2f0741ccf1f23aa5dad4efc
-
-Respect font_matrix translation in _cairo_gstate_glyph_path (Behdad Esfahbod)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=f183b835b111d23e838889178aa8106ec84663b3
-
-Fix vertical metrics adjustment to work with non-identity shapes (Behdad Esfahbod)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=b7bc263842a798d657a95e539e1693372448837f
-
-[PS] Set correct ImageMatrix in _cairo_ps_surface_emit_bitmap_glyph_data (Behdad Esfahbod)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=d47388ad759b0a1a0869655a87d9b5eb6ae2445d
-
-Build system fixes
-------------------
-Fix xlib detection to prefer pkg-config to avoid false libXt dependency (Behdad Esfahbod)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=0e78e7144353703cbd28aae6a67cd9ca261f1d68
-
-Fix typos causing win32 build problem with PS,PDF, and SVG backends (Behdad Esfahbod)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=aea83b908d020e26732753830bb3056e6702a774
-
-Fix configure cache to not use stale results (Behdad Esfahbod)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=6d0e3260444a2d5b6fb0cb223ac79f1c0e7b3a6e
-
-Fix to not pass unsupported warning options to the compiler (Jens Granseuer)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=97524a8fdb899de1ae4a3e920fb7bda6d76c5571
-
-Fix to allow env. variables such as png_REQUIRES to override configure detection (Jens Granseuer)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=abd16e47d6331bd3811c908e524b4dcb6bd23bf0
-
-Fix test suite to not use an old system cairo when converting svg2png (Behdad Esfahbod)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=6122cc85c8f71b1ba2df3ab86907768edebe1781
-
-Fix test suite to not require signal.h to be present (Behdad Esfahbod)
-http://gitweb.freedesktop.org/?p=cairo;a=commit;h=6f8cf53b1e1ccdbe1ab6a275656b19c6e5120e40
-
-Code cleanups
--------------
-Many useful warnings cleanups from sparse, valgrind, and careful eyes
-(Kjartan Maraas, Pavel Roskin)
-
-Release 1.2.2 (2006-08-08 Carl Worth <cworth@cworth.org>)
-=========================================================
-This is the first bug fix release in the 1.2 series since the original
-1.2.0 release made six weeks ago.
-
-There were some very serious bugs in the 1.2.0 release, (see below),
-so everybody is encouraged to upgrade from 1.2.0 to 1.2.2. The 1.2.2
-release maintains source and binary compatibility with 1.2.0 and does
-not make any API additions.
-
-Fix crashes with BGR X servers
-------------------------------
-With cairo 1.2.0 many people reported problems with all cairo-using
-programs, (including all GTK+ programs with GTK+ >= 2.8) immediately
-crashing with a complaint about an unsupported image format. This bug
-affected X servers that do not provide the Render extension and that
-provide a visual with BGR rather than RGB channel order.
-
-report: https://bugs.freedesktop.org/show_bug.cgi?id=7294
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=9ae66174e774b57f16ad791452ed44efc2770a59
-
-Fix the "disappearing text" bug
--------------------------------
-With cairo 1.2.0 many people reported that text would disappear from
-applications, sometimes reappearing with mouse motion or
-selection. The text would disappear after the first space in a string
-of text. This bug was caused by an underlying bug in (very common) X
-servers, and only affected text rendered without antialiasing, (either
-a bitmap font or a vector font with antialiasing disabled). The bug
-was also exacerbated by a KDE migration bug that caused antialiasing
-to be disabled more than desired.
-
-report: https://bugs.freedesktop.org/show_bug.cgi?id=7494
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=456cdb3058f3b416109a9600167cd8842300ae14
-see also:
-Xorg: https://bugs.freedesktop.org/show_bug.cgi?id=7681
-KDE: http://qa.mandriva.com/show_bug.cgi?id=23990
-
-Fix broken image fallback scaling (aka. "broken printing")
-----------------------------------------------------------
-The various "print" backends, (pdf, ps, and svg), sometimes fallback
-to using image-based rendering for some operations. In cairo 1.2.0
-these image fallbacks were scaled improperly. Applications using cairo
-can influence the resolution of the image fallbacks with
-cairo_surface_set_fallback_resolution. With the bug, any value other
-than 72.0 would lead to incorrect results, (larger values would lead
-to increasingly shrunken output).
-
-report: https://bugs.freedesktop.org/show_bug.cgi?id=7533
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=1feb4291cf7813494355459bb547eec604c54ffb
-
-Fix inadvertent semantic change of font matrix translation (Behdad Esfahbod)
-----------------------------------------------------------------------------
-The 1.2.0 release introduced an inadvertent change to how the
-translation components of a font matrix are interpreted. In the 1.0
-series, font matrix translation could be used to offset the glyph
-origin, (though glyph metrics were reported incorrectly in
-1.0). However in 1.2.0, the translation was applied to the advance
-values between each glyph. The 1.2.0 behavior is fairly useless in
-practice, and it was not intentional to introduce a semantic
-change. With 1.2.2 we return to the 1.0 semantics, with a much better
-implementation that provides correct glyph metrics.
-
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=84840e6bba6e72aa88fad7a0ee929e8955ba9051
-
-Fix create_similar to preserve fallback resolution and font options (Behdad Esfahbod)
--------------------------------------------------------------------------------------
-There has been a long-standing issue with cairo_surface_create_similar
-such that font options and other settings from the original
-destination surface would not be preserved to the intermediate
-"similar" surface. This could result in incorrect rendering
-(particularly with respect to text hinting/antialiasing) with
-fallbacks, for example.
-
-report: https://bugs.freedesktop.org/show_bug.cgi?id=4106
-fixes: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=9fcb3c32c1f16fe6ab913e27eb54d18b7d9a06b0
- http://gitweb.freedesktop.org/?p=cairo;a=commit;h=bdb4e1edadb78a2118ff70b28163f8bd4317f1ec
-
-xlib: Fix text performance regression from 1.0 to 1.2.0 (Vladimir Vukicevic)
-----------------------------------------------------------------------------
-Several people noticed that upgrading from cairo 1.0 to cairo 1.2.0
-caused a significant performance regression when using the xlib
-backend. This performance regression was particularly noticeable when
-doing lots of text rendering and when using a high-latency connection
-to the X server, (such as a remote X server over an ssh
-connection). The slowdown was identified and fixed in 1.2.2.
-
-report: https://bugs.freedesktop.org/show_bug.cgi?id=7514
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=b7191885c88068dad57d68ced69a752d1162b12c
-
-PDF: Eliminate dependency on FreeType library dependency (Adrian Johnson)
--------------------------------------------------------------------------
-The cairo 1.2 series adds a supported pdf backend to cairo. In cairo
-1.2.0 this backend required the freetype library, which was an
-undesirable dependency on systems such as win32, (cairo is designed to
-always prefer the "native" font system). As of cairo 1.2.2 the
-freetype library is not required to use the pdf backend on the win32
-platform.
-
-report: https://bugs.freedesktop.org/show_bug.cgi?id=7538
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=a0989f427be87c60415963dd6822b3c5c3781691
-
-PDF: Fix broken output on amd64 (Adrian Johnson)
-------------------------------------------------
-report: http://bugzilla.gnome.org/show_bug.cgi?id=349826
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=f4b12e497b7ac282b2f6831b8fb68deebc412e60
-
-PS: Fix broken output for truetype fonts > 64k (Adrian Johnson)
----------------------------------------------------------------
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=067d97eb1793a6b0d0dddfbd0b54117844511a94
-
-PDF: Fix so that dashing doesn't get stuck on (Kent Worsnop)
-------------------------------------------------------------
-Kent notices that with the PDF backend in cairo 1.2.0 as soon as a
-stroke was performed with dashing, all subsequent strokes would also
-be dashed. There was no way to turn dashing off again.
-
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=778c4730a86296bf0a71080cf7008d7291792256
-
-Fix memory leaks in failure paths in gradient creation (Alfred Peng)
---------------------------------------------------------------------
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=db06681b487873788b51a6766894fc619eb8d8f2
-
-Fix memory leak in _cairo_surface_show_glyphs (Chris Wilson)
-------------------------------------------------------------
-report: https://bugs.freedesktop.org/show_bug.cgi?id=7766
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=e2fddcccb43d06486d3680a19cfdd5a54963fcbd
-
-Solaris: Add definition of cairo_private for some Sun compilers (Alfred Peng)
------------------------------------------------------------------------------
-report: https://bugzilla.mozilla.org/show_bug.cgi?id=341874
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=04757a3aa8deeff3265719ebe01b021638990ec6
-
-Solaris: Change version number of Sun's Xorg server with buggy repeat (Brian Cameron)
--------------------------------------------------------------------------------------
-report: https://bugs.freedesktop.org/show_bug.cgi?id=7483
-fix: http://gitweb.freedesktop.org/?p=cairo;a=commit;h=e0ad1aa995bcec4246c0b8ab0d5a5a79871ce235
-
-Various memory leak fixes
--------------------------
-Fix memory leak in _cairo_surface_show_glyphs (bug 7766)
-Fix file handle leak in failure path (bug 7616)
-Fix some memory leaks in the test cases.
-Fix some memory leaks in font subsetting code used in print backends.
-
-Documentation improvements (Behdad Esfahbod)
---------------------------------------------
-Added new documentation for several functions (cairo_show_page,
-cairo_copy_page, cairo_in_stroke, cairo_in_fill).
-
-Fixed some syntax errors that were preventing some existing
-documentation from being published.
-
-Fixed several minor typographical errors.
-
-Added an index for new symbols in 1.2.
-
-Release 1.2.0 (2006-06-27 Carl Worth <cworth@cworth.org>)
-=========================================================
-This is the culmination of the work that has gone on within the 1.1
-branch of cairo.
-
-There has been one API addition since the cairo 1.1.10 snapshot:
-
- cairo_xlib_surface_get_width
- cairo_xlib_surface_get_height
-
-There's also a new feature without any API change:
-
- Dots can now be drawn by using CAIRO_LINE_CAP_ROUND with
- degenerate sub-paths, (cairo_move_to() followed by either
- cairo_close_path() or a cairo_line_to() to the same location).
-
-And at least the following bugs have been fixed:
-
- 6759 fontconfig option AntiAlias doesn't work in cairo 1.1.2
- 6955 Some characters aren't displayed when using xlib (cache u...
- 7268 positive device_offset values don't work as source
- * PDF emit_glyph function needs to support bitmapped glyphs
- * PS emit_glyph function needs to support bitmapped glyphs
- * SVG emit_glyph function needs to support bitmapped glyphs
- * PDF: minefield page one is falling back unnecessarily
- * PS/PDF: Fix broken placement for vertical glyphs
- * PS: Fix to not draw BUTT-capped zero-length dash segments
- * Do device offset before float->fixed conversion
- http://bugzilla.gnome.org/show_bug.cgi?id=332266
- * PS: Fix source surfaces with transformations
- * PS: Fix to not draw BUTT-capped degnerate sub-paths
- * PS: Don't walk off end of array when printing "~>"
- * Fix some memory leaks in the test suite rig
- * SVG: Fix memory leak when using cairo_mask
- * Fix ExtendMode::REFLECT and EXTEND_PAD to not crash (though these are
- still not yet fully implemented for surface patterns).
-
-This has been a tremendous effort by everyone, and I'm proud to have
-been a part of it. Congratulations to all contributors to cairo!
-
-Snapshot 1.1.10 (2006-06-16 Carl Worth <cworth@cworth.org>)
-===========================================================
-This is the fifth in a series of snapshots working toward the 1.2
-release of cairo.
-
-The primary motivation for this snapshot is to fix a long-standing bug
-that had long been silent, but as of the 1.1.8 snapshot started
-causing crashes when run against 16-bit depth X servers, (often Xvnc
-or Xnest). The fix for this adds a new CAIRO_FORMAT_RGB16_565 to the
-API.
-
-This snapshot also includes a rewrite of cairo's SVG backend to
-eliminate the dependency on libxml2. With this in place, cairo 1.2
-will not depend on any libraries that cairo 1.0 did not.
-
-As usual, there are also a few fixes for minor bugs.
-
-Snapshot 1.1.8 (2006-06-14 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the fourth in a series of snapshots working toward the 1.2
-release of cairo. At this point, all major features of the 1.2 release
-are in place, leaving just a few bug fixes left.
-
-In particular, there well be no additional API changes between this
-1.1.8 snapshot and the 1.2 release.
-
-The announcement for 1.1.6 mentioned several API changes being
-considered. Only one of these changes was actually implemented
-(set_dpi -> fallback_resolution). This change does introduce one
-source-level incompatibility with respect to previous 1.1.x snapshots,
-so see below for details.
-
-Here is an abbreviated summary of changes since the 1.1.6 snapshot:
-
-** API Change **
-----------------
-According to the plan mentioned in the 1.1.6 notes, one source-level
-incompatible change has been implemented. The following three
-functions have been removed from cairo's API:
-
- cairo_pdf_surface_set_dpi
- cairo_ps_surface_set_dpi
- cairo_svg_surface_set_dpi
-
-and in their place the following function has been added:
-
- cairo_surface_set_fallback_resolution
-
-The signature and semantics of the function remains the same, so it is
-a simple matter of changing the name of the function when calling
-it. As a transition mechanism, this snapshot will (on many systems)
-build to include the old symbols so that code previously compiled will
-still run. However, all source code using the old names must be
-updated before it will compile. And the upcoming 1.2 release is not
-anticipated to include the old symbols.
-
-Finally, it should be pointed out that the old symbols never existed
-in the supported API of any stable release of cairo. (In the stable
-1.0 releases the PDF, PS, and SVG backends were advertised as
-experimental and unstable.)
-
-And, as always, cairo continues to maintain source and binary
-compatibility between major releases. So applications compiled against
-supported backends in a stable release of cairo (1.0.4 say) will
-continue to compile and run without modification against new major
-releases (1.2.0 say) without modification.
-
-API additions
--------------
-The following new functions have been added to cairo's API:
-
- cairo_surface_get_content
- cairo_debug_reset_static_data
- cairo_image_surface_get_data
- cairo_image_surface_get_format
- cairo_image_surface_get_stride
- cairo_win32_font_face_create_for_hfont
-
-New, backend-specific pkg-config files
---------------------------------------
-In addition to the original cairo.pc file, cairo will also now install
-a pkg-config files for each configured backend, (for example
-cairo-pdf.pc, cairo-svg.pc, cairo-xlib.pc, cairo-win32.pc, etc.) this
-also includes optional font backends (such as cairo-ft.pc) and the
-optional png functionality (cairo-png.pc).
-
-These new pkg-config files should be very convenient for allowing
-cairo-using code to easily check for the existing of optional
-functionality in cairo without having to write complex rules to grub
-through cairo header files or the compiled library looking for
-symbols.
-
-Printing backend (PS, PDF, and SVG)
------------------------------------
-Improving the quality of the "printing" backends has been a priority
-of the development between cairo 1.1.6 and cairo 1.1.8.
-
-The big improvement here is in the area of text output. Previously, at
-best, text was output as paths without taking advantage of any font
-support available in the output file format.
-
-Now, at the minimum text paths will be shared by using type3 fonts
-(for PS and PDF---and similarly, defs for SVG). Also, if possible,
-type3 and truetype fonts will be embedded in PostScript and PDF
-output. There are still some known bugs with this, (for example,
-selecting text in a cairo-generated PDF file with an embedded truetype
-font does not work). So there will be some more changes in this area
-before cairo 1.2, but do try test this feature out as it exists so
-far.
-
-Many thanks to Kristian Høgsberg for the truetype and type1 font
-embedding.
-
-win32 backend
--------------
-Performance improvements by preferring GDI over pixman rendering when possible.
-Fixes for text rendering.
-
-xlib backend
-------------
-Fix potentially big performance bug by making xlib's create_similar
-try harder to create a pixmap of a depth matching that of the screen.
-
-Bug fixes
----------
-Among various other fixes, the following bugs listed in bugzilla have
-been fixed:
-
- Bug 2488: Patch to fix pixman samping location bug (#2488).
- https://bugs.freedesktop.org/show_bug.cgi?id=2488
-
- Bug 4196: undef MIN an MAX before defining to avoid duplicate definition
- https://bugs.freedesktop.org/show_bug.cgi?id=4196
-
- Bug 4723: configure.in: Fix m4 quoting when examining pkg-config version
- https://bugs.freedesktop.org/show_bug.cgi?id=4723
-
- Bug 4882: Flag Sun's X server has having buggy_repeat.
- https://bugs.freedesktop.org/show_bug.cgi?id=4882
-
- Bug 5306: test/pdf2png: Add missing include of stdio.h
- https://bugs.freedesktop.org/show_bug.cgi?id=5306
-
- Bug 7075: Fix make clean to remove cairo.def
- https://bugs.freedesktop.org/show_bug.cgi?id=7075
-
-(Many thanks to Behdad Esfahbod for helping us track down and fix many
-of these.)
-
-Snapshot 1.1.6 (2006-05-04 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the third in a series of snapshots working toward the imminent
-1.2 release of cairo. For a list of items still needing work on the
-cairo 1.2 roadmap, please see:
-
- http://cairographics.org/ROADMAP
-
-As can be seen in that list, there are no longer any API additions
-left on the roadmap. Instead, there is a feature (PDF type 3 fonts) a
-performance optimization (X server gradients) and a list of bug
-fixes. This gives us a fair amount of freedom to cut the 1.2 release
-at almost any point by deciding to defer remaining bug fixes to
-subsequent maintenance releases such as 1.2.2 and 1.2.4.
-
-Before we will do that, we must first be wiling to commit to all the
-new API additions. As a heads-up, there are a couple of potential API
-changes being considered. (Note that these are changes to new API
-introduced during 1.1 so these will not introduce API
-incompatibilities compared to the stable 1.0 series). The changes
-being considered are:
-
- cairo_get_group_target: may acquire x and y offset return
- parameters. May also be eliminated in favor of
- cairo_get_target assuming its role
-
- cairo_pdf_surface_set_dpi:
- cairo_ps_surface_set_dpi:
- cairo_svg_surface_set_dpi: These functions may be removed in favor
- of a new cairo_surface_set_fallback_resolution
-
-Additionally there is the possibility of a slight change in the
-semantics of cairo_set_line_width. We believe the current behavior of the sequence:
-
- cairo_set_line_width; ... change CTM ...; cairo_stroke;
-
-is buggy. It is currently behaving the same as:
-
- ... change CTM ...; cairo_set_line_width; cairo_stroke;
-
-We are considering fixing this bug before 1.2 with the hope that
-nobody is already relying on the buggy behavior described here. Do
-shout if you suspect you might be in that position.
-
-The items included in this snapshot (since the 1.1.4 snapshot) are
-described below.
-
-API additions
--------------
-The long-awaited group-rendering support is now available with the
-following function calls:
-
- cairo_push_group
- cairo_push_group_with_content
- cairo_pop_group
- cairo_pop_group_to_source
- cairo_get_group_target
-
-This API provides a much more convenient mechanism for doing rendering
-to an intermediate surface without the need to manually create a
-temporary cairo_surface_t and a temporary cairo_t and clean them up
-afterwards.
-
-Add the following missing get function to complement
-cairo_surface_set_device_offset:
-
- cairo_surface_get_device_offset
-
-PDF backend (API addition)
---------------------------
-The PDF backend now provides for per-page size changes, (similar to
-what the PostScript backend got in the 1.1.4 snapshot). The new API
-is:
-
- cairo_pdf_surface_set_size
-
-Xlib backend (API additions)
-----------------------------
-The following functions have been added to allow the extraction of
-Xlib surface:
-
- cairo_xlib_surface_get_display
- cairo_xlib_surface_get_drawable
- cairo_xlib_surface_get_screen
- cairo_xlib_surface_get_visual
- cairo_xlib_surface_get_depth
-
-XCB backend (experimental)
---------------------------
-Update backend so that it now compiles with the recent XCB 0.9 release.
-
-Bug fixes and memory leak cleanup
----------------------------------
-Various little things, nothing too significant though.
-
-Snapshot 1.1.4 (2006-05-03 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the second in a series of snapshots working toward the
-upcoming 1.2 release of cairo. For a list of items still needing work
-on the cairo 1.2 roadmap, please see:
-
- http://cairographics.org/ROADMAP
-
-The items included in this snapshot (since the 1.1.2 snapshot) are
-described below.
-
-PostScript backend: new printing-oriented API
----------------------------------------------
-We anticipate that with cairo 1.2, toolkits will begin to use cairo
-for printing on systems that use PostScript as the spool format. To
-support this use case, we have added 4 new function calls that are
-specific to the PostScript backend:
-
- cairo_ps_surface_set_size
- cairo_ps_surface_dsc_comment
- cairo_ps_surface_dsc_begin_setup
- cairo_ps_surface_dsc_begin_page_setup
-
-These functions allow variation of the page size/orientation from one
-page to the next in the PostScript output. They also allow the toolkit
-to provide per-document and per-page printer control options in a
-device-independent way, (for example, by using PPD options and
-emitting them as DSC comments into the PostScript output). This should
-allow toolkits to provide very fine-grained control of many options
-available in printers, (media size, media type, tray selection, etc.).
-
-SVG backend: builds by default, version control
------------------------------------------------
-The SVG backend continues to see major improvements. It is expected
-that the SVG backend will be a supported backend in the 1.2
-release. This backend will now be built by default if its dependencies
-(freetype and libxml2) are met.
-
-Additionally, the SVG backend now has flexibility with regard to what
-version of SVG it targets. It will target SVG 1.1 by default, which
-will require image fallbacks for some of the "fancier" cairo
-compositing operators. Or with the following new function calls:
-
- cairo_svg_surface_restrict_to_version
- cairo_svg_get_versions
- cairo_svg_version_to_string
-
-it can be made to target SVG 1.2 in which there is native support for
-these compositing operators.
-
-Bug fixes
----------
-At least the following bugs have been fixed since the 1.1.2 snapshot:
-
-crash at XRenderAddGlyphs
-https://bugs.freedesktop.org/show_bug.cgi?id=4705
-
-Can't build cairo-1.1.2 on opensolaris due to " void function cannot return value"
-https://bugs.freedesktop.org/show_bug.cgi?id=6792
-
-Missing out-of-memory check at gfx/cairo/cairo/src/cairo-atsui-font.c:185
-https://bugzilla.mozilla.org/show_bug.cgi?id=336129
-
-A couple of memory leaks.
-
-Snapshot 1.1.2 (2006-04-25 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is the first in a series of snapshots working toward the upcoming
-1.2 release of cairo. (Subsequent snapshot will use successive even
-numbers for the third digit, 1.1.4, 1.1.6, etc.) This snapshot is
-backwards-compatible with the 1.0 series---it makes a few API
-additions but does not remove any API.
-
-PostScript and PDF backends are no longer "experimental"
---------------------------------------------------------
-The major theme of the 1.2 release is improved PostScript and PDF
-backends for cairo. Unlike the 1.0 series, in the 1.2 series these
-backends will not be marked as experimental and will be enabled by
-default. We encourage people to test this snapshot and the PS/PDF
-backends in particular as much as possible.
-
-The PostScript and PDF output is not yet ideal.
-
- * One major problem with the PostScript output is that image
- fallbacks are used more often than strictly necessary, and the
- image fallbacks are at a lower resolution than desired, (the
- cairo_ps_surface_set_dpi call is ignored).
-
- * The major drawback of the current PDF backend implementation is
- its text support. Every glyph is represented by a filled path in
- the PDF file. The causes file sizes to be much larger and
- rendering to be much slower than desired.
-
-It is anticipated that both of these shortcomings will see some
-improvements before the final 1.2 release.
-
-In spite of those shortcomings, we hope that the PS and PDF backends
-will yield faithful results for pretty much any cairo operations you
-can throw at them. Please let us know if you are getting obviously
-"different" results from the PS/PDF backends than from the image or
-xlib backends.
-
-Other new experimental backends
--------------------------------
-This snapshot includes three new backends that did not exist in the
-1.0 series:
-
- * beos backend
-
- * directfb backend
-
- * svg backend
-
-These are all currently marked "experimental" and are disabled by
-default. But the SVG backend in particular has seen a lot of recent
-development and is very close to passing the entire cairo test
-suite. It is possible that this backend will become a fully supported
-backend by the time of the cairo 1.2 release.
-
-Public API additions
---------------------
-There have been a few new API functions added to cairo, including:
-
-New get_type functions for querying sub-types of object:
-
- cairo_surface_get_type
- cairo_pattern_get_type
- cairo_font_face_get_type
- cairo_scaled_font_get_type
-
-More convenience in working with cairo_scaled_font_t with new getter
-functions:
-
- cairo_scaled_font_get_font_face
- cairo_scaled_font_get_font_matrix
- cairo_scaled_font_get_ctm
- cairo_scaled_font_get_font_options
-
-As well as a convenience function for setting a scaled font into a
-cairo context:
-
- cairo_set_scaled_font
-
-and a function to allow text extents to be queried directly from a
-scaled font, (without requiring a cairo_surface_t or a cairo_t):
-
- cairo_scaled_font_text_extents
-
-These new scaled font functions were motivated by the needs of the
-pango library.
-
-Finally, a new path-construction function was added which clears the
-current point in preparation for a new sub path. This makes cairo_arc
-easier to use in some situations:
-
- cairo_new_sub_path
-
-Before the 1.2 release is final we do still plan a few more API
-additions specifically motivated by the needs of Mozilla/Firefox.
-
-Optimizations and bug fixes
----------------------------
-Shortly after the 1.0 maintenance series branched off the mainline
-there was a major rework of the cairo font internals. This should
-provide some good performance benefits, but it's also another area
-people should look at closely for potential regressions.
-
-There has not yet been any widespread, systematic optimization of
-cairo, but various performance improvements have been made, (and some
-of them are fairly significant). So if some things seem faster than
-1.0 then things are good. If there are any performance regressions
-compared to 1.0 then there is a real problem and we would like to hear
-about that.
-
-There has been a huge number of bug fixes---too many to mention in
-detail. Again, things should be better, and never worse compared to
-1.0. Please let us know if your testing shows otherwise.
-
-Release 1.0.2 (2005-10-03 Carl Worth <cworth@cworth.org>)
-=========================================================
-For each bug number XXXX below, see:
-
- https://bugs.freedesktop.org/show_bug.cgi?id=XXXX
-
-for more details.
-
-General bug fixes
------------------
- * 4408 - Add support for dashing of stroked curves
- (Carl Worth)
-
- * 4409 - Fix dashing so that each dash is capped on both ends
- (Carl Worth)
-
- * 4414 - Prevent SIGILL failures (proper use of -mmmx and -msse flags)
- (Sebastien Bacher, Billy Biggs)
-
- * 4299 - Fix crashes with text display in multi-threaded program
- (Alexey Shabalin, Carl Worth)
-
- * 4401 - Do not use sincos function since it is buggy on some platforms)
- (Tim Mooney, Carl Worth)
-
- * 4245 - Fix several bugs in the test suite exposed by amd64 systems
- (Seemant Kulleen, Carl Worth)
-
- * 4321 - Add missing byteswapping on GetImage/PutImage
- (Sjoerd Simons, Owen Taylor)
-
- * 4220 - Make the check for rectangular trapezoids simpler and more accurate
- (Richard Stellingwerff, Owen Taylor)
-
- * 4260 - Add missing channel-order swapping for antialised fonts
- (Barbie LeVile, Owen Taylor)
-
- * 4283 - Fix compilation failure with aggressive inlining (gcc -O3)
- (Marco Manfredini, Owen Taylor)
-
- * 4208 - Fix some warnings from sparse
- (Kjartan Maraas, Billy Biggs)
-
- * 4269 - Fix to not crash when compiled with -fomit-frame-pointer
- (Ronald Wahl, Owen Taylor)
-
- * 4263 - Improve performance for vertical gradients
- (Richard Stellingwerff, Owen Taylor)
-
- * 4231
- * 4298 - Accomodate gentoo and Mandriva versions in X server vendor string check
- (Billy Biggs, Frederic Crozat, Owen Taylor)
-
-win32-specific fixes
---------------------
- * 4599 - Fix "missing wedges" on some stroked paths (win32)
- (Tim Rowley, Jonathan Watt, Bertram Felgenhauer, Carl Worth, Keith Packard)
-
- * 4612 - Fix disappearing text if first character out of surface (win32)
- (Tim Rowley)
-
- * 4602 - Fix shutdown of cairo from failing intermediate, size-0 bitmaps (win32)
- Aka. the "white rectangles" bug from mozilla-svg testing
- (Tim Rowley)
-
- * Various portability improvements for win32
- (Hans Breuer, Owen Taylor, Carl Worth)
-
- * 4593 - Fix font sizes to match user expectations (win32)
- (Tor Lillqvist, Owen Taylor)
-
- * 3927 - Fix to report metrics of size 0 for glyph-not-available (win32)
- (Hans Breuer, Owen Taylor, Tor Lillqvist)
-
- * Add locking primitives for win32
- (Hans Breuer)
-
-xlib-specific fixes
--------------------
- * Fix crash from size-0 pixmap due to empty clip region (xlib)
- (Radek Doulík, Carl Worth)
-
-Release 1.0.0 (2005-08-24 Carl Worth <cworth@cworth.org>)
-=========================================================
-Experimental backends
----------------------
- * The Glitz, PS, PDF, Quartz, and XCB backends have been declared
- experimental, and are not part of the API guarantees that accompany
- this release. They are not built by default, even when the required
- libraries are available, and must be enabled explicitly with
- --enable-ps, --enable-pdf, --enable-quartz or --enable-xcb.
-
- It is very painful for us to be pushing out a major release without
- these backends enabled. There has been a tremendous amount of work
- put into each one and all are quite functional to some
- extent. However, each also has some limitations. And none of these
- backends have been tested to the level of completeness and
- correctness that we expect from cairo backends.
-
- We do encourage people to experiment with these backends and report
- success, failure, or means of improving them.
-
-Operator behavior
------------------
- * Prior to 0.9.0 the SOURCE, CLEAR and a number of other operators
- behaved in an inconsistent and buggy fashion and could affect areas
- outside the clip mask. In 0.9.0, these six "unbounded" operators
- were fixed to consistently clear areas outside the shape but within
- the clip mask. This is useful behavior for an operator such as IN,
- but not what was expected for SOURCE and CLEAR. So, in this release
- the behavior of SOURCE and CLEAR has been changed again. They now
- affect areas only within both the source and shape. We can write
- the new operators as:
-
- SOURCE: dest' = (mask IN clip) ? source : dest
- CLEAR: dest' = (mask IN clip) ? 0 : dest
-
-Behavior and API changes
-------------------------
- * Setting the filter on a gradient pattern would change the
- interpolation between color stops away from the normal linear
- interpolation. This dubious behavior has been removed.
-
- * The CAIRO_CONTENT_VALID() and CAIRO_FORMAT_VALID() macros --
- implementation details that leaked into cairo.h -- have been moved
- into an internal header.
-
- * The cairo_show_text function now advances the current point
- according to the total advance values of the string.
-
-API additions
--------------
- * cairo_set_dash can now detect error and can set
- CAIRO_STATUS_INVALID_DASH.
-
-Features
---------
- * When compiled against recent versions of fontconfig and FreeType,
- artificial bold fonts can now be turned on from fonts.conf using
- the FC_EMBOLDEN fontconfig key.
-
-Optimization
-------------
- * The compositing code from the 'xserver' code tree has now been
- completely merged into libpixman. This includes MMX optimization of
- common operations.
-
- * The image transformation code in libpixman has been improved and
- now performs significantly faster.
-
-Bug fixes
----------
- * Several crashes related to corruption in the font caches have been
- fixed.
-
- * All test cases now match pixel-for-pixel on x86 and PPC; this
- required fixing bugs in the compositing, stroking, and pattern
- rendering code.
-
- * Negative dash offsets have been fixed to work correctly.
-
- * The stroking of paths with mutiple subpaths has now been fixed to
- apply caps to all subpaths rather than just the last one.
-
- * Many build fixes for better portability on various systems.
-
- * Lots of other bug fixes, but we're too tired to describe them in
- more detail here.
-
-Release 0.9.2 (2005-08-13 Carl Worth <cworth@cworth.org>)
-=========================================================
-Release numbering
------------------
- * You will notice that this release jumped from 0.9.0 to 0.9.2. We've
- decided to use an odd micro version number (eg. 0.9.1) to indicate
- in-progress development between releases. As soon as 0.9.2 is
- tagged, the version will be incremented in CVS to 0.9.3 where it
- will stay until just before 0.9.4 is built, uploaded, and tagged.
-
- So, even-micro == a released version, odd-micro == something in-between.
-
-Libpixman dependency dropped
-----------------------------
- * As of this release, the dependency on an external libpixman has
- been dropped. Instead, the code from libpixman needed for cairo has
- been incorporated into the cairo source tree. The motivation for
- this change is that while cairo's API is stable and ready to be
- maintained after the 1.0 release, libpixman's API is not, so we do
- not want to expose it at this time.
-
- Also, the incorporation of libpixman into cairo also renames all
- previously-public libpixman symbols in order to avoid any conflict
- with a future release of libpixman
-
-API additions
--------------
- * Macros and functions have been added so that the version of cairo
- can be queried at either compile-time or at run-time. The version
- is made available as both a human-readable string and as a single
- integer:
-
- CAIRO_VERSION_STRING eg. "0.9.2"
- CAIRO_VERSION eg. 000902
-
- const char*
- cairo_version_string (void); /* eg. "0.9.2" */
-
- int
- cairo_version (void); /* eg. 000902 */
-
- A macro is provided to convert a three-part component version into
- the encoded single-integer form:
-
- CAIRO_VERSION_ENCODE(X,Y,Z)
-
- For example, the CAIRO_VERSION value of 000902 is obtained as
- CAIRO_VERSION_ENCODE(0,9,2). The intent is to make version
- comparisons easy, either at compile-time:
-
- #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(0,9,2)
- ...
- #endif
-
- Or at run-time:
-
- if (cairo_version() >= CAIRO_VERSION_ENCODE(0,9,2)) { /* ... */ }
-
-Thread safety
--------------
- * This release adds pthread-based locking (when available) to make
- the caches used by cairo safe for threaded programs. Some may
- remember a failed experiment with this locking between the 0.5.1
- and 0.5.2 snapshots, (where even single-threaded programs that
- linked with -lpthread would deadlock). We believe that that problem
- has been fixed, so we are looking forward to testing and reports
- from users with threaded applications.
-
-Bug fixes
----------
- * The XCB and Quartz backends failed to compiled in the 0.9.0 release
- due to minor syntax errors. These have now been fixed.
-
- * Various crashes in glitz and pixman due to size 0 glyphs have been
- fixed.
-
-Release 0.9.0 (2005-08-08 Carl Worth <cworth@cworth.org>)
-=========================================================
-Soname change
--------------
- * In all prior snapshots, the libtool library versioning was set to
- 1:0:0. As this release is intended to mark the beginning of
- backwards-compatible releases, the versioning has been incremented
- to 2:0:0. You will notice that the numeric extension on the
- installed library filename will change similarly.
-
- This change will also require all cairo-using applications to be
- recompiled. We recognize that this may cause some frustration since
- this release is backwards-compatible with 0.6.0 and in that sense
- "shouldn't" require re-compilation. However, since all historical
- snapshots have used the same 1:0:0 version in spite of incompatible
- API changes between them, it was essential that the upcoming 1.0
- release series have distinct library versioning.
-
- All future releases will use the library versioning to properly
- indicate compatibility between releases. So, any application
- re-compiled now to work with the 0.9.0 will not need to be
- recompiled when a compatible 1.0 release of cairo is made in the
- future.
-
-API additions
--------------
- * Add new function calls to set/get the current antialiasing mode in
- the graphics state:
-
- cairo_set_antialias
- cairo_get_antialias
-
- This call accepts the same modes recently added for font options
- (NONE or GRAY) but affects the rendering of geometry other than
- text. The intent of this call is to enable more precise control of
- which pixels are affected by each operation, for example to allow
- for full-scene antialiasing for seam-free rendering. It is not
- expected that non-antialiased rendering will perform better than
- anti-aliased rendering.
-
- * Three new functions were added to provide support for mixed cairo-
- and non-cairo drawing to the same surface:
-
- cairo_surface_mark_dirty
- cairo_surface_mark_dirty_rectangle
- cairo_surface_flush
-
- * The return type of the several "reference" functions was change,
- (API compatibly), from void to the same type as the argument. The
- affected functions are:
-
- cairo_font_face_reference
- cairo_scaled_font_reference
- cairo_pattern_reference
- cairo_surface_reference
- cairo_reference
-
- This allows a convenient way to assign and reference in a single
- statement.
-
-Semantic changes
-----------------
- * The behavior of cairo_set_source with a pattern with a non-identity
- matrix was previously not well-defined. The new behavior is as
- follows:
-
- The pattern's transformation matrix will be locked to the
- user space in effect at the time of cairo_set_source(). This means
- that further modifications of the CTM will not affect the source
- pattern.
-
-cairo-win32
------------
- * Some portability improvements, (eg. workaround for missing stdint.h).
-
-cairo-ft
---------
- * Updated to allow compilation with older versions of freetype.
-
-Bug fixes
----------
- * Fix the unbounded operators to actually produce a correct result,
- (previously the results were artificially restricted to the
- bounding box of whatever shape was being drawn rather than
- extending out infinitely). The fixed operators are:
-
- CAIRO_OPERATOR_CLEAR
- CAIRO_OPERATOR_SOURCE
- CAIRO_OPERATOR_OUT
- CAIRO_OPERATOR_IN
- CAIRO_OPERATOR_DEST_IN
- CAIRO_OPERATOR_DEST_ATOP
-
- * Fix cairo_mask and cairo_mask_surface to transform the mask by the
- current transformation matrix (CTM).
-
- * Fix cairo_set_source to lock the CTM used to transform the pattern.
-
- * Workaround for X server Render bug involving repeating patterns
- with a general transformation matrix.
-
- * cairo_get_font_face fixed to return a "nil" font face object rather
- than NULL on error.
-
- * cairo_set_font_face fixed to not crash if given a NULL font face,
- (which is the documented interface for restoring the default font
- face).
-
- * Fix xlib glyphset caching to not try to free a NULL glyph.
-
-Snapshot 0.6.0 (2005-07-28 Carl Worth <cworth@cworth.org>)
-==========================================================
-API changes
------------
-* The prototypes of the following functions have changed:
-
- cairo_xlib_surface_create_with_xrender_format
- cairo_xlib_surface_create_for_bitmap
-
- A Screen* parameter has been added to each. This allows the cairo
- xlib backend to work correctly with multi-head X servers.
-
-* The following function has been modified:
-
- cairo_scaled_font_create
-
- to accept a cairo_font_options_t*. See below fore more details.
-
-* All opaque, reference-counted cairo objects have now been moved to a
- standard error-handling scheme. The new objects to receive this
- treatment are cairo_font_face_t, cairo_scaled_font_t, and
- cairo_surface_t. (Previous snapshots already provided this scheme
- for cairo_t, cairo_path_t, and cairo_pattern_t.)
-
- This changes two functions to have a return type of void rather than
- cairo_status_t:
-
- cairo_scaled_font_extent
- cairo_surface_finish
-
- And significantly, none of the create functions for any of the
- objects listed above will return NULL. The pointer returned from any
- function will now always be a valid pointer and should always be
- passed to the corresponding destroy function when finished
-
- The simplest strategy for porting code is to switch from:
-
- object = cairo_<object>_create ();
- if (object == NULL)
- goto BAILOUT;
-
- /* act on object */
-
- cairo_<object>_destroy (object);
-
- to:
-
- object = cairo_<object>_create ();
- if (cairo_<object>_status (object))
- goto BAILOUT;
-
- /* act on object */
-
- cairo_<object>_destroy (object);
-
- But significantly, it is not required to check for an error status
- before the "act on object" portions of the code above. All
- operations on an object with an error status are, by definition,
- no-ops without side effect. So new code might be written in an
- easier-to-read style of:
-
- object = cairo_<object>_create ();
-
- /* act on object */
-
- cairo_<object>_destroy (object);
-
- with cairo_<object>_status checks placed only at strategic
- locations. For example, passing an error object to another object,
- (eg. cairo_set_source with an in-error pattern), will propagate the
- error to the subsequent object (eg. the cairo_t). This means that
- error checking can often be deferred even beyond the destruction of
- a temporary object.
-
-API additions
--------------
-* New functions for checking the status of objects that have been
- switched to the common error-handling scheme:
-
- cairo_font_face_status
- cairo_scaled_font_status
- cairo_surface_status
-
-* The _cairo_error function which was added in 0.5.1 has now been made
- much more useful. In 0.5.1 only errors on cairo_t objects passed
- through _cairo_error. Now, an error on any object should pass
- through _cairo_error making it much more reliable as a debugging
- mechanism for finding when an error first occurs.
-
-* Added new font options support with a myriad of functions:
-
- cairo_font_options_create
- cairo_font_options_copy
- cairo_font_options_destroy
-
- cairo_font_options_status
-
- cairo_font_options_merge
- cairo_font_options_equal
- cairo_font_options_hash
-
- cairo_font_options_set_antialias
- cairo_font_options_get_antialias
- cairo_font_options_set_subpixel_order
- cairo_font_options_get_subpixel_order
- cairo_font_options_set_hint_style
- cairo_font_options_get_hint_style
- cairo_font_options_set_hint_metrics
- cairo_font_options_get_hint_metrics
-
- cairo_surface_get_font_options
-
- cairo_ft_font_options_substitute
-
- cairo_set_font_options
- cairo_get_font_options
-
- This new font options support allows the application to have much
- more fine-grained control over how fonts are rendered.
- Significantly, it also allows surface backends to have some
- influence over the process. For example, the xlib backend now
- queries existing Xft properties to set font option defaults.
-
-* New function:
-
- cairo_xlib_surface_set_drawable
-
- which allows the target drawable for an xlib cairo_surface_t to be
- changed to another with the same format, screen, and display. This
- is necessary in certain double-buffering techniques.
-
-New features
-------------
-* Sub-pixel text antialiasing is now supported.
-
-Bug fixes
----------
-* Fixed assertion failure in cairo_surface_create_similar when
- application commits an error by passing a cairo_format_t rather than
- a cairo_content_t.
-
-* Avoid division by zero in various places (cairo-ft).
-
-* Fix infinite loop when using non-default visuals (cairo-xlib).
-
-* Eliminate segfault in cairo_image_surface_create_from_png_stream.
-
-* Prevent errant sign-extension of masks on 64-bit architectures
- (cairo-xlib and cairo-xcb).
-
-* Other miscellaneous fixes.
-
-Snapshot 0.5.2 (2005-07-18 Carl Worth <cworth@cworth.org>)
-==========================================================
-API changes
------------
-* New functions for creating patterns of a single color:
-
- cairo_pattern_create_rgb
- cairo_pattern_create_rgba
-
-* Change cairo_surface_create_similar to accept a new type of
- cairo_content_t rather than cairo_format_t:
-
- typedef enum _cairo_content {
- CAIRO_CONTENT_COLOR = 0x1000,
- CAIRO_CONTENT_ALPHA = 0x2000,
- CAIRO_CONTENT_COLOR_ALPHA = 0x3000
- } cairo_content_t;
-
-* Add new CAIRO_FORMAT_VALID and CAIRO_CONTENT_VALID macros.
-
-* Remove unused status value:
-
- CAIRO_STATUS_NO_TARGET_SURFACE
-
-* Add new status values:
-
- CAIRO_STATUS_INVALID_STATUS
-
-* Require libpixman >= 0.1.5 (for necessary bug fixes)
-
-Bug fixes
----------
-* Fix cairo_surface_write_to_png for RGB24 images.
-
-* Fix broken metrics and rendering for bitmap fonts. Add mostly
- useless bitmap glyph transformation.
-
-* Fix glyph caches to not eject entries that might be immediately
- needed, (fixing intermittent crashes when rendering text).
-
-* Fix all memory leaks found by running "make check-valgrind".
-
-ATSUI backend changes
----------------------
-* Allow building against < 10.3 SDK.
-
-* Prevent crash on empty strings.
-
-Glitz backend changes
----------------------
-* Require glitz >= 0.4.4.
-
-* Use frame buffer objects instead of pbuffers for accelerated
- offscreen drawing.
-
-* Minor improvement to gradient pattern creation.
-
-PostScript backend fixes
-------------------------
-* Rewrite of the PS backend to generate more interesting output that
- the old big-image implementation.
-
-Win32 backend fixes
--------------------
-* Implement glyph path support.
-
-* Fix swap of blue and green values in the fill_rectangles path.
-
-Xlib backend fixes
-------------------
-* Add optimization to use XCopyArea rather than XRenderComposite when
- transforming only with an integer translation, and using SOURCE
- operator or OVER with a source pattern without alpha.
-
-Snapshot 0.5.1 (2005-06-20 Carl Worth <cworth@cworth.org>)
-==========================================================
-API changes
------------
-* Removed cairo_status_string(cairo_t*) and add
- cairo_status_to_string(cairo_status_t) in its place. Code using
- cairo_status_string can be ported forward as follows:
-
- cairo_status (cr);
- ->
- cairo_status_to_string (cairo_status (cr));
-
-* Removed the BAD_NESTING restriction which means that two different
- cairo_t objects can now interleave drawing to the same
- cairo_surface_t without causing an error.
-
-* The following functions which previously had a return type of
- cairo_status_t now have a return type of void:
-
- cairo_pattern_add_color_stop_rgba
- cairo_pattern_set_matrix
- cairo_pattern_get_matrix
- cairo_pattern_set_extend
- cairo_pattern_set_filter
-
- See discussion of cairo_pattern_status below for more details.
-
-API additions
--------------
-* Improved error handling:
-
- cairo_status_t
- cairo_pattern_status (cairo_pattern_t *pattern);
-
- This snapshot expands the status-based error handling scheme from
- cairo_t to cairo_path_t and cairo_pattern_t. It also expands the
- scheme so that object-creating functions, (cairo_create,
- cairo_pattern_create_*, cairo_copy_path_*), are now guaranteed to
- not return NULL. Instead, in the case of out-of-memory these
- functions will return a static object with
- status==CAIRO_STATUS_NO_MEMORY. The status can be checked with the
- functions cairo_status and cairo_pattern_status, or by direct
- inspection of the new status field in cairo_path_t.
-
- Please note that some objects, including cairo_surface_t and all of
- the font-related objects have not been converted to this
- error-handling scheme.
-
-* In addition to the above changes, a new private function has been added:
-
- _cairo_error
-
- This function can be used to set a breakpoint in a debugger to make
- it easier to find programming error in cairo-using code. (Currently,
- _cairo_error is called when any error is detected within a cairo_t
- context, but is not called for non-cairo_t errors such as for
- cairo_path_t and cairo_pattern_t).
-
-* Fixed cairo_path_data_t so that its enum is visible to C++ code, (as
- cairo_path_data_type_t).
-
-Performance improvements
-------------------------
-* Made a minor performance improvement for clipping, (restrict clip
- surface to the new intersected bounds).
-
-* Optimize rendering of a solid source pattern with a pixel-aligned
- rectangular path to use backend clipping rather than rasterization
- and backend compositing.
-
-* Optimize cairo_paint_with_alpha to defer to cairo_paint when alpha
- is 1.0.
-
-Bug fixes
----------
-* Fixed memory leak in cairo_copy_path.
-
-* A build fix for non-srcdir builds.
-
-PDF backend fixes
------------------
-* New support for path-based clipping.
-
-* Fix for text rotated to angles other than multiples of π/2.
-
-Win32 backend fixes
--------------------
-* Fix for text extents.
-
-Xlib backend
-------------
-* Implemented a complex workaround for X server bug[*] related to
- Render-based compositing with untransformed, repeating source
- pictures. The workaround uses core Xlib when possible for
- performance, (ie. with CAIRO_OPERATOR_SOURCE or CAIRO_OPERATOR_OVER
- with an opaque source surface), and falls back to the pixman
- image-based compositing otherwise.
-
- [*] https://bugs.freedesktop.org/show_bug.cgi?id=3566
-
-* Various bug fixes, particularly in the fallback paths.
-
-Snapshot 0.5.0 (2005-05-17 Carl Worth <cworth@cworth.org>)
-==========================================================
-This is a pretty big, and fairly significant snapshot. It represents
-between 2 and 3 months of solid work from a lot of people on improving
-the API as much as possible. I'd like to express my appreciation and
-congratulations to everyone who has worked on the big API Shakeup,
-(whether in email battles over names, or fixing my silly bugs).
-
-This snapshot will require some effort on the part of users, since
-there are a _lot_ of API changes (ie. no cairo program ever written is
-safe --- they're all broken now in at least one way). But, in spite of
-that, we do encourage everyone to move their code to this snapshot as
-soon as possible. And we're doing everything we can think of to make
-the transition as smooth as possible.
-
-The idea behind 0.5 is that we've tried to make every good API change
-we could want now, and get them all done with. That is, between now
-and the 1.0 release of cairo, we expect very few new API changes,
-(though some will certainly sneak in). We will have some significant
-additions, but the pain of moving code from cairo 0.4 to cairo 0.5
-should be a one time experience, and things should be much smoother as
-we continue to move toward cairo 1.0.
-
-And with so many changes coming out for the first time in this 0.5
-release, we really do need a lot of people trying this out to make
-sure the ideas are solid before we freeze the API in preparation for
-the 1.0 release.
-
-OK, enough introduction. Here is a (not-quite-complete) description of
-the API removals, changes and additions in this snapshot, (compared to
-0.4.0)
-
-API removals
-============
-The following public functions have been removed:
-
-- cairo_set_target_*
-
- This is a big change. See the description of cairo_create in
- the API changes section for how to deal with this.
-
-- cairo_set_alpha
-
- Alpha blending hasn't gone away; there's just a much more
- unified rendering model now. Almost all uses of
- cairo_set_alpha will be trivially replaced with
- cairo_set_source_rgba and a few others will be replaced just
- as easily with cairo_paint_with_alpha.
-
-- cairo_show_surface
-
- Another useful function that we realized was muddling up the
- rendering model. The replacement is quite easy:
- cairo_set_source_surface and cairo_paint.
-
-- cairo_matrix_create
-- cairo_matrix_destroy
-- cairo_matrix_copy
-- cairo_matrix_get_affine
-
- These functions supported an opaque cairo_matrix_t. We now
- have an exposed cairo_matrix_t structure, so these can be
- dropped.
-
-- cairo_surface_set_repeat
-- cairo_surface_set_matrix
-- cairo_surface_set_filter
-
- These properties don't belong on surfaces. If you were using
- them, you'll just want to instead use
- cairo_pattern_create_for_surface and then set these properties
- on the pattern.
-
-- cairo_copy
-
- This was a confusing function and hopefully nobody will miss
- it. But if you really don't find cairo_save/restore adequate,
- let us know and we have another idea for a potential
- replacement.
-
-And while we're on the subject of removals, we carefully tightened up
-the cairo header files so they no longer gratuitously include header
-files that are not strictly necessary, (stdio.h, stdint.h, pixman.h,
-Xrender.h, etc. and their dependencies). This may lead to some
-surprising errors, so keep your eyes open for that.
-
-API changes
-===========
-Here are some of the API changes that have occurred:
-
-~ cairo_create(void) -> cairo_create(cairo_surface_t *)
-
- This is the big change that breaks every program. The ability
- to re-target a cairo_t was not particularly useful, but it did
- introduce a lot of muddy semantic questions. To eliminate
- that, cairo_create now requires its target surface to be
- passed in at creation time. This isn't too hard to cope with
- as the typical first operation after cairo_create was often
- cairo_set_target_foo. So the order of those two swap and the
- application instead has cairo_foo_surface_create, then
- cairo_create.
-
-~ cairo_current_* -> cairo_get_*
-
- We had a strange mixture of cairo_get and cairo_current
- functions. They've all been standardized on cairo_get, (though
- note one is cairo_get_current_point).
-
-~ CAIRO_OPERATOR_SRC -> CAIRO_OPERATOR_SOURCE
-~ CAIRO_OPERATOR_OVER_REVERSE -> CAIRO_OPERATOR_DEST_OVER
-
- Many of the cairo_operator_t symbolic values were renamed to
- reduce the amount of abbreviation. The confusing "OP_REVERSE"
- naming was also changed to use "DEST_OP" instead which is
- easier to read and has wider acceptance in other
- libraries/languages.
-
-~ cairo_set_pattern -> cairo_set_source
-~ cairo_set_rgb_color -> cairo_set_source_rgb
-
- All of the various functions that changed the source
- color/pattern were unified to use cairo_set_source names to
- make the relation more clear.
-
-~ cairo_transform_point -> cairo_user_to_device
-~ cairo_transform_distance -> cairo_user_to_device_distance
-~ cairo_inverse_transform_point -> cairo_device_to_user
-~ cairo_inverse_transform_distance -> cairo_device_to_user_distance
-
- These names just seemed a lot more clear.
-
-~ cairo_init_clip -> cairo_reset_clip
-~ cairo_concat_matrix -> cairo_transform
-
- More abbreviation elimination
-
-~ cairo_current_path -> cairo_copy_path
-~ cairo_current_path_flat -> cairo_copy_path_flat
-
- The former mechanism for examining the current path was a
- function that required 3 or 4 callbacks. This was more
- complexity than warranted in most situations. The new
- cairo_copy_path function copies the current path into an
- exposed data structure, and the documentation provides a
- convenient idiom for navigating the path data.
-
-API additions
--------------
-+ cairo_paint
-
- A generalized version of the painting operators cairo_stroke
- and cairo_fill. The cairo_paint call applies the source paint
- everywhere within the current clip region. Very useful for
- clearing a surface to a solid color, or painting an image,
- (see cairo_set_source_surface).
-
-+ cairo_paint_with_alpha
-
- Like cairo_paint but applying some alpha to the source,
- (making the source paint translucent, eg. to blend an image on
- top of another).
-
-+ cairo_mask
-
- A more generalized version of cairo_paint_with_alpha which
- allows a pattern to specify the amount of translucence at each
- point rather than using a constant value everywhere.
-
-+ cairo_mask_surface
-
- A convenience function on cairo_mask for when the mask pattern
- is already contained within a surface.
-
-+ cairo_surface_set_user_data
-+ cairo_surface_get_user_data
-+ cairo_font_face_set_user_data
-+ cairo_font_face_get_user_data
-
- Associate arbitrary data with a surface or font face for later
- retrieval. Get notified when a surface or font face object is
- destroyed.
-
-+ cairo_surface_finish
-
- Allows the user to instruct cairo to finish all of its
- operations for a given surface. This provides a safe point for
- doing things such as flushing and closing files that the
- surface may have had open for writing.
-
-+ cairo_fill_preserve
-+ cairo_stroke_preserve
-+ cairo_clip_preserve
-
- One interesting change in cairo is that the path is no longer
- part of the graphics state managed by
- cairo_save/restore. This allows functions to construct paths
- without interfering with the graphics state. But it prevents
- the traditional idiom for fill-and-stroke:
-
- cairo_save; cairo_fill; cairo_restore; cairo_stroke
-
- Instead we know have alternate versions cairo cairo_fill,
- cairo_stroke, and cairo_clip that preserve the current path
- rather than consuming it. So the idiom now becomes simply:
-
- cairo_fill_preserve; cairo_stroke
-
-+ cairo_surface_write_to_png
-+ cairo_surface_write_to_png_stream
-
- In place of a single PNG backend, now a surface created
- through any backend (except PDF currently) can be written out
- to a PNG image.
-
-+ cairo_image_surface_create_from_png
-+ cairo_image_surface_create_from_png_stream
-
- And its just as easy to load a PNG image into a surface as well.
-
-+ cairo_append_path
-
- With the new, exposed path data structure, it's now possible
- to append bulk path data to the current path, (rather than
- issuing a long sequence of cairo_move_to/line_to/curve_to
- function calls).
-
-Xlib and XCB backends
----------------------
-
-Any cairo_format_t and Colormap arguments have been dropped from
-cairo_xlib_surface_create. There are also two new
-cairo_xlib|xcb_surface_create functions:
-
- cairo_xlib|xcb_surface_create_for_bitmap
- (Particular for creating A1 surfaces)
- cairo_xlib|xcb_surface_create_with_xrender_format
- (For any other surface types, not described by a Visual*)
-
-All of these surface create functions now accept width and height. In
-addition, there are new cairo_xlib|xcb_surface_set_size functions
-which must be called each time a window that is underlying a surface
-changes size.
-
-Print backends (PS and PDF)
----------------------------
-The old FILE* based interfaces have been eliminated. In their place we
-have two different functions. One accepts a simple const char
-*filename. The other is a more general function which accepts a
-callback write function and a void* closure. This should allow the
-flexibility needed to hook up with various stream object in many
-languages.
-
-In addition, when specifying the surface size during construction, the
-units are now device-space units (ie. points) rather than inches. This
-provides consistency with all the other surface types and also makes
-it much easier to reason about the size of the surface when drawing to
-it with the default identity matrix.
-
-Finally, the DPI parameters, which are only needed to control the
-quality of fallbacks, have been made optional. Nothing is required
-during surface_create (300 DPI is assumed) and
-cairo_ps|pdf_surface_set_dpi can be used to set alternate values if
-needed.
-
-Font system
------------
-Owen very graciously listened to feedback after the big font rework he
-had done for 0.4, and came up with way to improve it even more. In 0.4
-there was a cairo_font_t that was always pre-scaled. Now, there is an
-unscaled cairo_font_face_t which is easier to construct, (eg. no
-scaling matrix required) and work with, (it can be scaled and
-transformed after being set on the graphics state). And the font size
-manipulation functions are much easier. You can set an explicit size
-and read/modify/write the font matrix with:
-
- cairo_set_font_size
- cairo_get_font_matrix
- cairo_set_font_matrix
-
-(Previously you could only multiply in a scale factor or a matrix.) A
-pleasant side effect is that we can (and do) now have a default font
-size that is reasonable, as opposed to the old default height of one
-device-space unit which was useless until scaled.
-
-Of course, the old pre-scaled font had allowed some performance
-benefits when getting many metrics for a font. Those benefits are
-still made available through the new cairo_scaled_font_t. And a
-cairo_font_face_t can be "promoted" to a cairo_scaled_font_t by
-suppling a font_matrix and the desired CTM.
-
-Quartz backend
---------------
-Tim Rowley put in the work to bring the Quartz backend back after it
-had been disabled in the 0.4.0 snapshot. He was not able to bring back
-the function that allows one to create a cairo_font_t from an ATSUI
-style:
-
- cairo_font_t *
- cairo_atsui_font_create (ATSUStyle style);
-
-because he didn't have a test case for it. If you care about this
-function, please provide a fairly minimal test and we'll try to bring
-it back in an upcoming snapshot.
-
-Snapshot 0.4.0 (2005-03-08 Carl Worth <cworth@cworth.org>)
-==========================================================
-New documentation
------------------
-Owen Taylor has converted cairo's documentation system to gtk-doc and
-has begun some long-needed work on the documentation, which can now be
-viewed online here:
-
- http://cairographics.org/manual/
-
-New backend: win32
-------------------
-This is the first snapshot to include a functional win32 backend,
-(thanks to Owen Taylor). The interface is as follows:
-
- #include <cairo-win32.h>
-
- void
- cairo_set_target_win32 (cairo_t *cr,
- HDC hdc);
-
- cairo_surface_t *
- cairo_win32_surface_create (HDC hdc);
-
- cairo_font_t *
- cairo_win32_font_create_for_logfontw (LOGFONTW *logfont,
- cairo_matrix_t *scale);
-
- cairo_status_t
- cairo_win32_font_select_font (cairo_font_t *font,
- HDC hdc);
-
- void
- cairo_win32_font_done_font (cairo_font_t *font);
-
- double
- cairo_win32_font_get_scale_factor (cairo_font_t *font);
-
-And see also the documentation at:
-
-http://cairographics.org/manual/cairo-Microsoft-Windows-Backend.html
-
-Disabled backend: quartz
-------------------------
-Unfortunately, the quartz backend code is currently out of date with
-respect to some recent backend interface changes. So, the quartz
-backend is disabled in this snapshot.
-
-If the quartz backend is brought up-to-date before the next snapshot,
-we would be glad to make a 0.4.1 snapshot that re-enables it, (we do
-not expect many more big backend interface changes).
-
-API Changes
------------
-The font system has been revamped, (as Owen Taylor's work with
-integrating pango and cairo gave us the first serious usage of the
-non-toy font API).
-
-One fundamental, user-visible change is that the cairo_font_t object
-now represents a font that is scaled to a particular device
-resolution. Further changes are described below.
-
- cairo.h
- -------
- Removed cairo_font_set_transform and cairo_font_current_transform.
-
- Added cairo_font_extents and cairo_font_glyph_extents. See
- documentation for details:
-
- http://cairographics.org/manual/cairo-cairo-t.html#cairo-font-extents
-
- cairo-ft.h
- ----------
- The cairo_ft_font API changed considerably. Please see the
- documentation for details:
-
- http://cairographics.org/manual/cairo-FreeType-Fonts.html
-
-Performance
------------
-Make the fast-path clipping (pixel-aligned rectangles) faster.
-
-Add optimization for applying a constant alpha to a pattern.
-
-Optimize gradients that are horizontal or vertical in device space.
-
-Xlib: When RENDER is not available, use image surfaces for
-intermediate surfaces rather than xlib surfaces.
-
-Backend-specific changes
-------------------------
- Glitz
- -----
- Major update to glitz backend. The output quality should now be just
- as good as the image and xlib backends.
-
- Track changes to glitz 0.4.0.
-
- PDF
- ---
- Various improvements to produce more conformant output.
-
-Internals
----------
-David Reveman contributed a large re-work of the cairo_pattern_t
-implementation, providing cleaner code and more optimization
-opportunities.
-
- Backend interface changes
- -------------------------
- Rework backend interface to accept patterns, not surfaces for source
- and mask.
-
- Remove set_matrix, set_filter, and set_repeat functions.
-
- More sophisticated backend interface for image fallbacks,
- ({acquire,release}_{source,dest}_image() and clone_similar).
-
-Bug fixes
----------
-Only install header files for backends that have been compiled.
-
-Fixed some rounding errors leading to incorrectly placed glyphs.
-
-Many other minor fixes.
-
-Snapshot 0.3.0 (2005-01-21 Carl Worth <cworth@cworth.org>)
-==========================================================
-Major API changes
------------------
-1) The public header files will no longer be directly installed into
- the system include directory. They will now be installed in a
- subdirectory named "cairo", (eg. in /usr/include/cairo rather than
- in /usr/include).
-
- As always, the easiest way for applications to discover the
- location of the header file is to let pkg-config generate the
- necessary -I CFLAGS and -L/-l LDFLAGS. For example:
-
- cc `pkg-config --cflags --libs cairo` -o foo foo.c
-
- IMPORTANT: Users with old versions of cairo installed will need to
- manually remove cairo.h and cairo-features.h from the
- system include directories in order to prevent the old
- headers from being used in preference to the new ones.
-
-2) The backend-specific portions of the old monolithic cairo.h have
- been split out into individual public header files. The new files
- are:
-
- cairo-atsui.h
- cairo-ft.h
- cairo-glitz.h
- cairo-pdf.h
- cairo-png.h
- cairo-ps.h
- cairo-quartz.h
- cairo-xcb.h
- cairo-xlib.h
-
- Applications will need to be modified to explicitly include the new
- header files where appropriate.
-
-3) There are two new graphics backends in this snapshot, a PDF
- backend, and a Quartz backend. There is also one new font backend,
- ATSUI.
-
-PDF backend
------------
-Kristian Høgsberg has contributed a new backend to allow cairo-based
-applications to generate PDF output. The interface for creating a PDF
-surface is similar to that of the PS backend, as can be seen in
-cairo-pdf.h:
-
- void
- cairo_set_target_pdf (cairo_t *cr,
- FILE *file,
- double width_inches,
- double height_inches,
- double x_pixels_per_inch,
- double y_pixels_per_inch);
-
- cairo_surface_t *
- cairo_pdf_surface_create (FILE *file,
- double width_inches,
- double height_inches,
- double x_pixels_per_inch,
- double y_pixels_per_inch);
-
-Once a PDF surface has been created, applications can draw to it as
-any other cairo surface.
-
-This code is still a bit rough around the edges, and does not yet
-support clipping, surface patterns, or transparent gradients. Text
-only works with TrueType fonts at this point and only black text is
-supported. Also, the size of the generated PDF files is currently
-quite big.
-
-Kristian is still actively developing this backend, so watch this
-space for future progress.
-
-Quartz backend
---------------
-Calum Robinson has contributed a new backend to allow cairo
-applications to target native Mac OS X windows through the Quartz
-API. Geoff Norton integrated this backend into the current
-configure-based build system, while Calum also provided Xcode build
-support in the separate "macosx" module available in CVS.
-
-The new interface, available in cairo-quartz.h, is as follows:
-
- void
- cairo_set_target_quartz_context (cairo_t *cr,
- CGContextRef context,
- int width,
- int height);
-
- cairo_surface_t *
- cairo_quartz_surface_create (CGContextRef context,
- int width,
- int height);
-
-There is an example program available in CVS in cairo-demo/quartz. It
-is a port of Keith Packard's fdclock program originally written for
-the xlib backend. A screenshot of this program running on Mac OS X is
-available here:
-
- http://cairographics.org/~cworth/images/fdclock-quartz.png
-
-ATSUI font backend
-------------------
-This new font backend complements the Quartz backend by allowing
-applications to use native font selection on Mac OS X. The interface
-is a single new function:
-
- cairo_font_t *
- cairo_atsui_font_create (ATSUStyle style);
-
-Minor API changes
------------------
-Prototype for non-existent function "cairo_ft_font_destroy" removed.
-
-Now depends on libpixman 0.1.2 or newer, (0.1.3 is being released
-concurrently and has some useful performance improvements).
-
-Default paint color is now opaque black, (was opaque white). Default
-background color is transparent (as before).
-
-Renamed "struct cairo" to "struct _cairo" to free up the word "cairo"
-from the C++ identifier name space.
-
-Functions returning multiple return values through provided pointers,
-(cairo_matrix_get_affine, cairo_current_point, and
-cairo_current_color_rgb), will now accept NULL for values the user
-wants to ignore.
-
-CAIRO_HAS_FREETYPE_FONT has now been renamed to CAIRO_HAS_FT_FONT.
-
-Performance improvements
-------------------------
-Alexander Larsson provided some fantastic performance improvements
-yielding a 10000% performance improvement in his application, (when
-also including his performance work in libpixman-0.1.3). These include
-
- * Fixed handling of cache misses.
-
- * Creating intermediate clip surfaces at the minimal size required.
-
- * Eliminating roundtrips when creating intermediate Xlib surfaces.
-
-Implementation
---------------
-Major re-work of font metrics system by Keith Packard. Font metrics
-should now be much more reliable.
-
-Glitz backend
--------------
-Updated for glitz-0.3.0.
-Bug fixes in reference counting.
-
-Test suite
-----------
-New tests for cache crashing, rotating text, improper filling of
-complex polygons, and leaky rasterization.
-
-Bug fixes
----------
-Fixed assertion failure when selecting the same font multiple times in
-sequence.
-
-Fixed reference counting so cache_destroy functions work.
-
-Remove unintended copyright statement from files generated with
-PostScript backend.
-
-Fixed to eliminate new warnings from gcc 3.4 and gcc 4.
-
-Snapshot 0.2.0 (2004-10-27 Carl Worth <cworth@cworth.org>)
-===========================================================
-New license: LGPL/MPL
----------------------
-The most significant news with this release is that the license of
-cairo has changed. It is now dual-licensed under the LGPL and the
-MPL. For details see the COPYING file as well as COPYING-LGPL-2.1 and
-COPYING-MPL-1.1.
-
-I express my thanks to everyone involved in the license change process
-for their patience and support!
-
-New font and glyph internals
-----------------------------
-Graydon Hoare has put a tremendous amount of work into new internals
-for handling fonts and glyphs, including caches where appropriate.
-This work has no impact on the user-level API, but should result in
-great performance improvements for applications using text.
-
-New test suite
---------------
-This snapshot of cairo includes a (small) test suite in
-cairo/test. The tests can be run with "make check". The test suite was
-designed to make it very easy to add new tests, and we hope to see
-many contributions here. As you find bugs, please try adding a minimal
-test case to the suite, and submit it with the bug report to the
-cairo@cairographics.org mailing list. This will make it much easier
-for us to track progress in fixing bugs.
-
-New name for glitz backend
---------------------------
-The gl backend has now been renamed to the glitz backend. This means
-that the following names have changed:
-
- CAIRO_HAS_GL_SURFACE -> CAIRO_HAS_GLITZ_SURFACE
- cairo_set_target_gl -> cairo_set_target_glitz
- cairo_gl_surface_create -> cairo_glitz_surface_create
-
-This change obviously breaks backwards compatibility for applications
-using the old gl backend.
-
-Up-to-date with latest glitz snapshots
---------------------------------------
-This snapshot of cairo is now up to date with the latest glitz
-snapshot, (currently 0.2.3). We know that the latest cairo and glitz
-snapshots have been incompatible for a very long time. We've finally
-fixed that now and we're determined to not let that happen again.
-
-Revert some tessellation regression bugs
-----------------------------------------
-People that have been seeing some tessellation bugs, (eg. leaked
-fills), in the CVS version of cairo may have better luck with this
-release. A change since the last snapshot was identified to trigger
-some of these bugs and was reverted before making the snapshot. The
-behavior should be the same as the previous (0.1.23) snapshot.
-
-Miscellaneous changes
----------------------
-Changed CAIRO_FILTER_DEFAULT to CAIRO_FILTER_BEST to make gradients
-easier.
-
-Track XCB API change regarding iterators.
-
-Various bug fixes
------------------
-Fix calculation of required number of vertices for pen.
-
-Fix to avoid zero-dimensioned pixmaps.
-
-Fix broken sort of pen vertices.
-
-Fix bug when cairo_show_text called with a NULL string.
-
-Fix clipping bugs.
-
-Fix bug in computing image length with XCB.
-
-Fix infinite loop bug in cairo_arc.
-
-Fix memory management interactions with libpixman.
-
-Snapshot 0.1.23 (2004-05-11 Carl Worth <cworth@isi.edu>)
-========================================================
-Fixes for gcc 3.4
------------------
-Fix prototype mismatches so that cairo can be built by gcc 3.4.
-
-Updates to track glitz
-----------------------
-Various fixes to support the latest glitz snapshot (0.1.2).
-
-Gradient updates
-----------------
-Radial gradients now support both inner and outer circles.
-Transformed linear gradients are now properly handled.
-Fixes for extend type reflect.
-
-Glitz updates
--------------
-Converted shading routines to use fixed point values and introduced a
-shading operator structure for more efficient shading calculations.
-Support compositing with mask surface when mask is solid or
-multi-texturing is available.
-
-PNG backend cleanups
---------------------
-Fix output to properly compensate for pre-multiplied alpha format in cairo.
-Add support for A8 and A1 image formats.
-
-Bug fixes
----------
-Avoid crash or infinite loop on null strings and degeneratively short
-splines.
-
-New? bugs in cairo_clip
------------------------
-There are some fairly serious bugs in cairo_clip. It is sometimes
-causing an incorrect result. And even when it does work, it is
-sometimes so slow as to be unusable. Some of these bugs may not be
-new, (indeed cairo_clip has only ever had a braindead-slow
-implementation), but I think they're worth mentioning here.
-
-Snapshot 0.1.22 (2004-04-16 Carl Worth <cworth@isi.edu>)
-========================================================
-Cairo was updated to track the changes in libpixman, and now depends
-on libpixman version 0.1.1.
-
-Snapshot 0.1.21 (2004-04-09 David Reveman <c99drn@cs.umu.se>)
-=============================================================
-New OpenGL backend
-------------------
-The OpenGL backend provides hardware accelerated output for
-X11 and OS X. The significant new functions are:
-
- cairo_set_target_gl
- cairo_gl_surface_create
-
-Automatic detection of available backends
------------------------------------------
-The configure script now automatically detect what backends are
-available, (use ./configure --disable-`backend' to prevent
-compilation of specific backends).
-
-Snapshot 0.1.20 (2004-04-06 Carl Worth <cworth@isi.edu>)
-========================================================
-New pattern API
----------------
-David Reveman has contributed a new pattern API which enable linear
-and radial gradient patterns in addition to the original surface-based
-patterns. The significant new top-level functions are:
-
- cairo_pattern_create_linear
- cairo_pattern_create_radial
- cairo_pattern_create_for_surface
- cairo_pattern_add_color_stop
- cairo_set_pattern
-
-Any code using the old cairo_set_pattern, (which accepted a
-cairo_surface_t rather than a cairo_pattern_t), will need to be
-updated.
-
-Update to XCB backend
----------------------
-The XCB backend is now enabled by default, (use ./configure
---disable-xcb to turn it off).
-
-Faster clipping
----------------
-Graydon Hoare has added optimizations that make cairo_clip much faster
-when the path is a pixel-aligned, rectangular region.
-
-Bug fixes.
-
-Snapshot 0.1.19 (2004-02-24 Carl Worth <cworth@isi.edu>)
-========================================================
-New PNG backend
----------------
-Olivier Andrieu contributed a new PNG backend. It builds on the
-existing image backend to make it easy to render "directly" to a
-.png file. The user never needs to deal with the actual image
-buffer. The significant new functions are:
-
- cairo_set_target_png
- cairo_png_surface_create
-
-The PNG backend is not enabled by default so that by default there is
-not a new dependency on libpng. Use ./configure --enable-png to enable
-this backend.
-
-Snapshot 0.1.18 (2004-02-17 Carl Worth <cworth@isi.edu>)
-========================================================
-Path query functionality
-------------------------
-It's now possible to query the current path. The two new functions
-are:
-
- cairo_current_path
- cairo_current_path_flat
-
-Each function accepts a number of callback functions that will be
-called for each element in the path (move_to, line_to, curve_to,
-close_path). The cairo_current_path_flat function does not accept a
-curve_to callback. Instead, all curved portions of the path will be
-converted to line segments, (within the current tolerance value). This
-can be handy for doing things like text-on-path without having to
-manually interpolate Bézier splines.
-
-New XCB backend
----------------
-Jamey Sharp has contributed a second X backend that uses the new, lean
-XCB library rather than Xlib. It cannot currently be compiled at the
-same time as the Xlib backend. See ./configure --enable-xcb.
-
-Build fixes for cygwin.
-
-Bug fixes.
-
-Snapshot 0.1.17 (2003-12-16 Carl Worth <cworth@isi.edu>)
-========================================================
-
-Better text support
--------------------
-This snapshot provides much better text support by implementing the
-following four functions:
-
- cairo_text_extents
- cairo_glyph_extents
- cairo_text_path
- cairo_glyph_path
-
-The text/glyph_extents functions can be used to determine the bounding
-box (and advance) for text as if drawn by show_text/glyphs.
-
-The text/glyph_path objects functions place text shapes on the current
-path, where they can be subsequently manipulated. For example,
-following these functions with cairo_stroke allows outline text to be
-drawn. Calling cairo_clip allows clipping to a text-shaped region.
-
-Combined dependencies
----------------------
-The cairo core now depends only on the libpixman library. This single
-library replaces the three previous libraries libic, libpixregion, and
-slim. Thanks to Dave Beckett <dave.beckett@bristol.ac.uk> for all of
-the heavy lifting with this renaming effort.
-
-Conditional compilation of backends
------------------------------------
-Cairo now allows optional backends to be disabled at compile time. The
-following options may now be passed to the configure script:
-
- --disable-xlib
- --disable-ps
-
-Note that the first option is a change from the old --without-x option
-which will no longer have any effect.
-
-OS X supported - several byte-order issues resolved
----------------------------------------------------
-Cairo has now been successfully compiled under OS X. Testing revealed
-that there were some byte-order problems in the PostScript backend and
-the PNG generation in the demos. These have now been resolved.
-
-2003-10
-=======
-Graydon Hoare <graydon@redhat.com> implemented the first real text
-support using Freetype/fontconfig, (previous versions of cairo used
-Xft and could only draw text when using an X backend).
-
-2003-09
-=======
-Graydon Hoare <graydon@redhat.com> added the first real support for
-running cairo with a non-render-aware X server.
-
-Jamey Sharp <jamey@minilop.net> virtualized the backend font and
-surface interfaces in September, 2003.
-
-2003-06
-=======
-Xr is renamed cairo to avoid confusion since it no longer had a strict
-dependence on X.
-
-2003-05
-=======
-A new image surface backend is added to Xr. Keith Packard
-<keithp@keithp.com> wrote the image compositing code in libic that is
-used for the image_surface backend. This code was originally written
-as the software fallback for the render extension within the X
-server.
-
-2002-06
-=======
-Carl Worth <cworth@isi.edu> wrote the first lines of Xr, after Keith
-Packard <keithp@keithp.com> proposed the plan for a stateful drawing
-library in C providing a PostScript-like rendering model.
-
- LocalWords: mutex BeOS extraordinaire
diff --git a/gfx/cairo/cairo/README b/gfx/cairo/cairo/README
index efca44cda..fc801fee3 100644
--- a/gfx/cairo/cairo/README
+++ b/gfx/cairo/cairo/README
@@ -1,3 +1,8 @@
+Important note: the source code included in this directory is a subset
+of the library, insofar as is needed to supply functionality to the
+UXP source. For the complete and unmodified source of Cairo, please
+go to the website indicated below.
+
Cairo - Multi-platform 2D graphics library
http://cairographics.org
diff --git a/gfx/cairo/cairo/src/cairo-analysis-surface-private.h b/gfx/cairo/cairo/src/cairo-analysis-surface-private.h
index c7dcb8291..81832126c 100644
--- a/gfx/cairo/cairo/src/cairo-analysis-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-analysis-surface-private.h
@@ -1,36 +1,6 @@
-/*
- * Copyright © 2005 Keith Packard
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Keith Packard
- *
- * Contributor(s):
- * Keith Packard <keithp@keithp.com>
- */
+/* 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_ANALYSIS_SURFACE_H
#define CAIRO_ANALYSIS_SURFACE_H
diff --git a/gfx/cairo/cairo/src/cairo-analysis-surface.c b/gfx/cairo/cairo/src/cairo-analysis-surface.c
index 96b43285d..2be419994 100644
--- a/gfx/cairo/cairo/src/cairo-analysis-surface.c
+++ b/gfx/cairo/cairo/src/cairo-analysis-surface.c
@@ -1,38 +1,6 @@
-/*
- * Copyright © 2006 Keith Packard
- * Copyright © 2007 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Keith Packard
- *
- * Contributor(s):
- * Keith Packard <keithp@keithp.com>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-arc-private.h b/gfx/cairo/cairo/src/cairo-arc-private.h
index 018a14b4a..e8dcc1394 100644
--- a/gfx/cairo/cairo/src/cairo-arc-private.h
+++ b/gfx/cairo/cairo/src/cairo-arc-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@redhat.com>
- */
+/* 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_ARC_PRIVATE_H
#define CAIRO_ARC_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-arc.c b/gfx/cairo/cairo/src/cairo-arc.c
index 56d42f19e..54a0723d0 100644
--- a/gfx/cairo/cairo/src/cairo-arc.c
+++ b/gfx/cairo/cairo/src/cairo-arc.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-array.c b/gfx/cairo/cairo/src/cairo-array.c
index 2d11402a3..442540c58 100644
--- a/gfx/cairo/cairo/src/cairo-array.c
+++ b/gfx/cairo/cairo/src/cairo-array.c
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Carl Worth <cworth@cworth.org>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-atomic-private.h b/gfx/cairo/cairo/src/cairo-atomic-private.h
index af462e370..e14c5fdaf 100644
--- a/gfx/cairo/cairo/src/cairo-atomic-private.h
+++ b/gfx/cairo/cairo/src/cairo-atomic-private.h
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Chris Wilson
- * Copyright © 2010 Andrea Canciani
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- * Andrea Canciani <ranma42@gmail.com>
- */
+/* 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_ATOMIC_PRIVATE_H
#define CAIRO_ATOMIC_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-atomic.c b/gfx/cairo/cairo/src/cairo-atomic.c
index 2af50cd38..fd5ee930b 100644
--- a/gfx/cairo/cairo/src/cairo-atomic.c
+++ b/gfx/cairo/cairo/src/cairo-atomic.c
@@ -1,35 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-base64-stream.c b/gfx/cairo/cairo/src/cairo-base64-stream.c
index 636431372..02ca8bd45 100644
--- a/gfx/cairo/cairo/src/cairo-base64-stream.c
+++ b/gfx/cairo/cairo/src/cairo-base64-stream.c
@@ -1,40 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005-2007 Emmanuel Pacaud <emmanuel.pacaud@free.fr>
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Author(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-base85-stream.c b/gfx/cairo/cairo/src/cairo-base85-stream.c
index f81affb49..ba19ff4a2 100644
--- a/gfx/cairo/cairo/src/cairo-base85-stream.c
+++ b/gfx/cairo/cairo/src/cairo-base85-stream.c
@@ -1,38 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Author(s):
- * Kristian Høgsberg <krh@redhat.com>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-bentley-ottmann-rectangular.c b/gfx/cairo/cairo/src/cairo-bentley-ottmann-rectangular.c
index 8c1d54f0c..4736f4f41 100644
--- a/gfx/cairo/cairo/src/cairo-bentley-ottmann-rectangular.c
+++ b/gfx/cairo/cairo/src/cairo-bentley-ottmann-rectangular.c
@@ -1,39 +1,6 @@
-/*
- * Copyright © 2004 Carl Worth
- * Copyright © 2006 Red Hat, Inc.
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Carl Worth
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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/. */
/* Provide definitions for standalone compilation */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-bentley-ottmann-rectilinear.c b/gfx/cairo/cairo/src/cairo-bentley-ottmann-rectilinear.c
index 1696d9367..b00d2823b 100644
--- a/gfx/cairo/cairo/src/cairo-bentley-ottmann-rectilinear.c
+++ b/gfx/cairo/cairo/src/cairo-bentley-ottmann-rectilinear.c
@@ -1,39 +1,6 @@
-/*
- * Copyright © 2004 Carl Worth
- * Copyright © 2006 Red Hat, Inc.
- * Copyright © 2008 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Carl Worth
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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/. */
/* Provide definitions for standalone compilation */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-bentley-ottmann.c b/gfx/cairo/cairo/src/cairo-bentley-ottmann.c
index b3819f2f7..c333becaa 100644
--- a/gfx/cairo/cairo/src/cairo-bentley-ottmann.c
+++ b/gfx/cairo/cairo/src/cairo-bentley-ottmann.c
@@ -1,39 +1,6 @@
-/*
- * Copyright © 2004 Carl Worth
- * Copyright © 2006 Red Hat, Inc.
- * Copyright © 2008 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Carl Worth
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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/. */
/* Provide definitions for standalone compilation */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-beos-surface.cpp b/gfx/cairo/cairo/src/cairo-beos-surface.cpp
index e527272e6..d52ae1513 100644
--- a/gfx/cairo/cairo/src/cairo-beos-surface.cpp
+++ b/gfx/cairo/cairo/src/cairo-beos-surface.cpp
@@ -1,38 +1,6 @@
-/* vim:set ts=8 sw=4 noet cin: */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Christian Biesinger <cbiesinger@web.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Christian Biesinger
- * <cbiesinger@web.de>
- *
- * Contributor(s):
- */
+/* 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
diff --git a/gfx/cairo/cairo/src/cairo-beos.h b/gfx/cairo/cairo/src/cairo-beos.h
index fdb89a6c4..375c930cc 100644
--- a/gfx/cairo/cairo/src/cairo-beos.h
+++ b/gfx/cairo/cairo/src/cairo-beos.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Christian Biesinger <cbiesinger@web.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Christian Biesinger
- * <cbiesinger@web.de>
- *
- * Contributor(s):
- */
+/* 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
diff --git a/gfx/cairo/cairo/src/cairo-botor-scan-converter.c b/gfx/cairo/cairo/src/cairo-botor-scan-converter.c
index 0778a5dcd..ae060dc31 100644
--- a/gfx/cairo/cairo/src/cairo-botor-scan-converter.c
+++ b/gfx/cairo/cairo/src/cairo-botor-scan-converter.c
@@ -1,43 +1,6 @@
-/*
- * Copyright © 2004 Carl Worth
- * Copyright © 2006 Red Hat, Inc.
- * Copyright © 2007 David Turner
- * Copyright © 2008 M Joonas Pihlaja
- * Copyright © 2008 Chris Wilson
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Carl Worth
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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/. */
/* Provide definitions for standalone compilation */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-boxes-private.h b/gfx/cairo/cairo/src/cairo-boxes-private.h
index 3af0fbdef..e61a64d7c 100644
--- a/gfx/cairo/cairo/src/cairo-boxes-private.h
+++ b/gfx/cairo/cairo/src/cairo-boxes-private.h
@@ -1,35 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_BOXES_H
#define CAIRO_BOXES_H
diff --git a/gfx/cairo/cairo/src/cairo-boxes.c b/gfx/cairo/cairo/src/cairo-boxes.c
index 31bfc0e4e..e29dd7e13 100644
--- a/gfx/cairo/cairo/src/cairo-boxes.c
+++ b/gfx/cairo/cairo/src/cairo-boxes.c
@@ -1,35 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-cache-private.h b/gfx/cairo/cairo/src/cairo-cache-private.h
index 927ff0c0b..06940a63a 100644
--- a/gfx/cairo/cairo/src/cairo-cache-private.h
+++ b/gfx/cairo/cairo/src/cairo-cache-private.h
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc.
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Keith Packard <keithp@keithp.com>
- * Graydon Hoare <graydon@redhat.com>
- * Carl Worth <cworth@cworth.org>
- */
+/* 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_CACHE_PRIVATE_H
#define CAIRO_CACHE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-cache.c b/gfx/cairo/cairo/src/cairo-cache.c
index 5c4e4caa3..021b012fd 100644
--- a/gfx/cairo/cairo/src/cairo-cache.c
+++ b/gfx/cairo/cairo/src/cairo-cache.c
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc.
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Keith Packard <keithp@keithp.com>
- * Graydon Hoare <graydon@redhat.com>
- * Carl Worth <cworth@cworth.org>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-cff-subset.c b/gfx/cairo/cairo/src/cairo-cff-subset.c
index f9b036814..6a5060047 100644
--- a/gfx/cairo/cairo/src/cairo-cff-subset.c
+++ b/gfx/cairo/cairo/src/cairo-cff-subset.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Adrian Johnson.
- *
- * Contributor(s):
- * Adrian Johnson <ajohnson@redneon.com>
- * Eugeniy Meshcheryakov <eugen@debian.org>
- */
+/* 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/. */
/*
* Useful links:
diff --git a/gfx/cairo/cairo/src/cairo-clip-private.h b/gfx/cairo/cairo/src/cairo-clip-private.h
index faf486409..04d80afc7 100644
--- a/gfx/cairo/cairo/src/cairo-clip-private.h
+++ b/gfx/cairo/cairo/src/cairo-clip-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- */
+/* 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_CLIP_PRIVATE_H
#define CAIRO_CLIP_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-clip.c b/gfx/cairo/cairo/src/cairo-clip.c
index 0ebe9b207..cbbf4d2ce 100644
--- a/gfx/cairo/cairo/src/cairo-clip.c
+++ b/gfx/cairo/cairo/src/cairo-clip.c
@@ -1,43 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Kristian Høgsberg <krh@redhat.com>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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-clip-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-color.c b/gfx/cairo/cairo/src/cairo-color.c
index d20fea4d2..b9dae237e 100644
--- a/gfx/cairo/cairo/src/cairo-color.c
+++ b/gfx/cairo/cairo/src/cairo-color.c
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-combsort-private.h b/gfx/cairo/cairo/src/cairo-combsort-private.h
index bb7abb477..3400a681c 100644
--- a/gfx/cairo/cairo/src/cairo-combsort-private.h
+++ b/gfx/cairo/cairo/src/cairo-combsort-private.h
@@ -1,36 +1,6 @@
-/*
- * Copyright © 2008 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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 fragment implements a comb sort (specifically combsort11) */
#ifndef _HAVE_CAIRO_COMBSORT_NEWGAP
diff --git a/gfx/cairo/cairo/src/cairo-compiler-private.h b/gfx/cairo/cairo/src/cairo-compiler-private.h
index 18dc661bd..34cfe0956 100644
--- a/gfx/cairo/cairo/src/cairo-compiler-private.h
+++ b/gfx/cairo/cairo/src/cairo-compiler-private.h
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_COMPILER_PRIVATE_H
#define CAIRO_COMPILER_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-composite-rectangles-private.h b/gfx/cairo/cairo/src/cairo-composite-rectangles-private.h
index 8c3c5abcc..ddbe6bb1a 100644
--- a/gfx/cairo/cairo/src/cairo-composite-rectangles-private.h
+++ b/gfx/cairo/cairo/src/cairo-composite-rectangles-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.u>
- */
+/* 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_COMPOSITE_RECTANGLES_PRIVATE_H
#define CAIRO_COMPOSITE_RECTANGLES_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-composite-rectangles.c b/gfx/cairo/cairo/src/cairo-composite-rectangles.c
index 7f6484339..a7b499cf4 100644
--- a/gfx/cairo/cairo/src/cairo-composite-rectangles.c
+++ b/gfx/cairo/cairo/src/cairo-composite-rectangles.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-d2d-private.h b/gfx/cairo/cairo/src/cairo-d2d-private.h
index 15810eb6d..00244b497 100644
--- a/gfx/cairo/cairo/src/cairo-d2d-private.h
+++ b/gfx/cairo/cairo/src/cairo-d2d-private.h
@@ -1,38 +1,7 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2010 Mozilla Foundation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is the Mozilla Foundation
- *
- * Contributor(s):
- * Bas Schouten <bschouten@mozilla.com>
- */
+/* 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_D2D_PRIVATE_H
#define CAIRO_D2D_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
index cb90245dc..6aa8a3503 100644
--- a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
+++ b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
@@ -1,38 +1,7 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2010 Mozilla Foundation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is the Mozilla Foundation
- *
- * Contributor(s):
- * Bas Schouten <bschouten@mozilla.com>
- */
+/* 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/. */
+
#define INITGUID
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-debug.c b/gfx/cairo/cairo/src/cairo-debug.c
index e9e72b6aa..49bf31594 100644
--- a/gfx/cairo/cairo/src/cairo-debug.c
+++ b/gfx/cairo/cairo/src/cairo-debug.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-deflate-stream.c b/gfx/cairo/cairo/src/cairo-deflate-stream.c
index ba5f18392..b6d10b12a 100644
--- a/gfx/cairo/cairo/src/cairo-deflate-stream.c
+++ b/gfx/cairo/cairo/src/cairo-deflate-stream.c
@@ -1,38 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Adrian Johnson.
- *
- * Author(s):
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-deprecated.h b/gfx/cairo/cairo/src/cairo-deprecated.h
index 7a56aadbf..04b5d264d 100644
--- a/gfx/cairo/cairo/src/cairo-deprecated.h
+++ b/gfx/cairo/cairo/src/cairo-deprecated.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_DEPRECATED_H
#define CAIRO_DEPRECATED_H
diff --git a/gfx/cairo/cairo/src/cairo-device-private.h b/gfx/cairo/cairo/src/cairo-device-private.h
index 6eb44f3b6..371f66714 100644
--- a/gfx/cairo/cairo/src/cairo-device-private.h
+++ b/gfx/cairo/cairo/src/cairo-device-private.h
@@ -1,37 +1,6 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Intel Corporation.
- *
- * Contributors(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_DEVICE_PRIVATE_H_
#define _CAIRO_DEVICE_PRIVATE_H_
diff --git a/gfx/cairo/cairo/src/cairo-device.c b/gfx/cairo/cairo/src/cairo-device.c
index 15b048477..d24dba94c 100644
--- a/gfx/cairo/cairo/src/cairo-device.c
+++ b/gfx/cairo/cairo/src/cairo-device.c
@@ -1,37 +1,6 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Intel Corporation.
- *
- * Contributors(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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-device-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-directfb-surface.c b/gfx/cairo/cairo/src/cairo-directfb-surface.c
index fc7509c1a..6387fee94 100644
--- a/gfx/cairo/cairo/src/cairo-directfb-surface.c
+++ b/gfx/cairo/cairo/src/cairo-directfb-surface.c
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2003 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Michael Emmel <mike.emmel@gmail.com>
- * Claudio Ciccani <klan@users.sf.net>
- */
+/* 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-directfb.h"
diff --git a/gfx/cairo/cairo/src/cairo-directfb.h b/gfx/cairo/cairo/src/cairo-directfb.h
index e3d818c66..029b43ef7 100644
--- a/gfx/cairo/cairo/src/cairo-directfb.h
+++ b/gfx/cairo/cairo/src/cairo-directfb.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2003 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@isi.edu>
- */
+/* 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/. */
/*
* Environment variables affecting the backend:
diff --git a/gfx/cairo/cairo/src/cairo-drm.h b/gfx/cairo/cairo/src/cairo-drm.h
index 907610dcd..bbdb28ba2 100644
--- a/gfx/cairo/cairo/src/cairo-drm.h
+++ b/gfx/cairo/cairo/src/cairo-drm.h
@@ -1,34 +1,6 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson.
- */
+/* 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_DRM_H
#define CAIRO_DRM_H
diff --git a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
index f3d45da1e..391f2e8a7 100644
--- a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
+++ b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
@@ -1,38 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2010 Mozilla Foundation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is the Mozilla Foundation
- *
- * Contributor(s):
- * Bas Schouten <bschouten@mozilla.com>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-dwrite-private.h b/gfx/cairo/cairo/src/cairo-dwrite-private.h
index 7c76abf5e..1eaa46113 100644
--- a/gfx/cairo/cairo/src/cairo-dwrite-private.h
+++ b/gfx/cairo/cairo/src/cairo-dwrite-private.h
@@ -1,38 +1,7 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2010 Mozilla Foundation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is the Mozilla Foundation
- *
- * Contributor(s):
- * Bas Schouten <bschouten@mozilla.com>
- */
+/* 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 <dwrite_1.h>
#include <d2d1.h>
diff --git a/gfx/cairo/cairo/src/cairo-eagle-context.c b/gfx/cairo/cairo/src/cairo-eagle-context.c
index 23766a944..5f59f5239 100644
--- a/gfx/cairo/cairo/src/cairo-eagle-context.c
+++ b/gfx/cairo/cairo/src/cairo-eagle-context.c
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Eric Anholt
- * Copyright © 2009 Chris Wilson
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-error-private.h b/gfx/cairo/cairo/src/cairo-error-private.h
index fc0c56438..c7a9f7098 100644
--- a/gfx/cairo/cairo/src/cairo-error-private.h
+++ b/gfx/cairo/cairo/src/cairo-error-private.h
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_ERROR_PRIVATE_H_
#define _CAIRO_ERROR_PRIVATE_H_
diff --git a/gfx/cairo/cairo/src/cairo-features.h.in b/gfx/cairo/cairo/src/cairo-features.h.in
index ee76be9ca..9692c7cb7 100644
--- a/gfx/cairo/cairo/src/cairo-features.h.in
+++ b/gfx/cairo/cairo/src/cairo-features.h.in
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2003 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_FEATURES_H
#define CAIRO_FEATURES_H
@@ -52,8 +20,8 @@
#endif
#define CAIRO_VERSION_MAJOR 1
-#define CAIRO_VERSION_MINOR 9
-#define CAIRO_VERSION_MICRO 5
+#define CAIRO_VERSION_MINOR 10
+#define CAIRO_VERSION_MICRO 28
@PS_SURFACE_FEATURE@
diff --git a/gfx/cairo/cairo/src/cairo-fixed-private.h b/gfx/cairo/cairo/src/cairo-fixed-private.h
index 9478d7d4f..a00e99cf3 100644
--- a/gfx/cairo/cairo/src/cairo-fixed-private.h
+++ b/gfx/cairo/cairo/src/cairo-fixed-private.h
@@ -1,38 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir@pobox.com>
- */
+/* 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_FIXED_PRIVATE_H
#define CAIRO_FIXED_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-fixed-type-private.h b/gfx/cairo/cairo/src/cairo-fixed-type-private.h
index 2bbd5f786..d2bf6cb66 100644
--- a/gfx/cairo/cairo/src/cairo-fixed-type-private.h
+++ b/gfx/cairo/cairo/src/cairo-fixed-type-private.h
@@ -1,38 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir@pobox.com>
- */
+/* 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_FIXED_TYPE_PRIVATE_H
#define CAIRO_FIXED_TYPE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-fixed.c b/gfx/cairo/cairo/src/cairo-fixed.c
index 03e055923..75805f3d3 100644
--- a/gfx/cairo/cairo/src/cairo-fixed.c
+++ b/gfx/cairo/cairo/src/cairo-fixed.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2003 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-font-face-twin.c b/gfx/cairo/cairo/src/cairo-font-face-twin.c
index 98c6dd8a9..da85cb08e 100644
--- a/gfx/cairo/cairo/src/cairo-font-face-twin.c
+++ b/gfx/cairo/cairo/src/cairo-font-face-twin.c
@@ -1,38 +1,6 @@
-/*
- * Copyright © 2004 Keith Packard
- * Copyright © 2008 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Keith Packard
- *
- * Contributor(s):
- * Keith Packard <keithp@keithp.com>
- * Behdad Esfahbod <behdad@behdad.org>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-font-face.c b/gfx/cairo/cairo/src/cairo-font-face.c
index a66054ead..ab17a8cb2 100644
--- a/gfx/cairo/cairo/src/cairo-font-face.c
+++ b/gfx/cairo/cairo/src/cairo-font-face.c
@@ -1,42 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Graydon Hoare <graydon@redhat.com>
- * Owen Taylor <otaylor@redhat.com>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-font-options.c b/gfx/cairo/cairo/src/cairo-font-options.c
index 5d59fb0f2..17a892160 100644
--- a/gfx/cairo/cairo/src/cairo-font-options.c
+++ b/gfx/cairo/cairo/src/cairo-font-options.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Owen Taylor <otaylor@redhat.com>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-fontconfig-private.h b/gfx/cairo/cairo/src/cairo-fontconfig-private.h
index ea873abe7..110304b18 100644
--- a/gfx/cairo/cairo/src/cairo-fontconfig-private.h
+++ b/gfx/cairo/cairo/src/cairo-fontconfig-private.h
@@ -1,43 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2000 Keith Packard
- * Copyright © 2005 Red Hat, Inc
- * Copyright © 2010 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Graydon Hoare <graydon@redhat.com>
- * Owen Taylor <otaylor@redhat.com>
- * Keith Packard <keithp@keithp.com>
- * Carl Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_FONTCONFIG_PRIVATE_H
#define _CAIRO_FONTCONFIG_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-freed-pool-private.h b/gfx/cairo/cairo/src/cairo-freed-pool-private.h
index c73e593c0..c23e5a03a 100644
--- a/gfx/cairo/cairo/src/cairo-freed-pool-private.h
+++ b/gfx/cairo/cairo/src/cairo-freed-pool-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_FREED_POOL_H
#define CAIRO_FREED_POOL_H
diff --git a/gfx/cairo/cairo/src/cairo-freed-pool.c b/gfx/cairo/cairo/src/cairo-freed-pool.c
index 5b1c4c0bb..c65f4626d 100644
--- a/gfx/cairo/cairo/src/cairo-freed-pool.c
+++ b/gfx/cairo/cairo/src/cairo-freed-pool.c
@@ -1,39 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-ft-font.c b/gfx/cairo/cairo/src/cairo-ft-font.c
index e51923a5d..1a2799b86 100644
--- a/gfx/cairo/cairo/src/cairo-ft-font.c
+++ b/gfx/cairo/cairo/src/cairo-ft-font.c
@@ -1,42 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2000 Keith Packard
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Graydon Hoare <graydon@redhat.com>
- * Owen Taylor <otaylor@redhat.com>
- * Keith Packard <keithp@keithp.com>
- * Carl Worth <cworth@cworth.org>
- */
+/* 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/. */
#define _BSD_SOURCE /* for strdup() */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-ft-private.h b/gfx/cairo/cairo/src/cairo-ft-private.h
index ff6ad4e65..42a1776ed 100644
--- a/gfx/cairo/cairo/src/cairo-ft-private.h
+++ b/gfx/cairo/cairo/src/cairo-ft-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Graydon Hoare <graydon@redhat.com>
- * Owen Taylor <otaylor@redhat.com>
- */
+/* 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_FT_PRIVATE_H
#define CAIRO_FT_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-ft.h b/gfx/cairo/cairo/src/cairo-ft.h
index 56d48c328..2f584066f 100644
--- a/gfx/cairo/cairo/src/cairo-ft.h
+++ b/gfx/cairo/cairo/src/cairo-ft.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Graydon Hoare <graydon@redhat.com>
- * Owen Taylor <otaylor@redhat.com>
- */
+/* 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_FT_H
#define CAIRO_FT_H
diff --git a/gfx/cairo/cairo/src/cairo-gl-glyphs.c b/gfx/cairo/cairo/src/cairo-gl-glyphs.c
index 4736e190e..883883fbf 100644
--- a/gfx/cairo/cairo/src/cairo-gl-glyphs.c
+++ b/gfx/cairo/cairo/src/cairo-gl-glyphs.c
@@ -1,40 +1,6 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- * Copyright © 2010 Intel Corporation
- * Copyright © 2010 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson.
- *
- * Contributors:
- * Benjamin Otte <otte@gnome.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-gl-private.h b/gfx/cairo/cairo/src/cairo-gl-private.h
index 54f226f42..96a2a1b5b 100644
--- a/gfx/cairo/cairo/src/cairo-gl-private.h
+++ b/gfx/cairo/cairo/src/cairo-gl-private.h
@@ -1,43 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Eric Anholt
- * Copyright © 2009 Chris Wilson
- * Copyright © 2005,2010 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Benjamin Otte <otte@gnome.org>
- * Carl Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- * Eric Anholt <eric@anholt.net>
- * T. Zachary Laine <whatwasthataddress@gmail.com>
- */
+/* 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_GL_PRIVATE_H
#define CAIRO_GL_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-gl-shaders.c b/gfx/cairo/cairo/src/cairo-gl-shaders.c
index d7773f567..d0edffa88 100644
--- a/gfx/cairo/cairo/src/cairo-gl-shaders.c
+++ b/gfx/cairo/cairo/src/cairo-gl-shaders.c
@@ -1,41 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 T. Zachary Laine
- * Copyright © 2010 Eric Anholt
- * Copyright © 2010 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is T. Zachary Laine.
- *
- * Contributor(s):
- * Benjamin Otte <otte@gnome.org>
- * Eric Anholt <eric@anholt.net>
- * T. Zachary Laine <whatwasthataddress@gmail.com>
- */
+/* 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-gl-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-gl-surface.c b/gfx/cairo/cairo/src/cairo-gl-surface.c
index 278e6429d..458300050 100644
--- a/gfx/cairo/cairo/src/cairo-gl-surface.c
+++ b/gfx/cairo/cairo/src/cairo-gl-surface.c
@@ -1,42 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Eric Anholt
- * Copyright © 2009 Chris Wilson
- * Copyright © 2005,2010 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Benjamin Otte <otte@gnome.org>
- * Carl Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- * Eric Anholt <eric@anholt.net>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-gl.h b/gfx/cairo/cairo/src/cairo-gl.h
index 131d1148b..17c5b03f1 100644
--- a/gfx/cairo/cairo/src/cairo-gl.h
+++ b/gfx/cairo/cairo/src/cairo-gl.h
@@ -1,35 +1,6 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Eric Anholt
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Eric Anholt.
- */
+/* 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_GL_H
#define CAIRO_GL_H
diff --git a/gfx/cairo/cairo/src/cairo-glitz-private.h b/gfx/cairo/cairo/src/cairo-glitz-private.h
index 8a876eeab..144eff4a5 100644
--- a/gfx/cairo/cairo/src/cairo-glitz-private.h
+++ b/gfx/cairo/cairo/src/cairo-glitz-private.h
@@ -1,34 +1,6 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- */
+/* 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_GLITZ_PRIVATE_H
#define CAIRO_GLITZ_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-glitz-surface.c b/gfx/cairo/cairo/src/cairo-glitz-surface.c
index 5f97f65e8..bd176d056 100644
--- a/gfx/cairo/cairo/src/cairo-glitz-surface.c
+++ b/gfx/cairo/cairo/src/cairo-glitz-surface.c
@@ -1,28 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 David Reveman
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of David
- * Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. David Reveman makes no representations about the
- * suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: David Reveman <davidr@novell.com>
- */
+/* 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-glitz.h"
diff --git a/gfx/cairo/cairo/src/cairo-glitz.h b/gfx/cairo/cairo/src/cairo-glitz.h
index 08519dcbd..b74e887bc 100644
--- a/gfx/cairo/cairo/src/cairo-glitz.h
+++ b/gfx/cairo/cairo/src/cairo-glitz.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_GLITZ_H
#define CAIRO_GLITZ_H
diff --git a/gfx/cairo/cairo/src/cairo-glx-context.c b/gfx/cairo/cairo/src/cairo-glx-context.c
index fa9d8be96..1ceab6cc3 100644
--- a/gfx/cairo/cairo/src/cairo-glx-context.c
+++ b/gfx/cairo/cairo/src/cairo-glx-context.c
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Eric Anholt
- * Copyright © 2009 Chris Wilson
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-gstate-private.h b/gfx/cairo/cairo/src/cairo-gstate-private.h
index b41c7a296..e8127d770 100644
--- a/gfx/cairo/cairo/src/cairo-gstate-private.h
+++ b/gfx/cairo/cairo/src/cairo-gstate-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@redhat.com>
- */
+/* 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_GSTATE_PRIVATE_H
#define CAIRO_GSTATE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-gstate.c b/gfx/cairo/cairo/src/cairo-gstate.c
index cb07b511f..6ba6f0b1d 100644
--- a/gfx/cairo/cairo/src/cairo-gstate.c
+++ b/gfx/cairo/cairo/src/cairo-gstate.c
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-hash-private.h b/gfx/cairo/cairo/src/cairo-hash-private.h
index 30e51ffe6..0c2759dbf 100644
--- a/gfx/cairo/cairo/src/cairo-hash-private.h
+++ b/gfx/cairo/cairo/src/cairo-hash-private.h
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc.
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Keith Packard <keithp@keithp.com>
- * Graydon Hoare <graydon@redhat.com>
- * Carl Worth <cworth@cworth.org>
- */
+/* 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_HASH_PRIVATE_H
#define CAIRO_HASH_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-hash.c b/gfx/cairo/cairo/src/cairo-hash.c
index 81a48a235..7e24d930d 100644
--- a/gfx/cairo/cairo/src/cairo-hash.c
+++ b/gfx/cairo/cairo/src/cairo-hash.c
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc.
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Keith Packard <keithp@keithp.com>
- * Graydon Hoare <graydon@redhat.com>
- * Carl Worth <cworth@cworth.org>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-hull.c b/gfx/cairo/cairo/src/cairo-hull.c
index c65593327..a9cb27982 100644
--- a/gfx/cairo/cairo/src/cairo-hull.c
+++ b/gfx/cairo/cairo/src/cairo-hull.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2003 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-image-info-private.h b/gfx/cairo/cairo/src/cairo-image-info-private.h
index 0d9ef8498..1107fa4f9 100644
--- a/gfx/cairo/cairo/src/cairo-image-info-private.h
+++ b/gfx/cairo/cairo/src/cairo-image-info-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Adrian Johnson.
- *
- * Contributor(s):
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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_IMAGE_INFO_PRIVATE_H
#define CAIRO_IMAGE_INFO_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-image-info.c b/gfx/cairo/cairo/src/cairo-image-info.c
index 63201e65b..5269ce25f 100644
--- a/gfx/cairo/cairo/src/cairo-image-info.c
+++ b/gfx/cairo/cairo/src/cairo-image-info.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Adrian Johnson.
- *
- * Contributor(s):
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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-image-info-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c
index 4aaf1c159..ad0737157 100644
--- a/gfx/cairo/cairo/src/cairo-image-surface.c
+++ b/gfx/cairo/cairo/src/cairo-image-surface.c
@@ -1,41 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2003 University of Southern California
- * Copyright © 2009,2010 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-list-private.h b/gfx/cairo/cairo/src/cairo-list-private.h
index ddfd0a4c6..ca4e368fc 100644
--- a/gfx/cairo/cairo/src/cairo-list-private.h
+++ b/gfx/cairo/cairo/src/cairo-list-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- *
- */
+/* 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_LIST_PRIVATE_H
#define CAIRO_LIST_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-lzw.c b/gfx/cairo/cairo/src/cairo-lzw.c
index de7f99983..e98e613bc 100644
--- a/gfx/cairo/cairo/src/cairo-lzw.c
+++ b/gfx/cairo/cairo/src/cairo-lzw.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-malloc-private.h b/gfx/cairo/cairo/src/cairo-malloc-private.h
index e5776abd0..765fb65b4 100644
--- a/gfx/cairo/cairo/src/cairo-malloc-private.h
+++ b/gfx/cairo/cairo/src/cairo-malloc-private.h
@@ -1,38 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir@pobox.com>
- */
+/* 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_MALLOC_PRIVATE_H
#define CAIRO_MALLOC_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-matrix.c b/gfx/cairo/cairo/src/cairo-matrix.c
index 583a7a649..b9691b8ee 100644
--- a/gfx/cairo/cairo/src/cairo-matrix.c
+++ b/gfx/cairo/cairo/src/cairo-matrix.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-meta-surface-private.h b/gfx/cairo/cairo/src/cairo-meta-surface-private.h
index f0c95c19c..c1f6c40f2 100644
--- a/gfx/cairo/cairo/src/cairo-meta-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-meta-surface-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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_META_SURFACE_H
#define CAIRO_META_SURFACE_H
diff --git a/gfx/cairo/cairo/src/cairo-misc.c b/gfx/cairo/cairo/src/cairo-misc.c
index e0ed70cb6..6aa793f61 100644
--- a/gfx/cairo/cairo/src/cairo-misc.c
+++ b/gfx/cairo/cairo/src/cairo-misc.c
@@ -1,42 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- * Copyright © 2007 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-mutex-impl-private.h b/gfx/cairo/cairo/src/cairo-mutex-impl-private.h
index 6c67f6ebb..72086036c 100644
--- a/gfx/cairo/cairo/src/cairo-mutex-impl-private.h
+++ b/gfx/cairo/cairo/src/cairo-mutex-impl-private.h
@@ -1,43 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005,2007 Red Hat, Inc.
- * Copyright © 2007 Mathias Hasselmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Mathias Hasselmann <mathias.hasselmann@gmx.de>
- * Behdad Esfahbod <behdad@behdad.org>
- * Mark Straver <moonchild@palemoon.org>
- */
+/* 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_MUTEX_IMPL_PRIVATE_H
#define CAIRO_MUTEX_IMPL_PRIVATE_H
@@ -178,7 +141,9 @@
#elif defined(_WIN32) /******************************************************/
-#define WIN32_LEAN_AND_MEAN
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
/* We require Windows 7 features */
#if !defined(WINVER) || (WINVER < 0x0601)
# define WINVER 0x0601
diff --git a/gfx/cairo/cairo/src/cairo-mutex-list-private.h b/gfx/cairo/cairo/src/cairo-mutex-list-private.h
index 7d5ba0299..3f2e44119 100644
--- a/gfx/cairo/cairo/src/cairo-mutex-list-private.h
+++ b/gfx/cairo/cairo/src/cairo-mutex-list-private.h
@@ -1,35 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Mathias Hasselmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * Contributor(s):
- * Mathias Hasselmann <mathias.hasselmann@gmx.de>
- */
+/* 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_FEATURES_H
/* This block is to just make this header file standalone */
diff --git a/gfx/cairo/cairo/src/cairo-mutex-private.h b/gfx/cairo/cairo/src/cairo-mutex-private.h
index 61a7160a0..e9359ef55 100644
--- a/gfx/cairo/cairo/src/cairo-mutex-private.h
+++ b/gfx/cairo/cairo/src/cairo-mutex-private.h
@@ -1,42 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005,2007 Red Hat, Inc.
- * Copyright © 2007 Mathias Hasselmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Mathias Hasselmann <mathias.hasselmann@gmx.de>
- * Behdad Esfahbod <behdad@behdad.org>
- */
+/* 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_MUTEX_PRIVATE_H
#define CAIRO_MUTEX_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-mutex-type-private.h b/gfx/cairo/cairo/src/cairo-mutex-type-private.h
index e8c493985..eac1d48e6 100644
--- a/gfx/cairo/cairo/src/cairo-mutex-type-private.h
+++ b/gfx/cairo/cairo/src/cairo-mutex-type-private.h
@@ -1,42 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005,2007 Red Hat, Inc.
- * Copyright © 2007 Mathias Hasselmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Mathias Hasselmann <mathias.hasselmann@gmx.de>
- * Behdad Esfahbod <behdad@behdad.org>
- */
+/* 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_MUTEX_TYPE_PRIVATE_H
#define CAIRO_MUTEX_TYPE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-mutex.c b/gfx/cairo/cairo/src/cairo-mutex.c
index 0a31dced3..d859e28d9 100644
--- a/gfx/cairo/cairo/src/cairo-mutex.c
+++ b/gfx/cairo/cairo/src/cairo-mutex.c
@@ -1,35 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Mathias Hasselmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * Contributor(s):
- * Mathias Hasselmann <mathias.hasselmann@gmx.de>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-observer.c b/gfx/cairo/cairo/src/cairo-observer.c
index 7c7b69c91..c8ce5eea2 100644
--- a/gfx/cairo/cairo/src/cairo-observer.c
+++ b/gfx/cairo/cairo/src/cairo-observer.c
@@ -1,38 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2010 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Intel Corporation
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-os2-private.h b/gfx/cairo/cairo/src/cairo-os2-private.h
index 829dd3c8d..e47efd316 100644
--- a/gfx/cairo/cairo/src/cairo-os2-private.h
+++ b/gfx/cairo/cairo/src/cairo-os2-private.h
@@ -1,39 +1,6 @@
-/* vim: set sw=4 sts=4 et cin: */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright (c) 2005-2006 netlabs.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is
- * Doodle <doodle@scenergy.dfmk.hu>
- *
- * Contributor(s):
- * Peter Weilbacher <mozilla@Weilbacher.org>
- */
+/* 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_OS2_PRIVATE_H
#define CAIRO_OS2_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-os2-surface.c b/gfx/cairo/cairo/src/cairo-os2-surface.c
index b9758281d..c0464f62b 100644
--- a/gfx/cairo/cairo/src/cairo-os2-surface.c
+++ b/gfx/cairo/cairo/src/cairo-os2-surface.c
@@ -1,40 +1,6 @@
-/* vim: set sw=4 sts=4 et cin: */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright (c) 2005-2006 netlabs.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is
- * Doodle <doodle@scenergy.dfmk.hu>
- *
- * Contributor(s):
- * Peter Weilbacher <mozilla@Weilbacher.org>
- * Rich Walsh <dragtext@e-vertise.com>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-os2.h b/gfx/cairo/cairo/src/cairo-os2.h
index d23f2dec4..16a4fc564 100644
--- a/gfx/cairo/cairo/src/cairo-os2.h
+++ b/gfx/cairo/cairo/src/cairo-os2.h
@@ -1,40 +1,6 @@
-/* vim: set sw=4 sts=4 et cin: */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright (c) 2005-2006 netlabs.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is
- * Doodle <doodle@scenergy.dfmk.hu>
- *
- * Contributor(s):
- * Peter Weilbacher <mozilla@Weilbacher.org>
- * Rich Walsh <dragtext@e-vertise.com>
- */
+/* 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_OS2_H_
#define _CAIRO_OS2_H_
diff --git a/gfx/cairo/cairo/src/cairo-output-stream-private.h b/gfx/cairo/cairo/src/cairo-output-stream-private.h
index edaabbe78..8f3cb3c6b 100644
--- a/gfx/cairo/cairo/src/cairo-output-stream-private.h
+++ b/gfx/cairo/cairo/src/cairo-output-stream-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Author(s):
- * Kristian Høgsberg <krh@redhat.com>
- */
+/* 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_OUTPUT_STREAM_PRIVATE_H
#define CAIRO_OUTPUT_STREAM_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-output-stream.c b/gfx/cairo/cairo/src/cairo-output-stream.c
index 1aabe821a..5f8d774cd 100644
--- a/gfx/cairo/cairo/src/cairo-output-stream.c
+++ b/gfx/cairo/cairo/src/cairo-output-stream.c
@@ -1,37 +1,6 @@
-/* cairo-output-stream.c: Output stream abstraction
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Author(s):
- * Kristian Høgsberg <krh@redhat.com>
- */
+/* 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/. */
#define _BSD_SOURCE /* for snprintf() */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-paginated-private.h b/gfx/cairo/cairo/src/cairo-paginated-private.h
index 42badbfdf..5687cf85c 100644
--- a/gfx/cairo/cairo/src/cairo-paginated-private.h
+++ b/gfx/cairo/cairo/src/cairo-paginated-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- */
+/* 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_PAGINATED_H
#define CAIRO_PAGINATED_H
diff --git a/gfx/cairo/cairo/src/cairo-paginated-surface-private.h b/gfx/cairo/cairo/src/cairo-paginated-surface-private.h
index ebf4b3424..0b4e81f23 100644
--- a/gfx/cairo/cairo/src/cairo-paginated-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-paginated-surface-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- */
+/* 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_PAGINATED_SURFACE_H
#define CAIRO_PAGINATED_SURFACE_H
diff --git a/gfx/cairo/cairo/src/cairo-paginated-surface.c b/gfx/cairo/cairo/src/cairo-paginated-surface.c
index af4790e7e..febcd05fa 100644
--- a/gfx/cairo/cairo/src/cairo-paginated-surface.c
+++ b/gfx/cairo/cairo/src/cairo-paginated-surface.c
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- * Copyright © 2007 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- * Keith Packard <keithp@keithp.com>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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/. */
/* The paginated surface layer exists to provide as much code sharing
* as possible for the various paginated surface backends in cairo
diff --git a/gfx/cairo/cairo/src/cairo-path-bounds.c b/gfx/cairo/cairo/src/cairo-path-bounds.c
index 8ca80fa13..c752fbca1 100644
--- a/gfx/cairo/cairo/src/cairo-path-bounds.c
+++ b/gfx/cairo/cairo/src/cairo-path-bounds.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2003 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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-path-fixed-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-path-fill.c b/gfx/cairo/cairo/src/cairo-path-fill.c
index 24aaa3969..40d41157a 100644
--- a/gfx/cairo/cairo/src/cairo-path-fill.c
+++ b/gfx/cairo/cairo/src/cairo-path-fill.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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-boxes-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-path-fixed-private.h b/gfx/cairo/cairo/src/cairo-path-fixed-private.h
index 42e64eda3..69972505a 100644
--- a/gfx/cairo/cairo/src/cairo-path-fixed-private.h
+++ b/gfx/cairo/cairo/src/cairo-path-fixed-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@redhat.com>
- */
+/* 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_PATH_FIXED_PRIVATE_H
#define CAIRO_PATH_FIXED_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-path-fixed.c b/gfx/cairo/cairo/src/cairo-path-fixed.c
index eea8630bd..3ba5f75e0 100644
--- a/gfx/cairo/cairo/src/cairo-path-fixed.c
+++ b/gfx/cairo/cairo/src/cairo-path-fixed.c
@@ -1,40 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-path-in-fill.c b/gfx/cairo/cairo/src/cairo-path-in-fill.c
index b344f529d..c303d8596 100644
--- a/gfx/cairo/cairo/src/cairo-path-in-fill.c
+++ b/gfx/cairo/cairo/src/cairo-path-in-fill.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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-path-fixed-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-path-private.h b/gfx/cairo/cairo/src/cairo-path-private.h
index 61b4060fa..c28612a32 100644
--- a/gfx/cairo/cairo/src/cairo-path-private.h
+++ b/gfx/cairo/cairo/src/cairo-path-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- * Copyright © 2006 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@redhat.com>
- */
+/* 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_PATH_PRIVATE_H
#define CAIRO_PATH_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-path-stroke.c b/gfx/cairo/cairo/src/cairo-path-stroke.c
index 505b6ab6a..6d1d6f205 100644
--- a/gfx/cairo/cairo/src/cairo-path-stroke.c
+++ b/gfx/cairo/cairo/src/cairo-path-stroke.c
@@ -1,40 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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/. */
#define _BSD_SOURCE /* for hypot() */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-path.c b/gfx/cairo/cairo/src/cairo-path.c
index 28182c0e4..49b479a99 100644
--- a/gfx/cairo/cairo/src/cairo-path.c
+++ b/gfx/cairo/cairo/src/cairo-path.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- * Copyright © 2006 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@redhat.com>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-pattern.c b/gfx/cairo/cairo/src/cairo-pattern.c
index 0c51804f8..502344f3c 100644
--- a/gfx/cairo/cairo/src/cairo-pattern.c
+++ b/gfx/cairo/cairo/src/cairo-pattern.c
@@ -1,32 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 David Reveman
- * Copyright © 2005 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of David
- * Reveman not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. David Reveman makes no representations about the
- * suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors: David Reveman <davidr@novell.com>
- * Keith Packard <keithp@keithp.com>
- * Carl Worth <cworth@cworth.org>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-pdf-operators-private.h b/gfx/cairo/cairo/src/cairo-pdf-operators-private.h
index 67d1cc233..d0051433b 100644
--- a/gfx/cairo/cairo/src/cairo-pdf-operators-private.h
+++ b/gfx/cairo/cairo/src/cairo-pdf-operators-private.h
@@ -1,43 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc
- * Copyright © 2006 Red Hat, Inc
- * Copyright © 2007 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Carl Worth <cworth@cworth.org>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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_PDF_OPERATORS_H
#define CAIRO_PDF_OPERATORS_H
diff --git a/gfx/cairo/cairo/src/cairo-pdf-operators.c b/gfx/cairo/cairo/src/cairo-pdf-operators.c
index d70756b3a..4da9d573c 100644
--- a/gfx/cairo/cairo/src/cairo-pdf-operators.c
+++ b/gfx/cairo/cairo/src/cairo-pdf-operators.c
@@ -1,43 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc
- * Copyright © 2006 Red Hat, Inc
- * Copyright © 2007, 2008 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Carl Worth <cworth@cworth.org>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-pdf-surface-private.h b/gfx/cairo/cairo/src/cairo-pdf-surface-private.h
index 221418ec9..ab5befa52 100644
--- a/gfx/cairo/cairo/src/cairo-pdf-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-pdf-surface-private.h
@@ -1,43 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc
- * Copyright © 2006 Red Hat, Inc
- * Copyright © 2007, 2008 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Carl Worth <cworth@cworth.org>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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_PDF_SURFACE_PRIVATE_H
#define CAIRO_PDF_SURFACE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-pdf-surface.c b/gfx/cairo/cairo/src/cairo-pdf-surface.c
index 09bd42ea0..3dcf58859 100644
--- a/gfx/cairo/cairo/src/cairo-pdf-surface.c
+++ b/gfx/cairo/cairo/src/cairo-pdf-surface.c
@@ -1,43 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc
- * Copyright © 2006 Red Hat, Inc
- * Copyright © 2007, 2008 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Carl Worth <cworth@cworth.org>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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/. */
#define _BSD_SOURCE /* for snprintf() */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-pdf.h b/gfx/cairo/cairo/src/cairo-pdf.h
index 50460ccdf..0e85e9804 100644
--- a/gfx/cairo/cairo/src/cairo-pdf.h
+++ b/gfx/cairo/cairo/src/cairo-pdf.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_PDF_H
#define CAIRO_PDF_H
diff --git a/gfx/cairo/cairo/src/cairo-pen.c b/gfx/cairo/cairo/src/cairo-pen.c
index e71f7b561..751b5dc3a 100644
--- a/gfx/cairo/cairo/src/cairo-pen.c
+++ b/gfx/cairo/cairo/src/cairo-pen.c
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2008 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-platform.h b/gfx/cairo/cairo/src/cairo-platform.h
index bfec29f67..9d4bc4d1f 100644
--- a/gfx/cairo/cairo/src/cairo-platform.h
+++ b/gfx/cairo/cairo/src/cairo-platform.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Mozilla Foundation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Stuart Parmenter <stuart@mozilla.com>
- */
+/* 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_PLATFORM_H
#define CAIRO_PLATFORM_H
diff --git a/gfx/cairo/cairo/src/cairo-png.c b/gfx/cairo/cairo/src/cairo-png.c
index 41a33d753..bbab2c2ae 100644
--- a/gfx/cairo/cairo/src/cairo-png.c
+++ b/gfx/cairo/cairo/src/cairo-png.c
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2003 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Kristian Høgsberg <krh@redhat.com>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-polygon.c b/gfx/cairo/cairo/src/cairo-polygon.c
index 1b5fab02b..fd71319e9 100644
--- a/gfx/cairo/cairo/src/cairo-polygon.c
+++ b/gfx/cairo/cairo/src/cairo-polygon.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-private.h b/gfx/cairo/cairo/src/cairo-private.h
index 901a69a31..33b049678 100644
--- a/gfx/cairo/cairo/src/cairo-private.h
+++ b/gfx/cairo/cairo/src/cairo-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@redhat.com>
- */
+/* 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_PRIVATE_H
#define CAIRO_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-ps-surface-private.h b/gfx/cairo/cairo/src/cairo-ps-surface-private.h
index a5a8cd0da..96da53554 100644
--- a/gfx/cairo/cairo/src/cairo-ps-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-ps-surface-private.h
@@ -1,42 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2003 University of Southern California
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Kristian Høgsberg <krh@redhat.com>
- * Keith Packard <keithp@keithp.com>
- */
+/* 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_PS_SURFACE_PRIVATE_H
#define CAIRO_PS_SURFACE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-ps-surface.c b/gfx/cairo/cairo/src/cairo-ps-surface.c
index 4e7fb132b..5696d6cb7 100644
--- a/gfx/cairo/cairo/src/cairo-ps-surface.c
+++ b/gfx/cairo/cairo/src/cairo-ps-surface.c
@@ -1,45 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2003 University of Southern California
- * Copyright © 2005 Red Hat, Inc
- * Copyright © 2007,2008 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Kristian Høgsberg <krh@redhat.com>
- * Keith Packard <keithp@keithp.com>
- * Adrian Johnson <ajohnson@redneon.com>
- */
-
+/* 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/. */
/*
* Design of the PS output:
diff --git a/gfx/cairo/cairo/src/cairo-ps.h b/gfx/cairo/cairo/src/cairo-ps.h
index fd1d21deb..3d609c9d1 100644
--- a/gfx/cairo/cairo/src/cairo-ps.h
+++ b/gfx/cairo/cairo/src/cairo-ps.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_PS_H
#define CAIRO_PS_H
diff --git a/gfx/cairo/cairo/src/cairo-qt-surface.cpp b/gfx/cairo/cairo/src/cairo-qt-surface.cpp
index 6311c7100..9d73395b7 100644
--- a/gfx/cairo/cairo/src/cairo-qt-surface.cpp
+++ b/gfx/cairo/cairo/src/cairo-qt-surface.cpp
@@ -1,38 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Corporation.
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir@mozilla.com>
- */
+/* 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
diff --git a/gfx/cairo/cairo/src/cairo-qt.h b/gfx/cairo/cairo/src/cairo-qt.h
index c20bbb18d..9bb6cd0e3 100644
--- a/gfx/cairo/cairo/src/cairo-qt.h
+++ b/gfx/cairo/cairo/src/cairo-qt.h
@@ -1,38 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Corporation.
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir@mozilla.com>
- */
+/* 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
diff --git a/gfx/cairo/cairo/src/cairo-quartz-font.c b/gfx/cairo/cairo/src/cairo-quartz-font.c
index 2a17e77fa..e58ae0559 100644
--- a/gfx/cairo/cairo/src/cairo-quartz-font.c
+++ b/gfx/cairo/cairo/src/cairo-quartz-font.c
@@ -1,38 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright � 2008 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir@mozilla.com>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-quartz-image-surface.c b/gfx/cairo/cairo/src/cairo-quartz-image-surface.c
index 9a18dd46e..155ec494f 100644
--- a/gfx/cairo/cairo/src/cairo-quartz-image-surface.c
+++ b/gfx/cairo/cairo/src/cairo-quartz-image-surface.c
@@ -1,38 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright � 2008 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir@mozilla.com>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-quartz-image.h b/gfx/cairo/cairo/src/cairo-quartz-image.h
index 2d6e8fb52..fffc1ee86 100644
--- a/gfx/cairo/cairo/src/cairo-quartz-image.h
+++ b/gfx/cairo/cairo/src/cairo-quartz-image.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir@mozilla.com>
- */
+/* 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
diff --git a/gfx/cairo/cairo/src/cairo-quartz-private.h b/gfx/cairo/cairo/src/cairo-quartz-private.h
index 1c8d496af..c0dcf3b91 100644
--- a/gfx/cairo/cairo/src/cairo-quartz-private.h
+++ b/gfx/cairo/cairo/src/cairo-quartz-private.h
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Calum Robinson
- * Copyright (C) 2006,2007 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Calum Robinson
- *
- * Contributor(s):
- * Calum Robinson <calumr@mac.com>
- * Vladimir Vukicevic <vladimir@mozilla.com>
- */
+/* 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
diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
index 434a28983..d5a5ffd92 100644
--- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
@@ -1,38 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright � 2006, 2007 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir@mozilla.com>
- */
+/* 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 */
diff --git a/gfx/cairo/cairo/src/cairo-quartz.h b/gfx/cairo/cairo/src/cairo-quartz.h
index 2941a0339..699a4e7ce 100644
--- a/gfx/cairo/cairo/src/cairo-quartz.h
+++ b/gfx/cairo/cairo/src/cairo-quartz.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006, 2007 Mozilla Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir@mozilla.com>
- */
+/* 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
diff --git a/gfx/cairo/cairo/src/cairo-recording-surface-private.h b/gfx/cairo/cairo/src/cairo-recording-surface-private.h
index 4ec5f88b4..c21a93205 100644
--- a/gfx/cairo/cairo/src/cairo-recording-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-recording-surface-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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_RECORDING_SURFACE_H
#define CAIRO_RECORDING_SURFACE_H
diff --git a/gfx/cairo/cairo/src/cairo-recording-surface.c b/gfx/cairo/cairo/src/cairo-recording-surface.c
index 0e955b83f..8230ac375 100644
--- a/gfx/cairo/cairo/src/cairo-recording-surface.c
+++ b/gfx/cairo/cairo/src/cairo-recording-surface.c
@@ -1,41 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- * Copyright © 2007 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Carl Worth <cworth@cworth.org>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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/. */
/**
* SECTION:cairo-recording
diff --git a/gfx/cairo/cairo/src/cairo-rectangle.c b/gfx/cairo/cairo/src/cairo-rectangle.c
index 608da53ea..ab043c1bc 100644
--- a/gfx/cairo/cairo/src/cairo-rectangle.c
+++ b/gfx/cairo/cairo/src/cairo-rectangle.c
@@ -1,41 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- * Copyright © 2006 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-rectangular-scan-converter.c b/gfx/cairo/cairo/src/cairo-rectangular-scan-converter.c
index dab2c151f..6c21f5fd5 100644
--- a/gfx/cairo/cairo/src/cairo-rectangular-scan-converter.c
+++ b/gfx/cairo/cairo/src/cairo-rectangular-scan-converter.c
@@ -1,35 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-reference-count-private.h b/gfx/cairo/cairo/src/cairo-reference-count-private.h
index 0d91488ee..c05d4c910 100644
--- a/gfx/cairo/cairo/src/cairo-reference-count-private.h
+++ b/gfx/cairo/cairo/src/cairo-reference-count-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_REFRENCE_COUNT_PRIVATE_H
#define CAIRO_REFRENCE_COUNT_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-region-private.h b/gfx/cairo/cairo/src/cairo-region-private.h
index 11070ba76..32c1e82ab 100644
--- a/gfx/cairo/cairo/src/cairo-region-private.h
+++ b/gfx/cairo/cairo/src/cairo-region-private.h
@@ -1,40 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Owen Taylor <otaylor@redhat.com>
- * Vladimir Vukicevic <vladimir@pobox.com>
- * Søren Sandmann <sandmann@daimi.au.dk>
- */
+/* 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_REGION_PRIVATE_H
#define CAIRO_REGION_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-region.c b/gfx/cairo/cairo/src/cairo-region.c
index 112b1d824..3e8ac1248 100644
--- a/gfx/cairo/cairo/src/cairo-region.c
+++ b/gfx/cairo/cairo/src/cairo-region.c
@@ -1,40 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Owen Taylor <otaylor@redhat.com>
- * Vladimir Vukicevic <vladimir@pobox.com>
- * Søren Sandmann <sandmann@daimi.au.dk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-rtree-private.h b/gfx/cairo/cairo/src/cairo-rtree-private.h
index 191c85871..295f48ced 100644
--- a/gfx/cairo/cairo/src/cairo-rtree-private.h
+++ b/gfx/cairo/cairo/src/cairo-rtree-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- *
- */
+/* 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_RTREE_PRIVATE_H
#define CAIRO_RTREE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-rtree.c b/gfx/cairo/cairo/src/cairo-rtree.c
index d6e57916a..059edff75 100644
--- a/gfx/cairo/cairo/src/cairo-rtree.c
+++ b/gfx/cairo/cairo/src/cairo-rtree.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- *
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-scaled-font-private.h b/gfx/cairo/cairo/src/cairo-scaled-font-private.h
index 029377b17..5d426494a 100644
--- a/gfx/cairo/cairo/src/cairo-scaled-font-private.h
+++ b/gfx/cairo/cairo/src/cairo-scaled-font-private.h
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_SCALED_FONT_PRIVATE_H
#define CAIRO_SCALED_FONT_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-scaled-font-subsets-private.h b/gfx/cairo/cairo/src/cairo-scaled-font-subsets-private.h
index b165d9aca..246dbdcfd 100644
--- a/gfx/cairo/cairo/src/cairo-scaled-font-subsets-private.h
+++ b/gfx/cairo/cairo/src/cairo-scaled-font-subsets-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_SCALED_FONT_SUBSETS_PRIVATE_H
#define CAIRO_SCALED_FONT_SUBSETS_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-scaled-font-subsets.c b/gfx/cairo/cairo/src/cairo-scaled-font-subsets.c
index 01bc05bfb..ba769d509 100644
--- a/gfx/cairo/cairo/src/cairo-scaled-font-subsets.c
+++ b/gfx/cairo/cairo/src/cairo-scaled-font-subsets.c
@@ -1,44 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2003 University of Southern California
- * Copyright © 2005 Red Hat, Inc
- * Copyright © 2006 Keith Packard
- * Copyright © 2006 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Kristian Høgsberg <krh@redhat.com>
- * Keith Packard <keithp@keithp.com>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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/. */
#define _BSD_SOURCE /* for snprintf(), strdup() */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-scaled-font.c b/gfx/cairo/cairo/src/cairo-scaled-font.c
index 95db65a99..37806bc63 100644
--- a/gfx/cairo/cairo/src/cairo-scaled-font.c
+++ b/gfx/cairo/cairo/src/cairo-scaled-font.c
@@ -1,42 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/*
- * Copyright © 2005 Keith Packard
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Keith Packard
- *
- * Contributor(s):
- * Keith Packard <keithp@keithp.com>
- * Carl D. Worth <cworth@cworth.org>
- * Graydon Hoare <graydon@redhat.com>
- * Owen Taylor <otaylor@redhat.com>
- * Behdad Esfahbod <behdad@behdad.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-script-surface.c b/gfx/cairo/cairo/src/cairo-script-surface.c
index 2cb427bcb..50214aa19 100644
--- a/gfx/cairo/cairo/src/cairo-script-surface.c
+++ b/gfx/cairo/cairo/src/cairo-script-surface.c
@@ -1,38 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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/. */
/* The script surface is one that records all operations performed on
* it in the form of a procedural script, similar in fashion to
diff --git a/gfx/cairo/cairo/src/cairo-script.h b/gfx/cairo/cairo/src/cairo-script.h
index b82230f2f..a9d1540cf 100644
--- a/gfx/cairo/cairo/src/cairo-script.h
+++ b/gfx/cairo/cairo/src/cairo-script.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_SCRIPT_H
#define CAIRO_SCRIPT_H
diff --git a/gfx/cairo/cairo/src/cairo-skia.h b/gfx/cairo/cairo/src/cairo-skia.h
index f62823522..89bd2713e 100644
--- a/gfx/cairo/cairo/src/cairo-skia.h
+++ b/gfx/cairo/cairo/src/cairo-skia.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_SKIA_H
#define CAIRO_SKIA_H
diff --git a/gfx/cairo/cairo/src/cairo-slope-private.h b/gfx/cairo/cairo/src/cairo-slope-private.h
index 6a58c9f45..bccc955d3 100644
--- a/gfx/cairo/cairo/src/cairo-slope-private.h
+++ b/gfx/cairo/cairo/src/cairo-slope-private.h
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_SLOPE_PRIVATE_H
#define _CAIRO_SLOPE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-slope.c b/gfx/cairo/cairo/src/cairo-slope.c
index 827037f76..fe93d66f6 100644
--- a/gfx/cairo/cairo/src/cairo-slope.c
+++ b/gfx/cairo/cairo/src/cairo-slope.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-spans-private.h b/gfx/cairo/cairo/src/cairo-spans-private.h
index 00a4df868..aecc9b976 100644
--- a/gfx/cairo/cairo/src/cairo-spans-private.h
+++ b/gfx/cairo/cairo/src/cairo-spans-private.h
@@ -1,4 +1,3 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
/* cairo - a vector graphics library with display and print output
*
* Copyright (c) 2008 M Joonas Pihlaja
diff --git a/gfx/cairo/cairo/src/cairo-spans.c b/gfx/cairo/cairo/src/cairo-spans.c
index a187b8998..f556d6b2a 100644
--- a/gfx/cairo/cairo/src/cairo-spans.c
+++ b/gfx/cairo/cairo/src/cairo-spans.c
@@ -1,4 +1,3 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
/* cairo - a vector graphics library with display and print output
*
* Copyright (c) 2008 M Joonas Pihlaja
diff --git a/gfx/cairo/cairo/src/cairo-spline.c b/gfx/cairo/cairo/src/cairo-spline.c
index ca2e2dc64..2fc99dfcb 100644
--- a/gfx/cairo/cairo/src/cairo-spline.c
+++ b/gfx/cairo/cairo/src/cairo-spline.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-stroke-style.c b/gfx/cairo/cairo/src/cairo-stroke-style.c
index 1513d1f35..e068e9dec 100644
--- a/gfx/cairo/cairo/src/cairo-stroke-style.c
+++ b/gfx/cairo/cairo/src/cairo-stroke-style.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-surface-clipper-private.h b/gfx/cairo/cairo/src/cairo-surface-clipper-private.h
index b9ca3cb1c..d8750e642 100644
--- a/gfx/cairo/cairo/src/cairo-surface-clipper-private.h
+++ b/gfx/cairo/cairo/src/cairo-surface-clipper-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.u>
- */
+/* 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_SURFACE_CLIPPER_PRIVATE_H
#define CAIRO_SURFACE_CLIPPER_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-surface-clipper.c b/gfx/cairo/cairo/src/cairo-surface-clipper.c
index 948730047..21c6fb1d5 100644
--- a/gfx/cairo/cairo/src/cairo-surface-clipper.c
+++ b/gfx/cairo/cairo/src/cairo-surface-clipper.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-surface-fallback-private.h b/gfx/cairo/cairo/src/cairo-surface-fallback-private.h
index e993de62e..3c6324815 100644
--- a/gfx/cairo/cairo/src/cairo-surface-fallback-private.h
+++ b/gfx/cairo/cairo/src/cairo-surface-fallback-private.h
@@ -1,40 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_SURFACE_FALLBACK_PRIVATE_H
#define CAIRO_SURFACE_FALLBACK_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-surface-fallback.c b/gfx/cairo/cairo/src/cairo-surface-fallback.c
index 51893ee65..09ab644a7 100644
--- a/gfx/cairo/cairo/src/cairo-surface-fallback.c
+++ b/gfx/cairo/cairo/src/cairo-surface-fallback.c
@@ -1,42 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-surface-offset-private.h b/gfx/cairo/cairo/src/cairo-surface-offset-private.h
index b7877b3de..94525a689 100644
--- a/gfx/cairo/cairo/src/cairo-surface-offset-private.h
+++ b/gfx/cairo/cairo/src/cairo-surface-offset-private.h
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.u>
- */
+/* 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_SURFACE_OFFSET_PRIVATE_H
#define CAIRO_SURFACE_OFFSET_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-surface-offset.c b/gfx/cairo/cairo/src/cairo-surface-offset.c
index fdbe1a124..a5070617d 100644
--- a/gfx/cairo/cairo/src/cairo-surface-offset.c
+++ b/gfx/cairo/cairo/src/cairo-surface-offset.c
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- * Copyright © 2007 Adrian Johnson
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-surface-private.h b/gfx/cairo/cairo/src/cairo-surface-private.h
index 61acf4b05..96cd4a371 100644
--- a/gfx/cairo/cairo/src/cairo-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-surface-private.h
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_SURFACE_PRIVATE_H
#define CAIRO_SURFACE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-surface-snapshot-private.h b/gfx/cairo/cairo/src/cairo-surface-snapshot-private.h
index bbb2bf2a0..a9520332a 100644
--- a/gfx/cairo/cairo/src/cairo-surface-snapshot-private.h
+++ b/gfx/cairo/cairo/src/cairo-surface-snapshot-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Intel Corporation.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_SURFACE_SNAPSHOT_PRIVATE_H
#define CAIRO_SURFACE_SNAPSHOT_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-surface-snapshot.c b/gfx/cairo/cairo/src/cairo-surface-snapshot.c
index 2dbf2507a..030636056 100644
--- a/gfx/cairo/cairo/src/cairo-surface-snapshot.c
+++ b/gfx/cairo/cairo/src/cairo-surface-snapshot.c
@@ -1,41 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-surface-subsurface-private.h b/gfx/cairo/cairo/src/cairo-surface-subsurface-private.h
index 435e1eb83..3fe48f83b 100644
--- a/gfx/cairo/cairo/src/cairo-surface-subsurface-private.h
+++ b/gfx/cairo/cairo/src/cairo-surface-subsurface-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Intel Corporation.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_SURFACE_SUBSURFACE_PRIVATE_H
#define CAIRO_SURFACE_SUBSURFACE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-surface-subsurface.c b/gfx/cairo/cairo/src/cairo-surface-subsurface.c
index 178966263..b9d8eacd6 100644
--- a/gfx/cairo/cairo/src/cairo-surface-subsurface.c
+++ b/gfx/cairo/cairo/src/cairo-surface-subsurface.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Intel Corporation.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-surface-wrapper-private.h b/gfx/cairo/cairo/src/cairo-surface-wrapper-private.h
index a1f05d386..c6d2bbe91 100644
--- a/gfx/cairo/cairo/src/cairo-surface-wrapper-private.h
+++ b/gfx/cairo/cairo/src/cairo-surface-wrapper-private.h
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.u>
- */
+/* 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_SURFACE_WRAPPER_PRIVATE_H
#define CAIRO_SURFACE_WRAPPER_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-surface-wrapper.c b/gfx/cairo/cairo/src/cairo-surface-wrapper.c
index d3f126e18..902e717cb 100644
--- a/gfx/cairo/cairo/src/cairo-surface-wrapper.c
+++ b/gfx/cairo/cairo/src/cairo-surface-wrapper.c
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- * Copyright © 2007 Adrian Johnson
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-surface.c b/gfx/cairo/cairo/src/cairo-surface.c
index b57b944b8..c80ea8553 100644
--- a/gfx/cairo/cairo/src/cairo-surface.c
+++ b/gfx/cairo/cairo/src/cairo-surface.c
@@ -1,40 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-svg-surface-private.h b/gfx/cairo/cairo/src/cairo-svg-surface-private.h
index ddbf464b1..eea51cbbf 100644
--- a/gfx/cairo/cairo/src/cairo-svg-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-svg-surface-private.h
@@ -1,42 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc
- * Copyright © 2005-2006 Emmanuel Pacaud <emmanuel.pacaud@free.fr>
- * Copyright © 2006 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Emmanuel Pacaud <emmanuel.pacaud@univ-poitiers.fr>
- * Carl Worth <cworth@cworth.org>
- */
+/* 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_SVG_SURFACE_PRIVATE_H
#define CAIRO_SVG_SURFACE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-svg-surface.c b/gfx/cairo/cairo/src/cairo-svg-surface.c
index fb612fadf..b18527f0c 100644
--- a/gfx/cairo/cairo/src/cairo-svg-surface.c
+++ b/gfx/cairo/cairo/src/cairo-svg-surface.c
@@ -1,43 +1,6 @@
-/* vim: set sw=4 sts=4: -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc
- * Copyright © 2005-2007 Emmanuel Pacaud <emmanuel.pacaud@free.fr>
- * Copyright © 2006 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Emmanuel Pacaud <emmanuel.pacaud@free.fr>
- * Carl Worth <cworth@cworth.org>
- */
+/* 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/. */
#define _BSD_SOURCE /* for snprintf() */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-svg.h b/gfx/cairo/cairo/src/cairo-svg.h
index 0f739fc04..2c07aeedf 100644
--- a/gfx/cairo/cairo/src/cairo-svg.h
+++ b/gfx/cairo/cairo/src/cairo-svg.h
@@ -1,33 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * cairo-svg.h
- *
- * Copyright © 2005 Emmanuel Pacaud <emmanuel.pacaud@univ-poitiers.fr>
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- */
+/* 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_SVG_H
#define CAIRO_SVG_H
diff --git a/gfx/cairo/cairo/src/cairo-system.c b/gfx/cairo/cairo/src/cairo-system.c
index 1ff4d078f..22e4934c7 100644
--- a/gfx/cairo/cairo/src/cairo-system.c
+++ b/gfx/cairo/cairo/src/cairo-system.c
@@ -1,40 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Owen Taylor <otaylor@redhat.com>
- * Stuart Parmenter <stuart@mozilla.com>
- * Vladimir Vukicevic <vladimir@pobox.com>
- */
+/* 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 file should include code that is system-specific, not
* feature-specific. For example, the DLL initialization/finalization
diff --git a/gfx/cairo/cairo/src/cairo-tee-surface-private.h b/gfx/cairo/cairo/src/cairo-tee-surface-private.h
index a83cfc959..dd8aeda4d 100644
--- a/gfx/cairo/cairo/src/cairo-tee-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-tee-surface-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_TEE_SURFACE_PRIVATE_H
#define CAIRO_TEE_SURFACE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-tee-surface.c b/gfx/cairo/cairo/src/cairo-tee-surface.c
index bca07716f..755a0b7ee 100644
--- a/gfx/cairo/cairo/src/cairo-tee-surface.c
+++ b/gfx/cairo/cairo/src/cairo-tee-surface.c
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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 surface supports redirecting all its input to multiple surfaces.
*/
diff --git a/gfx/cairo/cairo/src/cairo-tee.h b/gfx/cairo/cairo/src/cairo-tee.h
index 9c048c6fe..c60cb5327 100644
--- a/gfx/cairo/cairo/src/cairo-tee.h
+++ b/gfx/cairo/cairo/src/cairo-tee.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_TEE_H
#define CAIRO_TEE_H
diff --git a/gfx/cairo/cairo/src/cairo-tor-scan-converter.c b/gfx/cairo/cairo/src/cairo-tor-scan-converter.c
index dc8dad1c5..0dc20fef5 100644
--- a/gfx/cairo/cairo/src/cairo-tor-scan-converter.c
+++ b/gfx/cairo/cairo/src/cairo-tor-scan-converter.c
@@ -1,4 +1,3 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
/* glitter-paths - polygon scan converter
*
* Copyright (c) 2008 M Joonas Pihlaja
@@ -25,12 +24,14 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
+
/* This is the Glitter paths scan converter incorporated into cairo.
* The source is from commit 734c53237a867a773640bd5b64816249fa1730f8
* of
*
* http://gitweb.freedesktop.org/?p=users/joonas/glitter-paths
*/
+
/* Glitter-paths is a stand alone polygon rasteriser derived from
* David Turner's reimplementation of Tor Anderssons's 15x17
* supersampling rasteriser from the Apparition graphics library. The
diff --git a/gfx/cairo/cairo/src/cairo-toy-font-face.c b/gfx/cairo/cairo/src/cairo-toy-font-face.c
index 4c690da53..92045ba3e 100644
--- a/gfx/cairo/cairo/src/cairo-toy-font-face.c
+++ b/gfx/cairo/cairo/src/cairo-toy-font-face.c
@@ -1,43 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005,2008 Red Hat Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Graydon Hoare <graydon@redhat.com>
- * Owen Taylor <otaylor@redhat.com>
- * Behdad Esfahbod <behdad@behdad.org>
- */
+/* 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/. */
#define _BSD_SOURCE /* for strdup() */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-traps.c b/gfx/cairo/cairo/src/cairo-traps.c
index 2fe6684db..c3f1d2e35 100644
--- a/gfx/cairo/cairo/src/cairo-traps.c
+++ b/gfx/cairo/cairo/src/cairo-traps.c
@@ -1,41 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/*
- * Copyright © 2002 Keith Packard
- * Copyright © 2007 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Keith Packard
- *
- * Contributor(s):
- * Keith R. Packard <keithp@keithp.com>
- * Carl D. Worth <cworth@cworth.org>
- *
- * 2002-07-15: Converted from XRenderCompositeDoublePoly to #cairo_trap_t. Carl D. Worth
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-truetype-subset-private.h b/gfx/cairo/cairo/src/cairo-truetype-subset-private.h
index f0822611d..fee112b97 100644
--- a/gfx/cairo/cairo/src/cairo-truetype-subset-private.h
+++ b/gfx/cairo/cairo/src/cairo-truetype-subset-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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_TRUETYPE_SUBSET_PRIVATE_H
#define CAIRO_TRUETYPE_SUBSET_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-truetype-subset.c b/gfx/cairo/cairo/src/cairo-truetype-subset.c
index 9bf2f8ffc..219adbeb6 100644
--- a/gfx/cairo/cairo/src/cairo-truetype-subset.c
+++ b/gfx/cairo/cairo/src/cairo-truetype-subset.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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/. */
/*
* Useful links:
diff --git a/gfx/cairo/cairo/src/cairo-type1-fallback.c b/gfx/cairo/cairo/src/cairo-type1-fallback.c
index b93c42348..cc3a26966 100644
--- a/gfx/cairo/cairo/src/cairo-type1-fallback.c
+++ b/gfx/cairo/cairo/src/cairo-type1-fallback.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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/. */
#define _BSD_SOURCE /* for snprintf(), strdup() */
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-type1-private.h b/gfx/cairo/cairo/src/cairo-type1-private.h
index 1630397bc..0634b7061 100644
--- a/gfx/cairo/cairo/src/cairo-type1-private.h
+++ b/gfx/cairo/cairo/src/cairo-type1-private.h
@@ -1,37 +1,6 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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_TYPE1_PRIVATE_H
#define CAIRO_TYPE1_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-type1-subset.c b/gfx/cairo/cairo/src/cairo-type1-subset.c
index ffa9bfb8f..7abcb10cb 100644
--- a/gfx/cairo/cairo/src/cairo-type1-subset.c
+++ b/gfx/cairo/cairo/src/cairo-type1-subset.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- */
+/* 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/. */
/*
* Useful links:
diff --git a/gfx/cairo/cairo/src/cairo-type3-glyph-surface-private.h b/gfx/cairo/cairo/src/cairo-type3-glyph-surface-private.h
index b4abcf604..b101431fc 100644
--- a/gfx/cairo/cairo/src/cairo-type3-glyph-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-type3-glyph-surface-private.h
@@ -1,38 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Adrian Johnson.
- *
- * Contributor(s):
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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_TYPE3_GLYPH_SURFACE_PRIVATE_H
#define CAIRO_TYPE3_GLYPH_SURFACE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-type3-glyph-surface.c b/gfx/cairo/cairo/src/cairo-type3-glyph-surface.c
index 74257d4bf..e0ad08032 100644
--- a/gfx/cairo/cairo/src/cairo-type3-glyph-surface.c
+++ b/gfx/cairo/cairo/src/cairo-type3-glyph-surface.c
@@ -1,38 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Adrian Johnson.
- *
- * Contributor(s):
- * Adrian Johnson <ajohnson@redneon.com>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-types-private.h b/gfx/cairo/cairo/src/cairo-types-private.h
index 93b035d7c..00b9269c7 100644
--- a/gfx/cairo/cairo/src/cairo-types-private.h
+++ b/gfx/cairo/cairo/src/cairo-types-private.h
@@ -1,40 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_TYPES_PRIVATE_H
#define CAIRO_TYPES_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-unicode.c b/gfx/cairo/cairo/src/cairo-unicode.c
index 88de39516..3a60ff611 100644
--- a/gfx/cairo/cairo/src/cairo-unicode.c
+++ b/gfx/cairo/cairo/src/cairo-unicode.c
@@ -1,44 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * The code in this file is derived from GLib's gutf8.c and
- * ultimately from libunicode. It is relicensed under the
- * dual LGPL/MPL with permission of the original authors.
- *
- * Copyright © 1999 Tom Tromey
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Tom Tromey.
- * and Red Hat, Inc.
- *
- * Contributor(s):
- * Owen Taylor <otaylor@redhat.com>
- */
+/* 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-error-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-user-font-private.h b/gfx/cairo/cairo/src/cairo-user-font-private.h
index d54ef78b4..c5995978f 100644
--- a/gfx/cairo/cairo/src/cairo-user-font-private.h
+++ b/gfx/cairo/cairo/src/cairo-user-font-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006, 2008 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Behdad Esfahbod <behdad@behdad.org>
- */
+/* 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_USER_FONT_PRIVATE_H
#define CAIRO_USER_FONT_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-user-font.c b/gfx/cairo/cairo/src/cairo-user-font.c
index a524d588f..9219a7301 100644
--- a/gfx/cairo/cairo/src/cairo-user-font.c
+++ b/gfx/cairo/cairo/src/cairo-user-font.c
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2006, 2008 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Kristian Høgsberg <krh@redhat.com>
- * Behdad Esfahbod <behdad@behdad.org>
- */
+/* 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-user-font-private.h"
diff --git a/gfx/cairo/cairo/src/cairo-version.c b/gfx/cairo/cairo/src/cairo-version.c
index b07b48b37..5b7fa6827 100644
--- a/gfx/cairo/cairo/src/cairo-version.c
+++ b/gfx/cairo/cairo/src/cairo-version.c
@@ -1,40 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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/. */
#define CAIRO_VERSION_H 1
diff --git a/gfx/cairo/cairo/src/cairo-vg-surface.c b/gfx/cairo/cairo/src/cairo-vg-surface.c
index d3ae8aa52..3a3d83e96 100644
--- a/gfx/cairo/cairo/src/cairo-vg-surface.c
+++ b/gfx/cairo/cairo/src/cairo-vg-surface.c
@@ -1,38 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Opened Hand Ltd.
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.og/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * Contributor(s):
- * Pierre Tardy <tardyp@gmail.com>
- * Øyvind Kolås <pippin@gimp.org>
- * Vladimi Vukicevic <vladimir@mozilla.com> (stubbed out base backend)
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-vg.h b/gfx/cairo/cairo/src/cairo-vg.h
index f9a62e51c..7f1097d04 100644
--- a/gfx/cairo/cairo/src/cairo-vg.h
+++ b/gfx/cairo/cairo/src/cairo-vg.h
@@ -1,40 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 * Mozilla Corporation
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Mozilla Corporation.
- *
- * Contributor(s):
- * Vladimir Vukicevic <vladimir@mozilla.com>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_VG_H
#define CAIRO_VG_H
diff --git a/gfx/cairo/cairo/src/cairo-wideint-private.h b/gfx/cairo/cairo/src/cairo-wideint-private.h
index b9f8dae64..a1ae4dce8 100644
--- a/gfx/cairo/cairo/src/cairo-wideint-private.h
+++ b/gfx/cairo/cairo/src/cairo-wideint-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Keith Packard
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Keith Packard
- *
- * Contributor(s):
- * Keith R. Packard <keithp@keithp.com>
- *
- */
+/* 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_WIDEINT_H
#define CAIRO_WIDEINT_H
diff --git a/gfx/cairo/cairo/src/cairo-wideint-type-private.h b/gfx/cairo/cairo/src/cairo-wideint-type-private.h
index 9e49ad947..d7f0319a2 100644
--- a/gfx/cairo/cairo/src/cairo-wideint-type-private.h
+++ b/gfx/cairo/cairo/src/cairo-wideint-type-private.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Keith Packard
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Keith Packard
- *
- * Contributor(s):
- * Keith R. Packard <keithp@keithp.com>
- *
- */
+/* 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_WIDEINT_TYPE_H
#define CAIRO_WIDEINT_TYPE_H
diff --git a/gfx/cairo/cairo/src/cairo-wideint.c b/gfx/cairo/cairo/src/cairo-wideint.c
index 78dedcdf0..90809c005 100644
--- a/gfx/cairo/cairo/src/cairo-wideint.c
+++ b/gfx/cairo/cairo/src/cairo-wideint.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2004 Keith Packard
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Keith Packard
- *
- * Contributor(s):
- * Keith R. Packard <keithp@keithp.com>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-win32-font.c b/gfx/cairo/cairo/src/cairo-win32-font.c
index f0bdc8457..ccdd16187 100644
--- a/gfx/cairo/cairo/src/cairo-win32-font.c
+++ b/gfx/cairo/cairo/src/cairo-win32-font.c
@@ -1,45 +1,16 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- */
+/* 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/. */
-#define WIN32_LEAN_AND_MEAN
-/* We require Windows 2000 features such as GetGlyphIndices */
-#if !defined(WINVER) || (WINVER < 0x0500)
-# define WINVER 0x0500
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+/* We require at least Windows 7 features */
+#if !defined(WINVER) || (WINVER < 0x0601)
+# define WINVER 0x0601
#endif
-#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
-# define _WIN32_WINNT 0x0500
+#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0601)
+# define _WIN32_WINNT 0x0601
#endif
#include "cairoint.h"
@@ -245,18 +216,8 @@ _compute_transform (cairo_win32_scaled_font_t *scaled_font,
static cairo_bool_t
_have_cleartype_quality (void)
{
- OSVERSIONINFO version_info;
-
- version_info.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
-
- if (!GetVersionEx (&version_info)) {
- _cairo_win32_print_gdi_error ("_have_cleartype_quality");
- return FALSE;
- }
-
- return (version_info.dwMajorVersion > 5 ||
- (version_info.dwMajorVersion == 5 &&
- version_info.dwMinorVersion >= 1)); /* XP or newer */
+ // All supported versions have cleartype
+ return TRUE;
}
BYTE
diff --git a/gfx/cairo/cairo/src/cairo-win32-printing-surface.c b/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
index a6df34ae1..56cf3242b 100644
--- a/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
+++ b/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
@@ -1,47 +1,16 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007, 2008 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Adrian Johnson.
- *
- * Contributor(s):
- * Adrian Johnson <ajohnson@redneon.com>
- * Vladimir Vukicevic <vladimir@pobox.com>
- */
+/* 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/. */
-#define WIN32_LEAN_AND_MEAN
-/* We require Windows 2000 features such as ETO_PDY */
-#if !defined(WINVER) || (WINVER < 0x0500)
-# define WINVER 0x0500
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+/* We require at least Windows 7 features */
+#if !defined(WINVER) || (WINVER < 0x0601)
+# define WINVER 0x0601
#endif
-#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
-# define _WIN32_WINNT 0x0500
+#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0601)
+# define _WIN32_WINNT 0x0601
#endif
#include "cairoint.h"
diff --git a/gfx/cairo/cairo/src/cairo-win32-private.h b/gfx/cairo/cairo/src/cairo-win32-private.h
index 44c38535f..571b7547c 100644
--- a/gfx/cairo/cairo/src/cairo-win32-private.h
+++ b/gfx/cairo/cairo/src/cairo-win32-private.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Owen Taylor <otaylor@redhat.com>
- */
+/* 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_WIN32_PRIVATE_H
#define CAIRO_WIN32_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-win32-refptr.h b/gfx/cairo/cairo/src/cairo-win32-refptr.h
index 0baf8ee7b..8c0ec3338 100644
--- a/gfx/cairo/cairo/src/cairo-win32-refptr.h
+++ b/gfx/cairo/cairo/src/cairo-win32-refptr.h
@@ -1,38 +1,7 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2010 Mozilla Foundation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is the Mozilla Foundation
- *
- * Contributor(s):
- * Bas Schouten <bschouten@mozilla.com>
- */
+/* 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_WIN32_REFPTR_H
#define CAIRO_WIN32_REFPTR_H
diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
index 3a3d82989..2d7395590 100644
--- a/gfx/cairo/cairo/src/cairo-win32-surface.c
+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
@@ -1,48 +1,16 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Owen Taylor <otaylor@redhat.com>
- * Stuart Parmenter <stuart@mozilla.com>
- * Vladimir Vukicevic <vladimir@pobox.com>
- */
+/* 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/. */
-#define WIN32_LEAN_AND_MEAN
-/* We require Windows 2000 features such as ETO_PDY */
-#if !defined(WINVER) || (WINVER < 0x0500)
-# define WINVER 0x0500
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+/* We require at least Windows 7 features */
+#if !defined(WINVER) || (WINVER < 0x0601)
+# define WINVER 0x0601
#endif
-#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
-# define _WIN32_WINNT 0x0500
+#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0601)
+# define _WIN32_WINNT 0x0601
#endif
#include "cairoint.h"
@@ -947,28 +915,14 @@ _composite_alpha_blend (cairo_win32_surface_t *dst,
BLENDFUNCTION blend_function;
- /* Check for AlphaBlend dynamically to allow compiling on
- * MSVC 6 and use on older windows versions
- */
+ /* Check for AlphaBlend dynamically */
if (!alpha_blend_checked) {
- OSVERSIONINFO os;
-
- os.dwOSVersionInfoSize = sizeof (os);
- GetVersionEx (&os);
-
- /* If running on Win98, disable using AlphaBlend()
- * to avoid Win98 AlphaBlend() bug */
- if (VER_PLATFORM_WIN32_WINDOWS != os.dwPlatformId ||
- os.dwMajorVersion != 4 || os.dwMinorVersion != 10)
- {
HMODULE msimg32_dll = LoadLibraryW (L"msimg32");
if (msimg32_dll != NULL)
alpha_blend = (cairo_alpha_blend_func_t)GetProcAddress (msimg32_dll,
"AlphaBlend");
- }
-
- alpha_blend_checked = TRUE;
+ alpha_blend_checked = TRUE;
}
if (alpha_blend == NULL)
diff --git a/gfx/cairo/cairo/src/cairo-win32.h b/gfx/cairo/cairo/src/cairo-win32.h
index 07f7cc8e4..a1d45c19a 100644
--- a/gfx/cairo/cairo/src/cairo-win32.h
+++ b/gfx/cairo/cairo/src/cairo-win32.h
@@ -1,38 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Owen Taylor <otaylor@redhat.com>
- */
+/* 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_WIN32_H_
#define _CAIRO_WIN32_H_
diff --git a/gfx/cairo/cairo/src/cairo-xcb-surface.c b/gfx/cairo/cairo/src/cairo-xcb-surface.c
index da07f609f..7f53e630f 100644
--- a/gfx/cairo/cairo/src/cairo-xcb-surface.c
+++ b/gfx/cairo/cairo/src/cairo-xcb-surface.c
@@ -1,42 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Behdad Esfahbod <behdad@behdad.org>
- * Carl D. Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- * Karl Tomlinson <karlt+@karlt.net>, Mozilla Corporation
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-xcb-xrender.h b/gfx/cairo/cairo/src/cairo-xcb-xrender.h
index 09c609738..ff81706c4 100644
--- a/gfx/cairo/cairo/src/cairo-xcb-xrender.h
+++ b/gfx/cairo/cairo/src/cairo-xcb-xrender.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_XCB_XRENDER_H
#define CAIRO_XCB_XRENDER_H
diff --git a/gfx/cairo/cairo/src/cairo-xcb.h b/gfx/cairo/cairo/src/cairo-xcb.h
index 3f64dcbdc..de72b4f04 100644
--- a/gfx/cairo/cairo/src/cairo-xcb.h
+++ b/gfx/cairo/cairo/src/cairo-xcb.h
@@ -1,40 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2009 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_XCB_H
#define CAIRO_XCB_H
diff --git a/gfx/cairo/cairo/src/cairo-xlib-display.c b/gfx/cairo/cairo/src/cairo-xlib-display.c
index 139e63149..7967d6027 100644
--- a/gfx/cairo/cairo/src/cairo-xlib-display.c
+++ b/gfx/cairo/cairo/src/cairo-xlib-display.c
@@ -1,37 +1,6 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson.
- *
- * Contributor(s):
- * Karl Tomlinson <karlt+@karlt.net>, Mozilla Corporation
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-xlib-private.h b/gfx/cairo/cairo/src/cairo-xlib-private.h
index bd260bc0e..e575b2704 100644
--- a/gfx/cairo/cairo/src/cairo-xlib-private.h
+++ b/gfx/cairo/cairo/src/cairo-xlib-private.h
@@ -1,38 +1,6 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributors(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- * Karl Tomlinson <karlt+@karlt.net>, Mozilla Corporation
- */
+/* 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_XLIB_PRIVATE_H
#define CAIRO_XLIB_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-xlib-screen.c b/gfx/cairo/cairo/src/cairo-xlib-screen.c
index a0c3df840..9663ddb7b 100644
--- a/gfx/cairo/cairo/src/cairo-xlib-screen.c
+++ b/gfx/cairo/cairo/src/cairo-xlib-screen.c
@@ -1,35 +1,8 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Partially on code from xftdpy.c
+/* 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/. */
+
+/* Partially based on code from xftdpy.c, original code licensed under:
*
* Copyright © 2000 Keith Packard
*
diff --git a/gfx/cairo/cairo/src/cairo-xlib-surface-private.h b/gfx/cairo/cairo/src/cairo-xlib-surface-private.h
index 34732b4f6..cd7e79d69 100644
--- a/gfx/cairo/cairo/src/cairo-xlib-surface-private.h
+++ b/gfx/cairo/cairo/src/cairo-xlib-surface-private.h
@@ -1,34 +1,6 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- */
+/* 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_XLIB_SURFACE_PRIVATE_H
#define CAIRO_XLIB_SURFACE_PRIVATE_H
diff --git a/gfx/cairo/cairo/src/cairo-xlib-surface.c b/gfx/cairo/cairo/src/cairo-xlib-surface.c
index e24c9627a..36b696eaa 100644
--- a/gfx/cairo/cairo/src/cairo-xlib-surface.c
+++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c
@@ -1,43 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Behdad Esfahbod <behdad@behdad.org>
- * Chris Wilson <chris@chris-wilson.co.uk>
- * Karl Tomlinson <karlt+@karlt.net>, Mozilla Corporation
- */
+/* 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/. */
/* Heed well the words of Owen Taylor:
* "Any patch that works around a render bug, or claims to, without a
diff --git a/gfx/cairo/cairo/src/cairo-xlib-visual.c b/gfx/cairo/cairo/src/cairo-xlib-visual.c
index e076ed01e..f70db3a77 100644
--- a/gfx/cairo/cairo/src/cairo-xlib-visual.c
+++ b/gfx/cairo/cairo/src/cairo-xlib-visual.c
@@ -1,37 +1,6 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2008 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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"
diff --git a/gfx/cairo/cairo/src/cairo-xlib-xrender-private.h b/gfx/cairo/cairo/src/cairo-xlib-xrender-private.h
index 52f415915..6372787a0 100644
--- a/gfx/cairo/cairo/src/cairo-xlib-xrender-private.h
+++ b/gfx/cairo/cairo/src/cairo-xlib-xrender-private.h
@@ -1,34 +1,8 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2007 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- */
+/* 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/. */
+
+/* Part of this file is subject to a different license. See below. */
#ifndef CAIRO_XLIB_XRENDER_PRIVATE_H
#define CAIRO_XLIB_XRENDER_PRIVATE_H
@@ -184,7 +158,7 @@ typedef struct _XConicalGradient {
/* The rest of this file is copied from various Xrender header files, with
* the following copyright/license information:
*
- * Copyright © 2000 SuSE, Inc.
+ * Copyright (C) 2000 SuSE, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/gfx/cairo/cairo/src/cairo-xlib-xrender.h b/gfx/cairo/cairo/src/cairo-xlib-xrender.h
index b34b057de..996983e4e 100644
--- a/gfx/cairo/cairo/src/cairo-xlib-xrender.h
+++ b/gfx/cairo/cairo/src/cairo-xlib-xrender.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_XLIB_XRENDER_H
#define CAIRO_XLIB_XRENDER_H
diff --git a/gfx/cairo/cairo/src/cairo-xlib.h b/gfx/cairo/cairo/src/cairo-xlib.h
index 4ee592ce4..fdcff769c 100644
--- a/gfx/cairo/cairo/src/cairo-xlib.h
+++ b/gfx/cairo/cairo/src/cairo-xlib.h
@@ -1,38 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_XLIB_H
#define CAIRO_XLIB_H
diff --git a/gfx/cairo/cairo/src/cairo-xml-surface.c b/gfx/cairo/cairo/src/cairo-xml-surface.c
index 5583829e7..f1c3c3ed6 100644
--- a/gfx/cairo/cairo/src/cairo-xml-surface.c
+++ b/gfx/cairo/cairo/src/cairo-xml-surface.c
@@ -1,38 +1,6 @@
-/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson.
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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 surface is intended to produce a verbose, hierarchical, DAG XML file
* representing a single surface. It is intended to be used by debuggers,
diff --git a/gfx/cairo/cairo/src/cairo-xml.h b/gfx/cairo/cairo/src/cairo-xml.h
index 9ae76e90a..0367076a3 100644
--- a/gfx/cairo/cairo/src/cairo-xml.h
+++ b/gfx/cairo/cairo/src/cairo-xml.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson
- *
- * Contributor(s):
- * Chris Wilson <chris@chris-wilson.co.uk>
- */
+/* 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_XML_H
#define CAIRO_XML_H
diff --git a/gfx/cairo/cairo/src/cairo.c b/gfx/cairo/cairo/src/cairo.c
index eeee0206e..e4a90b57f 100644
--- a/gfx/cairo/cairo/src/cairo.c
+++ b/gfx/cairo/cairo/src/cairo.c
@@ -1,40 +1,6 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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-private.h"
diff --git a/gfx/cairo/cairo/src/cairo.h b/gfx/cairo/cairo/src/cairo.h
index 52d062352..3a34e80bf 100644
--- a/gfx/cairo/cairo/src/cairo.h
+++ b/gfx/cairo/cairo/src/cairo.h
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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_H
#define CAIRO_H
diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
index be78d6d89..3627cd288 100644
--- a/gfx/cairo/cairo/src/cairoint.h
+++ b/gfx/cairo/cairo/src/cairoint.h
@@ -1,39 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2002 University of Southern California
- * Copyright © 2005 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- */
+/* 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/. */
/*
* These definitions are solely for use by the implementation of cairo
diff --git a/gfx/cairo/cairo/src/test-fallback-surface.c b/gfx/cairo/cairo/src/test-fallback-surface.c
index 66399d4ab..ff07bc81e 100644
--- a/gfx/cairo/cairo/src/test-fallback-surface.c
+++ b/gfx/cairo/cairo/src/test-fallback-surface.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- */
+/* 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 isn't a "real" surface, but just something to be used by the
* test suite to test a mythical backend that uses nothing but
diff --git a/gfx/cairo/cairo/src/test-fallback-surface.h b/gfx/cairo/cairo/src/test-fallback-surface.h
index e70715113..c2534c184 100644
--- a/gfx/cairo/cairo/src/test-fallback-surface.h
+++ b/gfx/cairo/cairo/src/test-fallback-surface.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- */
+/* 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 TEST_FALLBACK_SURFACE_H
#define TEST_FALLBACK_SURFACE_H
diff --git a/gfx/cairo/cairo/src/test-meta-surface.c b/gfx/cairo/cairo/src/test-meta-surface.c
index d5e14d7d1..305174eb5 100644
--- a/gfx/cairo/cairo/src/test-meta-surface.c
+++ b/gfx/cairo/cairo/src/test-meta-surface.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- */
+/* 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 isn't a "real" surface, but just something to be used by the
* test suite to help exercise the meta-surface paths in cairo.
diff --git a/gfx/cairo/cairo/src/test-meta-surface.h b/gfx/cairo/cairo/src/test-meta-surface.h
index c036bb9c8..78b7a5752 100644
--- a/gfx/cairo/cairo/src/test-meta-surface.h
+++ b/gfx/cairo/cairo/src/test-meta-surface.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- */
+/* 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 TEST_META_SURFACE_H
#define TEST_META_SURFACE_H
diff --git a/gfx/cairo/cairo/src/test-paginated-surface.c b/gfx/cairo/cairo/src/test-paginated-surface.c
index e06cbed71..5d09308f4 100644
--- a/gfx/cairo/cairo/src/test-paginated-surface.c
+++ b/gfx/cairo/cairo/src/test-paginated-surface.c
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- */
+/* 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 isn't a "real" surface, but just something to be used by the
* test suite to help exercise the paginated-surface paths in cairo.
diff --git a/gfx/cairo/cairo/src/test-paginated-surface.h b/gfx/cairo/cairo/src/test-paginated-surface.h
index 2bd98aa5e..5f2d1d593 100644
--- a/gfx/cairo/cairo/src/test-paginated-surface.h
+++ b/gfx/cairo/cairo/src/test-paginated-surface.h
@@ -1,37 +1,6 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- * Carl Worth <cworth@cworth.org>
- */
+/* 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 TEST_PAGINATED_SURFACE_H
#define TEST_PAGINATED_SURFACE_H
diff --git a/gfx/cairo/cairo_qt_a8_fallback.diff b/gfx/cairo/cairo_qt_a8_fallback.diff
deleted file mode 100644
index a8388dda7..000000000
--- a/gfx/cairo/cairo_qt_a8_fallback.diff
+++ /dev/null
@@ -1,68 +0,0 @@
-CAIRO_FORMAT_A8 not allowed for cairo-qt image backend
-diff --git a/gfx/cairo/cairo/src/cairo-qt-surface.cpp b/gfx/cairo/cairo/src/cairo-qt-surface.cpp
---- a/gfx/cairo/cairo/src/cairo-qt-surface.cpp
-+++ b/gfx/cairo/cairo/src/cairo-qt-surface.cpp
-@@ -459,17 +459,17 @@ _cairo_qt_surface_finish (void *abstract
- {
- 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
-+ 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)
-@@ -736,17 +736,17 @@ _cairo_qt_surface_set_clip_region (cairo
- }
-
- 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", abstract_surface, path ? "(path)" : "(clear)"));
-+ 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 {
-@@ -1605,16 +1605,25 @@ cairo_qt_surface_create_with_qimage (cai
-
- _cairo_surface_init (&qs->base,
- &cairo_qt_surface_backend,
- _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);
diff --git a/gfx/cairo/cairo_qt_glyphs.patch b/gfx/cairo/cairo_qt_glyphs.patch
deleted file mode 100644
index b12356287..000000000
--- a/gfx/cairo/cairo_qt_glyphs.patch
+++ /dev/null
@@ -1,256 +0,0 @@
-Bug 29092 - Fix glyphs rendering for cairo-qpainter-surface
-diff --git a/src/cairo-qt-surface.cpp b/src/cairo-qt-surface.cpp
-index 2ac06ef..5b61b42 100644
---- a/src/cairo-qt-surface.cpp
-+++ b/src/cairo-qt-surface.cpp
-@@ -45,6 +45,7 @@
- #include "cairo-surface-clipper-private.h"
- #include "cairo-types-private.h"
-
-+#include "cairo-ft.h"
- #include "cairo-qt.h"
-
- #include <memory>
-@@ -58,14 +59,10 @@
- #include <QtGui/QPen>
- #include <QtGui/QWidget>
- #include <QtGui/QX11Info>
-+#include <QtCore/QVarLengthArray>
-
--#if CAIRO_HAS_XLIB_XRENDER_SURFACE
--#include "cairo-xlib.h"
--#include "cairo-xlib-xrender.h"
--// I hate X
--#undef Status
--#undef CursorShape
--#undef Bool
-+#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) || defined(QT_GLYPHS_API_BACKPORT)
-+extern void qt_draw_glyphs(QPainter *, const quint32 *glyphs, const QPointF *positions, int count);
- #endif
-
- #include <sys/time.h>
-@@ -118,15 +115,6 @@ struct cairo_qt_surface_t {
-
- cairo_bool_t supports_porter_duff;
-
--#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-- /* temporary, so that we can share the xlib surface's glyphs code */
-- bool xlib_has_clipping;
-- cairo_surface_t *xlib_equiv;
-- QRect xlib_clip_bounds;
-- int xlib_clip_serial;
-- QPoint redir_offset;
--#endif
--
- QPainter *p;
-
- /* The pixmap/image constructors will store their objects here */
-@@ -145,11 +133,6 @@ struct cairo_qt_surface_t {
- */
- static cairo_bool_t _qpixmaps_have_no_alpha = FALSE;
-
--#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
--slim_hidden_proto (cairo_xlib_surface_create);
--slim_hidden_proto (cairo_xlib_surface_create_with_xrender_format);
--#endif
--
- /**
- ** Helper methods
- **/
-@@ -498,11 +481,6 @@ _cairo_qt_surface_finish (void *abstract_surface)
-
- _cairo_surface_clipper_reset (&qs->clipper);
-
--#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-- if (qs->xlib_equiv)
-- cairo_surface_destroy (qs->xlib_equiv);
--#endif
--
- if (qs->image)
- delete qs->image;
-
-@@ -1392,33 +1370,40 @@ _cairo_qt_surface_show_glyphs (void *abstract_surface,
- cairo_clip_t *clip,
- int *remaining_glyphs)
- {
-+#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) || defined(QT_GLYPHS_API_BACKPORT)
- cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface;
-
--#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-- /* If we have an equivalent X surface, let the xlib surface handle this
-- * until we figure out how to do this natively with Qt.
-- */
-- if (qs->xlib_equiv) {
-- D(fprintf(stderr, "q[%p] show_glyphs (x11 equiv) op:%s nglyphs: %d\n", abstract_surface, _opstr(op), num_glyphs));
--
-- for (int i = 0; i < num_glyphs; i++) {
-- glyphs[i].x -= qs->redir_offset.x();
-- glyphs[i].y -= qs->redir_offset.y();
-- }
--
-- return (cairo_int_status_t)
-- _cairo_surface_show_text_glyphs (qs->xlib_equiv,
-- op, source,
-- NULL, 0,
-- glyphs, num_glyphs,
-- NULL, 0,
-- (cairo_text_cluster_flags_t) 0,
-- scaled_font,
-- clip);
-+ // pick out the colour to use from the cairo source
-+ cairo_solid_pattern_t *solid = (cairo_solid_pattern_t*) source;
-+ cairo_scaled_glyph_t* glyph;
-+ // documentation says you have to freeze the cache, but I don't believe it
-+ _cairo_scaled_font_freeze_cache(scaled_font);
-+
-+ QColor tempColour(solid->color.red * 255, solid->color.green * 255, solid->color.blue * 255);
-+ QVarLengthArray<QPointF> positions(num_glyphs);
-+ QVarLengthArray<unsigned int> glyphss(num_glyphs);
-+ FT_Face face = cairo_ft_scaled_font_lock_face (scaled_font);
-+ const FT_Size_Metrics& ftMetrics = face->size->metrics;
-+ QFont font(face->family_name);
-+ font.setStyleStrategy(QFont::NoFontMerging);
-+ font.setBold(face->style_flags & FT_STYLE_FLAG_BOLD);
-+ font.setItalic(face->style_flags & FT_STYLE_FLAG_ITALIC);
-+ font.setKerning(face->face_flags & FT_FACE_FLAG_KERNING);
-+ font.setPixelSize(ftMetrics.y_ppem);
-+ cairo_ft_scaled_font_unlock_face(scaled_font);
-+ qs->p->setFont(font);
-+ qs->p->setPen(tempColour);
-+ for (int currentGlyph = 0; currentGlyph < num_glyphs; currentGlyph++) {
-+ positions[currentGlyph].setX(glyphs[currentGlyph].x);
-+ positions[currentGlyph].setY(glyphs[currentGlyph].y);
-+ glyphss[currentGlyph] = glyphs[currentGlyph].index;
- }
--#endif
--
-+ qt_draw_glyphs(qs->p, glyphss.data(), positions.data(), num_glyphs);
-+ _cairo_scaled_font_thaw_cache(scaled_font);
-+ return CAIRO_INT_STATUS_SUCCESS;
-+#else
- return CAIRO_INT_STATUS_UNSUPPORTED;
-+#endif
- }
-
- static cairo_int_status_t
-@@ -1555,24 +1540,6 @@ _cairo_qt_surface_composite (cairo_operator_t op,
- }
-
- static cairo_status_t
--_cairo_qt_surface_flush (void *abstract_surface)
--{
-- cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface;
--
-- if (qs->p == NULL)
-- return CAIRO_STATUS_SUCCESS;
--
-- if (qs->image || qs->pixmap) {
-- qs->p->end ();
-- qs->p->begin (qs->p->device ());
-- } else {
-- qs->p->restore ();
-- }
--
-- return CAIRO_STATUS_SUCCESS;
--}
--
--static cairo_status_t
- _cairo_qt_surface_mark_dirty (void *abstract_surface,
- int x, int y,
- int width, int height)
-@@ -1609,7 +1576,7 @@ static const cairo_surface_backend_t cairo_qt_surface_backend = {
- _cairo_qt_surface_get_extents,
- NULL, /* old_show_glyphs */
- NULL, /* get_font_options */
-- _cairo_qt_surface_flush,
-+ NULL, /* flush */
- _cairo_qt_surface_mark_dirty,
- NULL, /* scaled_font_fini */
- NULL, /* scaled_glyph_fini */
-@@ -1629,64 +1596,6 @@ static const cairo_surface_backend_t cairo_qt_surface_backend = {
- NULL, /* show_text_glyphs */
- };
-
--#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
--static cairo_surface_t *
--_cairo_qt_create_xlib_surface (cairo_qt_surface_t *qs)
--{
-- if (!qs->p)
-- return NULL;
--
-- QPaintDevice *pd = qs->p->device();
-- if (!pd)
-- return NULL;
--
-- QPoint offs;
-- QPaintDevice *rpd = QPainter::redirected(pd, &offs);
-- if (rpd) {
-- pd = rpd;
-- qs->redir_offset = offs;
-- }
--
-- if (pd->devType() == QInternal::Widget) {
-- QWidget *w = (QWidget*) pd;
-- QX11Info xinfo = w->x11Info();
--
-- return cairo_xlib_surface_create (xinfo.display(),
-- (Drawable) w->handle (),
-- (Visual *) xinfo.visual (),
-- w->width (), w->height ());
-- } else if (pd->devType() == QInternal::Pixmap) {
-- QPixmap *pixmap = (QPixmap*) pd;
-- QX11Info xinfo = pixmap->x11Info ();
-- XRenderPictFormat *xrender_format;
-- int pict_format;
--
-- switch (pixmap->depth ()) {
-- case 1:
-- pict_format = PictStandardA1; break;
-- case 8:
-- pict_format = PictStandardA8; break;
-- case 24:
-- pict_format = PictStandardRGB24; break;
-- default:
-- ASSERT_NOT_REACHED;
-- case 32:
-- pict_format = PictStandardARGB32; break;
-- }
-- xrender_format = XRenderFindStandardFormat (xinfo.display (),
-- pict_format);
--
-- return cairo_xlib_surface_create_with_xrender_format (xinfo.display(),
-- (Drawable) pixmap->handle (),
-- ScreenOfDisplay (xinfo.display (),
-- xinfo.screen ()),
-- xrender_format,
-- pixmap->width (), pixmap->height ());
-- } else
-- return NULL;
--}
--#endif
--
- cairo_surface_t *
- cairo_qt_surface_create (QPainter *painter)
- {
-@@ -1717,10 +1626,6 @@ cairo_qt_surface_create (QPainter *painter)
-
- qs->window = painter->window();
-
--#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-- qs->xlib_equiv = _cairo_qt_create_xlib_surface (qs);
--#endif
--
- 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));
-@@ -1819,10 +1724,6 @@ cairo_qt_surface_create_with_qpixmap (cairo_content_t content,
-
- qs->window = QRect(0, 0, width, height);
-
--#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-- qs->xlib_equiv = _cairo_qt_create_xlib_surface (qs);
--#endif
--
- 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));
diff --git a/gfx/cairo/clip-invariant.patch b/gfx/cairo/clip-invariant.patch
deleted file mode 100644
index 08ba4d4de..000000000
--- a/gfx/cairo/clip-invariant.patch
+++ /dev/null
@@ -1,1255 +0,0 @@
-diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
-index 2acc8b5..019249e 100644
---- a/src/cairo-gl-surface.c
-+++ b/src/cairo-gl-surface.c
-@@ -2012,13 +2012,14 @@ typedef struct _cairo_gl_surface_span_renderer {
-
- cairo_gl_composite_setup_t setup;
-
-+ int xmin, xmax;
-+
- cairo_operator_t op;
- cairo_antialias_t antialias;
-
- cairo_gl_surface_t *dst;
- cairo_region_t *clip;
-
-- cairo_composite_rectangles_t composite_rectangles;
- GLuint vbo;
- void *vbo_base;
- unsigned int vbo_size;
-@@ -2049,11 +2050,11 @@ _cairo_gl_span_renderer_flush (cairo_gl_surface_span_renderer_t *renderer)
- cairo_region_get_rectangle (renderer->clip, i, &rect);
-
- glScissor (rect.x, rect.y, rect.width, rect.height);
-- glDrawArrays (GL_LINES, 0, count);
-+ glDrawArrays (GL_QUADS, 0, count);
- }
- glDisable (GL_SCISSOR_TEST);
- } else {
-- glDrawArrays (GL_LINES, 0, count);
-+ glDrawArrays (GL_QUADS, 0, count);
- }
- }
-
-@@ -2134,72 +2135,87 @@ _cairo_gl_emit_span_vertex (cairo_gl_surface_span_renderer_t *renderer,
-
- static void
- _cairo_gl_emit_span (cairo_gl_surface_span_renderer_t *renderer,
-- int x1, int x2, int y, uint8_t alpha)
-+ int x, int y1, int y2,
-+ uint8_t alpha)
- {
- float *vertices = _cairo_gl_span_renderer_get_vbo (renderer, 2);
-
-- _cairo_gl_emit_span_vertex (renderer, x1, y, alpha, vertices);
-- _cairo_gl_emit_span_vertex (renderer, x2, y, alpha,
-+ _cairo_gl_emit_span_vertex (renderer, x, y1, alpha, vertices);
-+ _cairo_gl_emit_span_vertex (renderer, x, y2, alpha,
- vertices + renderer->vertex_size / 4);
- }
-
--/* Emits the contents of the span renderer rows as GL_LINES with the span's
-- * alpha.
-- *
-- * Unlike the image surface, which is compositing into a temporary, we emit
-- * coverage even for alpha == 0, in case we're using an unbounded operator.
-- * But it means we avoid having to do the fixup.
-- */
-+static void
-+_cairo_gl_emit_rectangle (cairo_gl_surface_span_renderer_t *renderer,
-+ int x1, int y1,
-+ int x2, int y2,
-+ int coverage)
-+{
-+ _cairo_gl_emit_span (renderer, x1, y1, y2, coverage);
-+ _cairo_gl_emit_span (renderer, x2, y2, y1, coverage);
-+}
-+
- static cairo_status_t
--_cairo_gl_surface_span_renderer_render_row (
-- void *abstract_renderer,
-- int y,
-- const cairo_half_open_span_t *spans,
-- unsigned num_spans)
-+_cairo_gl_render_bounded_spans (void *abstract_renderer,
-+ int y, int height,
-+ const cairo_half_open_span_t *spans,
-+ unsigned num_spans)
- {
- cairo_gl_surface_span_renderer_t *renderer = abstract_renderer;
-- int xmin = renderer->composite_rectangles.mask.x;
-- int xmax = xmin + renderer->composite_rectangles.width;
-- int prev_x = xmin;
-- int prev_alpha = 0;
-- unsigned i;
-- int x_translate;
--
-- /* Make sure we're within y-range. */
-- if (y < renderer->composite_rectangles.mask.y ||
-- y >= renderer->composite_rectangles.mask.y +
-- renderer->composite_rectangles.height)
-+
-+ if (num_spans == 0)
- return CAIRO_STATUS_SUCCESS;
-
-- x_translate = renderer->composite_rectangles.dst.x -
-- renderer->composite_rectangles.mask.x;
-- y += renderer->composite_rectangles.dst.y -
-- renderer->composite_rectangles.mask.y;
-+ do {
-+ if (spans[0].coverage) {
-+ _cairo_gl_emit_rectangle (renderer,
-+ spans[0].x, y,
-+ spans[1].x, y + height,
-+ spans[0].coverage);
-+ }
-
-- /* Find the first span within x-range. */
-- for (i=0; i < num_spans && spans[i].x < xmin; i++) {}
-- if (i>0)
-- prev_alpha = spans[i-1].coverage;
-+ spans++;
-+ } while (--num_spans > 1);
-
-- /* Set the intermediate spans. */
-- for (; i < num_spans; i++) {
-- int x = spans[i].x;
-+ return CAIRO_STATUS_SUCCESS;
-+}
-
-- if (x >= xmax)
-- break;
-+static cairo_status_t
-+_cairo_gl_render_unbounded_spans (void *abstract_renderer,
-+ int y, int height,
-+ const cairo_half_open_span_t *spans,
-+ unsigned num_spans)
-+{
-+ cairo_gl_surface_span_renderer_t *renderer = abstract_renderer;
-
-- _cairo_gl_emit_span (renderer,
-- prev_x + x_translate, x + x_translate, y,
-- prev_alpha);
-+ if (num_spans == 0) {
-+ _cairo_gl_emit_rectangle (renderer,
-+ renderer->xmin, y,
-+ renderer->xmax, y + height,
-+ 0);
-+ return CAIRO_STATUS_SUCCESS;
-+ }
-
-- prev_x = x;
-- prev_alpha = spans[i].coverage;
-+ if (spans[0].x != renderer->xmin) {
-+ _cairo_gl_emit_rectangle (renderer,
-+ renderer->xmin, y,
-+ spans[0].x, y + height,
-+ 0);
- }
-
-- if (prev_x < xmax) {
-- _cairo_gl_emit_span (renderer,
-- prev_x + x_translate, xmax + x_translate, y,
-- prev_alpha);
-+ do {
-+ _cairo_gl_emit_rectangle (renderer,
-+ spans[0].x, y,
-+ spans[1].x, y + height,
-+ spans[0].coverage);
-+ spans++;
-+ } while (--num_spans > 1);
-+
-+ if (spans[0].x != renderer->xmax) {
-+ _cairo_gl_emit_rectangle (renderer,
-+ spans[0].x, y,
-+ renderer->xmax, y + height,
-+ 0);
- }
-
- return CAIRO_STATUS_SUCCESS;
-@@ -2274,8 +2290,6 @@ _cairo_gl_surface_create_span_renderer (cairo_operator_t op,
- cairo_gl_surface_t *dst = abstract_dst;
- cairo_gl_surface_span_renderer_t *renderer;
- cairo_status_t status;
-- int width = rects->width;
-- int height = rects->height;
- cairo_surface_attributes_t *src_attributes;
- GLenum err;
-
-diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
-index 48d8013..d52979d 100644
---- a/src/cairo-image-surface.c
-+++ b/src/cairo-image-surface.c
-@@ -1390,11 +1390,13 @@ typedef struct _cairo_image_surface_span_renderer {
- const cairo_pattern_t *pattern;
- cairo_antialias_t antialias;
-
-+ uint8_t *mask_data;
-+ uint32_t mask_stride;
-+
- cairo_image_surface_t *src;
- cairo_surface_attributes_t src_attributes;
- cairo_image_surface_t *mask;
- cairo_image_surface_t *dst;
--
- cairo_composite_rectangles_t composite_rectangles;
- } cairo_image_surface_span_renderer_t;
-
-@@ -1403,66 +1405,46 @@ _cairo_image_surface_span_render_row (
- int y,
- const cairo_half_open_span_t *spans,
- unsigned num_spans,
-- cairo_image_surface_t *mask,
-- const cairo_composite_rectangles_t *rects)
-+ uint8_t *data,
-+ uint32_t stride)
- {
-- int xmin = rects->mask.x;
-- int xmax = xmin + rects->width;
- uint8_t *row;
-- int prev_x = xmin;
-- int prev_alpha = 0;
- unsigned i;
-
-- /* Make sure we're within y-range. */
-- y -= rects->mask.y;
-- if (y < 0 || y >= rects->height)
-+ if (num_spans == 0)
- return;
-
-- row = (uint8_t*)(mask->data) + y*(size_t)mask->stride - xmin;
--
-- /* Find the first span within x-range. */
-- for (i=0; i < num_spans && spans[i].x < xmin; i++) {}
-- if (i>0)
-- prev_alpha = spans[i-1].coverage;
--
-- /* Set the intermediate spans. */
-- for (; i < num_spans; i++) {
-- int x = spans[i].x;
--
-- if (x >= xmax)
-- break;
--
-- if (prev_alpha != 0) {
-- /* We implement setting rendering the most common single
-- * pixel wide span case to avoid the overhead of a memset
-- * call. Open coding setting longer spans didn't show a
-- * noticeable improvement over memset. */
-- if (x == prev_x + 1) {
-- row[prev_x] = prev_alpha;
-- }
-- else {
-- memset(row + prev_x, prev_alpha, x - prev_x);
-- }
-+ row = data + y * stride;
-+ for (i = 0; i < num_spans - 1; i++) {
-+ if (! spans[i].coverage)
-+ continue;
-+
-+ /* We implement setting the most common single pixel wide
-+ * span case to avoid the overhead of a memset call.
-+ * Open coding setting longer spans didn't show a
-+ * noticeable improvement over memset.
-+ */
-+ if (spans[i+1].x == spans[i].x + 1) {
-+ row[spans[i].x] = spans[i].coverage;
-+ } else {
-+ memset (row + spans[i].x,
-+ spans[i].coverage,
-+ spans[i+1].x - spans[i].x);
- }
--
-- prev_x = x;
-- prev_alpha = spans[i].coverage;
-- }
--
-- if (prev_alpha != 0 && prev_x < xmax) {
-- memset(row + prev_x, prev_alpha, xmax - prev_x);
- }
- }
-
- static cairo_status_t
--_cairo_image_surface_span_renderer_render_row (
-+_cairo_image_surface_span_renderer_render_rows (
- void *abstract_renderer,
- int y,
-+ int height,
- const cairo_half_open_span_t *spans,
- unsigned num_spans)
- {
- cairo_image_surface_span_renderer_t *renderer = abstract_renderer;
-- _cairo_image_surface_span_render_row (y, spans, num_spans, renderer->mask, &renderer->composite_rectangles);
-+ while (height--)
-+ _cairo_image_surface_span_render_row (y++, spans, num_spans, renderer->mask_data, renderer->mask_stride);
- return CAIRO_STATUS_SUCCESS;
- }
-
-@@ -1517,11 +1499,11 @@ _cairo_image_surface_span_renderer_finish (void *abstract_renderer)
- &dst->base,
- src_attributes,
- src->width, src->height,
-- rects->width, rects->height,
-+ width, height,
- rects->src.x, rects->src.y,
- 0, 0, /* mask.x, mask.y */
- rects->dst.x, rects->dst.y,
-- rects->width, rects->height,
-+ width, height,
- dst->clip_region);
- }
- }
-@@ -1567,7 +1549,7 @@ _cairo_image_surface_create_span_renderer (cairo_operator_t op,
-
- renderer->base.destroy = _cairo_image_surface_span_renderer_destroy;
- renderer->base.finish = _cairo_image_surface_span_renderer_finish;
-- renderer->base.render_row = _cairo_image_surface_span_renderer_render_row;
-+ renderer->base.render_rows = _cairo_image_surface_span_renderer_render_rows;
- renderer->op = op;
- renderer->pattern = pattern;
- renderer->antialias = antialias;
-@@ -1604,6 +1586,9 @@ _cairo_image_surface_create_span_renderer (cairo_operator_t op,
- _cairo_image_surface_span_renderer_destroy (renderer);
- return _cairo_span_renderer_create_in_error (status);
- }
-+
-+ renderer->mask_data = renderer->mask->data - rects->mask.x - rects->mask.y * renderer->mask->stride;
-+ renderer->mask_stride = renderer->mask->stride;
- return &renderer->base;
- }
-
-diff --git a/src/cairo-spans-private.h b/src/cairo-spans-private.h
-index e29a567..af3b38c 100644
---- a/src/cairo-spans-private.h
-+++ b/src/cairo-spans-private.h
-@@ -47,26 +47,24 @@ typedef struct _cairo_half_open_span {
- * surfaces if they want to composite spans instead of trapezoids. */
- typedef struct _cairo_span_renderer cairo_span_renderer_t;
- struct _cairo_span_renderer {
-+ /* Private status variable. */
-+ cairo_status_t status;
-+
- /* Called to destroy the renderer. */
- cairo_destroy_func_t destroy;
-
-- /* Render the spans on row y of the source by whatever compositing
-- * method is required. The function should ignore spans outside
-- * the bounding box set by the init() function. */
-- cairo_status_t (*render_row)(
-- void *abstract_renderer,
-- int y,
-- const cairo_half_open_span_t *coverages,
-- unsigned num_coverages);
-+ /* Render the spans on row y of the destination by whatever compositing
-+ * method is required. */
-+ cairo_warn cairo_status_t
-+ (*render_rows) (void *abstract_renderer,
-+ int y, int height,
-+ const cairo_half_open_span_t *coverages,
-+ unsigned num_coverages);
-
- /* Called after all rows have been rendered to perform whatever
- * final rendering step is required. This function is called just
- * once before the renderer is destroyed. */
-- cairo_status_t (*finish)(
-- void *abstract_renderer);
--
-- /* Private status variable. */
-- cairo_status_t status;
-+ cairo_status_t (*finish) (void *abstract_renderer);
- };
-
- /* Scan converter interface. */
-diff --git a/src/cairo-spans.c b/src/cairo-spans.c
-index af3b85f..69894c1 100644
---- a/src/cairo-spans.c
-+++ b/src/cairo-spans.c
-@@ -275,13 +275,15 @@ _cairo_scan_converter_create_in_error (cairo_status_t status)
- }
-
- static cairo_status_t
--_cairo_nil_span_renderer_render_row (
-+_cairo_nil_span_renderer_render_rows (
- void *abstract_renderer,
- int y,
-+ int height,
- const cairo_half_open_span_t *coverages,
- unsigned num_coverages)
- {
- (void) y;
-+ (void) height;
- (void) coverages;
- (void) num_coverages;
- return _cairo_span_renderer_status (abstract_renderer);
-@@ -310,7 +312,7 @@ _cairo_span_renderer_set_error (
- ASSERT_NOT_REACHED;
- }
- if (renderer->status == CAIRO_STATUS_SUCCESS) {
-- renderer->render_row = _cairo_nil_span_renderer_render_row;
-+ renderer->render_rows = _cairo_nil_span_renderer_render_rows;
- renderer->finish = _cairo_nil_span_renderer_finish;
- renderer->status = error;
- }
-diff --git a/src/cairo-tor-scan-converter.c b/src/cairo-tor-scan-converter.c
-index 29262c2..2b9fb1b 100644
---- a/src/cairo-tor-scan-converter.c
-+++ b/src/cairo-tor-scan-converter.c
-@@ -128,27 +128,29 @@ blit_with_span_renderer(
- cairo_span_renderer_t *span_renderer,
- struct pool *span_pool,
- int y,
-+ int height,
- int xmin,
- int xmax);
-
- static glitter_status_t
--blit_empty_with_span_renderer (cairo_span_renderer_t *renderer, int y);
-+blit_empty_with_span_renderer (cairo_span_renderer_t *renderer, int y, int height);
-
- #define GLITTER_BLIT_COVERAGES_ARGS \
- cairo_span_renderer_t *span_renderer, \
- struct pool *span_pool
-
--#define GLITTER_BLIT_COVERAGES(cells, y, xmin, xmax) do { \
-+#define GLITTER_BLIT_COVERAGES(cells, y, height,xmin, xmax) do { \
- cairo_status_t status = blit_with_span_renderer (cells, \
- span_renderer, \
- span_pool, \
-- y, xmin, xmax); \
-+ y, height, \
-+ xmin, xmax); \
- if (unlikely (status)) \
- return status; \
- } while (0)
-
--#define GLITTER_BLIT_COVERAGES_EMPTY(y, xmin, xmax) do { \
-- cairo_status_t status = blit_empty_with_span_renderer (span_renderer, y); \
-+#define GLITTER_BLIT_COVERAGES_EMPTY(y, height, xmin, xmax) do { \
-+ cairo_status_t status = blit_empty_with_span_renderer (span_renderer, y, height); \
- if (unlikely (status)) \
- return status; \
- } while (0)
-@@ -309,8 +311,8 @@ typedef int grid_area_t;
- #define UNROLL3(x) x x x
-
- struct quorem {
-- int quo;
-- int rem;
-+ int32_t quo;
-+ int32_t rem;
- };
-
- /* Header for a chunk of memory in a memory pool. */
-@@ -382,6 +384,7 @@ struct edge {
- /* Original sign of the edge: +1 for downwards, -1 for upwards
- * edges. */
- int dir;
-+ int vertical;
- };
-
- /* Number of subsample rows per y-bucket. Must be GRID_Y. */
-@@ -389,18 +392,28 @@ struct edge {
-
- #define EDGE_Y_BUCKET_INDEX(y, ymin) (((y) - (ymin))/EDGE_Y_BUCKET_HEIGHT)
-
-+struct bucket {
-+ /* Unsorted list of edges starting within this bucket. */
-+ struct edge *edges;
-+
-+ /* Set to non-zero if there are edges starting strictly within the
-+ * bucket. */
-+ unsigned have_inside_edges;
-+};
-+
- /* A collection of sorted and vertically clipped edges of the polygon.
- * Edges are moved from the polygon to an active list while scan
- * converting. */
- struct polygon {
-- /* The vertical clip extents. */
-+ /* The clip extents. */
-+ grid_scaled_x_t xmin, xmax;
- grid_scaled_y_t ymin, ymax;
-
- /* Array of edges all starting in the same bucket. An edge is put
- * into bucket EDGE_BUCKET_INDEX(edge->ytop, polygon->ymin) when
- * it is added to the polygon. */
-- struct edge **y_buckets;
-- struct edge *y_buckets_embedded[64];
-+ struct bucket *y_buckets;
-+ struct bucket y_buckets_embedded[64];
-
- struct {
- struct pool base[1];
-@@ -702,7 +715,6 @@ static void
- cell_list_fini(struct cell_list *cells)
- {
- pool_fini (cells->cell_pool.base);
-- cell_list_init (cells);
- }
-
- /* Empty the cell list. This is called at the start of every pixel
-@@ -715,6 +727,26 @@ cell_list_reset (struct cell_list *cells)
- pool_reset (cells->cell_pool.base);
- }
-
-+static struct cell *
-+cell_list_alloc (struct cell_list *cells,
-+ struct cell **cursor,
-+ struct cell *tail,
-+ int x)
-+{
-+ struct cell *cell;
-+
-+ cell = pool_alloc (cells->cell_pool.base, sizeof (struct cell));
-+ if (unlikely (NULL == cell))
-+ return NULL;
-+
-+ *cursor = cell;
-+ cell->next = tail;
-+ cell->x = x;
-+ cell->uncovered_area = 0;
-+ cell->covered_height = 0;
-+ return cell;
-+}
-+
- /* Find a cell at the given x-coordinate. Returns %NULL if a new cell
- * needed to be allocated but couldn't be. Cells must be found with
- * non-decreasing x-coordinate until the cell list is rewound using
-@@ -737,22 +769,10 @@ cell_list_find (struct cell_list *cells, int x)
- }
- cells->cursor = cursor;
-
-- if (tail->x == x) {
-+ if (tail->x == x)
- return tail;
-- } else {
-- struct cell *cell;
--
-- cell = pool_alloc (cells->cell_pool.base, sizeof (struct cell));
-- if (unlikely (NULL == cell))
-- return NULL;
-
-- *cursor = cell;
-- cell->next = tail;
-- cell->x = x;
-- cell->uncovered_area = 0;
-- cell->covered_height = 0;
-- return cell;
-- }
-+ return cell_list_alloc (cells, cursor, tail, x);
- }
-
- /* Find two cells at x1 and x2. This is exactly equivalent
-@@ -832,9 +852,8 @@ cell_list_find_pair(struct cell_list *cells, int x1, int x2)
- /* Add an unbounded subpixel span covering subpixels >= x to the
- * coverage cells. */
- static glitter_status_t
--cell_list_add_unbounded_subspan(
-- struct cell_list *cells,
-- grid_scaled_x_t x)
-+cell_list_add_unbounded_subspan (struct cell_list *cells,
-+ grid_scaled_x_t x)
- {
- struct cell *cell;
- int ix, fx;
-@@ -907,20 +926,24 @@ cell_list_render_edge(
- struct edge *edge,
- int sign)
- {
-- struct quorem x1 = edge->x;
-- struct quorem x2 = x1;
- grid_scaled_y_t y1, y2, dy;
- grid_scaled_x_t dx;
- int ix1, ix2;
- grid_scaled_x_t fx1, fx2;
-
-- x2.quo += edge->dxdy_full.quo;
-- x2.rem += edge->dxdy_full.rem;
-- if (x2.rem >= 0) {
-- ++x2.quo;
-- x2.rem -= edge->dy;
-+ struct quorem x1 = edge->x;
-+ struct quorem x2 = x1;
-+
-+ if (! edge->vertical) {
-+ x2.quo += edge->dxdy_full.quo;
-+ x2.rem += edge->dxdy_full.rem;
-+ if (x2.rem >= 0) {
-+ ++x2.quo;
-+ x2.rem -= edge->dy;
-+ }
-+
-+ edge->x = x2;
- }
-- edge->x = x2;
-
- GRID_X_TO_INT_FRAC(x1.quo, ix1, fx1);
- GRID_X_TO_INT_FRAC(x2.quo, ix2, fx2);
-@@ -1026,6 +1049,7 @@ static void
- polygon_init (struct polygon *polygon)
- {
- polygon->ymin = polygon->ymax = 0;
-+ polygon->xmin = polygon->xmax = 0;
- polygon->y_buckets = polygon->y_buckets_embedded;
- pool_init (polygon->edge_pool.base,
- 8192 - sizeof (struct _pool_chunk),
-@@ -1045,10 +1069,11 @@ polygon_fini (struct polygon *polygon)
- * receive new edges and clip them to the vertical range
- * [ymin,ymax). */
- static glitter_status_t
--polygon_reset(
-- struct polygon *polygon,
-- grid_scaled_y_t ymin,
-- grid_scaled_y_t ymax)
-+polygon_reset (struct polygon *polygon,
-+ grid_scaled_x_t xmin,
-+ grid_scaled_x_t xmax,
-+ grid_scaled_y_t ymin,
-+ grid_scaled_y_t ymax)
- {
- unsigned h = ymax - ymin;
- unsigned num_buckets = EDGE_Y_BUCKET_INDEX(ymax + EDGE_Y_BUCKET_HEIGHT-1,
-@@ -1065,14 +1090,16 @@ polygon_reset(
- polygon->y_buckets = polygon->y_buckets_embedded;
- if (num_buckets > ARRAY_LENGTH (polygon->y_buckets_embedded)) {
- polygon->y_buckets = _cairo_malloc_ab (num_buckets,
-- sizeof (struct edge *));
-+ sizeof (struct bucket));
- if (unlikely (NULL == polygon->y_buckets))
- goto bail_no_mem;
- }
-- memset (polygon->y_buckets, 0, num_buckets * sizeof (struct edge *));
-+ memset (polygon->y_buckets, 0, num_buckets * sizeof (struct bucket));
-
- polygon->ymin = ymin;
- polygon->ymax = ymax;
-+ polygon->xmin = xmin;
-+ polygon->xmax = xmax;
- return GLITTER_STATUS_SUCCESS;
-
- bail_no_mem:
-@@ -1086,10 +1113,13 @@ _polygon_insert_edge_into_its_y_bucket(
- struct polygon *polygon,
- struct edge *e)
- {
-- unsigned ix = EDGE_Y_BUCKET_INDEX(e->ytop, polygon->ymin);
-- struct edge **ptail = &polygon->y_buckets[ix];
-+ unsigned j = e->ytop - polygon->ymin;
-+ unsigned ix = j / EDGE_Y_BUCKET_HEIGHT;
-+ unsigned offset = j % EDGE_Y_BUCKET_HEIGHT;
-+ struct edge **ptail = &polygon->y_buckets[ix].edges;
- e->next = *ptail;
- *ptail = e;
-+ polygon->y_buckets[ix].have_inside_edges |= offset;
- }
-
- inline static glitter_status_t
-@@ -1115,30 +1145,53 @@ polygon_add_edge (struct polygon *polygon,
- dx = edge->line.p2.x - edge->line.p1.x;
- dy = edge->line.p2.y - edge->line.p1.y;
- e->dy = dy;
-- e->dxdy = floored_divrem (dx, dy);
--
-- if (ymin <= edge->top)
-- ytop = edge->top;
-- else
-- ytop = ymin;
-- if (ytop == edge->line.p1.y) {
-- e->x.quo = edge->line.p1.x;
-- e->x.rem = 0;
-- } else {
-- e->x = floored_muldivrem (ytop - edge->line.p1.y, dx, dy);
-- e->x.quo += edge->line.p1.x;
-- }
--
- e->dir = edge->dir;
-+
-+ ytop = edge->top >= ymin ? edge->top : ymin;
-+ ybot = edge->bottom <= ymax ? edge->bottom : ymax;
- e->ytop = ytop;
-- ybot = edge->bottom < ymax ? edge->bottom : ymax;
- e->height_left = ybot - ytop;
-
-- if (e->height_left >= GRID_Y) {
-- e->dxdy_full = floored_muldivrem (GRID_Y, dx, dy);
-- } else {
-+ if (dx == 0) {
-+ e->vertical = TRUE;
-+ e->x.quo = edge->line.p1.x;
-+ e->x.rem = 0;
-+ e->dxdy.quo = 0;
-+ e->dxdy.rem = 0;
- e->dxdy_full.quo = 0;
- e->dxdy_full.rem = 0;
-+
-+ /* Drop edges to the right of the clip extents. */
-+ if (e->x.quo >= polygon->xmax)
-+ return GLITTER_STATUS_SUCCESS;
-+
-+ /* Offset vertical edges at the left side of the clip extents
-+ * to just shy of the left side. We depend on this when
-+ * checking for possible intersections within the clip
-+ * rectangle. */
-+ if (e->x.quo <= polygon->xmin) {
-+ e->x.quo = polygon->xmin - 1;
-+ }
-+ } else {
-+ e->vertical = FALSE;
-+ e->dxdy = floored_divrem (dx, dy);
-+ if (ytop == edge->line.p1.y) {
-+ e->x.quo = edge->line.p1.x;
-+ e->x.rem = 0;
-+ } else {
-+ e->x = floored_muldivrem (ytop - edge->line.p1.y, dx, dy);
-+ e->x.quo += edge->line.p1.x;
-+ }
-+
-+ if (e->x.quo >= polygon->xmax && e->dxdy.quo >= 0)
-+ return GLITTER_STATUS_SUCCESS;
-+
-+ if (e->height_left >= GRID_Y) {
-+ e->dxdy_full = floored_muldivrem (GRID_Y, dx, dy);
-+ } else {
-+ e->dxdy_full.quo = 0;
-+ e->dxdy_full.rem = 0;
-+ }
- }
-
- _polygon_insert_edge_into_its_y_bucket (polygon, e);
-@@ -1161,31 +1214,30 @@ active_list_init(struct active_list *active)
- active_list_reset(active);
- }
-
--static void
--active_list_fini(
-- struct active_list *active)
--{
-- active_list_reset(active);
--}
--
- /* Merge the edges in an unsorted list of edges into a sorted
- * list. The sort order is edges ascending by edge->x.quo. Returns
- * the new head of the sorted list. */
- static struct edge *
- merge_unsorted_edges(struct edge *sorted_head, struct edge *unsorted_head)
- {
-- struct edge *head = unsorted_head;
- struct edge **cursor = &sorted_head;
- int x;
-
-- while (NULL != head) {
-+ if (sorted_head == NULL) {
-+ sorted_head = unsorted_head;
-+ unsorted_head = unsorted_head->next;
-+ sorted_head->next = NULL;
-+ if (unsorted_head == NULL)
-+ return sorted_head;
-+ }
-+
-+ do {
-+ struct edge *next = unsorted_head->next;
- struct edge *prev = *cursor;
-- struct edge *next = head->next;
-- x = head->x.quo;
-
-- if (NULL == prev || x < prev->x.quo) {
-+ x = unsorted_head->x.quo;
-+ if (x < prev->x.quo)
- cursor = &sorted_head;
-- }
-
- while (1) {
- UNROLL3({
-@@ -1196,26 +1248,29 @@ merge_unsorted_edges(struct edge *sorted_head, struct edge *unsorted_head)
- });
- }
-
-- head->next = *cursor;
-- *cursor = head;
-+ unsorted_head->next = *cursor;
-+ *cursor = unsorted_head;
-+ unsorted_head = next;
-+ } while (unsorted_head != NULL);
-
-- head = next;
-- }
- return sorted_head;
- }
-
- /* Test if the edges on the active list can be safely advanced by a
- * full row without intersections or any edges ending. */
- inline static int
--active_list_can_step_full_row(
-- struct active_list *active)
-+active_list_can_step_full_row (struct active_list *active,
-+ grid_scaled_x_t xmin)
- {
-+ const struct edge *e;
-+ grid_scaled_x_t prev_x = INT_MIN;
-+
- /* Recomputes the minimum height of all edges on the active
- * list if we have been dropping edges. */
- if (active->min_height <= 0) {
-- struct edge *e = active->head;
- int min_height = INT_MAX;
-
-+ e = active->head;
- while (NULL != e) {
- if (e->height_left < min_height)
- min_height = e->height_left;
-@@ -1225,27 +1280,38 @@ active_list_can_step_full_row(
- active->min_height = min_height;
- }
-
-- /* Check for intersections only if no edges end during the next
-- * row. */
-- if (active->min_height >= GRID_Y) {
-- grid_scaled_x_t prev_x = INT_MIN;
-- struct edge *e = active->head;
-- while (NULL != e) {
-- struct quorem x = e->x;
-+ if (active->min_height < GRID_Y)
-+ return 0;
-
-+ /* Check for intersections as no edges end during the next row. */
-+ e = active->head;
-+ while (NULL != e) {
-+ struct quorem x = e->x;
-+
-+ if (! e->vertical) {
- x.quo += e->dxdy_full.quo;
- x.rem += e->dxdy_full.rem;
- if (x.rem >= 0)
- ++x.quo;
-+ }
-
-- if (x.quo <= prev_x)
-+ /* There's may be an intersection if the edge sort order might
-+ * change. */
-+ if (x.quo <= prev_x) {
-+ /* Ignore intersections to the left of the clip extents.
-+ * This assumes that all vertical edges on or at the left
-+ * side of the clip rectangle have been shifted slightly
-+ * to the left in polygon_add_edge(). */
-+ if (prev_x >= xmin || x.quo >= xmin || e->x.quo >= xmin)
- return 0;
-+ }
-+ else {
- prev_x = x.quo;
-- e = e->next;
- }
-- return 1;
-+ e = e->next;
- }
-- return 0;
-+
-+ return 1;
- }
-
- /* Merges edges on the given subpixel row from the polygon to the
-@@ -1261,7 +1327,7 @@ active_list_merge_edges_from_polygon(
- unsigned ix = EDGE_Y_BUCKET_INDEX(y, polygon->ymin);
- int min_height = active->min_height;
- struct edge *subrow_edges = NULL;
-- struct edge **ptail = &polygon->y_buckets[ix];
-+ struct edge **ptail = &polygon->y_buckets[ix].edges;
-
- while (1) {
- struct edge *tail = *ptail;
-@@ -1277,8 +1343,10 @@ active_list_merge_edges_from_polygon(
- ptail = &tail->next;
- }
- }
-- active->head = merge_unsorted_edges(active->head, subrow_edges);
-- active->min_height = min_height;
-+ if (subrow_edges) {
-+ active->head = merge_unsorted_edges(active->head, subrow_edges);
-+ active->min_height = min_height;
-+ }
- }
-
- /* Advance the edges on the active list by one subsample row by
-@@ -1439,11 +1507,13 @@ apply_nonzero_fill_rule_and_step_edges (struct active_list *active,
- }
- }
-
-- right_edge->x.quo += right_edge->dxdy_full.quo;
-- right_edge->x.rem += right_edge->dxdy_full.rem;
-- if (right_edge->x.rem >= 0) {
-- ++right_edge->x.quo;
-- right_edge->x.rem -= right_edge->dy;
-+ if (! right_edge->vertical) {
-+ right_edge->x.quo += right_edge->dxdy_full.quo;
-+ right_edge->x.rem += right_edge->dxdy_full.rem;
-+ if (right_edge->x.rem >= 0) {
-+ ++right_edge->x.quo;
-+ right_edge->x.rem -= right_edge->dy;
-+ }
- }
- }
-
-@@ -1472,6 +1542,7 @@ apply_evenodd_fill_rule_and_step_edges (struct active_list *active,
- left_edge = *cursor;
- while (NULL != left_edge) {
- struct edge *right_edge;
-+ int winding = left_edge->dir;
-
- left_edge->height_left -= GRID_Y;
- if (left_edge->height_left)
-@@ -1490,17 +1561,22 @@ apply_evenodd_fill_rule_and_step_edges (struct active_list *active,
- else
- *cursor = right_edge->next;
-
-+ winding += right_edge->dir;
-+ if ((winding & 1) == 0) {
- if (right_edge->next == NULL ||
- right_edge->next->x.quo != right_edge->x.quo)
- {
- break;
- }
-+ }
-
-- right_edge->x.quo += right_edge->dxdy_full.quo;
-- right_edge->x.rem += right_edge->dxdy_full.rem;
-- if (right_edge->x.rem >= 0) {
-- ++right_edge->x.quo;
-- right_edge->x.rem -= right_edge->dy;
-+ if (! right_edge->vertical) {
-+ right_edge->x.quo += right_edge->dxdy_full.quo;
-+ right_edge->x.rem += right_edge->dxdy_full.rem;
-+ if (right_edge->x.rem >= 0) {
-+ ++right_edge->x.quo;
-+ right_edge->x.rem -= right_edge->dy;
-+ }
- }
- }
-
-@@ -1537,8 +1613,14 @@ blit_span(
- }
- }
-
--#define GLITTER_BLIT_COVERAGES(coverages, y, xmin, xmax) \
-- blit_cells(coverages, raster_pixels + (y)*raster_stride, xmin, xmax)
-+#define GLITTER_BLIT_COVERAGES(coverages, y, height, xmin, xmax) \
-+ do { \
-+ int __y = y; \
-+ int __h = height; \
-+ do { \
-+ blit_cells(coverages, raster_pixels + (__y)*raster_stride, xmin, xmax); \
-+ } while (--__h); \
-+ } while (0)
-
- static void
- blit_cells(
-@@ -1597,7 +1679,6 @@ static void
- _glitter_scan_converter_fini(glitter_scan_converter_t *converter)
- {
- polygon_fini(converter->polygon);
-- active_list_fini(converter->active);
- cell_list_fini(converter->coverages);
- converter->xmin=0;
- converter->ymin=0;
-@@ -1641,7 +1722,7 @@ glitter_scan_converter_reset(
-
- active_list_reset(converter->active);
- cell_list_reset(converter->coverages);
-- status = polygon_reset(converter->polygon, ymin, ymax);
-+ status = polygon_reset(converter->polygon, xmin, xmax, ymin, ymax);
- if (status)
- return status;
-
-@@ -1711,19 +1792,48 @@ glitter_scan_converter_add_edge (glitter_scan_converter_t *converter,
- #endif
-
- #ifndef GLITTER_BLIT_COVERAGES_EMPTY
--# define GLITTER_BLIT_COVERAGES_EMPTY(y, xmin, xmax)
-+# define GLITTER_BLIT_COVERAGES_EMPTY(y0, y1, xmin, xmax)
- #endif
-
-+static cairo_bool_t
-+active_list_is_vertical (struct active_list *active)
-+{
-+ struct edge *e;
-+
-+ for (e = active->head; e != NULL; e = e->next) {
-+ if (! e->vertical)
-+ return FALSE;
-+ }
-+
-+ return TRUE;
-+}
-+
-+static void
-+step_edges (struct active_list *active, int count)
-+{
-+ struct edge **cursor = &active->head;
-+ struct edge *edge;
-+
-+ for (edge = *cursor; edge != NULL; edge = *cursor) {
-+ edge->height_left -= GRID_Y * count;
-+ if (edge->height_left)
-+ cursor = &edge->next;
-+ else
-+ *cursor = edge->next;
-+ }
-+}
-+
- I glitter_status_t
- glitter_scan_converter_render(
- glitter_scan_converter_t *converter,
- int nonzero_fill,
- GLITTER_BLIT_COVERAGES_ARGS)
- {
-- int i;
-+ int i, j;
- int ymax_i = converter->ymax / GRID_Y;
- int ymin_i = converter->ymin / GRID_Y;
- int xmin_i, xmax_i;
-+ grid_scaled_x_t xmin = converter->xmin;
- int h = ymax_i - ymin_i;
- struct polygon *polygon = converter->polygon;
- struct cell_list *coverages = converter->coverages;
-@@ -1738,22 +1848,28 @@ glitter_scan_converter_render(
- GLITTER_BLIT_COVERAGES_BEGIN;
-
- /* Render each pixel row. */
-- for (i=0; i<h; i++) {
-+ for (i = 0; i < h; i = j) {
- int do_full_step = 0;
- glitter_status_t status = 0;
-
-+ j = i + 1;
-+
- /* Determine if we can ignore this row or use the full pixel
- * stepper. */
-- if (GRID_Y == EDGE_Y_BUCKET_HEIGHT && ! polygon->y_buckets[i]) {
-+ if (polygon->y_buckets[i].edges == NULL) {
- if (! active->head) {
-- GLITTER_BLIT_COVERAGES_EMPTY (i+ymin_i, xmin_i, xmax_i);
-+ for (; j < h && ! polygon->y_buckets[j].edges; j++)
-+ ;
-+ GLITTER_BLIT_COVERAGES_EMPTY (i+ymin_i, j-i, xmin_i, xmax_i);
- continue;
- }
--
-- do_full_step = active_list_can_step_full_row (active);
-+ do_full_step = active_list_can_step_full_row (active, xmin);
-+ }
-+ else if (! polygon->y_buckets[i].have_inside_edges) {
-+ grid_scaled_y_t y = (i+ymin_i)*GRID_Y;
-+ active_list_merge_edges_from_polygon (active, y, polygon);
-+ do_full_step = active_list_can_step_full_row (active, xmin);
- }
--
-- cell_list_reset (coverages);
-
- if (do_full_step) {
- /* Step by a full pixel row's worth. */
-@@ -1764,8 +1880,20 @@ glitter_scan_converter_render(
- status = apply_evenodd_fill_rule_and_step_edges (active,
- coverages);
- }
-+
-+ if (active_list_is_vertical (active)) {
-+ while (j < h &&
-+ polygon->y_buckets[j].edges == NULL &&
-+ active->min_height >= 2*GRID_Y)
-+ {
-+ active->min_height -= GRID_Y;
-+ j++;
-+ }
-+ if (j != i + 1)
-+ step_edges (active, j - (i + 1));
-+ }
- } else {
-- /* Subsample this row. */
-+ /* Supersample this row. */
- grid_scaled_y_t suby;
- for (suby = 0; suby < GRID_Y; suby++) {
- grid_scaled_y_t y = (i+ymin_i)*GRID_Y + suby;
-@@ -1787,13 +1915,13 @@ glitter_scan_converter_render(
- if (unlikely (status))
- return status;
-
-- GLITTER_BLIT_COVERAGES(coverages, i+ymin_i, xmin_i, xmax_i);
-+ GLITTER_BLIT_COVERAGES(coverages, i+ymin_i, j-i, xmin_i, xmax_i);
-+ cell_list_reset (coverages);
-
-- if (! active->head) {
-+ if (! active->head)
- active->min_height = INT_MAX;
-- } else {
-+ else
- active->min_height -= GRID_Y;
-- }
- }
-
- /* Clean up the coverage blitter. */
-@@ -1807,21 +1935,20 @@ glitter_scan_converter_render(
- * scan converter subclass. */
-
- static glitter_status_t
--blit_with_span_renderer(
-- struct cell_list *cells,
-- cairo_span_renderer_t *renderer,
-- struct pool *span_pool,
-- int y,
-- int xmin,
-- int xmax)
-+blit_with_span_renderer (struct cell_list *cells,
-+ cairo_span_renderer_t *renderer,
-+ struct pool *span_pool,
-+ int y, int height,
-+ int xmin, int xmax)
- {
- struct cell *cell = cells->head;
- int prev_x = xmin;
- int cover = 0;
- cairo_half_open_span_t *spans;
- unsigned num_spans;
-+
- if (cell == NULL)
-- return CAIRO_STATUS_SUCCESS;
-+ return blit_empty_with_span_renderer (renderer, y, height);
-
- /* Skip cells to the left of the clip region. */
- while (cell != NULL && cell->x < xmin) {
-@@ -1833,12 +1960,12 @@ blit_with_span_renderer(
- /* Count number of cells remaining. */
- {
- struct cell *next = cell;
-- num_spans = 0;
-- while (next) {
-+ num_spans = 1;
-+ while (next != NULL) {
- next = next->next;
- ++num_spans;
- }
-- num_spans = 2*num_spans + 1;
-+ num_spans = 2*num_spans;
- }
-
- /* Allocate enough spans for the row. */
-@@ -1853,6 +1980,7 @@ blit_with_span_renderer(
- for (; cell != NULL; cell = cell->next) {
- int x = cell->x;
- int area;
-+
- if (x >= xmax)
- break;
-
-@@ -1872,20 +2000,26 @@ blit_with_span_renderer(
- prev_x = x+1;
- }
-
-- if (prev_x < xmax) {
-+ if (prev_x <= xmax) {
- spans[num_spans].x = prev_x;
- spans[num_spans].coverage = GRID_AREA_TO_ALPHA (cover);
- ++num_spans;
- }
-
-+ if (prev_x < xmax && cover) {
-+ spans[num_spans].x = xmax;
-+ spans[num_spans].coverage = 0;
-+ ++num_spans;
-+ }
-+
- /* Dump them into the renderer. */
-- return renderer->render_row (renderer, y, spans, num_spans);
-+ return renderer->render_rows (renderer, y, height, spans, num_spans);
- }
-
- static glitter_status_t
--blit_empty_with_span_renderer (cairo_span_renderer_t *renderer, int y)
-+blit_empty_with_span_renderer (cairo_span_renderer_t *renderer, int y, int height)
- {
-- return renderer->render_row (renderer, y, NULL, 0);
-+ return renderer->render_rows (renderer, y, height, NULL, 0);
- }
-
- struct _cairo_tor_scan_converter {
-diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
-index 82d1cf5..d4575a3 100644
---- a/src/cairo-win32-surface.c
-+++ b/src/cairo-win32-surface.c
-@@ -1954,6 +1954,9 @@ typedef struct _cairo_win32_surface_span_renderer {
- const cairo_pattern_t *pattern;
- cairo_antialias_t antialias;
-
-+ uint8_t *mask_data;
-+ uint32_t mask_stride;
-+
- cairo_image_surface_t *mask;
- cairo_win32_surface_t *dst;
- cairo_region_t *clip_region;
-@@ -1962,14 +1965,16 @@ typedef struct _cairo_win32_surface_span_renderer {
- } cairo_win32_surface_span_renderer_t;
-
- static cairo_status_t
--_cairo_win32_surface_span_renderer_render_row (
-+_cairo_win32_surface_span_renderer_render_rows (
- void *abstract_renderer,
- int y,
-+ int height,
- const cairo_half_open_span_t *spans,
- unsigned num_spans)
- {
- cairo_win32_surface_span_renderer_t *renderer = abstract_renderer;
-- _cairo_image_surface_span_render_row (y, spans, num_spans, renderer->mask, &renderer->composite_rectangles);
-+ while (height--)
-+ _cairo_image_surface_span_render_row (y++, spans, num_spans, renderer->mask_data, renderer->mask_stride);
- return CAIRO_STATUS_SUCCESS;
- }
-
-@@ -2066,8 +2071,7 @@ _cairo_win32_surface_create_span_renderer (cairo_operator_t op,
-
- renderer->base.destroy = _cairo_win32_surface_span_renderer_destroy;
- renderer->base.finish = _cairo_win32_surface_span_renderer_finish;
-- renderer->base.render_row =
-- _cairo_win32_surface_span_renderer_render_row;
-+ renderer->base.render_rows = _cairo_win32_surface_span_renderer_render_rows;
- renderer->op = op;
- renderer->pattern = pattern;
- renderer->antialias = antialias;
-@@ -2088,6 +2092,9 @@ _cairo_win32_surface_create_span_renderer (cairo_operator_t op,
- _cairo_win32_surface_span_renderer_destroy (renderer);
- return _cairo_span_renderer_create_in_error (status);
- }
-+
-+ renderer->mask_data = renderer->mask->data - rects->mask.x - rects->mask.y * renderer->mask->stride;
-+ renderer->mask_stride = renderer->mask->stride;
- return &renderer->base;
- }
-
-diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
-index a7a40b8..566d9fb 100644
---- a/src/cairo-xlib-display.c
-+++ b/src/cairo-xlib-display.c
-@@ -407,6 +407,10 @@ _cairo_xlib_display_get (Display *dpy,
- display->buggy_pad_reflect = TRUE;
- }
-
-+ /* gradients don't seem to work */
-+ display->buggy_gradients = TRUE;
-+
-+
- /* XXX workaround; see https://bugzilla.mozilla.org/show_bug.cgi?id=413583 */
- /* If buggy_repeat_force == -1, then initialize.
- * - set to -2, meaning "nothing was specified", and we trust the above detection.
-diff --git a/src/cairoint.h b/src/cairoint.h
-index 58850ab..1cdf6ff 100644
---- a/src/cairoint.h
-+++ b/src/cairoint.h
-@@ -2257,8 +2257,8 @@ cairo_private void
- _cairo_image_surface_span_render_row (int y,
- const cairo_half_open_span_t *spans,
- unsigned num_spans,
-- cairo_image_surface_t *mask,
-- const cairo_composite_rectangles_t *rects);
-+ uint8_t *data,
-+ uint32_t stride);
-
- cairo_private cairo_image_transparency_t
- _cairo_image_analyze_transparency (cairo_image_surface_t *image);
diff --git a/gfx/cairo/clip-rects-surface-extents.patch b/gfx/cairo/clip-rects-surface-extents.patch
deleted file mode 100644
index 1a9972aa7..000000000
--- a/gfx/cairo/clip-rects-surface-extents.patch
+++ /dev/null
@@ -1,163 +0,0 @@
-From 108b1c7825116ed3f93aa57384bbd3290cdc9181 Mon Sep 17 00:00:00 2001
-From: Karl Tomlinson <karlt+@karlt.net>
-Date: Sat, 17 Jul 2010 01:08:53 +0000
-Subject: clip: consider gstate target extents in _cairo_gstate_copy_clip_rectangle_list
-
-Fixes https://bugs.freedesktop.org/show_bug.cgi?id=29125
-
-To be consistent with _cairo_gstate_clip_extents, the context's clip
-should be intersected with the target surface extents (instead of only
-using them when there is no clip).
-
-Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
----
-diff --git a/src/cairo-clip.c b/src/cairo-clip.c
-index 77d8214..d5a2fab 100644
---- a/src/cairo-clip.c
-+++ b/src/cairo-clip.c
-@@ -1495,7 +1495,7 @@ _cairo_rectangle_list_create_in_error (cairo_status_t status)
- cairo_rectangle_list_t *
- _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
- {
--#define ERROR_LIST(S) _cairo_rectangle_list_create_in_error (_cairo_error (S));
-+#define ERROR_LIST(S) _cairo_rectangle_list_create_in_error (_cairo_error (S))
-
- cairo_rectangle_list_t *list;
- cairo_rectangle_t *rectangles = NULL;
-@@ -1507,57 +1507,37 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
- if (clip->all_clipped)
- goto DONE;
-
-- if (clip->path != NULL) {
-- status = _cairo_clip_get_region (clip, &region);
-- if (status == CAIRO_INT_STATUS_NOTHING_TO_DO) {
-- goto DONE;
-- } else if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
-- return ERROR_LIST (CAIRO_STATUS_CLIP_NOT_REPRESENTABLE)
-- } else if (unlikely (status)) {
-- return ERROR_LIST (status);
-- }
-- }
--
-- if (region != NULL) {
-- n_rects = cairo_region_num_rectangles (region);
-- if (n_rects) {
-- rectangles = _cairo_malloc_ab (n_rects, sizeof (cairo_rectangle_t));
-- if (unlikely (rectangles == NULL)) {
-- return ERROR_LIST (CAIRO_STATUS_NO_MEMORY);
-- }
-+ if (!clip->path)
-+ return ERROR_LIST (CAIRO_STATUS_CLIP_NOT_REPRESENTABLE);
-
-- for (i = 0; i < n_rects; ++i) {
-- cairo_rectangle_int_t clip_rect;
--
-- cairo_region_get_rectangle (region, i, &clip_rect);
-+ status = _cairo_clip_get_region (clip, &region);
-+ if (status == CAIRO_INT_STATUS_NOTHING_TO_DO) {
-+ goto DONE;
-+ } else if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
-+ return ERROR_LIST (CAIRO_STATUS_CLIP_NOT_REPRESENTABLE);
-+ } else if (unlikely (status)) {
-+ return ERROR_LIST (status);
-+ }
-
-- if (! _cairo_clip_int_rect_to_user (gstate,
-- &clip_rect,
-- &rectangles[i]))
-- {
-- free (rectangles);
-- return ERROR_LIST (CAIRO_STATUS_CLIP_NOT_REPRESENTABLE);
-- }
-- }
-+ n_rects = cairo_region_num_rectangles (region);
-+ if (n_rects) {
-+ rectangles = _cairo_malloc_ab (n_rects, sizeof (cairo_rectangle_t));
-+ if (unlikely (rectangles == NULL)) {
-+ return ERROR_LIST (CAIRO_STATUS_NO_MEMORY);
- }
-- } else {
-- cairo_rectangle_int_t extents;
-
-- if (! _cairo_surface_get_extents (_cairo_gstate_get_target (gstate),
-- &extents))
-- {
-- /* unbounded surface -> unclipped */
-- goto DONE;
-- }
-+ for (i = 0; i < n_rects; ++i) {
-+ cairo_rectangle_int_t clip_rect;
-
-- n_rects = 1;
-- rectangles = malloc(sizeof (cairo_rectangle_t));
-- if (unlikely (rectangles == NULL))
-- return ERROR_LIST (CAIRO_STATUS_NO_MEMORY);
-+ cairo_region_get_rectangle (region, i, &clip_rect);
-
-- if (! _cairo_clip_int_rect_to_user (gstate, &extents, rectangles)) {
-- free (rectangles);
-- return ERROR_LIST (CAIRO_STATUS_CLIP_NOT_REPRESENTABLE);
-+ if (! _cairo_clip_int_rect_to_user (gstate,
-+ &clip_rect,
-+ &rectangles[i]))
-+ {
-+ free (rectangles);
-+ return ERROR_LIST (CAIRO_STATUS_CLIP_NOT_REPRESENTABLE);
-+ }
- }
- }
-
-diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
-index baf6145..7caf624 100644
---- a/src/cairo-gstate.c
-+++ b/src/cairo-gstate.c
-@@ -1555,7 +1555,19 @@ _cairo_gstate_clip_extents (cairo_gstate_t *gstate,
- cairo_rectangle_list_t*
- _cairo_gstate_copy_clip_rectangle_list (cairo_gstate_t *gstate)
- {
-- return _cairo_clip_copy_rectangle_list (&gstate->clip, gstate);
-+ cairo_clip_t clip;
-+ cairo_rectangle_int_t extents;
-+ cairo_rectangle_list_t *list;
-+
-+ _cairo_clip_init_copy (&clip, &gstate->clip);
-+
-+ if (_cairo_surface_get_extents (gstate->target, &extents))
-+ _cairo_clip_rectangle (&clip, &extents);
-+
-+ list = _cairo_clip_copy_rectangle_list (&clip, gstate);
-+ _cairo_clip_fini (&clip);
-+
-+ return list;
- }
-
- static void
-diff --git a/test/get-clip.c b/test/get-clip.c
-index f0477a1..f97db3f 100644
---- a/test/get-clip.c
-+++ b/test/get-clip.c
-@@ -120,6 +120,22 @@ preamble (cairo_test_context_t *ctx)
- }
- cairo_rectangle_list_destroy (rectangle_list);
-
-+ /* We should get the same results after applying a clip that contains the
-+ existing clip. */
-+ phase = "Clip beyond surface extents";
-+ cairo_save (cr);
-+ cairo_rectangle (cr, -10, -10, SIZE + 20 , SIZE + 20);
-+ cairo_clip (cr);
-+ rectangle_list = cairo_copy_clip_rectangle_list (cr);
-+ if (! check_count (ctx, phase, rectangle_list, 1) ||
-+ ! check_clip_extents (ctx, phase, cr, 0, 0, SIZE, SIZE) ||
-+ ! check_rectangles_contain (ctx, phase, rectangle_list, 0, 0, SIZE, SIZE))
-+ {
-+ goto FAIL;
-+ }
-+ cairo_rectangle_list_destroy (rectangle_list);
-+ cairo_restore (cr);
-+
- /* Test simple clip rect. */
- phase = "Simple clip rect";
- cairo_save (cr);
---
-cgit v0.8.3-6-g21f6
diff --git a/gfx/cairo/copyarea-with-alpha.patch b/gfx/cairo/copyarea-with-alpha.patch
deleted file mode 100644
index c6765105e..000000000
--- a/gfx/cairo/copyarea-with-alpha.patch
+++ /dev/null
@@ -1,110 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-xlib-surface.c b/gfx/cairo/cairo/src/cairo-xlib-surface.c
---- a/gfx/cairo/cairo/src/cairo-xlib-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c
-@@ -1722,30 +1722,31 @@ _surface_has_alpha (cairo_xlib_surface_t
- else
- return FALSE;
- } else {
- /* In the no-render case, we never have alpha */
- return FALSE;
- }
- }
-
--/* Returns true if the given operator and source-alpha combination
-- * requires alpha compositing to complete.
-+/* Returns true if the given operator and alpha combination requires alpha
-+ * compositing to complete on source and destination surfaces with the same
-+ * format. i.e. if a simple bitwise copy is not appropriate.
- */
- static cairo_bool_t
- _operator_needs_alpha_composite (cairo_operator_t op,
-- cairo_bool_t destination_has_alpha,
-- cairo_bool_t source_has_alpha)
-+ cairo_bool_t surfaces_have_alpha)
- {
-- if (op == CAIRO_OPERATOR_SOURCE ||
-- (! source_has_alpha &&
-- (op == CAIRO_OPERATOR_OVER ||
-- op == CAIRO_OPERATOR_ATOP ||
-- op == CAIRO_OPERATOR_IN)))
-- return destination_has_alpha;
-+ if (op == CAIRO_OPERATOR_SOURCE)
-+ return FALSE;
-+
-+ if (op == CAIRO_OPERATOR_OVER ||
-+ op == CAIRO_OPERATOR_IN ||
-+ op == CAIRO_OPERATOR_ATOP)
-+ return surfaces_have_alpha;
-
- return TRUE;
- }
-
- /* There is a bug in most older X servers with compositing using a
- * untransformed repeating source pattern when the source is in off-screen
- * video memory, and another with repeated transformed images using a
- * general transform matrix. When these bugs could be triggered, we need a
-@@ -1843,24 +1844,24 @@ _categorize_composite_operation (cairo_x
- */
- static composite_operation_t
- _recategorize_composite_operation (cairo_xlib_surface_t *dst,
- cairo_operator_t op,
- cairo_xlib_surface_t *src,
- cairo_surface_attributes_t *src_attr,
- cairo_bool_t have_mask)
- {
-- /* Can we use the core protocol? */
-+ /* Can we use the core protocol? (If _surfaces_compatible, then src and
-+ * dst have the same format and _surface_has_alpha is the same for each.)
-+ */
- if (! have_mask &&
- src->owns_pixmap &&
-- src->depth == dst->depth &&
-+ _surfaces_compatible (src, dst) &&
- _cairo_matrix_is_integer_translation (&src_attr->matrix, NULL, NULL) &&
-- ! _operator_needs_alpha_composite (op,
-- _surface_has_alpha (dst),
-- _surface_has_alpha (src)))
-+ ! _operator_needs_alpha_composite (op, _surface_has_alpha (dst)))
- {
- if (src_attr->extend == CAIRO_EXTEND_NONE)
- return DO_XCOPYAREA;
-
- if (dst->buggy_repeat && src_attr->extend == CAIRO_EXTEND_REPEAT)
- return DO_XTILE;
- }
-
-@@ -2211,34 +2212,28 @@ _cairo_xlib_surface_composite (cairo_ope
- cairo_surface_attributes_t src_attr, mask_attr;
- cairo_xlib_surface_t *dst = abstract_dst;
- cairo_xlib_surface_t *src;
- cairo_xlib_surface_t *mask;
- cairo_int_status_t status;
- composite_operation_t operation;
- int itx, ity;
- cairo_bool_t is_integer_translation;
-- cairo_bool_t needs_alpha_composite;
- GC gc;
-
- if (mask_pattern != NULL && ! CAIRO_SURFACE_RENDER_HAS_COMPOSITE (dst))
- return UNSUPPORTED ("no support for masks");
-
- operation = _categorize_composite_operation (dst, op, src_pattern,
- mask_pattern != NULL);
- if (operation == DO_UNSUPPORTED)
- return UNSUPPORTED ("unsupported operation");
-
- X_DEBUG ((dst->dpy, "composite (dst=%x)", (unsigned int) dst->drawable));
-
-- needs_alpha_composite =
-- _operator_needs_alpha_composite (op,
-- _surface_has_alpha (dst),
-- ! _cairo_pattern_is_opaque (src_pattern));
--
- _cairo_xlib_display_notify (dst->display);
-
- status =
- _cairo_xlib_surface_acquire_pattern_surfaces (dst,
- src_pattern, mask_pattern,
- src_x, src_y,
- mask_x, mask_y,
- width, height,
diff --git a/gfx/cairo/d2d-gradient-ensure-stops.patch b/gfx/cairo/d2d-gradient-ensure-stops.patch
deleted file mode 100644
index 2f7bb9334..000000000
--- a/gfx/cairo/d2d-gradient-ensure-stops.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-# HG changeset patch
-# User Robert O'Callahan <robert@ocallahan.org>
-# Date 1348618772 -43200
-# Node ID 55ccbc8d52e69b020f2ba493e92ad2e214388df0
-# Parent e0d69219dd2b3b2826d186dc99c673b879409ea6
-Bug 792903. Prevent num_stops from being set to zero. r=bas
-
-diff --git a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
---- a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
-+++ b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
-@@ -1641,17 +1641,20 @@ static RefPtr<ID2D1Brush>
- min_dist = MIN(_cairo_d2d_dot_product(u, _cairo_d2d_subtract_point(top_left, p1)),
- _cairo_d2d_dot_product(u, _cairo_d2d_subtract_point(top_right, p1)));
- min_dist = MIN(min_dist, _cairo_d2d_dot_product(u, _cairo_d2d_subtract_point(bottom_left, p1)));
- min_dist = MIN(min_dist, _cairo_d2d_dot_product(u, _cairo_d2d_subtract_point(bottom_right, p1)));
-
- min_dist = MAX(-min_dist, 0);
-
- // Repeats after gradient start.
-- int after_repeat = (int)ceil(max_dist / gradient_length);
-+ // It's possible for max_dist and min_dist to both be zero, in which case
-+ // we'll set num_stops to 0 and crash D2D. Let's just ensure after_repeat
-+ // is at least 1.
-+ int after_repeat = MAX((int)ceil(max_dist / gradient_length), 1);
- int before_repeat = (int)ceil(min_dist / gradient_length);
- num_stops *= (after_repeat + before_repeat);
-
- p2.x = p1.x + u.x * after_repeat * gradient_length;
- p2.y = p1.y + u.y * after_repeat * gradient_length;
- p1.x = p1.x - u.x * before_repeat * gradient_length;
- p1.y = p1.y - u.y * before_repeat * gradient_length;
-
diff --git a/gfx/cairo/d2d-repeating-gradients.patch b/gfx/cairo/d2d-repeating-gradients.patch
deleted file mode 100644
index 993695bf0..000000000
--- a/gfx/cairo/d2d-repeating-gradients.patch
+++ /dev/null
@@ -1,271 +0,0 @@
-From: Robert O'Callahan <robert@ocallahan.org>
-Bug 768775. Improve the precision of the calculation of the number of stops that need to be added to handle 'repeat' and 'reflect', when we're filling a path. r=bas
-
-diff --git a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
---- a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
-+++ b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
-@@ -1411,17 +1411,17 @@ static RefPtr<ID2D1Brush>
-
- gradient_center.x = _cairo_fixed_to_float(source_pattern->c1.x);
- gradient_center.y = _cairo_fixed_to_float(source_pattern->c1.y);
-
- // Transform surface corners into pattern coordinates.
- cairo_matrix_transform_point(&source_pattern->base.base.matrix, &top_left.x, &top_left.y);
- cairo_matrix_transform_point(&source_pattern->base.base.matrix, &top_right.x, &top_right.y);
- cairo_matrix_transform_point(&source_pattern->base.base.matrix, &bottom_left.x, &bottom_left.y);
-- cairo_matrix_transform_point(&source_pattern->base.base.matrix, &bottom_right.x, &top_left.y);
-+ cairo_matrix_transform_point(&source_pattern->base.base.matrix, &bottom_right.x, &bottom_right.y);
-
- // Find the corner furthest away from the gradient center in pattern space.
- double largest = MAX(_cairo_d2d_point_dist(top_left, gradient_center), _cairo_d2d_point_dist(top_right, gradient_center));
- largest = MAX(largest, _cairo_d2d_point_dist(bottom_left, gradient_center));
- largest = MAX(largest, _cairo_d2d_point_dist(bottom_right, gradient_center));
-
- unsigned int minSize = (unsigned int)ceil(largest);
-
-@@ -1531,16 +1531,17 @@ static RefPtr<ID2D1Brush>
- stopCollection,
- &brush);
- delete [] stops;
- return brush;
- }
-
- static RefPtr<ID2D1Brush>
- _cairo_d2d_create_linear_gradient_brush(cairo_d2d_surface_t *d2dsurf,
-+ cairo_path_fixed_t *fill_path,
- cairo_linear_pattern_t *source_pattern)
- {
- if (source_pattern->p1.x == source_pattern->p2.x &&
- source_pattern->p1.y == source_pattern->p2.y) {
- // Cairo behavior in this situation is to draw a solid color the size of the last stop.
- RefPtr<ID2D1SolidColorBrush> brush;
- d2dsurf->rt->CreateSolidColorBrush(
- _cairo_d2d_color_from_cairo_color_stop(source_pattern->base.stops[source_pattern->base.n_stops - 1].color),
-@@ -1564,35 +1565,46 @@ static RefPtr<ID2D1Brush>
- p1.x = _cairo_fixed_to_float(source_pattern->p1.x);
- p1.y = _cairo_fixed_to_float(source_pattern->p1.y);
- p2.x = _cairo_fixed_to_float(source_pattern->p2.x);
- p2.y = _cairo_fixed_to_float(source_pattern->p2.y);
-
- D2D1_GRADIENT_STOP *stops;
- int num_stops = source_pattern->base.n_stops;
- if (source_pattern->base.base.extend == CAIRO_EXTEND_REPEAT || source_pattern->base.base.extend == CAIRO_EXTEND_REFLECT) {
--
-- RefPtr<IDXGISurface> surf;
-- d2dsurf->surface->QueryInterface(&surf);
-- DXGI_SURFACE_DESC desc;
-- surf->GetDesc(&desc);
--
- // Get this when the points are not transformed yet.
- double gradient_length = _cairo_d2d_point_dist(p1, p2);
--
-- // Calculate the repeat count needed;
-- cairo_point_double_t top_left, top_right, bottom_left, bottom_right;
-- top_left.x = bottom_left.x = top_left.y = top_right.y = 0;
-- top_right.x = bottom_right.x = desc.Width;
-- bottom_right.y = bottom_left.y = desc.Height;
-+ cairo_point_double_t top_left, top_right, bottom_left, bottom_right;
-+
-+ if (fill_path) {
-+ // Calculate the repeat count needed;
-+ cairo_box_t fill_extents;
-+ _cairo_path_fixed_extents (fill_path, &fill_extents);
-+
-+ top_left.x = bottom_left.x = _cairo_fixed_to_double (fill_extents.p1.x);
-+ top_left.y = top_right.y = _cairo_fixed_to_double (fill_extents.p1.y);
-+ top_right.x = bottom_right.x = _cairo_fixed_to_double (fill_extents.p2.x);
-+ bottom_right.y = bottom_left.y = _cairo_fixed_to_double (fill_extents.p2.y);
-+ } else {
-+ RefPtr<IDXGISurface> surf;
-+ d2dsurf->surface->QueryInterface(&surf);
-+ DXGI_SURFACE_DESC desc;
-+ surf->GetDesc(&desc);
-+
-+ top_left.x = bottom_left.x = 0;
-+ top_left.y = top_right.y = 0;
-+ top_right.x = bottom_right.x = desc.Width;
-+ bottom_right.y = bottom_left.y = desc.Height;
-+ }
-+
- // Transform the corners of our surface to pattern space.
- cairo_matrix_transform_point(&source_pattern->base.base.matrix, &top_left.x, &top_left.y);
- cairo_matrix_transform_point(&source_pattern->base.base.matrix, &top_right.x, &top_right.y);
- cairo_matrix_transform_point(&source_pattern->base.base.matrix, &bottom_left.x, &bottom_left.y);
-- cairo_matrix_transform_point(&source_pattern->base.base.matrix, &bottom_right.x, &top_left.y);
-+ cairo_matrix_transform_point(&source_pattern->base.base.matrix, &bottom_right.x, &bottom_right.y);
-
- cairo_point_double_t u;
- // Unit vector of the gradient direction.
- u = _cairo_d2d_subtract_point(p2, p1);
- _cairo_d2d_normalize_point(&u);
-
- // (corner - p1) . u = |corner - p1| cos(a) where a is the angle between the two vectors.
- // Coincidentally |corner - p1| cos(a) is actually also the distance our gradient needs to cover since
-@@ -1701,17 +1713,18 @@ static RefPtr<ID2D1Brush>
- * \param d2dsurf Surface to create a brush for
- * \param pattern The pattern to create a brush for
- * \param unique We cache the bitmap/color brush for speed. If this
- * needs a brush that is unique (i.e. when more than one is needed),
- * this will make the function return a seperate brush.
- * \return A brush object
- */
- static RefPtr<ID2D1Brush>
--_cairo_d2d_create_brush_for_pattern(cairo_d2d_surface_t *d2dsurf,
-+_cairo_d2d_create_brush_for_pattern(cairo_d2d_surface_t *d2dsurf,
-+ cairo_path_fixed_t *fill_path,
- const cairo_pattern_t *pattern,
- bool unique = false)
- {
- HRESULT hr;
-
- if (pattern->type == CAIRO_PATTERN_TYPE_SOLID) {
- cairo_solid_pattern_t *sourcePattern =
- (cairo_solid_pattern_t*)pattern;
-@@ -1729,17 +1742,17 @@ static RefPtr<ID2D1Brush>
- d2dsurf->solidColorBrush->SetColor(color);
- }
- return d2dsurf->solidColorBrush;
- }
-
- } else if (pattern->type == CAIRO_PATTERN_TYPE_LINEAR) {
- cairo_linear_pattern_t *source_pattern =
- (cairo_linear_pattern_t*)pattern;
-- return _cairo_d2d_create_linear_gradient_brush(d2dsurf, source_pattern);
-+ return _cairo_d2d_create_linear_gradient_brush(d2dsurf, fill_path, source_pattern);
- } else if (pattern->type == CAIRO_PATTERN_TYPE_RADIAL) {
- cairo_radial_pattern_t *source_pattern =
- (cairo_radial_pattern_t*)pattern;
- return _cairo_d2d_create_radial_gradient_brush(d2dsurf, source_pattern);
- } else if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE) {
- cairo_matrix_t mat = pattern->matrix;
- cairo_matrix_invert(&mat);
-
-@@ -3228,17 +3241,17 @@ static cairo_int_status_t
-
- if (unlikely(status))
- return status;
- }
- #endif
-
- target_rt->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
-
-- RefPtr<ID2D1Brush> brush = _cairo_d2d_create_brush_for_pattern(d2dsurf,
-+ RefPtr<ID2D1Brush> brush = _cairo_d2d_create_brush_for_pattern(d2dsurf, NULL,
- source);
-
- if (!brush) {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- D2D1_SIZE_F size = target_rt->GetSize();
- target_rt->FillRectangle(D2D1::RectF((FLOAT)0,
-@@ -3349,17 +3362,17 @@ static cairo_int_status_t
- source->filter,
- solidAlphaValue);
- if (rv != CAIRO_INT_STATUS_UNSUPPORTED) {
- return rv;
- }
- }
- }
-
-- RefPtr<ID2D1Brush> brush = _cairo_d2d_create_brush_for_pattern(d2dsurf, source);
-+ RefPtr<ID2D1Brush> brush = _cairo_d2d_create_brush_for_pattern(d2dsurf, NULL, source);
- if (!brush) {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- RefPtr<ID2D1RenderTarget> target_rt = d2dsurf->rt;
- #ifndef ALWAYS_MANUAL_COMPOSITE
- if (op != CAIRO_OPERATOR_OVER) {
- #endif
-@@ -3389,17 +3402,17 @@ static cairo_int_status_t
- brush->SetOpacity(1.0);
-
- if (target_rt.get() != d2dsurf->rt.get()) {
- return _cairo_d2d_blend_temp_surface(d2dsurf, op, target_rt, clip);
- }
- return CAIRO_INT_STATUS_SUCCESS;
- }
-
-- RefPtr<ID2D1Brush> opacityBrush = _cairo_d2d_create_brush_for_pattern(d2dsurf, mask, true);
-+ RefPtr<ID2D1Brush> opacityBrush = _cairo_d2d_create_brush_for_pattern(d2dsurf, NULL, mask, true);
- if (!opacityBrush) {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- if (!d2dsurf->maskLayer) {
- d2dsurf->rt->CreateLayer(&d2dsurf->maskLayer);
- }
- target_rt->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(),
-@@ -3475,17 +3488,17 @@ static cairo_int_status_t
- D2D1_FIGURE_BEGIN_FILLED);
-
- bool transformed = true;
-
- if (_cairo_matrix_is_identity(ctm)) {
- transformed = false;
- }
-
-- RefPtr<ID2D1Brush> brush = _cairo_d2d_create_brush_for_pattern(d2dsurf,
-+ RefPtr<ID2D1Brush> brush = _cairo_d2d_create_brush_for_pattern(d2dsurf, NULL,
- source);
- if (!brush) {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- D2D1::Matrix3x2F mat;
- if (transformed) {
- // If we are transformed we will draw the geometry multiplied by the
-@@ -3602,31 +3615,31 @@ static cairo_int_status_t
- }
-
- if (is_box) {
- float x1 = _cairo_fixed_to_float(box.p1.x);
- float y1 = _cairo_fixed_to_float(box.p1.y);
- float x2 = _cairo_fixed_to_float(box.p2.x);
- float y2 = _cairo_fixed_to_float(box.p2.y);
- RefPtr<ID2D1Brush> brush = _cairo_d2d_create_brush_for_pattern(d2dsurf,
-- source);
-+ path, source);
- if (!brush) {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- target_rt->FillRectangle(D2D1::RectF(x1,
- y1,
- x2,
- y2),
- brush);
- } else {
- RefPtr<ID2D1Geometry> d2dpath = _cairo_d2d_create_path_geometry_for_path(path, fill_rule, D2D1_FIGURE_BEGIN_FILLED);
-
- RefPtr<ID2D1Brush> brush = _cairo_d2d_create_brush_for_pattern(d2dsurf,
-- source);
-+ path, source);
- if (!brush) {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
- target_rt->FillGeometry(d2dpath, brush);
- }
-
- if (target_rt.get() != d2dsurf->rt.get()) {
- double x1, y1, x2, y2;
-@@ -4138,17 +4151,17 @@ static cairo_int_status_t
- DWRITE_TEXTURE_ALIASED_1x1 : DWRITE_TEXTURE_CLEARTYPE_3x1,
- &bounds);
- fontArea.x = bounds.left;
- fontArea.y = bounds.top;
- fontArea.width = bounds.right - bounds.left;
- fontArea.height = bounds.bottom - bounds.top;
- }
-
-- RefPtr<ID2D1Brush> brush = _cairo_d2d_create_brush_for_pattern(dst,
-+ RefPtr<ID2D1Brush> brush = _cairo_d2d_create_brush_for_pattern(dst, NULL,
- source);
-
- if (!brush) {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- if (transform) {
- D2D1::Matrix3x2F mat_inverse = _cairo_d2d_matrix_from_matrix(&dwritesf->mat_inverse);
diff --git a/gfx/cairo/d2d.patch b/gfx/cairo/d2d.patch
deleted file mode 100644
index b8dd155e7..000000000
--- a/gfx/cairo/d2d.patch
+++ /dev/null
@@ -1,465 +0,0 @@
-commit 4a412c0b144ed1fdde668e0e91241bac8bedd579
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Sun Jan 24 14:04:33 2010 -0500
-
- d2d
-
-diff --git a/src/cairo-fixed-private.h b/src/cairo-fixed-private.h
-index c299def..a37ca6a 100644
---- a/src/cairo-fixed-private.h
-+++ b/src/cairo-fixed-private.h
-@@ -50,6 +50,7 @@
-
- #define CAIRO_FIXED_ONE ((cairo_fixed_t)(1 << CAIRO_FIXED_FRAC_BITS))
- #define CAIRO_FIXED_ONE_DOUBLE ((double)(1 << CAIRO_FIXED_FRAC_BITS))
-+#define CAIRO_FIXED_ONE_FLOAT ((float)(1 << CAIRO_FIXED_FRAC_BITS))
- #define CAIRO_FIXED_EPSILON ((cairo_fixed_t)(1))
-
- #define CAIRO_FIXED_FRAC_MASK (((cairo_fixed_unsigned_t)(-1)) >> (CAIRO_FIXED_BITS - CAIRO_FIXED_FRAC_BITS))
-@@ -141,6 +142,12 @@ _cairo_fixed_to_double (cairo_fixed_t f)
- return ((double) f) / CAIRO_FIXED_ONE_DOUBLE;
- }
-
-+static inline float
-+_cairo_fixed_to_float (cairo_fixed_t f)
-+{
-+ return ((float) f) / CAIRO_FIXED_ONE_FLOAT;
-+}
-+
- static inline int
- _cairo_fixed_is_integer (cairo_fixed_t f)
- {
-diff --git a/src/cairo-win32-private.h b/src/cairo-win32-private.h
-index b9926bb..ba57595 100644
---- a/src/cairo-win32-private.h
-+++ b/src/cairo-win32-private.h
-@@ -231,4 +231,19 @@ inline BOOL ModifyWorldTransform(HDC hdc, CONST XFORM * lpxf, DWORD mode) { retu
-
- #endif
-
-+#ifdef CAIRO_HAS_DWRITE_FONT
-+CAIRO_BEGIN_DECLS
-+
-+cairo_public cairo_int_status_t
-+cairo_dwrite_show_glyphs_on_surface(void *surface,
-+ cairo_operator_t op,
-+ const cairo_pattern_t *source,
-+ cairo_glyph_t *glyphs,
-+ int num_glyphs,
-+ cairo_scaled_font_t *scaled_font,
-+ cairo_rectangle_int_t *extents);
-+
-+
-+CAIRO_END_DECLS
-+#endif /* CAIRO_HAS_DWRITE_FONT */
- #endif /* CAIRO_WIN32_PRIVATE_H */
-diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
-index 0dc5e76..bee00b1 100644
---- a/src/cairo-win32-surface.c
-+++ b/src/cairo-win32-surface.c
-@@ -1547,152 +1547,158 @@ _cairo_win32_surface_show_glyphs (void *surface,
- int *remaining_glyphs)
- {
- #if defined(CAIRO_HAS_WIN32_FONT) && !defined(WINCE)
-- cairo_win32_surface_t *dst = surface;
--
-- WORD glyph_buf_stack[STACK_GLYPH_SIZE];
-- WORD *glyph_buf = glyph_buf_stack;
-- int dxy_buf_stack[2 * STACK_GLYPH_SIZE];
-- int *dxy_buf = dxy_buf_stack;
--
-- BOOL win_result = 0;
-- int i, j;
-+ if (scaled_font->backend->type == CAIRO_FONT_TYPE_DWRITE) {
-+#ifdef CAIRO_HAS_DWRITE_FONT
-+ return cairo_dwrite_show_glyphs_on_surface(surface, op, source, glyphs, num_glyphs, scaled_font, clip);
-+#endif
-+ } else {
-+ cairo_win32_surface_t *dst = surface;
-+
-+ WORD glyph_buf_stack[STACK_GLYPH_SIZE];
-+ WORD *glyph_buf = glyph_buf_stack;
-+ int dxy_buf_stack[2 * STACK_GLYPH_SIZE];
-+ int *dxy_buf = dxy_buf_stack;
-
-- cairo_solid_pattern_t *solid_pattern;
-- COLORREF color;
-+ BOOL win_result = 0;
-+ int i, j;
-
-- cairo_matrix_t device_to_logical;
-+ cairo_solid_pattern_t *solid_pattern;
-+ COLORREF color;
-
-- int start_x, start_y;
-- double user_x, user_y;
-- int logical_x, logical_y;
-- unsigned int glyph_index_option;
-+ cairo_matrix_t device_to_logical;
-
-- /* We can only handle win32 fonts */
-- if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_WIN32)
-- return CAIRO_INT_STATUS_UNSUPPORTED;
-+ int start_x, start_y;
-+ double user_x, user_y;
-+ int logical_x, logical_y;
-+ unsigned int glyph_index_option;
-
-- /* We can only handle opaque solid color sources */
-- if (!_cairo_pattern_is_opaque_solid(source))
-- return CAIRO_INT_STATUS_UNSUPPORTED;
-+ /* We can only handle win32 fonts */
-+ if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_WIN32)
-+ return CAIRO_INT_STATUS_UNSUPPORTED;
-
-- /* We can only handle operator SOURCE or OVER with the destination
-- * having no alpha */
-- if ((op != CAIRO_OPERATOR_SOURCE && op != CAIRO_OPERATOR_OVER) ||
-- (dst->format != CAIRO_FORMAT_RGB24))
-- return CAIRO_INT_STATUS_UNSUPPORTED;
-+ /* We can only handle opaque solid color sources */
-+ if (!_cairo_pattern_is_opaque_solid(source))
-+ return CAIRO_INT_STATUS_UNSUPPORTED;
-
-- /* If we have a fallback mask clip set on the dst, we have
-- * to go through the fallback path, but only if we're not
-- * doing this for printing */
-- if (clip != NULL) {
-- if ((dst->flags & CAIRO_WIN32_SURFACE_FOR_PRINTING) == 0) {
-- cairo_region_t *clip_region;
-- cairo_status_t status;
-+ /* We can only handle operator SOURCE or OVER with the destination
-+ * having no alpha */
-+ if ((op != CAIRO_OPERATOR_SOURCE && op != CAIRO_OPERATOR_OVER) ||
-+ (dst->format != CAIRO_FORMAT_RGB24))
-+ return CAIRO_INT_STATUS_UNSUPPORTED;
-
-- status = _cairo_clip_get_region (clip, &clip_region);
-- assert (status != CAIRO_INT_STATUS_NOTHING_TO_DO);
-- if (status)
-- return status;
-+ /* If we have a fallback mask clip set on the dst, we have
-+ * to go through the fallback path, but only if we're not
-+ * doing this for printing */
-+ if (clip != NULL) {
-+ if ((dst->flags & CAIRO_WIN32_SURFACE_FOR_PRINTING) == 0) {
-+ cairo_region_t *clip_region;
-+ cairo_status_t status;
-+
-+ status = _cairo_clip_get_region (clip, &clip_region);
-+ assert (status != CAIRO_INT_STATUS_NOTHING_TO_DO);
-+ if (status)
-+ return status;
-
-- _cairo_win32_surface_set_clip_region (surface, clip_region);
-+ _cairo_win32_surface_set_clip_region (surface, clip_region);
-+ }
- }
-- }
-
-- solid_pattern = (cairo_solid_pattern_t *)source;
-- color = RGB(((int)solid_pattern->color.red_short) >> 8,
-- ((int)solid_pattern->color.green_short) >> 8,
-- ((int)solid_pattern->color.blue_short) >> 8);
-+ solid_pattern = (cairo_solid_pattern_t *)source;
-+ color = RGB(((int)solid_pattern->color.red_short) >> 8,
-+ ((int)solid_pattern->color.green_short) >> 8,
-+ ((int)solid_pattern->color.blue_short) >> 8);
-
-- cairo_win32_scaled_font_get_device_to_logical(scaled_font, &device_to_logical);
-+ cairo_win32_scaled_font_get_device_to_logical(scaled_font, &device_to_logical);
-
-- SaveDC(dst->dc);
-+ SaveDC(dst->dc);
-
-- cairo_win32_scaled_font_select_font(scaled_font, dst->dc);
-- SetTextColor(dst->dc, color);
-- SetTextAlign(dst->dc, TA_BASELINE | TA_LEFT);
-- SetBkMode(dst->dc, TRANSPARENT);
-+ cairo_win32_scaled_font_select_font(scaled_font, dst->dc);
-+ SetTextColor(dst->dc, color);
-+ SetTextAlign(dst->dc, TA_BASELINE | TA_LEFT);
-+ SetBkMode(dst->dc, TRANSPARENT);
-
-- if (num_glyphs > STACK_GLYPH_SIZE) {
-- glyph_buf = (WORD *) _cairo_malloc_ab (num_glyphs, sizeof(WORD));
-- dxy_buf = (int *) _cairo_malloc_abc (num_glyphs, sizeof(int), 2);
-- }
-+ if (num_glyphs > STACK_GLYPH_SIZE) {
-+ glyph_buf = (WORD *) _cairo_malloc_ab (num_glyphs, sizeof(WORD));
-+ dxy_buf = (int *) _cairo_malloc_abc (num_glyphs, sizeof(int), 2);
-+ }
-
-- /* It is vital that dx values for dxy_buf are calculated from the delta of
-- * _logical_ x coordinates (not user x coordinates) or else the sum of all
-- * previous dx values may start to diverge from the current glyph's x
-- * coordinate due to accumulated rounding error. As a result strings could
-- * be painted shorter or longer than expected. */
-+ /* It is vital that dx values for dxy_buf are calculated from the delta of
-+ * _logical_ x coordinates (not user x coordinates) or else the sum of all
-+ * previous dx values may start to diverge from the current glyph's x
-+ * coordinate due to accumulated rounding error. As a result strings could
-+ * be painted shorter or longer than expected. */
-
-- user_x = glyphs[0].x;
-- user_y = glyphs[0].y;
-+ user_x = glyphs[0].x;
-+ user_y = glyphs[0].y;
-
-- cairo_matrix_transform_point(&device_to_logical,
-- &user_x, &user_y);
-+ cairo_matrix_transform_point(&device_to_logical,
-+ &user_x, &user_y);
-
-- logical_x = _cairo_lround (user_x);
-- logical_y = _cairo_lround (user_y);
-+ logical_x = _cairo_lround (user_x);
-+ logical_y = _cairo_lround (user_y);
-
-- start_x = logical_x;
-- start_y = logical_y;
-+ start_x = logical_x;
-+ start_y = logical_y;
-
-- for (i = 0, j = 0; i < num_glyphs; ++i, j = 2 * i) {
-- glyph_buf[i] = (WORD) glyphs[i].index;
-- if (i == num_glyphs - 1) {
-- dxy_buf[j] = 0;
-- dxy_buf[j+1] = 0;
-- } else {
-- double next_user_x = glyphs[i+1].x;
-- double next_user_y = glyphs[i+1].y;
-- int next_logical_x, next_logical_y;
-+ for (i = 0, j = 0; i < num_glyphs; ++i, j = 2 * i) {
-+ glyph_buf[i] = (WORD) glyphs[i].index;
-+ if (i == num_glyphs - 1) {
-+ dxy_buf[j] = 0;
-+ dxy_buf[j+1] = 0;
-+ } else {
-+ double next_user_x = glyphs[i+1].x;
-+ double next_user_y = glyphs[i+1].y;
-+ int next_logical_x, next_logical_y;
-
-- cairo_matrix_transform_point(&device_to_logical,
-- &next_user_x, &next_user_y);
-+ cairo_matrix_transform_point(&device_to_logical,
-+ &next_user_x, &next_user_y);
-
-- next_logical_x = _cairo_lround (next_user_x);
-- next_logical_y = _cairo_lround (next_user_y);
-+ next_logical_x = _cairo_lround (next_user_x);
-+ next_logical_y = _cairo_lround (next_user_y);
-
-- dxy_buf[j] = _cairo_lround (next_logical_x - logical_x);
-- dxy_buf[j+1] = _cairo_lround (logical_y - next_logical_y);
-- /* note that GDI coordinate system is inverted */
-+ dxy_buf[j] = _cairo_lround (next_logical_x - logical_x);
-+ dxy_buf[j+1] = _cairo_lround (logical_y - next_logical_y);
-+ /* note that GDI coordinate system is inverted */
-
-- logical_x = next_logical_x;
-- logical_y = next_logical_y;
-- }
-- }
-+ logical_x = next_logical_x;
-+ logical_y = next_logical_y;
-+ }
-+ }
-
-- /* Using glyph indices for a Type 1 font does not work on a
-- * printer DC. The win32 printing surface will convert the the
-- * glyph indices of Type 1 fonts to the unicode values.
-- */
-- if ((dst->flags & CAIRO_WIN32_SURFACE_FOR_PRINTING) &&
-- _cairo_win32_scaled_font_is_type1 (scaled_font))
-- {
-- glyph_index_option = 0;
-- }
-- else
-- {
-- glyph_index_option = ETO_GLYPH_INDEX;
-- }
-+ /* Using glyph indices for a Type 1 font does not work on a
-+ * printer DC. The win32 printing surface will convert the the
-+ * glyph indices of Type 1 fonts to the unicode values.
-+ */
-+ if ((dst->flags & CAIRO_WIN32_SURFACE_FOR_PRINTING) &&
-+ _cairo_win32_scaled_font_is_type1 (scaled_font))
-+ {
-+ glyph_index_option = 0;
-+ }
-+ else
-+ {
-+ glyph_index_option = ETO_GLYPH_INDEX;
-+ }
-
-- win_result = ExtTextOutW(dst->dc,
-- start_x,
-- start_y,
-- glyph_index_option | ETO_PDY,
-- NULL,
-- glyph_buf,
-- num_glyphs,
-- dxy_buf);
-- if (!win_result) {
-- _cairo_win32_print_gdi_error("_cairo_win32_surface_show_glyphs(ExtTextOutW failed)");
-- }
-+ win_result = ExtTextOutW(dst->dc,
-+ start_x,
-+ start_y,
-+ glyph_index_option | ETO_PDY,
-+ NULL,
-+ glyph_buf,
-+ num_glyphs,
-+ dxy_buf);
-+ if (!win_result) {
-+ _cairo_win32_print_gdi_error("_cairo_win32_surface_show_glyphs(ExtTextOutW failed)");
-+ }
-
-- RestoreDC(dst->dc, -1);
-+ RestoreDC(dst->dc, -1);
-
-- if (glyph_buf != glyph_buf_stack) {
-- free(glyph_buf);
-- free(dxy_buf);
-+ if (glyph_buf != glyph_buf_stack) {
-+ free(glyph_buf);
-+ free(dxy_buf);
-+ }
-+ return (win_result) ? CAIRO_STATUS_SUCCESS : CAIRO_INT_STATUS_UNSUPPORTED;
- }
-- return (win_result) ? CAIRO_STATUS_SUCCESS : CAIRO_INT_STATUS_UNSUPPORTED;
- #else
- return CAIRO_INT_STATUS_UNSUPPORTED;
- #endif
-diff --git a/src/cairo-win32.h b/src/cairo-win32.h
-index 6b86d4e..fcf20b8 100644
---- a/src/cairo-win32.h
-+++ b/src/cairo-win32.h
-@@ -109,6 +109,63 @@ cairo_win32_scaled_font_get_device_to_logical (cairo_scaled_font_t *scaled_font,
-
- #endif /* CAIRO_HAS_WIN32_FONT */
-
-+#if CAIRO_HAS_DWRITE_FONT
-+
-+/*
-+ * Win32 DirectWrite font support
-+ */
-+cairo_public cairo_font_face_t *
-+cairo_dwrite_font_face_create_for_dwrite_fontface(void *dwrite_font, void *dwrite_font_face);
-+
-+#endif /* CAIRO_HAS_DWRITE_FONT */
-+
-+#if CAIRO_HAS_D2D_SURFACE
-+
-+/**
-+ * Create a D2D surface for an HWND
-+ *
-+ * \param wnd Handle for the window
-+ * \return New cairo surface
-+ */
-+cairo_public cairo_surface_t *
-+cairo_d2d_surface_create_for_hwnd(HWND wnd);
-+
-+/**
-+ * Create a D2D surface of a certain size.
-+ *
-+ * \param format Cairo format of the surface
-+ * \param width Width of the surface
-+ * \param height Height of the surface
-+ * \return New cairo surface
-+ */
-+cairo_public cairo_surface_t *
-+cairo_d2d_surface_create(cairo_format_t format,
-+ int width,
-+ int height);
-+
-+/**
-+ * Present the backbuffer for a surface create for an HWND. This needs
-+ * to be called when the owner of the original window surface wants to
-+ * actually present the executed drawing operations to the screen.
-+ *
-+ * \param surface D2D surface.
-+ */
-+void cairo_d2d_present_backbuffer(cairo_surface_t *surface);
-+
-+/**
-+ * Scroll the surface, this only moves the surface graphics, it does not
-+ * actually scroll child windows or anything like that. Nor does it invalidate
-+ * that area of the window.
-+ *
-+ * \param surface The d2d surface this operation should apply to.
-+ * \param x The x delta for the movement
-+ * \param y The y delta for the movement
-+ * \param clip The clip rectangle, the is the 'part' of the surface that needs
-+ * scrolling.
-+ */
-+void cairo_d2d_scroll(cairo_surface_t *surface, int x, int y, cairo_rectangle_t *clip);
-+#endif
-+
- CAIRO_END_DECLS
-
- #else /* CAIRO_HAS_WIN32_SURFACE */
-diff --git a/src/cairo.h b/src/cairo.h
-index 3a8b8a6..21827aa 100644
---- a/src/cairo.h
-+++ b/src/cairo.h
-@@ -1370,7 +1370,8 @@ typedef enum _cairo_font_type {
- CAIRO_FONT_TYPE_FT,
- CAIRO_FONT_TYPE_WIN32,
- CAIRO_FONT_TYPE_QUARTZ,
-- CAIRO_FONT_TYPE_USER
-+ CAIRO_FONT_TYPE_USER,
-+ CAIRO_FONT_TYPE_DWRITE
- } cairo_font_type_t;
-
- cairo_public cairo_font_type_t
-@@ -2009,7 +2010,7 @@ typedef enum _cairo_surface_type {
- CAIRO_SURFACE_TYPE_TEE,
- CAIRO_SURFACE_TYPE_XML,
- CAIRO_SURFACE_TYPE_SKIA,
-- CAIRO_SURFACE_TYPE_DDRAW
-+ CAIRO_SURFACE_TYPE_D2D
- } cairo_surface_type_t;
-
- cairo_public cairo_surface_type_t
-diff --git a/src/cairoint.h b/src/cairoint.h
-index b942b4b..58850ab 100644
---- a/src/cairoint.h
-+++ b/src/cairoint.h
-@@ -587,6 +587,12 @@ extern const cairo_private struct _cairo_font_face_backend _cairo_win32_font_fac
-
- #endif
-
-+#if CAIRO_HAS_DWRITE_FONT
-+
-+extern const cairo_private struct _cairo_font_face_backend _cairo_dwrite_font_face_backend;
-+
-+#endif
-+
- #if CAIRO_HAS_QUARTZ_FONT
-
- extern const cairo_private struct _cairo_font_face_backend _cairo_quartz_font_face_backend;
-@@ -932,7 +938,12 @@ typedef struct _cairo_traps {
- #define CAIRO_FT_FONT_FAMILY_DEFAULT ""
- #define CAIRO_USER_FONT_FAMILY_DEFAULT "@cairo:"
-
--#if CAIRO_HAS_WIN32_FONT
-+#if CAIRO_HAS_DWRITE_FONT
-+
-+#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_WIN32_FONT_FAMILY_DEFAULT
-+#define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_dwrite_font_face_backend
-+
-+#elif CAIRO_HAS_WIN32_FONT
-
- #define CAIRO_FONT_FAMILY_DEFAULT CAIRO_WIN32_FONT_FAMILY_DEFAULT
- #define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_win32_font_face_backend
-@@ -2617,7 +2628,7 @@ cairo_private int
- _cairo_ucs4_to_utf8 (uint32_t unicode,
- char *utf8);
-
--#if CAIRO_HAS_WIN32_FONT || CAIRO_HAS_QUARTZ_FONT || CAIRO_HAS_PDF_OPERATORS
-+#if CAIRO_HAS_WIN32_FONT || CAIRO_HAS_QUARTZ_FONT || CAIRO_HAS_PDF_OPERATORS || CAIRO_HAS_DW_FONT
- # define CAIRO_HAS_UTF8_TO_UTF16 1
- #endif
- #if CAIRO_HAS_UTF8_TO_UTF16
diff --git a/gfx/cairo/dasharray-zero-gap.patch b/gfx/cairo/dasharray-zero-gap.patch
deleted file mode 100644
index e26580ae1..000000000
--- a/gfx/cairo/dasharray-zero-gap.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -2573,29 +2573,43 @@ static cairo_int_status_t
-
- 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;
-
-- 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);
-+ 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);
diff --git a/gfx/cairo/disable-previous-scaled-font-cache.patch b/gfx/cairo/disable-previous-scaled-font-cache.patch
deleted file mode 100644
index afeac5ec8..000000000
--- a/gfx/cairo/disable-previous-scaled-font-cache.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo.c b/gfx/cairo/cairo/src/cairo.c
---- a/gfx/cairo/cairo/src/cairo.c
-+++ b/gfx/cairo/cairo/src/cairo.c
-@@ -3201,8 +3201,12 @@ cairo_set_scaled_font (cairo_t
-
- _cairo_gstate_set_font_options (cr->gstate, &scaled_font->options);
-
-+ /* XXX: Mozilla code assumes that the ctm of a scaled font doesn't need to
-+ * match the context ctm. This assumption breaks the previous_scaled_font
-+ * cache. So we avoid using the cache for now.
- if (was_previous)
- cr->gstate->scaled_font = cairo_scaled_font_reference ((cairo_scaled_font_t *) scaled_font);
-+ */
-
- return;
-
diff --git a/gfx/cairo/disable-printing.patch b/gfx/cairo/disable-printing.patch
deleted file mode 100644
index c1006d819..000000000
--- a/gfx/cairo/disable-printing.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
-@@ -1892,21 +1892,22 @@ cairo_win32_surface_get_dc (cairo_surfac
- return winsurf->dc;
- }
-
- if (_cairo_surface_is_paginated (surface)) {
- cairo_surface_t *target;
-
- target = _cairo_paginated_surface_get_target (surface);
-
-+#ifndef CAIRO_OMIT_WIN32_PRINTING
- if (_cairo_surface_is_win32_printing (target)) {
- winsurf = (cairo_win32_surface_t *) target;
--
- return winsurf->dc;
- }
-+#endif
- }
-
- return NULL;
- }
-
- /**
- * cairo_win32_surface_get_image
- * @surface: a #cairo_surface_t
diff --git a/gfx/cairo/disable-server-gradients.patch b/gfx/cairo/disable-server-gradients.patch
deleted file mode 100644
index 2d8fb5b6d..000000000
--- a/gfx/cairo/disable-server-gradients.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-commit 31579379422b75c3fe01b75d363e03f9b1e85604
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Fri Mar 12 16:07:59 2010 -0500
-
- xlib bugs
-
-diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
-index a7a40b8..566d9fb 100644
---- a/src/cairo-xlib-display.c
-+++ b/src/cairo-xlib-display.c
-@@ -407,6 +407,10 @@ _cairo_xlib_display_get (Display *dpy,
- display->buggy_pad_reflect = TRUE;
- }
-
-+ /* gradients don't seem to work */
-+ display->buggy_gradients = TRUE;
-+
-+
- /* XXX workaround; see https://bugzilla.mozilla.org/show_bug.cgi?id=413583 */
- /* If buggy_repeat_force == -1, then initialize.
- * - set to -2, meaning "nothing was specified", and we trust the above detection.
diff --git a/gfx/cairo/disable-subpixel-antialiasing.patch b/gfx/cairo/disable-subpixel-antialiasing.patch
deleted file mode 100644
index 7a0eb3a06..000000000
--- a/gfx/cairo/disable-subpixel-antialiasing.patch
+++ /dev/null
@@ -1,519 +0,0 @@
-# HG changeset patch
-# User Robert O'Callahan <robert@ocallahan.org>
-# Date 1294019288 -46800
-# Node ID 8857392e37aea7475ed6d8ee4b45023e1233bcec
-# Parent c53f60831c43cca397dfed8adf8d350aeec7d3ca
-Bug 363861. Part 2: Introduce cairo_surface_get/set_subpixel_antialiasing. r=jrmuizel,sr=vlad,a=blocking
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -2473,16 +2473,17 @@ _cairo_quartz_surface_show_glyphs (void
- cairo_int_status_t rv = CAIRO_STATUS_SUCCESS;
- cairo_quartz_drawing_state_t state;
- float 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)
-@@ -2514,16 +2515,22 @@ _cairo_quartz_surface_show_glyphs (void
- 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;
-diff --git a/gfx/cairo/cairo/src/cairo-surface-private.h b/gfx/cairo/cairo/src/cairo-surface-private.h
---- a/gfx/cairo/cairo/src/cairo-surface-private.h
-+++ b/gfx/cairo/cairo/src/cairo-surface-private.h
-@@ -58,16 +58,17 @@ struct _cairo_surface {
-
- cairo_reference_count_t ref_count;
- cairo_status_t status;
- unsigned int unique_id;
-
- unsigned finished : 1;
- unsigned is_clear : 1;
- unsigned has_font_options : 1;
-+ unsigned permit_subpixel_antialiasing : 1;
-
- cairo_user_data_array_t user_data;
- cairo_user_data_array_t mime_data;
-
- cairo_matrix_t device_transform;
- cairo_matrix_t device_transform_inverse;
-
- /* The actual resolution of the device, in dots per inch. */
-diff --git a/gfx/cairo/cairo/src/cairo-surface.c b/gfx/cairo/cairo/src/cairo-surface.c
---- a/gfx/cairo/cairo/src/cairo-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-surface.c
-@@ -49,17 +49,18 @@ const cairo_surface_t name = { \
- NULL, /* backend */ \
- CAIRO_SURFACE_TYPE_IMAGE, /* type */ \
- CAIRO_CONTENT_COLOR, /* content */ \
- CAIRO_REFERENCE_COUNT_INVALID, /* ref_count */ \
- status, /* status */ \
- 0, /* unique id */ \
- FALSE, /* finished */ \
- TRUE, /* is_clear */ \
-- FALSE, /* has_font_options */ \
-+ FALSE, /* has_font_options */ \
-+ FALSE, /* permit_subpixel_antialiasing */ \
- { 0, 0, 0, NULL, }, /* user_data */ \
- { 0, 0, 0, NULL, }, /* mime_data */ \
- { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }, /* device_transform */ \
- { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }, /* device_transform_inverse */ \
- 0.0, /* x_resolution */ \
- 0.0, /* y_resolution */ \
- 0.0, /* x_fallback_resolution */ \
- 0.0, /* y_fallback_resolution */ \
-@@ -342,46 +343,48 @@ _cairo_surface_init (cairo_surface_t *
- surface->content = content;
- surface->type = backend->type;
-
- CAIRO_REFERENCE_COUNT_INIT (&surface->ref_count, 1);
- surface->status = CAIRO_STATUS_SUCCESS;
- surface->unique_id = _cairo_surface_allocate_unique_id ();
- surface->finished = FALSE;
- surface->is_clear = FALSE;
-+ surface->has_font_options = FALSE;
-+ surface->permit_subpixel_antialiasing = TRUE;
-
- _cairo_user_data_array_init (&surface->user_data);
- _cairo_user_data_array_init (&surface->mime_data);
-
- cairo_matrix_init_identity (&surface->device_transform);
- cairo_matrix_init_identity (&surface->device_transform_inverse);
-
- surface->x_resolution = CAIRO_SURFACE_RESOLUTION_DEFAULT;
- surface->y_resolution = CAIRO_SURFACE_RESOLUTION_DEFAULT;
-
- surface->x_fallback_resolution = CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT;
- surface->y_fallback_resolution = CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT;
-
- _cairo_array_init (&surface->snapshots, sizeof (cairo_surface_t *));
- surface->snapshot_of = NULL;
--
-- surface->has_font_options = FALSE;
- }
-
- static void
- _cairo_surface_copy_similar_properties (cairo_surface_t *surface,
- cairo_surface_t *other)
- {
- if (other->has_font_options || other->backend != surface->backend) {
- cairo_font_options_t options;
-
- cairo_surface_get_font_options (other, &options);
- _cairo_surface_set_font_options (surface, &options);
- }
-
-+ surface->permit_subpixel_antialiasing = other->permit_subpixel_antialiasing;
-+
- cairo_surface_set_fallback_resolution (surface,
- other->x_fallback_resolution,
- other->y_fallback_resolution);
- }
-
- cairo_surface_t *
- _cairo_surface_create_similar_scratch (cairo_surface_t *other,
- cairo_content_t content,
-@@ -2482,16 +2485,67 @@ cairo_surface_has_show_text_glyphs (cair
-
- if (surface->backend->has_show_text_glyphs)
- return surface->backend->has_show_text_glyphs (surface);
- else
- return surface->backend->show_text_glyphs != NULL;
- }
- slim_hidden_def (cairo_surface_has_show_text_glyphs);
-
-+/**
-+ * cairo_surface_set_subpixel_antialiasing:
-+ * @surface: a #cairo_surface_t
-+ *
-+ * Sets whether the surface permits subpixel antialiasing. By default,
-+ * surfaces permit subpixel antialiasing.
-+ *
-+ * Enabling subpixel antialiasing for CONTENT_COLOR_ALPHA surfaces generally
-+ * requires that the pixels in the areas under a subpixel antialiasing
-+ * operation already be opaque.
-+ *
-+ * Since: 1.12
-+ **/
-+void
-+cairo_surface_set_subpixel_antialiasing (cairo_surface_t *surface,
-+ cairo_subpixel_antialiasing_t enabled)
-+{
-+ if (surface->status)
-+ return;
-+
-+ if (surface->finished) {
-+ _cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_FINISHED);
-+ return;
-+ }
-+
-+ surface->permit_subpixel_antialiasing =
-+ enabled == CAIRO_SUBPIXEL_ANTIALIASING_ENABLED;
-+}
-+slim_hidden_def (cairo_surface_set_subpixel_antialiasing);
-+
-+/**
-+ * cairo_surface_get_subpixel_antialiasing:
-+ * @surface: a #cairo_surface_t
-+ *
-+ * Gets whether the surface supports subpixel antialiasing. By default,
-+ * CAIRO_CONTENT_COLOR surfaces support subpixel antialiasing but other
-+ * surfaces do not.
-+ *
-+ * Since: 1.12
-+ **/
-+cairo_subpixel_antialiasing_t
-+cairo_surface_get_subpixel_antialiasing (cairo_surface_t *surface)
-+{
-+ if (surface->status)
-+ return CAIRO_SUBPIXEL_ANTIALIASING_DISABLED;
-+
-+ return surface->permit_subpixel_antialiasing ?
-+ CAIRO_SUBPIXEL_ANTIALIASING_ENABLED : CAIRO_SUBPIXEL_ANTIALIASING_DISABLED;
-+}
-+slim_hidden_def (cairo_surface_get_subpixel_antialiasing);
-+
- /* Note: the backends may modify the contents of the glyph array as long as
- * they do not return %CAIRO_INT_STATUS_UNSUPPORTED. This makes it possible to
- * avoid copying the array again and again, and edit it in-place.
- * Backends are in fact free to use the array as a generic buffer as they
- * see fit.
- *
- * For show_glyphs backend method, and NOT for show_text_glyphs method,
- * when they do return UNSUPPORTED, they may adjust remaining_glyphs to notify
-diff --git a/gfx/cairo/cairo/src/cairo-win32-font.c b/gfx/cairo/cairo/src/cairo-win32-font.c
---- a/gfx/cairo/cairo/src/cairo-win32-font.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-font.c
-@@ -1380,16 +1380,17 @@ _cairo_win32_scaled_font_show_glyphs (vo
- cairo_win32_surface_t *surface = (cairo_win32_surface_t *)generic_surface;
- cairo_status_t status;
-
- if (width == 0 || height == 0)
- return CAIRO_STATUS_SUCCESS;
-
- if (_cairo_surface_is_win32 (generic_surface) &&
- surface->format == CAIRO_FORMAT_RGB24 &&
-+ (generic_surface->permit_subpixel_antialiasing || scaled_font->quality != CLEARTYPE_QUALITY) &&
- op == CAIRO_OPERATOR_OVER &&
- _cairo_pattern_is_opaque_solid (pattern)) {
-
- cairo_solid_pattern_t *solid_pattern = (cairo_solid_pattern_t *)pattern;
-
- /* When compositing OVER on a GDI-understood surface, with a
- * solid opaque color, we can just call ExtTextOut directly.
- */
-@@ -1411,16 +1412,18 @@ _cairo_win32_scaled_font_show_glyphs (vo
- * surface by drawing the the glyphs onto a DIB, black-on-white then
- * inverting. GDI outputs gamma-corrected images so inverted black-on-white
- * is very different from white-on-black. We favor the more common
- * case where the final output is dark-on-light.
- */
- cairo_win32_surface_t *tmp_surface;
- cairo_surface_t *mask_surface;
- cairo_surface_pattern_t mask;
-+ cairo_bool_t use_subpixel_antialiasing =
-+ scaled_font->quality == CLEARTYPE_QUALITY && generic_surface->permit_subpixel_antialiasing;
- RECT r;
-
- tmp_surface = (cairo_win32_surface_t *)cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32, width, height);
- if (tmp_surface->base.status)
- return tmp_surface->base.status;
-
- r.left = 0;
- r.top = 0;
-@@ -1432,17 +1435,17 @@ _cairo_win32_scaled_font_show_glyphs (vo
- scaled_font, RGB (0, 0, 0),
- dest_x, dest_y,
- glyphs, num_glyphs);
- if (status) {
- cairo_surface_destroy (&tmp_surface->base);
- return status;
- }
-
-- if (scaled_font->quality == CLEARTYPE_QUALITY) {
-+ if (use_subpixel_antialiasing) {
- /* For ClearType, we need a 4-channel mask. If we are compositing on
- * a surface with alpha, we need to compute the alpha channel of
- * the mask (we just copy the green channel). But for a destination
- * surface without alpha the alpha channel of the mask is ignored
- */
-
- if (surface->format != CAIRO_FORMAT_RGB24)
- _compute_argb32_mask_alpha (tmp_surface);
-@@ -1460,17 +1463,17 @@ _cairo_win32_scaled_font_show_glyphs (vo
-
- /* For op == OVER, no-cleartype, a possible optimization here is to
- * draw onto an intermediate ARGB32 surface and alpha-blend that with the
- * destination
- */
- _cairo_pattern_init_for_surface (&mask, mask_surface);
- cairo_surface_destroy (mask_surface);
-
-- if (scaled_font->quality == CLEARTYPE_QUALITY)
-+ if (use_subpixel_antialiasing)
- mask.base.has_component_alpha = TRUE;
-
- status = _cairo_surface_composite (op, pattern,
- &mask.base,
- &surface->base,
- source_x, source_y,
- 0, 0,
- dest_x, dest_y,
-diff --git a/gfx/cairo/cairo/src/cairo-xlib-surface.c b/gfx/cairo/cairo/src/cairo-xlib-surface.c
---- a/gfx/cairo/cairo/src/cairo-xlib-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c
-@@ -3570,16 +3570,17 @@ typedef struct _cairo_xlib_font_glyphset
- GlyphSet glyphset;
- cairo_format_t format;
- XRenderPictFormat *xrender_format;
- cairo_xlib_font_glyphset_free_glyphs_t *pending_free_glyphs;
- } cairo_xlib_font_glyphset_info_t;
-
- typedef struct _cairo_xlib_surface_font_private {
- cairo_scaled_font_t *scaled_font;
-+ cairo_scaled_font_t *grayscale_font;
- cairo_xlib_hook_t close_display_hook;
- cairo_xlib_display_t *display;
- cairo_xlib_font_glyphset_info_t glyphset_info[NUM_GLYPHSETS];
- } cairo_xlib_surface_font_private_t;
-
- /* callback from CloseDisplay */
- static void
- _cairo_xlib_surface_remove_scaled_font (cairo_xlib_display_t *display,
-@@ -3599,16 +3600,20 @@ _cairo_xlib_surface_remove_scaled_font (
-
- _cairo_scaled_font_reset_cache (scaled_font);
- CAIRO_MUTEX_UNLOCK (scaled_font->mutex);
-
- if (font_private != NULL) {
- Display *dpy;
- int i;
-
-+ if (font_private->grayscale_font) {
-+ cairo_scaled_font_destroy (font_private->grayscale_font);
-+ }
-+
- dpy = _cairo_xlib_display_get_dpy (display);
- for (i = 0; i < NUM_GLYPHSETS; i++) {
- cairo_xlib_font_glyphset_info_t *glyphset_info;
-
- glyphset_info = &font_private->glyphset_info[i];
- if (glyphset_info->glyphset)
- XRenderFreeGlyphSet (dpy, glyphset_info->glyphset);
-
-@@ -3629,16 +3634,17 @@ _cairo_xlib_surface_font_init (Display
- cairo_status_t status;
- int i;
-
- font_private = malloc (sizeof (cairo_xlib_surface_font_private_t));
- if (unlikely (font_private == NULL))
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- font_private->scaled_font = scaled_font;
-+ font_private->grayscale_font = NULL;
- status = _cairo_xlib_display_get (dpy, &font_private->display);
- if (unlikely (status)) {
- free (font_private);
- return status;
- }
-
- /* initialize and hook into the CloseDisplay callback */
- font_private->close_display_hook.func =
-@@ -3671,16 +3677,20 @@ _cairo_xlib_surface_scaled_font_fini (ca
- {
- cairo_xlib_surface_font_private_t *font_private;
-
- font_private = scaled_font->surface_private;
- if (font_private != NULL) {
- cairo_xlib_display_t *display;
- int i;
-
-+ if (font_private->grayscale_font) {
-+ cairo_scaled_font_destroy (font_private->grayscale_font);
-+ }
-+
- display = font_private->display;
- _cairo_xlib_remove_close_display_hook (display,
- &font_private->close_display_hook);
-
- for (i = 0; i < NUM_GLYPHSETS; i++) {
- cairo_xlib_font_glyphset_info_t *glyphset_info;
-
- glyphset_info = &font_private->glyphset_info[i];
-@@ -4417,16 +4427,62 @@ _cairo_xlib_surface_owns_font (cairo_xli
- (font_private != NULL && font_private->display != dst->display))
- {
- return FALSE;
- }
-
- return TRUE;
- }
-
-+/* Gets a grayscale version of scaled_font. The grayscale version is cached
-+ * in our surface_private data.
-+ */
-+static cairo_scaled_font_t *
-+_cairo_xlib_get_grayscale_font (cairo_xlib_surface_t *dst,
-+ cairo_scaled_font_t *scaled_font)
-+{
-+ cairo_xlib_surface_font_private_t *font_private = scaled_font->surface_private;
-+ cairo_bool_t needs_font;
-+
-+ if (font_private == NULL) {
-+ cairo_status_t status = _cairo_xlib_surface_font_init (dst->dpy, scaled_font);
-+ if (unlikely (status))
-+ return _cairo_scaled_font_create_in_error (status);
-+ font_private = scaled_font->surface_private;
-+ }
-+
-+ CAIRO_MUTEX_LOCK (scaled_font->mutex);
-+ needs_font = !font_private->grayscale_font;
-+ CAIRO_MUTEX_UNLOCK (scaled_font->mutex);
-+
-+ if (needs_font) {
-+ cairo_font_options_t options;
-+ cairo_scaled_font_t *new_font;
-+
-+ options = scaled_font->options;
-+ options.antialias = CAIRO_ANTIALIAS_GRAY;
-+ new_font = cairo_scaled_font_create (scaled_font->font_face,
-+ &scaled_font->font_matrix,
-+ &scaled_font->ctm, &options);
-+
-+ CAIRO_MUTEX_LOCK (scaled_font->mutex);
-+ if (!font_private->grayscale_font) {
-+ font_private->grayscale_font = new_font;
-+ new_font = NULL;
-+ }
-+ CAIRO_MUTEX_UNLOCK (scaled_font->mutex);
-+
-+ if (new_font) {
-+ cairo_scaled_font_destroy (new_font);
-+ }
-+ }
-+
-+ return font_private->grayscale_font;
-+}
-+
- static cairo_int_status_t
- _cairo_xlib_surface_show_glyphs (void *abstract_dst,
- cairo_operator_t op,
- const cairo_pattern_t *src_pattern,
- cairo_glyph_t *glyphs,
- int num_glyphs,
- cairo_scaled_font_t *scaled_font,
- cairo_clip_t *clip,
-@@ -4475,16 +4531,21 @@ _cairo_xlib_surface_show_glyphs (void
-
- operation = _categorize_composite_operation (dst, op, src_pattern, TRUE);
- if (operation == DO_UNSUPPORTED)
- return UNSUPPORTED ("unsupported op");
-
- if (! _cairo_xlib_surface_owns_font (dst, scaled_font))
- return UNSUPPORTED ("unowned font");
-
-+ if (!dst->base.permit_subpixel_antialiasing &&
-+ scaled_font->options.antialias == CAIRO_ANTIALIAS_SUBPIXEL) {
-+ scaled_font = _cairo_xlib_get_grayscale_font (dst, scaled_font);
-+ }
-+
- X_DEBUG ((dst->dpy, "show_glyphs (dst=%x)", (unsigned int) dst->drawable));
-
- if (clip_region != NULL &&
- cairo_region_num_rectangles (clip_region) == 1)
- {
- cairo_rectangle_int_t glyph_extents;
- const cairo_rectangle_int_t *clip_extents;
-
-diff --git a/gfx/cairo/cairo/src/cairo.h b/gfx/cairo/cairo/src/cairo.h
---- a/gfx/cairo/cairo/src/cairo.h
-+++ b/gfx/cairo/cairo/src/cairo.h
-@@ -2101,16 +2101,35 @@ cairo_public void
- cairo_surface_copy_page (cairo_surface_t *surface);
-
- cairo_public void
- cairo_surface_show_page (cairo_surface_t *surface);
-
- cairo_public cairo_bool_t
- cairo_surface_has_show_text_glyphs (cairo_surface_t *surface);
-
-+/**
-+ * _cairo_subpixel_antialiasing_t:
-+ * @CAIRO_SUBPIXEL_ANTIALIASING_ENABLED: subpixel antialiasing is enabled
-+ * for this surface.
-+ * @CAIRO_SUBPIXEL_ANTIALIASING_DISABLED: subpixel antialiasing is disabled
-+ * for this surface.
-+ */
-+typedef enum _cairo_subpixel_antialiasing_t {
-+ CAIRO_SUBPIXEL_ANTIALIASING_ENABLED,
-+ CAIRO_SUBPIXEL_ANTIALIASING_DISABLED
-+} cairo_subpixel_antialiasing_t;
-+
-+cairo_public void
-+cairo_surface_set_subpixel_antialiasing (cairo_surface_t *surface,
-+ cairo_subpixel_antialiasing_t enabled);
-+
-+cairo_public cairo_subpixel_antialiasing_t
-+cairo_surface_get_subpixel_antialiasing (cairo_surface_t *surface);
-+
- /* Image-surface functions */
-
- /**
- * cairo_format_t:
- * @CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with
- * alpha in the upper 8 bits, then red, then green, then blue.
- * The 32-bit quantities are stored native-endian. Pre-multiplied
- * alpha is used. (That is, 50% transparent red is 0x80800000,
-diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
---- a/gfx/cairo/cairo/src/cairoint.h
-+++ b/gfx/cairo/cairo/src/cairoint.h
-@@ -2750,16 +2750,18 @@ slim_hidden_proto (cairo_surface_destroy
- slim_hidden_proto (cairo_surface_finish);
- slim_hidden_proto (cairo_surface_flush);
- slim_hidden_proto (cairo_surface_get_content);
- slim_hidden_proto (cairo_surface_get_device_offset);
- slim_hidden_proto (cairo_surface_get_font_options);
- slim_hidden_proto (cairo_surface_get_mime_data);
- slim_hidden_proto (cairo_surface_get_type);
- slim_hidden_proto (cairo_surface_has_show_text_glyphs);
-+slim_hidden_proto (cairo_surface_set_subpixel_antialiasing);
-+slim_hidden_proto (cairo_surface_get_subpixel_antialiasing);
- slim_hidden_proto (cairo_surface_mark_dirty_rectangle);
- slim_hidden_proto_no_warn (cairo_surface_reference);
- slim_hidden_proto (cairo_surface_set_device_offset);
- slim_hidden_proto (cairo_surface_set_fallback_resolution);
- slim_hidden_proto (cairo_surface_set_mime_data);
- slim_hidden_proto (cairo_surface_show_page);
- slim_hidden_proto (cairo_surface_status);
- slim_hidden_proto (cairo_text_cluster_allocate);
diff --git a/gfx/cairo/dwrite-font-match-robustness.patch b/gfx/cairo/dwrite-font-match-robustness.patch
deleted file mode 100644
index eadcce3bd..000000000
--- a/gfx/cairo/dwrite-font-match-robustness.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From: Robert O'Callahan <robert@ocallahan.org>
-Bug 717178. Part 1: Don't crash when passing a nil scaled-font to _name_tables_match. r=jfkthame
-
-diff --git a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
---- a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
-+++ b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
-@@ -1489,17 +1489,18 @@ static cairo_bool_t
- unsigned long size1;
- unsigned long size2;
- cairo_int_status_t status1;
- cairo_int_status_t status2;
- unsigned char *buffer1;
- unsigned char *buffer2;
- cairo_bool_t result = false;
-
-- if (!font1->backend->load_truetype_table ||
-+ if (!font1->backend || !font2->backend ||
-+ !font1->backend->load_truetype_table ||
- !font2->backend->load_truetype_table)
- return false;
-
- status1 = font1->backend->load_truetype_table (font1,
- TT_TAG_name, 0, NULL, &size1);
- status2 = font2->backend->load_truetype_table (font2,
- TT_TAG_name, 0, NULL, &size2);
- if (status1 || status2)
diff --git a/gfx/cairo/dwrite-font-printing.patch b/gfx/cairo/dwrite-font-printing.patch
deleted file mode 100644
index 837e19f6c..000000000
--- a/gfx/cairo/dwrite-font-printing.patch
+++ /dev/null
@@ -1,157 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
---- a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
-+++ b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
-@@ -37,16 +37,17 @@
- #include "cairoint.h"
-
- #include "cairo-win32-private.h"
- #include "cairo-surface-private.h"
- #include "cairo-clip-private.h"
-
- #include "cairo-d2d-private.h"
- #include "cairo-dwrite-private.h"
-+#include "cairo-truetype-subset-private.h"
- #include <float.h>
-
- typedef HRESULT (WINAPI*D2D1CreateFactoryFunc)(
- D2D1_FACTORY_TYPE factoryType,
- REFIID iid,
- CONST D2D1_FACTORY_OPTIONS *pFactoryOptions,
- void **factory
- );
-@@ -1036,17 +1037,17 @@ cairo_int_status_t
- {
- cairo_dwrite_scaled_font_t *dwritesf = static_cast<cairo_dwrite_scaled_font_t*>(scaled_font);
- cairo_dwrite_font_face_t *face = reinterpret_cast<cairo_dwrite_font_face_t*>(dwritesf->base.font_face);
-
- const void *data;
- UINT32 size;
- void *tableContext;
- BOOL exists;
-- face->dwriteface->TryGetFontTable(tag,
-+ face->dwriteface->TryGetFontTable(be32_to_cpu (tag),
- &data,
- &size,
- &tableContext,
- &exists);
-
- if (!exists) {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-@@ -1476,16 +1477,59 @@ DWriteFactory::CreateRenderingParams()
- Instance()->CreateCustomRenderingParams(gamma, contrast, clearTypeLevel,
- pixelGeometry, renderingMode,
- &mCustomClearTypeRenderingParams);
- Instance()->CreateCustomRenderingParams(gamma, contrast, clearTypeLevel,
- pixelGeometry, DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC,
- &mForceGDIClassicRenderingParams);
- }
-
-+static cairo_bool_t
-+_name_tables_match (cairo_scaled_font_t *font1,
-+ cairo_scaled_font_t *font2)
-+{
-+ unsigned long size1;
-+ unsigned long size2;
-+ cairo_int_status_t status1;
-+ cairo_int_status_t status2;
-+ unsigned char *buffer1;
-+ unsigned char *buffer2;
-+ cairo_bool_t result = false;
-+
-+ if (!font1->backend->load_truetype_table ||
-+ !font2->backend->load_truetype_table)
-+ return false;
-+
-+ status1 = font1->backend->load_truetype_table (font1,
-+ TT_TAG_name, 0, NULL, &size1);
-+ status2 = font2->backend->load_truetype_table (font2,
-+ TT_TAG_name, 0, NULL, &size2);
-+ if (status1 || status2)
-+ return false;
-+ if (size1 != size2)
-+ return false;
-+
-+ buffer1 = (unsigned char*)malloc (size1);
-+ buffer2 = (unsigned char*)malloc (size2);
-+
-+ if (buffer1 && buffer2) {
-+ status1 = font1->backend->load_truetype_table (font1,
-+ TT_TAG_name, 0, buffer1, &size1);
-+ status2 = font2->backend->load_truetype_table (font2,
-+ TT_TAG_name, 0, buffer2, &size2);
-+ if (!status1 && !status2) {
-+ result = memcmp (buffer1, buffer2, size1) == 0;
-+ }
-+ }
-+
-+ free (buffer1);
-+ free (buffer2);
-+ return result;
-+}
-+
- // Helper for _cairo_win32_printing_surface_show_glyphs to create a win32 equivalent
- // of a dwrite scaled_font so that we can print using ExtTextOut instead of drawing
- // paths or blitting glyph bitmaps.
- cairo_int_status_t
- _cairo_dwrite_scaled_font_create_win32_scaled_font (cairo_scaled_font_t *scaled_font,
- cairo_scaled_font_t **new_font)
- {
- if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_DWRITE) {
-@@ -1528,19 +1572,18 @@ cairo_int_status_t
- &ctm,
- &options);
- cairo_font_face_destroy (win32_face);
-
- if (!font) {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
-- if (_cairo_win32_scaled_font_is_type1 (font) || _cairo_win32_scaled_font_is_bitmap (font)) {
-- // If we somehow got a Type1 or bitmap font, it can't be the same physical font
-- // as directwrite was using, so glyph IDs will not match; best we can do is to
-- // throw it away and fall back on rendering paths or blitting bitmaps instead.
-+ if (!_name_tables_match (font, scaled_font)) {
-+ // If the font name tables aren't equal, then GDI may have failed to
-+ // find the right font and substituted a different font.
- cairo_scaled_font_destroy (font);
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- *new_font = font;
- return CAIRO_INT_STATUS_SUCCESS;
- }
-diff --git a/gfx/cairo/cairo/src/cairo-truetype-subset-private.h b/gfx/cairo/cairo/src/cairo-truetype-subset-private.h
---- a/gfx/cairo/cairo/src/cairo-truetype-subset-private.h
-+++ b/gfx/cairo/cairo/src/cairo-truetype-subset-private.h
-@@ -34,16 +34,18 @@
- * Adrian Johnson <ajohnson@redneon.com>
- */
-
- #ifndef CAIRO_TRUETYPE_SUBSET_PRIVATE_H
- #define CAIRO_TRUETYPE_SUBSET_PRIVATE_H
-
- #include "cairoint.h"
-
-+CAIRO_BEGIN_DECLS
-+
- #if CAIRO_HAS_FONT_SUBSET
-
- /* The structs defined here should strictly follow the TrueType
- * specification and not be padded. We use only 16-bit integer
- * in their definition to guarantee that. The fields of type
- * "FIXED" in the TT spec are broken into two *_1 and *_2 16-bit
- * parts, and 64-bit members are broken into four.
- *
-@@ -191,9 +193,11 @@ typedef struct _tt_composite_glyph {
- typedef struct _tt_glyph_data {
- int16_t num_contours;
- int8_t data[8];
- tt_composite_glyph_t glyph;
- } tt_glyph_data_t;
-
- #endif /* CAIRO_HAS_FONT_SUBSET */
-
-+CAIRO_END_DECLS
-+
- #endif /* CAIRO_TRUETYPE_SUBSET_PRIVATE_H */
diff --git a/gfx/cairo/dwrite-glyph-extents.patch b/gfx/cairo/dwrite-glyph-extents.patch
deleted file mode 100644
index d3625e198..000000000
--- a/gfx/cairo/dwrite-glyph-extents.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
---- a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
-+++ b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
-@@ -582,22 +582,37 @@ _cairo_dwrite_scaled_font_init_glyph_met
- DWRITE_FONT_METRICS fontMetrics;
- font_face->dwriteface->GetMetrics(&fontMetrics);
- HRESULT hr = font_face->dwriteface->GetDesignGlyphMetrics(&charIndex, 1, &metrics);
- if (FAILED(hr)) {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- // TODO: Treat swap_xy.
-- extents.width = (FLOAT)(metrics.advanceWidth - metrics.leftSideBearing - metrics.rightSideBearing) / fontMetrics.designUnitsPerEm;
-- extents.height = (FLOAT)(metrics.advanceHeight - metrics.topSideBearing - metrics.bottomSideBearing) / fontMetrics.designUnitsPerEm;
-+ extents.width = (FLOAT)(metrics.advanceWidth - metrics.leftSideBearing - metrics.rightSideBearing) /
-+ fontMetrics.designUnitsPerEm;
-+ extents.height = (FLOAT)(metrics.advanceHeight - metrics.topSideBearing - metrics.bottomSideBearing) /
-+ fontMetrics.designUnitsPerEm;
- extents.x_advance = (FLOAT)metrics.advanceWidth / fontMetrics.designUnitsPerEm;
- extents.x_bearing = (FLOAT)metrics.leftSideBearing / fontMetrics.designUnitsPerEm;
- extents.y_advance = 0.0;
-- extents.y_bearing = (FLOAT)(metrics.topSideBearing - metrics.verticalOriginY) / fontMetrics.designUnitsPerEm;
-+ extents.y_bearing = (FLOAT)(metrics.topSideBearing - metrics.verticalOriginY) /
-+ fontMetrics.designUnitsPerEm;
-+
-+ // We pad the extents here because GetDesignGlyphMetrics returns "ideal" metrics
-+ // for the glyph outline, without accounting for hinting/gridfitting/antialiasing,
-+ // and therefore it does not always cover all pixels that will actually be touched.
-+ if (scaled_font->base.options.antialias != CAIRO_ANTIALIAS_NONE &&
-+ extents.width > 0 && extents.height > 0) {
-+ extents.width += scaled_font->mat_inverse.xx * 2;
-+ extents.x_bearing -= scaled_font->mat_inverse.xx;
-+ extents.height += scaled_font->mat_inverse.yy * 2;
-+ extents.y_bearing -= scaled_font->mat_inverse.yy;
-+ }
-+
- _cairo_scaled_glyph_set_metrics (scaled_glyph,
- &scaled_font->base,
- &extents);
- return CAIRO_INT_STATUS_SUCCESS;
- }
-
- /**
- * Stack-based helper implementing IDWriteGeometrySink.
diff --git a/gfx/cairo/empty-clip-extents.patch b/gfx/cairo/empty-clip-extents.patch
deleted file mode 100644
index 306a61ad6..000000000
--- a/gfx/cairo/empty-clip-extents.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From b79ea8a6cab8bd28aebecf6e1e8229d5ac017264 Mon Sep 17 00:00:00 2001
-From: Karl Tomlinson <karlt+@karlt.net>
-Date: Fri, 16 Jul 2010 23:46:25 +0000
-Subject: clip: consider all_clipped in _cairo_clip_get_extents
-
-If the gstate clip in _cairo_gstate_int_clip_extents() has all_clipped
-set (and path NULL), then it returns the gstate target extents instead of
-an empty rectangle. If the target is infinite, then it says the clip is
-unbounded.
-
-Fixes https://bugs.freedesktop.org/show_bug.cgi?id=29124
-Tested-by test/get-clip
-
-Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
----
-diff --git a/src/cairo-clip.c b/src/cairo-clip.c
-index f6173c6..77d8214 100644
---- a/src/cairo-clip.c
-+++ b/src/cairo-clip.c
-@@ -1264,9 +1264,14 @@ _cairo_clip_combine_with_surface (cairo_clip_t *clip,
- return CAIRO_STATUS_SUCCESS;
- }
-
-+static const cairo_rectangle_int_t _cairo_empty_rectangle_int = { 0, 0, 0, 0 };
-+
- const cairo_rectangle_int_t *
- _cairo_clip_get_extents (const cairo_clip_t *clip)
- {
-+ if (clip->all_clipped)
-+ return &_cairo_empty_rectangle_int;
-+
- if (clip->path == NULL)
- return NULL;
-
-diff --git a/test/get-clip.c b/test/get-clip.c
-index 9d6e796..f0477a1 100644
---- a/test/get-clip.c
-+++ b/test/get-clip.c
-@@ -83,6 +83,8 @@ check_clip_extents (const cairo_test_context_t *ctx,
- cairo_clip_extents (cr, &ext_x1, &ext_y1, &ext_x2, &ext_y2);
- if (ext_x1 == x && ext_y1 == y && ext_x2 == x + width && ext_y2 == y + height)
- return 1;
-+ if (width == 0.0 && height == 0.0 && ext_x1 == ext_x2 && ext_y1 == ext_y2)
-+ return 1;
- cairo_test_log (ctx, "Error: %s; clip extents %f,%f,%f,%f should be %f,%f,%f,%f\n",
- message, ext_x1, ext_y1, ext_x2 - ext_x1, ext_y2 - ext_y1,
- x, y, width, height);
-@@ -138,7 +140,8 @@ preamble (cairo_test_context_t *ctx)
- cairo_save (cr);
- cairo_clip (cr);
- rectangle_list = cairo_copy_clip_rectangle_list (cr);
-- if (! check_count (ctx, phase, rectangle_list, 0))
-+ if (! check_count (ctx, phase, rectangle_list, 0) ||
-+ ! check_clip_extents (ctx, phase, cr, 0, 0, 0, 0))
- {
- goto FAIL;
- }
---
-cgit v0.8.3-6-g21f6
diff --git a/gfx/cairo/empty-clip-rectangles.patch b/gfx/cairo/empty-clip-rectangles.patch
deleted file mode 100644
index c9aa558a2..000000000
--- a/gfx/cairo/empty-clip-rectangles.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From f2fa15680ec3ac95cb68d4957557f06561a7dc55 Mon Sep 17 00:00:00 2001
-From: Karl Tomlinson <karlt+@karlt.net>
-Date: Fri, 16 Jul 2010 22:39:50 +0000
-Subject: clip: return empty clip from _cairo_clip_copy_rectangle_list when all_clipped
-
-Fixes https://bugs.freedesktop.org/show_bug.cgi?id=29122
-Tested by test/get-clip
-
-Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
----
-diff --git a/src/cairo-clip.c b/src/cairo-clip.c
-index 12dc04d..f6173c6 100644
---- a/src/cairo-clip.c
-+++ b/src/cairo-clip.c
-@@ -1499,7 +1499,10 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
- int n_rects = 0;
- int i;
-
-- if (clip != NULL && clip->path != NULL) {
-+ if (clip->all_clipped)
-+ goto DONE;
-+
-+ if (clip->path != NULL) {
- status = _cairo_clip_get_region (clip, &region);
- if (status == CAIRO_INT_STATUS_NOTHING_TO_DO) {
- goto DONE;
---
-cgit v0.8.3-6-g21f6
diff --git a/gfx/cairo/ensure-text-flushed.patch b/gfx/cairo/ensure-text-flushed.patch
deleted file mode 100644
index 5ec578fe5..000000000
--- a/gfx/cairo/ensure-text-flushed.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-pdf-operators.c b/gfx/cairo/cairo/src/cairo-pdf-operators.c
---- a/gfx/cairo/cairo/src/cairo-pdf-operators.c
-+++ b/gfx/cairo/cairo/src/cairo-pdf-operators.c
-@@ -480,6 +480,12 @@ _cairo_pdf_operators_clip (cairo_pdf_ope
- const char *pdf_operator;
- cairo_status_t status;
-
-+ if (pdf_operators->in_text_object) {
-+ status = _cairo_pdf_operators_end_text (pdf_operators);
-+ if (unlikely (status))
-+ return status;
-+ }
-+
- if (! path->has_current_point) {
- /* construct an empty path */
- _cairo_output_stream_printf (pdf_operators->stream, "0 0 m ");
diff --git a/gfx/cairo/expose-snapshot.patch b/gfx/cairo/expose-snapshot.patch
deleted file mode 100644
index 879b1fc90..000000000
--- a/gfx/cairo/expose-snapshot.patch
+++ /dev/null
@@ -1,528 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-analysis-surface-private.h b/gfx/cairo/cairo/src/cairo-analysis-surface-private.h
---- a/gfx/cairo/cairo/src/cairo-analysis-surface-private.h
-+++ b/gfx/cairo/cairo/src/cairo-analysis-surface-private.h
-@@ -65,14 +65,11 @@ _cairo_analysis_surface_has_unsupported
- cairo_private void
- _cairo_analysis_surface_get_bounding_box (cairo_surface_t *surface,
- cairo_box_t *bbox);
-
- cairo_private cairo_int_status_t
- _cairo_analysis_surface_merge_status (cairo_int_status_t status_a,
- cairo_int_status_t status_b);
-
--cairo_private cairo_surface_t *
--_cairo_null_surface_create (cairo_content_t content);
--
- CAIRO_END_DECLS
-
- #endif /* CAIRO_ANALYSIS_SURFACE_H */
-diff --git a/gfx/cairo/cairo/src/cairo-analysis-surface.c b/gfx/cairo/cairo/src/cairo-analysis-surface.c
---- a/gfx/cairo/cairo/src/cairo-analysis-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-analysis-surface.c
-@@ -902,17 +902,17 @@ static const cairo_surface_backend_t cai
- 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_null_surface_create (cairo_content_t content)
-+cairo_null_surface_create (cairo_content_t content)
- {
- cairo_surface_t *surface;
-
- surface = malloc (sizeof (cairo_surface_t));
- if (unlikely (surface == NULL)) {
- return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
- }
-
-diff --git a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
---- a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
-+++ b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
-@@ -1951,24 +1951,24 @@ _cairo_d2d_create_brush_for_pattern(cair
- rect = D2D1::RectU(1, 1, srcSurf->width + 1, srcSurf->height + 1);
- } else {
- rect = D2D1::RectU(0, 0, srcSurf->width, srcSurf->height);
- }
- sourceBitmap->CopyFromMemory(&rect,
- srcSurf->data,
- srcSurf->stride);
- cairo_surface_t *nullSurf =
-- _cairo_null_surface_create(CAIRO_CONTENT_COLOR_ALPHA);
-+ cairo_null_surface_create(CAIRO_CONTENT_COLOR_ALPHA);
- cachebitmap->refs++;
- cachebitmap->dirty = false;
- cairo_surface_set_user_data(nullSurf,
- &bitmap_key_snapshot,
- cachebitmap,
- NULL);
-- _cairo_surface_attach_snapshot(surfacePattern->surface,
-+ cairo_surface_attach_snapshot(surfacePattern->surface,
- nullSurf,
- _d2d_snapshot_detached);
- }
- } else {
- if (pattern->extend != CAIRO_EXTEND_NONE) {
- d2dsurf->rt->CreateBitmap(D2D1::SizeU(width, height),
- data + yoffset * stride + xoffset * Bpp,
- stride,
-@@ -2015,22 +2015,22 @@ _cairo_d2d_create_brush_for_pattern(cair
- * and one more in the user data structure.
- */
- cachebitmap->refs = 2;
- cairo_surface_set_user_data(surfacePattern->surface,
- key,
- cachebitmap,
- _d2d_release_bitmap);
- cairo_surface_t *nullSurf =
-- _cairo_null_surface_create(CAIRO_CONTENT_COLOR_ALPHA);
-+ cairo_null_surface_create(CAIRO_CONTENT_COLOR_ALPHA);
- cairo_surface_set_user_data(nullSurf,
- &bitmap_key_snapshot,
- cachebitmap,
- NULL);
-- _cairo_surface_attach_snapshot(surfacePattern->surface,
-+ cairo_surface_attach_snapshot(surfacePattern->surface,
- nullSurf,
- _d2d_snapshot_detached);
- cache_usage += _d2d_compute_bitmap_mem_size(sourceBitmap);
- }
- if (pix_image) {
- pixman_image_unref(pix_image);
- }
- }
-diff --git a/gfx/cairo/cairo/src/cairo-recording-surface.c b/gfx/cairo/cairo/src/cairo-recording-surface.c
---- a/gfx/cairo/cairo/src/cairo-recording-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-recording-surface.c
-@@ -276,17 +276,17 @@ _cairo_recording_surface_acquire_source_
- -surface->extents.y);
-
- status = _cairo_recording_surface_replay (&surface->base, image);
- if (unlikely (status)) {
- cairo_surface_destroy (image);
- return status;
- }
-
-- _cairo_surface_attach_snapshot (&surface->base, image, NULL);
-+ cairo_surface_attach_snapshot (&surface->base, image, NULL);
-
- *image_out = (cairo_image_surface_t *) image;
- *image_extra = NULL;
- return CAIRO_STATUS_SUCCESS;
- }
-
- static void
- _cairo_recording_surface_release_source_image (void *abstract_surface,
-@@ -1046,17 +1046,17 @@ static cairo_status_t
- _recording_surface_get_ink_bbox (cairo_recording_surface_t *surface,
- cairo_box_t *bbox,
- const cairo_matrix_t *transform)
- {
- cairo_surface_t *null_surface;
- cairo_surface_t *analysis_surface;
- cairo_status_t status;
-
-- null_surface = _cairo_null_surface_create (surface->content);
-+ null_surface = cairo_null_surface_create (surface->content);
- analysis_surface = _cairo_analysis_surface_create (null_surface);
- cairo_surface_destroy (null_surface);
-
- status = analysis_surface->status;
- if (unlikely (status))
- return status;
-
- if (transform != NULL)
-diff --git a/gfx/cairo/cairo/src/cairo-surface-private.h b/gfx/cairo/cairo/src/cairo-surface-private.h
---- a/gfx/cairo/cairo/src/cairo-surface-private.h
-+++ b/gfx/cairo/cairo/src/cairo-surface-private.h
-@@ -40,18 +40,16 @@
-
- #include "cairo.h"
-
- #include "cairo-types-private.h"
- #include "cairo-list-private.h"
- #include "cairo-reference-count-private.h"
- #include "cairo-clip-private.h"
-
--typedef void (*cairo_surface_func_t) (cairo_surface_t *);
--
- struct _cairo_surface {
- const cairo_surface_backend_t *backend;
- cairo_device_t *device;
-
- /* We allow surfaces to override the backend->type by shoving something
- * else into surface->type. This is for "wrapper" surfaces that want to
- * hide their internal type from the user-level API. */
- cairo_surface_type_t type;
-diff --git a/gfx/cairo/cairo/src/cairo-surface-snapshot.c b/gfx/cairo/cairo/src/cairo-surface-snapshot.c
---- a/gfx/cairo/cairo/src/cairo-surface-snapshot.c
-+++ b/gfx/cairo/cairo/src/cairo-surface-snapshot.c
-@@ -209,17 +209,17 @@ _cairo_surface_snapshot (cairo_surface_t
- if (unlikely (status)) {
- cairo_surface_destroy (snap);
- return _cairo_surface_create_in_error (status);
- }
-
- snap->device_transform = surface->device_transform;
- snap->device_transform_inverse = surface->device_transform_inverse;
-
-- _cairo_surface_attach_snapshot (surface, snap, NULL);
-+ cairo_surface_attach_snapshot (surface, snap, NULL);
-
- return snap;
- }
- }
-
- snapshot = (cairo_surface_snapshot_t *)
- _cairo_surface_has_snapshot (surface, &_cairo_surface_snapshot_backend);
- if (snapshot != NULL)
-@@ -242,14 +242,14 @@ _cairo_surface_snapshot (cairo_surface_t
- if (unlikely (status)) {
- cairo_surface_destroy (&snapshot->base);
- return _cairo_surface_create_in_error (status);
- }
-
- snapshot->base.device_transform = surface->device_transform;
- snapshot->base.device_transform_inverse = surface->device_transform_inverse;
-
-- _cairo_surface_attach_snapshot (surface,
-+ cairo_surface_attach_snapshot (surface,
- &snapshot->base,
- _cairo_surface_snapshot_copy_on_write);
-
- return &snapshot->base;
- }
-diff --git a/gfx/cairo/cairo/src/cairo-surface-subsurface.c b/gfx/cairo/cairo/src/cairo-surface-subsurface.c
---- a/gfx/cairo/cairo/src/cairo-surface-subsurface.c
-+++ b/gfx/cairo/cairo/src/cairo-surface-subsurface.c
-@@ -326,17 +326,17 @@ _cairo_surface_subsurface_acquire_source
- _cairo_image_surface_create_with_content (meta->content,
- surface->extents.width,
- surface->extents.height);
- if (unlikely (image->base.status))
- return image->base.status;
-
- cairo_surface_paint_to_target (&image->base, surface);
-
-- _cairo_surface_attach_snapshot (&surface->base, &image->base, NULL);
-+ cairo_surface_attach_snapshot (&surface->base, &image->base, NULL);
-
- *image_out = image;
- *extra_out = NULL;
- return CAIRO_STATUS_SUCCESS;
- }
- }
-
- extra = malloc (sizeof (struct extra));
-diff --git a/gfx/cairo/cairo/src/cairo-surface.c b/gfx/cairo/cairo/src/cairo-surface.c
---- a/gfx/cairo/cairo/src/cairo-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-surface.c
-@@ -305,51 +305,51 @@ _cairo_surface_detach_mime_data (cairo_s
- if (! _cairo_surface_has_mime_data (surface))
- return;
-
- _cairo_user_data_array_fini (&surface->mime_data);
- _cairo_user_data_array_init (&surface->mime_data);
- }
-
- static void
--_cairo_surface_detach_snapshots (cairo_surface_t *surface)
-+cairo_surface_detach_snapshots (cairo_surface_t *surface)
- {
- while (_cairo_surface_has_snapshots (surface)) {
-- _cairo_surface_detach_snapshot (cairo_list_first_entry (&surface->snapshots,
-+ cairo_surface_detach_snapshot (cairo_list_first_entry (&surface->snapshots,
- cairo_surface_t,
- snapshot));
- }
- }
-
- void
--_cairo_surface_detach_snapshot (cairo_surface_t *snapshot)
-+cairo_surface_detach_snapshot (cairo_surface_t *snapshot)
- {
- assert (snapshot->snapshot_of != NULL);
-
- snapshot->snapshot_of = NULL;
- cairo_list_del (&snapshot->snapshot);
-
- if (snapshot->snapshot_detach != NULL)
- snapshot->snapshot_detach (snapshot);
-
- cairo_surface_destroy (snapshot);
- }
-
- void
--_cairo_surface_attach_snapshot (cairo_surface_t *surface,
-+cairo_surface_attach_snapshot (cairo_surface_t *surface,
- cairo_surface_t *snapshot,
- cairo_surface_func_t detach_func)
- {
- assert (surface != snapshot);
- assert (snapshot->snapshot_of != surface);
-
- cairo_surface_reference (snapshot);
-
- if (snapshot->snapshot_of != NULL)
-- _cairo_surface_detach_snapshot (snapshot);
-+ cairo_surface_detach_snapshot (snapshot);
-
- snapshot->snapshot_of = surface;
- snapshot->snapshot_detach = detach_func;
-
- cairo_list_add (&snapshot->snapshot, &surface->snapshots);
-
- assert (_cairo_surface_has_snapshot (surface, snapshot->backend) == snapshot);
- }
-@@ -382,17 +382,17 @@ _cairo_surface_is_writable (cairo_surfac
-
- static void
- _cairo_surface_begin_modification (cairo_surface_t *surface)
- {
- assert (surface->status == CAIRO_STATUS_SUCCESS);
- assert (! surface->finished);
- assert (surface->snapshot_of == NULL);
-
-- _cairo_surface_detach_snapshots (surface);
-+ cairo_surface_detach_snapshots (surface);
- _cairo_surface_detach_mime_data (surface);
- }
-
- void
- _cairo_surface_init (cairo_surface_t *surface,
- const cairo_surface_backend_t *backend,
- cairo_device_t *device,
- cairo_content_t content)
-@@ -711,19 +711,19 @@ cairo_surface_finish (cairo_surface_t *s
-
- if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count))
- return;
-
- if (surface->finished)
- return;
-
- /* update the snapshots *before* we declare the surface as finished */
-- _cairo_surface_detach_snapshots (surface);
-+ cairo_surface_detach_snapshots (surface);
- if (surface->snapshot_of != NULL)
-- _cairo_surface_detach_snapshot (surface);
-+ cairo_surface_detach_snapshot (surface);
-
- cairo_surface_flush (surface);
- surface->finished = TRUE;
-
- /* call finish even if in error mode */
- if (surface->backend->finish) {
- status = surface->backend->finish (surface);
- if (unlikely (status))
-@@ -1106,17 +1106,17 @@ cairo_surface_flush (cairo_surface_t *su
-
- if (surface->status)
- return;
-
- if (surface->finished)
- return;
-
- /* update the current snapshots *before* the user updates the surface */
-- _cairo_surface_detach_snapshots (surface);
-+ cairo_surface_detach_snapshots (surface);
-
- if (surface->backend->flush) {
- status = surface->backend->flush (surface);
- if (unlikely (status))
- status = _cairo_surface_set_error (surface, status);
- }
- }
- slim_hidden_def (cairo_surface_flush);
-@@ -1628,17 +1628,17 @@ _cairo_recording_surface_clone_similar (
- return similar->status;
-
- status = _cairo_recording_surface_replay (src, similar);
- if (unlikely (status)) {
- cairo_surface_destroy (similar);
- return status;
- }
-
-- _cairo_surface_attach_snapshot (src, similar, NULL);
-+ cairo_surface_attach_snapshot (src, similar, NULL);
-
- src_x = src_y = 0;
- }
-
- *clone_out = similar;
- *clone_offset_x = src_x;
- *clone_offset_y = src_y;
- return CAIRO_STATUS_SUCCESS;
-diff --git a/gfx/cairo/cairo/src/cairo-vg-surface.c b/gfx/cairo/cairo/src/cairo-vg-surface.c
---- a/gfx/cairo/cairo/src/cairo-vg-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-vg-surface.c
-@@ -977,17 +977,17 @@ _vg_setup_surface_source (cairo_vg_conte
- status = _cairo_cache_insert (&context->snapshot_cache,
- &clone->snapshot_cache_entry);
- if (unlikely (status)) {
- clone->snapshot_cache_entry.hash = 0;
- cairo_surface_destroy (&clone->base);
- return status;
- }
-
-- _cairo_surface_attach_snapshot (spat->surface, &clone->base,
-+ cairo_surface_attach_snapshot (spat->surface, &clone->base,
- _vg_surface_remove_from_cache);
-
- DONE:
- cairo_surface_destroy (&context->source->base);
- context->source = clone;
-
- vgSetParameteri (context->paint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
-
-diff --git a/gfx/cairo/cairo/src/cairo-xcb-surface.c b/gfx/cairo/cairo/src/cairo-xcb-surface.c
---- a/gfx/cairo/cairo/src/cairo-xcb-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-xcb-surface.c
-@@ -560,17 +560,17 @@ _cairo_xcb_surface_acquire_source_image
- image = (cairo_image_surface_t *) cairo_surface_reference (&image->base);
- goto DONE;
- }
-
- status = _get_image (surface, FALSE, &image);
- if (unlikely (status))
- return status;
-
-- _cairo_surface_attach_snapshot (&surface->base, &image->base, NULL);
-+ cairo_surface_attach_snapshot (&surface->base, &image->base, NULL);
-
- DONE:
- *image_out = image;
- *image_extra = NULL;
- return CAIRO_STATUS_SUCCESS;
- }
-
- static void
-@@ -713,17 +713,17 @@ _cairo_xcb_surface_flush (void *abstract
- status = cairo_surface_status (surface->fallback);
-
- if (status == CAIRO_STATUS_SUCCESS) {
- status = _put_image (surface,
- (cairo_image_surface_t *) surface->fallback);
- }
-
- if (status == CAIRO_STATUS_SUCCESS) {
-- _cairo_surface_attach_snapshot (&surface->base,
-+ cairo_surface_attach_snapshot (&surface->base,
- surface->fallback,
- cairo_surface_finish);
- }
- }
-
- cairo_surface_destroy (surface->fallback);
- surface->fallback = NULL;
-
-diff --git a/gfx/cairo/cairo/src/cairo.h b/gfx/cairo/cairo/src/cairo.h
---- a/gfx/cairo/cairo/src/cairo.h
-+++ b/gfx/cairo/cairo/src/cairo.h
-@@ -214,16 +214,25 @@ typedef struct _cairo_pattern cairo_patt
- *
- * #cairo_destroy_func_t the type of function which is called when a
- * data element is destroyed. It is passed the pointer to the data
- * element and should free any memory and resources allocated for it.
- **/
- typedef void (*cairo_destroy_func_t) (void *data);
-
- /**
-+ * cairo_surface_func_t:
-+ * @surface: The surface being referred to.
-+ *
-+ * #cairo_surface_func_t the type of function which is used for callback
-+ * when a surface needs to be apssed as a parameter.
-+ */
-+typedef void (*cairo_surface_func_t) (cairo_surface_t *surface);
-+
-+/**
- * cairo_user_data_key_t:
- * @unused: not used; ignore.
- *
- * #cairo_user_data_key_t is used for attaching user data to cairo
- * data structures. The actual contents of the struct is never used,
- * and there is no need to initialize the object; only the unique
- * address of a #cairo_data_key_t object is used. Typically, you
- * would just use the address of a static #cairo_data_key_t object.
-@@ -2150,16 +2159,24 @@ cairo_surface_get_user_data (cairo_surfa
- const cairo_user_data_key_t *key);
-
- cairo_public cairo_status_t
- cairo_surface_set_user_data (cairo_surface_t *surface,
- const cairo_user_data_key_t *key,
- void *user_data,
- cairo_destroy_func_t destroy);
-
-+cairo_public void
-+cairo_surface_attach_snapshot (cairo_surface_t *surface,
-+ cairo_surface_t *snapshot,
-+ cairo_surface_func_t detach_func);
-+
-+cairo_public void
-+cairo_surface_detach_snapshot (cairo_surface_t *snapshot);
-+
- #define CAIRO_MIME_TYPE_JPEG "image/jpeg"
- #define CAIRO_MIME_TYPE_PNG "image/png"
- #define CAIRO_MIME_TYPE_JP2 "image/jp2"
- #define CAIRO_MIME_TYPE_URI "text/x-uri"
-
- cairo_public void
- cairo_surface_get_mime_data (cairo_surface_t *surface,
- const char *mime_type,
-@@ -2328,16 +2345,21 @@ cairo_recording_surface_create (cairo_co
-
- cairo_public void
- cairo_recording_surface_ink_extents (cairo_surface_t *surface,
- double *x0,
- double *y0,
- double *width,
- double *height);
-
-+/* Null-surface functions */
-+
-+cairo_public cairo_surface_t *
-+cairo_null_surface_create (cairo_content_t content);
-+
- /* Pattern creation functions */
-
- cairo_public cairo_pattern_t *
- cairo_pattern_create_rgb (double red, double green, double blue);
-
- cairo_public cairo_pattern_t *
- cairo_pattern_create_rgba (double red, double green, double blue,
- double alpha);
-diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
---- a/gfx/cairo/cairo/src/cairoint.h
-+++ b/gfx/cairo/cairo/src/cairoint.h
-@@ -1770,27 +1770,19 @@ _cairo_surface_clone_similar (cairo_surf
- int height,
- int *clone_offset_x,
- int *clone_offset_y,
- cairo_surface_t **clone_out);
-
- cairo_private cairo_surface_t *
- _cairo_surface_snapshot (cairo_surface_t *surface);
-
--cairo_private void
--_cairo_surface_attach_snapshot (cairo_surface_t *surface,
-- cairo_surface_t *snapshot,
-- cairo_surface_func_t detach_func);
--
- cairo_private cairo_surface_t *
- _cairo_surface_has_snapshot (cairo_surface_t *surface,
-- const cairo_surface_backend_t *backend);
--
--cairo_private void
--_cairo_surface_detach_snapshot (cairo_surface_t *snapshot);
-+ const cairo_surface_backend_t *backend);
-
- cairo_private cairo_bool_t
- _cairo_surface_is_similar (cairo_surface_t *surface_a,
- cairo_surface_t *surface_b);
-
- cairo_private cairo_bool_t
- _cairo_surface_get_extents (cairo_surface_t *surface,
- cairo_rectangle_int_t *extents);
diff --git a/gfx/cairo/fix-build-with-Werror=return-type.patch b/gfx/cairo/fix-build-with-Werror=return-type.patch
deleted file mode 100644
index 7cd77a597..000000000
--- a/gfx/cairo/fix-build-with-Werror=return-type.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -436,16 +436,17 @@ _cairo_quartz_cairo_operator_to_quartz_c
- 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));
-
diff --git a/gfx/cairo/fix-cairo-surface-wrapper-flush-build-warning.patch b/gfx/cairo/fix-cairo-surface-wrapper-flush-build-warning.patch
deleted file mode 100644
index 0e7c0b973..000000000
--- a/gfx/cairo/fix-cairo-surface-wrapper-flush-build-warning.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-# HG changeset patch
-# Parent 5479a346b95b82162c72419a95cbb4022cbbfe4d
-# User Ed Morley <bmo@edmorley.co.uk>
-Bug 631155 - undefined return value in function '_cairo_surface_wrapper_flush'; r=jrmuizel
-
-diff --git a/gfx/cairo/cairo/src/cairo-surface-wrapper.c b/gfx/cairo/cairo/src/cairo-surface-wrapper.c
---- a/gfx/cairo/cairo/src/cairo-surface-wrapper.c
-+++ b/gfx/cairo/cairo/src/cairo-surface-wrapper.c
-@@ -712,9 +712,10 @@ _cairo_surface_wrapper_fini (cairo_surfa
- }
-
- cairo_status_t
- _cairo_surface_wrapper_flush (cairo_surface_wrapper_t *wrapper)
- {
- if (wrapper->target->backend->flush) {
- return wrapper->target->backend->flush(wrapper->target);
- }
-+ return CAIRO_STATUS_SUCCESS;
- }
diff --git a/gfx/cairo/fix-cairo-win32-print-gdi-error.diff b/gfx/cairo/fix-cairo-win32-print-gdi-error.diff
deleted file mode 100644
index 9387a87af..000000000
--- a/gfx/cairo/fix-cairo-win32-print-gdi-error.diff
+++ /dev/null
@@ -1,26 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
-@@ -95,20 +95,21 @@ _cairo_win32_print_gdi_error (const char
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- last_error,
- MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPSTR) &lpMsgBuf,
- 0, NULL)) {
- fprintf (stderr, "%s: Unknown GDI error", context);
- } else {
-- fwprintf (stderr, "%S: %s", context, (char *)lpMsgBuf);
-+ fprintf (stderr, "%s: %S", context, (char *)lpMsgBuf);
-
- LocalFree (lpMsgBuf);
- }
-+ fflush(stderr);
-
- /* We should switch off of last_status, but we'd either return
- * CAIRO_STATUS_NO_MEMORY or CAIRO_STATUS_UNKNOWN_ERROR and there
- * is no CAIRO_STATUS_UNKNOWN_ERROR.
- */
-
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- }
diff --git a/gfx/cairo/fix-clip-copy.patch b/gfx/cairo/fix-clip-copy.patch
deleted file mode 100644
index c2c3b2fc8..000000000
--- a/gfx/cairo/fix-clip-copy.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-commit f49a9740350d2f0d69ed59e913f0263a899cfb2a
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Fri Jan 29 14:39:24 2010 -0500
-
- Fix clip copy
-
-diff --git a/src/cairo-clip.c b/src/cairo-clip.c
-index 8d66a5f..6acbcff 100644
---- a/src/cairo-clip.c
-+++ b/src/cairo-clip.c
-@@ -280,13 +280,12 @@ cairo_clip_t *
- _cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other)
- {
- if (other != NULL) {
-- if (other->path == NULL) {
-- _cairo_clip_init (clip);
-- clip = NULL;
-- } else {
-- clip->all_clipped = other->all_clipped;
-- clip->path = _cairo_clip_path_reference (other->path);
-- }
-+ clip->all_clipped = other->all_clipped;
-+ clip->path = _cairo_clip_path_reference (other->path);
-+
-+ /* this guy is here because of the weird return semantics of _cairo_clip_init_copy */
-+ if (!other->path)
-+ return NULL;
- } else {
- _cairo_clip_init (clip);
- }
diff --git a/gfx/cairo/fix-clip-region-simplification.patch b/gfx/cairo/fix-clip-region-simplification.patch
deleted file mode 100644
index 825130a2e..000000000
--- a/gfx/cairo/fix-clip-region-simplification.patch
+++ /dev/null
@@ -1 +0,0 @@
-stg show: fix-clip-region-simplication: Unknown patch or revision name
diff --git a/gfx/cairo/fix-clip-test.patch b/gfx/cairo/fix-clip-test.patch
deleted file mode 100644
index 9987b48bf..000000000
--- a/gfx/cairo/fix-clip-test.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-Fix a clip test to test the right coordinate.
-
-Fixed upstream by 498c10032ea3f8631a928cd7df96766f2c8ddca4
-diff --git a/gfx/cairo/cairo/src/cairo-clip.c b/gfx/cairo/cairo/src/cairo-clip.c
---- a/gfx/cairo/cairo/src/cairo-clip.c
-+++ b/gfx/cairo/cairo/src/cairo-clip.c
-@@ -408,7 +408,7 @@ _cairo_clip_rectangle (cairo_clip_t
- /* if a smaller clip has already been set, ignore the new path */
- if (clip->path != NULL) {
- if (rectangle->x <= clip->path->extents.x &&
-- rectangle->y <= clip->path->extents.x &&
-+ rectangle->y <= clip->path->extents.y &&
- rectangle->x + rectangle->width >= clip->path->extents.x + clip->path->extents.width &&
- rectangle->y + rectangle->height >= clip->path->extents.y + clip->path->extents.height)
- {
diff --git a/gfx/cairo/fix-ps-output.patch b/gfx/cairo/fix-ps-output.patch
deleted file mode 100644
index b325f0bc5..000000000
--- a/gfx/cairo/fix-ps-output.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-# HG changeset patch
-# User Jeff Muizelaar <jmuizelaar@mozilla.com>
-# Date 1276629019 14400
-# Node ID b5eb246c152dedb895d3010eb7192f88cce51146
-# Parent 792cd3e8aa59b24c333f2c90f938beda361b3336
-cairo: PS: Add missing 'q' when resetting clip path
-
-diff --git a/gfx/cairo/cairo/src/cairo-ps-surface.c b/gfx/cairo/cairo/src/cairo-ps-surface.c
---- a/gfx/cairo/cairo/src/cairo-ps-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-ps-surface.c
-@@ -3696,7 +3696,7 @@ _cairo_ps_surface_set_paginated_mode (vo
- if (surface->clipper.clip.path != NULL) {
- status = _cairo_pdf_operators_flush (&surface->pdf_operators);
-
-- _cairo_output_stream_printf (surface->stream, "Q\n");
-+ _cairo_output_stream_printf (surface->stream, "Q q\n");
- _cairo_surface_clipper_reset (&surface->clipper);
- }
- }
diff --git a/gfx/cairo/fix-unnecessary-fallback.patch b/gfx/cairo/fix-unnecessary-fallback.patch
deleted file mode 100644
index 468801623..000000000
--- a/gfx/cairo/fix-unnecessary-fallback.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
-index 353cbcd..1a053d0 100644
---- a/src/cairo-xlib-surface.c
-+++ b/src/cairo-xlib-surface.c
-@@ -1818,7 +1817,8 @@ _recategorize_composite_operation (cairo_xlib_surface_t *dst,
- return DO_XTILE;
- }
-
-- if (dst->buggy_repeat && src_attr->extend == CAIRO_EXTEND_REPEAT)
-+ if (dst->buggy_repeat && src_attr->extend == CAIRO_EXTEND_REPEAT &&
-+ (src->width != 1 || src->height != 1))
- return DO_UNSUPPORTED;
-
- if (! CAIRO_SURFACE_RENDER_HAS_COMPOSITE (src))
diff --git a/gfx/cairo/fix-win32-font-assertion.patch b/gfx/cairo/fix-win32-font-assertion.patch
deleted file mode 100644
index 23cc5474b..000000000
--- a/gfx/cairo/fix-win32-font-assertion.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From: Jonathan Kew <jkew@mozilla.com>
-bug 838617 - don't assert equality with the key's hash unless it was actually initialized. r=roc
-
-diff --git a/gfx/cairo/cairo/src/cairo-win32-font.c b/gfx/cairo/cairo/src/cairo-win32-font.c
---- a/gfx/cairo/cairo/src/cairo-win32-font.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-font.c
-@@ -2104,19 +2104,19 @@ cairo_win32_font_face_create_for_logfont
- font_face = malloc (sizeof (cairo_win32_font_face_t));
- if (!font_face) {
- _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
- goto FAIL;
- }
-
- _cairo_win32_font_face_init_key (font_face, logfont, font);
- _cairo_font_face_init (&font_face->base, &_cairo_win32_font_face_backend);
-- assert (font_face->base.hash_entry.hash == key.base.hash_entry.hash);
-
- if (!font) {
-+ assert (font_face->base.hash_entry.hash == key.base.hash_entry.hash);
- status = _cairo_hash_table_insert (hash_table,
- &font_face->base.hash_entry);
- if (unlikely (status))
- goto FAIL;
- }
-
- DONE:
- if (!font) {
diff --git a/gfx/cairo/fix-win32-show-glyphs-clipping.patch b/gfx/cairo/fix-win32-show-glyphs-clipping.patch
deleted file mode 100644
index 91c5de2e1..000000000
--- a/gfx/cairo/fix-win32-show-glyphs-clipping.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 25fb70d4dc1e67553dba5973a79902e4cf81341f
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Wed Apr 21 11:23:27 2010 -0400
-
- fix show glyphs clipping
-
-diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
-index c10e134..ff823a3 100644
---- a/src/cairo-win32-surface.c
-+++ b/src/cairo-win32-surface.c
-@@ -1603,6 +1603,8 @@ _cairo_win32_surface_show_glyphs (void *surface,
-
- _cairo_win32_surface_set_clip_region (surface, clip_region);
- }
-+ } else {
-+ _cairo_win32_surface_set_clip_region (surface, NULL);
- }
-
- solid_pattern = (cairo_solid_pattern_t *)source;
diff --git a/gfx/cairo/fix-xcopyarea-with-clips.patch b/gfx/cairo/fix-xcopyarea-with-clips.patch
deleted file mode 100644
index 6bf3320b6..000000000
--- a/gfx/cairo/fix-xcopyarea-with-clips.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From: Benjamin Otte <otte@redhat.com>
-Date: Thu, 29 Apr 2010 16:20:59 +0000
-Subject: xlib: Don't modify variables that are needed later
-
-In the XCopyArea region code, don't modify src_x/y when they are later
-used in the unbounded fixup code.
-
-Exposed by composite-integer-translate-source test.
----
-diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
-index bedc3fd..30c08d3 100644
---- a/gfx/cairo/cairo/src/cairo-xlib-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c
-@@ -2322,10 +2322,10 @@ _cairo_xlib_surface_composite (cairo_operator_t op,
- width, height,
- dst_x, dst_y);
- } else {
-- int n, num_rects;
-+ int n, num_rects, x, y;
-
-- src_x += src_attr.x_offset + itx - dst_x;
-- src_y += src_attr.y_offset + ity - dst_y;
-+ x = src_x + src_attr.x_offset + itx - dst_x;
-+ y = src_y + src_attr.y_offset + ity - dst_y;
-
- num_rects = cairo_region_num_rectangles (clip_region);
- for (n = 0; n < num_rects; n++) {
-@@ -2333,7 +2333,7 @@ _cairo_xlib_surface_composite (cairo_operator_t op,
-
- cairo_region_get_rectangle (clip_region, n, &rect);
- XCopyArea (dst->dpy, src->drawable, dst->drawable, gc,
-- rect.x + src_x, rect.y + src_y,
-+ rect.x + x, rect.y + y,
- rect.width, rect.height,
- rect.x, rect.y);
- }
---
-cgit v0.8.3-6-g21f6
diff --git a/gfx/cairo/fix-zero-length-gradient.patch b/gfx/cairo/fix-zero-length-gradient.patch
deleted file mode 100644
index a920d76e9..000000000
--- a/gfx/cairo/fix-zero-length-gradient.patch
+++ /dev/null
@@ -1 +0,0 @@
-stg show: fix-zero-len-graident: Unknown patch or revision name
diff --git a/gfx/cairo/fixup-unbounded.patch b/gfx/cairo/fixup-unbounded.patch
deleted file mode 100644
index 09b3a9069..000000000
--- a/gfx/cairo/fixup-unbounded.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c
---- a/gfx/cairo/cairo/src/cairo-image-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-image-surface.c
-@@ -1797,17 +1797,17 @@ _cairo_image_surface_fixup_unbounded_box
- cairo_boxes_t *boxes)
- {
- cairo_boxes_t clear;
- cairo_box_t box;
- cairo_status_t status;
- struct _cairo_boxes_chunk *chunk;
- int i;
-
-- if (boxes->num_boxes <= 1 && clip_region == NULL)
-+ if (boxes->num_boxes < 1 && clip_region == NULL)
- return _cairo_image_surface_fixup_unbounded (dst, extents, NULL);
-
- _cairo_boxes_init (&clear);
-
- box.p1.x = _cairo_fixed_from_int (extents->unbounded.x + extents->unbounded.width);
- box.p1.y = _cairo_fixed_from_int (extents->unbounded.y);
- box.p2.x = _cairo_fixed_from_int (extents->unbounded.x);
- box.p2.y = _cairo_fixed_from_int (extents->unbounded.y + extents->unbounded.height);
diff --git a/gfx/cairo/ft-no-subpixel-if-surface-disables.patch b/gfx/cairo/ft-no-subpixel-if-surface-disables.patch
deleted file mode 100644
index a53e5de2b..000000000
--- a/gfx/cairo/ft-no-subpixel-if-surface-disables.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-# HG changeset patch
-# Parent 31c7eac3de3de324cb5c93bd19c4e16a693f1101
-# User Karl Tomlinson <karlt+@karlt.net>
-b=929451 don't use subpixel aa for ft fonts on surfaces that don't support it r?roc
-
-Also:
-* Prefer subpixel order provided by the surface over that from the font face.
-* Allow font face options to turn off subpixel aa.
-
-diff --git a/gfx/cairo/cairo/src/cairo-ft-font.c b/gfx/cairo/cairo/src/cairo-ft-font.c
---- a/gfx/cairo/cairo/src/cairo-ft-font.c
-+++ b/gfx/cairo/cairo/src/cairo-ft-font.c
-@@ -1759,23 +1759,26 @@ static void
-
- if (load_flags & FT_LOAD_NO_HINTING)
- other->base.hint_style = CAIRO_HINT_STYLE_NONE;
-
- if (other->base.antialias == CAIRO_ANTIALIAS_NONE ||
- options->base.antialias == CAIRO_ANTIALIAS_NONE) {
- options->base.antialias = CAIRO_ANTIALIAS_NONE;
- options->base.subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
-- }
--
-- if (other->base.antialias == CAIRO_ANTIALIAS_SUBPIXEL &&
-- (options->base.antialias == CAIRO_ANTIALIAS_DEFAULT ||
-- options->base.antialias == CAIRO_ANTIALIAS_GRAY)) {
-- options->base.antialias = CAIRO_ANTIALIAS_SUBPIXEL;
-- options->base.subpixel_order = other->base.subpixel_order;
-+ } else if (options->base.antialias != CAIRO_ANTIALIAS_GRAY) {
-+ /* The surface supports subpixel aa, so let the font face options
-+ * choose whether to use subpixel aa. If the surface has
-+ * CAIRO_ANTIALIAS_GRAY (e.g. PS, PDF, SVG, translucent part of a
-+ * CONTENT_COLOR_ALPHA surface), then don't accept subpixel aa. */
-+ if (other->base.antialias != CAIRO_ANTIALIAS_DEFAULT)
-+ options->base.antialias = other->base.antialias;
-+ /* If the surface knows the subpixel order then use that. */
-+ if (options->base.subpixel_order == CAIRO_SUBPIXEL_ORDER_DEFAULT)
-+ options->base.subpixel_order = other->base.subpixel_order;
- }
-
- if (options->base.hint_style == CAIRO_HINT_STYLE_DEFAULT)
- options->base.hint_style = other->base.hint_style;
-
- if (other->base.hint_style == CAIRO_HINT_STYLE_NONE)
- options->base.hint_style = CAIRO_HINT_STYLE_NONE;
-
diff --git a/gfx/cairo/gdi-RGB24-ARGB32.patch b/gfx/cairo/gdi-RGB24-ARGB32.patch
deleted file mode 100644
index 1df95f9ac..000000000
--- a/gfx/cairo/gdi-RGB24-ARGB32.patch
+++ /dev/null
@@ -1,141 +0,0 @@
-changeset: 106848:28db6dbdd9ea
-tag: gdi-patch
-tag: qbase
-tag: qtip
-tag: tip
-user: Jeff Muizelaar <jmuizelaar@mozilla.com>
-date: Wed Sep 12 22:52:06 2012 -0400
-summary: Bug 788794. Use BitBlt to do SOURCE and OVER from RGB24 to ARGB32. r=nical
-
-diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
-@@ -884,16 +884,28 @@ static cairo_int_status_t
- src_x, src_y,
- src_w, src_h,
- blend_function))
- return _cairo_win32_print_gdi_error ("_cairo_win32_surface_composite(AlphaBlend)");
-
- return CAIRO_STATUS_SUCCESS;
- }
-
-+/* makes the alpha channel in a RGB24 surface 0xff */
-+static void
-+make_opaque (cairo_image_surface_t *image, cairo_rectangle_int_t src_r)
-+{
-+ int x; int y;
-+ for (y = src_r.y; y < src_r.height; y++) {
-+ for (x = src_r.x; x < src_r.width; x++) {
-+ image->data[y * image->stride + x*4 + 3] = 0xff;
-+ }
-+ }
-+}
-+
- static cairo_int_status_t
- _cairo_win32_surface_composite_inner (cairo_win32_surface_t *src,
- cairo_image_surface_t *src_image,
- cairo_win32_surface_t *dst,
- cairo_rectangle_int_t src_extents,
- cairo_rectangle_int_t src_r,
- cairo_rectangle_int_t dst_r,
- int alpha,
-@@ -935,16 +947,24 @@ static cairo_int_status_t
- src_r.width, - (int) src_r.height,
- src_image->data,
- &bi,
- DIB_RGB_COLORS,
- SRCCOPY))
- return _cairo_win32_print_gdi_error ("_cairo_win32_surface_composite(StretchDIBits)");
- }
- } else if (!needs_alpha) {
-+ if (src->format == CAIRO_FORMAT_RGB24 && dst->format == CAIRO_FORMAT_ARGB32) {
-+ /* Because we store RGB24 & ARGB32 in the same way GDI has no way
-+ * to ignore the alpha channel from a RGB24 source. Therefore, we set
-+ * the alpha channel in our RGB24 source to opaque so that we can treat
-+ * it like ARGB32. */
-+ GdiFlush();
-+ make_opaque(src->image, src_r);
-+ }
- /* BitBlt or StretchBlt? */
- if (!needs_scale && (dst->flags & CAIRO_WIN32_SURFACE_CAN_BITBLT)) {
- if (!BitBlt (dst->dc,
- dst_r.x, dst_r.y,
- dst_r.width, dst_r.height,
- src->dc,
- src_r.x, src_r.y,
- SRCCOPY))
-@@ -1184,28 +1204,36 @@ static cairo_int_status_t
- }
- } else {
- needs_repeat = TRUE;
- }
-
- /*
- * Operations that we can do:
- *
-+ * AlphaBlend uses the following formula for alpha when not use the per-pixel alpha (AlphaFormat = 0)
-+ * Dst.Alpha = Src.Alpha * (SCA/255.0) + Dst.Alpha * (1.0 - (SCA/255.0))
-+ * This turns into Dst.Alpha = Src.Alpha when SCA = 255.
-+ * (http://msdn.microsoft.com/en-us/library/aa921335.aspx)
-+ *
- * RGB OVER RGB -> BitBlt (same as SOURCE)
-- * RGB OVER ARGB -> UNSUPPORTED (AlphaBlend treats this as a BitBlt, even with SCA 255 and no AC_SRC_ALPHA)
-+ * RGB OVER ARGB -> Partially supported, We convert this operation into a ARGB SOURCE ARGB
-+ * by setting the alpha values of the source to 255.
- * ARGB OVER ARGB -> AlphaBlend, with AC_SRC_ALPHA
- * ARGB OVER RGB -> AlphaBlend, with AC_SRC_ALPHA; we'll have junk in the dst A byte
- *
- * RGB OVER RGB + mask -> AlphaBlend, no AC_SRC_ALPHA
-- * RGB OVER ARGB + mask -> UNSUPPORTED
-+ * RGB OVER ARGB + mask -> Partially supported, We convert this operation into a ARGB OVER ARGB + mask
-+ * by setting the alpha values of the source to 255.
- * ARGB OVER ARGB + mask -> AlphaBlend, with AC_SRC_ALPHA
- * ARGB OVER RGB + mask -> AlphaBlend, with AC_SRC_ALPHA; junk in the dst A byte
- *
- * RGB SOURCE RGB -> BitBlt
-- * RGB SOURCE ARGB -> UNSUPPORTED (AlphaBlend treats this as a BitBlt, even with SCA 255 and no AC_SRC_ALPHA)
-+ * RGB SOURCE ARGB -> Partially supported, We convert this operation into a ARGB SOURCE ARGB
-+ * by setting the alpha values of the source to 255.
- * ARGB SOURCE ARGB -> BitBlt
- * ARGB SOURCE RGB -> BitBlt
- *
- * RGB SOURCE RGB + mask -> unsupported
- * RGB SOURCE ARGB + mask -> unsupported
- * ARGB SOURCE ARGB + mask -> unsupported
- * ARGB SOURCE RGB + mask -> unsupported
- */
-@@ -1222,22 +1250,32 @@ static cairo_int_status_t
- needs_alpha = FALSE;
- } else {
- needs_alpha = TRUE;
- }
- } else if (src_format == CAIRO_FORMAT_ARGB32 &&
- dst->format == CAIRO_FORMAT_RGB24)
- {
- needs_alpha = TRUE;
-+ } else if (src_format == CAIRO_FORMAT_RGB24 &&
-+ dst->format == CAIRO_FORMAT_ARGB32 &&
-+ src->image)
-+ {
-+ if (alpha == 255) {
-+ needs_alpha = FALSE;
-+ } else {
-+ needs_alpha = TRUE;
-+ }
- } else {
- goto UNSUPPORTED;
- }
- } else if (alpha == 255 && op == CAIRO_OPERATOR_SOURCE) {
- if ((src_format == dst->format) ||
-- (src_format == CAIRO_FORMAT_ARGB32 && dst->format == CAIRO_FORMAT_RGB24))
-+ (src_format == CAIRO_FORMAT_ARGB32 && dst->format == CAIRO_FORMAT_RGB24) ||
-+ (src_format == CAIRO_FORMAT_RGB24 && dst->format == CAIRO_FORMAT_ARGB32 && src->image))
- {
- needs_alpha = FALSE;
- } else {
- goto UNSUPPORTED;
- }
- } else {
- goto UNSUPPORTED;
- }
-
diff --git a/gfx/cairo/handle-a1.patch b/gfx/cairo/handle-a1.patch
deleted file mode 100644
index eaad3d69e..000000000
--- a/gfx/cairo/handle-a1.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-commit 82aab44a9005047743538d52e9fbc27fd6ce408a
-Author: Chris Wilson <chris@chris-wilson.co.uk>
-Date: Fri Mar 19 17:23:20 2010 -0400
-
- commit f07195860620959c27d43080a7b987e28222735a
-
- xlib: Handle a1 image uploads through converter
-
- Fixes test/large-source [xlib]
-
-diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
-index 1a053d0..8f773b0 100644
---- a/src/cairo-xlib-surface.c
-+++ b/src/cairo-xlib-surface.c
-@@ -1155,7 +1155,9 @@ _draw_image_surface (cairo_xlib_surface_t *surface,
- int dither_adjustment = dither_row[x_off];
- int a, r, g, b;
-
-- if (image_masks.bpp <= 8)
-+ if (image_masks.bpp == 1)
-+ in_pixel = !! (((uint8_t*)row)[x/8] & (1 << (x & 7)));
-+ else if (image_masks.bpp <= 8)
- in_pixel = ((uint8_t*)row)[x];
- else if (image_masks.bpp <= 16)
- in_pixel = ((uint16_t*)row)[x];
diff --git a/gfx/cairo/handle-multi-path-clip.patch b/gfx/cairo/handle-multi-path-clip.patch
deleted file mode 100644
index fe4268885..000000000
--- a/gfx/cairo/handle-multi-path-clip.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c
---- a/gfx/cairo/cairo/src/cairo-image-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-image-surface.c
-@@ -2885,16 +2885,18 @@ static cairo_status_t
- cairo_bool_t need_clip_mask = FALSE;
- cairo_status_t status;
- struct _cairo_boxes_chunk *chunk;
- uint32_t pixel;
- int i;
-
- if (clip != NULL) {
- status = _cairo_clip_get_region (clip, &clip_region);
-+ if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO))
-+ return CAIRO_STATUS_SUCCESS;
- need_clip_mask = status == CAIRO_INT_STATUS_UNSUPPORTED;
- if (need_clip_mask &&
- (op == CAIRO_OPERATOR_SOURCE || ! extents->is_bounded))
- {
- return CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
-@@ -3200,30 +3202,20 @@ static cairo_status_t
- return _clip_and_composite (dst, op, src,
- _composite_traps, &info,
- extents, clip);
- }
-
- static cairo_clip_path_t *
- _clip_get_single_path (cairo_clip_t *clip)
- {
-- cairo_clip_path_t *iter = clip->path;
-- cairo_clip_path_t *path = NULL;
--
-- do {
-- if ((iter->flags & CAIRO_CLIP_PATH_IS_BOX) == 0) {
-- if (path != NULL)
-- return FALSE;
--
-- path = iter;
-- }
-- iter = iter->prev;
-- } while (iter != NULL);
--
-- return path;
-+ if (clip->path->prev == NULL)
-+ return clip->path;
-+
-+ return NULL;
- }
-
- /* high level image interface */
-
- static cairo_int_status_t
- _cairo_image_surface_paint (void *abstract_surface,
- cairo_operator_t op,
- const cairo_pattern_t *source,
diff --git a/gfx/cairo/ignore-rank0.patch b/gfx/cairo/ignore-rank0.patch
deleted file mode 100644
index 7e20f66fb..000000000
--- a/gfx/cairo/ignore-rank0.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-gstate.c b/gfx/cairo/cairo/src/cairo-gstate.c
-index 0439bcf..32a5c4b 100644
---- a/gfx/cairo/cairo/src/cairo-gstate.c
-+++ b/gfx/cairo/cairo/src/cairo-gstate.c
-@@ -1271,8 +1271,13 @@ _cairo_gstate_set_font_matrix (cairo_gstate_t *gstate,
- if (memcmp (matrix, &gstate->font_matrix, sizeof (cairo_matrix_t)) == 0)
- return CAIRO_STATUS_SUCCESS;
-
-- if (! _cairo_matrix_is_invertible (matrix))
-- return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
-+ if (! _cairo_matrix_is_invertible (matrix)) {
-+ /* rank 0 matrices are ok even though they are not invertible */
-+ if (!(matrix->xx == 0. && matrix->xy == 0. &&
-+ matrix->yx == 0. && matrix->yy == 0.)) {
-+ return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
-+ }
-+ }
-
- _cairo_gstate_unset_scaled_font (gstate);
-
diff --git a/gfx/cairo/libpixman/AUTHORS b/gfx/cairo/libpixman/AUTHORS
index e69de29bb..a7798bdf1 100644
--- a/gfx/cairo/libpixman/AUTHORS
+++ b/gfx/cairo/libpixman/AUTHORS
@@ -0,0 +1,18 @@
+Richard D. Worth
+Red Hat, Inc.
+USC, Information Sciences Institute
+David Reveman
+Novell, Inc.
+David Reveman, Peter Nilsson
+Keith Packard, member of The XFree86 Project, Inc.
+Lars Knoll & Zack Rusin, Trolltech
+Keith Packard
+Nicholas Miell
+Trolltech AS
+SuSE, Inc.
+Carl Worth
+The Open Group
+Digital Equipment Corporation, Maynard, Massachusetts.
+Keith Packard
+Richard Henderson
+Mark Straver
diff --git a/gfx/cairo/libpixman/COPYING b/gfx/cairo/libpixman/COPYING
index e69de29bb..47c05f154 100644
--- a/gfx/cairo/libpixman/COPYING
+++ b/gfx/cairo/libpixman/COPYING
@@ -0,0 +1,37 @@
+Libpixman is free software.
+
+This (modified) version of the libpixman implementation is available to
+be redistributed and/or modified under the terms of the following license[1].
+
+Please see the headers of individual files for the respective copyright
+holder(s) to the original code.
+For all files it should be assumed that some modifications have been made
+to adapt the code to surrounding requirements of the UXP source, and
+the authors listed are only authors of the original code, not this modified
+version.
+The contributors to this code are not always listed, so for all files should
+be assumed:
+
+Contributors: Mozilla, Pale Moon and UXP contributors.
+
+[1] License follows:
+Copyright (C) <date> <copyright holder>
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without
+fee, provided that the above copyright notice appear in all copies
+and that both that copyright notice and this permission notice
+appear in supporting documentation, and that the name of
+<copyright holder> not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+<copyright holder> makes no representations about the suitability of this
+software for any purpose. It is provided "as is" without express or
+implied warranty.
+
+<COPYRIGHT HOLDER> DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+WITH THE USE OR PERFORMANCE OF THIS SOFTWARE \ No newline at end of file
diff --git a/gfx/cairo/lround-c99-only.patch b/gfx/cairo/lround-c99-only.patch
deleted file mode 100644
index 9002235f0..000000000
--- a/gfx/cairo/lround-c99-only.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-Only use lround in C99 programs.
-
-diff --git a/gfx/cairo/cairo/src/cairo-misc.c b/gfx/cairo/cairo/src/cairo-misc.c
---- a/gfx/cairo/cairo/src/cairo-misc.c
-+++ b/gfx/cairo/cairo/src/cairo-misc.c
-@@ -478,17 +478,17 @@ _cairo_operator_bounded_by_either (cairo
- case CAIRO_OPERATOR_IN:
- case CAIRO_OPERATOR_DEST_IN:
- case CAIRO_OPERATOR_DEST_ATOP:
- return 0;
- }
-
- }
-
--#if DISABLE_SOME_FLOATING_POINT
-+#if DISABLE_SOME_FLOATING_POINT || __STDC_VERSION__ < 199901L
- /* This function is identical to the C99 function lround(), except that it
- * performs arithmetic rounding (floor(d + .5) instead of away-from-zero rounding) and
- * has a valid input range of (INT_MIN, INT_MAX] instead of
- * [INT_MIN, INT_MAX]. It is much faster on both x86 and FPU-less systems
- * than other commonly used methods for rounding (lround, round, rint, lrint
- * or float (d + 0.5)).
- *
- * The reason why this function is much faster on x86 than other
-diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
---- a/gfx/cairo/cairo/src/cairoint.h
-+++ b/gfx/cairo/cairo/src/cairoint.h
-@@ -969,17 +969,17 @@ _cairo_restrict_value (double value, dou
- * away from 0. _cairo_round rounds halfway cases toward negative infinity.
- * This matches the rounding behaviour of _cairo_lround. */
- static inline double cairo_const
- _cairo_round (double r)
- {
- return floor (r + .5);
- }
-
--#if DISABLE_SOME_FLOATING_POINT
-+#if DISABLE_SOME_FLOATING_POINT || __STDC_VERSION__ < 199901L
- cairo_private int
- _cairo_lround (double d) cairo_const;
- #else
- #define _cairo_lround lround
- #endif
-
- cairo_private uint16_t
- _cairo_half_from_float (float f) cairo_const;
diff --git a/gfx/cairo/max-font-size.patch b/gfx/cairo/max-font-size.patch
deleted file mode 100644
index 99be23906..000000000
--- a/gfx/cairo/max-font-size.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-ft-font.c b/gfx/cairo/cairo/src/cairo-ft-font.c
---- a/gfx/cairo/cairo/src/cairo-ft-font.c
-+++ b/gfx/cairo/cairo/src/cairo-ft-font.c
-@@ -63,6 +63,10 @@
- /* This is the max number of FT_face objects we keep open at once
- */
- #define MAX_OPEN_FACES 10
-+
-+/* This is the maximum font size we allow to be passed to FT_Set_Char_Size
-+ */
-+#define MAX_FONT_SIZE 1000
-
- /*
- * The simple 2x2 matrix is converted into separate scale and shape
-@@ -682,9 +686,11 @@ _cairo_ft_unscaled_font_set_scale (cairo
- FT_Set_Transform(unscaled->face, &mat, NULL);
-
- if ((unscaled->face->face_flags & FT_FACE_FLAG_SCALABLE) != 0) {
-+ double x_scale = MIN(sf.x_scale, MAX_FONT_SIZE);
-+ double y_scale = MIN(sf.y_scale, MAX_FONT_SIZE);
- error = FT_Set_Char_Size (unscaled->face,
-- sf.x_scale * 64.0 + .5,
-- sf.y_scale * 64.0 + .5,
-+ x_scale * 64.0 + .5,
-+ y_scale * 64.0 + .5,
- 0, 0);
- if (error)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/gfx/cairo/missing-cairo-clip-init.diff b/gfx/cairo/missing-cairo-clip-init.diff
deleted file mode 100644
index a3f46771f..000000000
--- a/gfx/cairo/missing-cairo-clip-init.diff
+++ /dev/null
@@ -1,21 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-gstate.c b/gfx/cairo/cairo/src/cairo-gstate.c
---- a/gfx/cairo/cairo/src/cairo-gstate.c
-+++ b/gfx/cairo/cairo/src/cairo-gstate.c
-@@ -1841,16 +1841,17 @@ _cairo_gstate_show_text_glyphs (cairo_gs
- transformed_glyphs,
- &num_glyphs,
- transformed_clusters);
-
- if (status || num_glyphs == 0)
- goto CLEANUP_GLYPHS;
-
- _cairo_gstate_copy_transformed_source (gstate, &source_pattern.base);
-+ _cairo_clip_init(&clip);
-
- /* For really huge font sizes, we can just do path;fill instead of
- * show_glyphs, as show_glyphs would put excess pressure on the cache,
- * not all components below us correctly handle huge font sizes, and
- * path filling can be cheaper since parts of glyphs are likely to be
- * clipped out. 256 seems like a good limit. But alas, seems like cairo's
- * rasterizer is something like ten times slower than freetype's for huge
- * sizes. So, no win just yet when we're using cairo's rasterizer.
diff --git a/gfx/cairo/native-clipping.patch b/gfx/cairo/native-clipping.patch
deleted file mode 100644
index 171998fe7..000000000
--- a/gfx/cairo/native-clipping.patch
+++ /dev/null
@@ -1,189 +0,0 @@
-commit 857df0583365228150b3319475efc43b22077d06
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Tue Apr 20 15:43:54 2010 -0400
-
- native clipping
-
-diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
-index df063bf..819e53e 100644
---- a/src/cairo-quartz-surface.c
-+++ b/src/cairo-quartz-surface.c
-@@ -39,6 +39,8 @@
-
- #include "cairo-quartz-private.h"
- #include "cairo-surface-clipper-private.h"
-+#include "cairo-gstate-private.h"
-+#include "cairo-private.h"
-
- #include <dlfcn.h>
-
-@@ -3095,6 +3097,61 @@ cairo_quartz_surface_get_cg_context (cairo_surface_t *surface)
- return quartz->cgContext;
- }
-
-+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 */
-+ CGContextSaveGState (quartz->cgContext);
-+
-+ /* _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);
-+
-+ 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);
-+}
-
- /* Debug stuff */
-
-diff --git a/src/cairo-quartz.h b/src/cairo-quartz.h
-index e8b71ba..aa1cdd2 100644
---- a/src/cairo-quartz.h
-+++ b/src/cairo-quartz.h
-@@ -57,6 +57,12 @@ cairo_quartz_surface_create_for_cg_context (CGContextRef cgContext,
- 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);
-+
- #if CAIRO_HAS_QUARTZ_FONT
-
- /*
-diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
-index d4575a3..c10e134 100644
---- a/src/cairo-win32-surface.c
-+++ b/src/cairo-win32-surface.c
-@@ -52,7 +52,9 @@
- #include "cairo-win32-private.h"
- #include "cairo-scaled-font-subsets-private.h"
- #include "cairo-surface-fallback-private.h"
--
-+#include "cairo-surface-clipper-private.h"
-+#include "cairo-gstate-private.h"
-+#include "cairo-private.h"
- #include <wchar.h>
- #include <windows.h>
-
-@@ -1914,6 +1916,61 @@ cairo_win32_surface_get_dc (cairo_surface_t *surface)
- return NULL;
- }
-
-+
-+HDC
-+cairo_win32_get_dc_with_clip (cairo_t *cr)
-+{
-+ cairo_surface_t *surface = cr->gstate->target;
-+ cairo_clip_t clip;
-+ _cairo_clip_init_copy(&clip, &cr->gstate->clip);
-+
-+ if (_cairo_surface_is_win32 (surface)){
-+ cairo_win32_surface_t *winsurf = (cairo_win32_surface_t *) surface;
-+ cairo_region_t *clip_region = NULL;
-+ cairo_status_t status;
-+
-+ if (clip.path) {
-+ status = _cairo_clip_get_region (&clip, &clip_region);
-+ assert (status != CAIRO_INT_STATUS_NOTHING_TO_DO);
-+ if (status) {
-+ _cairo_clip_fini(&clip);
-+ return NULL;
-+ }
-+ }
-+ _cairo_win32_surface_set_clip_region (winsurf, clip_region);
-+
-+ _cairo_clip_fini(&clip);
-+ return winsurf->dc;
-+ }
-+
-+ if (_cairo_surface_is_paginated (surface)) {
-+ cairo_surface_t *target;
-+
-+ target = _cairo_paginated_surface_get_target (surface);
-+
-+#ifndef CAIRO_OMIT_WIN32_PRINTING
-+ if (_cairo_surface_is_win32_printing (target)) {
-+ cairo_status_t status;
-+ cairo_win32_surface_t *winsurf = (cairo_win32_surface_t *) target;
-+
-+ status = _cairo_surface_clipper_set_clip (&winsurf->clipper, &clip);
-+
-+ _cairo_clip_fini(&clip);
-+
-+ if (status)
-+ return NULL;
-+
-+ return winsurf->dc;
-+ }
-+#endif
-+ }
-+
-+ _cairo_clip_fini(&clip);
-+ return NULL;
-+}
-+
-+
-+
- /**
- * cairo_win32_surface_get_image
- * @surface: a #cairo_surface_t
-diff --git a/src/cairo-win32.h b/src/cairo-win32.h
-index 7d04d2a..c304f92 100644
---- a/src/cairo-win32.h
-+++ b/src/cairo-win32.h
-@@ -65,6 +65,9 @@ cairo_win32_surface_create_with_dib (cairo_format_t format,
- cairo_public HDC
- cairo_win32_surface_get_dc (cairo_surface_t *surface);
-
-+cairo_public HDC
-+cairo_win32_get_dc_with_clip (cairo_t *cr);
-+
- cairo_public cairo_surface_t *
- cairo_win32_surface_get_image (cairo_surface_t *surface);
-
diff --git a/gfx/cairo/no-pixman-image-reuse-across-threads.patch b/gfx/cairo/no-pixman-image-reuse-across-threads.patch
deleted file mode 100644
index ccaf5a5e6..000000000
--- a/gfx/cairo/no-pixman-image-reuse-across-threads.patch
+++ /dev/null
@@ -1,242 +0,0 @@
-From
-https://cgit.freedesktop.org/cairo/commit/?id=71e8a4c23019b01aa43b334fcb2784c70daae9b5
-https://bugs.freedesktop.org/show_bug.cgi?id=34177
-
-diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c
---- a/gfx/cairo/cairo/src/cairo-image-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-image-surface.c
-@@ -870,17 +870,17 @@ static cairo_bool_t
- *ty = _pixman_nearest_sample (*ty);
- } else {
- if (*tx != floor (*tx) || *ty != floor (*ty))
- return FALSE;
- }
- return fabs (*tx) < PIXMAN_MAX_INT && fabs (*ty) < PIXMAN_MAX_INT;
- }
-
--#if HAS_ATOMIC_OPS
-+#if PIXMAN_HAS_ATOMIC_OPS
- static pixman_image_t *__pixman_transparent_image;
- static pixman_image_t *__pixman_black_image;
- static pixman_image_t *__pixman_white_image;
-
- static pixman_image_t *
- _pixman_transparent_image (void)
- {
- pixman_image_t *image;
-@@ -964,56 +964,59 @@ static pixman_image_t *
- pixman_image_ref (image);
- }
- } else {
- pixman_image_ref (image);
- }
-
- return image;
- }
--#else
--static pixman_image_t *
--_pixman_transparent_image (void)
--{
-- return _pixman_image_for_solid (&_cairo_pattern_clear);
--}
--static pixman_image_t *
--_pixman_black_image (void)
--{
-- return _pixman_image_for_solid (&_cairo_pattern_black);
--}
--static pixman_image_t *
--_pixman_white_image (void)
--{
-- return _pixman_image_for_solid (&_cairo_pattern_white);
--}
--#endif
-
- static uint32_t
- hars_petruska_f54_1_random (void)
- {
- #define rol(x,k) ((x << k) | (x >> (32-k)))
- static uint32_t x;
- return x = (x ^ rol (x, 5) ^ rol (x, 24)) + 0x37798849;
- #undef rol
- }
-
- static struct {
- cairo_color_t color;
- pixman_image_t *image;
- } cache[16];
- static int n_cached;
-
-+#else /* !PIXMAN_HAS_ATOMIC_OPS */
-+static pixman_image_t *
-+_pixman_transparent_image (void)
-+{
-+ return _pixman_image_for_solid (&_cairo_pattern_clear);
-+}
-+
-+static pixman_image_t *
-+_pixman_black_image (void)
-+{
-+ return _pixman_image_for_solid (&_cairo_pattern_black);
-+}
-+
-+static pixman_image_t *
-+_pixman_white_image (void)
-+{
-+ return _pixman_image_for_solid (&_cairo_pattern_white);
-+}
-+#endif /* !PIXMAN_HAS_ATOMIC_OPS */
-+
- void
- _cairo_image_reset_static_data (void)
- {
-+#if PIXMAN_HAS_ATOMIC_OPS
- while (n_cached)
- pixman_image_unref (cache[--n_cached].image);
-
--#if HAS_ATOMIC_OPS
- if (__pixman_transparent_image) {
- pixman_image_unref (__pixman_transparent_image);
- __pixman_transparent_image = NULL;
- }
-
- if (__pixman_black_image) {
- pixman_image_unref (__pixman_black_image);
- __pixman_black_image = NULL;
-@@ -1026,19 +1029,20 @@ void
- #endif
- }
-
- static pixman_image_t *
- _pixman_image_for_solid (const cairo_solid_pattern_t *pattern)
- {
- pixman_color_t color;
- pixman_image_t *image;
-+
-+#if PIXMAN_HAS_ATOMIC_OPS
- int i;
-
--#if HAS_ATOMIC_OPS
- if (pattern->color.alpha_short <= 0x00ff)
- return _pixman_transparent_image ();
-
- if (pattern->color.alpha_short >= 0xff00) {
- if (pattern->color.red_short <= 0x00ff &&
- pattern->color.green_short <= 0x00ff &&
- pattern->color.blue_short <= 0x00ff)
- {
-@@ -1047,46 +1051,48 @@ static pixman_image_t *
-
- if (pattern->color.red_short >= 0xff00 &&
- pattern->color.green_short >= 0xff00 &&
- pattern->color.blue_short >= 0xff00)
- {
- return _pixman_white_image ();
- }
- }
--#endif
-
- CAIRO_MUTEX_LOCK (_cairo_image_solid_cache_mutex);
- for (i = 0; i < n_cached; i++) {
- if (_cairo_color_equal (&cache[i].color, &pattern->color)) {
- image = pixman_image_ref (cache[i].image);
- goto UNLOCK;
- }
- }
-+#endif
-
- color.red = pattern->color.red_short;
- color.green = pattern->color.green_short;
- color.blue = pattern->color.blue_short;
- color.alpha = pattern->color.alpha_short;
-
- image = pixman_image_create_solid_fill (&color);
-+#if PIXMAN_HAS_ATOMIC_OPS
- if (image == NULL)
- goto UNLOCK;
-
- if (n_cached < ARRAY_LENGTH (cache)) {
- i = n_cached++;
- } else {
- i = hars_petruska_f54_1_random () % ARRAY_LENGTH (cache);
- pixman_image_unref (cache[i].image);
- }
- cache[i].image = pixman_image_ref (image);
- cache[i].color = pattern->color;
-
- UNLOCK:
- CAIRO_MUTEX_UNLOCK (_cairo_image_solid_cache_mutex);
-+#endif
- return image;
- }
-
- static double
- clamp (double val, double min, double max)
- {
- return val < min ? min : (val > max ? max : val);
- }
-@@ -1423,25 +1429,27 @@ static pixman_image_t *
- return _pixman_transparent_image ();
- }
- else
- {
- return _pixel_to_solid (source, sample.x, sample.y);
- }
- }
-
-+#if PIXMAN_HAS_ATOMIC_OPS
- /* avoid allocating a 'pattern' image if we can reuse the original */
- if (extend == CAIRO_EXTEND_NONE &&
- _cairo_matrix_is_translation (&pattern->base.matrix) &&
- _nearest_sample (filter, &tx, &ty))
- {
- *ix = tx;
- *iy = ty;
- return pixman_image_ref (source->pixman_image);
- }
-+#endif
-
- pixman_image = pixman_image_create_bits (source->pixman_format,
- source->width,
- source->height,
- (uint32_t *) source->data,
- source->stride);
- if (unlikely (pixman_image == NULL))
- return NULL;
-@@ -1466,31 +1474,36 @@ static pixman_image_t *
- sub->extents.x + sample.x,
- sub->extents.y + sample.y);
- } else {
- if (extend == CAIRO_EXTEND_NONE)
- return _pixman_transparent_image ();
- }
- }
-
-+#if PIXMAN_HAS_ATOMIC_OPS
- if (is_contained &&
- _cairo_matrix_is_translation (&pattern->base.matrix) &&
- _nearest_sample (filter, &tx, &ty))
- {
- *ix = tx + sub->extents.x;
- *iy = ty + sub->extents.y;
- return pixman_image_ref (source->pixman_image);
- }
-+#endif
-
- /* Avoid sub-byte offsets, force a copy in that case. */
- if (PIXMAN_FORMAT_BPP (source->pixman_format) >= 8) {
-+ void *data = source->data
-+ + sub->extents.x * PIXMAN_FORMAT_BPP(source->pixman_format)/8
-+ + sub->extents.y * source->stride;
- pixman_image = pixman_image_create_bits (source->pixman_format,
- sub->extents.width,
- sub->extents.height,
-- (uint32_t *) (source->data + sub->extents.x * PIXMAN_FORMAT_BPP(source->pixman_format)/8 + sub->extents.y * source->stride),
-+ data,
- source->stride);
- if (unlikely (pixman_image == NULL))
- return NULL;
- }
- }
- }
-
- if (pixman_image == NULL) {
diff --git a/gfx/cairo/nonfatal-assertions.patch b/gfx/cairo/nonfatal-assertions.patch
deleted file mode 100644
index dcbb904ab..000000000
--- a/gfx/cairo/nonfatal-assertions.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-diff -r b79d47dad1ea gfx/cairo/cairo/src/cairoint.h
---- a/gfx/cairo/cairo/src/cairoint.h Fri Jun 08 18:09:53 2007 -0700
-+++ b/gfx/cairo/cairo/src/cairoint.h Fri Jun 29 09:18:02 2007 +0200
-@@ -159,6 +159,13 @@ CAIRO_BEGIN_DECLS
-
- #ifndef M_PI
- #define M_PI 3.14159265358979323846
-+#endif
-+
-+#ifndef NDEBUG
-+#undef assert
-+#define assert(expr) \
-+ do { if (!(expr)) fprintf(stderr, "Assertion failed at %s:%d: %s\n", \
-+ __FILE__, __LINE__, #expr); } while (0)
- #endif
-
- #undef ARRAY_LENGTH
diff --git a/gfx/cairo/on-edge.patch b/gfx/cairo/on-edge.patch
deleted file mode 100644
index 85e328ad8..000000000
--- a/gfx/cairo/on-edge.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-commit a26655b3144ed273940486fc15ccdac12b0562ec
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Tue Mar 17 15:08:50 2009 -0400
-
- Jeff Muizelaar noted that the treatment of edges differed with firefox's
- canvas definition, which considers a point on any edge as inside. The
- current implementation has a similar definition to that of flash, for
- which the top and right edges are outside. Arguably, firefox has the more
- intuitive definition here...
-
-diff --git a/src/cairo-path-in-fill.c b/src/cairo-path-in-fill.c
-index 21cd0bd..e641654 100644
---- a/src/cairo-path-in-fill.c
-+++ b/src/cairo-path-in-fill.c
-@@ -41,6 +41,7 @@ typedef struct cairo_in_fill {
- int winding;
-
- cairo_fixed_t x, y;
-+ cairo_bool_t on_edge;
-
- cairo_bool_t has_current_point;
- cairo_point_t current_point;
-@@ -58,6 +59,7 @@ _cairo_in_fill_init (cairo_in_fill_t *in_fill,
-
- in_fill->x = _cairo_fixed_from_double (x);
- in_fill->y = _cairo_fixed_from_double (y);
-+ in_fill->on_edge = FALSE;
-
- in_fill->has_current_point = FALSE;
- in_fill->current_point.x = 0;
-@@ -103,6 +105,9 @@ _cairo_in_fill_add_edge (cairo_in_fill_t *in_fill,
- {
- int dir;
-
-+ if (in_fill->on_edge)
-+ return;
-+
- /* count the number of edge crossing to -∞ */
-
- dir = 1;
-@@ -116,6 +121,18 @@ _cairo_in_fill_add_edge (cairo_in_fill_t *in_fill,
- dir = -1;
- }
-
-+ /* First check whether the query is on an edge */
-+ if ((p1->x == in_fill->x && p1->x == in_fill->y) ||
-+ (p2->x == in_fill->x && p2->x == in_fill->y) ||
-+ (! (p2->y < in_fill->y || p1->y > in_fill->y) &&
-+ ! (p1->x > in_fill->x && p2->x > in_fill->x) &&
-+ ! (p1->x < in_fill->x && p2->x < in_fill->x) &&
-+ edge_compare_for_y_against_x (p1, p2, in_fill->y, in_fill->x) == 0))
-+ {
-+ in_fill->on_edge = TRUE;
-+ return;
-+ }
-+
- /* edge is entirely above or below, note the shortening rule */
- if (p2->y <= in_fill->y || p1->y > in_fill->y)
- return;
-@@ -246,7 +263,9 @@ _cairo_path_fixed_in_fill (cairo_path_fixed_t *path,
-
- _cairo_in_fill_close_path (&in_fill);
-
-- switch (fill_rule) {
-+ if (in_fill.on_edge) {
-+ *is_inside = TRUE;
-+ } else switch (fill_rule) {
- case CAIRO_FILL_RULE_EVEN_ODD:
- *is_inside = in_fill.winding & 1;
- break;
diff --git a/gfx/cairo/pattern_get_surface-no-error.patch b/gfx/cairo/pattern_get_surface-no-error.patch
deleted file mode 100644
index 93f08512d..000000000
--- a/gfx/cairo/pattern_get_surface-no-error.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-# HG changeset patch
-# User Robert O'Callahan <robert@ocallahan.org>
-# Date 1294019288 -46800
-# Node ID e427b4ea7e2ff980769e1acd92f4730c5ed3654f
-# Parent bacc54d452a9fddb5a0d6a1442ec7be4de81ffa7
-Bug 593604. Part 2.5: cairo_pattern_get_surface should not call cairo_error. r=jrmuizel,a=blocking
-
-diff --git a/gfx/cairo/cairo/src/cairo-pattern.c b/gfx/cairo/cairo/src/cairo-pattern.c
---- a/gfx/cairo/cairo/src/cairo-pattern.c
-+++ b/gfx/cairo/cairo/src/cairo-pattern.c
-@@ -2940,17 +2940,17 @@ cairo_pattern_get_surface (cairo_pattern
- cairo_surface_t **surface)
- {
- cairo_surface_pattern_t *spat = (cairo_surface_pattern_t*) pattern;
-
- if (pattern->status)
- return pattern->status;
-
- if (pattern->type != CAIRO_PATTERN_TYPE_SURFACE)
-- return _cairo_error (CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
-+ return CAIRO_STATUS_PATTERN_TYPE_MISMATCH;
-
- if (surface)
- *surface = spat->surface;
-
- return CAIRO_STATUS_SUCCESS;
- }
-
- /**
diff --git a/gfx/cairo/pixman-16-bit-pipeline.patch b/gfx/cairo/pixman-16-bit-pipeline.patch
deleted file mode 100644
index 8a7878ca2..000000000
--- a/gfx/cairo/pixman-16-bit-pipeline.patch
+++ /dev/null
@@ -1,1242 +0,0 @@
-diff --git a/gfx/cairo/libpixman/src/pixman-access.c b/gfx/cairo/libpixman/src/pixman-access.c
---- a/gfx/cairo/libpixman/src/pixman-access.c
-+++ b/gfx/cairo/libpixman/src/pixman-access.c
-@@ -933,16 +933,54 @@ store_scanline_x2b10g10r10 (bits_image_t
- {
- WRITE (image, pixel++,
- ((values[i] >> 38) & 0x3ff) |
- ((values[i] >> 12) & 0xffc00) |
- ((values[i] << 14) & 0x3ff00000));
- }
- }
-
-+static void
-+store_scanline_16 (bits_image_t * image,
-+ int x,
-+ int y,
-+ int width,
-+ const uint32_t *v)
-+{
-+ uint16_t *bits = (uint16_t*)(image->bits + image->rowstride * y);
-+ uint16_t *values = (uint16_t *)v;
-+ uint16_t *pixel = bits + x;
-+ int i;
-+
-+ for (i = 0; i < width; ++i)
-+ {
-+ WRITE (image, pixel++, values[i]);
-+ }
-+}
-+
-+static void
-+fetch_scanline_16 (pixman_image_t *image,
-+ int x,
-+ int y,
-+ int width,
-+ uint32_t * b,
-+ const uint32_t *mask)
-+{
-+ const uint16_t *bits = (uint16_t*)(image->bits.bits + y * image->bits.rowstride);
-+ const uint16_t *pixel = bits + x;
-+ int i;
-+ uint16_t *buffer = (uint16_t *)b;
-+
-+ for (i = 0; i < width; ++i)
-+ {
-+ *buffer++ = READ (image, pixel++);
-+ }
-+}
-+
-+
- /*
- * Contracts a 64bpp image to 32bpp and then stores it using a regular 32-bit
- * store proc. Despite the type, this function expects a uint64_t buffer.
- */
- static void
- store_scanline_generic_64 (bits_image_t * image,
- int x,
- int y,
-@@ -1044,32 +1082,47 @@ fetch_pixel_generic_lossy_32 (bits_image
- pixman_contract (&result, &pixel64, 1);
-
- return result;
- }
-
- typedef struct
- {
- pixman_format_code_t format;
-+ fetch_scanline_t fetch_scanline_16;
- fetch_scanline_t fetch_scanline_32;
- fetch_scanline_t fetch_scanline_64;
- fetch_pixel_32_t fetch_pixel_32;
- fetch_pixel_64_t fetch_pixel_64;
-+ store_scanline_t store_scanline_16;
- store_scanline_t store_scanline_32;
- store_scanline_t store_scanline_64;
- } format_info_t;
-
- #define FORMAT_INFO(format) \
- { \
- PIXMAN_ ## format, \
-+ NULL, \
- fetch_scanline_ ## format, \
- fetch_scanline_generic_64, \
- fetch_pixel_ ## format, fetch_pixel_generic_64, \
-+ NULL, \
- store_scanline_ ## format, store_scanline_generic_64 \
- }
-+#define FORMAT_INFO16(format) \
-+ { \
-+ PIXMAN_ ## format, \
-+ fetch_scanline_16, \
-+ fetch_scanline_ ## format, \
-+ fetch_scanline_generic_64, \
-+ fetch_pixel_ ## format, fetch_pixel_generic_64, \
-+ store_scanline_16, \
-+ store_scanline_ ## format, store_scanline_generic_64 \
-+ }
-+
-
- static const format_info_t accessors[] =
- {
- /* 32 bpp formats */
- FORMAT_INFO (a8r8g8b8),
- FORMAT_INFO (x8r8g8b8),
- FORMAT_INFO (a8b8g8r8),
- FORMAT_INFO (x8b8g8r8),
-@@ -1079,18 +1132,18 @@ static const format_info_t accessors[] =
- FORMAT_INFO (r8g8b8x8),
- FORMAT_INFO (x14r6g6b6),
-
- /* 24bpp formats */
- FORMAT_INFO (r8g8b8),
- FORMAT_INFO (b8g8r8),
-
- /* 16bpp formats */
-- FORMAT_INFO (r5g6b5),
-- FORMAT_INFO (b5g6r5),
-+ FORMAT_INFO16 (r5g6b5),
-+ FORMAT_INFO16 (b5g6r5),
-
- FORMAT_INFO (a1r5g5b5),
- FORMAT_INFO (x1r5g5b5),
- FORMAT_INFO (a1b5g5r5),
- FORMAT_INFO (x1b5g5r5),
- FORMAT_INFO (a4r4g4b4),
- FORMAT_INFO (x4r4g4b4),
- FORMAT_INFO (a4b4g4r4),
-@@ -1132,62 +1185,64 @@ static const format_info_t accessors[] =
-
- /* 1bpp formats */
- FORMAT_INFO (a1),
- FORMAT_INFO (g1),
-
- /* Wide formats */
-
- { PIXMAN_a2r10g10b10,
-- NULL, fetch_scanline_a2r10g10b10,
-+ NULL, NULL, fetch_scanline_a2r10g10b10,
- fetch_pixel_generic_lossy_32, fetch_pixel_a2r10g10b10,
- NULL, store_scanline_a2r10g10b10 },
-
- { PIXMAN_x2r10g10b10,
-- NULL, fetch_scanline_x2r10g10b10,
-+ NULL, NULL, fetch_scanline_x2r10g10b10,
- fetch_pixel_generic_lossy_32, fetch_pixel_x2r10g10b10,
- NULL, store_scanline_x2r10g10b10 },
-
- { PIXMAN_a2b10g10r10,
-- NULL, fetch_scanline_a2b10g10r10,
-+ NULL, NULL, fetch_scanline_a2b10g10r10,
- fetch_pixel_generic_lossy_32, fetch_pixel_a2b10g10r10,
- NULL, store_scanline_a2b10g10r10 },
-
- { PIXMAN_x2b10g10r10,
-- NULL, fetch_scanline_x2b10g10r10,
-+ NULL, NULL, fetch_scanline_x2b10g10r10,
- fetch_pixel_generic_lossy_32, fetch_pixel_x2b10g10r10,
- NULL, store_scanline_x2b10g10r10 },
-
- /* YUV formats */
- { PIXMAN_yuy2,
-- fetch_scanline_yuy2, fetch_scanline_generic_64,
-+ NULL, fetch_scanline_yuy2, fetch_scanline_generic_64,
- fetch_pixel_yuy2, fetch_pixel_generic_64,
- NULL, NULL },
-
- { PIXMAN_yv12,
-- fetch_scanline_yv12, fetch_scanline_generic_64,
-+ NULL, fetch_scanline_yv12, fetch_scanline_generic_64,
- fetch_pixel_yv12, fetch_pixel_generic_64,
- NULL, NULL },
-
- { PIXMAN_null },
- };
-
- static void
- setup_accessors (bits_image_t *image)
- {
- const format_info_t *info = accessors;
-
- while (info->format != PIXMAN_null)
- {
- if (info->format == image->format)
- {
-+ image->fetch_scanline_16 = info->fetch_scanline_16;
- image->fetch_scanline_32 = info->fetch_scanline_32;
- image->fetch_scanline_64 = info->fetch_scanline_64;
- image->fetch_pixel_32 = info->fetch_pixel_32;
- image->fetch_pixel_64 = info->fetch_pixel_64;
-+ image->store_scanline_16 = info->store_scanline_16;
- image->store_scanline_32 = info->store_scanline_32;
- image->store_scanline_64 = info->store_scanline_64;
-
- return;
- }
-
- info++;
- }
-diff --git a/gfx/cairo/libpixman/src/pixman-bits-image.c b/gfx/cairo/libpixman/src/pixman-bits-image.c
---- a/gfx/cairo/libpixman/src/pixman-bits-image.c
-+++ b/gfx/cairo/libpixman/src/pixman-bits-image.c
-@@ -1247,16 +1247,31 @@ src_get_scanline_wide (pixman_iter_t *it
-
- void
- _pixman_bits_image_src_iter_init (pixman_image_t *image, pixman_iter_t *iter)
- {
- if (iter->flags & ITER_NARROW)
- iter->get_scanline = src_get_scanline_narrow;
- else
- iter->get_scanline = src_get_scanline_wide;
-+
-+}
-+
-+static uint32_t *
-+dest_get_scanline_16 (pixman_iter_t *iter, const uint32_t *mask)
-+{
-+ pixman_image_t *image = iter->image;
-+ int x = iter->x;
-+ int y = iter->y;
-+ int width = iter->width;
-+ uint32_t * buffer = iter->buffer;
-+
-+ image->bits.fetch_scanline_16 (image, x, y, width, buffer, mask);
-+
-+ return iter->buffer;
- }
-
- static uint32_t *
- dest_get_scanline_narrow (pixman_iter_t *iter, const uint32_t *mask)
- {
- pixman_image_t *image = iter->image;
- int x = iter->x;
- int y = iter->y;
-@@ -1327,16 +1342,30 @@ dest_get_scanline_wide (pixman_iter_t *i
- free (alpha);
- }
- }
-
- return iter->buffer;
- }
-
- static void
-+dest_write_back_16 (pixman_iter_t *iter)
-+{
-+ bits_image_t * image = &iter->image->bits;
-+ int x = iter->x;
-+ int y = iter->y;
-+ int width = iter->width;
-+ const uint32_t *buffer = iter->buffer;
-+
-+ image->store_scanline_16 (image, x, y, width, buffer);
-+
-+ iter->y++;
-+}
-+
-+static void
- dest_write_back_narrow (pixman_iter_t *iter)
- {
- bits_image_t * image = &iter->image->bits;
- int x = iter->x;
- int y = iter->y;
- int width = iter->width;
- const uint32_t *buffer = iter->buffer;
-
-@@ -1375,28 +1404,41 @@ dest_write_back_wide (pixman_iter_t *ite
- }
-
- iter->y++;
- }
-
- void
- _pixman_bits_image_dest_iter_init (pixman_image_t *image, pixman_iter_t *iter)
- {
-- if (iter->flags & ITER_NARROW)
-+ if (iter->flags & ITER_16)
-+ {
-+ if ((iter->flags & (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA)) ==
-+ (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA))
-+ {
-+ iter->get_scanline = _pixman_iter_get_scanline_noop;
-+ }
-+ else
-+ {
-+ iter->get_scanline = dest_get_scanline_16;
-+ }
-+ iter->write_back = dest_write_back_16;
-+ }
-+ else if (iter->flags & ITER_NARROW)
- {
- if ((iter->flags & (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA)) ==
- (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA))
- {
- iter->get_scanline = _pixman_iter_get_scanline_noop;
- }
- else
- {
- iter->get_scanline = dest_get_scanline_narrow;
- }
--
-+
- iter->write_back = dest_write_back_narrow;
- }
- else
- {
- iter->get_scanline = dest_get_scanline_wide;
- iter->write_back = dest_write_back_wide;
- }
- }
-diff --git a/gfx/cairo/libpixman/src/pixman-combine16.c b/gfx/cairo/libpixman/src/pixman-combine16.c
-new file mode 100644
---- /dev/null
-+++ b/gfx/cairo/libpixman/src/pixman-combine16.c
-@@ -0,0 +1,124 @@
-+#ifdef HAVE_CONFIG_H
-+#include <config.h>
-+#endif
-+
-+#include <math.h>
-+#include <string.h>
-+
-+#include "pixman-private.h"
-+
-+#include "pixman-combine32.h"
-+
-+static force_inline uint32_t
-+combine_mask (const uint32_t src, const uint32_t mask)
-+{
-+ uint32_t s, m;
-+
-+ m = mask >> A_SHIFT;
-+
-+ if (!m)
-+ return 0;
-+ s = src;
-+
-+ UN8x4_MUL_UN8 (s, m);
-+
-+ return s;
-+}
-+
-+static inline uint32_t convert_0565_to_8888(uint16_t color)
-+{
-+ return CONVERT_0565_TO_8888(color);
-+}
-+
-+static inline uint16_t convert_8888_to_0565(uint32_t color)
-+{
-+ return CONVERT_8888_TO_0565(color);
-+}
-+
-+static void
-+combine_src_u (pixman_implementation_t *imp,
-+ pixman_op_t op,
-+ uint32_t * dest,
-+ const uint32_t * src,
-+ const uint32_t * mask,
-+ int width)
-+{
-+ int i;
-+
-+ if (!mask)
-+ memcpy (dest, src, width * sizeof (uint16_t));
-+ else
-+ {
-+ uint16_t *d = (uint16_t*)dest;
-+ uint16_t *src16 = (uint16_t*)src;
-+ for (i = 0; i < width; ++i)
-+ {
-+ if ((*mask & 0xff000000) == 0xff000000) {
-+ // it's likely worth special casing
-+ // fully opaque because it avoids
-+ // the cost of conversion as well the multiplication
-+ *(d + i) = *src16;
-+ } else {
-+ // the mask is still 32bits
-+ uint32_t s = combine_mask (convert_0565_to_8888(*src16), *mask);
-+ *(d + i) = convert_8888_to_0565(s);
-+ }
-+ mask++;
-+ src16++;
-+ }
-+ }
-+
-+}
-+
-+static void
-+combine_over_u (pixman_implementation_t *imp,
-+ pixman_op_t op,
-+ uint32_t * dest,
-+ const uint32_t * src,
-+ const uint32_t * mask,
-+ int width)
-+{
-+ int i;
-+
-+ if (!mask)
-+ memcpy (dest, src, width * sizeof (uint16_t));
-+ else
-+ {
-+ uint16_t *d = (uint16_t*)dest;
-+ uint16_t *src16 = (uint16_t*)src;
-+ for (i = 0; i < width; ++i)
-+ {
-+ if ((*mask & 0xff000000) == 0xff000000) {
-+ // it's likely worth special casing
-+ // fully opaque because it avoids
-+ // the cost of conversion as well the multiplication
-+ *(d + i) = *src16;
-+ } else if ((*mask & 0xff000000) == 0x00000000) {
-+ // keep the dest the same
-+ } else {
-+ // the mask is still 32bits
-+ uint32_t s = combine_mask (convert_0565_to_8888(*src16), *mask);
-+ uint32_t ia = ALPHA_8 (~s);
-+ uint32_t d32 = convert_0565_to_8888(*(d + i));
-+ UN8x4_MUL_UN8_ADD_UN8x4 (d32, ia, s);
-+ *(d + i) = convert_8888_to_0565(d32);
-+ }
-+ mask++;
-+ src16++;
-+ }
-+ }
-+
-+}
-+
-+
-+void
-+_pixman_setup_combiner_functions_16 (pixman_implementation_t *imp)
-+{
-+ int i;
-+ for (i = 0; i < PIXMAN_N_OPERATORS; i++) {
-+ imp->combine_16[i] = NULL;
-+ }
-+ imp->combine_16[PIXMAN_OP_SRC] = combine_src_u;
-+ imp->combine_16[PIXMAN_OP_OVER] = combine_over_u;
-+}
-+
-diff --git a/gfx/cairo/libpixman/src/pixman-general.c b/gfx/cairo/libpixman/src/pixman-general.c
---- a/gfx/cairo/libpixman/src/pixman-general.c
-+++ b/gfx/cairo/libpixman/src/pixman-general.c
-@@ -106,46 +106,61 @@ general_composite_rect (pixman_implemen
- PIXMAN_COMPOSITE_ARGS (info);
- uint64_t stack_scanline_buffer[(SCANLINE_BUFFER_LENGTH * 3 + 7) / 8];
- uint8_t *scanline_buffer = (uint8_t *) stack_scanline_buffer;
- uint8_t *src_buffer, *mask_buffer, *dest_buffer;
- pixman_iter_t src_iter, mask_iter, dest_iter;
- pixman_combine_32_func_t compose;
- pixman_bool_t component_alpha;
- iter_flags_t narrow, src_flags;
-+ iter_flags_t rgb16;
- int Bpp;
- int i;
-
- if ((src_image->common.flags & FAST_PATH_NARROW_FORMAT) &&
- (!mask_image || mask_image->common.flags & FAST_PATH_NARROW_FORMAT) &&
- (dest_image->common.flags & FAST_PATH_NARROW_FORMAT))
- {
- narrow = ITER_NARROW;
- Bpp = 4;
- }
- else
- {
- narrow = 0;
- Bpp = 8;
- }
-
-+ // XXX: This special casing is bad. Ideally, we'd keep the general code general perhaps
-+ // by having it deal more specifically with different intermediate formats
-+ if (
-+ (dest_image->common.flags & FAST_PATH_16_FORMAT && (src_image->type == LINEAR || src_image->type == RADIAL)) &&
-+ ( op == PIXMAN_OP_SRC ||
-+ (op == PIXMAN_OP_OVER && (src_image->common.flags & FAST_PATH_IS_OPAQUE))
-+ )
-+ ) {
-+ rgb16 = ITER_16;
-+ } else {
-+ rgb16 = 0;
-+ }
-+
-+
- if (width * Bpp > SCANLINE_BUFFER_LENGTH)
- {
- scanline_buffer = pixman_malloc_abc (width, 3, Bpp);
-
- if (!scanline_buffer)
- return;
- }
-
- src_buffer = scanline_buffer;
- mask_buffer = src_buffer + width * Bpp;
- dest_buffer = mask_buffer + width * Bpp;
-
- /* src iter */
-- src_flags = narrow | op_flags[op].src;
-+ src_flags = narrow | op_flags[op].src | rgb16;
-
- _pixman_implementation_src_iter_init (imp->toplevel, &src_iter, src_image,
- src_x, src_y, width, height,
- src_buffer, src_flags);
-
- /* mask iter */
- if ((src_flags & (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB)) ==
- (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB))
-@@ -164,20 +179,20 @@ general_composite_rect (pixman_implemen
-
- _pixman_implementation_src_iter_init (
- imp->toplevel, &mask_iter, mask_image, mask_x, mask_y, width, height,
- mask_buffer, narrow | (component_alpha? 0 : ITER_IGNORE_RGB));
-
- /* dest iter */
- _pixman_implementation_dest_iter_init (
- imp->toplevel, &dest_iter, dest_image, dest_x, dest_y, width, height,
-- dest_buffer, narrow | op_flags[op].dst);
-+ dest_buffer, narrow | op_flags[op].dst | rgb16);
-
- compose = _pixman_implementation_lookup_combiner (
-- imp->toplevel, op, component_alpha, narrow);
-+ imp->toplevel, op, component_alpha, narrow, !!rgb16);
-
- if (!compose)
- return;
-
- for (i = 0; i < height; ++i)
- {
- uint32_t *s, *m, *d;
-
-@@ -234,16 +249,17 @@ general_fill (pixman_implementation_t *i
- return FALSE;
- }
-
- pixman_implementation_t *
- _pixman_implementation_create_general (void)
- {
- pixman_implementation_t *imp = _pixman_implementation_create (NULL, general_fast_path);
-
-+ _pixman_setup_combiner_functions_16 (imp);
- _pixman_setup_combiner_functions_32 (imp);
- _pixman_setup_combiner_functions_64 (imp);
-
- imp->blt = general_blt;
- imp->fill = general_fill;
- imp->src_iter_init = general_src_iter_init;
- imp->dest_iter_init = general_dest_iter_init;
-
-diff --git a/gfx/cairo/libpixman/src/pixman-image.c b/gfx/cairo/libpixman/src/pixman-image.c
---- a/gfx/cairo/libpixman/src/pixman-image.c
-+++ b/gfx/cairo/libpixman/src/pixman-image.c
-@@ -451,16 +451,20 @@ compute_image_info (pixman_image_t *imag
- flags |= FAST_PATH_IS_OPAQUE;
- }
-
- if (image->bits.read_func || image->bits.write_func)
- flags &= ~FAST_PATH_NO_ACCESSORS;
-
- if (PIXMAN_FORMAT_IS_WIDE (image->bits.format))
- flags &= ~FAST_PATH_NARROW_FORMAT;
-+
-+ if (image->bits.format == PIXMAN_r5g6b5)
-+ flags |= FAST_PATH_16_FORMAT;
-+
- break;
-
- case RADIAL:
- code = PIXMAN_unknown;
-
- /*
- * As explained in pixman-radial-gradient.c, every point of
- * the plane has a valid associated radius (and thus will be
-diff --git a/gfx/cairo/libpixman/src/pixman-implementation.c b/gfx/cairo/libpixman/src/pixman-implementation.c
---- a/gfx/cairo/libpixman/src/pixman-implementation.c
-+++ b/gfx/cairo/libpixman/src/pixman-implementation.c
-@@ -101,45 +101,51 @@ pixman_implementation_t *
- imp->fill = delegate_fill;
- imp->src_iter_init = delegate_src_iter_init;
- imp->dest_iter_init = delegate_dest_iter_init;
-
- imp->fast_paths = fast_paths;
-
- for (i = 0; i < PIXMAN_N_OPERATORS; ++i)
- {
-+ imp->combine_16[i] = NULL;
- imp->combine_32[i] = NULL;
- imp->combine_64[i] = NULL;
- imp->combine_32_ca[i] = NULL;
- imp->combine_64_ca[i] = NULL;
- }
-
- return imp;
- }
-
- pixman_combine_32_func_t
- _pixman_implementation_lookup_combiner (pixman_implementation_t *imp,
- pixman_op_t op,
- pixman_bool_t component_alpha,
-- pixman_bool_t narrow)
-+ pixman_bool_t narrow,
-+ pixman_bool_t rgb16)
- {
- pixman_combine_32_func_t f;
-
- do
- {
- pixman_combine_32_func_t (*combiners[]) =
- {
- (pixman_combine_32_func_t *)imp->combine_64,
- (pixman_combine_32_func_t *)imp->combine_64_ca,
- imp->combine_32,
- imp->combine_32_ca,
-+ (pixman_combine_32_func_t *)imp->combine_16,
-+ NULL,
- };
--
-- f = combiners[component_alpha | (narrow << 1)][op];
--
-+ if (rgb16) {
-+ f = combiners[4][op];
-+ } else {
-+ f = combiners[component_alpha + (narrow << 1)][op];
-+ }
- imp = imp->delegate;
- }
- while (!f);
-
- return f;
- }
-
- pixman_bool_t
-diff --git a/gfx/cairo/libpixman/src/pixman-linear-gradient.c b/gfx/cairo/libpixman/src/pixman-linear-gradient.c
---- a/gfx/cairo/libpixman/src/pixman-linear-gradient.c
-+++ b/gfx/cairo/libpixman/src/pixman-linear-gradient.c
-@@ -217,42 +217,185 @@ linear_get_scanline_narrow (pixman_iter_
- }
- }
-
- iter->y++;
-
- return iter->buffer;
- }
-
-+static uint16_t convert_8888_to_0565(uint32_t color)
-+{
-+ return CONVERT_8888_TO_0565(color);
-+}
-+
-+static uint32_t *
-+linear_get_scanline_16 (pixman_iter_t *iter,
-+ const uint32_t *mask)
-+{
-+ pixman_image_t *image = iter->image;
-+ int x = iter->x;
-+ int y = iter->y;
-+ int width = iter->width;
-+ uint16_t * buffer = (uint16_t*)iter->buffer;
-+
-+ pixman_vector_t v, unit;
-+ pixman_fixed_32_32_t l;
-+ pixman_fixed_48_16_t dx, dy;
-+ gradient_t *gradient = (gradient_t *)image;
-+ linear_gradient_t *linear = (linear_gradient_t *)image;
-+ uint16_t *end = buffer + width;
-+ pixman_gradient_walker_t walker;
-+
-+ _pixman_gradient_walker_init (&walker, gradient, image->common.repeat);
-+
-+ /* reference point is the center of the pixel */
-+ v.vector[0] = pixman_int_to_fixed (x) + pixman_fixed_1 / 2;
-+ v.vector[1] = pixman_int_to_fixed (y) + pixman_fixed_1 / 2;
-+ v.vector[2] = pixman_fixed_1;
-+
-+ if (image->common.transform)
-+ {
-+ if (!pixman_transform_point_3d (image->common.transform, &v))
-+ return iter->buffer;
-+
-+ unit.vector[0] = image->common.transform->matrix[0][0];
-+ unit.vector[1] = image->common.transform->matrix[1][0];
-+ unit.vector[2] = image->common.transform->matrix[2][0];
-+ }
-+ else
-+ {
-+ unit.vector[0] = pixman_fixed_1;
-+ unit.vector[1] = 0;
-+ unit.vector[2] = 0;
-+ }
-+
-+ dx = linear->p2.x - linear->p1.x;
-+ dy = linear->p2.y - linear->p1.y;
-+
-+ l = dx * dx + dy * dy;
-+
-+ if (l == 0 || unit.vector[2] == 0)
-+ {
-+ /* affine transformation only */
-+ pixman_fixed_32_32_t t, next_inc;
-+ double inc;
-+
-+ if (l == 0 || v.vector[2] == 0)
-+ {
-+ t = 0;
-+ inc = 0;
-+ }
-+ else
-+ {
-+ double invden, v2;
-+
-+ invden = pixman_fixed_1 * (double) pixman_fixed_1 /
-+ (l * (double) v.vector[2]);
-+ v2 = v.vector[2] * (1. / pixman_fixed_1);
-+ t = ((dx * v.vector[0] + dy * v.vector[1]) -
-+ (dx * linear->p1.x + dy * linear->p1.y) * v2) * invden;
-+ inc = (dx * unit.vector[0] + dy * unit.vector[1]) * invden;
-+ }
-+ next_inc = 0;
-+
-+ if (((pixman_fixed_32_32_t )(inc * width)) == 0)
-+ {
-+ register uint16_t color;
-+
-+ color = convert_8888_to_0565(_pixman_gradient_walker_pixel (&walker, t));
-+ while (buffer < end)
-+ *buffer++ = color;
-+ }
-+ else
-+ {
-+ int i;
-+
-+ i = 0;
-+ while (buffer < end)
-+ {
-+ if (!mask || *mask++)
-+ {
-+ *buffer = convert_8888_to_0565(_pixman_gradient_walker_pixel (&walker,
-+ t + next_inc));
-+ }
-+ i++;
-+ next_inc = inc * i;
-+ buffer++;
-+ }
-+ }
-+ }
-+ else
-+ {
-+ /* projective transformation */
-+ double t;
-+
-+ t = 0;
-+
-+ while (buffer < end)
-+ {
-+ if (!mask || *mask++)
-+ {
-+ if (v.vector[2] != 0)
-+ {
-+ double invden, v2;
-+
-+ invden = pixman_fixed_1 * (double) pixman_fixed_1 /
-+ (l * (double) v.vector[2]);
-+ v2 = v.vector[2] * (1. / pixman_fixed_1);
-+ t = ((dx * v.vector[0] + dy * v.vector[1]) -
-+ (dx * linear->p1.x + dy * linear->p1.y) * v2) * invden;
-+ }
-+
-+ *buffer = convert_8888_to_0565(_pixman_gradient_walker_pixel (&walker, t));
-+ }
-+
-+ ++buffer;
-+
-+ v.vector[0] += unit.vector[0];
-+ v.vector[1] += unit.vector[1];
-+ v.vector[2] += unit.vector[2];
-+ }
-+ }
-+
-+ iter->y++;
-+
-+ return iter->buffer;
-+}
-+
- static uint32_t *
- linear_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
- {
- uint32_t *buffer = linear_get_scanline_narrow (iter, NULL);
-
- pixman_expand ((uint64_t *)buffer, buffer, PIXMAN_a8r8g8b8, iter->width);
-
- return buffer;
- }
-
- void
- _pixman_linear_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter)
- {
- if (linear_gradient_is_horizontal (
- iter->image, iter->x, iter->y, iter->width, iter->height))
- {
-- if (iter->flags & ITER_NARROW)
-+ if (iter->flags & ITER_16)
-+ linear_get_scanline_16 (iter, NULL);
-+ else if (iter->flags & ITER_NARROW)
- linear_get_scanline_narrow (iter, NULL);
- else
- linear_get_scanline_wide (iter, NULL);
-
- iter->get_scanline = _pixman_iter_get_scanline_noop;
- }
- else
- {
-- if (iter->flags & ITER_NARROW)
-+ if (iter->flags & ITER_16)
-+ iter->get_scanline = linear_get_scanline_16;
-+ else if (iter->flags & ITER_NARROW)
- iter->get_scanline = linear_get_scanline_narrow;
- else
- iter->get_scanline = linear_get_scanline_wide;
- }
- }
-
- PIXMAN_EXPORT pixman_image_t *
- pixman_image_create_linear_gradient (pixman_point_fixed_t * p1,
-diff --git a/gfx/cairo/libpixman/src/pixman-private.h b/gfx/cairo/libpixman/src/pixman-private.h
---- a/gfx/cairo/libpixman/src/pixman-private.h
-+++ b/gfx/cairo/libpixman/src/pixman-private.h
-@@ -152,24 +152,28 @@ struct bits_image
- int height;
- uint32_t * bits;
- uint32_t * free_me;
- int rowstride; /* in number of uint32_t's */
-
- fetch_scanline_t get_scanline_32;
- fetch_scanline_t get_scanline_64;
-
-+ fetch_scanline_t fetch_scanline_16;
-+
- fetch_scanline_t fetch_scanline_32;
- fetch_pixel_32_t fetch_pixel_32;
- store_scanline_t store_scanline_32;
-
- fetch_scanline_t fetch_scanline_64;
- fetch_pixel_64_t fetch_pixel_64;
- store_scanline_t store_scanline_64;
-
-+ store_scanline_t store_scanline_16;
-+
- /* Used for indirect access to the bits */
- pixman_read_memory_func_t read_func;
- pixman_write_memory_func_t write_func;
- };
-
- union pixman_image
- {
- image_type_t type;
-@@ -202,17 +206,24 @@ typedef enum
- * destination.
- *
- * When he destination is xRGB, this is useful knowledge, because then
- * we can treat it as if it were ARGB, which means in some cases we can
- * avoid copying it to a temporary buffer.
- */
- ITER_LOCALIZED_ALPHA = (1 << 1),
- ITER_IGNORE_ALPHA = (1 << 2),
-- ITER_IGNORE_RGB = (1 << 3)
-+ ITER_IGNORE_RGB = (1 << 3),
-+
-+ /* With the addition of ITER_16 we now have two flags that to represent
-+ * 3 pipelines. This means that there can be an invalid state when
-+ * both ITER_NARROW and ITER_16 are set. In this case
-+ * ITER_16 overrides NARROW and we should use the 16 bit pipeline.
-+ * Note: ITER_16 still has a 32 bit mask, which is a bit weird. */
-+ ITER_16 = (1 << 4)
- } iter_flags_t;
-
- struct pixman_iter_t
- {
- /* These are initialized by _pixman_implementation_{src,dest}_init */
- pixman_image_t * image;
- uint32_t * buffer;
- int x, y;
-@@ -429,16 +440,17 @@ typedef pixman_bool_t (*pixman_fill_func
- int x,
- int y,
- int width,
- int height,
- uint32_t xor);
- typedef void (*pixman_iter_init_func_t) (pixman_implementation_t *imp,
- pixman_iter_t *iter);
-
-+void _pixman_setup_combiner_functions_16 (pixman_implementation_t *imp);
- void _pixman_setup_combiner_functions_32 (pixman_implementation_t *imp);
- void _pixman_setup_combiner_functions_64 (pixman_implementation_t *imp);
-
- typedef struct
- {
- pixman_op_t op;
- pixman_format_code_t src_format;
- uint32_t src_flags;
-@@ -459,32 +471,34 @@ struct pixman_implementation_t
- pixman_fill_func_t fill;
- pixman_iter_init_func_t src_iter_init;
- pixman_iter_init_func_t dest_iter_init;
-
- pixman_combine_32_func_t combine_32[PIXMAN_N_OPERATORS];
- pixman_combine_32_func_t combine_32_ca[PIXMAN_N_OPERATORS];
- pixman_combine_64_func_t combine_64[PIXMAN_N_OPERATORS];
- pixman_combine_64_func_t combine_64_ca[PIXMAN_N_OPERATORS];
-+ pixman_combine_64_func_t combine_16[PIXMAN_N_OPERATORS];
- };
-
- uint32_t
- _pixman_image_get_solid (pixman_implementation_t *imp,
- pixman_image_t * image,
- pixman_format_code_t format);
-
- pixman_implementation_t *
- _pixman_implementation_create (pixman_implementation_t *delegate,
- const pixman_fast_path_t *fast_paths);
-
- pixman_combine_32_func_t
- _pixman_implementation_lookup_combiner (pixman_implementation_t *imp,
- pixman_op_t op,
- pixman_bool_t component_alpha,
-- pixman_bool_t wide);
-+ pixman_bool_t wide,
-+ pixman_bool_t rgb16);
-
- pixman_bool_t
- _pixman_implementation_blt (pixman_implementation_t *imp,
- uint32_t * src_bits,
- uint32_t * dst_bits,
- int src_stride,
- int dst_stride,
- int src_bpp,
-@@ -613,16 +627,17 @@ uint32_t *
- #define FAST_PATH_Y_UNIT_ZERO (1 << 18)
- #define FAST_PATH_BILINEAR_FILTER (1 << 19)
- #define FAST_PATH_ROTATE_90_TRANSFORM (1 << 20)
- #define FAST_PATH_ROTATE_180_TRANSFORM (1 << 21)
- #define FAST_PATH_ROTATE_270_TRANSFORM (1 << 22)
- #define FAST_PATH_SAMPLES_COVER_CLIP_NEAREST (1 << 23)
- #define FAST_PATH_SAMPLES_COVER_CLIP_BILINEAR (1 << 24)
- #define FAST_PATH_BITS_IMAGE (1 << 25)
-+#define FAST_PATH_16_FORMAT (1 << 26)
-
- #define FAST_PATH_PAD_REPEAT \
- (FAST_PATH_NO_NONE_REPEAT | \
- FAST_PATH_NO_NORMAL_REPEAT | \
- FAST_PATH_NO_REFLECT_REPEAT)
-
- #define FAST_PATH_NORMAL_REPEAT \
- (FAST_PATH_NO_NONE_REPEAT | \
-diff --git a/gfx/cairo/libpixman/src/pixman-radial-gradient.c b/gfx/cairo/libpixman/src/pixman-radial-gradient.c
---- a/gfx/cairo/libpixman/src/pixman-radial-gradient.c
-+++ b/gfx/cairo/libpixman/src/pixman-radial-gradient.c
-@@ -395,35 +395,289 @@ radial_get_scanline_narrow (pixman_iter_
- v.vector[2] += unit.vector[2];
- }
- }
-
- iter->y++;
- return iter->buffer;
- }
-
-+static uint16_t convert_8888_to_0565(uint32_t color)
-+{
-+ return CONVERT_8888_TO_0565(color);
-+}
-+
-+static uint32_t *
-+radial_get_scanline_16 (pixman_iter_t *iter, const uint32_t *mask)
-+{
-+ /*
-+ * Implementation of radial gradients following the PDF specification.
-+ * See section 8.7.4.5.4 Type 3 (Radial) Shadings of the PDF Reference
-+ * Manual (PDF 32000-1:2008 at the time of this writing).
-+ *
-+ * In the radial gradient problem we are given two circles (câ‚,râ‚) and
-+ * (câ‚‚,râ‚‚) that define the gradient itself.
-+ *
-+ * Mathematically the gradient can be defined as the family of circles
-+ *
-+ * ((1-t)·c₠+ t·(c₂), (1-t)·r₠+ t·r₂)
-+ *
-+ * excluding those circles whose radius would be < 0. When a point
-+ * belongs to more than one circle, the one with a bigger t is the only
-+ * one that contributes to its color. When a point does not belong
-+ * to any of the circles, it is transparent black, i.e. RGBA (0, 0, 0, 0).
-+ * Further limitations on the range of values for t are imposed when
-+ * the gradient is not repeated, namely t must belong to [0,1].
-+ *
-+ * The graphical result is the same as drawing the valid (radius > 0)
-+ * circles with increasing t in [-inf, +inf] (or in [0,1] if the gradient
-+ * is not repeated) using SOURCE operator composition.
-+ *
-+ * It looks like a cone pointing towards the viewer if the ending circle
-+ * is smaller than the starting one, a cone pointing inside the page if
-+ * the starting circle is the smaller one and like a cylinder if they
-+ * have the same radius.
-+ *
-+ * What we actually do is, given the point whose color we are interested
-+ * in, compute the t values for that point, solving for t in:
-+ *
-+ * length((1-t)·c₠+ t·(c₂) - p) = (1-t)·r₠+ t·r₂
-+ *
-+ * Let's rewrite it in a simpler way, by defining some auxiliary
-+ * variables:
-+ *
-+ * cd = câ‚‚ - câ‚
-+ * pd = p - câ‚
-+ * dr = râ‚‚ - râ‚
-+ * length(t·cd - pd) = r₠+ t·dr
-+ *
-+ * which actually means
-+ *
-+ * hypot(t·cdx - pdx, t·cdy - pdy) = r₠+ t·dr
-+ *
-+ * or
-+ *
-+ * ⎷((t·cdx - pdx)² + (t·cdy - pdy)²) = r₠+ t·dr.
-+ *
-+ * If we impose (as stated earlier) that r₠+ t·dr >= 0, it becomes:
-+ *
-+ * (t·cdx - pdx)² + (t·cdy - pdy)² = (r₠+ t·dr)²
-+ *
-+ * where we can actually expand the squares and solve for t:
-+ *
-+ * t²cdx² - 2t·cdx·pdx + pdx² + t²cdy² - 2t·cdy·pdy + pdy² =
-+ * = r₲ + 2·râ‚·t·dr + t²·dr²
-+ *
-+ * (cdx² + cdy² - dr²)t² - 2(cdx·pdx + cdy·pdy + râ‚·dr)t +
-+ * (pdx² + pdy² - r₲) = 0
-+ *
-+ * A = cdx² + cdy² - dr²
-+ * B = pdx·cdx + pdy·cdy + râ‚·dr
-+ * C = pdx² + pdy² - r₲
-+ * At² - 2Bt + C = 0
-+ *
-+ * The solutions (unless the equation degenerates because of A = 0) are:
-+ *
-+ * t = (B ± ⎷(B² - A·C)) / A
-+ *
-+ * The solution we are going to prefer is the bigger one, unless the
-+ * radius associated to it is negative (or it falls outside the valid t
-+ * range).
-+ *
-+ * Additional observations (useful for optimizations):
-+ * A does not depend on p
-+ *
-+ * A < 0 <=> one of the two circles completely contains the other one
-+ * <=> for every p, the radiuses associated with the two t solutions
-+ * have opposite sign
-+ */
-+ pixman_image_t *image = iter->image;
-+ int x = iter->x;
-+ int y = iter->y;
-+ int width = iter->width;
-+ uint16_t *buffer = iter->buffer;
-+
-+ gradient_t *gradient = (gradient_t *)image;
-+ radial_gradient_t *radial = (radial_gradient_t *)image;
-+ uint16_t *end = buffer + width;
-+ pixman_gradient_walker_t walker;
-+ pixman_vector_t v, unit;
-+
-+ /* reference point is the center of the pixel */
-+ v.vector[0] = pixman_int_to_fixed (x) + pixman_fixed_1 / 2;
-+ v.vector[1] = pixman_int_to_fixed (y) + pixman_fixed_1 / 2;
-+ v.vector[2] = pixman_fixed_1;
-+
-+ _pixman_gradient_walker_init (&walker, gradient, image->common.repeat);
-+
-+ if (image->common.transform)
-+ {
-+ if (!pixman_transform_point_3d (image->common.transform, &v))
-+ return iter->buffer;
-+
-+ unit.vector[0] = image->common.transform->matrix[0][0];
-+ unit.vector[1] = image->common.transform->matrix[1][0];
-+ unit.vector[2] = image->common.transform->matrix[2][0];
-+ }
-+ else
-+ {
-+ unit.vector[0] = pixman_fixed_1;
-+ unit.vector[1] = 0;
-+ unit.vector[2] = 0;
-+ }
-+
-+ if (unit.vector[2] == 0 && v.vector[2] == pixman_fixed_1)
-+ {
-+ /*
-+ * Given:
-+ *
-+ * t = (B ± ⎷(B² - A·C)) / A
-+ *
-+ * where
-+ *
-+ * A = cdx² + cdy² - dr²
-+ * B = pdx·cdx + pdy·cdy + râ‚·dr
-+ * C = pdx² + pdy² - r₲
-+ * det = B² - A·C
-+ *
-+ * Since we have an affine transformation, we know that (pdx, pdy)
-+ * increase linearly with each pixel,
-+ *
-+ * pdx = pdx₀ + n·ux,
-+ * pdy = pdy₀ + n·uy,
-+ *
-+ * we can then express B, C and det through multiple differentiation.
-+ */
-+ pixman_fixed_32_32_t b, db, c, dc, ddc;
-+
-+ /* warning: this computation may overflow */
-+ v.vector[0] -= radial->c1.x;
-+ v.vector[1] -= radial->c1.y;
-+
-+ /*
-+ * B and C are computed and updated exactly.
-+ * If fdot was used instead of dot, in the worst case it would
-+ * lose 11 bits of precision in each of the multiplication and
-+ * summing up would zero out all the bit that were preserved,
-+ * thus making the result 0 instead of the correct one.
-+ * This would mean a worst case of unbound relative error or
-+ * about 2^10 absolute error
-+ */
-+ b = dot (v.vector[0], v.vector[1], radial->c1.radius,
-+ radial->delta.x, radial->delta.y, radial->delta.radius);
-+ db = dot (unit.vector[0], unit.vector[1], 0,
-+ radial->delta.x, radial->delta.y, 0);
-+
-+ c = dot (v.vector[0], v.vector[1],
-+ -((pixman_fixed_48_16_t) radial->c1.radius),
-+ v.vector[0], v.vector[1], radial->c1.radius);
-+ dc = dot (2 * (pixman_fixed_48_16_t) v.vector[0] + unit.vector[0],
-+ 2 * (pixman_fixed_48_16_t) v.vector[1] + unit.vector[1],
-+ 0,
-+ unit.vector[0], unit.vector[1], 0);
-+ ddc = 2 * dot (unit.vector[0], unit.vector[1], 0,
-+ unit.vector[0], unit.vector[1], 0);
-+
-+ while (buffer < end)
-+ {
-+ if (!mask || *mask++)
-+ {
-+ *buffer = convert_8888_to_0565(
-+ radial_compute_color (radial->a, b, c,
-+ radial->inva,
-+ radial->delta.radius,
-+ radial->mindr,
-+ &walker,
-+ image->common.repeat));
-+ }
-+
-+ b += db;
-+ c += dc;
-+ dc += ddc;
-+ ++buffer;
-+ }
-+ }
-+ else
-+ {
-+ /* projective */
-+ /* Warning:
-+ * error propagation guarantees are much looser than in the affine case
-+ */
-+ while (buffer < end)
-+ {
-+ if (!mask || *mask++)
-+ {
-+ if (v.vector[2] != 0)
-+ {
-+ double pdx, pdy, invv2, b, c;
-+
-+ invv2 = 1. * pixman_fixed_1 / v.vector[2];
-+
-+ pdx = v.vector[0] * invv2 - radial->c1.x;
-+ /* / pixman_fixed_1 */
-+
-+ pdy = v.vector[1] * invv2 - radial->c1.y;
-+ /* / pixman_fixed_1 */
-+
-+ b = fdot (pdx, pdy, radial->c1.radius,
-+ radial->delta.x, radial->delta.y,
-+ radial->delta.radius);
-+ /* / pixman_fixed_1 / pixman_fixed_1 */
-+
-+ c = fdot (pdx, pdy, -radial->c1.radius,
-+ pdx, pdy, radial->c1.radius);
-+ /* / pixman_fixed_1 / pixman_fixed_1 */
-+
-+ *buffer = convert_8888_to_0565 (
-+ radial_compute_color (radial->a, b, c,
-+ radial->inva,
-+ radial->delta.radius,
-+ radial->mindr,
-+ &walker,
-+ image->common.repeat));
-+ }
-+ else
-+ {
-+ *buffer = 0;
-+ }
-+ }
-+
-+ ++buffer;
-+
-+ v.vector[0] += unit.vector[0];
-+ v.vector[1] += unit.vector[1];
-+ v.vector[2] += unit.vector[2];
-+ }
-+ }
-+
-+ iter->y++;
-+ return iter->buffer;
-+}
- static uint32_t *
- radial_get_scanline_wide (pixman_iter_t *iter, const uint32_t *mask)
- {
- uint32_t *buffer = radial_get_scanline_narrow (iter, NULL);
-
- pixman_expand ((uint64_t *)buffer, buffer, PIXMAN_a8r8g8b8, iter->width);
-
- return buffer;
- }
-
- void
- _pixman_radial_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter)
- {
-- if (iter->flags & ITER_NARROW)
-+ if (iter->flags & ITER_16)
-+ iter->get_scanline = radial_get_scanline_16;
-+ else if (iter->flags & ITER_NARROW)
- iter->get_scanline = radial_get_scanline_narrow;
- else
- iter->get_scanline = radial_get_scanline_wide;
- }
-
-+
- PIXMAN_EXPORT pixman_image_t *
- pixman_image_create_radial_gradient (pixman_point_fixed_t * inner,
- pixman_point_fixed_t * outer,
- pixman_fixed_t inner_radius,
- pixman_fixed_t outer_radius,
- const pixman_gradient_stop_t *stops,
- int n_stops)
- {
diff --git a/gfx/cairo/pixman-8888-over-565.patch b/gfx/cairo/pixman-8888-over-565.patch
deleted file mode 100644
index d6ab4618f..000000000
--- a/gfx/cairo/pixman-8888-over-565.patch
+++ /dev/null
@@ -1,712 +0,0 @@
-changeset: 96613:3e003f0b8026
-tag: 2pass
-tag: qbase
-tag: qtip
-tag: tip
-user: Jeff Muizelaar <jmuizelaar@mozilla.com>
-date: Thu May 17 19:23:53 2012 -0400
-summary: Bug 757878. Add a fast path for 8888_over_565 with NEON. r=bgirard,joe
-
-diff --git a/gfx/cairo/libpixman/src/pixman-arm-common.h b/gfx/cairo/libpixman/src/pixman-arm-common.h
---- a/gfx/cairo/libpixman/src/pixman-arm-common.h
-+++ b/gfx/cairo/libpixman/src/pixman-arm-common.h
-@@ -355,26 +355,26 @@ scaled_bilinear_scanline_##cputype##_##n
- if ((flags & SKIP_ZERO_SRC) && zero_src) \
- return; \
- pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
- dst, src_top, src_bottom, wt, wb, vx, unit_x, w); \
- } \
- \
- FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \
- scaled_bilinear_scanline_##cputype##_##name##_##op, \
-- src_type, uint32_t, dst_type, COVER, FLAG_NONE) \
-+ NULL, src_type, uint32_t, dst_type, COVER, FLAG_NONE) \
- FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \
- scaled_bilinear_scanline_##cputype##_##name##_##op, \
-- src_type, uint32_t, dst_type, NONE, FLAG_NONE) \
-+ NULL, src_type, uint32_t, dst_type, NONE, FLAG_NONE) \
- FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \
- scaled_bilinear_scanline_##cputype##_##name##_##op, \
-- src_type, uint32_t, dst_type, PAD, FLAG_NONE) \
-+ NULL, src_type, uint32_t, dst_type, PAD, FLAG_NONE) \
- FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_normal_##op, \
- scaled_bilinear_scanline_##cputype##_##name##_##op, \
-- src_type, uint32_t, dst_type, NORMAL, \
-+ NULL, src_type, uint32_t, dst_type, NORMAL, \
- FLAG_NONE)
-
-
- #define PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_A8_DST(flags, cputype, name, op, \
- src_type, dst_type) \
- void \
- pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
- dst_type * dst, \
-@@ -404,25 +404,25 @@ scaled_bilinear_scanline_##cputype##_##n
- if ((flags & SKIP_ZERO_SRC) && zero_src) \
- return; \
- pixman_scaled_bilinear_scanline_##name##_##op##_asm_##cputype ( \
- dst, mask, src_top, src_bottom, wt, wb, vx, unit_x, w); \
- } \
- \
- FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_cover_##op, \
- scaled_bilinear_scanline_##cputype##_##name##_##op, \
-- src_type, uint8_t, dst_type, COVER, \
-+ NULL, src_type, uint8_t, dst_type, COVER, \
- FLAG_HAVE_NON_SOLID_MASK) \
- FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_none_##op, \
- scaled_bilinear_scanline_##cputype##_##name##_##op, \
-- src_type, uint8_t, dst_type, NONE, \
-+ NULL, src_type, uint8_t, dst_type, NONE, \
- FLAG_HAVE_NON_SOLID_MASK) \
- FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_pad_##op, \
- scaled_bilinear_scanline_##cputype##_##name##_##op, \
-- src_type, uint8_t, dst_type, PAD, \
-+ NULL, src_type, uint8_t, dst_type, PAD, \
- FLAG_HAVE_NON_SOLID_MASK) \
- FAST_BILINEAR_MAINLOOP_COMMON (cputype##_##name##_normal_##op, \
- scaled_bilinear_scanline_##cputype##_##name##_##op, \
-- src_type, uint8_t, dst_type, NORMAL, \
-+ NULL, src_type, uint8_t, dst_type, NORMAL, \
- FLAG_HAVE_NON_SOLID_MASK)
-
-
- #endif
-diff --git a/gfx/cairo/libpixman/src/pixman-arm-neon.c b/gfx/cairo/libpixman/src/pixman-arm-neon.c
---- a/gfx/cairo/libpixman/src/pixman-arm-neon.c
-+++ b/gfx/cairo/libpixman/src/pixman-arm-neon.c
-@@ -140,16 +140,33 @@ PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST
- PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST (0, neon, 8888_0565, SRC,
- uint32_t, uint16_t)
- PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST (0, neon, 0565_x888, SRC,
- uint16_t, uint32_t)
- PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST (0, neon, 0565_0565, SRC,
- uint16_t, uint16_t)
- PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST (SKIP_ZERO_SRC, neon, 8888_8888, OVER,
- uint32_t, uint32_t)
-+static force_inline void
-+pixman_scaled_bilinear_scanline_8888_8888_SRC (
-+ uint32_t * dst,
-+ const uint32_t * mask,
-+ const uint32_t * src_top,
-+ const uint32_t * src_bottom,
-+ int32_t w,
-+ int wt,
-+ int wb,
-+ pixman_fixed_t vx,
-+ pixman_fixed_t unit_x,
-+ pixman_fixed_t max_vx,
-+ pixman_bool_t zero_src)
-+{
-+ pixman_scaled_bilinear_scanline_8888_8888_SRC_asm_neon (dst, src_top, src_bottom, wt, wb, vx, unit_x, w);
-+}
-+
- PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_DST (SKIP_ZERO_SRC, neon, 8888_8888, ADD,
- uint32_t, uint32_t)
-
- PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_A8_DST (0, neon, 8888_8_8888, SRC,
- uint32_t, uint32_t)
- PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_A8_DST (0, neon, 8888_8_0565, SRC,
- uint32_t, uint16_t)
- PIXMAN_ARM_BIND_SCALED_BILINEAR_SRC_A8_DST (0, neon, 0565_8_x888, SRC,
-@@ -261,16 +278,38 @@ pixman_blt_neon (uint32_t *src_bits,
- (uint32_t *)(((char *) src_bits) +
- src_y * src_stride * 4 + src_x * 4), src_stride);
- return TRUE;
- default:
- return FALSE;
- }
- }
-
-+static inline void op_bilinear_over_8888_0565(uint16_t *dst, const uint32_t *mask, const uint32_t *src, int width)
-+{
-+ pixman_composite_over_8888_0565_asm_neon (width, 1, dst, 0, src, 0);
-+}
-+
-+FAST_BILINEAR_MAINLOOP_COMMON (neon_8888_0565_cover_OVER,
-+ pixman_scaled_bilinear_scanline_8888_8888_SRC, op_bilinear_over_8888_0565,
-+ uint32_t, uint32_t, uint16_t,
-+ COVER, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (neon_8888_0565_pad_OVER,
-+ pixman_scaled_bilinear_scanline_8888_8888_SRC, op_bilinear_over_8888_0565,
-+ uint32_t, uint32_t, uint16_t,
-+ PAD, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (neon_8888_0565_none_OVER,
-+ pixman_scaled_bilinear_scanline_8888_8888_SRC, op_bilinear_over_8888_0565,
-+ uint32_t, uint32_t, uint16_t,
-+ NONE, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (neon_8888_0565_normal_OVER,
-+ pixman_scaled_bilinear_scanline_8888_8888_SRC, op_bilinear_over_8888_0565,
-+ uint32_t, uint32_t, uint16_t,
-+ NORMAL, FLAG_NONE)
-+
- static const pixman_fast_path_t arm_neon_fast_paths[] =
- {
- PIXMAN_STD_FAST_PATH (SRC, r5g6b5, null, r5g6b5, neon_composite_src_0565_0565),
- PIXMAN_STD_FAST_PATH (SRC, b5g6r5, null, b5g6r5, neon_composite_src_0565_0565),
- PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, r5g6b5, neon_composite_src_8888_0565),
- PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, r5g6b5, neon_composite_src_8888_0565),
- PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, b5g6r5, neon_composite_src_8888_0565),
- PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, b5g6r5, neon_composite_src_8888_0565),
-@@ -414,16 +453,18 @@ static const pixman_fast_path_t arm_neon
- SIMPLE_BILINEAR_A8_MASK_FAST_PATH (SRC, r5g6b5, r5g6b5, neon_0565_8_0565),
-
- SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, neon_8888_8_8888),
- SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, neon_8888_8_8888),
-
- SIMPLE_BILINEAR_A8_MASK_FAST_PATH (ADD, a8r8g8b8, a8r8g8b8, neon_8888_8_8888),
- SIMPLE_BILINEAR_A8_MASK_FAST_PATH (ADD, a8r8g8b8, x8r8g8b8, neon_8888_8_8888),
-
-+ SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, r5g6b5, neon_8888_0565),
-+
- { PIXMAN_OP_NONE },
- };
-
- static pixman_bool_t
- arm_neon_blt (pixman_implementation_t *imp,
- uint32_t * src_bits,
- uint32_t * dst_bits,
- int src_stride,
-diff --git a/gfx/cairo/libpixman/src/pixman-fast-path.c b/gfx/cairo/libpixman/src/pixman-fast-path.c
---- a/gfx/cairo/libpixman/src/pixman-fast-path.c
-+++ b/gfx/cairo/libpixman/src/pixman-fast-path.c
-@@ -1356,63 +1356,63 @@ scaled_bilinear_scanline_565_565_SRC (ui
- vx += unit_x;
- *dst++ = d;
- }
- }
-
- #endif
-
- FAST_BILINEAR_MAINLOOP_COMMON (565_565_cover_SRC,
-- scaled_bilinear_scanline_565_565_SRC,
-+ scaled_bilinear_scanline_565_565_SRC, NULL,
- uint16_t, uint32_t, uint16_t,
- COVER, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (565_565_pad_SRC,
-- scaled_bilinear_scanline_565_565_SRC,
-+ scaled_bilinear_scanline_565_565_SRC, NULL,
- uint16_t, uint32_t, uint16_t,
- PAD, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (565_565_none_SRC,
-- scaled_bilinear_scanline_565_565_SRC,
-+ scaled_bilinear_scanline_565_565_SRC, NULL,
- uint16_t, uint32_t, uint16_t,
- NONE, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (565_565_normal_SRC,
-- scaled_bilinear_scanline_565_565_SRC,
-+ scaled_bilinear_scanline_565_565_SRC, NULL,
- uint16_t, uint32_t, uint16_t,
- NORMAL, FLAG_NONE)
-
- FAST_BILINEAR_MAINLOOP_COMMON (8888_565_cover_OVER,
-- scaled_bilinear_scanline_8888_565_OVER,
-+ scaled_bilinear_scanline_8888_565_OVER, NULL,
- uint32_t, uint32_t, uint16_t,
- COVER, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (8888_565_pad_OVER,
-- scaled_bilinear_scanline_8888_565_OVER,
-+ scaled_bilinear_scanline_8888_565_OVER, NULL,
- uint32_t, uint32_t, uint16_t,
- PAD, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (8888_565_none_OVER,
-- scaled_bilinear_scanline_8888_565_OVER,
-+ scaled_bilinear_scanline_8888_565_OVER, NULL,
- uint32_t, uint32_t, uint16_t,
- NONE, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (8888_565_normal_OVER,
-- scaled_bilinear_scanline_8888_565_OVER,
-+ scaled_bilinear_scanline_8888_565_OVER, NULL,
- uint32_t, uint32_t, uint16_t,
- NORMAL, FLAG_NONE)
-
- FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_cover_OVER,
-- scaled_bilinear_scanline_8888_8888_OVER,
-+ scaled_bilinear_scanline_8888_8888_OVER, NULL,
- uint32_t, uint32_t, uint32_t,
- COVER, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_pad_OVER,
-- scaled_bilinear_scanline_8888_8888_OVER,
-+ scaled_bilinear_scanline_8888_8888_OVER, NULL,
- uint32_t, uint32_t, uint32_t,
- PAD, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_none_OVER,
-- scaled_bilinear_scanline_8888_8888_OVER,
-+ scaled_bilinear_scanline_8888_8888_OVER, NULL,
- uint32_t, uint32_t, uint32_t,
- NONE, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_normal_OVER,
-- scaled_bilinear_scanline_8888_8888_OVER,
-+ scaled_bilinear_scanline_8888_8888_OVER, NULL,
- uint32_t, uint32_t, uint32_t,
- NORMAL, FLAG_NONE)
-
- #define REPEAT_MIN_WIDTH 32
-
- static void
- fast_composite_tiled_repeat (pixman_implementation_t *imp,
- pixman_composite_info_t *info)
-diff --git a/gfx/cairo/libpixman/src/pixman-inlines.h b/gfx/cairo/libpixman/src/pixman-inlines.h
---- a/gfx/cairo/libpixman/src/pixman-inlines.h
-+++ b/gfx/cairo/libpixman/src/pixman-inlines.h
-@@ -816,18 +816,48 @@ bilinear_pad_repeat_get_scanline_bounds
- *
- * Note: normally the sum of 'weight_top' and 'weight_bottom' is equal to 256,
- * but sometimes it may be less than that for NONE repeat when handling
- * fuzzy antialiased top or bottom image edges. Also both top and
- * bottom weight variables are guaranteed to have value in 0-255
- * range and can fit into unsigned byte or be used with 8-bit SIMD
- * multiplication instructions.
- */
--#define FAST_BILINEAR_MAINLOOP_INT(scale_func_name, scanline_func, src_type_t, mask_type_t, \
-- dst_type_t, repeat_mode, flags) \
-+
-+/* Replace a single "scanline_func" with "fetch_func" & "op_func" to allow optional
-+ * two stage processing (bilinear fetch to a temp buffer, followed by unscaled
-+ * combine), "op_func" may be NULL, in this case we keep old behavior.
-+ * This is ugly and gcc issues some warnings, but works.
-+ *
-+ * An advice: clang has much better error reporting than gcc for deeply nested macros.
-+ */
-+
-+#define scanline_func(dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, dst, \
-+ scanline_buf, mask, src_top, src_bottom, width, \
-+ weight_top, weight_bottom, vx, unit_x, max_vx, zero_src) \
-+ do { \
-+ if (op_func != NULL) \
-+ { \
-+ fetch_func ((void *)scanline_buf, (mask), (src_top), (src_bottom), (width), \
-+ (weight_top), (weight_bottom), (vx), (unit_x), (max_vx), (zero_src)); \
-+ ((void (*)(dst_type_t *, const mask_type_t *, const src_type_t *, int)) op_func)\
-+ ((dst), (mask), (src_type_t *)scanline_buf, (width)); \
-+ } \
-+ else \
-+ { \
-+ fetch_func ((void*)(dst), (mask), (src_top), (src_bottom), (width), (weight_top), \
-+ (weight_bottom), (vx), (unit_x), (max_vx), (zero_src)); \
-+ } \
-+ } while (0)
-+
-+
-+#define SCANLINE_BUFFER_LENGTH 3072
-+
-+#define FAST_BILINEAR_MAINLOOP_INT(scale_func_name, fetch_func, op_func, src_type_t, \
-+ mask_type_t, dst_type_t, repeat_mode, flags) \
- static void \
- fast_composite_scaled_bilinear ## scale_func_name (pixman_implementation_t *imp, \
- pixman_composite_info_t *info) \
- { \
- PIXMAN_COMPOSITE_ARGS (info); \
- dst_type_t *dst_line; \
- mask_type_t *mask_line; \
- src_type_t *src_first_line; \
-@@ -842,16 +872,19 @@ fast_composite_scaled_bilinear ## scale_
- mask_type_t solid_mask; \
- const mask_type_t *mask = &solid_mask; \
- int src_stride, mask_stride, dst_stride; \
- \
- int src_width; \
- pixman_fixed_t src_width_fixed; \
- int max_x; \
- pixman_bool_t need_src_extension; \
-+ \
-+ uint64_t stack_scanline_buffer[SCANLINE_BUFFER_LENGTH]; \
-+ uint8_t *scanline_buffer = (uint8_t *) stack_scanline_buffer; \
- \
- PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, dst_type_t, dst_stride, dst_line, 1); \
- if (flags & FLAG_HAVE_SOLID_MASK) \
- { \
- solid_mask = _pixman_image_get_solid (imp, mask_image, dest_image->bits.format); \
- mask_stride = 0; \
- } \
- else if (flags & FLAG_HAVE_NON_SOLID_MASK) \
-@@ -914,16 +947,24 @@ fast_composite_scaled_bilinear ## scale_
- else \
- { \
- src_width = src_image->bits.width; \
- need_src_extension = FALSE; \
- } \
- \
- src_width_fixed = pixman_int_to_fixed (src_width); \
- } \
-+ \
-+ if (op_func != NULL && width * sizeof(src_type_t) > sizeof(stack_scanline_buffer)) \
-+ { \
-+ scanline_buffer = pixman_malloc_ab (width, sizeof(src_type_t)); \
-+ \
-+ if (!scanline_buffer) \
-+ return; \
-+ } \
- \
- while (--height >= 0) \
- { \
- int weight1, weight2; \
- dst = dst_line; \
- dst_line += dst_stride; \
- vx = v.vector[0]; \
- if (flags & FLAG_HAVE_NON_SOLID_MASK) \
-@@ -956,36 +997,39 @@ fast_composite_scaled_bilinear ## scale_
- repeat (PIXMAN_REPEAT_PAD, &y2, src_image->bits.height); \
- src1 = src_first_line + src_stride * y1; \
- src2 = src_first_line + src_stride * y2; \
- \
- if (left_pad > 0) \
- { \
- buf1[0] = buf1[1] = src1[0]; \
- buf2[0] = buf2[1] = src2[0]; \
-- scanline_func (dst, mask, \
-- buf1, buf2, left_pad, weight1, weight2, 0, 0, 0, FALSE); \
-+ scanline_func (dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, dst, \
-+ scanline_buffer, mask, buf1, buf2, left_pad, weight1, weight2, \
-+ 0, 0, 0, FALSE); \
- dst += left_pad; \
- if (flags & FLAG_HAVE_NON_SOLID_MASK) \
- mask += left_pad; \
- } \
- if (width > 0) \
- { \
-- scanline_func (dst, mask, \
-- src1, src2, width, weight1, weight2, vx, unit_x, 0, FALSE); \
-+ scanline_func (dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, dst, \
-+ scanline_buffer, mask, src1, src2, width, weight1, weight2, \
-+ vx, unit_x, 0, FALSE); \
- dst += width; \
- if (flags & FLAG_HAVE_NON_SOLID_MASK) \
- mask += width; \
- } \
- if (right_pad > 0) \
- { \
- buf1[0] = buf1[1] = src1[src_image->bits.width - 1]; \
- buf2[0] = buf2[1] = src2[src_image->bits.width - 1]; \
-- scanline_func (dst, mask, \
-- buf1, buf2, right_pad, weight1, weight2, 0, 0, 0, FALSE); \
-+ scanline_func (dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, dst, \
-+ scanline_buffer, mask, buf1, buf2, right_pad, weight1, weight2, \
-+ 0, 0, 0, FALSE); \
- } \
- } \
- else if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NONE) \
- { \
- src_type_t *src1, *src2; \
- src_type_t buf1[2]; \
- src_type_t buf2[2]; \
- /* handle top/bottom zero padding by just setting weights to 0 if needed */ \
-@@ -1011,64 +1055,67 @@ fast_composite_scaled_bilinear ## scale_
- } \
- src1 = src_first_line + src_stride * y1; \
- src2 = src_first_line + src_stride * y2; \
- \
- if (left_pad > 0) \
- { \
- buf1[0] = buf1[1] = 0; \
- buf2[0] = buf2[1] = 0; \
-- scanline_func (dst, mask, \
-- buf1, buf2, left_pad, weight1, weight2, 0, 0, 0, TRUE); \
-+ scanline_func (dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, dst, \
-+ scanline_buffer, mask, buf1, buf2, left_pad, weight1, weight2, \
-+ 0, 0, 0, TRUE); \
- dst += left_pad; \
- if (flags & FLAG_HAVE_NON_SOLID_MASK) \
- mask += left_pad; \
- } \
- if (left_tz > 0) \
- { \
- buf1[0] = 0; \
- buf1[1] = src1[0]; \
- buf2[0] = 0; \
- buf2[1] = src2[0]; \
-- scanline_func (dst, mask, \
-- buf1, buf2, left_tz, weight1, weight2, \
-+ scanline_func (dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, dst, \
-+ scanline_buffer, mask, buf1, buf2, left_tz, weight1, weight2, \
- pixman_fixed_frac (vx), unit_x, 0, FALSE); \
- dst += left_tz; \
- if (flags & FLAG_HAVE_NON_SOLID_MASK) \
- mask += left_tz; \
- vx += left_tz * unit_x; \
- } \
- if (width > 0) \
- { \
-- scanline_func (dst, mask, \
-- src1, src2, width, weight1, weight2, vx, unit_x, 0, FALSE); \
-+ scanline_func (dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, dst, \
-+ scanline_buffer, mask, src1, src2, width, weight1, weight2, \
-+ vx, unit_x, 0, FALSE); \
- dst += width; \
- if (flags & FLAG_HAVE_NON_SOLID_MASK) \
- mask += width; \
- vx += width * unit_x; \
- } \
- if (right_tz > 0) \
- { \
- buf1[0] = src1[src_image->bits.width - 1]; \
- buf1[1] = 0; \
- buf2[0] = src2[src_image->bits.width - 1]; \
- buf2[1] = 0; \
-- scanline_func (dst, mask, \
-- buf1, buf2, right_tz, weight1, weight2, \
-+ scanline_func (dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, dst, \
-+ scanline_buffer, mask, buf1, buf2, right_tz, weight1, weight2, \
- pixman_fixed_frac (vx), unit_x, 0, FALSE); \
- dst += right_tz; \
- if (flags & FLAG_HAVE_NON_SOLID_MASK) \
- mask += right_tz; \
- } \
- if (right_pad > 0) \
- { \
- buf1[0] = buf1[1] = 0; \
- buf2[0] = buf2[1] = 0; \
-- scanline_func (dst, mask, \
-- buf1, buf2, right_pad, weight1, weight2, 0, 0, 0, TRUE); \
-+ scanline_func (dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, dst, \
-+ scanline_buffer, mask, buf1, buf2, right_pad, weight1, weight2, \
-+ 0, 0, 0, TRUE); \
- } \
- } \
- else if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NORMAL) \
- { \
- int32_t num_pixels; \
- int32_t width_remain; \
- src_type_t * src_line_top; \
- src_type_t * src_line_bottom; \
-@@ -1120,17 +1167,18 @@ fast_composite_scaled_bilinear ## scale_
- * vx is in range [0, src_width_fixed - pixman_fixed_e] \
- * So we are safe from overflow. \
- */ \
- num_pixels = ((src_width_fixed - vx - pixman_fixed_e) / unit_x) + 1; \
- \
- if (num_pixels > width_remain) \
- num_pixels = width_remain; \
- \
-- scanline_func (dst, mask, buf1, buf2, num_pixels, \
-+ scanline_func (dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, \
-+ dst, scanline_buffer, mask, buf1, buf2, num_pixels, \
- weight1, weight2, pixman_fixed_frac(vx), \
- unit_x, src_width_fixed, FALSE); \
- \
- width_remain -= num_pixels; \
- vx += num_pixels * unit_x; \
- dst += num_pixels; \
- \
- if (flags & FLAG_HAVE_NON_SOLID_MASK) \
-@@ -1149,41 +1197,47 @@ fast_composite_scaled_bilinear ## scale_
- * So we are safe from overflow here. \
- */ \
- num_pixels = ((src_width_fixed - pixman_fixed_1 - vx - pixman_fixed_e) \
- / unit_x) + 1; \
- \
- if (num_pixels > width_remain) \
- num_pixels = width_remain; \
- \
-- scanline_func (dst, mask, src_line_top, src_line_bottom, num_pixels, \
-- weight1, weight2, vx, unit_x, src_width_fixed, FALSE); \
-+ scanline_func (dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, \
-+ dst, scanline_buffer, mask, src_line_top, src_line_bottom, \
-+ num_pixels, weight1, weight2, vx, unit_x, src_width_fixed, \
-+ FALSE); \
- \
- width_remain -= num_pixels; \
- vx += num_pixels * unit_x; \
- dst += num_pixels; \
- \
- if (flags & FLAG_HAVE_NON_SOLID_MASK) \
- mask += num_pixels; \
- } \
- } \
- } \
- else \
- { \
-- scanline_func (dst, mask, src_first_line + src_stride * y1, \
-+ scanline_func (dst_type_t, mask_type_t, src_type_t, fetch_func, op_func, dst, \
-+ scanline_buffer, mask, \
-+ src_first_line + src_stride * y1, \
- src_first_line + src_stride * y2, width, \
- weight1, weight2, vx, unit_x, max_vx, FALSE); \
- } \
- } \
-+ if (scanline_buffer != (uint8_t *) stack_scanline_buffer) \
-+ free (scanline_buffer); \
- }
-
- /* A workaround for old sun studio, see: https://bugs.freedesktop.org/show_bug.cgi?id=32764 */
--#define FAST_BILINEAR_MAINLOOP_COMMON(scale_func_name, scanline_func, src_type_t, mask_type_t, \
-+#define FAST_BILINEAR_MAINLOOP_COMMON(scale_func_name, fetch_func, op_func, src_type_t, mask_type_t,\
- dst_type_t, repeat_mode, flags) \
-- FAST_BILINEAR_MAINLOOP_INT(_ ## scale_func_name, scanline_func, src_type_t, mask_type_t,\
-+ FAST_BILINEAR_MAINLOOP_INT(_ ## scale_func_name, fetch_func, op_func, src_type_t, mask_type_t,\
- dst_type_t, repeat_mode, flags)
-
- #define SCALED_BILINEAR_FLAGS \
- (FAST_PATH_SCALE_TRANSFORM | \
- FAST_PATH_NO_ALPHA_MAP | \
- FAST_PATH_BILINEAR_FILTER | \
- FAST_PATH_NO_ACCESSORS | \
- FAST_PATH_NARROW_FORMAT)
-diff --git a/gfx/cairo/libpixman/src/pixman-sse2.c b/gfx/cairo/libpixman/src/pixman-sse2.c
---- a/gfx/cairo/libpixman/src/pixman-sse2.c
-+++ b/gfx/cairo/libpixman/src/pixman-sse2.c
-@@ -5404,30 +5404,33 @@ scaled_bilinear_scanline_sse2_8888_8888_
- if (w & 1)
- {
- BILINEAR_INTERPOLATE_ONE_PIXEL (pix1);
- *dst = pix1;
- }
-
- }
-
-+/* Add extra NULL argument to the existing bilinear fast paths to indicate
-+ * that we don't need two-pass processing */
-+
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_cover_SRC,
-- scaled_bilinear_scanline_sse2_8888_8888_SRC,
-+ scaled_bilinear_scanline_sse2_8888_8888_SRC, NULL,
- uint32_t, uint32_t, uint32_t,
- COVER, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_pad_SRC,
-- scaled_bilinear_scanline_sse2_8888_8888_SRC,
-+ scaled_bilinear_scanline_sse2_8888_8888_SRC, NULL,
- uint32_t, uint32_t, uint32_t,
- PAD, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_none_SRC,
-- scaled_bilinear_scanline_sse2_8888_8888_SRC,
-+ scaled_bilinear_scanline_sse2_8888_8888_SRC, NULL,
- uint32_t, uint32_t, uint32_t,
- NONE, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_normal_SRC,
-- scaled_bilinear_scanline_sse2_8888_8888_SRC,
-+ scaled_bilinear_scanline_sse2_8888_8888_SRC, NULL,
- uint32_t, uint32_t, uint32_t,
- NORMAL, FLAG_NONE)
-
- static force_inline void
- scaled_bilinear_scanline_sse2_8888_8888_OVER (uint32_t * dst,
- const uint32_t * mask,
- const uint32_t * src_top,
- const uint32_t * src_bottom,
-@@ -5505,32 +5508,66 @@ scaled_bilinear_scanline_sse2_8888_8888_
- }
-
- w--;
- dst++;
- }
- }
-
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_cover_OVER,
-- scaled_bilinear_scanline_sse2_8888_8888_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8888_OVER, NULL,
- uint32_t, uint32_t, uint32_t,
- COVER, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_pad_OVER,
-- scaled_bilinear_scanline_sse2_8888_8888_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8888_OVER, NULL,
- uint32_t, uint32_t, uint32_t,
- PAD, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_none_OVER,
-- scaled_bilinear_scanline_sse2_8888_8888_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8888_OVER, NULL,
- uint32_t, uint32_t, uint32_t,
- NONE, FLAG_NONE)
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8888_normal_OVER,
-- scaled_bilinear_scanline_sse2_8888_8888_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8888_OVER, NULL,
- uint32_t, uint32_t, uint32_t,
- NORMAL, FLAG_NONE)
-
-+
-+/* An example of SSE2 two-stage bilinear_over_8888_0565 fast path, which is implemented
-+ as scaled_bilinear_scanline_sse2_8888_8888_SRC + op_bilinear_over_8888_0565 */
-+
-+void op_bilinear_over_8888_0565(uint16_t *dst, const uint32_t *mask, const uint32_t *src, int width)
-+{
-+ /* Note: this is not really fast and should be based on 8 pixel loop from sse2_composite_over_8888_0565 */
-+ while (--width >= 0)
-+ {
-+ *dst = composite_over_8888_0565pixel (*src, *dst);
-+ src++;
-+ dst++;
-+ }
-+}
-+
-+FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_0565_cover_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8888_SRC, op_bilinear_over_8888_0565,
-+ uint32_t, uint32_t, uint16_t,
-+ COVER, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_0565_pad_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8888_SRC, op_bilinear_over_8888_0565,
-+ uint32_t, uint32_t, uint16_t,
-+ PAD, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_0565_none_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8888_SRC, op_bilinear_over_8888_0565,
-+ uint32_t, uint32_t, uint16_t,
-+ NONE, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_0565_normal_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8888_SRC, op_bilinear_over_8888_0565,
-+ uint32_t, uint32_t, uint16_t,
-+ NORMAL, FLAG_NONE)
-+
-+/*****************************/
-+
- static force_inline void
- scaled_bilinear_scanline_sse2_8888_8_8888_OVER (uint32_t * dst,
- const uint8_t * mask,
- const uint32_t * src_top,
- const uint32_t * src_bottom,
- int32_t w,
- int wt,
- int wb,
-@@ -5669,29 +5706,29 @@ scaled_bilinear_scanline_sse2_8888_8_888
- }
-
- w--;
- dst++;
- }
- }
-
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8_8888_cover_OVER,
-- scaled_bilinear_scanline_sse2_8888_8_8888_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8_8888_OVER, NULL,
- uint32_t, uint8_t, uint32_t,
- COVER, FLAG_HAVE_NON_SOLID_MASK)
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8_8888_pad_OVER,
-- scaled_bilinear_scanline_sse2_8888_8_8888_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8_8888_OVER, NULL,
- uint32_t, uint8_t, uint32_t,
- PAD, FLAG_HAVE_NON_SOLID_MASK)
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8_8888_none_OVER,
-- scaled_bilinear_scanline_sse2_8888_8_8888_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8_8888_OVER, NULL,
- uint32_t, uint8_t, uint32_t,
- NONE, FLAG_HAVE_NON_SOLID_MASK)
- FAST_BILINEAR_MAINLOOP_COMMON (sse2_8888_8_8888_normal_OVER,
-- scaled_bilinear_scanline_sse2_8888_8_8888_OVER,
-+ scaled_bilinear_scanline_sse2_8888_8_8888_OVER, NULL,
- uint32_t, uint8_t, uint32_t,
- NORMAL, FLAG_HAVE_NON_SOLID_MASK)
-
- static const pixman_fast_path_t sse2_fast_paths[] =
- {
- /* PIXMAN_OP_OVER */
- PIXMAN_STD_FAST_PATH (OVER, solid, a8, r5g6b5, sse2_composite_over_n_8_0565),
- PIXMAN_STD_FAST_PATH (OVER, solid, a8, b5g6r5, sse2_composite_over_n_8_0565),
-@@ -5808,16 +5845,21 @@ static const pixman_fast_path_t sse2_fas
- SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, sse2_8888_8888),
- SIMPLE_BILINEAR_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, sse2_8888_8888),
-
- SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, sse2_8888_8_8888),
- SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, sse2_8888_8_8888),
- SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, sse2_8888_8_8888),
- SIMPLE_BILINEAR_A8_MASK_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, sse2_8888_8_8888),
-
-+ /* and here the needed entries are added to the fast path table */
-+
-+ SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, r5g6b5, sse2_8888_0565),
-+ SIMPLE_BILINEAR_FAST_PATH (OVER, a8b8g8r8, b5g6r5, sse2_8888_0565),
-+
- { PIXMAN_OP_NONE },
- };
-
- static pixman_bool_t
- sse2_blt (pixman_implementation_t *imp,
- uint32_t * src_bits,
- uint32_t * dst_bits,
- int src_stride,
-
diff --git a/gfx/cairo/pixman-android-cpu-detect.patch b/gfx/cairo/pixman-android-cpu-detect.patch
deleted file mode 100644
index 130af5130..000000000
--- a/gfx/cairo/pixman-android-cpu-detect.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-diff --git a/gfx/cairo/libpixman/src/pixman-cpu.c b/gfx/cairo/libpixman/src/pixman-cpu.c
---- a/gfx/cairo/libpixman/src/pixman-cpu.c
-+++ b/gfx/cairo/libpixman/src/pixman-cpu.c
-@@ -257,19 +257,22 @@ pixman_arm_read_auxv()
- arm_tests_initialized = TRUE;
- return;
- }
-
- fread(buf, sizeof(char), 1024, f);
- fclose(f);
- pos = strstr(buf, ver_token);
- if (pos) {
-- int ver = *(pos + strlen(ver_token)) - '0';
-- arm_has_v7 = ver >= 7;
-- arm_has_v6 = ver >= 6;
-+ char vchar = *(pos + strlen(ver_token));
-+ if (vchar >= '0' && vchar <= '9') {
-+ int ver = vchar - '0';
-+ arm_has_v7 = ver >= 7;
-+ arm_has_v6 = ver >= 6;
-+ }
- }
- arm_has_neon = strstr(buf, "neon") != NULL;
- arm_has_vfp = strstr(buf, "vfp") != NULL;
- arm_has_iwmmxt = strstr(buf, "iwmmxt") != NULL;
- arm_tests_initialized = TRUE;
- }
-
- #else
diff --git a/gfx/cairo/pixman-bilinear-fastpath.patch b/gfx/cairo/pixman-bilinear-fastpath.patch
deleted file mode 100644
index b2c5f270c..000000000
--- a/gfx/cairo/pixman-bilinear-fastpath.patch
+++ /dev/null
@@ -1,287 +0,0 @@
-changeset: 94061:73a9b24d863a
-tag: bilin
-tag: qbase
-tag: qtip
-tag: tip
-user: Jeff Muizelaar <jmuizelaar@mozilla.com>
-date: Tue May 15 18:26:16 2012 -0400
-summary: Bug 754364. Add bilinear non-repeat and repeat fast paths. r=joe
-
-diff --git a/gfx/cairo/libpixman/src/pixman-fast-path.c b/gfx/cairo/libpixman/src/pixman-fast-path.c
---- a/gfx/cairo/libpixman/src/pixman-fast-path.c
-+++ b/gfx/cairo/libpixman/src/pixman-fast-path.c
-@@ -1186,16 +1186,228 @@ FAST_NEAREST (8888_565_none, 8888, 0565,
- FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, SRC, PAD)
- FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL)
- FAST_NEAREST (565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, NORMAL)
- FAST_NEAREST (8888_565_cover, 8888, 0565, uint32_t, uint16_t, OVER, COVER)
- FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE)
- FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, OVER, PAD)
- FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL)
-
-+static force_inline void
-+scaled_bilinear_scanline_8888_565_OVER (uint16_t * dst,
-+ const uint32_t * mask,
-+ const uint32_t * src_top,
-+ const uint32_t * src_bottom,
-+ int32_t w,
-+ int wt,
-+ int wb,
-+ pixman_fixed_t vx,
-+ pixman_fixed_t unit_x,
-+ pixman_fixed_t max_vx,
-+ pixman_bool_t zero_src)
-+{
-+ while ((w -= 1) >= 0)
-+ {
-+ uint32_t tl = src_top [pixman_fixed_to_int (vx)];
-+ uint32_t tr = src_top [pixman_fixed_to_int (vx) + 1];
-+ uint32_t bl = src_bottom [pixman_fixed_to_int (vx)];
-+ uint32_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
-+ uint32_t src, result;
-+ uint16_t d;
-+ d = *dst;
-+ src = bilinear_interpolation (tl, tr,
-+ bl, br,
-+ interpolation_coord(vx),
-+ wb >> (8 - INTERPOLATION_PRECISION_BITS));
-+ vx += unit_x;
-+ result = over (src, CONVERT_0565_TO_0888 (d));
-+ *dst++ = CONVERT_8888_TO_0565(result);
-+ }
-+}
-+
-+static force_inline void
-+scaled_bilinear_scanline_8888_8888_OVER (uint32_t * dst,
-+ const uint32_t * mask,
-+ const uint32_t * src_top,
-+ const uint32_t * src_bottom,
-+ int32_t w,
-+ int wt,
-+ int wb,
-+ pixman_fixed_t vx,
-+ pixman_fixed_t unit_x,
-+ pixman_fixed_t max_vx,
-+ pixman_bool_t zero_src)
-+{
-+ while ((w -= 1) >= 0)
-+ {
-+ uint32_t tl = src_top [pixman_fixed_to_int (vx)];
-+ uint32_t tr = src_top [pixman_fixed_to_int (vx) + 1];
-+ uint32_t bl = src_bottom [pixman_fixed_to_int (vx)];
-+ uint32_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
-+ uint32_t src;
-+ uint32_t d;
-+ uint32_t result;
-+ d = *dst;
-+ src = bilinear_interpolation (tl, tr,
-+ bl, br,
-+ interpolation_coord(vx),
-+ wb >> (8 - INTERPOLATION_PRECISION_BITS));
-+ vx += unit_x;
-+ *dst++ = over (src, d);
-+ }
-+}
-+
-+#if 1
-+
-+static force_inline void
-+scaled_bilinear_scanline_565_565_SRC (uint16_t * dst,
-+ const uint32_t * mask,
-+ const uint16_t * src_top,
-+ const uint16_t * src_bottom,
-+ int32_t w,
-+ int wt,
-+ int wb,
-+ pixman_fixed_t vx,
-+ pixman_fixed_t unit_x,
-+ pixman_fixed_t max_vx,
-+ pixman_bool_t zero_src)
-+{
-+ while ((w -= 1) >= 0)
-+ {
-+ uint16_t tl = src_top [pixman_fixed_to_int (vx)];
-+ uint16_t tr = src_top [pixman_fixed_to_int (vx) + 1];
-+ uint16_t bl = src_bottom [pixman_fixed_to_int (vx)];
-+ uint16_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
-+ uint32_t d;
-+ d = bilinear_interpolation(CONVERT_0565_TO_8888(tl),
-+ CONVERT_0565_TO_8888(tr),
-+ CONVERT_0565_TO_8888(bl),
-+ CONVERT_0565_TO_8888(br),
-+ interpolation_coord(vx),
-+ wb >> (8 - INTERPOLATION_PRECISION_BITS));
-+ vx += unit_x;
-+ *dst++ = CONVERT_8888_TO_0565(d);
-+ }
-+}
-+
-+#else
-+
-+#define SK_G16_MASK_IN_PLACE 0xfc0
-+
-+static inline uint32_t SkExpand_rgb_16(uint16_t c) {
-+
-+ return ((c & SK_G16_MASK_IN_PLACE) << 16) | (c & ~SK_G16_MASK_IN_PLACE);
-+}
-+
-+/** Compress an expanded value (from SkExpand_rgb_16) back down to a 16bit
-+ color value. The computation yields only 16bits of valid data, but we claim
-+ to return 32bits, so that the compiler won't generate extra instructions to
-+ "clean" the top 16bits. However, the top 16 can contain garbage, so it is
-+ up to the caller to safely ignore them.
-+*/
-+static inline uint16_t SkCompact_rgb_16(uint32_t c) {
-+ return ((c >> 16) & SK_G16_MASK_IN_PLACE) | (c & ~SK_G16_MASK_IN_PLACE);
-+}
-+// returns expanded * 5bits
-+static inline uint32_t Filter_565_Expanded(unsigned x, unsigned y,
-+ uint32_t a00, uint32_t a01,
-+ uint32_t a10, uint32_t a11) {
-+ a00 = SkExpand_rgb_16(a00);
-+ a01 = SkExpand_rgb_16(a01);
-+ a10 = SkExpand_rgb_16(a10);
-+ a11 = SkExpand_rgb_16(a11);
-+
-+ int xy = x * y >> 3;
-+ return a00 * (32 - 2*y - 2*x + xy) +
-+ a01 * (2*x - xy) +
-+ a10 * (2*y - xy) +
-+ a11 * xy;
-+}
-+
-+
-+
-+static force_inline void
-+scaled_bilinear_scanline_565_565_SRC (uint16_t * dst,
-+ const uint32_t * mask,
-+ const uint16_t * src_top,
-+ const uint16_t * src_bottom,
-+ int32_t w,
-+ int wt,
-+ int wb,
-+ pixman_fixed_t vx,
-+ pixman_fixed_t unit_x,
-+ pixman_fixed_t max_vx,
-+ pixman_bool_t zero_src)
-+{
-+ while ((w -= 1) >= 0)
-+ {
-+ uint16_t tl = src_top [pixman_fixed_to_int (vx)];
-+ uint16_t tr = src_top [pixman_fixed_to_int (vx) + 1];
-+ uint16_t bl = src_bottom [pixman_fixed_to_int (vx)];
-+ uint16_t br = src_bottom [pixman_fixed_to_int (vx) + 1];
-+
-+ uint32_t tmp = Filter_565_Expanded((vx>>12)&0xf, wb>>4, tl, tr, bl, br);
-+ vx += unit_x;
-+ *dst++ = SkCompact_rgb_16((tmp) >> 5);
-+ }
-+}
-+
-+
-+#endif
-+FAST_BILINEAR_MAINLOOP_COMMON (565_565_cover_SRC,
-+ scaled_bilinear_scanline_565_565_SRC,
-+ uint16_t, uint32_t, uint16_t,
-+ COVER, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (565_565_pad_SRC,
-+ scaled_bilinear_scanline_565_565_SRC,
-+ uint16_t, uint32_t, uint16_t,
-+ PAD, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (565_565_none_SRC,
-+ scaled_bilinear_scanline_565_565_SRC,
-+ uint16_t, uint32_t, uint16_t,
-+ NONE, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (565_565_normal_SRC,
-+ scaled_bilinear_scanline_565_565_SRC,
-+ uint16_t, uint32_t, uint16_t,
-+ NORMAL, FLAG_NONE)
-+
-+FAST_BILINEAR_MAINLOOP_COMMON (8888_565_cover_OVER,
-+ scaled_bilinear_scanline_8888_565_OVER,
-+ uint32_t, uint32_t, uint16_t,
-+ COVER, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (8888_565_pad_OVER,
-+ scaled_bilinear_scanline_8888_565_OVER,
-+ uint32_t, uint32_t, uint16_t,
-+ PAD, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (8888_565_none_OVER,
-+ scaled_bilinear_scanline_8888_565_OVER,
-+ uint32_t, uint32_t, uint16_t,
-+ NONE, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (8888_565_normal_OVER,
-+ scaled_bilinear_scanline_8888_565_OVER,
-+ uint32_t, uint32_t, uint16_t,
-+ NORMAL, FLAG_NONE)
-+
-+FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_cover_OVER,
-+ scaled_bilinear_scanline_8888_8888_OVER,
-+ uint32_t, uint32_t, uint32_t,
-+ COVER, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_pad_OVER,
-+ scaled_bilinear_scanline_8888_8888_OVER,
-+ uint32_t, uint32_t, uint32_t,
-+ PAD, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_none_OVER,
-+ scaled_bilinear_scanline_8888_8888_OVER,
-+ uint32_t, uint32_t, uint32_t,
-+ NONE, FLAG_NONE)
-+FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_normal_OVER,
-+ scaled_bilinear_scanline_8888_8888_OVER,
-+ uint32_t, uint32_t, uint32_t,
-+ NORMAL, FLAG_NONE)
-+
- #define REPEAT_MIN_WIDTH 32
-
- static void
- fast_composite_tiled_repeat (pixman_implementation_t *imp,
- pixman_composite_info_t *info)
- {
- PIXMAN_COMPOSITE_ARGS (info);
- pixman_composite_func_t func;
-@@ -1960,16 +2172,20 @@ static const pixman_fast_path_t c_fast_p
- PIXMAN_any,
- (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | FAST_PATH_BITS_IMAGE |
- FAST_PATH_NORMAL_REPEAT),
- PIXMAN_any, 0,
- PIXMAN_any, FAST_PATH_STD_DEST_FLAGS,
- fast_composite_tiled_repeat
- },
-
-+ SIMPLE_BILINEAR_FAST_PATH (SRC, r5g6b5, r5g6b5, 565_565),
-+ SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, r5g6b5, 8888_565),
-+ SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, 8888_8888),
-+
- { PIXMAN_OP_NONE },
- };
-
- #ifdef WORDS_BIGENDIAN
- #define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (32 - (offs) - (n)))
- #else
- #define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (offs))
- #endif
-diff --git a/gfx/cairo/libpixman/src/pixman-inlines.h b/gfx/cairo/libpixman/src/pixman-inlines.h
---- a/gfx/cairo/libpixman/src/pixman-inlines.h
-+++ b/gfx/cairo/libpixman/src/pixman-inlines.h
-@@ -80,16 +80,21 @@ repeat (pixman_repeat_t repeat, int *c,
- }
- return TRUE;
- }
-
- #ifdef MOZ_GFX_OPTIMIZE_MOBILE
- #define LOW_QUALITY_INTERPOLATION
- #endif
-
-+#ifdef LOW_QUALITY_INTERPOLATION
-+#define INTERPOLATION_PRECISION_BITS 4
-+#else
-+#define INTERPOLATION_PRECISION_BITS 8
-+#endif
- static force_inline int32_t
- interpolation_coord(pixman_fixed_t t)
- {
- #ifdef LOW_QUALITY_INTERPOLATION
- return (t >> 12) & 0xf;
- #else
- return (t >> 8) & 0xff;
- #endif
diff --git a/gfx/cairo/pixman-component-alpha.patch b/gfx/cairo/pixman-component-alpha.patch
deleted file mode 100644
index f6a6f4a95..000000000
--- a/gfx/cairo/pixman-component-alpha.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-commit d14b8c688f4cbe6c9289955d9ce7257c07869f9e
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Wed May 6 10:19:04 2009 -0400
-
- create getter for component alpha
-
-diff --git a/gfx/cairo/libpixman/src/pixman-image.c b/gfx/cairo/libpixman/src/pixman-image.c
-index e80c479..2c49f92 100644
---- a/gfx/cairo/libpixman/src/pixman-image.c
-+++ b/gfx/cairo/libpixman/src/pixman-image.c
-@@ -563,6 +563,11 @@ pixman_image_set_component_alpha (pixman_image_t *image,
- image->common.component_alpha = component_alpha;
- }
-
-+PIXMAN_EXPORT pixman_bool_t
-+pixman_image_get_component_alpha (pixman_image_t *image)
-+{
-+ return image->common.component_alpha;
-+}
-
- PIXMAN_EXPORT void
- pixman_image_set_accessors (pixman_image_t *image,
-diff --git a/gfx/cairo/libpixman/src/pixman.h b/gfx/cairo/libpixman/src/pixman.h
-index 49c39d5..522a866 100644
---- a/gfx/cairo/libpixman/src/pixman.h
-+++ b/gfx/cairo/libpixman/src/pixman.h
-@@ -767,6 +767,7 @@ void pixman_image_set_alpha_map (pixman_image_t
- int16_t y);
- void pixman_image_set_component_alpha (pixman_image_t *image,
- pixman_bool_t component_alpha);
-+pixman_bool_t pixman_image_get_component_alpha (pixman_image_t *image);
- void pixman_image_set_accessors (pixman_image_t *image,
- pixman_read_memory_func_t read_func,
- pixman_write_memory_func_t write_func);
diff --git a/gfx/cairo/pixman-dither.patch b/gfx/cairo/pixman-dither.patch
deleted file mode 100644
index 633a8d728..000000000
--- a/gfx/cairo/pixman-dither.patch
+++ /dev/null
@@ -1,310 +0,0 @@
-diff --git a/gfx/cairo/libpixman/src/pixman-dither.h b/gfx/cairo/libpixman/src/pixman-dither.h
-new file mode 100644
---- /dev/null
-+++ b/gfx/cairo/libpixman/src/pixman-dither.h
-@@ -0,0 +1,51 @@
-+#define R16_BITS 5
-+#define G16_BITS 6
-+#define B16_BITS 5
-+
-+#define R16_SHIFT (B16_BITS + G16_BITS)
-+#define G16_SHIFT (B16_BITS)
-+#define B16_SHIFT 0
-+
-+#define MASK 0xff
-+#define ONE_HALF 0x80
-+
-+#define A_SHIFT 8 * 3
-+#define R_SHIFT 8 * 2
-+#define G_SHIFT 8
-+#define A_MASK 0xff000000
-+#define R_MASK 0xff0000
-+#define G_MASK 0xff00
-+
-+#define RB_MASK 0xff00ff
-+#define AG_MASK 0xff00ff00
-+#define RB_ONE_HALF 0x800080
-+#define RB_MASK_PLUS_ONE 0x10000100
-+
-+#define ALPHA_8(x) ((x) >> A_SHIFT)
-+#define RED_8(x) (((x) >> R_SHIFT) & MASK)
-+#define GREEN_8(x) (((x) >> G_SHIFT) & MASK)
-+#define BLUE_8(x) ((x) & MASK)
-+
-+// This uses the same dithering technique that Skia does.
-+// It is essentially preturbing the lower bit based on the
-+// high bit
-+static inline uint16_t dither_32_to_16(uint32_t c)
-+{
-+ uint8_t b = BLUE_8(c);
-+ uint8_t g = GREEN_8(c);
-+ uint8_t r = RED_8(c);
-+ r = ((r << 1) - ((r >> (8 - R16_BITS) << (8 - R16_BITS)) | (r >> R16_BITS))) >> (8 - R16_BITS);
-+ g = ((g << 1) - ((g >> (8 - G16_BITS) << (8 - G16_BITS)) | (g >> G16_BITS))) >> (8 - G16_BITS);
-+ b = ((b << 1) - ((b >> (8 - B16_BITS) << (8 - B16_BITS)) | (b >> B16_BITS))) >> (8 - B16_BITS);
-+ return ((r << R16_SHIFT) | (g << G16_SHIFT) | (b << B16_SHIFT));
-+}
-+
-+static inline uint16_t dither_8888_to_0565(uint32_t color, pixman_bool_t toggle)
-+{
-+ // alternate between a preturbed truncation and a regular truncation
-+ if (toggle) {
-+ return dither_32_to_16(color);
-+ } else {
-+ return CONVERT_8888_TO_0565(color);
-+ }
-+}
-diff --git a/gfx/cairo/libpixman/src/pixman-linear-gradient.c b/gfx/cairo/libpixman/src/pixman-linear-gradient.c
---- a/gfx/cairo/libpixman/src/pixman-linear-gradient.c
-+++ b/gfx/cairo/libpixman/src/pixman-linear-gradient.c
-@@ -26,16 +26,18 @@
- */
-
- #ifdef HAVE_CONFIG_H
- #include <config.h>
- #endif
- #include <stdlib.h>
- #include "pixman-private.h"
-
-+#include "pixman-dither.h"
-+
- static pixman_bool_t
- linear_gradient_is_horizontal (pixman_image_t *image,
- int x,
- int y,
- int width,
- int height)
- {
- linear_gradient_t *linear = (linear_gradient_t *)image;
-@@ -222,25 +224,28 @@ linear_get_scanline_narrow (pixman_iter_
- return iter->buffer;
- }
-
- static uint16_t convert_8888_to_0565(uint32_t color)
- {
- return CONVERT_8888_TO_0565(color);
- }
-
-+
-+
- static uint32_t *
- linear_get_scanline_16 (pixman_iter_t *iter,
- const uint32_t *mask)
- {
- pixman_image_t *image = iter->image;
- int x = iter->x;
- int y = iter->y;
- int width = iter->width;
- uint16_t * buffer = (uint16_t*)iter->buffer;
-+ pixman_bool_t toggle = ((x ^ y) & 1);
-
- pixman_vector_t v, unit;
- pixman_fixed_32_32_t l;
- pixman_fixed_48_16_t dx, dy;
- gradient_t *gradient = (gradient_t *)image;
- linear_gradient_t *linear = (linear_gradient_t *)image;
- uint16_t *end = buffer + width;
- pixman_gradient_walker_t walker;
-@@ -294,34 +299,47 @@ linear_get_scanline_16 (pixman_iter_t *
- t = ((dx * v.vector[0] + dy * v.vector[1]) -
- (dx * linear->p1.x + dy * linear->p1.y) * v2) * invden;
- inc = (dx * unit.vector[0] + dy * unit.vector[1]) * invden;
- }
- next_inc = 0;
-
- if (((pixman_fixed_32_32_t )(inc * width)) == 0)
- {
-- register uint16_t color;
-+ register uint32_t color;
-+ uint16_t dither_diff;
-+ uint16_t color16;
-+ uint16_t color16b;
-
-- color = convert_8888_to_0565(_pixman_gradient_walker_pixel (&walker, t));
-- while (buffer < end)
-- *buffer++ = color;
-+ color = _pixman_gradient_walker_pixel (&walker, t);
-+ color16 = dither_8888_to_0565(color, toggle);
-+ color16b = dither_8888_to_0565(color, toggle^1);
-+ // compute the difference
-+ dither_diff = color16 ^ color16b;
-+ while (buffer < end) {
-+ *buffer++ = color16;
-+ // use dither_diff to toggle between color16 and color16b
-+ color16 ^= dither_diff;
-+ toggle ^= 1;
-+ }
- }
- else
- {
- int i;
-
- i = 0;
- while (buffer < end)
- {
- if (!mask || *mask++)
- {
-- *buffer = convert_8888_to_0565(_pixman_gradient_walker_pixel (&walker,
-- t + next_inc));
-+ *buffer = dither_8888_to_0565(_pixman_gradient_walker_pixel (&walker,
-+ t + next_inc),
-+ toggle);
- }
-+ toggle ^= 1;
- i++;
- next_inc = inc * i;
- buffer++;
- }
- }
- }
- else
- {
-@@ -340,18 +358,20 @@ linear_get_scanline_16 (pixman_iter_t *
-
- invden = pixman_fixed_1 * (double) pixman_fixed_1 /
- (l * (double) v.vector[2]);
- v2 = v.vector[2] * (1. / pixman_fixed_1);
- t = ((dx * v.vector[0] + dy * v.vector[1]) -
- (dx * linear->p1.x + dy * linear->p1.y) * v2) * invden;
- }
-
-- *buffer = convert_8888_to_0565(_pixman_gradient_walker_pixel (&walker, t));
-+ *buffer = dither_8888_to_0565(_pixman_gradient_walker_pixel (&walker, t),
-+ toggle);
- }
-+ toggle ^= 1;
-
- ++buffer;
-
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
-@@ -369,17 +389,18 @@ linear_get_scanline_wide (pixman_iter_t
- pixman_expand ((uint64_t *)buffer, buffer, PIXMAN_a8r8g8b8, iter->width);
-
- return buffer;
- }
-
- void
- _pixman_linear_gradient_iter_init (pixman_image_t *image, pixman_iter_t *iter)
- {
-- if (linear_gradient_is_horizontal (
-+ // XXX: we can't use this optimization when dithering
-+ if (0 && linear_gradient_is_horizontal (
- iter->image, iter->x, iter->y, iter->width, iter->height))
- {
- if (iter->flags & ITER_16)
- linear_get_scanline_16 (iter, NULL);
- else if (iter->flags & ITER_NARROW)
- linear_get_scanline_narrow (iter, NULL);
- else
- linear_get_scanline_wide (iter, NULL);
-diff --git a/gfx/cairo/libpixman/src/pixman-radial-gradient.c b/gfx/cairo/libpixman/src/pixman-radial-gradient.c
---- a/gfx/cairo/libpixman/src/pixman-radial-gradient.c
-+++ b/gfx/cairo/libpixman/src/pixman-radial-gradient.c
-@@ -29,16 +29,18 @@
-
- #ifdef HAVE_CONFIG_H
- #include <config.h>
- #endif
- #include <stdlib.h>
- #include <math.h>
- #include "pixman-private.h"
-
-+#include "pixman-dither.h"
-+
- static inline pixman_fixed_32_32_t
- dot (pixman_fixed_48_16_t x1,
- pixman_fixed_48_16_t y1,
- pixman_fixed_48_16_t z1,
- pixman_fixed_48_16_t x2,
- pixman_fixed_48_16_t y2,
- pixman_fixed_48_16_t z2)
- {
-@@ -489,16 +491,17 @@ radial_get_scanline_16 (pixman_iter_t *i
- * <=> for every p, the radiuses associated with the two t solutions
- * have opposite sign
- */
- pixman_image_t *image = iter->image;
- int x = iter->x;
- int y = iter->y;
- int width = iter->width;
- uint16_t *buffer = iter->buffer;
-+ pixman_bool_t toggle = ((x ^ y) & 1);
-
- gradient_t *gradient = (gradient_t *)image;
- radial_gradient_t *radial = (radial_gradient_t *)image;
- uint16_t *end = buffer + width;
- pixman_gradient_walker_t walker;
- pixman_vector_t v, unit;
-
- /* reference point is the center of the pixel */
-@@ -575,25 +578,27 @@ radial_get_scanline_16 (pixman_iter_t *i
- unit.vector[0], unit.vector[1], 0);
- ddc = 2 * dot (unit.vector[0], unit.vector[1], 0,
- unit.vector[0], unit.vector[1], 0);
-
- while (buffer < end)
- {
- if (!mask || *mask++)
- {
-- *buffer = convert_8888_to_0565(
-+ *buffer = dither_8888_to_0565(
- radial_compute_color (radial->a, b, c,
- radial->inva,
- radial->delta.radius,
- radial->mindr,
- &walker,
-- image->common.repeat));
-+ image->common.repeat),
-+ toggle);
- }
-
-+ toggle ^= 1;
- b += db;
- c += dc;
- dc += ddc;
- ++buffer;
- }
- }
- else
- {
-@@ -621,31 +626,33 @@ radial_get_scanline_16 (pixman_iter_t *i
- radial->delta.x, radial->delta.y,
- radial->delta.radius);
- /* / pixman_fixed_1 / pixman_fixed_1 */
-
- c = fdot (pdx, pdy, -radial->c1.radius,
- pdx, pdy, radial->c1.radius);
- /* / pixman_fixed_1 / pixman_fixed_1 */
-
-- *buffer = convert_8888_to_0565 (
-+ *buffer = dither_8888_to_0565 (
- radial_compute_color (radial->a, b, c,
- radial->inva,
- radial->delta.radius,
- radial->mindr,
- &walker,
-- image->common.repeat));
-+ image->common.repeat),
-+ toggle);
- }
- else
- {
- *buffer = 0;
- }
- }
-
- ++buffer;
-+ toggle ^= 1;
-
- v.vector[0] += unit.vector[0];
- v.vector[1] += unit.vector[1];
- v.vector[2] += unit.vector[2];
- }
- }
-
- iter->y++;
-
diff --git a/gfx/cairo/pixman-enable-altivec-acceleration.patch b/gfx/cairo/pixman-enable-altivec-acceleration.patch
deleted file mode 100644
index d0685cce1..000000000
--- a/gfx/cairo/pixman-enable-altivec-acceleration.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-# HG changeset patch
-# Parent d0b3d7af190b3c62397ece2bc33b429d903e455d
-
-diff -r d0b3d7af190b gfx/cairo/libpixman/src/Makefile.in
---- a/gfx/cairo/libpixman/src/Makefile.in Sat Nov 24 14:26:11 2012 +0100
-+++ b/gfx/cairo/libpixman/src/Makefile.in Thu Nov 29 22:20:59 2012 +0100
-@@ -42,6 +42,10 @@
- endif
-
- ifdef GNU_CC
-+ifeq (ppc,$(findstring ppc,$(OS_TEST)))
-+USE_VMX=1
-+VMX_CFLAGS=-maltivec
-+endif
- ifeq (86,$(findstring 86,$(OS_TEST)))
- USE_MMX=1
- MMX_CFLAGS=-mmmx -Winline
-@@ -156,3 +160,6 @@
- pixman-sse2.$(OBJ_SUFFIX): COMPILE_CFLAGS += $(SSE2_CFLAGS)
-
- pixman-arm-neon.$(OBJ_SUFFIX): COMPILE_CFLAGS += $(ARM_NEON_CFLAGS)
-+
-+pixman-vmx.$(OBJ_SUFFIX): COMPILE_CFLAGS += $(VMX_CFLAGS)
-+
-diff -r d0b3d7af190b gfx/cairo/libpixman/src/pixman-vmx.c
---- a/gfx/cairo/libpixman/src/pixman-vmx.c Sat Nov 24 14:26:11 2012 +0100
-+++ b/gfx/cairo/libpixman/src/pixman-vmx.c Thu Nov 29 22:20:59 2012 +0100
-@@ -25,7 +25,10 @@
- * Based on fbmmx.c by Owen Taylor, Søren Sandmann and Nicholas Miell
- */
-
-+#ifdef HAVE_CONFIG_H
- #include <config.h>
-+#endif
-+
- #include "pixman-private.h"
- #include "pixman-combine32.h"
- #include <altivec.h>
diff --git a/gfx/cairo/pixman-export.patch b/gfx/cairo/pixman-export.patch
deleted file mode 100644
index 78ca8c669..000000000
--- a/gfx/cairo/pixman-export.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-diff --git a/gfx/cairo/libpixman/src/pixman-compiler.h b/gfx/cairo/libpixman/src/pixman-compiler.h
---- a/gfx/cairo/libpixman/src/pixman-compiler.h
-+++ b/gfx/cairo/libpixman/src/pixman-compiler.h
-@@ -59,26 +59,33 @@
- # ifndef force_inline
- # define force_inline inline
- # endif
- # ifndef noinline
- # define noinline
- # endif
- #endif
-
-+/* In libxul builds we don't ever want to export pixman symbols */
-+#if 1
-+# define PIXMAN_EXPORT cairo_public
-+#else
-+
- /* GCC visibility */
- #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(_WIN32)
- # define PIXMAN_EXPORT __attribute__ ((visibility("default")))
- /* Sun Studio 8 visibility */
- #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
- # define PIXMAN_EXPORT __global
- #else
- # define PIXMAN_EXPORT
- #endif
-
-+#endif
-+
- /* TLS */
- #if defined(PIXMAN_NO_TLS)
-
- # define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \
- static type name
- # define PIXMAN_GET_THREAD_LOCAL(name) \
- (&name)
-
diff --git a/gfx/cairo/pixman-image-transform.patch b/gfx/cairo/pixman-image-transform.patch
deleted file mode 100644
index 2f93d315a..000000000
--- a/gfx/cairo/pixman-image-transform.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-# HG changeset patch
-# User Jeff Muizelaar <jmuizelaar@mozilla.com>
-# Date 1299543337 18000
-# Node ID 57f411f16517fa3abc31b6b081dd31420c4d9b45
-# Parent e56ecd8b3a68c158025207c5fd081d043e28f5ce
-Bug 637828. Reset the transform on the dest image. r=joe
-
-We can get into a situation where the destination image has a transform
-because we use it as source. The transform set when the image is a source
-sticks around and when we use it as a destination pixman gets confused.
-
-It seems like the code at fault here is really pixman. I think that pixman
-should probably not be using a transformed fetch on the destination image under
-any circumstances.
-
-For example, in this case we're fetching destination pixels from a different
-part of the image than we're storing them to. I can't see any reason for
-wanting this behaviour.
-
-However, reseting the transform seemed like the easiest solution.
-
-diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c
---- a/gfx/cairo/cairo/src/cairo-image-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-image-surface.c
-@@ -1138,16 +1138,27 @@ _cairo_image_surface_composite (cairo_op
- return status;
-
- status = _cairo_image_surface_set_attributes (src, &src_attr,
- dst_x + width / 2.,
- dst_y + height / 2.);
- if (unlikely (status))
- goto CLEANUP_SURFACES;
-
-+ /* we sometimes get destinations with transforms.
-+ * we're not equiped to deal with this */
-+ {
-+ static const pixman_transform_t id = {
-+ {{ pixman_fixed_1, 0, 0 },
-+ { 0, pixman_fixed_1, 0 },
-+ { 0, 0, pixman_fixed_1 }}
-+ };
-+ pixman_image_set_transform (dst->pixman_image, &id);
-+ }
-+
- if (mask) {
- status = _cairo_image_surface_set_attributes (mask, &mask_attr,
- dst_x + width / 2.,
- dst_y + height / 2.);
- if (unlikely (status))
- goto CLEANUP_SURFACES;
-
- pixman_image_composite (_pixman_operator (op),
diff --git a/gfx/cairo/pixman-limits.patch b/gfx/cairo/pixman-limits.patch
deleted file mode 100644
index bc820e673..000000000
--- a/gfx/cairo/pixman-limits.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-commit 3c275c75e381184fb3fa0537c4bfce50b44690e7
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Fri Apr 20 00:12:32 2012 -0400
-
- limits
-
-diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c
-index 2ec2594..de05c0e 100644
---- a/pixman/pixman-utils.c
-+++ b/pixman/pixman-utils.c
-@@ -27,6 +27,7 @@
- #endif
- #include <stdio.h>
- #include <stdlib.h>
-+#include <limits.h>
-
- #include "pixman-private.h"
-
diff --git a/gfx/cairo/pixman-lowres-interp.patch b/gfx/cairo/pixman-lowres-interp.patch
deleted file mode 100644
index e2572f000..000000000
--- a/gfx/cairo/pixman-lowres-interp.patch
+++ /dev/null
@@ -1,222 +0,0 @@
-summary: Bug 689707. Use lower precision bilinear interpolation. r=joe
-
-diff --git a/gfx/cairo/libpixman/src/pixman-bits-image.c b/gfx/cairo/libpixman/src/pixman-bits-image.c
---- a/gfx/cairo/libpixman/src/pixman-bits-image.c
-+++ b/gfx/cairo/libpixman/src/pixman-bits-image.c
-@@ -124,18 +124,18 @@ bits_image_fetch_pixel_bilinear (bits_im
- int height = image->height;
- int x1, y1, x2, y2;
- uint32_t tl, tr, bl, br;
- int32_t distx, disty;
-
- x1 = x - pixman_fixed_1 / 2;
- y1 = y - pixman_fixed_1 / 2;
-
-- distx = (x1 >> 8) & 0xff;
-- disty = (y1 >> 8) & 0xff;
-+ distx = interpolation_coord(x1);
-+ disty = interpolation_coord(y1);
-
- x1 = pixman_fixed_to_int (x1);
- y1 = pixman_fixed_to_int (y1);
- x2 = x1 + 1;
- y2 = y1 + 1;
-
- if (repeat_mode != PIXMAN_REPEAT_NONE)
- {
-@@ -190,17 +190,17 @@ bits_image_fetch_bilinear_no_repeat_8888
-
- if (!pixman_transform_point_3d (bits->common.transform, &v))
- return;
-
- ux = ux_top = ux_bottom = bits->common.transform->matrix[0][0];
- x = x_top = x_bottom = v.vector[0] - pixman_fixed_1/2;
-
- y = v.vector[1] - pixman_fixed_1/2;
-- disty = (y >> 8) & 0xff;
-+ disty = interpolation_coord(y);
-
- /* Load the pointers to the first and second lines from the source
- * image that bilinear code must read.
- *
- * The main trick in this code is about the check if any line are
- * outside of the image;
- *
- * When I realize that a line (any one) is outside, I change
-@@ -299,17 +299,17 @@ bits_image_fetch_bilinear_no_repeat_8888
- while (buffer < end && x < 0)
- {
- uint32_t tr, br;
- int32_t distx;
-
- tr = top_row[pixman_fixed_to_int (x_top) + 1] | top_mask;
- br = bottom_row[pixman_fixed_to_int (x_bottom) + 1] | bottom_mask;
-
-- distx = (x >> 8) & 0xff;
-+ distx = interpolation_coord(x);
-
- *buffer++ = bilinear_interpolation (0, tr, 0, br, distx, disty);
-
- x += ux;
- x_top += ux_top;
- x_bottom += ux_bottom;
- mask += mask_inc;
- }
-@@ -324,17 +324,17 @@ bits_image_fetch_bilinear_no_repeat_8888
- uint32_t tl, tr, bl, br;
- int32_t distx;
-
- tl = top_row [pixman_fixed_to_int (x_top)] | top_mask;
- tr = top_row [pixman_fixed_to_int (x_top) + 1] | top_mask;
- bl = bottom_row [pixman_fixed_to_int (x_bottom)] | bottom_mask;
- br = bottom_row [pixman_fixed_to_int (x_bottom) + 1] | bottom_mask;
-
-- distx = (x >> 8) & 0xff;
-+ distx = interpolation_coord(x);
-
- *buffer = bilinear_interpolation (tl, tr, bl, br, distx, disty);
- }
-
- buffer++;
- x += ux;
- x_top += ux_top;
- x_bottom += ux_bottom;
-@@ -348,17 +348,17 @@ bits_image_fetch_bilinear_no_repeat_8888
- if (*mask)
- {
- uint32_t tl, bl;
- int32_t distx;
-
- tl = top_row [pixman_fixed_to_int (x_top)] | top_mask;
- bl = bottom_row [pixman_fixed_to_int (x_bottom)] | bottom_mask;
-
-- distx = (x >> 8) & 0xff;
-+ distx = interpolation_coord(x);
-
- *buffer = bilinear_interpolation (tl, 0, bl, 0, distx, disty);
- }
-
- buffer++;
- x += ux;
- x_top += ux_top;
- x_bottom += ux_bottom;
-@@ -675,18 +675,18 @@ bits_image_fetch_bilinear_affine (pixman
- const uint8_t *row2;
-
- if (mask && !mask[i])
- goto next;
-
- x1 = x - pixman_fixed_1 / 2;
- y1 = y - pixman_fixed_1 / 2;
-
-- distx = (x1 >> 8) & 0xff;
-- disty = (y1 >> 8) & 0xff;
-+ distx = interpolation_coord(x1);
-+ disty = interpolation_coord(y1);
-
- y1 = pixman_fixed_to_int (y1);
- y2 = y1 + 1;
- x1 = pixman_fixed_to_int (x1);
- x2 = x1 + 1;
-
- if (repeat_mode != PIXMAN_REPEAT_NONE)
- {
-diff --git a/gfx/cairo/libpixman/src/pixman-inlines.h b/gfx/cairo/libpixman/src/pixman-inlines.h
---- a/gfx/cairo/libpixman/src/pixman-inlines.h
-+++ b/gfx/cairo/libpixman/src/pixman-inlines.h
-@@ -76,16 +76,31 @@ repeat (pixman_repeat_t repeat, int *c,
- {
- *c = MOD (*c, size * 2);
- if (*c >= size)
- *c = size * 2 - *c - 1;
- }
- return TRUE;
- }
-
-+#ifdef MOZ_GFX_OPTIMIZE_MOBILE
-+#define LOW_QUALITY_INTERPOLATION
-+#endif
-+
-+static force_inline int32_t
-+interpolation_coord(pixman_fixed_t t)
-+{
-+#ifdef LOW_QUALITY_INTERPOLATION
-+ return (t >> 12) & 0xf;
-+#else
-+ return (t >> 8) & 0xff;
-+#endif
-+}
-+
-+
- #if SIZEOF_LONG > 4
-
- static force_inline uint32_t
- bilinear_interpolation (uint32_t tl, uint32_t tr,
- uint32_t bl, uint32_t br,
- int distx, int disty)
- {
- uint64_t distxy, distxiy, distixy, distixiy;
-@@ -122,16 +137,44 @@ bilinear_interpolation (uint32_t tl, uin
- f = tl64 * distixiy + tr64 * distxiy + bl64 * distixy + br64 * distxy;
- r |= ((f >> 16) & 0x000000ff00000000ull) | (f & 0xff000000ull);
-
- return (uint32_t)(r >> 16);
- }
-
- #else
-
-+#ifdef LOW_QUALITY_INTERPOLATION
-+/* Based on Filter_32_opaque_portable from Skia */
-+static force_inline uint32_t
-+bilinear_interpolation(uint32_t a00, uint32_t a01,
-+ uint32_t a10, uint32_t a11,
-+ int x, int y)
-+{
-+ int xy = x * y;
-+ static const uint32_t mask = 0xff00ff;
-+
-+ int scale = 256 - 16*y - 16*x + xy;
-+ uint32_t lo = (a00 & mask) * scale;
-+ uint32_t hi = ((a00 >> 8) & mask) * scale;
-+
-+ scale = 16*x - xy;
-+ lo += (a01 & mask) * scale;
-+ hi += ((a01 >> 8) & mask) * scale;
-+
-+ scale = 16*y - xy;
-+ lo += (a10 & mask) * scale;
-+ hi += ((a10 >> 8) & mask) * scale;
-+
-+ lo += (a11 & mask) * xy;
-+ hi += ((a11 >> 8) & mask) * xy;
-+
-+ return ((lo >> 8) & mask) | (hi & ~mask);
-+}
-+#else
- static force_inline uint32_t
- bilinear_interpolation (uint32_t tl, uint32_t tr,
- uint32_t bl, uint32_t br,
- int distx, int disty)
- {
- int distxy, distxiy, distixy, distixiy;
- uint32_t f, r;
-
-@@ -164,17 +207,17 @@ bilinear_interpolation (uint32_t tl, uin
-
- /* Alpha */
- f = (tl & 0x0000ff00) * distixiy + (tr & 0x0000ff00) * distxiy
- + (bl & 0x0000ff00) * distixy + (br & 0x0000ff00) * distxy;
- r |= f & 0xff000000;
-
- return r;
- }
--
-+#endif
- #endif
-
- /*
- * For each scanline fetched from source image with PAD repeat:
- * - calculate how many pixels need to be padded on the left side
- * - calculate how many pixels need to be padded on the right side
- * - update width to only count pixels which are fetched from the image
- * All this information is returned via 'width', 'left_pad', 'right_pad'
diff --git a/gfx/cairo/pixman-rename-and-endian.patch b/gfx/cairo/pixman-rename-and-endian.patch
deleted file mode 100644
index 41006695f..000000000
--- a/gfx/cairo/pixman-rename-and-endian.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/gfx/cairo/libpixman/src/pixman.h b/gfx/cairo/libpixman/src/pixman.h
---- a/gfx/cairo/libpixman/src/pixman.h
-+++ b/gfx/cairo/libpixman/src/pixman.h
-@@ -64,16 +64,18 @@ SOFTWARE.
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
- #ifndef PIXMAN_H__
- #define PIXMAN_H__
-
-+#include "cairo-platform.h"
-+
- #include <pixman-version.h>
-
- /*
- * Standard integers
- */
- #if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || defined (_sgi) || defined (__sun) || defined (sun) || defined (__digital__)
- # include <inttypes.h>
- #elif defined (_MSC_VER)
diff --git a/gfx/cairo/pixman-xp-dll-workaround b/gfx/cairo/pixman-xp-dll-workaround
deleted file mode 100644
index e5d1fcbf8..000000000
--- a/gfx/cairo/pixman-xp-dll-workaround
+++ /dev/null
@@ -1,27 +0,0 @@
-diff --git a/gfx/cairo/libpixman/src/pixman-compiler.h b/gfx/cairo/libpixman/src/pixman-compiler.h
---- a/gfx/cairo/libpixman/src/pixman-compiler.h
-+++ b/gfx/cairo/libpixman/src/pixman-compiler.h
-@@ -114,20 +114,22 @@
-
- #elif defined(TLS)
-
- # define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \
- static TLS type name
- # define PIXMAN_GET_THREAD_LOCAL(name) \
- (&name)
-
--#elif defined(__MINGW32__)
-+#elif defined(__MINGW32__) || defined(PIXMAN_USE_XP_DLL_TLS_WORKAROUND)
-
- # define _NO_W32_PSEUDO_MODIFIERS
- # include <windows.h>
-+#undef IN
-+#undef OUT
-
- # define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \
- static volatile int tls_ ## name ## _initialized = 0; \
- static void *tls_ ## name ## _mutex = NULL; \
- static unsigned tls_ ## name ## _index; \
- \
- static type * \
- tls_ ## name ## _alloc (void) \
diff --git a/gfx/cairo/premultiply-alpha-solid-gradients.patch b/gfx/cairo/premultiply-alpha-solid-gradients.patch
deleted file mode 100644
index 665f64969..000000000
--- a/gfx/cairo/premultiply-alpha-solid-gradients.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-Fix single and multi-stop solid gradients by multiplying by the alpha component. r=roc
-
-This cairo commit that caused the problem: 2d790daa957471670f4ae0d3b22da89e4ee7111f.
-It was merged into mozilla-central with 1effb72d30cf
-
-diff --git a/gfx/cairo/cairo/src/cairo-pattern.c b/gfx/cairo/cairo/src/cairo-pattern.c
---- a/gfx/cairo/cairo/src/cairo-pattern.c
-+++ b/gfx/cairo/cairo/src/cairo-pattern.c
-@@ -2262,8 +2262,17 @@ _cairo_pattern_acquire_surface (const ca
-
- if (src->n_stops)
- {
-+ cairo_color_t color;
-+
-+ /* multiply by alpha */
-+ _cairo_color_init_rgba (&color,
-+ src->stops->color.red,
-+ src->stops->color.green,
-+ src->stops->color.blue,
-+ src->stops->color.alpha);
-+
- _cairo_pattern_init_solid (&solid,
-- &src->stops->color,
-+ &color,
- CAIRO_CONTENT_COLOR_ALPHA);
- }
- else
-@@ -2295,9 +2304,17 @@ _cairo_pattern_acquire_surface (const ca
- }
- if (i == src->n_stops) {
- cairo_solid_pattern_t solid;
-+ cairo_color_t color;
-+
-+ /* multiply by alpha */
-+ _cairo_color_init_rgba (&color,
-+ src->stops->color.red,
-+ src->stops->color.green,
-+ src->stops->color.blue,
-+ src->stops->color.alpha);
-
- _cairo_pattern_init_solid (&solid,
-- &src->stops->color,
-+ &color,
- CAIRO_CONTENT_COLOR_ALPHA);
-
- status =
diff --git a/gfx/cairo/quartz-cache-CGImageRef.patch b/gfx/cairo/quartz-cache-CGImageRef.patch
deleted file mode 100644
index f27f03081..000000000
--- a/gfx/cairo/quartz-cache-CGImageRef.patch
+++ /dev/null
@@ -1,173 +0,0 @@
-changeset: 42954:7881873b2b5d
-user: Robert O'Callahan <robert@ocallahan.org>
-date: Tue Jun 01 11:19:45 2010 +1200
-summary: Bug 552537. Cache the CGImageRef that we create for a CGBitmapContext so that we can take advantage of Quartz caching optimizations. r=jrmuizel
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-private.h b/gfx/cairo/cairo/src/cairo-quartz-private.h
---- a/gfx/cairo/cairo/src/cairo-quartz-private.h
-+++ b/gfx/cairo/cairo/src/cairo-quartz-private.h
-@@ -49,16 +49,24 @@ typedef struct cairo_quartz_surface {
-
- 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;
-+
- cairo_rectangle_int_t extents;
- } cairo_quartz_surface_t;
-
- typedef struct cairo_quartz_image_surface {
- cairo_surface_t base;
-
- cairo_rectangle_int_t extents;
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -1134,19 +1134,24 @@ _cairo_surface_to_cgimage (cairo_surface
- if (stype == CAIRO_SURFACE_TYPE_QUARTZ) {
- 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)) {
-- *image_out = CGBitmapContextCreateImage (surface->cgContext);
-- if (*image_out)
-- return CAIRO_STATUS_SUCCESS;
-+ if (!surface->bitmapContextImage) {
-+ surface->bitmapContextImage =
-+ CGBitmapContextCreateImage (surface->cgContext);
-+ }
-+ if (surface->bitmapContextImage) {
-+ *image_out = CGImageRetain (surface->bitmapContextImage);
-+ return CAIRO_STATUS_SUCCESS;
-+ }
- }
- }
-
- if (stype != CAIRO_SURFACE_TYPE_IMAGE) {
- status = _cairo_surface_acquire_source_image (source,
- &isurf, &image_extra);
- if (status)
- return status;
-@@ -1589,16 +1594,29 @@ _cairo_quartz_setup_radial_source (cairo
-
- CGColorSpaceRelease(rgb);
- CGFunctionRelease(gradFunc);
-
- state->action = DO_SHADING;
- }
-
- /**
-+ * 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,
-@@ -1609,16 +1627,18 @@ _cairo_quartz_setup_state (cairo_quartz_
- cairo_status_t status;
-
- state.context = context;
- state.image = NULL;
- state.imageSurface = 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);
-@@ -1936,16 +1956,21 @@ _cairo_quartz_surface_finish (void *abst
- /* 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) {
- cairo_surface_destroy (surface->imageSurfaceEquiv);
- surface->imageSurfaceEquiv = NULL;
- }
-
- if (surface->imageData) {
- free (surface->imageData);
- surface->imageData = NULL;
-@@ -2006,16 +2031,18 @@ _cairo_quartz_surface_acquire_dest_image
- cairo_rectangle_int_t *image_rect,
- void **image_extra)
- {
- cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface;
- cairo_int_status_t status;
-
- ND((stderr, "%p _cairo_quartz_surface_acquire_dest_image\n", surface));
-
-+ _cairo_quartz_surface_will_change (surface);
-+
- status = _cairo_quartz_get_image (surface, image_out);
- if (status)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- *image_rect = surface->extents;
- *image_extra = NULL;
-
- return CAIRO_STATUS_SUCCESS;
-@@ -2939,16 +2966,17 @@ _cairo_quartz_surface_create_internal (C
- */
- CGContextSaveGState (cgContext);
-
- surface->cgContext = cgContext;
- surface->cgContextBaseCTM = CGContextGetCTM (cgContext);
-
- surface->imageData = NULL;
- surface->imageSurfaceEquiv = NULL;
-+ surface->bitmapContextImage = NULL;
-
- 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
-
diff --git a/gfx/cairo/quartz-cg-layers-fix-fallback.patch b/gfx/cairo/quartz-cg-layers-fix-fallback.patch
deleted file mode 100644
index bcebab350..000000000
--- a/gfx/cairo/quartz-cg-layers-fix-fallback.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-Bug 572912. Fix surface type passed to cairo_quartz_surface_create during fallback for CGLayers. r=jrmuizel
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -2026,17 +2026,17 @@ _cairo_quartz_surface_acquire_image (voi
-
- /* 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_CONTENT_COLOR_ALPHA,
-+ 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);
-@@ -2049,16 +2049,17 @@ _cairo_quartz_surface_acquire_image (voi
- 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);
-
diff --git a/gfx/cairo/quartz-cglayers.patch b/gfx/cairo/quartz-cglayers.patch
deleted file mode 100644
index bb3d44d9e..000000000
--- a/gfx/cairo/quartz-cglayers.patch
+++ /dev/null
@@ -1,715 +0,0 @@
-changeset: 42959:e1964291f8ff
-user: Robert O'Callahan <robert@ocallahan.org>
-date: Tue Jun 01 11:33:23 2010 +1200
-summary: Bug 568189. Implement CGLayer-backed cairo-quartz surfaces. r=jrmuizel
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-private.h b/gfx/cairo/cairo/src/cairo-quartz-private.h
---- a/gfx/cairo/cairo/src/cairo-quartz-private.h
-+++ b/gfx/cairo/cairo/src/cairo-quartz-private.h
-@@ -57,16 +57,21 @@ typedef struct cairo_quartz_surface {
-
- /**
- * 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_quartz_surface_t;
-
- typedef struct cairo_quartz_image_surface {
- cairo_surface_t base;
-
- cairo_rectangle_int_t extents;
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -1110,18 +1110,17 @@ CreateRepeatingRadialGradientFunction (c
- 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_status_t
--_cairo_surface_to_cgimage (cairo_surface_t *target,
-- cairo_surface_t *source,
-+_cairo_surface_to_cgimage (cairo_surface_t *source,
- CGImageRef *image_out)
- {
- cairo_status_t status = CAIRO_STATUS_SUCCESS;
- cairo_surface_type_t stype = cairo_surface_get_type (source);
- cairo_image_surface_t *isurf;
- CGImageRef image;
- void *image_extra;
-
-@@ -1267,17 +1266,17 @@ _cairo_quartz_cairo_repeating_surface_pa
- 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 ((cairo_surface_t*) dest, pat_surf, &image);
-+ 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;
-@@ -1339,33 +1338,39 @@ _cairo_quartz_cairo_repeating_surface_pa
- }
-
- 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 and DO_TILED_IMAGE
-+ // 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
-@@ -1423,17 +1428,17 @@ _cairo_quartz_setup_fallback_source (cai
- _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 (&surface->base, fallback, &img);
-+ status = _cairo_surface_to_cgimage (fallback, &img);
- if (status) {
- state->action = DO_UNSUPPORTED;
- return;
- }
- if (img == NULL) {
- state->action = DO_NOTHING;
- return;
- }
-@@ -1624,16 +1629,17 @@ _cairo_quartz_setup_state (cairo_quartz_
- {
- 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)
-@@ -1689,33 +1695,43 @@ _cairo_quartz_setup_state (cairo_quartz_
- 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;
-
-- status = _cairo_surface_to_cgimage ((cairo_surface_t *) surface, pat_surf, &img);
-+ cairo_matrix_invert(&m);
-+ _cairo_quartz_cairo_matrix_to_quartz (&m, &state.transform);
-+
-+ if (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 && source->extend == CAIRO_EXTEND_NONE) {
-+ state.imageRect = CGRectMake (0, 0, quartz_surf->extents.width, quartz_surf->extents.height);
-+ state.layer = quartz_surf->cgLayer;
-+ state.action = DO_LAYER;
-+ return state;
-+ }
-+ }
-+
-+ status = _cairo_surface_to_cgimage (pat_surf, &img);
- if (status) {
- state.action = DO_UNSUPPORTED;
- return state;
- }
- if (img == NULL) {
- state.action = DO_NOTHING;
- return state;
- }
-
- CGContextSetRGBFillColor (surface->cgContext, 0, 0, 0, 1);
-
- state.image = img;
-
-- cairo_matrix_invert(&m);
-- _cairo_quartz_cairo_matrix_to_quartz (&m, &state.transform);
--
- is_bounded = _cairo_surface_get_extents (pat_surf, &extents);
- assert (is_bounded);
-
- if (source->extend == CAIRO_EXTEND_NONE) {
- state.imageRect = CGRectMake (0, 0, extents.width, extents.height);
- state.action = DO_IMAGE;
- return state;
- }
-@@ -1820,33 +1836,48 @@ _cairo_quartz_teardown_state (cairo_quar
-
- 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));
-+ 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_IMAGE) {
-- CGContextDrawImage (state->context, state->imageRect, state->image);
-+ 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);
-+ }
-+
- if (!_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);
- }
-- } else
-- CGContextDrawTiledImagePtr (state->context, state->imageRect, state->image);
-+ }
- }
-
-
- /*
- * get source/dest image implementation
- */
-
- /* Read the image from the surface's front buffer */
-@@ -1971,95 +2002,153 @@ _cairo_quartz_surface_finish (void *abst
- surface->imageSurfaceEquiv = NULL;
- }
-
- if (surface->imageData) {
- free (surface->imageData);
- surface->imageData = NULL;
- }
-
-+ if (surface->cgLayer) {
-+ CGLayerRelease (surface->cgLayer);
-+ }
-+
- return CAIRO_STATUS_SUCCESS;
- }
-
- static cairo_status_t
--_cairo_quartz_surface_acquire_source_image (void *abstract_surface,
-- cairo_image_surface_t **image_out,
-- void **image_extra)
-+_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;
-
-- //ND((stderr, "%p _cairo_quartz_surface_acquire_source_image\n", 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_CONTENT_COLOR_ALPHA,
-+ 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;
-+ } else {
-+ cairo_surface_destroy (tmp);
-+ }
-+ }
-+
- if (status)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
-- *image_extra = NULL;
--
- 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;
-- cairo_int_status_t status;
-
- ND((stderr, "%p _cairo_quartz_surface_acquire_dest_image\n", surface));
-
-- _cairo_quartz_surface_will_change (surface);
--
-- status = _cairo_quartz_get_image (surface, image_out);
-- if (status)
-- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
--
- *image_rect = surface->extents;
- *image_extra = NULL;
-
-- return CAIRO_STATUS_SUCCESS;
-+ _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)
- {
-- //cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface;
--
-- //ND((stderr, "%p _cairo_quartz_surface_release_dest_image\n", surface));
-+ /* 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_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, 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;
-@@ -2113,17 +2202,17 @@ _cairo_quartz_surface_clone_similar (voi
- _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 ((cairo_surface_t*) abstract_surface, src, &quartz_image);
-+ 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;
- }
-
-@@ -2194,17 +2283,18 @@ _cairo_quartz_surface_paint (void *abstr
- 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) {
-+ } 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"));
-@@ -2291,17 +2381,18 @@ _cairo_quartz_surface_fill (void *abstra
- // 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) {
-+ } 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;
-@@ -2416,17 +2507,18 @@ _cairo_quartz_surface_stroke (void *abst
- if (rv)
- goto BAIL;
-
- 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) {
-+ } 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);
-@@ -2511,17 +2603,18 @@ _cairo_quartz_surface_show_glyphs (void
- &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) {
-+ } 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;
- }
-
-@@ -2622,17 +2715,18 @@ _cairo_quartz_surface_show_glyphs (void
-
- CGContextShowGlyphsWithAdvances (state.context,
- cg_glyphs,
- cg_advances,
- num_glyphs);
-
- CGContextSetCTM (state.context, ctm);
-
-- if (state.action == DO_IMAGE || state.action == DO_TILED_IMAGE) {
-+ 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)
-@@ -2679,17 +2773,17 @@ _cairo_quartz_surface_mask_with_surface
- 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 ((cairo_surface_t *) surface, pat_surf, &img);
-+ 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;
- }
-
-@@ -2869,17 +2963,17 @@ _cairo_quartz_surface_clipper_intersect_
- }
-
- // 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_source_image,
-+ _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 */
-@@ -2950,16 +3044,17 @@ _cairo_quartz_surface_create_internal (C
- CGContextSaveGState (cgContext);
-
- surface->cgContext = cgContext;
- surface->cgContextBaseCTM = CGContextGetCTM (cgContext);
-
- surface->imageData = NULL;
- surface->imageSurfaceEquiv = NULL;
- surface->bitmapContextImage = NULL;
-+ surface->cgLayer = NULL;
-
- 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
-@@ -3002,16 +3097,88 @@ cairo_quartz_surface_create_for_cg_conte
- // 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)."
-+ * @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
-+ * with CAIRO_CONTENT_COLOR_ALPHA.
-+ * 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,
-+ 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, CAIRO_CONTENT_COLOR_ALPHA,
-+ 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, CAIRO_CONTENT_COLOR_ALPHA,
-+ 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, CAIRO_CONTENT_COLOR_ALPHA,
-+ 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
-diff --git a/gfx/cairo/cairo/src/cairo-quartz.h b/gfx/cairo/cairo/src/cairo-quartz.h
---- a/gfx/cairo/cairo/src/cairo-quartz.h
-+++ b/gfx/cairo/cairo/src/cairo-quartz.h
-@@ -45,16 +45,21 @@
- 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_cg_layer (cairo_surface_t *surface,
-+ 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
-
diff --git a/gfx/cairo/quartz-check-imageSurfaceEquiv.patch b/gfx/cairo/quartz-check-imageSurfaceEquiv.patch
deleted file mode 100644
index 1d84ab27e..000000000
--- a/gfx/cairo/quartz-check-imageSurfaceEquiv.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From: Daniel Holbert <dholbert@cs.stanford.edu>
-Bug 612662 patch 3: Drop cairo_quartz_surface_t's "imageSurfaceEquiv" member if we fail to create it. r=roc a=blocking-final+
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -3152,17 +3152,28 @@ cairo_quartz_surface_create (cairo_forma
- if (surf->base.status) {
- CGContextRelease (cgc);
- free (imageData);
- // create_internal will have set an error
- return (cairo_surface_t*) surf;
- }
-
- surf->imageData = imageData;
-- surf->imageSurfaceEquiv = cairo_image_surface_create_for_data (imageData, format, width, height, stride);
-+
-+ 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;
-+ }
-
- return (cairo_surface_t *) surf;
- }
-
- /**
- * cairo_quartz_surface_get_cg_context
- * @surface: the Cairo Quartz surface
- *
diff --git a/gfx/cairo/quartz-const-globals.patch b/gfx/cairo/quartz-const-globals.patch
deleted file mode 100644
index 8db32270a..000000000
--- a/gfx/cairo/quartz-const-globals.patch
+++ /dev/null
@@ -1,134 +0,0 @@
-# HG changeset patch
-# User Robert O'Callahan <robert@ocallahan.org>
-# Date 1249558626 -43200
-# Node ID 963b9451ad305924738d05d997a640698cd3af91
-# Parent e564f3ab4ea6e3b5dd9c4e9e6042d3a84c229dde
-Bug 508730. Clean up Quartz gradient code by moving some local variables to static const globals. r=jmuizelaar
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -684,51 +684,50 @@ ComputeGradientValue (void *info, const
- 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 float 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
-+};
-+
- static CGFunctionRef
- CreateGradientFunction (const cairo_gradient_pattern_t *gpat)
- {
- cairo_pattern_t *pat;
- float input_value_range[2] = { 0.f, 1.f };
-- float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
-- CGFunctionCallbacks callbacks = {
-- 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
-- };
-
- 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,
-- output_value_ranges,
-- &callbacks);
-+ gradient_output_value_ranges,
-+ &gradient_callbacks);
- }
-
- static CGFunctionRef
- CreateRepeatingLinearGradientFunction (cairo_quartz_surface_t *surface,
- const cairo_gradient_pattern_t *gpat,
- CGPoint *start, CGPoint *end,
- CGAffineTransform matrix)
- {
- cairo_pattern_t *pat;
- float input_value_range[2];
-- float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
-- CGFunctionCallbacks callbacks = {
-- 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
-- };
-
- CGPoint mstart, mend;
-
- double dx, dy;
- int x_rep_start = 0, x_rep_end = 0;
- int y_rep_start = 0, y_rep_end = 0;
-
- int rep_start, rep_end;
-@@ -787,18 +786,18 @@ CreateRepeatingLinearGradientFunction (c
- /* 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,
-- output_value_ranges,
-- &callbacks);
-+ 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
-@@ -847,20 +846,16 @@ CreateRepeatingRadialGradientFunction (c
- const cairo_gradient_pattern_t *gpat,
- CGPoint *start, double *start_radius,
- CGPoint *end, double *end_radius)
- {
- CGRect clip = CGContextGetClipBoundingBox (surface->cgContext);
- CGAffineTransform transform;
- cairo_pattern_t *pat;
- float input_value_range[2];
-- float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
-- CGFunctionCallbacks callbacks = {
-- 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
-- };
- 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 */
-@@ -927,18 +922,18 @@ CreateRepeatingRadialGradientFunction (c
- /* 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,
-- output_value_ranges,
-- &callbacks);
-+ gradient_output_value_ranges,
-+ &gradient_callbacks);
- }
-
- /* Obtain a CGImageRef from a #cairo_surface_t * */
-
- static void
- DataProviderReleaseCallback (void *info, const void *data, size_t size)
- {
- cairo_surface_t *surface = (cairo_surface_t *) info;
diff --git a/gfx/cairo/quartz-create-for-data.patch b/gfx/cairo/quartz-create-for-data.patch
deleted file mode 100644
index ae374fafe..000000000
--- a/gfx/cairo/quartz-create-for-data.patch
+++ /dev/null
@@ -1,309 +0,0 @@
-diff --git a/gfx/cairo/README b/gfx/cairo/README
---- a/gfx/cairo/README
-+++ b/gfx/cairo/README
-@@ -71,16 +71,18 @@ quartz-cache-CGImageRef.patch: cache CGI
- quartz-remove-snapshot.patch: remove broken implementation of backend snapshot
-
- quartz-cglayers.patch: add support for cairo surfaces backed by CGLayers
-
- quartz-cglayers-fix-fallback.patch: Bug 572912; fix bug in fallback code in previous patch
-
- quartz-get-image.patch: Bug 575521; add a way to get the image surface associated with a surface
-
-+quartz-create-for-data.patch: Bug 575521; add a way to create quartz surfaces backed with application-provided data
-+
- premultiply-alpha-solid-gradients.patch: bug 539165; multiply the solid color by the alpha component before using it for a solid surface
-
- xlib-initialize-members.path: bug 548793; initialize XRender version if the server doesn't have the extension
-
- remove-comma: remove a comma from enum
-
- d2d.patch: add d2d support
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-private.h b/gfx/cairo/cairo/src/cairo-quartz-private.h
---- a/gfx/cairo/cairo/src/cairo-quartz-private.h
-+++ b/gfx/cairo/cairo/src/cairo-quartz-private.h
-@@ -63,16 +63,18 @@ typedef struct cairo_quartz_surface {
- 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;
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -1880,20 +1880,21 @@ _cairo_quartz_surface_finish (void *abst
- surface->cgContext = NULL;
-
- if (surface->bitmapContextImage) {
- CGImageRelease (surface->bitmapContextImage);
- surface->bitmapContextImage = NULL;
- }
-
- if (surface->imageSurfaceEquiv) {
-- _cairo_image_surface_assume_ownership_of_data (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) {
-+ } else if (surface->imageData && surface->ownsData) {
- free (surface->imageData);
- }
-
- surface->imageData = NULL;
-
- if (surface->cgLayer) {
- CGLayerRelease (surface->cgLayer);
- }
-@@ -2888,16 +2889,17 @@ _cairo_quartz_surface_create_internal (C
-
- 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
-@@ -3031,23 +3033,103 @@ cairo_quartz_surface_create_cg_layer (ca
- *
- * 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;
-- int stride;
-+ 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);
-@@ -3058,47 +3140,30 @@ cairo_quartz_surface_create (cairo_forma
- {
- cgColorspace = CGColorSpaceCreateDeviceRGB();
- bitinfo = kCGBitmapByteOrder32Host;
- if (format == CAIRO_FORMAT_ARGB32)
- bitinfo |= kCGImageAlphaPremultipliedFirst;
- else
- bitinfo |= kCGImageAlphaNoneSkipFirst;
- bitsPerComponent = 8;
-- stride = width * 4;
- } else if (format == CAIRO_FORMAT_A8) {
- cgColorspace = NULL;
-- stride = width;
- 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));
- }
-
-- /* 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;
--
-- imageData = _cairo_malloc_ab (height, stride);
-- if (!imageData) {
-- CGColorSpaceRelease (cgColorspace);
-- return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
-- }
--
-- /* zero the memory to match the image surface behaviour */
-- memset (imageData, 0, height * stride);
--
- cgc = CGBitmapContextCreate (imageData,
- width,
- height,
- bitsPerComponent,
- stride,
- cgColorspace,
- bitinfo);
- CGColorSpaceRelease (cgColorspace);
-@@ -3118,16 +3183,17 @@ cairo_quartz_surface_create (cairo_forma
- CGContextRelease (cgc);
- free (imageData);
- // create_internal will have set an error
- return (cairo_surface_t*) surf;
- }
-
- surf->imageData = imageData;
- surf->imageSurfaceEquiv = cairo_image_surface_create_for_data (imageData, format, width, height, stride);
-+ surf->ownsData = FALSE;
-
- return (cairo_surface_t *) surf;
- }
-
- /**
- * cairo_quartz_surface_get_cg_context
- * @surface: the Cairo Quartz surface
- *
-diff --git a/gfx/cairo/cairo/src/cairo-quartz.h b/gfx/cairo/cairo/src/cairo-quartz.h
---- a/gfx/cairo/cairo/src/cairo-quartz.h
-+++ b/gfx/cairo/cairo/src/cairo-quartz.h
-@@ -45,16 +45,23 @@
- 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,
- 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);
-diff --git a/gfx/cairo/cairo/src/cairo-rename.h b/gfx/cairo/cairo/src/cairo-rename.h
---- a/gfx/cairo/cairo/src/cairo-rename.h
-+++ b/gfx/cairo/cairo/src/cairo-rename.h
-@@ -176,16 +176,17 @@
- #define cairo_qpainter_surface_get_image _moz_cairo_qpainter_surface_get_image
- #define cairo_qpainter_surface_get_qimage _moz_cairo_qpainter_surface_get_qimage
- #define cairo_qpainter_surface_get_qpainter _moz_cairo_qpainter_surface_get_qpainter
- #define cairo_quartz_font_face_create_for_atsu_font_id _moz_cairo_quartz_font_face_create_for_atsu_font_id
- #define cairo_quartz_font_face_create_for_cgfont _moz_cairo_quartz_font_face_create_for_cgfont
- #define cairo_quartz_image_surface_create _moz_cairo_quartz_image_surface_create
- #define cairo_quartz_image_surface_get_image _moz_cairo_quartz_image_surface_get_image
- #define cairo_quartz_surface_create _moz_cairo_quartz_surface_create
-+#define cairo_quartz_surface_create_for_data _moz_cairo_quartz_surface_create_for_data
- #define cairo_quartz_surface_create_for_cg_context _moz_cairo_quartz_surface_create_for_cg_context
- #define cairo_quartz_surface_get_cg_context _moz_cairo_quartz_surface_get_cg_context
- #define cairo_quartz_surface_get_image _moz_cairo_quartz_surface_get_image
- #define cairo_rectangle _moz_cairo_rectangle
- #define cairo_rectangle_list_destroy _moz_cairo_rectangle_list_destroy
- #define cairo_reference _moz_cairo_reference
- #define cairo_rel_curve_to _moz_cairo_rel_curve_to
- #define cairo_rel_line_to _moz_cairo_rel_line_to
diff --git a/gfx/cairo/quartz-fallback.patch b/gfx/cairo/quartz-fallback.patch
deleted file mode 100644
index ca41b6e1f..000000000
--- a/gfx/cairo/quartz-fallback.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-# HG changeset patch
-# User Robert O'Callahan <robert@ocallahan.org>
-# Date 1250204857 -43200
-# Node ID cc6bebbd93bb9d8606fe06b997f890acc17996fb
-# Parent caea8b548962f0df38e8e9032e9f57ef0fd099ec
-Bug 507939 - Remove erroneous clip rect fixup which caused repainting errors with repeating radial gradients on Mac. r=jmuizelaar
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -1033,38 +1033,29 @@ typedef enum {
- DO_TILED_IMAGE
- } cairo_quartz_action_t;
-
- static cairo_quartz_action_t
- _cairo_quartz_setup_fallback_source (cairo_quartz_surface_t *surface,
- const cairo_pattern_t *source)
- {
- CGRect clipBox = CGContextGetClipBoundingBox (surface->cgContext);
-- CGAffineTransform ctm;
- double x0, y0, w, h;
-
- cairo_surface_t *fallback;
- cairo_t *fallback_cr;
- CGImageRef img;
- cairo_pattern_t *source_copy;
-
- cairo_status_t status;
-
- if (clipBox.size.width == 0.0f ||
- clipBox.size.height == 0.0f)
- return DO_NOTHING;
-
-- // the clipBox is in userspace, so:
-- ctm = CGContextGetCTM (surface->cgContext);
-- ctm = CGAffineTransformInvert (ctm);
-- clipBox = CGRectApplyAffineTransform (clipBox, ctm);
--
-- // get the Y flip right -- the CTM will always have a Y flip in place
-- clipBox.origin.y = surface->extents.height - (clipBox.origin.y + clipBox.size.height);
--
- 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);
-@@ -1717,18 +1708,20 @@ _cairo_quartz_surface_paint (void *abstr
- action = _cairo_quartz_setup_source (surface, source);
-
- if (action == DO_SOLID || action == DO_PATTERN) {
- CGContextFillRect (surface->cgContext, CGRectMake(surface->extents.x,
- surface->extents.y,
- surface->extents.width,
- surface->extents.height));
- } else if (action == DO_SHADING) {
-+ CGContextSaveGState (surface->cgContext);
- CGContextConcatCTM (surface->cgContext, surface->sourceTransform);
- CGContextDrawShading (surface->cgContext, surface->sourceShading);
-+ CGContextRestoreGState (surface->cgContext);
- } else if (action == DO_IMAGE || action == DO_TILED_IMAGE) {
- CGContextSaveGState (surface->cgContext);
-
- CGContextConcatCTM (surface->cgContext, surface->sourceTransform);
- CGContextTranslateCTM (surface->cgContext, 0, surface->sourceImageRect.size.height);
- CGContextScaleCTM (surface->cgContext, 1, -1);
-
- if (action == DO_IMAGE)
diff --git a/gfx/cairo/quartz-first-stop.patch b/gfx/cairo/quartz-first-stop.patch
deleted file mode 100644
index 5ea4b916c..000000000
--- a/gfx/cairo/quartz-first-stop.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -690,31 +690,51 @@ ComputeGradientValue (void *info, const
- }
-
- static const float 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 float nonrepeating_gradient_input_value_range[2] = { -0.001f, 1.f };
-
- static CGFunctionRef
- CreateGradientFunction (const cairo_gradient_pattern_t *gpat)
- {
- cairo_pattern_t *pat;
-- float input_value_range[2] = { 0.f, 1.f };
-
- 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,
-+ 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,
diff --git a/gfx/cairo/quartz-fix-PAD.patch b/gfx/cairo/quartz-fix-PAD.patch
deleted file mode 100644
index 0e5ed3107..000000000
--- a/gfx/cairo/quartz-fix-PAD.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-From: Robert O'Callahan <robert@ocallahan.org>
-Bug 593270. Part 2: Treat EXTEND_PAD like EXTEND_NONE when painting. r=jrmuizel,a=joe
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -1464,35 +1464,35 @@ 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 ||
-+ 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 (source->extend == CAIRO_EXTEND_NONE ||
-- (CGContextDrawTiledImagePtr && source->extend == CAIRO_EXTEND_REPEAT))
-+ 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;
- }
- }
-@@ -1510,17 +1510,17 @@ _cairo_quartz_setup_surface_source (cair
- /* 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 (source->extend == CAIRO_EXTEND_NONE) {
-+ 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
diff --git a/gfx/cairo/quartz-get-image-performance.patch b/gfx/cairo/quartz-get-image-performance.patch
deleted file mode 100644
index ff3618cf8..000000000
--- a/gfx/cairo/quartz-get-image-performance.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-# HG changeset patch
-# User Matt Woodrow <mwoodrow@mozilla.com>
-# Date 1314162877 -43200
-# Node ID 87458c4670dcd16be5a5715d741ee2ca4cf18d0f
-# Parent 95eb700a64591cda694c284a9f8ad08c11e3dd97
-Bug 675837 - Only flush Quartz surfaces on the success paths during cairo_quartz_get_image. r=roc
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -1909,30 +1909,30 @@ _cairo_quartz_get_image (cairo_quartz_su
- 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;
- }
-
-- CGContextFlush(surface->cgContext);
--
- 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);
diff --git a/gfx/cairo/quartz-get-image.patch b/gfx/cairo/quartz-get-image.patch
deleted file mode 100644
index e95d82d54..000000000
--- a/gfx/cairo/quartz-get-image.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff --git a/gfx/cairo/README b/gfx/cairo/README
---- a/gfx/cairo/README
-+++ b/gfx/cairo/README
-@@ -69,16 +69,18 @@ quartz-state.patch: bug 522859; refactor
- quartz-cache-CGImageRef.patch: cache CGImageRef for a CGBitmapContext; when we reuse it, Quartz will cache stuff, improving performance
-
- quartz-remove-snapshot.patch: remove broken implementation of backend snapshot
-
- quartz-cglayers.patch: add support for cairo surfaces backed by CGLayers
-
- quartz-cglayers-fix-fallback.patch: Bug 572912; fix bug in fallback code in previous patch
-
-+quartz-get-image.patch: Bug 575521; add a way to get the image surface associated with a surface
-+
- premultiply-alpha-solid-gradients.patch: bug 539165; multiply the solid color by the alpha component before using it for a solid surface
-
- xlib-initialize-members.path: bug 548793; initialize XRender version if the server doesn't have the extension
-
- remove-comma: remove a comma from enum
-
- d2d.patch: add d2d support
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -1880,24 +1880,24 @@ _cairo_quartz_surface_finish (void *abst
- surface->cgContext = NULL;
-
- if (surface->bitmapContextImage) {
- CGImageRelease (surface->bitmapContextImage);
- surface->bitmapContextImage = NULL;
- }
-
- if (surface->imageSurfaceEquiv) {
-+ _cairo_image_surface_assume_ownership_of_data (surface->imageSurfaceEquiv);
- cairo_surface_destroy (surface->imageSurfaceEquiv);
- surface->imageSurfaceEquiv = NULL;
-+ } else if (surface->imageData) {
-+ free (surface->imageData);
- }
-
-- if (surface->imageData) {
-- free (surface->imageData);
-- surface->imageData = NULL;
-- }
-+ surface->imageData = NULL;
-
- if (surface->cgLayer) {
- CGLayerRelease (surface->cgLayer);
- }
-
- return CAIRO_STATUS_SUCCESS;
- }
-
-@@ -3200,16 +3200,28 @@ cairo_quartz_finish_cg_context_with_clip
- 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)
- {
-diff --git a/gfx/cairo/cairo/src/cairo-quartz.h b/gfx/cairo/cairo/src/cairo-quartz.h
---- a/gfx/cairo/cairo/src/cairo-quartz.h
-+++ b/gfx/cairo/cairo/src/cairo-quartz.h
-@@ -63,16 +63,19 @@ 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);
-diff --git a/gfx/cairo/cairo/src/cairo-rename.h b/gfx/cairo/cairo/src/cairo-rename.h
---- a/gfx/cairo/cairo/src/cairo-rename.h
-+++ b/gfx/cairo/cairo/src/cairo-rename.h
-@@ -178,16 +178,17 @@
- #define cairo_qpainter_surface_get_qpainter _moz_cairo_qpainter_surface_get_qpainter
- #define cairo_quartz_font_face_create_for_atsu_font_id _moz_cairo_quartz_font_face_create_for_atsu_font_id
- #define cairo_quartz_font_face_create_for_cgfont _moz_cairo_quartz_font_face_create_for_cgfont
- #define cairo_quartz_image_surface_create _moz_cairo_quartz_image_surface_create
- #define cairo_quartz_image_surface_get_image _moz_cairo_quartz_image_surface_get_image
- #define cairo_quartz_surface_create _moz_cairo_quartz_surface_create
- #define cairo_quartz_surface_create_for_cg_context _moz_cairo_quartz_surface_create_for_cg_context
- #define cairo_quartz_surface_get_cg_context _moz_cairo_quartz_surface_get_cg_context
-+#define cairo_quartz_surface_get_image _moz_cairo_quartz_surface_get_image
- #define cairo_rectangle _moz_cairo_rectangle
- #define cairo_rectangle_list_destroy _moz_cairo_rectangle_list_destroy
- #define cairo_reference _moz_cairo_reference
- #define cairo_rel_curve_to _moz_cairo_rel_curve_to
- #define cairo_rel_line_to _moz_cairo_rel_line_to
- #define cairo_rel_move_to _moz_cairo_rel_move_to
- #define cairo_reset_clip _moz_cairo_reset_clip
- #define cairo_restore _moz_cairo_restore
diff --git a/gfx/cairo/quartz-glyph-extents.patch b/gfx/cairo/quartz-glyph-extents.patch
deleted file mode 100644
index 311404292..000000000
--- a/gfx/cairo/quartz-glyph-extents.patch
+++ /dev/null
@@ -1,19 +0,0 @@
---- a/gfx/cairo/cairo/src/cairo-quartz-font.c Wed Dec 23 14:17:44 2009 -0500
-+++ b/gfx/cairo/cairo/src/cairo-quartz-font.c Wed Dec 23 20:45:00 2009 +0000
-@@ -420,6 +420,16 @@ _cairo_quartz_init_glyph_metrics (cairo_
- !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)
diff --git a/gfx/cairo/quartz-is-clear.patch b/gfx/cairo/quartz-is-clear.patch
deleted file mode 100644
index 714951b44..000000000
--- a/gfx/cairo/quartz-is-clear.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-commit df2b22c8c6677d531194579c82a55e855adff706
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Thu Apr 8 15:43:41 2010 -0400
-
- Propagate is_clear flag to quartz_image_surface
-
-diff --git a/src/cairo-quartz-image-surface.c b/src/cairo-quartz-image-surface.c
-index 5a624eb..b8809d5 100644
---- a/src/cairo-quartz-image-surface.c
-+++ b/src/cairo-quartz-image-surface.c
-@@ -146,6 +146,8 @@ _cairo_quartz_image_surface_flush (void *asurface)
- surface->image = newImage;
- CGImageRelease (oldImage);
-
-+ surface->base.is_clear = surface->imageSurface->base.is_clear;
-+
- return CAIRO_STATUS_SUCCESS;
- }
-
-@@ -267,6 +269,8 @@ cairo_quartz_image_surface_create (cairo_surface_t *surface)
- qisurf->image = image;
- qisurf->imageSurface = image_surface;
-
-+ qisurf->base.is_clear = image_surface->base.is_clear;
-+
- return &qisurf->base;
- }
-
diff --git a/gfx/cairo/quartz-layers-content.patch b/gfx/cairo/quartz-layers-content.patch
deleted file mode 100644
index 243d1f017..000000000
--- a/gfx/cairo/quartz-layers-content.patch
+++ /dev/null
@@ -1,125 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -2040,17 +2040,18 @@ _cairo_quartz_surface_create_similar (vo
- 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, width, height);
-+ 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
-@@ -2960,54 +2961,55 @@ cairo_quartz_surface_create_for_cg_conte
-
- 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
-- * with CAIRO_CONTENT_COLOR_ALPHA.
-+ * 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, CAIRO_CONTENT_COLOR_ALPHA,
-+ 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, CAIRO_CONTENT_COLOR_ALPHA,
-+ _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));
-@@ -3016,18 +3018,18 @@ cairo_quartz_surface_create_cg_layer (ca
- /* 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, CAIRO_CONTENT_COLOR_ALPHA,
-- width, height);
-+ 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;
-diff --git a/gfx/cairo/cairo/src/cairo-quartz.h b/gfx/cairo/cairo/src/cairo-quartz.h
---- a/gfx/cairo/cairo/src/cairo-quartz.h
-+++ b/gfx/cairo/cairo/src/cairo-quartz.h
-@@ -46,16 +46,17 @@ 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_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);
-
diff --git a/gfx/cairo/quartz-mark-dirty.patch b/gfx/cairo/quartz-mark-dirty.patch
deleted file mode 100644
index ddaaf94e8..000000000
--- a/gfx/cairo/quartz-mark-dirty.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-Date: Thu Jan 5 18:40:01 2012 -0500
-
-Bug 715704. Add a quartz implementation of mark_dirty_rectangle. r=roc
-
-We need to drop our CGImage cache when the surface has been changed by outside users.
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -3116,16 +3116,27 @@ _cairo_quartz_surface_clipper_intersect_
- 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,
-@@ -3138,17 +3149,17 @@ static const struct _cairo_surface_backe
- 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 */
-- NULL, /* mark_dirty_rectangle */
-+ _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,
diff --git a/gfx/cairo/quartz-mask-non-OVER.patch b/gfx/cairo/quartz-mask-non-OVER.patch
deleted file mode 100644
index a6d94be12..000000000
--- a/gfx/cairo/quartz-mask-non-OVER.patch
+++ /dev/null
@@ -1,80 +0,0 @@
-From: Robert O'Callahan <robert@ocallahan.org>
-Bug 579985. Using CGContextSetAlpha to implement mask alpha doesn't work for some operators. r=jrmuizel,a=blocking
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -2734,17 +2734,19 @@ _cairo_quartz_surface_mask (void *abstra
-
- if (IS_EMPTY(surface))
- return CAIRO_STATUS_SUCCESS;
-
- rv = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
- if (unlikely (rv))
- return rv;
-
-- if (mask->type == CAIRO_PATTERN_TYPE_SOLID) {
-+ /* 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 (surface, op, source, clip);
- CGContextSetAlpha (surface->cgContext, 1.0);
-
- return rv;
-diff --git a/layout/reftests/bugs/579985-1-ref.html b/layout/reftests/bugs/579985-1-ref.html
-new file mode 100644
---- /dev/null
-+++ b/layout/reftests/bugs/579985-1-ref.html
-@@ -0,0 +1,6 @@
-+<!DOCTYPE HTML>
-+<html>
-+<body>
-+<div style="width:100px; height:100px; background:blue; opacity:0.5;">Hello</div>
-+</body>
-+</html>
-diff --git a/layout/reftests/bugs/579985-1.html b/layout/reftests/bugs/579985-1.html
-new file mode 100644
---- /dev/null
-+++ b/layout/reftests/bugs/579985-1.html
-@@ -0,0 +1,16 @@
-+<!DOCTYPE HTML>
-+<html class="reftest-wait">
-+<head>
-+<script>
-+function doTest() {
-+ var d = document.getElementById("d");
-+ d.style.opacity = 0.75;
-+ document.documentElement.removeAttribute("class");
-+}
-+window.addEventListener("MozReftestInvalidate", doTest, false);
-+</script>
-+</head>
-+<body>
-+<div id="d" style="width:100px; height:100px; background:blue;">Hello</div>
-+</body>
-+</html>
-diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list
---- a/layout/reftests/bugs/reftest.list
-+++ b/layout/reftests/bugs/reftest.list
-@@ -1499,16 +1499,17 @@ random-if(layersGPUAccelerated) == 56499
- == 571347-3.html 571347-3-ref.html
- == 572598-1.html 572598-ref.html
- == 574898-1.html 574898-ref.html
- == 579655-1.html 579655-1-ref.html
- == 577838-1.html 577838-1-ref.html
- == 577838-2.html 577838-2-ref.html
- random-if(layersGPUAccelerated) == 579323-1.html 579323-1-ref.html
- == 579349-1.html 579349-1-ref.html
-+== 579985-1.html 579985-1-ref.html
- == 580160-1.html 580160-1-ref.html
- HTTP(..) == 580863-1.html 580863-1-ref.html
- random-if(layersGPUAccelerated) == 581317-1.html 581317-1-ref.html
- == 581579-1.html 581579-1-ref.html
- == 582037-1a.html 582037-1-ref.html
- == 582037-1b.html 582037-1-ref.html
- == 582037-2a.html 582037-2-ref.html
- == 582037-2b.html 582037-2-ref.html
diff --git a/gfx/cairo/quartz-minimize-gradient-repeat.patch b/gfx/cairo/quartz-minimize-gradient-repeat.patch
deleted file mode 100644
index 9782bef11..000000000
--- a/gfx/cairo/quartz-minimize-gradient-repeat.patch
+++ /dev/null
@@ -1,561 +0,0 @@
-# HG changeset patch
-# User Robert O'Callahan <robert@ocallahan.org>
-# Date 1249558989 -43200
-# Node ID 0bac4c903d2bb1d5c0d5426209001fc2a77cc105
-# Parent 963b9451ad305924738d05d997a640698cd3af91
-Bug 508730. Don't repeat a Quartz gradient more times than necessary, to avoid Quartz quality problems when there are lots of repeated color stops. r=jmuizelaar
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -710,82 +710,100 @@ CreateGradientFunction (const cairo_grad
- return CGFunctionCreate (pat,
- 1,
- 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,
-- CGAffineTransform matrix)
-+ cairo_rectangle_int_t *extents)
- {
- cairo_pattern_t *pat;
- float 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;
-
-- CGPoint mstart, mend;
-+ 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);
-
-- double dx, dy;
-- int x_rep_start = 0, x_rep_end = 0;
-- int y_rep_start = 0, y_rep_end = 0;
-+ 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);
-
-- int rep_start, rep_end;
--
-- // figure out how many times we'd need to repeat the gradient pattern
-- // to cover the whole (transformed) surface area
-- mstart = CGPointApplyAffineTransform (*start, matrix);
-- mend = CGPointApplyAffineTransform (*end, matrix);
--
-- dx = fabs (mend.x - mstart.x);
-- dy = fabs (mend.y - mstart.y);
--
-- if (dx > 1e-6) {
-- x_rep_start = (int) ceil(MIN(mstart.x, mend.x) / dx);
-- x_rep_end = (int) ceil((surface->extents.width - MAX(mstart.x, mend.x)) / dx);
--
-- if (mend.x < mstart.x) {
-- int swap = x_rep_end;
-- x_rep_end = x_rep_start;
-- x_rep_start = swap;
-- }
-- }
--
-- if (dy > 1e-6) {
-- y_rep_start = (int) ceil(MIN(mstart.y, mend.y) / dy);
-- y_rep_end = (int) ceil((surface->extents.width - MAX(mstart.y, mend.y)) / dy);
--
-- if (mend.y < mstart.y) {
-- int swap = y_rep_end;
-- y_rep_end = y_rep_start;
-- y_rep_start = swap;
-- }
-- }
--
-- rep_start = MAX(x_rep_start, y_rep_start);
-- rep_end = MAX(x_rep_end, y_rep_end);
--
-- // extend the line between start and end by rep_start times from the start
-- // and rep_end times from the end
--
-- dx = end->x - start->x;
-- dy = end->y - start->y;
--
-- start->x = start->x - dx * rep_start;
-- start->y = start->y - dy * rep_start;
--
-- end->x = end->x + dx * rep_end;
-- end->y = end->y + dy * rep_end;
-+ /* 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] = 0.0 - 1.0 * rep_start;
-- input_value_range[1] = 1.0 + 1.0 * rep_end;
-+ 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,
-@@ -840,35 +858,43 @@ UpdateRadialParameterToIncludePoint(doub
- }
- }
-
- /* 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)
-+ CGPoint *end, double *end_radius,
-+ cairo_rectangle_int_t *extents)
- {
-- CGRect clip = CGContextGetClipBoundingBox (surface->cgContext);
-- CGAffineTransform transform;
- cairo_pattern_t *pat;
- float 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;
-
-- _cairo_quartz_cairo_matrix_to_quartz (&gpat->base.matrix, &transform);
-- /* clip is in cairo device coordinates; get it into cairo user space */
-- clip = CGRectApplyAffineTransform (clip, transform);
-+ 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 {
-@@ -878,36 +904,37 @@ CreateRepeatingRadialGradientFunction (c
- 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,
-- clip.origin.x, clip.origin.y);
-+ bounds_x1, bounds_y1);
- UpdateRadialParameterToIncludePoint(&t_temp, inner, dr, dx, dy,
-- clip.origin.x + clip.size.width, clip.origin.y);
-+ bounds_x2, bounds_y1);
- UpdateRadialParameterToIncludePoint(&t_temp, inner, dr, dx, dy,
-- clip.origin.x + clip.size.width, clip.origin.y + clip.size.height);
-+ bounds_x2, bounds_y2);
- UpdateRadialParameterToIncludePoint(&t_temp, inner, dr, dx, dy,
-- clip.origin.x, clip.origin.y + clip.size.height);
-+ 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.
-- Also, add a small fudge factor to avoid rounding issues. Since the
-- circles are alway expanding and containing the earlier circles, this is
-- OK. */
-- t_temp += 1e-6;
-+ 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) {
-@@ -1218,33 +1245,57 @@ _cairo_quartz_setup_fallback_source (cai
- surface->sourceImageRect = CGRectMake (0.0, 0.0, w, h);
- surface->sourceImage = img;
- surface->sourceImageSurface = fallback;
- surface->sourceTransform = CGAffineTransformMakeTranslation (x0, y0);
-
- return 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 cairo_quartz_action_t
- _cairo_quartz_setup_linear_source (cairo_quartz_surface_t *surface,
-- const cairo_linear_pattern_t *lpat)
-+ const cairo_linear_pattern_t *lpat,
-+ cairo_rectangle_int_t *extents)
- {
- 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 (surface->cgContext, 0., 0., 0., 0.);
- CGContextSetRGBFillColor (surface->cgContext, 0., 0., 0., 0.);
- return DO_SOLID;
- }
-
-+ 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.
-+ */
-+ return _cairo_quartz_setup_fallback_source (surface, abspat);
-+ }
-+
- mat = abspat->matrix;
- cairo_matrix_invert (&mat);
- _cairo_quartz_cairo_matrix_to_quartz (&mat, &surface->sourceTransform);
-
- rgb = CGColorSpaceCreateDeviceRGB();
-
- start = CGPointMake (_cairo_fixed_to_double (lpat->p1.x),
- _cairo_fixed_to_double (lpat->p1.y));
-@@ -1254,33 +1305,34 @@ _cairo_quartz_setup_linear_source (cairo
- if (abspat->extend == CAIRO_EXTEND_NONE ||
- abspat->extend == CAIRO_EXTEND_PAD)
- {
- gradFunc = CreateGradientFunction (&lpat->base);
- } else {
- gradFunc = CreateRepeatingLinearGradientFunction (surface,
- &lpat->base,
- &start, &end,
-- surface->sourceTransform);
-+ extents);
- }
-
- surface->sourceShading = CGShadingCreateAxial (rgb,
- start, end,
- gradFunc,
- extend, extend);
-
- CGColorSpaceRelease(rgb);
- CGFunctionRelease(gradFunc);
-
- return DO_SHADING;
- }
-
- static cairo_quartz_action_t
- _cairo_quartz_setup_radial_source (cairo_quartz_surface_t *surface,
-- const cairo_radial_pattern_t *rpat)
-+ const cairo_radial_pattern_t *rpat,
-+ cairo_rectangle_int_t *extents)
- {
- 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);
-@@ -1322,17 +1374,18 @@ _cairo_quartz_setup_radial_source (cairo
- 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);
-+ &end, &r2,
-+ extents);
- }
-
- surface->sourceShading = CGShadingCreateRadial (rgb,
- start,
- r1,
- end,
- r2,
- gradFunc,
-@@ -1341,17 +1394,18 @@ _cairo_quartz_setup_radial_source (cairo
- CGColorSpaceRelease(rgb);
- CGFunctionRelease(gradFunc);
-
- return DO_SHADING;
- }
-
- static cairo_quartz_action_t
- _cairo_quartz_setup_source (cairo_quartz_surface_t *surface,
-- const cairo_pattern_t *source)
-+ const cairo_pattern_t *source,
-+ cairo_rectangle_int_t *extents)
- {
- assert (!(surface->sourceImage || surface->sourceShading || surface->sourcePattern));
-
- surface->oldInterpolationQuality = CGContextGetInterpolationQuality (surface->cgContext);
- CGContextSetInterpolationQuality (surface->cgContext, _cairo_quartz_filter_to_quartz (source->filter));
-
- if (source->type == CAIRO_PATTERN_TYPE_SOLID) {
- cairo_solid_pattern_t *solid = (cairo_solid_pattern_t *) source;
-@@ -1367,24 +1421,22 @@ _cairo_quartz_setup_source (cairo_quartz
- solid->color.blue,
- solid->color.alpha);
-
- return DO_SOLID;
- }
-
- if (source->type == CAIRO_PATTERN_TYPE_LINEAR) {
- const cairo_linear_pattern_t *lpat = (const cairo_linear_pattern_t *)source;
-- return _cairo_quartz_setup_linear_source (surface, lpat);
--
-+ return _cairo_quartz_setup_linear_source (surface, lpat, extents);
- }
-
- if (source->type == CAIRO_PATTERN_TYPE_RADIAL) {
- const cairo_radial_pattern_t *rpat = (const cairo_radial_pattern_t *)source;
-- return _cairo_quartz_setup_radial_source (surface, rpat);
--
-+ return _cairo_quartz_setup_radial_source (surface, rpat, extents);
- }
-
- if (source->type == CAIRO_PATTERN_TYPE_SURFACE &&
- (source->extend == CAIRO_EXTEND_NONE || (CGContextDrawTiledImagePtr && source->extend == CAIRO_EXTEND_REPEAT)))
- {
- const cairo_surface_pattern_t *spat = (const cairo_surface_pattern_t *) source;
- cairo_surface_t *pat_surf = spat->surface;
- CGImageRef img;
-@@ -1852,17 +1904,17 @@ _cairo_quartz_surface_paint (void *abstr
- if (IS_EMPTY(surface))
- return CAIRO_STATUS_SUCCESS;
-
- if (op == CAIRO_OPERATOR_DEST)
- return CAIRO_STATUS_SUCCESS;
-
- CGContextSetCompositeOperation (surface->cgContext, _cairo_quartz_cairo_operator_to_quartz (op));
-
-- action = _cairo_quartz_setup_source (surface, source);
-+ action = _cairo_quartz_setup_source (surface, source, NULL);
-
- if (action == DO_SOLID || action == DO_PATTERN) {
- CGContextFillRect (surface->cgContext, CGRectMake(surface->extents.x,
- surface->extents.y,
- surface->extents.width,
- surface->extents.height));
- } else if (action == DO_SHADING) {
- CGContextSaveGState (surface->cgContext);
-@@ -1886,16 +1938,35 @@ _cairo_quartz_surface_paint (void *abstr
- }
-
- _cairo_quartz_teardown_source (surface, source);
-
- 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_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,
-@@ -1926,17 +1997,27 @@ _cairo_quartz_surface_fill (void *abstra
- return CAIRO_STATUS_SUCCESS;
- }
-
- CGContextSaveGState (surface->cgContext);
-
- CGContextSetShouldAntialias (surface->cgContext, (antialias != CAIRO_ANTIALIAS_NONE));
- CGContextSetCompositeOperation (surface->cgContext, _cairo_quartz_cairo_operator_to_quartz (op));
-
-- action = _cairo_quartz_setup_source (surface, source);
-+ 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);
-+ action = _cairo_quartz_setup_source (surface, source, &path_extents);
-+ } else {
-+ action = _cairo_quartz_setup_source (surface, source, NULL);
-+ }
-
- CGContextBeginPath (surface->cgContext);
-
- stroke.cgContext = surface->cgContext;
- stroke.ctm_inverse = NULL;
- rv = _cairo_quartz_cairo_path_to_quartz_context (path, &stroke);
- if (rv)
- goto BAIL;
-@@ -2059,17 +2140,24 @@ _cairo_quartz_surface_stroke (void *abst
-
- CGContextSetLineDash (surface->cgContext, style->dash_offset, fdash, max_dashes);
- if (fdash != sdash)
- free (fdash);
- }
-
- CGContextSetCompositeOperation (surface->cgContext, _cairo_quartz_cairo_operator_to_quartz (op));
-
-- action = _cairo_quartz_setup_source (surface, source);
-+ if (_cairo_quartz_source_needs_extents (source))
-+ {
-+ cairo_rectangle_int_t path_extents;
-+ _cairo_path_fixed_approximate_stroke_extents (path, style, ctm, &path_extents);
-+ action = _cairo_quartz_setup_source (surface, source, &path_extents);
-+ } else {
-+ action = _cairo_quartz_setup_source (surface, source, NULL);
-+ }
-
- CGContextBeginPath (surface->cgContext);
-
- stroke.cgContext = surface->cgContext;
- stroke.ctm_inverse = ctm_inverse;
- rv = _cairo_quartz_cairo_path_to_quartz_context (path, &stroke);
- if (rv)
- goto BAIL;
-@@ -2180,17 +2268,26 @@ _cairo_quartz_surface_show_glyphs (void
- if (op == CAIRO_OPERATOR_DEST)
- return CAIRO_STATUS_SUCCESS;
-
- if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_QUARTZ)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- CGContextSaveGState (surface->cgContext);
-
-- action = _cairo_quartz_setup_source (surface, source);
-+ if (_cairo_quartz_source_needs_extents (source))
-+ {
-+ cairo_rectangle_int_t glyph_extents;
-+ _cairo_scaled_font_glyph_device_extents (scaled_font, glyphs, num_glyphs,
-+ &glyph_extents);
-+ action = _cairo_quartz_setup_source (surface, source, &glyph_extents);
-+ } else {
-+ action = _cairo_quartz_setup_source (surface, source, NULL);
-+ }
-+
- if (action == DO_SOLID || action == DO_PATTERN) {
- CGContextSetTextDrawingMode (surface->cgContext, kCGTextFill);
- } else if (action == DO_IMAGE || action == DO_TILED_IMAGE || action == DO_SHADING) {
- CGContextSetTextDrawingMode (surface->cgContext, kCGTextClip);
- isClipping = TRUE;
- } else {
- if (action != DO_NOTHING)
- rv = CAIRO_INT_STATUS_UNSUPPORTED;
diff --git a/gfx/cairo/quartz-optimize-OVER.patch b/gfx/cairo/quartz-optimize-OVER.patch
deleted file mode 100644
index 2c587459b..000000000
--- a/gfx/cairo/quartz-optimize-OVER.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From: Robert O'Callahan <robert@ocallahan.org>
-Bug 579885. Part 4: Paint opaque surfaces using kPrivateCGCompositeCopy when possible. r=jrmuizel,a=blocking
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -122,16 +122,17 @@ static void (*CGContextClipToMaskPtr) (C
- static void (*CGContextDrawTiledImagePtr) (CGContextRef, CGRect, CGImageRef) = NULL;
- static unsigned int (*CGContextGetTypePtr) (CGContextRef) = NULL;
- static void (*CGContextSetShouldAntialiasFontsPtr) (CGContextRef, bool) = NULL;
- static bool (*CGContextGetShouldAntialiasFontsPtr) (CGContextRef) = NULL;
- static bool (*CGContextGetShouldSmoothFontsPtr) (CGContextRef) = NULL;
- static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL;
- static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;
- static void (*CGContextReplacePathWithClipPathPtr) (CGContextRef) = NULL;
-+static CGFloat (*CGContextGetAlphaPtr) (CGContextRef) = NULL;
-
- static SInt32 _cairo_quartz_osx_version = 0x0;
-
- static cairo_bool_t _cairo_quartz_symbol_lookup_done = FALSE;
-
- /*
- * Utility functions
- */
-@@ -157,16 +158,17 @@ static void quartz_ensure_symbols(void)
- CGContextDrawTiledImagePtr = dlsym(RTLD_DEFAULT, "CGContextDrawTiledImage");
- CGContextGetTypePtr = dlsym(RTLD_DEFAULT, "CGContextGetType");
- CGContextSetShouldAntialiasFontsPtr = dlsym(RTLD_DEFAULT, "CGContextSetShouldAntialiasFonts");
- CGContextGetShouldAntialiasFontsPtr = dlsym(RTLD_DEFAULT, "CGContextGetShouldAntialiasFonts");
- CGContextGetShouldSmoothFontsPtr = dlsym(RTLD_DEFAULT, "CGContextGetShouldSmoothFonts");
- CGContextReplacePathWithClipPathPtr = dlsym(RTLD_DEFAULT, "CGContextReplacePathWithClipPath");
- CGContextGetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
- CGContextSetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextSetAllowsFontSmoothing");
-+ CGContextGetAlphaPtr = dlsym(RTLD_DEFAULT, "CGContextGetAlpha");
-
- if (Gestalt(gestaltSystemVersion, &_cairo_quartz_osx_version) != noErr) {
- // assume 10.4
- _cairo_quartz_osx_version = 0x1040;
- }
-
- _cairo_quartz_symbol_lookup_done = TRUE;
- }
-@@ -1698,16 +1700,28 @@ _cairo_quartz_setup_state (cairo_quartz_
-
- 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) &&
-+ 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;
- }
diff --git a/gfx/cairo/quartz-refactor-surface-setup.patch b/gfx/cairo/quartz-refactor-surface-setup.patch
deleted file mode 100644
index 22e2d0ee1..000000000
--- a/gfx/cairo/quartz-refactor-surface-setup.patch
+++ /dev/null
@@ -1,290 +0,0 @@
-From: Robert O'Callahan <robert@ocallahan.org>
-Bug 593270. Part 1: Move surface setup code to a helper function. r=jrmuizel,a=joe
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -1455,16 +1455,147 @@ _cairo_quartz_setup_radial_source (cairo
- 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 ||
-+ (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_status_t status;
-+
-+ cairo_matrix_invert(&m);
-+ _cairo_quartz_cairo_matrix_to_quartz (&m, &state->transform);
-+
-+ /* Draw nonrepeating CGLayer surface using DO_LAYER */
-+ if (source->extend == CAIRO_EXTEND_NONE ||
-+ (CGContextDrawTiledImagePtr && source->extend == CAIRO_EXTEND_REPEAT))
-+ 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 (source->extend == CAIRO_EXTEND_NONE) {
-+ 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) {
-@@ -1566,133 +1697,19 @@ _cairo_quartz_setup_state (cairo_quartz_
- }
-
- 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 &&
-- (source->extend == CAIRO_EXTEND_NONE || (CGContextDrawTiledImagePtr && source->extend == CAIRO_EXTEND_REPEAT)))
-- {
-+ if (source->type == CAIRO_PATTERN_TYPE_SURFACE) {
- const cairo_surface_pattern_t *spat = (const cairo_surface_pattern_t *) source;
-- 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_matrix_invert(&m);
-- _cairo_quartz_cairo_matrix_to_quartz (&m, &state.transform);
--
-- if (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 && source->extend == CAIRO_EXTEND_NONE) {
-- state.imageRect = CGRectMake (0, 0, quartz_surf->extents.width, quartz_surf->extents.height);
-- state.layer = quartz_surf->cgLayer;
-- state.action = DO_LAYER;
-- return state;
-- }
-- }
--
-- status = _cairo_surface_to_cgimage (pat_surf, &img);
-- if (status) {
-- state.action = DO_UNSUPPORTED;
-- return state;
-- }
-- if (img == NULL) {
-- state.action = DO_NOTHING;
-- return state;
-- }
--
-- CGContextSetRGBFillColor (surface->cgContext, 0, 0, 0, 1);
--
-- state.image = img;
--
-- is_bounded = _cairo_surface_get_extents (pat_surf, &extents);
-- assert (is_bounded);
--
-- if (source->extend == CAIRO_EXTEND_NONE) {
-- state.imageRect = CGRectMake (0, 0, extents.width, extents.height);
-- state.action = DO_IMAGE;
-- return state;
-- }
--
-- /* 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 state;
-- }
--
-- /* Fall through to generic SURFACE case */
-- }
--
-- if (source->type == CAIRO_PATTERN_TYPE_SURFACE) {
-- 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 state;
-- }
-- if (status) {
-- state.action = DO_UNSUPPORTED;
-- return state;
-- }
--
-- 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;
-+ _cairo_quartz_setup_surface_source (surface, spat, extents, &state);
- return state;
- }
-
- state.action = DO_UNSUPPORTED;
- return state;
- }
-
- /**
diff --git a/gfx/cairo/quartz-remove-snapshot.patch b/gfx/cairo/quartz-remove-snapshot.patch
deleted file mode 100644
index 5cc2cddb4..000000000
--- a/gfx/cairo/quartz-remove-snapshot.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-changeset: 42958:dd0f1f0a96b3
-user: Robert O'Callahan <robert@ocallahan.org>
-date: Tue Jun 01 11:33:05 2010 +1200
-summary: Bug 568189. Part 3: Remove snapshot backend function since it doesn't work and we may as well just fall back. r=jrmuizel
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -1993,33 +1993,16 @@ _cairo_quartz_surface_acquire_source_ima
- if (status)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- *image_extra = NULL;
-
- return CAIRO_STATUS_SUCCESS;
- }
-
--static cairo_surface_t *
--_cairo_quartz_surface_snapshot (void *abstract_surface)
--{
-- cairo_int_status_t status;
-- cairo_quartz_surface_t *surface = abstract_surface;
-- cairo_image_surface_t *image;
--
-- if (surface->imageSurfaceEquiv)
-- return NULL;
--
-- status = _cairo_quartz_get_image (surface, &image);
-- if (unlikely (status))
-- return _cairo_surface_create_in_error (CAIRO_STATUS_NO_MEMORY);
--
-- return &image->base;
--}
--
- 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);
- }
-
-@@ -2916,17 +2899,17 @@ static const struct _cairo_surface_backe
- _cairo_quartz_surface_stroke,
- _cairo_quartz_surface_fill,
- #if CAIRO_HAS_QUARTZ_FONT
- _cairo_quartz_surface_show_glyphs,
- #else
- NULL, /* show_glyphs */
- #endif
-
-- _cairo_quartz_surface_snapshot,
-+ 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,
-
diff --git a/gfx/cairo/quartz-repeating-radial-gradients.patch b/gfx/cairo/quartz-repeating-radial-gradients.patch
deleted file mode 100644
index 67fca30d0..000000000
--- a/gfx/cairo/quartz-repeating-radial-gradients.patch
+++ /dev/null
@@ -1,305 +0,0 @@
-# HG changeset patch
-# User Robert O'Callahan <robert@ocallahan.org>
-# Date 1249558156 -43200
-# Node ID e564f3ab4ea6e3b5dd9c4e9e6042d3a84c229dde
-# Parent 6ef9993a30bf2f983c9d64d7441d2e3b6b935de1
-Bug 508227. Don't fallback to Quartz for repeating radial gradients. r=jmuizelaar
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -708,20 +708,20 @@ CreateGradientFunction (const cairo_grad
- 1,
- input_value_range,
- 4,
- output_value_ranges,
- &callbacks);
- }
-
- static CGFunctionRef
--CreateRepeatingGradientFunction (cairo_quartz_surface_t *surface,
-- const cairo_gradient_pattern_t *gpat,
-- CGPoint *start, CGPoint *end,
-- CGAffineTransform matrix)
-+CreateRepeatingLinearGradientFunction (cairo_quartz_surface_t *surface,
-+ const cairo_gradient_pattern_t *gpat,
-+ CGPoint *start, CGPoint *end,
-+ CGAffineTransform matrix)
- {
- cairo_pattern_t *pat;
- float input_value_range[2];
- float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
- CGFunctionCallbacks callbacks = {
- 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
- };
-
-@@ -791,16 +791,156 @@ CreateRepeatingGradientFunction (cairo_q
- return CGFunctionCreate (pat,
- 1,
- input_value_range,
- 4,
- output_value_ranges,
- &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)
-+{
-+ CGRect clip = CGContextGetClipBoundingBox (surface->cgContext);
-+ CGAffineTransform transform;
-+ cairo_pattern_t *pat;
-+ float input_value_range[2];
-+ float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
-+ CGFunctionCallbacks callbacks = {
-+ 0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
-+ };
-+ 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;
-+
-+ _cairo_quartz_cairo_matrix_to_quartz (&gpat->base.matrix, &transform);
-+ /* clip is in cairo device coordinates; get it into cairo user space */
-+ clip = CGRectApplyAffineTransform (clip, transform);
-+
-+ 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;
-+
-+ 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,
-+ clip.origin.x, clip.origin.y);
-+ UpdateRadialParameterToIncludePoint(&t_temp, inner, dr, dx, dy,
-+ clip.origin.x + clip.size.width, clip.origin.y);
-+ UpdateRadialParameterToIncludePoint(&t_temp, inner, dr, dx, dy,
-+ clip.origin.x + clip.size.width, clip.origin.y + clip.size.height);
-+ UpdateRadialParameterToIncludePoint(&t_temp, inner, dr, dx, dy,
-+ clip.origin.x, clip.origin.y + clip.size.height);
-+ /* UpdateRadialParameterToIncludePoint assumes t=0 means radius 0.
-+ But for the parameter values we use with Quartz, t_min means radius 0.
-+ Also, add a small fudge factor to avoid rounding issues. Since the
-+ circles are alway expanding and containing the earlier circles, this is
-+ OK. */
-+ t_temp += 1e-6;
-+ 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] = -t_max;
-+ input_value_range[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,
-+ output_value_ranges,
-+ &callbacks);
-+}
-+
- /* Obtain a CGImageRef from a #cairo_surface_t * */
-
- static void
- DataProviderReleaseCallback (void *info, const void *data, size_t size)
- {
- cairo_surface_t *surface = (cairo_surface_t *) info;
- cairo_surface_destroy (surface);
- }
-@@ -1112,23 +1252,24 @@ _cairo_quartz_setup_linear_source (cairo
- 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)
-+ abspat->extend == CAIRO_EXTEND_PAD)
- {
- gradFunc = CreateGradientFunction (&lpat->base);
- } else {
-- gradFunc = CreateRepeatingGradientFunction (surface,
-- &lpat->base,
-- &start, &end, surface->sourceTransform);
-+ gradFunc = CreateRepeatingLinearGradientFunction (surface,
-+ &lpat->base,
-+ &start, &end,
-+ surface->sourceTransform);
- }
-
- surface->sourceShading = CGShadingCreateAxial (rgb,
- start, end,
- gradFunc,
- extend, extend);
-
- CGColorSpaceRelease(rgb);
-@@ -1142,52 +1283,68 @@ _cairo_quartz_setup_radial_source (cairo
- const cairo_radial_pattern_t *rpat)
- {
- 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 (surface->cgContext, 0., 0., 0., 0.);
- CGContextSetRGBFillColor (surface->cgContext, 0., 0., 0., 0.);
- return DO_SOLID;
- }
-
-- if (abspat->extend == CAIRO_EXTEND_REPEAT ||
-- abspat->extend == CAIRO_EXTEND_REFLECT)
-- {
-- /* I started trying to map these to Quartz, but it's much harder
-- * then the linear case (I think it would involve doing multiple
-- * Radial shadings). So, instead, let's just render an image
-- * for pixman to draw the shading into, and use that.
-+ 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.
- */
-- return _cairo_quartz_setup_fallback_source (surface, &rpat->base.base);
-+ return _cairo_quartz_setup_fallback_source (surface, abspat);
- }
-
- mat = abspat->matrix;
- cairo_matrix_invert (&mat);
- _cairo_quartz_cairo_matrix_to_quartz (&mat, &surface->sourceTransform);
-
- rgb = CGColorSpaceCreateDeviceRGB();
-
-- start = CGPointMake (_cairo_fixed_to_double (rpat->c1.x),
-- _cairo_fixed_to_double (rpat->c1.y));
-- end = CGPointMake (_cairo_fixed_to_double (rpat->c2.x),
-- _cairo_fixed_to_double (rpat->c2.y));
-+ start = CGPointMake (c1x, c1y);
-+ end = CGPointMake (c2x, c2y);
-
-- gradFunc = CreateGradientFunction (&rpat->base);
-+ 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);
-+ }
-
- surface->sourceShading = CGShadingCreateRadial (rgb,
- start,
-- _cairo_fixed_to_double (rpat->r1),
-+ r1,
- end,
-- _cairo_fixed_to_double (rpat->r2),
-+ r2,
- gradFunc,
- extend, extend);
-
- CGColorSpaceRelease(rgb);
- CGFunctionRelease(gradFunc);
-
- return DO_SHADING;
- }
diff --git a/gfx/cairo/quartz-state.patch b/gfx/cairo/quartz-state.patch
deleted file mode 100644
index d4c04f706..000000000
--- a/gfx/cairo/quartz-state.patch
+++ /dev/null
@@ -1,1190 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-private.h b/gfx/cairo/cairo/src/cairo-quartz-private.h
---- a/gfx/cairo/cairo/src/cairo-quartz-private.h
-+++ b/gfx/cairo/cairo/src/cairo-quartz-private.h
-@@ -50,30 +50,16 @@ typedef struct cairo_quartz_surface {
- CGContextRef cgContext;
- CGAffineTransform cgContextBaseCTM;
-
- void *imageData;
- cairo_surface_t *imageSurfaceEquiv;
-
- cairo_surface_clipper_t clipper;
- cairo_rectangle_int_t extents;
--
-- /* These are stored while drawing operations are in place, set up
-- * by quartz_setup_source() and quartz_finish_source()
-- */
-- CGAffineTransform sourceTransform;
--
-- CGImageRef sourceImage;
-- cairo_surface_t *sourceImageSurface;
-- CGRect sourceImageRect;
--
-- CGShadingRef sourceShading;
-- CGPatternRef sourcePattern;
--
-- CGInterpolationQuality oldInterpolationQuality;
- } cairo_quartz_surface_t;
-
- typedef struct cairo_quartz_image_surface {
- cairo_surface_t base;
-
- cairo_rectangle_int_t extents;
-
- CGImageRef image;
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -1333,36 +1333,59 @@ _cairo_quartz_cairo_repeating_surface_pa
- return CAIRO_STATUS_SUCCESS;
- }
-
- typedef enum {
- DO_SOLID,
- DO_SHADING,
- DO_PATTERN,
- DO_IMAGE,
-+ DO_TILED_IMAGE,
- DO_UNSUPPORTED,
-- DO_NOTHING,
-- DO_TILED_IMAGE
-+ DO_NOTHING
- } cairo_quartz_action_t;
-
--static 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 and DO_TILED_IMAGE
-+ CGAffineTransform transform;
-+
-+ // Used with DO_IMAGE and DO_TILED_IMAGE
-+ CGImageRef image;
-+ cairo_surface_t *imageSurface;
-+ CGRect imageRect;
-+
-+ // 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)
-+ const cairo_pattern_t *source,
-+ cairo_quartz_drawing_state_t *state)
- {
-- CGRect clipBox = CGContextGetClipBoundingBox (surface->cgContext);
-+ 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)
-- return DO_NOTHING;
-+ 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 */
-@@ -1396,73 +1419,79 @@ _cairo_quartz_setup_fallback_source (cai
- &fallback->device_transform_inverse);
- status = _cairo_surface_paint (fallback,
- CAIRO_OPERATOR_SOURCE,
- &pattern.base, NULL);
- }
- #endif
-
- status = _cairo_surface_to_cgimage (&surface->base, fallback, &img);
-- if (status)
-- return DO_UNSUPPORTED;
-- if (img == NULL)
-- return DO_NOTHING;
--
-- surface->sourceImageRect = CGRectMake (0.0, 0.0, w, h);
-- surface->sourceImage = img;
-- surface->sourceImageSurface = fallback;
-- surface->sourceTransform = CGAffineTransformMakeTranslation (x0, y0);
--
-- return DO_IMAGE;
-+ 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 cairo_quartz_action_t
-+static void
- _cairo_quartz_setup_linear_source (cairo_quartz_surface_t *surface,
- const cairo_linear_pattern_t *lpat,
-- cairo_rectangle_int_t *extents)
-+ 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 (surface->cgContext, 0., 0., 0., 0.);
-- CGContextSetRGBFillColor (surface->cgContext, 0., 0., 0., 0.);
-- return DO_SOLID;
-+ 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.
- */
-- return _cairo_quartz_setup_fallback_source (surface, abspat);
-+ _cairo_quartz_setup_fallback_source (surface, abspat, state);
-+ return;
- }
-
- mat = abspat->matrix;
- cairo_matrix_invert (&mat);
-- _cairo_quartz_cairo_matrix_to_quartz (&mat, &surface->sourceTransform);
-+ _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));
-
-@@ -1472,31 +1501,32 @@ _cairo_quartz_setup_linear_source (cairo
- gradFunc = CreateGradientFunction (&lpat->base);
- } else {
- gradFunc = CreateRepeatingLinearGradientFunction (surface,
- &lpat->base,
- &start, &end,
- extents);
- }
-
-- surface->sourceShading = CGShadingCreateAxial (rgb,
-- start, end,
-- gradFunc,
-- extend, extend);
-+ state->shading = CGShadingCreateAxial (rgb,
-+ start, end,
-+ gradFunc,
-+ extend, extend);
-
- CGColorSpaceRelease(rgb);
- CGFunctionRelease(gradFunc);
-
-- return DO_SHADING;
-+ state->action = DO_SHADING;
- }
-
--static cairo_quartz_action_t
-+static void
- _cairo_quartz_setup_radial_source (cairo_quartz_surface_t *surface,
- const cairo_radial_pattern_t *rpat,
-- cairo_rectangle_int_t *extents)
-+ 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);
-@@ -1505,35 +1535,37 @@ _cairo_quartz_setup_radial_source (cairo
- 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 (surface->cgContext, 0., 0., 0., 0.);
-- CGContextSetRGBFillColor (surface->cgContext, 0., 0., 0., 0.);
-- return DO_SOLID;
-+ 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.
- */
-- return _cairo_quartz_setup_fallback_source (surface, abspat);
-+ _cairo_quartz_setup_fallback_source (surface, abspat, state);
-+ return;
- }
-
- mat = abspat->matrix;
- cairo_matrix_invert (&mat);
-- _cairo_quartz_cairo_matrix_to_quartz (&mat, &surface->sourceTransform);
-+ _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)
-@@ -1542,111 +1574,146 @@ _cairo_quartz_setup_radial_source (cairo
- } else {
- gradFunc = CreateRepeatingRadialGradientFunction (surface,
- &rpat->base,
- &start, &r1,
- &end, &r2,
- extents);
- }
-
-- surface->sourceShading = CGShadingCreateRadial (rgb,
-- start,
-- r1,
-- end,
-- r2,
-- gradFunc,
-- extend, extend);
-+ state->shading = CGShadingCreateRadial (rgb,
-+ start,
-+ r1,
-+ end,
-+ r2,
-+ gradFunc,
-+ extend, extend);
-
- CGColorSpaceRelease(rgb);
- CGFunctionRelease(gradFunc);
-
-- return DO_SHADING;
-+ state->action = DO_SHADING;
- }
-
--static cairo_quartz_action_t
--_cairo_quartz_setup_source (cairo_quartz_surface_t *surface,
-- const cairo_pattern_t *source,
-- cairo_rectangle_int_t *extents)
-+/**
-+ * 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)
- {
-- assert (!(surface->sourceImage || surface->sourceShading || surface->sourcePattern));
--
-- surface->oldInterpolationQuality = CGContextGetInterpolationQuality (surface->cgContext);
-- CGContextSetInterpolationQuality (surface->cgContext, _cairo_quartz_filter_to_quartz (source->filter));
-+ CGContextRef context = surface->cgContext;
-+ cairo_quartz_drawing_state_t state;
-+ cairo_status_t status;
-+
-+ state.context = context;
-+ state.image = NULL;
-+ state.imageSurface = NULL;
-+ state.shading = NULL;
-+ state.pattern = NULL;
-+
-+ // 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 (surface->cgContext,
-+ CGContextSetRGBStrokeColor (context,
- solid->color.red,
- solid->color.green,
- solid->color.blue,
- solid->color.alpha);
-- CGContextSetRGBFillColor (surface->cgContext,
-+ CGContextSetRGBFillColor (context,
- solid->color.red,
- solid->color.green,
- solid->color.blue,
- solid->color.alpha);
-
-- return DO_SOLID;
-+ 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;
-- return _cairo_quartz_setup_linear_source (surface, lpat, extents);
-+ _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;
-- return _cairo_quartz_setup_radial_source (surface, rpat, extents);
-+ _cairo_quartz_setup_radial_source (surface, rpat, extents, &state);
-+ return state;
- }
-
- if (source->type == CAIRO_PATTERN_TYPE_SURFACE &&
- (source->extend == CAIRO_EXTEND_NONE || (CGContextDrawTiledImagePtr && source->extend == CAIRO_EXTEND_REPEAT)))
- {
- const cairo_surface_pattern_t *spat = (const cairo_surface_pattern_t *) source;
- cairo_surface_t *pat_surf = spat->surface;
- CGImageRef img;
- cairo_matrix_t m = spat->base.matrix;
- cairo_rectangle_int_t extents;
-- cairo_status_t status;
- CGAffineTransform xform;
- CGRect srcRect;
- cairo_fixed_t fw, fh;
- cairo_bool_t is_bounded;
-
- status = _cairo_surface_to_cgimage ((cairo_surface_t *) surface, pat_surf, &img);
-- if (status)
-- return DO_UNSUPPORTED;
-- if (img == NULL)
-- return DO_NOTHING;
-+ if (status) {
-+ state.action = DO_UNSUPPORTED;
-+ return state;
-+ }
-+ if (img == NULL) {
-+ state.action = DO_NOTHING;
-+ return state;
-+ }
-
- CGContextSetRGBFillColor (surface->cgContext, 0, 0, 0, 1);
-
-- surface->sourceImage = img;
-+ state.image = img;
-
- cairo_matrix_invert(&m);
-- _cairo_quartz_cairo_matrix_to_quartz (&m, &surface->sourceTransform);
-+ _cairo_quartz_cairo_matrix_to_quartz (&m, &state.transform);
-
- is_bounded = _cairo_surface_get_extents (pat_surf, &extents);
- assert (is_bounded);
-
- if (source->extend == CAIRO_EXTEND_NONE) {
-- surface->sourceImageRect = CGRectMake (0, 0, extents.width, extents.height);
-- return DO_IMAGE;
-+ state.imageRect = CGRectMake (0, 0, extents.width, extents.height);
-+ state.action = DO_IMAGE;
-+ return state;
- }
-
- /* 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 (surface->cgContext),
-- surface->sourceTransform);
-+ 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 &&
-@@ -1657,111 +1724,109 @@ _cairo_quartz_setup_source (cairo_quartz
-
- srcRect.size.width = round(srcRect.size.width);
- srcRect.size.height = round(srcRect.size.height);
-
- xform = CGAffineTransformInvert (xform);
-
- srcRect = CGRectApplyAffineTransform (srcRect, xform);
-
-- surface->sourceImageRect = srcRect;
--
-- return DO_TILED_IMAGE;
-+ state.imageRect = srcRect;
-+ state.action = DO_TILED_IMAGE;
-+ return state;
- }
-
- /* Fall through to generic SURFACE case */
- }
-
- if (source->type == CAIRO_PATTERN_TYPE_SURFACE) {
- 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)
-- return DO_NOTHING;
-- if (status)
-- return DO_UNSUPPORTED;
--
-- // 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(surface->cgContext);
--
-- patternSpace = CGColorSpaceCreatePattern(NULL);
-- CGContextSetFillColorSpace (surface->cgContext, patternSpace);
-- CGContextSetFillPattern (surface->cgContext, pattern, &patternAlpha);
-- CGContextSetStrokeColorSpace (surface->cgContext, patternSpace);
-- CGContextSetStrokePattern (surface->cgContext, pattern, &patternAlpha);
-+ if (status == CAIRO_INT_STATUS_NOTHING_TO_DO) {
-+ state.action = DO_NOTHING;
-+ return state;
-+ }
-+ if (status) {
-+ state.action = DO_UNSUPPORTED;
-+ return state;
-+ }
-+
-+ 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 (surface->cgContext, CGSizeMake(0,0));
--
-- surface->sourcePattern = pattern;
--
-- return DO_PATTERN;
-+ CGContextSetPatternPhase (context, CGSizeMake(0,0));
-+
-+ state.pattern = pattern;
-+ state.action = DO_PATTERN;
-+ return state;
- }
-
-- return DO_UNSUPPORTED;
-+ 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_source (cairo_quartz_surface_t *surface,
-- const cairo_pattern_t *source)
-+_cairo_quartz_teardown_state (cairo_quartz_drawing_state_t *state)
- {
-- CGContextSetInterpolationQuality (surface->cgContext, surface->oldInterpolationQuality);
--
-- if (surface->sourceImage) {
-- CGImageRelease(surface->sourceImage);
-- surface->sourceImage = NULL;
--
-- cairo_surface_destroy(surface->sourceImageSurface);
-- surface->sourceImageSurface = NULL;
-+ if (state->image) {
-+ CGImageRelease(state->image);
- }
-
-- if (surface->sourceShading) {
-- CGShadingRelease(surface->sourceShading);
-- surface->sourceShading = NULL;
-+ if (state->imageSurface) {
-+ cairo_surface_destroy(state->imageSurface);
- }
-
-- if (surface->sourcePattern) {
-- CGPatternRelease(surface->sourcePattern);
-- // To tear down the pattern and colorspace
-- CGContextRestoreGState(surface->cgContext);
--
-- surface->sourcePattern = NULL;
-+ if (state->shading) {
-+ CGShadingRelease(state->shading);
- }
-+
-+ if (state->pattern) {
-+ CGPatternRelease(state->pattern);
-+ }
-+
-+ CGContextRestoreGState(state->context);
- }
-
-
- static void
--_cairo_quartz_draw_image (cairo_quartz_surface_t *surface, cairo_operator_t op, cairo_quartz_action_t action)
-+_cairo_quartz_draw_image (cairo_quartz_drawing_state_t *state, cairo_operator_t op)
- {
-- assert (surface && surface->sourceImage && (action == DO_IMAGE || action == DO_TILED_IMAGE));
--
-- CGContextConcatCTM (surface->cgContext, surface->sourceTransform);
-- CGContextTranslateCTM (surface->cgContext, 0, surface->sourceImageRect.size.height);
-- CGContextScaleCTM (surface->cgContext, 1, -1);
--
-- if (action == DO_IMAGE) {
-- CGContextDrawImage (surface->cgContext, surface->sourceImageRect, surface->sourceImage);
-- if (!_cairo_operator_bounded_by_source(op)) {
-- CGContextBeginPath (surface->cgContext);
-- CGContextAddRect (surface->cgContext, surface->sourceImageRect);
-- CGContextAddRect (surface->cgContext, CGContextGetClipBoundingBox (surface->cgContext));
-- CGContextSetRGBFillColor (surface->cgContext, 0, 0, 0, 0);
-- CGContextEOFillPath (surface->cgContext);
-+ assert (state && state->image && (state->action == DO_IMAGE || state->action == DO_TILED_IMAGE));
-+
-+ CGContextConcatCTM (state->context, state->transform);
-+ CGContextTranslateCTM (state->context, 0, state->imageRect.size.height);
-+ CGContextScaleCTM (state->context, 1, -1);
-+
-+ if (state->action == DO_IMAGE) {
-+ CGContextDrawImage (state->context, state->imageRect, state->image);
-+ if (!_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);
- }
- } else
-- CGContextDrawTiledImagePtr (surface->cgContext, surface->sourceImageRect, surface->sourceImage);
-+ CGContextDrawTiledImagePtr (state->context, state->imageRect, state->image);
- }
-
-
- /*
- * get source/dest image implementation
- */
-
- /* Read the image from the surface's front buffer */
-@@ -2098,52 +2163,44 @@ _cairo_quartz_surface_get_extents (void
- 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_STATUS_SUCCESS;
-- cairo_quartz_action_t action;
-+ 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;
-
-- rv = _cairo_quartz_surface_set_cairo_operator (surface, op);
-- if (unlikely (rv))
-- return rv == CAIRO_INT_STATUS_NOTHING_TO_DO ? CAIRO_STATUS_SUCCESS : rv;
--
-- action = _cairo_quartz_setup_source (surface, source, NULL);
--
-- if (action == DO_SOLID || action == DO_PATTERN) {
-- CGContextFillRect (surface->cgContext, CGRectMake(surface->extents.x,
-- surface->extents.y,
-- surface->extents.width,
-- surface->extents.height));
-- } else if (action == DO_SHADING) {
-- CGContextSaveGState (surface->cgContext);
-- CGContextConcatCTM (surface->cgContext, surface->sourceTransform);
-- CGContextDrawShading (surface->cgContext, surface->sourceShading);
-- CGContextRestoreGState (surface->cgContext);
-- } else if (action == DO_IMAGE || action == DO_TILED_IMAGE) {
-- CGContextSaveGState (surface->cgContext);
-- _cairo_quartz_draw_image (surface, op, action);
-- CGContextRestoreGState (surface->cgContext);
-- } else if (action != DO_NOTHING) {
-+ 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) {
-+ _cairo_quartz_draw_image (&state, op);
-+ } else if (state.action != DO_NOTHING) {
- rv = CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
-- _cairo_quartz_teardown_source (surface, source);
-+ _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)
- {
-@@ -2170,91 +2227,83 @@ _cairo_quartz_surface_fill (void *abstra
- 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_action_t action;
-+ cairo_quartz_drawing_state_t state;
- quartz_stroke_t stroke;
- 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;
-
-- rv = _cairo_quartz_surface_set_cairo_operator (surface, op);
-- if (unlikely (rv))
-- return rv == CAIRO_INT_STATUS_NOTHING_TO_DO ? CAIRO_STATUS_SUCCESS : rv;
--
-- CGContextSaveGState (surface->cgContext);
--
-- CGContextSetShouldAntialias (surface->cgContext, (antialias != CAIRO_ANTIALIAS_NONE));
--
- 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);
-- action = _cairo_quartz_setup_source (surface, source, &path_extents);
-+ state = _cairo_quartz_setup_state (surface, source, op, &path_extents);
- } else {
-- action = _cairo_quartz_setup_source (surface, source, NULL);
-+ state = _cairo_quartz_setup_state (surface, source, op, NULL);
- }
-
-- CGContextBeginPath (surface->cgContext);
--
-- stroke.cgContext = surface->cgContext;
-+ CGContextSetShouldAntialias (state.context, (antialias != CAIRO_ANTIALIAS_NONE));
-+
-+ CGContextBeginPath (state.context);
-+
-+ stroke.cgContext = state.context;
- stroke.ctm_inverse = NULL;
- rv = _cairo_quartz_cairo_path_to_quartz_context (path, &stroke);
- if (rv)
- goto BAIL;
-
- if (!_cairo_operator_bounded_by_mask(op) && CGContextCopyPathPtr)
-- path_for_unbounded = CGContextCopyPathPtr (surface->cgContext);
--
-- if (action == DO_SOLID || action == DO_PATTERN) {
-+ path_for_unbounded = CGContextCopyPathPtr (state.context);
-+
-+ if (state.action == DO_SOLID || state.action == DO_PATTERN) {
- if (fill_rule == CAIRO_FILL_RULE_WINDING)
-- CGContextFillPath (surface->cgContext);
-+ CGContextFillPath (state.context);
- else
-- CGContextEOFillPath (surface->cgContext);
-- } else if (action == DO_SHADING) {
-+ 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 (surface->cgContext);
-+ CGContextClip (state.context);
- else
-- CGContextEOClip (surface->cgContext);
--
-- CGContextConcatCTM (surface->cgContext, surface->sourceTransform);
-- CGContextDrawShading (surface->cgContext, surface->sourceShading);
-- } else if (action == DO_IMAGE || action == DO_TILED_IMAGE) {
-+ CGContextEOClip (state.context);
-+
-+ CGContextConcatCTM (state.context, state.transform);
-+ CGContextDrawShading (state.context, state.shading);
-+ } else if (state.action == DO_IMAGE || state.action == DO_TILED_IMAGE) {
- if (fill_rule == CAIRO_FILL_RULE_WINDING)
-- CGContextClip (surface->cgContext);
-+ CGContextClip (state.context);
- else
-- CGContextEOClip (surface->cgContext);
--
-- _cairo_quartz_draw_image (surface, op, action);
-- } else if (action != DO_NOTHING) {
-+ CGContextEOClip (state.context);
-+
-+ _cairo_quartz_draw_image (&state, op);
-+ } else if (state.action != DO_NOTHING) {
- rv = CAIRO_INT_STATUS_UNSUPPORTED;
- }
-
- BAIL:
-- _cairo_quartz_teardown_source (surface, source);
--
-- CGContextRestoreGState (surface->cgContext);
-+ _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);
-@@ -2274,44 +2323,49 @@ _cairo_quartz_surface_stroke (void *abst
- cairo_matrix_t *ctm,
- 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_action_t action;
-+ cairo_quartz_drawing_state_t state;
- quartz_stroke_t stroke;
- 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 (surface->cgContext, (antialias != CAIRO_ANTIALIAS_NONE));
-- CGContextSetLineWidth (surface->cgContext, style->line_width);
-- CGContextSetLineCap (surface->cgContext, _cairo_quartz_cairo_line_cap_to_quartz (style->line_cap));
-- CGContextSetLineJoin (surface->cgContext, _cairo_quartz_cairo_line_join_to_quartz (style->line_join));
-- CGContextSetMiterLimit (surface->cgContext, style->miter_limit);
--
-- origCTM = CGContextGetCTM (surface->cgContext);
-+ 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
- CGFloat sdash[STATIC_DASH];
- CGFloat *fdash = sdash;
- double offset = style->dash_offset;
- unsigned int max_dashes = style->num_dashes;
- unsigned int k;
-@@ -2330,90 +2384,75 @@ _cairo_quartz_surface_stroke (void *abst
- if (max_dashes > STATIC_DASH)
- fdash = _cairo_malloc_ab (max_dashes, sizeof (CGFloat));
- if (fdash == NULL)
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- for (k = 0; k < max_dashes; k++)
- fdash[k] = (CGFloat) style->dash[k % style->num_dashes];
- }
-- CGContextSetLineDash (surface->cgContext, offset, fdash, max_dashes);
-+ CGContextSetLineDash (state.context, offset, fdash, max_dashes);
- if (fdash != sdash)
- free (fdash);
- } else
-- CGContextSetLineDash (surface->cgContext, 0, NULL, 0);
--
-- CGContextSaveGState (surface->cgContext);
--
--
-- if (_cairo_quartz_source_needs_extents (source))
-- {
-- cairo_rectangle_int_t path_extents;
-- _cairo_path_fixed_approximate_stroke_extents (path, style, ctm, &path_extents);
-- action = _cairo_quartz_setup_source (surface, source, &path_extents);
-- } else {
-- action = _cairo_quartz_setup_source (surface, source, NULL);
-- }
-+ CGContextSetLineDash (state.context, 0, NULL, 0);
-
- _cairo_quartz_cairo_matrix_to_quartz (ctm, &strokeTransform);
-- CGContextConcatCTM (surface->cgContext, strokeTransform);
--
-- CGContextBeginPath (surface->cgContext);
--
-- stroke.cgContext = surface->cgContext;
-+ CGContextConcatCTM (state.context, strokeTransform);
-+
-+ CGContextBeginPath (state.context);
-+
-+ stroke.cgContext = state.context;
- stroke.ctm_inverse = ctm_inverse;
- rv = _cairo_quartz_cairo_path_to_quartz_context (path, &stroke);
- if (rv)
- goto BAIL;
-
- if (!_cairo_operator_bounded_by_mask (op) && CGContextCopyPathPtr)
-- path_for_unbounded = CGContextCopyPathPtr (surface->cgContext);
--
-- if (action == DO_SOLID || action == DO_PATTERN) {
-- CGContextStrokePath (surface->cgContext);
-- } else if (action == DO_IMAGE || action == DO_TILED_IMAGE) {
-- CGContextReplacePathWithStrokedPath (surface->cgContext);
-- CGContextClip (surface->cgContext);
--
-- CGContextSetCTM (surface->cgContext, origCTM);
-- _cairo_quartz_draw_image (surface, op, action);
-- } else if (action == DO_SHADING) {
-- CGContextReplacePathWithStrokedPath (surface->cgContext);
-- CGContextClip (surface->cgContext);
--
-- CGContextSetCTM (surface->cgContext, origCTM);
--
-- CGContextConcatCTM (surface->cgContext, surface->sourceTransform);
-- CGContextDrawShading (surface->cgContext, surface->sourceShading);
-- } else if (action != DO_NOTHING) {
-+ 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) {
-+ 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) {
-+ CGContextSetCTM (state.context, origCTM);
-+ CGContextConcatCTM (state.context, strokeTransform);
-+
-+ CGContextBeginPath (state.context);
-+ CGContextAddPath (state.context, path_for_unbounded);
-+ CGPathRelease (path_for_unbounded);
-+
-+ CGContextReplacePathWithStrokedPath (state.context);
-+
-+ CGContextAddRect (state.context, CGContextGetClipBoundingBox (state.context));
-+
-+ CGContextSetRGBFillColor (state.context, 0., 0., 0., 0.);
-+ CGContextEOFillPath (state.context);
-+ }
-+
- BAIL:
-- _cairo_quartz_teardown_source (surface, source);
--
-- CGContextRestoreGState (surface->cgContext);
--
-- if (path_for_unbounded) {
-- CGContextSaveGState (surface->cgContext);
-- CGContextConcatCTM (surface->cgContext, strokeTransform);
--
-- CGContextBeginPath (surface->cgContext);
-- CGContextAddPath (surface->cgContext, path_for_unbounded);
-- CGPathRelease (path_for_unbounded);
--
-- CGContextReplacePathWithStrokedPath (surface->cgContext);
--
-- CGContextAddRect (surface->cgContext, CGContextGetClipBoundingBox (surface->cgContext));
--
-- CGContextSetRGBFillColor (surface->cgContext, 0., 0., 0., 0.);
-- CGContextEOFillPath (surface->cgContext);
--
-- CGContextRestoreGState (surface->cgContext);
-- }
-+ _cairo_quartz_teardown_state (&state);
-
- ND((stderr, "-- stroke\n"));
- return rv;
- }
-
- #if CAIRO_HAS_QUARTZ_FONT
- static cairo_int_status_t
- _cairo_quartz_surface_show_glyphs (void *abstract_surface,
-@@ -2429,17 +2468,17 @@ _cairo_quartz_surface_show_glyphs (void
- #define STATIC_BUF_SIZE 64
- CGGlyph glyphs_static[STATIC_BUF_SIZE];
- CGSize cg_advances_static[STATIC_BUF_SIZE];
- CGGlyph *cg_glyphs = &glyphs_static[0];
- CGSize *cg_advances = &cg_advances_static[0];
-
- cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface;
- cairo_int_status_t rv = CAIRO_STATUS_SUCCESS;
-- cairo_quartz_action_t action;
-+ cairo_quartz_drawing_state_t state;
- float xprev, yprev;
- int i;
- CGFontRef cgfref = NULL;
-
- cairo_bool_t isClipping = FALSE;
- cairo_bool_t didForceFontSmoothing = FALSE;
-
- if (IS_EMPTY(surface))
-@@ -2450,65 +2489,59 @@ _cairo_quartz_surface_show_glyphs (void
-
- 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;
-
-- rv = _cairo_quartz_surface_set_cairo_operator (surface, op);
-- if (unlikely (rv))
-- return rv == CAIRO_INT_STATUS_NOTHING_TO_DO ? CAIRO_STATUS_SUCCESS : rv;
--
-- CGContextSaveGState (surface->cgContext);
--
- if (_cairo_quartz_source_needs_extents (source))
- {
- cairo_rectangle_int_t glyph_extents;
- _cairo_scaled_font_glyph_device_extents (scaled_font, glyphs, num_glyphs,
- &glyph_extents, NULL);
-- action = _cairo_quartz_setup_source (surface, source, &glyph_extents);
-+ state = _cairo_quartz_setup_state (surface, source, op, &glyph_extents);
- } else {
-- action = _cairo_quartz_setup_source (surface, source, NULL);
-+ state = _cairo_quartz_setup_state (surface, source, op, NULL);
- }
-
-- if (action == DO_SOLID || action == DO_PATTERN) {
-- CGContextSetTextDrawingMode (surface->cgContext, kCGTextFill);
-- } else if (action == DO_IMAGE || action == DO_TILED_IMAGE || action == DO_SHADING) {
-- CGContextSetTextDrawingMode (surface->cgContext, kCGTextClip);
-+ 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) {
-+ CGContextSetTextDrawingMode (state.context, kCGTextClip);
- isClipping = TRUE;
- } else {
-- if (action != DO_NOTHING)
-+ 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 (surface->cgContext, cgfref);
-- CGContextSetFontSize (surface->cgContext, 1.0);
-+ CGContextSetFont (state.context, cgfref);
-+ CGContextSetFontSize (state.context, 1.0);
-
- switch (scaled_font->options.antialias) {
- case CAIRO_ANTIALIAS_SUBPIXEL:
-- CGContextSetShouldAntialias (surface->cgContext, TRUE);
-- CGContextSetShouldSmoothFonts (surface->cgContext, TRUE);
-+ CGContextSetShouldAntialias (state.context, TRUE);
-+ CGContextSetShouldSmoothFonts (state.context, TRUE);
- if (CGContextSetAllowsFontSmoothingPtr &&
-- !CGContextGetAllowsFontSmoothingPtr (surface->cgContext))
-+ !CGContextGetAllowsFontSmoothingPtr (state.context))
- {
- didForceFontSmoothing = TRUE;
-- CGContextSetAllowsFontSmoothingPtr (surface->cgContext, TRUE);
-+ CGContextSetAllowsFontSmoothingPtr (state.context, TRUE);
- }
- break;
- case CAIRO_ANTIALIAS_NONE:
-- CGContextSetShouldAntialias (surface->cgContext, FALSE);
-+ CGContextSetShouldAntialias (state.context, FALSE);
- break;
- case CAIRO_ANTIALIAS_GRAY:
-- CGContextSetShouldAntialias (surface->cgContext, TRUE);
-- CGContextSetShouldSmoothFonts (surface->cgContext, FALSE);
-+ 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));
-@@ -2532,17 +2565,17 @@ _cairo_quartz_surface_show_glyphs (void
- textTransform = CGAffineTransformScale (textTransform, 1.0, -1.0);
- textTransform = CGAffineTransformConcat (CGAffineTransformMake(scaled_font->ctm.xx,
- -scaled_font->ctm.yx,
- -scaled_font->ctm.xy,
- scaled_font->ctm.yy,
- 0., 0.),
- textTransform);
-
-- CGContextSetTextMatrix (surface->cgContext, textTransform);
-+ CGContextSetTextMatrix (state.context, textTransform);
-
- /* 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;
-
-@@ -2569,40 +2602,38 @@ _cairo_quartz_surface_show_glyphs (void
-
- #if 0
- for (i = 0; i < num_glyphs; i++) {
- ND((stderr, "[%d: %d %f,%f]\n", i, cg_glyphs[i], cg_advances[i].width, cg_advances[i].height));
- }
- #endif
-
- /* Translate to the first glyph's position before drawing */
-- ctm = CGContextGetCTM (surface->cgContext);
-- CGContextTranslateCTM (surface->cgContext, glyphs[0].x, glyphs[0].y);
--
-- CGContextShowGlyphsWithAdvances (surface->cgContext,
-+ ctm = CGContextGetCTM (state.context);
-+ CGContextTranslateCTM (state.context, glyphs[0].x, glyphs[0].y);
-+
-+ CGContextShowGlyphsWithAdvances (state.context,
- cg_glyphs,
- cg_advances,
- num_glyphs);
-
-- CGContextSetCTM (surface->cgContext, ctm);
--
-- if (action == DO_IMAGE || action == DO_TILED_IMAGE) {
-- _cairo_quartz_draw_image (surface, op, action);
-- } else if (action == DO_SHADING) {
-- CGContextConcatCTM (surface->cgContext, surface->sourceTransform);
-- CGContextDrawShading (surface->cgContext, surface->sourceShading);
-+ CGContextSetCTM (state.context, ctm);
-+
-+ if (state.action == DO_IMAGE || state.action == DO_TILED_IMAGE) {
-+ _cairo_quartz_draw_image (&state, op);
-+ } else if (state.action == DO_SHADING) {
-+ CGContextConcatCTM (state.context, state.transform);
-+ CGContextDrawShading (state.context, state.shading);
- }
-
- BAIL:
-- _cairo_quartz_teardown_source (surface, source);
--
- if (didForceFontSmoothing)
-- CGContextSetAllowsFontSmoothingPtr (surface->cgContext, FALSE);
--
-- CGContextRestoreGState (surface->cgContext);
-+ 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;
-
diff --git a/gfx/cairo/quartz-support-color-emoji-font.patch b/gfx/cairo/quartz-support-color-emoji-font.patch
deleted file mode 100644
index 5fb88b271..000000000
--- a/gfx/cairo/quartz-support-color-emoji-font.patch
+++ /dev/null
@@ -1,432 +0,0 @@
-From: Jonathan Kew <jkew@mozilla.com>
-bug 715798 pt 1 - support Apple Color Emoji font in cairo-quartz backend. r=jrmuizel
-
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-font.c b/gfx/cairo/cairo/src/cairo-quartz-font.c
---- a/gfx/cairo/cairo/src/cairo-quartz-font.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-font.c
-@@ -85,16 +85,20 @@ typedef struct {
- 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;
-@@ -122,16 +126,18 @@ quartz_font_ensure_symbols(void)
- 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 &&
- CGFontGetGlyphPathPtr &&
- (CGFontGetHMetricsPtr || (CGFontGetAscentPtr && CGFontGetDescentPtr && CGFontGetLeadingPtr)))
- _cairo_quartz_font_symbols_present = TRUE;
-@@ -145,16 +151,17 @@ typedef struct _cairo_quartz_scaled_font
- 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,
-@@ -229,16 +236,20 @@ static cairo_status_t
- 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,
-@@ -353,16 +364,22 @@ cairo_quartz_font_face_create_for_cgfont
- 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
- */
-@@ -772,16 +789,24 @@ static const cairo_scaled_font_backend_t
- 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;
-+}
-+
- #ifndef __LP64__
- /*
- * compat with old ATSUI backend
- */
-
- /**
- * cairo_quartz_font_face_create_for_atsu_font_id
- * @font_id: an ATSUFontID for the font.
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-private.h b/gfx/cairo/cairo/src/cairo-quartz-private.h
---- a/gfx/cairo/cairo/src/cairo-quartz-private.h
-+++ b/gfx/cairo/cairo/src/cairo-quartz-private.h
-@@ -45,16 +45,19 @@
- #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;
-@@ -99,15 +102,18 @@ CGImageRef
- 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/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -130,16 +130,19 @@ static void (*CGContextClipToMaskPtr) (C
- 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
- */
-
-@@ -167,16 +170,18 @@ static void quartz_ensure_symbols(void)
- 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 (Gestalt(gestaltSystemVersion, &_cairo_quartz_osx_version) != noErr) {
- // assume 10.5
- _cairo_quartz_osx_version = 0x1050;
- }
-
- _cairo_quartz_symbol_lookup_done = TRUE;
- }
-
-@@ -605,20 +610,23 @@ static inline void
- dst->d = src->yy;
- dst->tx = src->x0;
- dst->ty = src->y0;
- }
-
- typedef struct {
- bool isClipping;
- CGGlyph *cg_glyphs;
-- CGSize *cg_advances;
-+ union {
-+ CGSize *cg_advances;
-+ CGPoint *cg_positions;
-+ } u;
- size_t nglyphs;
- CGAffineTransform textTransform;
-- CGFontRef font;
-+ 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;
-
-@@ -686,36 +694,43 @@ static void
- 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) {
-- CGContextSetFont (cgc, op->u.show_glyphs.font);
-- CGContextSetFontSize (cgc, 1.0);
-- CGContextSetTextMatrix (cgc, CGAffineTransformIdentity);
-- CGContextTranslateCTM (cgc, op->u.show_glyphs.origin.x, op->u.show_glyphs.origin.y);
-- CGContextConcatCTM (cgc, op->u.show_glyphs.textTransform);
--
- 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);
- }
--
-- CGContextShowGlyphsWithAdvances (cgc,
-- op->u.show_glyphs.cg_glyphs,
-- op->u.show_glyphs.cg_advances,
-- op->u.show_glyphs.nglyphs);
--
-+ 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);
-@@ -2684,16 +2699,19 @@ static cairo_int_status_t
- 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;
-@@ -2796,41 +2814,62 @@ static cairo_int_status_t
- 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);
-
-- /* 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;
-- }
--
- /* 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);
-
-- CGContextShowGlyphsWithAdvances (state.context,
-- cg_glyphs,
-- cg_advances,
-- num_glyphs);
-+ 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);
-@@ -2847,20 +2886,27 @@ BAIL:
- 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;
-- ub.u.show_glyphs.cg_advances = cg_advances;
-+ 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.font = cgfref;
-+ 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);
diff --git a/gfx/cairo/quartz-surface-mask-patch b/gfx/cairo/quartz-surface-mask-patch
deleted file mode 100644
index d5ee7d8be..000000000
--- a/gfx/cairo/quartz-surface-mask-patch
+++ /dev/null
@@ -1,79 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
---- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
-@@ -128,20 +128,22 @@ CG_EXTERN CGImageRef CGBitmapContextCrea
- */
- 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;
-
-+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
-@@ -163,20 +165,25 @@ static void quartz_ensure_symbols(void)
-
- 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");
-
-+ if (Gestalt(gestaltSystemVersion, &_cairo_quartz_osx_version) != noErr) {
-+ // assume 10.5
-+ _cairo_quartz_osx_version = 0x1050;
-+ }
-+
- _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,
-@@ -3028,22 +3035,25 @@ static cairo_int_status_t
- 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 */
-- if (mask->type == CAIRO_PATTERN_TYPE_SURFACE && mask->extend == CAIRO_EXTEND_NONE)
-+ /* 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;
diff --git a/gfx/cairo/setlcdfilter_in_tree.patch b/gfx/cairo/setlcdfilter_in_tree.patch
deleted file mode 100644
index 5a9470cc2..000000000
--- a/gfx/cairo/setlcdfilter_in_tree.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-ft-font.c b/gfx/cairo/cairo/src/cairo-ft-font.c
---- a/gfx/cairo/cairo/src/cairo-ft-font.c
-+++ b/gfx/cairo/cairo/src/cairo-ft-font.c
-@@ -1361,21 +1361,25 @@ static cairo_status_t
- case FT_RENDER_MODE_MONO:
- case FT_RENDER_MODE_LIGHT:
- case FT_RENDER_MODE_NORMAL:
- case FT_RENDER_MODE_MAX:
- default:
- break;
- }
-
- if (!initialized_setLcdFilter) {
- initialized_setLcdFilter = 1;
-+#ifdef HAVE_FT_LIBRARY_SETLCDFILTER
-+ setLcdFilter = &FT_Library_SetLcdFilter;
-+#else
- setLcdFilter = (setLcdFilterFunc) dlsym(RTLD_DEFAULT, "FT_Library_SetLcdFilter");
-+#endif
- }
-
- if (setLcdFilter)
- setLcdFilter (library, lcd_filter);
-
- fterror = FT_Render_Glyph (face->glyph, render_mode);
-
- if (setLcdFilter)
- setLcdFilter (library, FT_LCD_FILTER_NONE);
-
-
diff --git a/gfx/cairo/support-new-style-atomic-primitives.patch b/gfx/cairo/support-new-style-atomic-primitives.patch
deleted file mode 100644
index 1830a4691..000000000
--- a/gfx/cairo/support-new-style-atomic-primitives.patch
+++ /dev/null
@@ -1,121 +0,0 @@
-From 5d150ee111c222f09e78f4f88540964476327844 Mon Sep 17 00:00:00 2001
-From: Nathan Froyd <froydnj@mozilla.com>
-Date: Mon, 4 May 2015 13:38:41 -0400
-Subject: Support new-style __atomic_* primitives
-
-Recent versions of GCC/clang feature a new set of compiler intrinsics
-for performing atomic operations, motivated by the operations needed to
-support the C++11 memory model. These intrinsics are more flexible than
-the old __sync_* intrinstics and offer efficient support for atomic load
-and store operations.
-
-Having the load appear atomic to the compiler is particular important
-for tools like ThreadSanitizer so they don't report false positives on
-memory operations that we intend to be atomic.
-
-Patch from Nathan Froyd <froydnj@mozilla.com>
-
-diff --git a/src/cairo-atomic-private.h b/src/cairo-atomic-private.h
-index 327fed1..11b2887 100644
---- a/src/cairo-atomic-private.h
-+++ b/src/cairo-atomic-private.h
-@@ -53,6 +53,96 @@
-
- CAIRO_BEGIN_DECLS
-
-+/* C++11 atomic primitives were designed to be more flexible than the
-+ * __sync_* family of primitives. Despite the name, they are available
-+ * in C as well as C++. The motivating reason for using them is that
-+ * for _cairo_atomic_{int,ptr}_get, the compiler is able to see that
-+ * the load is intended to be atomic, as opposed to the __sync_*
-+ * version, below, where the load looks like a plain load. Having
-+ * the load appear atomic to the compiler is particular important for
-+ * tools like ThreadSanitizer so they don't report false positives on
-+ * memory operations that we intend to be atomic.
-+ */
-+#if HAVE_CXX11_ATOMIC_PRIMITIVES
-+
-+#define HAS_ATOMIC_OPS 1
-+
-+typedef int cairo_atomic_int_t;
-+
-+static cairo_always_inline cairo_atomic_int_t
-+_cairo_atomic_int_get (cairo_atomic_int_t *x)
-+{
-+ return __atomic_load_n(x, __ATOMIC_SEQ_CST);
-+}
-+
-+static cairo_always_inline void *
-+_cairo_atomic_ptr_get (void **x)
-+{
-+ return __atomic_load_n(x, __ATOMIC_SEQ_CST);
-+}
-+
-+# define _cairo_atomic_int_inc(x) ((void) __atomic_fetch_add(x, 1, __ATOMIC_SEQ_CST))
-+# define _cairo_atomic_int_dec(x) ((void) __atomic_fetch_sub(x, 1, __ATOMIC_SEQ_CST))
-+# define _cairo_atomic_int_dec_and_test(x) (__atomic_fetch_sub(x, 1, __ATOMIC_SEQ_CST) == 1)
-+
-+#if SIZEOF_VOID_P==SIZEOF_INT
-+typedef int cairo_atomic_intptr_t;
-+#elif SIZEOF_VOID_P==SIZEOF_LONG
-+typedef long cairo_atomic_intptr_t;
-+#elif SIZEOF_VOID_P==SIZEOF_LONG_LONG
-+typedef long long cairo_atomic_intptr_t;
-+#else
-+#error No matching integer pointer type
-+#endif
-+
-+static cairo_always_inline cairo_bool_t
-+_cairo_atomic_int_cmpxchg_impl(cairo_atomic_int_t *x,
-+ cairo_atomic_int_t oldv,
-+ cairo_atomic_int_t newv)
-+{
-+ cairo_atomic_int_t expected = oldv;
-+ return __atomic_compare_exchange_n(x, &expected, newv, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
-+}
-+
-+#define _cairo_atomic_int_cmpxchg(x, oldv, newv) \
-+ _cairo_atomic_int_cmpxchg_impl(x, oldv, newv)
-+
-+static cairo_always_inline cairo_atomic_int_t
-+_cairo_atomic_int_cmpxchg_return_old_impl(cairo_atomic_int_t *x,
-+ cairo_atomic_int_t oldv,
-+ cairo_atomic_int_t newv)
-+{
-+ cairo_atomic_int_t expected = oldv;
-+ (void) __atomic_compare_exchange_n(x, &expected, newv, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
-+ return expected;
-+}
-+
-+#define _cairo_atomic_int_cmpxchg_return_old(x, oldv, newv) \
-+ _cairo_atomic_int_cmpxchg_return_old_impl(x, oldv, newv)
-+
-+static cairo_always_inline cairo_bool_t
-+_cairo_atomic_ptr_cmpxchg_impl(void **x, void *oldv, void *newv)
-+{
-+ void *expected = oldv;
-+ return __atomic_compare_exchange_n(x, &expected, newv, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
-+}
-+
-+#define _cairo_atomic_ptr_cmpxchg(x, oldv, newv) \
-+ _cairo_atomic_ptr_cmpxchg_impl(x, oldv, newv)
-+
-+static cairo_always_inline void *
-+_cairo_atomic_ptr_cmpxchg_return_old_impl(void **x, void *oldv, void *newv)
-+{
-+ void *expected = oldv;
-+ (void) __atomic_compare_exchange_n(x, &expected, newv, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
-+ return expected;
-+}
-+
-+#define _cairo_atomic_ptr_cmpxchg_return_old(x, oldv, newv) \
-+ _cairo_atomic_ptr_cmpxchg_return_old_impl(x, oldv, newv)
-+
-+#endif
-+
- #if HAVE_INTEL_ATOMIC_PRIMITIVES
-
- #define HAS_ATOMIC_OPS 1
---
-cgit v0.10.2
-
diff --git a/gfx/cairo/surface-clipper.patch b/gfx/cairo/surface-clipper.patch
deleted file mode 100644
index 608841147..000000000
--- a/gfx/cairo/surface-clipper.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-commit 061cc774a861f349334117203c301dee202f9f26
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-Date: Wed Apr 7 23:05:48 2010 -0400
-
- Remove an incorrect optimization that was causing the clip
- not to be set when it should've been.
-
- This happens when the path is equal but the parents aren't shared.
-
-diff --git a/src/cairo-surface-clipper.c b/src/cairo-surface-clipper.c
-index d536f0c..03610d1 100644
---- a/src/cairo-surface-clipper.c
-+++ b/src/cairo-surface-clipper.c
-@@ -78,12 +78,6 @@ _cairo_surface_clipper_set_clip (cairo_surface_clipper_t *clipper,
- if (clip != NULL && clip->path == clipper->clip.path)
- return CAIRO_STATUS_SUCCESS;
-
-- if (clip != NULL && clipper->clip.path != NULL &&
-- _cairo_path_fixed_equal (&clip->path->path, &clipper->clip.path->path))
-- {
-- return CAIRO_STATUS_SUCCESS;
-- }
--
- /* all clipped out state should never propagate this far */
- assert (clip == NULL || clip->path != NULL);
-
diff --git a/gfx/cairo/tee-surfaces-pointwise.patch b/gfx/cairo/tee-surfaces-pointwise.patch
deleted file mode 100644
index 180005fa6..000000000
--- a/gfx/cairo/tee-surfaces-pointwise.patch
+++ /dev/null
@@ -1,278 +0,0 @@
-# HG changeset patch
-# User Robert O'Callahan <robert@ocallahan.org>
-# Date 1294019288 -46800
-# Node ID bacc54d452a9fddb5a0d6a1442ec7be4de81ffa7
-# Parent ccba8826be1451d0e61d0df38363dadffb20ba48
-Bug 593604. Part 2: When compositing a tee surface into another tee surface, try to compose the subsurfaces pointwise. r=jrmuizel,a=blocking
-
-diff --git a/gfx/cairo/cairo/src/cairo-tee-surface.c b/gfx/cairo/cairo/src/cairo-tee-surface.c
---- a/gfx/cairo/cairo/src/cairo-tee-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-tee-surface.c
-@@ -186,35 +186,72 @@ static void
- _cairo_tee_surface_get_font_options (void *abstract_surface,
- cairo_font_options_t *options)
- {
- cairo_tee_surface_t *surface = abstract_surface;
-
- _cairo_surface_wrapper_get_font_options (&surface->master, options);
- }
-
-+static const cairo_pattern_t *
-+_cairo_tee_surface_match_source (cairo_tee_surface_t *surface,
-+ const cairo_pattern_t *source,
-+ int index,
-+ cairo_surface_wrapper_t *dest,
-+ cairo_surface_pattern_t *temp)
-+{
-+ cairo_surface_t *s;
-+ cairo_status_t status = cairo_pattern_get_surface ((cairo_pattern_t *)source, &s);
-+ if (status == CAIRO_STATUS_SUCCESS &&
-+ cairo_surface_get_type (s) == CAIRO_SURFACE_TYPE_TEE) {
-+ cairo_surface_t *tee_surf = cairo_tee_surface_index (s, index);
-+ if (tee_surf->status == CAIRO_STATUS_SUCCESS &&
-+ tee_surf->backend == dest->target->backend) {
-+ status = _cairo_pattern_init_copy (&temp->base, source);
-+ if (status == CAIRO_STATUS_SUCCESS) {
-+ cairo_surface_destroy (temp->surface);
-+ temp->surface = tee_surf;
-+ cairo_surface_reference (temp->surface);
-+ return &temp->base;
-+ }
-+ }
-+ }
-+
-+ return source;
-+}
-+
- static cairo_int_status_t
- _cairo_tee_surface_paint (void *abstract_surface,
- cairo_operator_t op,
- const cairo_pattern_t *source,
- cairo_clip_t *clip)
- {
- cairo_tee_surface_t *surface = abstract_surface;
- cairo_surface_wrapper_t *slaves;
- int n, num_slaves;
- cairo_status_t status;
-+ const cairo_pattern_t *matched_source;
-+ cairo_surface_pattern_t temp;
-
-- status = _cairo_surface_wrapper_paint (&surface->master, op, source, clip);
-+ matched_source = _cairo_tee_surface_match_source (surface, source, 0, &surface->master, &temp);
-+ status = _cairo_surface_wrapper_paint (&surface->master, op, matched_source, clip);
-+ if (matched_source == &temp.base) {
-+ _cairo_pattern_fini (&temp.base);
-+ }
- if (unlikely (status))
- return status;
-
- num_slaves = _cairo_array_num_elements (&surface->slaves);
- slaves = _cairo_array_index (&surface->slaves, 0);
- for (n = 0; n < num_slaves; n++) {
-- status = _cairo_surface_wrapper_paint (&slaves[n], op, source, clip);
-+ matched_source = _cairo_tee_surface_match_source (surface, source, n + 1, &slaves[n], &temp);
-+ status = _cairo_surface_wrapper_paint (&slaves[n], op, matched_source, clip);
-+ if (matched_source == &temp.base) {
-+ _cairo_pattern_fini (&temp.base);
-+ }
- if (unlikely (status))
- return status;
- }
-
- return CAIRO_STATUS_SUCCESS;
- }
-
- static cairo_int_status_t
-@@ -223,27 +260,37 @@ _cairo_tee_surface_mask (void *abstrac
- const cairo_pattern_t *source,
- const cairo_pattern_t *mask,
- cairo_clip_t *clip)
- {
- cairo_tee_surface_t *surface = abstract_surface;
- cairo_surface_wrapper_t *slaves;
- int n, num_slaves;
- cairo_status_t status;
-+ const cairo_pattern_t *matched_source;
-+ cairo_surface_pattern_t temp;
-
-+ matched_source = _cairo_tee_surface_match_source (surface, source, 0, &surface->master, &temp);
- status = _cairo_surface_wrapper_mask (&surface->master,
-- op, source, mask, clip);
-+ op, matched_source, mask, clip);
-+ if (matched_source == &temp.base) {
-+ _cairo_pattern_fini (&temp.base);
-+ }
- if (unlikely (status))
- return status;
-
- num_slaves = _cairo_array_num_elements (&surface->slaves);
- slaves = _cairo_array_index (&surface->slaves, 0);
- for (n = 0; n < num_slaves; n++) {
-+ matched_source = _cairo_tee_surface_match_source (surface, source, n + 1, &slaves[n], &temp);
- status = _cairo_surface_wrapper_mask (&slaves[n],
-- op, source, mask, clip);
-+ op, matched_source, mask, clip);
-+ if (matched_source == &temp.base) {
-+ _cairo_pattern_fini (&temp.base);
-+ }
- if (unlikely (status))
- return status;
- }
-
- return CAIRO_STATUS_SUCCESS;
- }
-
- static cairo_int_status_t
-@@ -257,35 +304,45 @@ _cairo_tee_surface_stroke (void *abst
- double tolerance,
- cairo_antialias_t antialias,
- cairo_clip_t *clip)
- {
- cairo_tee_surface_t *surface = abstract_surface;
- cairo_surface_wrapper_t *slaves;
- int n, num_slaves;
- cairo_status_t status;
-+ const cairo_pattern_t *matched_source;
-+ cairo_surface_pattern_t temp;
-
-+ matched_source = _cairo_tee_surface_match_source (surface, source, 0, &surface->master, &temp);
- status = _cairo_surface_wrapper_stroke (&surface->master,
-- op, source,
-+ op, matched_source,
- path, style,
- ctm, ctm_inverse,
- tolerance, antialias,
- clip);
-+ if (matched_source == &temp.base) {
-+ _cairo_pattern_fini (&temp.base);
-+ }
- if (unlikely (status))
- return status;
-
- num_slaves = _cairo_array_num_elements (&surface->slaves);
- slaves = _cairo_array_index (&surface->slaves, 0);
- for (n = 0; n < num_slaves; n++) {
-+ matched_source = _cairo_tee_surface_match_source (surface, source, n + 1, &slaves[n], &temp);
- status = _cairo_surface_wrapper_stroke (&slaves[n],
-- op, source,
-+ op, matched_source,
- path, style,
- ctm, ctm_inverse,
- tolerance, antialias,
- clip);
-+ if (matched_source == &temp.base) {
-+ _cairo_pattern_fini (&temp.base);
-+ }
- if (unlikely (status))
- return status;
- }
-
- return CAIRO_STATUS_SUCCESS;
- }
-
- static cairo_int_status_t
-@@ -297,33 +354,43 @@ _cairo_tee_surface_fill (void *abstra
- double tolerance,
- cairo_antialias_t antialias,
- cairo_clip_t *clip)
- {
- cairo_tee_surface_t *surface = abstract_surface;
- cairo_surface_wrapper_t *slaves;
- int n, num_slaves;
- cairo_status_t status;
-+ const cairo_pattern_t *matched_source;
-+ cairo_surface_pattern_t temp;
-
-+ matched_source = _cairo_tee_surface_match_source (surface, source, 0, &surface->master, &temp);
- status = _cairo_surface_wrapper_fill (&surface->master,
-- op, source,
-+ op, matched_source,
- path, fill_rule,
- tolerance, antialias,
- clip);
-+ if (matched_source == &temp.base) {
-+ _cairo_pattern_fini (&temp.base);
-+ }
- if (unlikely (status))
- return status;
-
- num_slaves = _cairo_array_num_elements (&surface->slaves);
- slaves = _cairo_array_index (&surface->slaves, 0);
- for (n = 0; n < num_slaves; n++) {
-+ matched_source = _cairo_tee_surface_match_source (surface, source, n + 1, &slaves[n], &temp);
- status = _cairo_surface_wrapper_fill (&slaves[n],
-- op, source,
-+ op, matched_source,
- path, fill_rule,
- tolerance, antialias,
- clip);
-+ if (matched_source == &temp.base) {
-+ _cairo_pattern_fini (&temp.base);
-+ }
- if (unlikely (status))
- return status;
- }
-
- return CAIRO_STATUS_SUCCESS;
- }
-
- static cairo_bool_t
-@@ -346,46 +413,56 @@ _cairo_tee_surface_show_text_glyphs (voi
- cairo_scaled_font_t *scaled_font,
- cairo_clip_t *clip)
- {
- cairo_tee_surface_t *surface = abstract_surface;
- cairo_surface_wrapper_t *slaves;
- int n, num_slaves;
- cairo_status_t status;
- cairo_glyph_t *glyphs_copy;
-+ const cairo_pattern_t *matched_source;
-+ cairo_surface_pattern_t temp;
-
- /* XXX: This copying is ugly. */
- glyphs_copy = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
- if (unlikely (glyphs_copy == NULL))
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
- memcpy (glyphs_copy, glyphs, sizeof (cairo_glyph_t) * num_glyphs);
-+ matched_source = _cairo_tee_surface_match_source (surface, source, 0, &surface->master, &temp);
- status = _cairo_surface_wrapper_show_text_glyphs (&surface->master, op,
-- source,
-+ matched_source,
- utf8, utf8_len,
- glyphs_copy, num_glyphs,
- clusters, num_clusters,
- cluster_flags,
- scaled_font,
- clip);
-+ if (matched_source == &temp.base) {
-+ _cairo_pattern_fini (&temp.base);
-+ }
- if (unlikely (status))
- goto CLEANUP;
-
- num_slaves = _cairo_array_num_elements (&surface->slaves);
- slaves = _cairo_array_index (&surface->slaves, 0);
- for (n = 0; n < num_slaves; n++) {
- memcpy (glyphs_copy, glyphs, sizeof (cairo_glyph_t) * num_glyphs);
-+ matched_source = _cairo_tee_surface_match_source (surface, source, n + 1, &slaves[n], &temp);
- status = _cairo_surface_wrapper_show_text_glyphs (&slaves[n], op,
-- source,
-+ matched_source,
- utf8, utf8_len,
- glyphs_copy, num_glyphs,
- clusters, num_clusters,
- cluster_flags,
- scaled_font,
- clip);
-+ if (matched_source == &temp.base) {
-+ _cairo_pattern_fini (&temp.base);
-+ }
- if (unlikely (status))
- goto CLEANUP;
- }
-
- CLEANUP:
- free (glyphs_copy);
- return status;
- }
diff --git a/gfx/cairo/text-path-filling-threshold.patch b/gfx/cairo/text-path-filling-threshold.patch
deleted file mode 100644
index 69efce093..000000000
--- a/gfx/cairo/text-path-filling-threshold.patch
+++ /dev/null
@@ -1,90 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-gstate.c b/gfx/cairo/cairo/src/cairo-gstate.c
---- a/gfx/cairo/cairo/src/cairo-gstate.c
-+++ b/gfx/cairo/cairo/src/cairo-gstate.c
-@@ -1673,26 +1673,31 @@ _cairo_gstate_show_text_glyphs (cairo_gs
-
- source_pattern = &source_pattern_stack.base;
- status = _cairo_gstate_copy_transformed_source (gstate, &source_pattern);
- if (unlikely (status))
- goto CLEANUP_GLYPHS;
-
- /* For really huge font sizes, we can just do path;fill instead of
- * show_glyphs, as show_glyphs would put excess pressure on the cache,
-- * and moreover, not all components below us correctly handle huge font
-- * sizes. I wanted to set the limit at 256. But alas, seems like cairo's
-+ * not all components below us correctly handle huge font sizes, and
-+ * path filling can be cheaper since parts of glyphs are likely to be
-+ * clipped out. 256 seems like a good limit. But alas, seems like cairo's
- * rasterizer is something like ten times slower than freetype's for huge
-- * sizes. So, no win just yet. For now, do it for insanely-huge sizes,
-- * just to make sure we don't make anyone unhappy. When we get a really
-- * fast rasterizer in cairo, we may want to readjust this.
-+ * sizes. So, no win just yet when we're using cairo's rasterizer.
-+ * For now, if we're using cairo's rasterizer, use path filling only
-+ * for insanely-huge sizes, just to make sure we don't make anyone
-+ * unhappy. When we get a really fast rasterizer in cairo, we may
-+ * want to readjust this. The threshold calculation is
-+ * encapsulated in _cairo_surface_get_text_path_fill_threshold.
- *
- * Needless to say, do this only if show_text_glyphs is not available. */
- if (cairo_surface_has_show_text_glyphs (gstate->target) ||
-- _cairo_scaled_font_get_max_scale (gstate->scaled_font) <= 10240) {
-+ _cairo_scaled_font_get_max_scale (gstate->scaled_font) <=
-+ _cairo_surface_get_text_path_fill_threshold (gstate->target)) {
- status = _cairo_surface_show_text_glyphs (gstate->target,
- gstate->op,
- source_pattern,
- utf8, utf8_len,
- transformed_glyphs, num_glyphs,
- transformed_clusters, num_clusters,
- cluster_flags,
- gstate->scaled_font, NULL);
-diff --git a/gfx/cairo/cairo/src/cairo-surface.c b/gfx/cairo/cairo/src/cairo-surface.c
---- a/gfx/cairo/cairo/src/cairo-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-surface.c
-@@ -1120,16 +1120,22 @@ cairo_surface_get_fallback_resolution (c
- double *y_pixels_per_inch)
- {
- if (x_pixels_per_inch)
- *x_pixels_per_inch = surface->x_fallback_resolution;
- if (y_pixels_per_inch)
- *y_pixels_per_inch = surface->y_fallback_resolution;
- }
-
-+int
-+_cairo_surface_get_text_path_fill_threshold (const cairo_surface_t *surface)
-+{
-+ return surface->backend->fill == NULL ? 10240 : 256;
-+}
-+
- cairo_bool_t
- _cairo_surface_has_device_transform (cairo_surface_t *surface)
- {
- return ! _cairo_matrix_is_identity (&surface->device_transform);
- }
-
- /**
- * _cairo_surface_acquire_source_image:
-diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
---- a/gfx/cairo/cairo/src/cairoint.h
-+++ b/gfx/cairo/cairo/src/cairoint.h
-@@ -2065,16 +2065,19 @@ _cairo_surface_composite_shape_fixup_unb
- int dst_x,
- int dst_y,
- unsigned int width,
- unsigned int height);
-
- cairo_private cairo_bool_t
- _cairo_surface_is_opaque (const cairo_surface_t *surface);
-
-+cairo_private int
-+_cairo_surface_get_text_path_fill_threshold (const cairo_surface_t *surface);
-+
- cairo_private void
- _cairo_surface_set_device_scale (cairo_surface_t *surface,
- double sx,
- double sy);
-
- cairo_private cairo_bool_t
- _cairo_surface_has_device_transform (cairo_surface_t *surface);
-
diff --git a/gfx/cairo/unicode-printing.patch b/gfx/cairo/unicode-printing.patch
deleted file mode 100644
index 09b3991ea..000000000
--- a/gfx/cairo/unicode-printing.patch
+++ /dev/null
@@ -1,333 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-win32-printing-surface.c b/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
-@@ -1426,16 +1426,104 @@ _cairo_win32_printing_surface_fill (void
- }
-
- fflush(stderr);
-
- return status;
- }
-
- static cairo_int_status_t
-+_cairo_win32_printing_surface_emit_win32_glyphs (cairo_win32_surface_t *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_matrix_t ctm;
-+ cairo_glyph_t *unicode_glyphs;
-+ cairo_scaled_font_subsets_glyph_t subset_glyph;
-+ int i, first;
-+ cairo_bool_t sequence_is_unicode;
-+ cairo_status_t status = CAIRO_STATUS_SUCCESS;
-+
-+ /* Where possible reverse the glyph indices back to unicode
-+ * characters. Strings of glyphs that could not be reversed to
-+ * unicode will be printed with ETO_GLYPH_INDEX.
-+ *
-+ * As _cairo_win32_scaled_font_index_to_ucs4() is a slow
-+ * operation, the font subsetting function
-+ * _cairo_scaled_font_subsets_map_glyph() is used to obtain
-+ * the unicode value because it caches the reverse mapping in
-+ * the subsets.
-+ */
-+
-+ if (surface->has_ctm) {
-+ for (i = 0; i < num_glyphs; i++)
-+ cairo_matrix_transform_point (&surface->ctm, &glyphs[i].x, &glyphs[i].y);
-+ cairo_matrix_multiply (&ctm, &scaled_font->ctm, &surface->ctm);
-+ scaled_font = cairo_scaled_font_create (scaled_font->font_face,
-+ &scaled_font->font_matrix,
-+ &ctm,
-+ &scaled_font->options);
-+ }
-+
-+ unicode_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
-+ if (unicode_glyphs == NULL)
-+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-+
-+ memcpy (unicode_glyphs, glyphs, num_glyphs * sizeof (cairo_glyph_t));
-+ for (i = 0; i < num_glyphs; i++) {
-+ status = _cairo_scaled_font_subsets_map_glyph (surface->font_subsets,
-+ scaled_font,
-+ glyphs[i].index,
-+ NULL, 0,
-+ &subset_glyph);
-+ if (status)
-+ goto fail;
-+
-+ unicode_glyphs[i].index = subset_glyph.unicode;
-+ }
-+
-+ i = 0;
-+ first = 0;
-+ sequence_is_unicode = unicode_glyphs[0].index <= 0xffff;
-+ while (i < num_glyphs) {
-+ if (i == num_glyphs - 1 ||
-+ ((unicode_glyphs[i + 1].index < 0xffff) != sequence_is_unicode))
-+ {
-+ status = _cairo_win32_surface_show_glyphs_internal (
-+ surface,
-+ op,
-+ source,
-+ sequence_is_unicode ? &unicode_glyphs[first] : &glyphs[first],
-+ i - first + 1,
-+ scaled_font,
-+ clip,
-+ remaining_glyphs,
-+ ! sequence_is_unicode);
-+ first = i + 1;
-+ if (i < num_glyphs - 1)
-+ sequence_is_unicode = unicode_glyphs[i + 1].index <= 0xffff;
-+ }
-+ i++;
-+ }
-+
-+fail:
-+ if (surface->has_ctm)
-+ cairo_scaled_font_destroy (scaled_font);
-+
-+ free (unicode_glyphs);
-+
-+ return status;
-+}
-+
-+static cairo_int_status_t
- _cairo_win32_printing_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)
-@@ -1533,77 +1621,24 @@ _cairo_win32_printing_surface_show_glyph
- }
- }
- #endif
-
- #if CAIRO_HAS_WIN32_FONT
- if (cairo_scaled_font_get_type (scaled_font) == CAIRO_FONT_TYPE_WIN32 &&
- source->type == CAIRO_PATTERN_TYPE_SOLID)
- {
-- cairo_matrix_t ctm;
-- cairo_glyph_t *type1_glyphs = NULL;
-- cairo_scaled_font_subsets_glyph_t subset_glyph;
--
-- /* Calling ExtTextOutW() with ETO_GLYPH_INDEX and a Type 1
-- * font on a printer DC prints garbled text. The text displays
-- * correctly on a display DC. When using a printer
-- * DC, ExtTextOutW() only works with characters and not glyph
-- * indices.
-- *
-- * For Type 1 fonts the glyph indices are converted back to
-- * unicode characters before calling _cairo_win32_surface_show_glyphs().
-- *
-- * As _cairo_win32_scaled_font_index_to_ucs4() is a slow
-- * operation, the font subsetting function
-- * _cairo_scaled_font_subsets_map_glyph() is used to obtain
-- * the unicode value because it caches the reverse mapping in
-- * the subsets.
-- */
-- if (_cairo_win32_scaled_font_is_type1 (scaled_font)) {
-- type1_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
-- if (type1_glyphs == NULL) {
-- status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-- goto FINISH;
-- }
-- memcpy (type1_glyphs, glyphs, num_glyphs * sizeof (cairo_glyph_t));
-- for (i = 0; i < num_glyphs; i++) {
-- status = _cairo_scaled_font_subsets_map_glyph (surface->font_subsets,
-- scaled_font,
-- type1_glyphs[i].index,
-- NULL, 0,
-- &subset_glyph);
-- if (status)
-- goto FINISH;
--
-- type1_glyphs[i].index = subset_glyph.unicode;
-- }
-- glyphs = type1_glyphs;
-- }
--
-- if (surface->has_ctm || surface->has_gdi_ctm) {
-- cairo_matrix_multiply (&ctm, &surface->ctm, &surface->gdi_ctm);
-- for (i = 0; i < num_glyphs; i++)
-- cairo_matrix_transform_point (&ctm, &glyphs[i].x, &glyphs[i].y);
-- cairo_matrix_multiply (&ctm, &scaled_font->ctm, &ctm);
-- scaled_font = cairo_scaled_font_create (scaled_font->font_face,
-- &scaled_font->font_matrix,
-- &ctm,
-- &scaled_font->options);
-- }
-- status = _cairo_win32_surface_show_glyphs (surface, op,
-- source, glyphs,
-- num_glyphs, scaled_font,
-- clip,
-- remaining_glyphs);
-- if (surface->has_ctm || surface->has_gdi_ctm)
-- cairo_scaled_font_destroy (scaled_font);
--
-- if (type1_glyphs != NULL)
-- free (type1_glyphs);
--
-+ status = _cairo_win32_printing_surface_emit_win32_glyphs (surface,
-+ op,
-+ source,
-+ glyphs,
-+ num_glyphs,
-+ scaled_font,
-+ clip,
-+ remaining_glyphs);
- goto FINISH;
- }
- #endif
-
- SaveDC (surface->dc);
- old_ctm = surface->ctm;
- old_has_ctm = surface->has_ctm;
- surface->has_ctm = TRUE;
-diff --git a/gfx/cairo/cairo/src/cairo-win32-private.h b/gfx/cairo/cairo/src/cairo-win32-private.h
---- a/gfx/cairo/cairo/src/cairo-win32-private.h
-+++ b/gfx/cairo/cairo/src/cairo-win32-private.h
-@@ -157,16 +157,27 @@ _cairo_win32_surface_get_extents (void
- uint32_t
- _cairo_win32_flags_for_dc (HDC dc);
-
- cairo_status_t
- _cairo_win32_surface_set_clip_region (void *abstract_surface,
- cairo_region_t *region);
-
- cairo_int_status_t
-+_cairo_win32_surface_show_glyphs_internal (void *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_bool_t glyph_indices);
-+
-+cairo_int_status_t
- _cairo_win32_surface_show_glyphs (void *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);
-diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
-@@ -1607,24 +1607,25 @@ static cairo_status_t
- _cairo_win32_surface_flush (void *abstract_surface)
- {
- return _cairo_win32_surface_set_clip_region (abstract_surface, NULL);
- }
-
- #define STACK_GLYPH_SIZE 256
-
- cairo_int_status_t
--_cairo_win32_surface_show_glyphs (void *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_win32_surface_show_glyphs_internal (void *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_bool_t glyph_indexing)
- {
- #ifdef CAIRO_HAS_WIN32_FONT
- if (scaled_font->backend->type == CAIRO_FONT_TYPE_DWRITE) {
- #ifdef CAIRO_HAS_DWRITE_FONT
- return _cairo_dwrite_show_glyphs_on_surface(surface, op, source, glyphs, num_glyphs, scaled_font, clip);
- #endif
- } else {
- cairo_win32_surface_t *dst = surface;
-@@ -1737,29 +1738,20 @@ _cairo_win32_surface_show_glyphs (void
- dxy_buf[j+1] = _cairo_lround (logical_y - next_logical_y);
- /* note that GDI coordinate system is inverted */
-
- logical_x = next_logical_x;
- logical_y = next_logical_y;
- }
- }
-
-- /* Using glyph indices for a Type 1 font does not work on a
-- * printer DC. The win32 printing surface will convert the the
-- * glyph indices of Type 1 fonts to the unicode values.
-- */
-- if ((dst->flags & CAIRO_WIN32_SURFACE_FOR_PRINTING) &&
-- _cairo_win32_scaled_font_is_type1 (scaled_font))
-- {
-+ if (glyph_indexing)
-+ glyph_index_option = ETO_GLYPH_INDEX;
-+ else
- glyph_index_option = 0;
-- }
-- else
-- {
-- glyph_index_option = ETO_GLYPH_INDEX;
-- }
-
- win_result = ExtTextOutW(dst->dc,
- start_x,
- start_y,
- glyph_index_option | ETO_PDY,
- NULL,
- glyph_buf,
- num_glyphs,
-@@ -1778,16 +1770,37 @@ _cairo_win32_surface_show_glyphs (void
- }
- #else
- return CAIRO_INT_STATUS_UNSUPPORTED;
- #endif
- }
-
- #undef STACK_GLYPH_SIZE
-
-+cairo_int_status_t
-+_cairo_win32_surface_show_glyphs (void *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_win32_surface_show_glyphs_internal (surface,
-+ op,
-+ source,
-+ glyphs,
-+ num_glyphs,
-+ scaled_font,
-+ clip,
-+ remaining_glyphs,
-+ TRUE);
-+}
-+
- static cairo_surface_t *
- cairo_win32_surface_create_internal (HDC hdc, cairo_format_t format)
- {
- cairo_win32_surface_t *surface;
-
- RECT rect;
-
- surface = malloc (sizeof (cairo_win32_surface_t));
diff --git a/gfx/cairo/use-show-text-glyphs-if-glyph-path-fails.patch b/gfx/cairo/use-show-text-glyphs-if-glyph-path-fails.patch
deleted file mode 100644
index 1670eaf73..000000000
--- a/gfx/cairo/use-show-text-glyphs-if-glyph-path-fails.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From: Jonathan Kew <jkew@mozilla.com>
-bug 715798 pt 2 - fall back to show_text_glyphs even at huge sizes if scaled_font_glyph_path didn't work. r=jrmuizel
-
-diff --git a/gfx/cairo/cairo/src/cairo-gstate.c b/gfx/cairo/cairo/src/cairo-gstate.c
---- a/gfx/cairo/cairo/src/cairo-gstate.c
-+++ b/gfx/cairo/cairo/src/cairo-gstate.c
-@@ -2002,23 +2002,34 @@ cairo_status_t
- cairo_path_fixed_t path;
-
- _cairo_path_fixed_init (&path);
-
- status = _cairo_scaled_font_glyph_path (gstate->scaled_font,
- transformed_glyphs, num_glyphs,
- &path);
-
-- if (status == CAIRO_STATUS_SUCCESS) {
-+ if (status == CAIRO_STATUS_SUCCESS && !_cairo_path_fixed_fill_is_empty (&path)) {
- status = _cairo_surface_fill (gstate->target, op, pattern,
- &path,
- CAIRO_FILL_RULE_WINDING,
- gstate->tolerance,
- gstate->scaled_font->options.antialias,
- _gstate_get_clip (gstate, &clip));
-+ } else {
-+ /* if _cairo_scaled_font_glyph_path() failed, maybe the font doesn't support
-+ * returning paths, so try the _cairo_surface_show_text_glyphs() option
-+ */
-+ status = _cairo_surface_show_text_glyphs (gstate->target, op, pattern,
-+ utf8, utf8_len,
-+ transformed_glyphs, num_glyphs,
-+ transformed_clusters, num_clusters,
-+ cluster_flags,
-+ gstate->scaled_font,
-+ _gstate_get_clip (gstate, &clip));
- }
-
- _cairo_path_fixed_fini (&path);
- }
-
- _cairo_clip_fini (&clip);
-
- CLEANUP_GLYPHS:
diff --git a/gfx/cairo/win32-ExtCreatePen-zero-size.patch b/gfx/cairo/win32-ExtCreatePen-zero-size.patch
deleted file mode 100644
index 3970015f7..000000000
--- a/gfx/cairo/win32-ExtCreatePen-zero-size.patch
+++ /dev/null
@@ -1,85 +0,0 @@
-From: Robert O'Callahan <robert@ocallahan.org>
-Bug 768348. Avoid ExtCreatePen failures by avoiding rounding widths and dash lengths down to zero. r=jrmuizel
-
-diff --git a/gfx/cairo/cairo/src/cairo-win32-printing-surface.c b/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
-@@ -1251,22 +1251,24 @@ static cairo_int_status_t
- {
- cairo_win32_surface_t *surface = abstract_surface;
- cairo_int_status_t status;
- HPEN pen;
- LOGBRUSH brush;
- COLORREF color;
- XFORM xform;
- DWORD pen_style;
-+ DWORD pen_width;
- DWORD *dash_array;
- HGDIOBJ obj;
- unsigned int i;
- cairo_solid_pattern_t clear;
- cairo_matrix_t mat;
- double scale;
-+ double scaled_width;
-
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
- if (status)
- return status;
-
- if (op == CAIRO_OPERATOR_CLEAR) {
- _cairo_win32_printing_surface_init_clear_color (surface, &clear);
- source = (cairo_pattern_t*) &clear;
-@@ -1288,17 +1290,21 @@ static cairo_int_status_t
- _cairo_matrix_factor_out_scale (&mat, &scale);
-
- pen_style = PS_GEOMETRIC;
- dash_array = NULL;
- if (style->num_dashes) {
- pen_style |= PS_USERSTYLE;
- dash_array = calloc (sizeof (DWORD), style->num_dashes);
- for (i = 0; i < style->num_dashes; i++) {
-- dash_array[i] = (DWORD) (scale * style->dash[i]);
-+ DWORD dashes = (DWORD) (scale * style->dash[i]);
-+ /* zero dash-lengths cause ExtCreatePen to fail. Make the dashes
-+ * longer if necessary.
-+ */
-+ dash_array[i] = MAX(1, dashes);
- }
- } else {
- pen_style |= PS_SOLID;
- }
-
- SetMiterLimit (surface->dc, (FLOAT) (style->miter_limit), NULL);
- if (source->type == CAIRO_PATTERN_TYPE_SOLID) {
- cairo_solid_pattern_t *solid = (cairo_solid_pattern_t *) source;
-@@ -1310,18 +1316,29 @@ static cairo_int_status_t
- /* Color not used as the pen will only be used by WidenPath() */
- color = RGB (0,0,0);
- }
- brush.lbStyle = BS_SOLID;
- brush.lbColor = color;
- brush.lbHatch = 0;
- pen_style |= _cairo_win32_line_cap (style->line_cap);
- pen_style |= _cairo_win32_line_join (style->line_join);
-+ scaled_width = scale * style->line_width;
-+ if (scaled_width == 0.0)
-+ return status;
-+ pen_width = (DWORD)scaled_width;
-+ if (pen_width == 0) {
-+ /* ExtCreatePen will fail if passed zero width. We have to choose
-+ * between drawing something too wide, or drawing nothing at all.
-+ * Let's draw something.
-+ */
-+ pen_width = 1;
-+ }
- pen = ExtCreatePen(pen_style,
-- scale * style->line_width,
-+ pen_width,
- &brush,
- style->num_dashes,
- dash_array);
- if (pen == NULL)
- return _cairo_win32_print_gdi_error ("_win32_surface_stroke:ExtCreatePen");
- obj = SelectObject (surface->dc, pen);
- if (obj == NULL)
- return _cairo_win32_print_gdi_error ("_win32_surface_stroke:SelectObject");
diff --git a/gfx/cairo/win32-avoid-extend-pad-fallback.patch b/gfx/cairo/win32-avoid-extend-pad-fallback.patch
deleted file mode 100644
index b04282ce9..000000000
--- a/gfx/cairo/win32-avoid-extend-pad-fallback.patch
+++ /dev/null
@@ -1,109 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
-@@ -1114,17 +1114,17 @@ static cairo_int_status_t
- cairo_win32_surface_t *dst = abstract_dst;
- cairo_win32_surface_t *src;
- cairo_surface_pattern_t *src_surface_pattern;
- int alpha;
- double scalex, scaley;
- cairo_fixed_t x0_fixed, y0_fixed;
- cairo_int_status_t status;
-
-- cairo_bool_t needs_alpha, needs_scale, needs_repeat;
-+ cairo_bool_t needs_alpha, needs_scale, needs_repeat, needs_pad;
- cairo_image_surface_t *src_image = NULL;
-
- cairo_format_t src_format;
- cairo_rectangle_int_t src_extents;
-
- cairo_rectangle_int_t src_r = { src_x, src_y, width, height };
- cairo_rectangle_int_t dst_r = { dst_x, dst_y, width, height };
-
-@@ -1145,17 +1145,18 @@ static cairo_int_status_t
- {
- goto UNSUPPORTED;
- }
-
- if (pattern->type != CAIRO_PATTERN_TYPE_SURFACE)
- goto UNSUPPORTED;
-
- if (pattern->extend != CAIRO_EXTEND_NONE &&
-- pattern->extend != CAIRO_EXTEND_REPEAT)
-+ pattern->extend != CAIRO_EXTEND_REPEAT &&
-+ pattern->extend != CAIRO_EXTEND_PAD)
- goto UNSUPPORTED;
-
- if (mask_pattern) {
- /* FIXME: When we fully support RENDER style 4-channel
- * masks we need to check r/g/b != 1.0.
- */
- if (mask_pattern->type != CAIRO_PATTERN_TYPE_SOLID)
- return CAIRO_INT_STATUS_UNSUPPORTED;
-@@ -1252,16 +1253,17 @@ static cairo_int_status_t
-
- /* If the src rectangle doesn't wholly lie within the src extents,
- * fudge things. We really need to do fixup on the unpainted
- * region -- e.g. the SOURCE operator is broken for areas outside
- * of the extents, because it won't clear that area to transparent
- * black.
- */
-
-+ needs_pad = FALSE;
- if (pattern->extend != CAIRO_EXTEND_REPEAT) {
- needs_repeat = FALSE;
-
- /* If the src rect and the extents of the source image don't overlap at all,
- * we can't do anything useful here.
- */
- if (src_r.x > src_extents.width || src_r.y > src_extents.height ||
- (src_r.x + src_r.width) < 0 || (src_r.y + src_r.height) < 0)
-@@ -1273,40 +1275,48 @@ static cairo_int_status_t
-
- if (src_r.x < 0) {
- src_r.width += src_r.x;
-
- dst_r.width += src_r.x;
- dst_r.x -= src_r.x;
-
- src_r.x = 0;
-+ needs_pad = TRUE;
- }
-
- if (src_r.y < 0) {
- src_r.height += src_r.y;
-
- dst_r.height += src_r.y;
- dst_r.y -= src_r.y;
-
- src_r.y = 0;
-+ needs_pad = TRUE;
- }
-
- if (src_r.x + src_r.width > src_extents.width) {
- src_r.width = src_extents.width - src_r.x;
- dst_r.width = src_r.width;
-+ needs_pad = TRUE;
- }
-
- if (src_r.y + src_r.height > src_extents.height) {
- src_r.height = src_extents.height - src_r.y;
- dst_r.height = src_r.height;
-+ needs_pad = TRUE;
- }
- } else {
- needs_repeat = TRUE;
- }
-
-+ if (pattern->extend == CAIRO_EXTEND_PAD && needs_pad) {
-+ goto UNSUPPORTED;
-+ }
-+
- /*
- * Operations that we can do:
- *
- * AlphaBlend uses the following formula for alpha when not use the per-pixel alpha (AlphaFormat = 0)
- * Dst.Alpha = Src.Alpha * (SCA/255.0) + Dst.Alpha * (1.0 - (SCA/255.0))
- * This turns into Dst.Alpha = Src.Alpha when SCA = 255.
- * (http://msdn.microsoft.com/en-us/library/aa921335.aspx)
- *
diff --git a/gfx/cairo/win32-canvas-glyph-position.patch b/gfx/cairo/win32-canvas-glyph-position.patch
deleted file mode 100644
index 4ed10596c..000000000
--- a/gfx/cairo/win32-canvas-glyph-position.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-win32-font.c b/gfx/cairo/cairo/src/cairo-win32-font.c
---- a/gfx/cairo/cairo/src/cairo-win32-font.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-font.c
-@@ -1182,22 +1182,22 @@ _add_glyph (cairo_glyph_state_t *state,
- if (state->glyphs.num_elements > 0) {
- int dx;
-
- if (logical_y != state->last_y) {
- status = _flush_glyphs (state);
- if (status)
- return status;
- state->start_x = logical_x;
-+ } else {
-+ dx = logical_x - state->last_x;
-+ status = _cairo_array_append (&state->dx, &dx);
-+ if (status)
-+ return status;
- }
--
-- dx = logical_x - state->last_x;
-- status = _cairo_array_append (&state->dx, &dx);
-- if (status)
-- return status;
- } else {
- state->start_x = logical_x;
- }
-
- state->last_x = logical_x;
- state->last_y = logical_y;
-
- status = _cairo_array_append (&state->glyphs, &glyph_index);
diff --git a/gfx/cairo/win32-cleartype-clipping.patch b/gfx/cairo/win32-cleartype-clipping.patch
deleted file mode 100644
index 839e94039..000000000
--- a/gfx/cairo/win32-cleartype-clipping.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-win32-font.c b/gfx/cairo/cairo/src/cairo-win32-font.c
---- a/gfx/cairo/cairo/src/cairo-win32-font.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-font.c
-@@ -986,6 +986,19 @@ _cairo_win32_scaled_font_init_glyph_metr
- &metrics, 0, NULL, &matrix) == GDI_ERROR) {
- status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_init_glyph_metrics:GetGlyphOutlineW");
- memset (&metrics, 0, sizeof (GLYPHMETRICS));
-+ } else {
-+ if (metrics.gmBlackBoxX > 0 && scaled_font->base.options.antialias != CAIRO_ANTIALIAS_NONE) {
-+ /* The bounding box reported by Windows supposedly contains the glyph's "black" area;
-+ * however, antialiasing (especially with ClearType) means that the actual image that
-+ * needs to be rendered may "bleed" into the adjacent pixels, mainly on the right side.
-+ * To avoid clipping the glyphs when drawn by _cairo_surface_fallback_show_glyphs,
-+ * for example, or other code that uses glyph extents to determine the area to update,
-+ * we add a pixel of "slop" to left side of the nominal "black" area returned by GDI,
-+ * and two pixels to the right (as tests show some glyphs bleed into this column).
-+ */
-+ metrics.gmptGlyphOrigin.x -= 1;
-+ metrics.gmBlackBoxX += 3;
-+ }
- }
- cairo_win32_scaled_font_done_font (&scaled_font->base);
- if (status)
diff --git a/gfx/cairo/win32-composite-src-mod.patch b/gfx/cairo/win32-composite-src-mod.patch
deleted file mode 100644
index f2f99940a..000000000
--- a/gfx/cairo/win32-composite-src-mod.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
-@@ -928,16 +928,19 @@ _cairo_win32_surface_composite_inner (ca
- return _composite_alpha_blend (dst, src, alpha,
- src_r.x, src_r.y, src_r.width, src_r.height,
- dst_r.x, dst_r.y, dst_r.width, dst_r.height);
- }
-
- return CAIRO_STATUS_SUCCESS;
- }
-
-+/* from pixman-private.h */
-+#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
-+
- static cairo_int_status_t
- _cairo_win32_surface_composite (cairo_operator_t op,
- cairo_pattern_t *pattern,
- cairo_pattern_t *mask_pattern,
- void *abstract_dst,
- int src_x,
- int src_y,
- int mask_x,
-@@ -1209,18 +1212,18 @@ _cairo_win32_surface_composite (cairo_op
- /* If we need to repeat, we turn the repeated blit into
- * a bunch of piece-by-piece blits.
- */
- if (needs_repeat) {
- cairo_rectangle_int_t piece_src_r, piece_dst_r;
- uint32_t rendered_width = 0, rendered_height = 0;
- uint32_t to_render_height, to_render_width;
- int32_t piece_x, piece_y;
-- int32_t src_start_x = src_r.x % src_extents.width;
-- int32_t src_start_y = src_r.y % src_extents.height;
-+ int32_t src_start_x = MOD(src_r.x, src_extents.width);
-+ int32_t src_start_y = MOD(src_r.y, src_extents.height);
-
- if (needs_scale)
- goto UNSUPPORTED;
-
- /* If both the src and dest have an image, we may as well fall
- * back, because it will be faster than our separate blits.
- * Our blit code will be fastest when the src is a DDB and the
- * destination is a DDB.
diff --git a/gfx/cairo/win32-d3dsurface9.patch b/gfx/cairo/win32-d3dsurface9.patch
deleted file mode 100644
index b0e80252f..000000000
--- a/gfx/cairo/win32-d3dsurface9.patch
+++ /dev/null
@@ -1,465 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-rename.h b/gfx/cairo/cairo/src/cairo-rename.h
---- a/gfx/cairo/cairo/src/cairo-rename.h
-+++ b/gfx/cairo/cairo/src/cairo-rename.h
-@@ -335,16 +335,17 @@
- #define cairo_win32_font_face_create_for_logfontw_hfont _moz_cairo_win32_font_face_create_for_logfontw_hfont
- #define cairo_win32_printing_surface_create _moz_cairo_win32_printing_surface_create
- #define cairo_win32_scaled_font_done_font _moz_cairo_win32_scaled_font_done_font
- #define cairo_win32_scaled_font_get_device_to_logical _moz_cairo_win32_scaled_font_get_device_to_logical
- #define cairo_win32_scaled_font_get_logical_to_device _moz_cairo_win32_scaled_font_get_logical_to_device
- #define cairo_win32_scaled_font_get_metrics_factor _moz_cairo_win32_scaled_font_get_metrics_factor
- #define cairo_win32_scaled_font_select_font _moz_cairo_win32_scaled_font_select_font
- #define cairo_win32_surface_create _moz_cairo_win32_surface_create
-+#define cairo_win32_surface_create_with_d3dsurface9 _moz_cairo_win32_surface_create_with_d3dsurface9
- #define cairo_win32_surface_create_with_ddb _moz_cairo_win32_surface_create_with_ddb
- #define cairo_win32_surface_create_with_dib _moz_cairo_win32_surface_create_with_dib
- #define cairo_win32_surface_get_dc _moz_cairo_win32_surface_get_dc
- #define cairo_win32_surface_get_image _moz_cairo_win32_surface_get_image
- #define cairo_xcb_surface_create _moz_cairo_xcb_surface_create
- #define cairo_xcb_surface_create_for_bitmap _moz_cairo_xcb_surface_create_for_bitmap
- #define cairo_xcb_surface_create_with_xrender_format _moz_cairo_xcb_surface_create_with_xrender_format
- #define cairo_xcb_surface_set_size _moz_cairo_xcb_surface_set_size
-diff --git a/gfx/cairo/cairo/src/cairo-win32-printing-surface.c b/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
-@@ -1852,16 +1852,17 @@ cairo_win32_printing_surface_create (HDC
- }
-
- _cairo_surface_clipper_init (&surface->clipper,
- _cairo_win32_printing_surface_clipper_intersect_clip_path);
-
- surface->image = NULL;
- surface->format = CAIRO_FORMAT_RGB24;
- surface->content = CAIRO_CONTENT_COLOR_ALPHA;
-+ surface->d3d9surface = NULL;
-
- surface->dc = hdc;
- surface->bitmap = NULL;
- surface->is_dib = FALSE;
- surface->saved_dc_bitmap = NULL;
- surface->brush = NULL;
- surface->old_brush = NULL;
- surface->font_subsets = _cairo_scaled_font_subsets_create_scaled ();
-diff --git a/gfx/cairo/cairo/src/cairo-win32-private.h b/gfx/cairo/cairo/src/cairo-win32-private.h
---- a/gfx/cairo/cairo/src/cairo-win32-private.h
-+++ b/gfx/cairo/cairo/src/cairo-win32-private.h
-@@ -54,16 +54,18 @@ CAIRO_BEGIN_DECLS
-
- typedef struct _cairo_win32_surface {
- cairo_surface_t base;
-
- cairo_format_t format;
-
- HDC dc;
-
-+ struct IDirect3DSurface9 *d3d9surface;
-+
- /* We create off-screen surfaces as DIBs or DDBs, based on what we created
- * originally*/
- HBITMAP bitmap;
- cairo_bool_t is_dib;
-
- /* Used to save the initial 1x1 monochrome bitmap for the DC to
- * select back into the DC before deleting the DC and our
- * bitmap. For Windows XP, this doesn't seem to be necessary
-diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
-@@ -54,16 +54,17 @@
- #include "cairo-win32-private.h"
- #include "cairo-scaled-font-subsets-private.h"
- #include "cairo-surface-fallback-private.h"
- #include "cairo-surface-clipper-private.h"
- #include "cairo-gstate-private.h"
- #include "cairo-private.h"
- #include <wchar.h>
- #include <windows.h>
-+#include <d3d9.h>
-
- #if defined(__MINGW32__) && !defined(ETO_PDY)
- # define ETO_PDY 0x2000
- #endif
-
- #undef DEBUG_COMPOSITE
-
- /* for older SDKs */
-@@ -384,16 +385,17 @@ static cairo_surface_t *
-
- surface->image = cairo_image_surface_create_for_data (bits, format,
- width, height, rowstride);
- status = surface->image->status;
- if (status)
- goto FAIL;
-
- surface->format = format;
-+ surface->d3d9surface = NULL;
-
- surface->clip_rect.x = 0;
- surface->clip_rect.y = 0;
- surface->clip_rect.width = width;
- surface->clip_rect.height = height;
-
- surface->initial_clip_rgn = NULL;
- surface->had_simple_clip = FALSE;
-@@ -481,26 +483,73 @@ cairo_status_t
- if (surface->bitmap) {
- SelectObject (surface->dc, surface->saved_dc_bitmap);
- DeleteObject (surface->bitmap);
- DeleteDC (surface->dc);
- } else {
- _cairo_win32_restore_initial_clip (surface);
- }
-
-+ if (surface->d3d9surface) {
-+ IDirect3DSurface9_ReleaseDC (surface->d3d9surface, surface->dc);
-+ IDirect3DSurface9_Release (surface->d3d9surface);
-+ }
-+
- if (surface->initial_clip_rgn)
- DeleteObject (surface->initial_clip_rgn);
-
- if (surface->font_subsets != NULL)
- _cairo_scaled_font_subsets_destroy (surface->font_subsets);
-
- return CAIRO_STATUS_SUCCESS;
- }
-
- static cairo_status_t
-+_cairo_win32_surface_d3d9_lock_rect (cairo_win32_surface_t *surface,
-+ int x,
-+ int y,
-+ int width,
-+ int height,
-+ cairo_image_surface_t **local_out)
-+{
-+ cairo_image_surface_t *local;
-+ cairo_int_status_t status;
-+
-+ RECT rectin = { x, y, x+width, y+height };
-+ D3DLOCKED_RECT rectout;
-+ HRESULT hr;
-+ hr = IDirect3DSurface9_ReleaseDC (surface->d3d9surface, surface->dc);
-+ hr = IDirect3DSurface9_LockRect (surface->d3d9surface,
-+ &rectout, &rectin, 0);
-+ surface->dc = 0; // Don't use the DC when this is locked!
-+ if (hr) {
-+ IDirect3DSurface9_GetDC (surface->d3d9surface, &surface->dc);
-+ return CAIRO_INT_STATUS_UNSUPPORTED;
-+ }
-+ local = cairo_image_surface_create_for_data (rectout.pBits,
-+ surface->format,
-+ width, height,
-+ rectout.Pitch);
-+ if (local == NULL) {
-+ IDirect3DSurface9_UnlockRect (surface->d3d9surface);
-+ IDirect3DSurface9_GetDC (surface->d3d9surface, &surface->dc);
-+ return CAIRO_INT_STATUS_UNSUPPORTED;
-+ }
-+ if (local->base.status) {
-+ IDirect3DSurface9_UnlockRect (surface->d3d9surface);
-+ IDirect3DSurface9_GetDC (surface->d3d9surface, &surface->dc);
-+ return local->base.status;
-+ }
-+
-+ *local_out = local;
-+
-+ return CAIRO_STATUS_SUCCESS;
-+}
-+
-+static cairo_status_t
- _cairo_win32_surface_get_subimage (cairo_win32_surface_t *surface,
- int x,
- int y,
- int width,
- int height,
- cairo_win32_surface_t **local_out)
- {
- cairo_win32_surface_t *local;
-@@ -599,17 +648,16 @@ static void
- }
-
- static cairo_status_t
- _cairo_win32_surface_acquire_source_image (void *abstract_surface,
- cairo_image_surface_t **image_out,
- void **image_extra)
- {
- cairo_win32_surface_t *surface = abstract_surface;
-- cairo_win32_surface_t *local;
- cairo_status_t status;
-
- if (!surface->image && !surface->is_dib && surface->bitmap &&
- (surface->flags & CAIRO_WIN32_SURFACE_CAN_CONVERT_TO_DIB) != 0)
- {
- /* This is a DDB, and we're being asked to use it as a source for
- * something that we couldn't support natively. So turn it into
- * a DIB, so that we have an equivalent image surface, as long
-@@ -619,69 +667,109 @@ static cairo_status_t
- }
-
- if (surface->image) {
- *image_out = (cairo_image_surface_t *)surface->image;
- *image_extra = NULL;
- return CAIRO_STATUS_SUCCESS;
- }
-
-- status = _cairo_win32_surface_get_subimage (abstract_surface, 0, 0,
-- surface->extents.width,
-- surface->extents.height, &local);
-- if (status)
-- return status;
--
-- *image_out = (cairo_image_surface_t *)local->image;
-- *image_extra = local;
-+ if (surface->d3d9surface) {
-+ cairo_image_surface_t *local;
-+ status = _cairo_win32_surface_d3d9_lock_rect (abstract_surface, 0, 0,
-+ surface->extents.width,
-+ surface->extents.height, &local);
-+ if (status)
-+ return status;
-+
-+ *image_out = local;
-+ *image_extra = surface;
-+ } else {
-+ cairo_win32_surface_t *local;
-+ status = _cairo_win32_surface_get_subimage (abstract_surface, 0, 0,
-+ surface->extents.width,
-+ surface->extents.height, &local);
-+ if (status)
-+ return status;
-+
-+ *image_out = (cairo_image_surface_t *)local->image;
-+ *image_extra = local;
-+ }
-+ // image_extra is always of type cairo_win32_surface_t. For d3d9surface it points
-+ // to the original surface to get back the d3d9surface and properly unlock.
-+
- return CAIRO_STATUS_SUCCESS;
- }
-
- static void
- _cairo_win32_surface_release_source_image (void *abstract_surface,
- cairo_image_surface_t *image,
- void *image_extra)
- {
-+ cairo_win32_surface_t *surface = abstract_surface;
- cairo_win32_surface_t *local = image_extra;
-
-- if (local)
-+ if (local && local->d3d9surface) {
-+ IDirect3DSurface9_UnlockRect (local->d3d9surface);
-+ IDirect3DSurface9_GetDC (local->d3d9surface, &local->dc);
-+ cairo_surface_destroy ((cairo_surface_t *)image);
-+ } else {
- cairo_surface_destroy ((cairo_surface_t *)local);
-+ }
- }
-
- static cairo_status_t
- _cairo_win32_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_win32_surface_t *surface = abstract_surface;
-- cairo_win32_surface_t *local = NULL;
- cairo_status_t status;
-
- if (surface->image) {
- GdiFlush();
-
- *image_out = (cairo_image_surface_t *) surface->image;
- *image_extra = NULL;
- *image_rect = surface->extents;
- return CAIRO_STATUS_SUCCESS;
- }
-
-- status = _cairo_win32_surface_get_subimage (abstract_surface,
-+ if (surface->d3d9surface) {
-+ cairo_image_surface_t *local = NULL;
-+ status = _cairo_win32_surface_d3d9_lock_rect (abstract_surface,
- interest_rect->x,
- interest_rect->y,
- interest_rect->width,
-- interest_rect->height,
-- &local);
-- if (status)
-- return status;
--
-- *image_out = (cairo_image_surface_t *) local->image;
-- *image_extra = local;
-+ interest_rect->height, &local);
-+
-+ if (status)
-+ return status;
-+
-+ *image_out = local;
-+ *image_extra = surface;
-+ } else {
-+ cairo_win32_surface_t *local = NULL;
-+ status = _cairo_win32_surface_get_subimage (abstract_surface,
-+ interest_rect->x,
-+ interest_rect->y,
-+ interest_rect->width,
-+ interest_rect->height, &local);
-+
-+ if (status)
-+ return status;
-+
-+ *image_out = (cairo_image_surface_t *) local->image;
-+ *image_extra = local;
-+ }
-+ // image_extra is always of type cairo_win32_surface_t. For d3d9surface it points
-+ // to the original surface to get back the d3d9surface and properly unlock.
-+
- *image_rect = *interest_rect;
- return CAIRO_STATUS_SUCCESS;
- }
-
- static void
- _cairo_win32_surface_release_dest_image (void *abstract_surface,
- cairo_rectangle_int_t *interest_rect,
- cairo_image_surface_t *image,
-@@ -689,29 +777,37 @@ static void
- void *image_extra)
- {
- cairo_win32_surface_t *surface = abstract_surface;
- cairo_win32_surface_t *local = image_extra;
-
- if (!local)
- return;
-
-- /* clear any clip that's currently set on the surface
-- so that we can blit uninhibited. */
-- _cairo_win32_surface_set_clip_region (surface, NULL);
--
-- if (!BitBlt (surface->dc,
-- image_rect->x, image_rect->y,
-- image_rect->width, image_rect->height,
-- local->dc,
-- 0, 0,
-- SRCCOPY))
-- _cairo_win32_print_gdi_error ("_cairo_win32_surface_release_dest_image");
--
-- cairo_surface_destroy ((cairo_surface_t *)local);
-+ if (local->d3d9surface) {
-+ IDirect3DSurface9_UnlockRect (local->d3d9surface);
-+ IDirect3DSurface9_GetDC (local->d3d9surface, &local->dc);
-+ cairo_surface_destroy ((cairo_surface_t *)image);
-+ } else {
-+
-+ /* clear any clip that's currently set on the surface
-+ so that we can blit uninhibited. */
-+ _cairo_win32_surface_set_clip_region (surface, NULL);
-+
-+ if (!BitBlt (surface->dc,
-+ image_rect->x, image_rect->y,
-+ image_rect->width, image_rect->height,
-+ local->dc,
-+ 0, 0,
-+ SRCCOPY))
-+ _cairo_win32_print_gdi_error ("_cairo_win32_surface_release_dest_image");
-+
-+ cairo_surface_destroy ((cairo_surface_t *)local);
-+ }
-+
- }
-
- cairo_status_t
- _cairo_win32_surface_set_clip_region (void *abstract_surface,
- cairo_region_t *region)
- {
- cairo_win32_surface_t *surface = abstract_surface;
- cairo_status_t status = CAIRO_STATUS_SUCCESS;
-@@ -1849,16 +1945,17 @@ cairo_win32_surface_create_internal (HDC
- free (surface);
- return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
- }
-
- surface->clip_region = NULL;
- surface->image = NULL;
- surface->format = format;
-
-+ surface->d3d9surface = NULL;
- surface->dc = hdc;
- surface->bitmap = NULL;
- surface->is_dib = FALSE;
- surface->saved_dc_bitmap = NULL;
- surface->brush = NULL;
- surface->old_brush = NULL;
- surface->font_subsets = NULL;
-
-@@ -2009,16 +2106,29 @@ cairo_win32_surface_create_with_ddb (HDC
-
- FINISH:
- if (screen_dc)
- ReleaseDC (NULL, screen_dc);
-
- return (cairo_surface_t*) new_surf;
- }
-
-+cairo_public cairo_surface_t *
-+cairo_win32_surface_create_with_d3dsurface9 (IDirect3DSurface9 *surface)
-+{
-+ HDC dc;
-+ cairo_win32_surface_t *win_surface;
-+
-+ IDirect3DSurface9_AddRef (surface);
-+ IDirect3DSurface9_GetDC (surface, &dc);
-+ win_surface = cairo_win32_surface_create_internal(dc, CAIRO_FORMAT_RGB24);
-+ win_surface->d3d9surface = surface;
-+ return (cairo_surface_t*) win_surface;
-+
-+}
- /**
- * _cairo_surface_is_win32:
- * @surface: a #cairo_surface_t
- *
- * Checks if a surface is a win32 surface. This will
- * return False if this is a win32 printing surface; use
- * _cairo_surface_is_win32_printing() to check for that.
- *
-diff --git a/gfx/cairo/cairo/src/cairo-win32.h b/gfx/cairo/cairo/src/cairo-win32.h
---- a/gfx/cairo/cairo/src/cairo-win32.h
-+++ b/gfx/cairo/cairo/src/cairo-win32.h
-@@ -59,17 +59,16 @@ cairo_win32_surface_create_with_ddb (HDC hdc,
- cairo_format_t format,
- int width,
- int height);
-
- cairo_public cairo_surface_t *
- cairo_win32_surface_create_with_dib (cairo_format_t format,
- int width,
- int height);
--
- cairo_public HDC
- cairo_win32_surface_get_dc (cairo_surface_t *surface);
-
- cairo_public HDC
- cairo_win32_get_dc_with_clip (cairo_t *cr);
-
- cairo_public cairo_surface_t *
- cairo_win32_surface_get_image (cairo_surface_t *surface);
-@@ -143,16 +142,21 @@ cairo_dwrite_scaled_font_get_force_GDI_classic(cairo_scaled_font_t *dwrite_scale
- void
- cairo_dwrite_set_cleartype_params(FLOAT gamma, FLOAT contrast, FLOAT level, int geometry, int mode);
-
- int
- cairo_dwrite_get_cleartype_rendering_mode();
-
- #endif /* CAIRO_HAS_DWRITE_FONT */
-
-+struct IDirect3DSurface9;
-+cairo_public cairo_surface_t *
-+cairo_win32_surface_create_with_d3dsurface9 (struct IDirect3DSurface9 *surface);
-+
-+
- #if CAIRO_HAS_D2D_SURFACE
-
- struct _cairo_device
- {
- int type;
- int refcount;
- };
-
diff --git a/gfx/cairo/win32-ddb-dib.patch b/gfx/cairo/win32-ddb-dib.patch
deleted file mode 100644
index a520d6e10..000000000
--- a/gfx/cairo/win32-ddb-dib.patch
+++ /dev/null
@@ -1,181 +0,0 @@
-b=455513; add optional flag to allow converting a DDB to a DIB internally, if the surface is every used as a source; r=jmuizelaar
-
-If a DDB is used as a source for an operation that can't be handled
-natively by GDI, we end up needing to take a really slow path (creating a
-temporary surface for acquire_source) for each operation. If we convert
-the DDB to a DIB, we then end up having a real image buffer and can hand
-things off to pixman directly.
-
-This isn't the default mode because I'm not sure if there are cases where a
-DDB is explicitly needed (e.g. for printing), and it would change
-current cairo behaviour. It might become the default at some point in the
-future.
-
-diff --git a/gfx/cairo/cairo/src/cairo-win32-private.h b/gfx/cairo/cairo/src/cairo-win32-private.h
---- a/gfx/cairo/cairo/src/cairo-win32-private.h
-+++ b/gfx/cairo/cairo/src/cairo-win32-private.h
-@@ -117,6 +117,9 @@
-
- /* Whether we can use the CHECKJPEGFORMAT escape function */
- CAIRO_WIN32_SURFACE_CAN_CHECK_PNG = (1<<8),
-+
-+ /* if this DDB surface can be converted to a DIB if necessary */
-+ CAIRO_WIN32_SURFACE_CAN_CONVERT_TO_DIB = (1<<9),
- };
-
- cairo_status_t
-diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
-@@ -560,6 +560,56 @@
- return CAIRO_STATUS_SUCCESS;
- }
-
-+static void
-+_cairo_win32_convert_ddb_to_dib (cairo_win32_surface_t *surface)
-+{
-+ cairo_win32_surface_t *new_surface;
-+ int width = surface->extents.width;
-+ int height = surface->extents.height;
-+
-+ BOOL ok;
-+ HBITMAP oldbitmap;
-+
-+ new_surface = (cairo_win32_surface_t*)
-+ _cairo_win32_surface_create_for_dc (surface->dc,
-+ surface->format,
-+ width,
-+ height);
-+
-+ if (new_surface->base.status)
-+ return;
-+
-+ /* DDB can't be 32bpp, so BitBlt is safe */
-+ ok = BitBlt (new_surface->dc,
-+ 0, 0, width, height,
-+ surface->dc,
-+ 0, 0, SRCCOPY);
-+
-+ if (!ok)
-+ goto out;
-+
-+ /* Now swap around new_surface and surface's internal bitmap
-+ * pointers. */
-+ DeleteDC (new_surface->dc);
-+ new_surface->dc = NULL;
-+
-+ oldbitmap = SelectObject (surface->dc, new_surface->bitmap);
-+ DeleteObject (oldbitmap);
-+
-+ surface->image = new_surface->image;
-+ surface->is_dib = new_surface->is_dib;
-+ surface->bitmap = new_surface->bitmap;
-+
-+ new_surface->bitmap = NULL;
-+ new_surface->image = NULL;
-+
-+ /* Finally update flags */
-+ surface->flags = _cairo_win32_flags_for_dc (surface->dc);
-+
-+ out:
-+ cairo_surface_destroy ((cairo_surface_t*)new_surface);
-+}
-+
- static cairo_status_t
- _cairo_win32_surface_acquire_source_image (void *abstract_surface,
- cairo_image_surface_t **image_out,
-@@ -568,6 +618,17 @@
- cairo_win32_surface_t *surface = abstract_surface;
- cairo_win32_surface_t *local = NULL;
- cairo_status_t status;
-+
-+ if (!surface->image && !surface->is_dib && surface->bitmap &&
-+ (surface->flags & CAIRO_WIN32_SURFACE_CAN_CONVERT_TO_DIB) != 0)
-+ {
-+ /* This is a DDB, and we're being asked to use it as a source for
-+ * something that we couldn't support natively. So turn it into
-+ * a DIB, so that we have an equivalent image surface, as long
-+ * as we're allowed to via flags.
-+ */
-+ _cairo_win32_convert_ddb_to_dib (surface);
-+ }
-
- if (surface->image) {
- *image_out = (cairo_image_surface_t *)surface->image;
-@@ -2133,3 +2194,61 @@
- free(rd);
- fflush (stderr);
- }
-+
-+/**
-+ * cairo_win32_surface_set_can_convert_to_dib
-+ * @surface: a #cairo_surface_t
-+ * @can_convert: a #cairo_bool_t indicating whether this surface can
-+ * be coverted to a DIB if necessary
-+ *
-+ * A DDB surface with this flag set can be converted to a DIB if it's
-+ * used as a source in a way that GDI can't natively handle; for
-+ * example, drawing a RGB24 DDB onto an ARGB32 DIB. Doing this
-+ * conversion results in a significant speed optimization, because we
-+ * can call on pixman to perform the operation natively, instead of
-+ * reading the data from the DC each time.
-+ *
-+ * Return value: %CAIRO_STATUS_SUCCESS if the flag was successfully
-+ * changed, or an error otherwise.
-+ *
-+ */
-+cairo_status_t
-+cairo_win32_surface_set_can_convert_to_dib (cairo_surface_t *asurface, cairo_bool_t can_convert)
-+{
-+ cairo_win32_surface_t *surface = (cairo_win32_surface_t*) asurface;
-+ if (surface->base.type != CAIRO_SURFACE_TYPE_WIN32)
-+ return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
-+
-+ if (surface->bitmap) {
-+ if (can_convert)
-+ surface->flags |= CAIRO_WIN32_SURFACE_CAN_CONVERT_TO_DIB;
-+ else
-+ surface->flags &= ~CAIRO_WIN32_SURFACE_CAN_CONVERT_TO_DIB;
-+ }
-+
-+ return CAIRO_STATUS_SUCCESS;
-+}
-+
-+/**
-+ * cairo_win32_surface_get_can_convert_to_dib
-+ * @surface: a #cairo_surface_t
-+ * @can_convert: a #cairo_bool_t* that receives the return value
-+ *
-+ * Returns the value of the flag indicating whether the surface can be
-+ * converted to a DIB if necessary, as set by
-+ * cairo_win32_surface_set_can_convert_to_dib.
-+ *
-+ * Return value: %CAIRO_STATUS_SUCCESS if the flag was successfully
-+ * retreived, or an error otherwise.
-+ *
-+ */
-+cairo_status_t
-+cairo_win32_surface_get_can_convert_to_dib (cairo_surface_t *asurface, cairo_bool_t *can_convert)
-+{
-+ cairo_win32_surface_t *surface = (cairo_win32_surface_t*) asurface;
-+ if (surface->base.type != CAIRO_SURFACE_TYPE_WIN32)
-+ return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
-+
-+ *can_convert = ((surface->flags & CAIRO_WIN32_SURFACE_CAN_CONVERT_TO_DIB) != 0);
-+ return CAIRO_STATUS_SUCCESS;
-+}
-diff --git a/gfx/cairo/cairo/src/cairo-win32.h b/gfx/cairo/cairo/src/cairo-win32.h
---- a/gfx/cairo/cairo/src/cairo-win32.h
-+++ b/gfx/cairo/cairo/src/cairo-win32.h
-@@ -68,6 +68,12 @@ cairo_win32_surface_get_dc (cairo_surface_t *surface);
- cairo_public cairo_surface_t *
- cairo_win32_surface_get_image (cairo_surface_t *surface);
-
-+cairo_public cairo_status_t
-+cairo_win32_surface_set_can_convert_to_dib (cairo_surface_t *surface, cairo_bool_t can_convert);
-+
-+cairo_public cairo_status_t
-+cairo_win32_surface_get_can_convert_to_dib (cairo_surface_t *surface, cairo_bool_t *can_convert);
-+
- #if CAIRO_HAS_WIN32_FONT
-
diff --git a/gfx/cairo/win32-ffs-gcc.patch b/gfx/cairo/win32-ffs-gcc.patch
deleted file mode 100644
index e7cc1d1f6..000000000
--- a/gfx/cairo/win32-ffs-gcc.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-compiler-private.h b/gfx/cairo/cairo/src/cairo-compiler-private.h
-index ffac9ce..9a05831 100644
---- a/gfx/cairo/cairo/src/cairo-compiler-private.h
-+++ b/gfx/cairo/cairo/src/cairo-compiler-private.h
-@@ -229,16 +229,20 @@ ffs (int x)
-
- if (_BitScanForward(&i, x) != 0)
- return i + 1;
-
- return 0;
- }
- #endif
-
-+#elif defined(__WIN32__) && defined(__GNUC__)
-+
-+#define ffs(x) __builtin_ffs(x)
-+
- #endif
-
- #if defined(_MSC_VER) && defined(_M_IX86)
- /* When compiling with /Gy and /OPT:ICF identical functions will be folded in together.
- The CAIRO_ENSURE_UNIQUE macro ensures that a function is always unique and
- will never be folded into another one. Something like this might eventually
- be needed for GCC but it seems fine for now. */
- #define CAIRO_ENSURE_UNIQUE \
diff --git a/gfx/cairo/win32-gdi-font-cache-no-HFONT.patch b/gfx/cairo/win32-gdi-font-cache-no-HFONT.patch
deleted file mode 100644
index fe93095ae..000000000
--- a/gfx/cairo/win32-gdi-font-cache-no-HFONT.patch
+++ /dev/null
@@ -1,145 +0,0 @@
-# HG changeset patch
-# User Robert O'Callahan <robert@ocallahan.org>
-# Date 1357107533 -46800
-# Node ID ed54dfdd2facb11a4d4158138b460a31de45e9f7
-# Parent ab6457cc16ec14ea07386dcfc57cad6b8a9ac55d
-Bug 717178. Part 3 alternative: don't put Win32 cairo_font_face_ts into the font-face cache if they were created with an explicit HFONT. r=jrmuizel
-
-diff --git a/gfx/cairo/cairo/src/cairo-win32-font.c b/gfx/cairo/cairo/src/cairo-win32-font.c
---- a/gfx/cairo/cairo/src/cairo-win32-font.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-font.c
-@@ -1941,16 +1942,21 @@ const cairo_font_face_backend_t _cairo_w
- * The primary purpose of this mapping is to provide unique
- * #cairo_font_face_t values so that our cache and mapping from
- * #cairo_font_face_t => #cairo_scaled_font_t works. Once the
- * corresponding #cairo_font_face_t objects fall out of downstream
- * caches, we don't need them in this hash table anymore.
- *
- * Modifications to this hash table are protected by
- * _cairo_win32_font_face_mutex.
-+ *
-+ * Only #cairo_font_face_t values with null 'hfont' (no
-+ * HFONT preallocated by caller) are stored in this table. We rely
-+ * on callers to manage the lifetime of the HFONT, and they can't
-+ * do that if we share #cairo_font_face_t values with other callers.
- */
-
- static cairo_hash_table_t *cairo_win32_font_face_hash_table = NULL;
-
- static int
- _cairo_win32_font_face_keys_equal (const void *key_a,
- const void *key_b);
-
-@@ -2036,22 +2042,24 @@ static int
- }
-
- static void
- _cairo_win32_font_face_destroy (void *abstract_face)
- {
- cairo_hash_table_t *hash_table;
- cairo_win32_font_face_t *font_face = abstract_face;
-
-- hash_table = _cairo_win32_font_face_hash_table_lock ();
-- if (unlikely (hash_table == NULL)) {
-- return;
-+ if (!font_face->hfont) {
-+ hash_table = _cairo_win32_font_face_hash_table_lock ();
-+ if (unlikely (hash_table == NULL)) {
-+ return;
-+ }
-+ _cairo_hash_table_remove (hash_table, &font_face->base.hash_entry);
-+ _cairo_win32_font_face_hash_table_unlock ();
- }
-- _cairo_hash_table_remove (hash_table, &font_face->base.hash_entry);
-- _cairo_win32_font_face_hash_table_unlock ();
- }
-
- /**
- * cairo_win32_font_face_create_for_logfontw_hfont:
- * @logfont: A #LOGFONTW structure specifying the font to use.
- * If @font is %NULL then the lfHeight, lfWidth, lfOrientation and lfEscapement
- * fields of this structure are ignored. Otherwise lfWidth, lfOrientation and
- * lfEscapement must be zero.
-@@ -2070,55 +2078,63 @@ static void
- **/
- cairo_font_face_t *
- cairo_win32_font_face_create_for_logfontw_hfont (LOGFONTW *logfont, HFONT font)
- {
- cairo_win32_font_face_t *font_face, key;
- cairo_hash_table_t *hash_table;
- cairo_status_t status;
-
-- hash_table = _cairo_win32_font_face_hash_table_lock ();
-- if (unlikely (hash_table == NULL)) {
-- _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
-- return (cairo_font_face_t *)&_cairo_font_face_nil;
-- }
-+ if (!font) {
-+ hash_table = _cairo_win32_font_face_hash_table_lock ();
-+ if (unlikely (hash_table == NULL)) {
-+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
-+ return (cairo_font_face_t *)&_cairo_font_face_nil;
-+ }
-
-- _cairo_win32_font_face_init_key (&key, logfont, font);
-+ _cairo_win32_font_face_init_key (&key, logfont, font);
-
-- /* Return existing unscaled font if it exists in the hash table. */
-- font_face = _cairo_hash_table_lookup (hash_table,
-- &key.base.hash_entry);
-- if (font_face != NULL) {
-- cairo_font_face_reference (&font_face->base);
-- goto DONE;
-+ /* Return existing unscaled font if it exists in the hash table. */
-+ font_face = _cairo_hash_table_lookup (hash_table,
-+ &key.base.hash_entry);
-+ if (font_face != NULL) {
-+ cairo_font_face_reference (&font_face->base);
-+ goto DONE;
-+ }
- }
-
- /* Otherwise create it and insert into hash table. */
- font_face = malloc (sizeof (cairo_win32_font_face_t));
- if (!font_face) {
- _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
- goto FAIL;
- }
-
- _cairo_win32_font_face_init_key (font_face, logfont, font);
- _cairo_font_face_init (&font_face->base, &_cairo_win32_font_face_backend);
-+ assert (font_face->base.hash_entry.hash == key.base.hash_entry.hash);
-
-- assert (font_face->base.hash_entry.hash == key.base.hash_entry.hash);
-- status = _cairo_hash_table_insert (hash_table,
-- &font_face->base.hash_entry);
-- if (unlikely (status))
-- goto FAIL;
-+ if (!font) {
-+ status = _cairo_hash_table_insert (hash_table,
-+ &font_face->base.hash_entry);
-+ if (unlikely (status))
-+ goto FAIL;
-+ }
-
- DONE:
-- _cairo_win32_font_face_hash_table_unlock ();
-+ if (!font) {
-+ _cairo_win32_font_face_hash_table_unlock ();
-+ }
-
- return &font_face->base;
-
- FAIL:
-- _cairo_win32_font_face_hash_table_unlock ();
-+ if (!font) {
-+ _cairo_win32_font_face_hash_table_unlock ();
-+ }
-
- return (cairo_font_face_t *)&_cairo_font_face_nil;
- }
-
- /**
- * cairo_win32_font_face_create_for_logfontw:
- * @logfont: A #LOGFONTW structure specifying the font to use.
- * The lfHeight, lfWidth, lfOrientation and lfEscapement
diff --git a/gfx/cairo/win32-gdi-font-cache.patch b/gfx/cairo/win32-gdi-font-cache.patch
deleted file mode 100644
index e082a2e4d..000000000
--- a/gfx/cairo/win32-gdi-font-cache.patch
+++ /dev/null
@@ -1,375 +0,0 @@
-# HG changeset patch
-# User Andrea Canciani <ranma42@gmail.com>, Adrian Johnson <ajohnson@redneon.com>
-# Date 1354838294 -46800
-# Node ID 390df735b9d5c5ba07a4d3fe9ca2ebc9e7626a78
-# Parent e30a5b6a5a003b85fc1ca8b76719a56ef59d976e
-Bug 717178. Part 2: Import changesets eb29a25d, 6e3e3291 and 101fab7c from upstream.
-======
-
-From 101fab7cd8a90f7cf3d8113c792b3f8c2a9afb7d Mon Sep 17 00:00:00 2001
-From: Andrea Canciani <ranma42@gmail.com>
-Date: Wed, 15 Jun 2011 09:37:36 +0000
-Subject: win32-font: Improve static data reset function
-
-The hashtable is guaranteed to only contain font faces which are
-currently referenced, hence there is no need to remove any font face
-when it is reset (just like for toy-font).
-
-This makes the function simpler and fixes the assertion
-
-Assertion failed: predicate != NULL, file cairo-hash.c, line 373
-
-hit by multiple tests (the first one being "clear").
-
-See https://bugs.freedesktop.org/show_bug.cgi?id=38049
-
-======
-
-From eb29a25dd6dddc511388bf883c9b95843ecdb823 Mon Sep 17 00:00:00 2001
-From: Adrian Johnson <ajohnson@redneon.com>
-Date: Tue, 16 Nov 2010 13:18:39 +0000
-Subject: win32: Use a font_face hash table to provide unique font faces
-
-Similar to the freetype and toy font backends, use a hash table
-to map logfont,hfont to font faces.
-
-This fixes the multiple embedding of the same font in PDF.
-
-https://bugs.freedesktop.org/show_bug.cgi?id=24849
-
-======
-
-From 6e3e329170ab4b96bc0d587c8071e869e228e758 Mon Sep 17 00:00:00 2001
-From: Adrian Johnson <ajohnson@redneon.com>
-Date: Thu, 18 Nov 2010 12:37:45 +0000
-Subject: win32: fix font_face hashing
-
-some bugs were discovered while testing with firefox
-
-======
-
-diff --git a/gfx/cairo/cairo/src/cairo-debug.c b/gfx/cairo/cairo/src/cairo-debug.c
---- a/gfx/cairo/cairo/src/cairo-debug.c
-+++ b/gfx/cairo/cairo/src/cairo-debug.c
-@@ -64,16 +64,20 @@ cairo_debug_reset_static_data (void)
- _cairo_scaled_font_map_destroy ();
-
- _cairo_toy_font_face_reset_static_data ();
-
- #if CAIRO_HAS_FT_FONT
- _cairo_ft_font_reset_static_data ();
- #endif
-
-+#if CAIRO_HAS_WIN32_FONT
-+ _cairo_win32_font_reset_static_data ();
-+#endif
-+
- _cairo_intern_string_reset_static_data ();
-
- _cairo_scaled_font_reset_static_data ();
-
- _cairo_pattern_reset_static_data ();
-
- _cairo_clip_reset_static_data ();
-
-diff --git a/gfx/cairo/cairo/src/cairo-mutex-list-private.h b/gfx/cairo/cairo/src/cairo-mutex-list-private.h
---- a/gfx/cairo/cairo/src/cairo-mutex-list-private.h
-+++ b/gfx/cairo/cairo/src/cairo-mutex-list-private.h
-@@ -46,16 +46,20 @@ CAIRO_MUTEX_DECLARE (_cairo_intern_strin
- CAIRO_MUTEX_DECLARE (_cairo_scaled_font_map_mutex)
- CAIRO_MUTEX_DECLARE (_cairo_scaled_glyph_page_cache_mutex)
- CAIRO_MUTEX_DECLARE (_cairo_scaled_font_error_mutex)
-
- #if CAIRO_HAS_FT_FONT
- CAIRO_MUTEX_DECLARE (_cairo_ft_unscaled_font_map_mutex)
- #endif
-
-+#if CAIRO_HAS_WIN32_FONT
-+CAIRO_MUTEX_DECLARE (_cairo_win32_font_face_mutex)
-+#endif
-+
- #if CAIRO_HAS_XLIB_SURFACE
- CAIRO_MUTEX_DECLARE (_cairo_xlib_display_mutex)
- #endif
-
- #if CAIRO_HAS_XCB_SURFACE
- CAIRO_MUTEX_DECLARE (_cairo_xcb_connections_mutex)
- #endif
-
-diff --git a/gfx/cairo/cairo/src/cairo-win32-font.c b/gfx/cairo/cairo/src/cairo-win32-font.c
---- a/gfx/cairo/cairo/src/cairo-win32-font.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-font.c
-@@ -42,16 +42,18 @@
- # define _WIN32_WINNT 0x0500
- #endif
-
- #include "cairoint.h"
-
- #include "cairo-win32-private.h"
- #include "cairo-error-private.h"
-
-+#include <wchar.h>
-+
- #ifndef SPI_GETFONTSMOOTHINGTYPE
- #define SPI_GETFONTSMOOTHINGTYPE 0x200a
- #endif
- #ifndef FE_FONTSMOOTHINGCLEARTYPE
- #define FE_FONTSMOOTHINGCLEARTYPE 2
- #endif
- #ifndef CLEARTYPE_QUALITY
- #define CLEARTYPE_QUALITY 5
-@@ -1887,19 +1889,17 @@ struct _cairo_win32_font_face {
- cairo_font_face_t base;
- LOGFONTW logfont;
- HFONT hfont;
- };
-
- /* implement the platform-specific interface */
-
- static void
--_cairo_win32_font_face_destroy (void *abstract_face)
--{
--}
-+_cairo_win32_font_face_destroy (void *abstract_face);
-
- static cairo_bool_t
- _is_scale (const cairo_matrix_t *matrix, double scale)
- {
- return matrix->xx == scale && matrix->yy == scale &&
- matrix->xy == 0. && matrix->yx == 0. &&
- matrix->x0 == 0. && matrix->y0 == 0.;
- }
-@@ -1932,16 +1932,128 @@ static cairo_status_t
-
- const cairo_font_face_backend_t _cairo_win32_font_face_backend = {
- CAIRO_FONT_TYPE_WIN32,
- _cairo_win32_font_face_create_for_toy,
- _cairo_win32_font_face_destroy,
- _cairo_win32_font_face_scaled_font_create
- };
-
-+/* We maintain a hash table from LOGFONT,HFONT => #cairo_font_face_t.
-+ * The primary purpose of this mapping is to provide unique
-+ * #cairo_font_face_t values so that our cache and mapping from
-+ * #cairo_font_face_t => #cairo_scaled_font_t works. Once the
-+ * corresponding #cairo_font_face_t objects fall out of downstream
-+ * caches, we don't need them in this hash table anymore.
-+ *
-+ * Modifications to this hash table are protected by
-+ * _cairo_win32_font_face_mutex.
-+ */
-+
-+static cairo_hash_table_t *cairo_win32_font_face_hash_table = NULL;
-+
-+static int
-+_cairo_win32_font_face_keys_equal (const void *key_a,
-+ const void *key_b);
-+
-+static void
-+_cairo_win32_font_face_hash_table_destroy (void)
-+{
-+ cairo_hash_table_t *hash_table;
-+
-+ /* We manually acquire the lock rather than calling
-+ * _cairo_win32_font_face_hash_table_lock simply to avoid creating
-+ * the table only to destroy it again. */
-+ CAIRO_MUTEX_LOCK (_cairo_win32_font_face_mutex);
-+ hash_table = cairo_win32_font_face_hash_table;
-+ cairo_win32_font_face_hash_table = NULL;
-+ CAIRO_MUTEX_UNLOCK (_cairo_win32_font_face_mutex);
-+
-+ if (hash_table != NULL)
-+ _cairo_hash_table_destroy (hash_table);
-+}
-+
-+static cairo_hash_table_t *
-+_cairo_win32_font_face_hash_table_lock (void)
-+{
-+ CAIRO_MUTEX_LOCK (_cairo_win32_font_face_mutex);
-+
-+ if (unlikely (cairo_win32_font_face_hash_table == NULL))
-+ {
-+ cairo_win32_font_face_hash_table =
-+ _cairo_hash_table_create (_cairo_win32_font_face_keys_equal);
-+
-+ if (unlikely (cairo_win32_font_face_hash_table == NULL)) {
-+ CAIRO_MUTEX_UNLOCK (_cairo_win32_font_face_mutex);
-+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
-+ return NULL;
-+ }
-+ }
-+
-+ return cairo_win32_font_face_hash_table;
-+}
-+
-+static void
-+_cairo_win32_font_face_hash_table_unlock (void)
-+{
-+ CAIRO_MUTEX_UNLOCK (_cairo_win32_font_face_mutex);
-+}
-+
-+static void
-+_cairo_win32_font_face_init_key (cairo_win32_font_face_t *key,
-+ LOGFONTW *logfont,
-+ HFONT font)
-+{
-+ unsigned long hash = _CAIRO_HASH_INIT_VALUE;
-+
-+ key->logfont = *logfont;
-+ key->hfont = font;
-+
-+ hash = _cairo_hash_bytes (0, logfont->lfFaceName, 2*wcslen(logfont->lfFaceName));
-+ hash = _cairo_hash_bytes (hash, &logfont->lfWeight, sizeof(logfont->lfWeight));
-+ hash = _cairo_hash_bytes (hash, &logfont->lfItalic, sizeof(logfont->lfItalic));
-+
-+ key->base.hash_entry.hash = hash;
-+}
-+
-+static int
-+_cairo_win32_font_face_keys_equal (const void *key_a,
-+ const void *key_b)
-+{
-+ const cairo_win32_font_face_t *face_a = key_a;
-+ const cairo_win32_font_face_t *face_b = key_b;
-+
-+ if (face_a->logfont.lfWeight == face_b->logfont.lfWeight &&
-+ face_a->logfont.lfItalic == face_b->logfont.lfItalic &&
-+ face_a->logfont.lfUnderline == face_b->logfont.lfUnderline &&
-+ face_a->logfont.lfStrikeOut == face_b->logfont.lfStrikeOut &&
-+ face_a->logfont.lfCharSet == face_b->logfont.lfCharSet &&
-+ face_a->logfont.lfOutPrecision == face_b->logfont.lfOutPrecision &&
-+ face_a->logfont.lfClipPrecision == face_b->logfont.lfClipPrecision &&
-+ face_a->logfont.lfPitchAndFamily == face_b->logfont.lfPitchAndFamily &&
-+ (wcscmp (face_a->logfont.lfFaceName, face_b->logfont.lfFaceName) == 0))
-+ return TRUE;
-+ else
-+ return FALSE;
-+}
-+
-+static void
-+_cairo_win32_font_face_destroy (void *abstract_face)
-+{
-+ cairo_hash_table_t *hash_table;
-+ cairo_win32_font_face_t *font_face = abstract_face;
-+
-+ hash_table = _cairo_win32_font_face_hash_table_lock ();
-+ if (unlikely (hash_table == NULL)) {
-+ return;
-+ }
-+ _cairo_hash_table_remove (hash_table, &font_face->base.hash_entry);
-+ _cairo_win32_font_face_hash_table_unlock ();
-+}
-+
- /**
- * cairo_win32_font_face_create_for_logfontw_hfont:
- * @logfont: A #LOGFONTW structure specifying the font to use.
- * If @font is %NULL then the lfHeight, lfWidth, lfOrientation and lfEscapement
- * fields of this structure are ignored. Otherwise lfWidth, lfOrientation and
- * lfEscapement must be zero.
- * @font: An #HFONT that can be used when the font matrix is a scale by
- * -lfHeight and the CTM is identity.
-@@ -1954,30 +2066,61 @@ const cairo_font_face_backend_t _cairo_w
- * and can be used with functions such as cairo_win32_scaled_font_select_font().
- *
- * Return value: a newly created #cairo_font_face_t. Free with
- * cairo_font_face_destroy() when you are done using it.
- **/
- cairo_font_face_t *
- cairo_win32_font_face_create_for_logfontw_hfont (LOGFONTW *logfont, HFONT font)
- {
-- cairo_win32_font_face_t *font_face;
-+ cairo_win32_font_face_t *font_face, key;
-+ cairo_hash_table_t *hash_table;
-+ cairo_status_t status;
-
-+ hash_table = _cairo_win32_font_face_hash_table_lock ();
-+ if (unlikely (hash_table == NULL)) {
-+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
-+ return (cairo_font_face_t *)&_cairo_font_face_nil;
-+ }
-+
-+ _cairo_win32_font_face_init_key (&key, logfont, font);
-+
-+ /* Return existing unscaled font if it exists in the hash table. */
-+ font_face = _cairo_hash_table_lookup (hash_table,
-+ &key.base.hash_entry);
-+ if (font_face != NULL) {
-+ cairo_font_face_reference (&font_face->base);
-+ goto DONE;
-+ }
-+
-+ /* Otherwise create it and insert into hash table. */
- font_face = malloc (sizeof (cairo_win32_font_face_t));
- if (!font_face) {
- _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
-- return (cairo_font_face_t *)&_cairo_font_face_nil;
-+ goto FAIL;
- }
-
-- font_face->logfont = *logfont;
-- font_face->hfont = font;
--
-+ _cairo_win32_font_face_init_key (font_face, logfont, font);
- _cairo_font_face_init (&font_face->base, &_cairo_win32_font_face_backend);
-
-+ assert (font_face->base.hash_entry.hash == key.base.hash_entry.hash);
-+ status = _cairo_hash_table_insert (hash_table,
-+ &font_face->base.hash_entry);
-+ if (unlikely (status))
-+ goto FAIL;
-+
-+DONE:
-+ _cairo_win32_font_face_hash_table_unlock ();
-+
- return &font_face->base;
-+
-+FAIL:
-+ _cairo_win32_font_face_hash_table_unlock ();
-+
-+ return (cairo_font_face_t *)&_cairo_font_face_nil;
- }
-
- /**
- * cairo_win32_font_face_create_for_logfontw:
- * @logfont: A #LOGFONTW structure specifying the font to use.
- * The lfHeight, lfWidth, lfOrientation and lfEscapement
- * fields of this structure are ignored.
- *
-@@ -2176,8 +2319,14 @@ cairo_win32_scaled_font_get_device_to_lo
- cairo_win32_scaled_font_t *win_font = (cairo_win32_scaled_font_t *)scaled_font;
- if (! _cairo_scaled_font_is_win32 (scaled_font)) {
- _cairo_error_throw (CAIRO_STATUS_FONT_TYPE_MISMATCH);
- cairo_matrix_init_identity (device_to_logical);
- return;
- }
- *device_to_logical = win_font->device_to_logical;
- }
-+
-+void
-+_cairo_win32_font_reset_static_data (void)
-+{
-+ _cairo_win32_font_face_hash_table_destroy ();
-+}
-diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
---- a/gfx/cairo/cairo/src/cairoint.h
-+++ b/gfx/cairo/cairo/src/cairoint.h
-@@ -403,16 +403,19 @@ cairo_private void
- _cairo_reset_static_data (void);
-
- cairo_private void
- _cairo_toy_font_face_reset_static_data (void);
-
- cairo_private void
- _cairo_ft_font_reset_static_data (void);
-
-+cairo_private void
-+_cairo_win32_font_reset_static_data (void);
-+
- /* the font backend interface */
-
- struct _cairo_unscaled_font_backend {
- void (*destroy) (void *unscaled_font);
- };
-
- /* #cairo_toy_font_face_t - simple family/slant/weight font faces used for
- * the built-in font API
diff --git a/gfx/cairo/win32-inline-cpp-keyword.patch b/gfx/cairo/win32-inline-cpp-keyword.patch
deleted file mode 100644
index 4b6f542d7..000000000
--- a/gfx/cairo/win32-inline-cpp-keyword.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-compiler-private.h b/gfx/cairo/cairo/src/cairo-compiler-private.h
---- a/gfx/cairo/cairo/src/cairo-compiler-private.h
-+++ b/gfx/cairo/cairo/src/cairo-compiler-private.h
-@@ -205,18 +205,20 @@
- #if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER)
- #define snprintf _snprintf
- #define popen _popen
- #define pclose _pclose
- #define hypot _hypot
- #endif
-
- #ifdef _MSC_VER
-+#ifndef __cplusplus
- #undef inline
- #define inline __inline
-+#endif
-
- /* there are currently linkage problems that arise when trying to include intrin.h in c++:
- * D:\sdks\v7.0\include\winnt.h(3674) : error C2733: second C linkage of overloaded function '_interlockedbittestandset' not allowed
- * so avoid defining ffs in c++ code for now */
- #ifndef __cplusplus
- /* Add a definition of ffs */
- #include <intrin.h>
- #pragma intrinsic(_BitScanForward)
diff --git a/gfx/cairo/win32-logical-font-scale.patch b/gfx/cairo/win32-logical-font-scale.patch
deleted file mode 100644
index 02d812be3..000000000
--- a/gfx/cairo/win32-logical-font-scale.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -r e10a8066a62c gfx/cairo/cairo/src/cairo-win32-private.h
---- a/gfx/cairo/cairo/src/cairo-win32-private.h Fri Jun 08 17:39:38 2007 -0700
-+++ b/gfx/cairo/cairo/src/cairo-win32-private.h Fri Jun 29 09:14:35 2007 +0200
-@@ -46,7 +46,7 @@
- #define SB_NONE 0
- #endif
-
--#define WIN32_FONT_LOGICAL_SCALE 32
-+#define WIN32_FONT_LOGICAL_SCALE 1
-
- typedef struct _cairo_win32_surface {
- cairo_surface_t base;
diff --git a/gfx/cairo/win32-printing-axis-swap.patch b/gfx/cairo/win32-printing-axis-swap.patch
deleted file mode 100644
index 87a1a91e4..000000000
--- a/gfx/cairo/win32-printing-axis-swap.patch
+++ /dev/null
@@ -1,292 +0,0 @@
-# HG changeset patch
-# User Lee Salzman <lsalzman@mozilla.com>
-# Date 1445463645 14400
-# Wed Oct 21 17:40:45 2015 -0400
-# Node ID 9e84563cbd73c5b0993dfd018ca25b660b667e94
-# Parent 2d3fd51c4182c253a2f102655e8e9e466032853f
-workaround for Windows printer drivers that can't handle swapped X and Y axes
-
-diff --git a/gfx/cairo/cairo/src/cairo-matrix.c b/gfx/cairo/cairo/src/cairo-matrix.c
---- a/gfx/cairo/cairo/src/cairo-matrix.c
-+++ b/gfx/cairo/cairo/src/cairo-matrix.c
-@@ -873,42 +873,56 @@ cairo_bool_t
- (Note that the minor axis length is at the minimum of the above solution,
- which is just sqrt ( f - sqrt(g² + h²) ) given the symmetry of (D)).
-
-
- For another derivation of the same result, using Singular Value Decomposition,
- see doc/tutorial/src/singular.c.
- */
-
--/* determine the length of the major axis of a circle of the given radius
-- after applying the transformation matrix. */
--double
--_cairo_matrix_transformed_circle_major_axis (const cairo_matrix_t *matrix,
-- double radius)
-+/* determine the length of the major and minor axes of a circle of the given
-+ radius after applying the transformation matrix. */
-+void
-+_cairo_matrix_transformed_circle_axes (const cairo_matrix_t *matrix,
-+ double radius,
-+ double *major,
-+ double *minor)
- {
-- double a, b, c, d, f, g, h, i, j;
-+ double a, b, c, d, f, g, h, i, j, k;
-
- _cairo_matrix_get_affine (matrix,
- &a, &b,
- &c, &d,
- NULL, NULL);
-
- i = a*a + b*b;
- j = c*c + d*d;
-+ k = a*c + b*d;
-
- f = 0.5 * (i + j);
- g = 0.5 * (i - j);
-- h = a*c + b*d;
-+ h = hypot (g, k);
-
-- return radius * sqrt (f + hypot (g, h));
-+ if (major)
-+ *major = radius * sqrt (f + h);
-+ if (minor)
-+ *minor = radius * sqrt (f - h);
-+}
-
-- /*
-- * we don't need the minor axis length, which is
-- * double min = radius * sqrt (f - sqrt (g*g+h*h));
-- */
-+/* determine the length of the major axis of a circle of the given radius
-+ after applying the transformation matrix. */
-+double
-+_cairo_matrix_transformed_circle_major_axis (const cairo_matrix_t *matrix,
-+ double radius)
-+{
-+ double major;
-+
-+ _cairo_matrix_transformed_circle_axes (matrix, radius, &major, NULL);
-+
-+ return major;
- }
-
- void
- _cairo_matrix_to_pixman_matrix (const cairo_matrix_t *matrix,
- pixman_transform_t *pixman_transform,
- double xc,
- double yc)
- {
-diff --git a/gfx/cairo/cairo/src/cairo-win32-printing-surface.c b/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-printing-surface.c
-@@ -610,16 +610,17 @@ static cairo_status_t
- int x_tile, y_tile, left, right, top, bottom;
- RECT clip;
- const cairo_color_t *background_color;
- const unsigned char *mime_data;
- unsigned long mime_size;
- cairo_image_info_t mime_info;
- cairo_bool_t use_mime;
- DWORD mime_type;
-+ cairo_bool_t axis_swap;
-
- /* If we can't use StretchDIBits with this surface, we can't do anything
- * here.
- */
- if (!(surface->flags & CAIRO_WIN32_SURFACE_CAN_STRETCHDIB))
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- if (surface->content == CAIRO_CONTENT_COLOR_ALPHA)
-@@ -658,39 +659,65 @@ static cairo_status_t
- &mime_size,
- &mime_info);
- }
- if (_cairo_status_is_error (status))
- return status;
-
- use_mime = (status == CAIRO_STATUS_SUCCESS);
-
-- if (!use_mime && image->format != CAIRO_FORMAT_RGB24) {
-+ m = pattern->base.matrix;
-+ status = cairo_matrix_invert (&m);
-+ /* _cairo_pattern_set_matrix guarantees invertibility */
-+ assert (status == CAIRO_STATUS_SUCCESS);
-+ cairo_matrix_multiply (&m, &m, &surface->ctm);
-+ cairo_matrix_multiply (&m, &m, &surface->gdi_ctm);
-+ /* Check if the matrix swaps the X and Y axes by checking if the diagonal
-+ * is effectively zero. This can happen, for example, if it was composed
-+ * with a rotation such as a landscape transform. Some printing devices
-+ * don't support such transforms in StretchDIBits.
-+ */
-+ axis_swap = fabs (m.xx*image->width) < 1 && fabs (m.yy*image->height) < 1;
-+
-+ if (!use_mime && (image->format != CAIRO_FORMAT_RGB24 || axis_swap)) {
- cairo_surface_t *opaque_surface;
- cairo_surface_pattern_t image_pattern;
- cairo_solid_pattern_t background_pattern;
-+ int width = image->width, height = image->height;
-
-+ if (axis_swap) {
-+ width = image->height;
-+ height = image->width;
-+ }
- opaque_surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
-- image->width,
-- image->height);
-+ width,
-+ height);
- if (opaque_surface->status) {
- status = opaque_surface->status;
- goto CLEANUP_OPAQUE_IMAGE;
- }
-
-- _cairo_pattern_init_solid (&background_pattern,
-- background_color);
-- status = _cairo_surface_paint (opaque_surface,
-- CAIRO_OPERATOR_SOURCE,
-- &background_pattern.base,
-- NULL);
-- if (status)
-- goto CLEANUP_OPAQUE_IMAGE;
-+ if (image->format != CAIRO_FORMAT_RGB24) {
-+ _cairo_pattern_init_solid (&background_pattern,
-+ background_color);
-+ status = _cairo_surface_paint (opaque_surface,
-+ CAIRO_OPERATOR_SOURCE,
-+ &background_pattern.base,
-+ NULL);
-+ if (status)
-+ goto CLEANUP_OPAQUE_IMAGE;
-+ }
-
- _cairo_pattern_init_for_surface (&image_pattern, &image->base);
-+ if (axis_swap) {
-+ /* swap the X and Y axes to undo the axis swap in the matrix */
-+ cairo_matrix_t swap_xy = { 0, 1, 1, 0, 0, 0 };
-+ cairo_pattern_set_matrix (&image_pattern.base, &swap_xy);
-+ cairo_matrix_multiply (&m, &swap_xy, &m);
-+ }
- status = _cairo_surface_paint (opaque_surface,
- CAIRO_OPERATOR_OVER,
- &image_pattern.base,
- NULL);
- _cairo_pattern_fini (&image_pattern.base);
- if (status)
- goto CLEANUP_OPAQUE_IMAGE;
-
-@@ -706,23 +733,16 @@ static cairo_status_t
- bi.bmiHeader.biXPelsPerMeter = PELS_72DPI;
- bi.bmiHeader.biYPelsPerMeter = PELS_72DPI;
- bi.bmiHeader.biPlanes = 1;
- bi.bmiHeader.biBitCount = 32;
- bi.bmiHeader.biCompression = use_mime ? mime_type : BI_RGB;
- bi.bmiHeader.biClrUsed = 0;
- bi.bmiHeader.biClrImportant = 0;
-
-- m = pattern->base.matrix;
-- status = cairo_matrix_invert (&m);
-- /* _cairo_pattern_set_matrix guarantees invertibility */
-- assert (status == CAIRO_STATUS_SUCCESS);
--
-- cairo_matrix_multiply (&m, &m, &surface->gdi_ctm);
-- cairo_matrix_multiply(&m, &m, &surface->ctm);
- SaveDC (surface->dc);
- _cairo_matrix_to_win32_xform (&m, &xform);
-
- if (! SetWorldTransform (surface->dc, &xform)) {
- status = _cairo_win32_print_gdi_error ("_cairo_win32_printing_surface_paint_image_pattern");
- goto CLEANUP_OPAQUE_IMAGE;
- }
-
-@@ -1260,16 +1280,17 @@ static cairo_int_status_t
- DWORD pen_width;
- DWORD *dash_array;
- HGDIOBJ obj;
- unsigned int i;
- cairo_solid_pattern_t clear;
- cairo_matrix_t mat;
- double scale;
- double scaled_width;
-+ double major, minor;
-
- status = _cairo_surface_clipper_set_clip (&surface->clipper, clip);
- if (status)
- return status;
-
- if (op == CAIRO_OPERATOR_CLEAR) {
- _cairo_win32_printing_surface_init_clear_color (surface, &clear);
- source = (cairo_pattern_t*) &clear;
-@@ -1350,22 +1371,40 @@ static cairo_int_status_t
- if (status)
- return status;
-
- /*
- * Switch to user space to set line parameters
- */
- SaveDC (surface->dc);
-
-- _cairo_matrix_to_win32_xform (&mat, &xform);
-- xform.eDx = 0.0f;
-- xform.eDy = 0.0f;
-+ /* Some printers don't handle transformed strokes. Avoid the transform
-+ * if not required for the pen shape. Use the SVD here to find the major
-+ * and minor scales then check if they differ by more than 1 device unit.
-+ * If the difference is smaller, then just treat the scaling as uniform.
-+ * This check ignores rotations as the pen shape is symmetric before
-+ * transformation.
-+ */
-+ _cairo_matrix_transformed_circle_axes (&mat, scale, &major, &minor);
-+ if (fabs (major - minor) > 1) {
-+ /* Check if the matrix swaps the X and Y axes such that the diagonal
-+ * is nearly zero. This was observed to cause problems with XPS export.
-+ */
-+ if (fabs (mat.xx) < 1e-6 && fabs (mat.yy) < 1e-6) {
-+ /* swap the X and Y axes to undo the axis swap in the matrix */
-+ cairo_matrix_t swap_xy = { 0, 1, 1, 0, 0, 0 };
-+ cairo_matrix_multiply (&mat, &swap_xy, &mat);
-+ }
-+ _cairo_matrix_to_win32_xform (&mat, &xform);
-+ xform.eDx = 0.0f;
-+ xform.eDy = 0.0f;
-
-- if (!ModifyWorldTransform (surface->dc, &xform, MWT_LEFTMULTIPLY))
-- return _cairo_win32_print_gdi_error ("_win32_surface_stroke:SetWorldTransform");
-+ if (!ModifyWorldTransform (surface->dc, &xform, MWT_LEFTMULTIPLY))
-+ return _cairo_win32_print_gdi_error ("_win32_surface_stroke:SetWorldTransform");
-+ }
-
- if (source->type == CAIRO_PATTERN_TYPE_SOLID) {
- StrokePath (surface->dc);
- } else {
- if (!WidenPath (surface->dc))
- return _cairo_win32_print_gdi_error ("_win32_surface_stroke:WidenPath");
- if (!SelectClipPath (surface->dc, RGN_AND))
- return _cairo_win32_print_gdi_error ("_win32_surface_stroke:SelectClipPath");
-diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
---- a/gfx/cairo/cairo/src/cairoint.h
-+++ b/gfx/cairo/cairo/src/cairoint.h
-@@ -2115,16 +2115,22 @@ cairo_private cairo_bool_t
- int *itx, int *ity);
-
- cairo_private cairo_bool_t
- _cairo_matrix_has_unity_scale (const cairo_matrix_t *matrix);
-
- cairo_private cairo_bool_t
- _cairo_matrix_is_pixel_exact (const cairo_matrix_t *matrix) cairo_pure;
-
-+cairo_private void
-+_cairo_matrix_transformed_circle_axes (const cairo_matrix_t *matrix,
-+ double radius,
-+ double *major,
-+ double *minor);
-+
- cairo_private double
- _cairo_matrix_transformed_circle_major_axis (const cairo_matrix_t *matrix,
- double radius) cairo_pure;
-
- cairo_private void
- _cairo_matrix_to_pixman_matrix (const cairo_matrix_t *matrix,
- pixman_transform_t *pixman_transform,
- double xc,
diff --git a/gfx/cairo/win32-raster.patch b/gfx/cairo/win32-raster.patch
deleted file mode 100644
index 080873121..000000000
--- a/gfx/cairo/win32-raster.patch
+++ /dev/null
@@ -1,262 +0,0 @@
-changeset: 29338:f2a10f325734
-tag: qtip
-tag: tip
-tag: win32-raster-mask2.patch
-tag: qbase
-user: Jeff Muizelaar <jmuizelaar@mozilla.com>
-date: Mon Jun 22 14:26:07 2009 -0400
-summary: imported patch win32-raster-mask2.patch
-
-diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c
---- a/gfx/cairo/cairo/src/cairo-image-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-image-surface.c
-@@ -1232,27 +1232,27 @@ typedef struct _cairo_image_surface_span
- cairo_composite_rectangles_t composite_rectangles;
- } cairo_image_surface_span_renderer_t;
-
--static cairo_status_t
--_cairo_image_surface_span_renderer_render_row (
-- void *abstract_renderer,
-+void
-+_cairo_image_surface_span_render_row (
- int y,
- const cairo_half_open_span_t *spans,
-- unsigned num_spans)
-+ unsigned num_spans,
-+ cairo_image_surface_t *mask,
-+ const cairo_composite_rectangles_t *rects)
- {
-- cairo_image_surface_span_renderer_t *renderer = abstract_renderer;
-- int xmin = renderer->composite_rectangles.mask.x;
-- int xmax = xmin + renderer->composite_rectangles.width;
-+ int xmin = rects->mask.x;
-+ int xmax = xmin + rects->width;
- uint8_t *row;
- int prev_x = xmin;
- int prev_alpha = 0;
- unsigned i;
-
- /* Make sure we're within y-range. */
-- y -= renderer->composite_rectangles.mask.y;
-- if (y < 0 || y >= renderer->composite_rectangles.height)
-+ y -= rects->mask.y;
-+ if (y < 0 || y >= rects->height)
- return CAIRO_STATUS_SUCCESS;
-
-- row = (uint8_t*)(renderer->mask->data) + y*(size_t)renderer->mask->stride - xmin;
-+ row = (uint8_t*)(mask->data) + y*(size_t)mask->stride - xmin;
-
- /* Find the first span within x-range. */
- for (i=0; i < num_spans && spans[i].x < xmin; i++) {}
-@@ -1286,7 +1286,17 @@ _cairo_image_surface_span_renderer_rende
- if (prev_alpha != 0 && prev_x < xmax) {
- memset(row + prev_x, prev_alpha, xmax - prev_x);
- }
-+}
-
-+static cairo_status_t
-+_cairo_image_surface_span_renderer_render_row (
-+ void *abstract_renderer,
-+ int y,
-+ const cairo_half_open_span_t *spans,
-+ unsigned num_spans)
-+{
-+ cairo_image_surface_span_renderer_t *renderer = abstract_renderer;
-+ _cairo_image_surface_span_render_row (y, spans, num_spans, renderer->mask, &renderer->composite_rectangles);
- return CAIRO_STATUS_SUCCESS;
- }
-
-diff --git a/gfx/cairo/cairo/src/cairo-tor-scan-converter.c b/gfx/cairo/cairo/src/cairo-tor-scan-converter.c
---- a/gfx/cairo/cairo/src/cairo-tor-scan-converter.c
-+++ b/gfx/cairo/cairo/src/cairo-tor-scan-converter.c
-@@ -295,9 +295,9 @@ typedef int grid_area_t;
- #elif GRID_XY == 15
- # define GRID_AREA_TO_ALPHA(c) (((c) << 4) + (c))
- #elif GRID_XY == 2*256*15
--# define GRID_AREA_TO_ALPHA(c) (((c) + ((c)<<4)) >> 9)
-+# define GRID_AREA_TO_ALPHA(c) (((c) + ((c)<<4) + 256) >> 9)
- #else
--# define GRID_AREA_TO_ALPHA(c) ((c)*255 / GRID_XY) /* tweak me for rounding */
-+# define GRID_AREA_TO_ALPHA(c) (((c)*255 + GRID_XY/2) / GRID_XY)
- #endif
-
- #define UNROLL3(x) x x x
-diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
-@@ -2048,6 +2048,148 @@ _cairo_win32_surface_reset (void *abstra
- return CAIRO_STATUS_SUCCESS;
- }
-
-+typedef struct _cairo_win32_surface_span_renderer {
-+ cairo_span_renderer_t base;
-+
-+ cairo_operator_t op;
-+ const cairo_pattern_t *pattern;
-+ cairo_antialias_t antialias;
-+
-+ cairo_image_surface_t *mask;
-+ cairo_win32_surface_t *dst;
-+
-+ cairo_composite_rectangles_t composite_rectangles;
-+} cairo_win32_surface_span_renderer_t;
-+
-+static cairo_status_t
-+_cairo_win32_surface_span_renderer_render_row (
-+ void *abstract_renderer,
-+ int y,
-+ const cairo_half_open_span_t *spans,
-+ unsigned num_spans)
-+{
-+ cairo_win32_surface_span_renderer_t *renderer = abstract_renderer;
-+ _cairo_image_surface_span_render_row (y, spans, num_spans, renderer->mask, &renderer->composite_rectangles);
-+ return CAIRO_STATUS_SUCCESS;
-+}
-+
-+static void
-+_cairo_win32_surface_span_renderer_destroy (void *abstract_renderer)
-+{
-+ cairo_win32_surface_span_renderer_t *renderer = abstract_renderer;
-+ if (!renderer) return;
-+
-+ if (renderer->mask != NULL)
-+ cairo_surface_destroy (&renderer->mask->base);
-+
-+ free (renderer);
-+}
-+
-+static cairo_status_t
-+_cairo_win32_surface_span_renderer_finish (void *abstract_renderer)
-+{
-+ cairo_win32_surface_span_renderer_t *renderer = abstract_renderer;
-+ cairo_status_t status = CAIRO_STATUS_SUCCESS;
-+
-+ if (renderer->pattern == NULL || renderer->mask == NULL)
-+ return CAIRO_STATUS_SUCCESS;
-+
-+ status = cairo_surface_status (&renderer->mask->base);
-+ if (status == CAIRO_STATUS_SUCCESS) {
-+ cairo_composite_rectangles_t *rects = &renderer->composite_rectangles;
-+ cairo_win32_surface_t *dst = renderer->dst;
-+ cairo_pattern_t *mask_pattern = cairo_pattern_create_for_surface (&renderer->mask->base);
-+ /* composite onto the image surface directly if we can */
-+ if (dst->image) {
-+ GdiFlush();
-+
-+ status = dst->image->backend->composite (renderer->op,
-+ renderer->pattern, mask_pattern, dst->image,
-+ rects->src.x,
-+ rects->src.y,
-+ 0, 0, /* mask.x, mask.y */
-+ rects->dst.x, rects->dst.y,
-+ rects->width, rects->height);
-+ } else {
-+ /* otherwise go through the fallback_composite path which
-+ * will do the appropriate surface acquisition */
-+ status = _cairo_surface_fallback_composite (
-+ renderer->op,
-+ renderer->pattern, mask_pattern, dst,
-+ rects->src.x,
-+ rects->src.y,
-+ 0, 0, /* mask.x, mask.y */
-+ rects->dst.x, rects->dst.y,
-+ rects->width, rects->height);
-+ }
-+ cairo_pattern_destroy (mask_pattern);
-+
-+ }
-+ if (status != CAIRO_STATUS_SUCCESS)
-+ return _cairo_span_renderer_set_error (abstract_renderer,
-+ status);
-+ return CAIRO_STATUS_SUCCESS;
-+}
-+
-+static cairo_bool_t
-+_cairo_win32_surface_check_span_renderer (cairo_operator_t op,
-+ const cairo_pattern_t *pattern,
-+ void *abstract_dst,
-+ cairo_antialias_t antialias,
-+ const cairo_composite_rectangles_t *rects)
-+{
-+ (void) op;
-+ (void) pattern;
-+ (void) abstract_dst;
-+ (void) antialias;
-+ (void) rects;
-+ return TRUE;
-+}
-+
-+static cairo_span_renderer_t *
-+_cairo_win32_surface_create_span_renderer (cairo_operator_t op,
-+ const cairo_pattern_t *pattern,
-+ void *abstract_dst,
-+ cairo_antialias_t antialias,
-+ const cairo_composite_rectangles_t *rects)
-+{
-+ cairo_win32_surface_t *dst = abstract_dst;
-+ cairo_win32_surface_span_renderer_t *renderer
-+ = calloc(1, sizeof(*renderer));
-+ cairo_status_t status;
-+ int width = rects->width;
-+ int height = rects->height;
-+
-+ if (renderer == NULL)
-+ return _cairo_span_renderer_create_in_error (CAIRO_STATUS_NO_MEMORY);
-+
-+ renderer->base.destroy = _cairo_win32_surface_span_renderer_destroy;
-+ renderer->base.finish = _cairo_win32_surface_span_renderer_finish;
-+ renderer->base.render_row =
-+ _cairo_win32_surface_span_renderer_render_row;
-+ renderer->op = op;
-+ renderer->pattern = pattern;
-+ renderer->antialias = antialias;
-+ renderer->dst = dst;
-+
-+ renderer->composite_rectangles = *rects;
-+
-+ /* TODO: support rendering to A1 surfaces (or: go add span
-+ * compositing to pixman.) */
-+ renderer->mask = (cairo_image_surface_t *)
-+ cairo_image_surface_create (CAIRO_FORMAT_A8,
-+ width, height);
-+
-+ status = cairo_surface_status (&renderer->mask->base);
-+
-+ if (status != CAIRO_STATUS_SUCCESS) {
-+ _cairo_win32_surface_span_renderer_destroy (renderer);
-+ return _cairo_span_renderer_create_in_error (status);
-+ }
-+ return &renderer->base;
-+}
-+
-+
- static const cairo_surface_backend_t cairo_win32_surface_backend = {
- CAIRO_SURFACE_TYPE_WIN32,
- _cairo_win32_surface_create_similar,
-@@ -2060,8 +2202,8 @@ static const cairo_surface_backend_t cai
- _cairo_win32_surface_composite,
- _cairo_win32_surface_fill_rectangles,
- NULL, /* composite_trapezoids */
-- NULL, /* create_span_renderer */
-- NULL, /* check_span_renderer */
-+ _cairo_win32_surface_create_span_renderer,
-+ _cairo_win32_surface_check_span_renderer,
- NULL, /* copy_page */
- NULL, /* show_page */
- _cairo_win32_surface_set_clip_region,
-diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
---- a/gfx/cairo/cairo/src/cairoint.h
-+++ b/gfx/cairo/cairo/src/cairoint.h
-@@ -2193,6 +2193,12 @@ _cairo_image_surface_set_clip_region (vo
- cairo_private cairo_image_surface_t *
- _cairo_image_surface_coerce (cairo_image_surface_t *surface,
- cairo_format_t format);
-+cairo_private void
-+_cairo_image_surface_span_render_row (int y,
-+ const cairo_half_open_span_t *spans,
-+ unsigned num_spans,
-+ cairo_image_surface_t *mask,
-+ const cairo_composite_rectangles_t *rects);
-
- cairo_private cairo_image_transparency_t
- _cairo_image_analyze_transparency (cairo_image_surface_t *image);
diff --git a/gfx/cairo/win32-transparent-surface.patch b/gfx/cairo/win32-transparent-surface.patch
deleted file mode 100644
index c8765cf28..000000000
--- a/gfx/cairo/win32-transparent-surface.patch
+++ /dev/null
@@ -1,129 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
-@@ -1709,40 +1709,23 @@ _cairo_win32_surface_show_glyphs (void
- }
- #else
- return CAIRO_INT_STATUS_UNSUPPORTED;
- #endif
- }
-
- #undef STACK_GLYPH_SIZE
-
--/**
-- * cairo_win32_surface_create:
-- * @hdc: the DC to create a surface for
-- *
-- * Creates a cairo surface that targets the given DC. The DC will be
-- * queried for its initial clip extents, and this will be used as the
-- * size of the cairo surface. The resulting surface will always be of
-- * format %CAIRO_FORMAT_RGB24; should you need another surface format,
-- * you will need to create one through
-- * cairo_win32_surface_create_with_dib().
-- *
-- * Return value: the newly created surface
-- **/
--cairo_surface_t *
--cairo_win32_surface_create (HDC hdc)
-+static cairo_surface_t *
-+cairo_win32_surface_create_internal (HDC hdc, cairo_format_t format)
- {
- cairo_win32_surface_t *surface;
-
-- cairo_format_t format;
- RECT rect;
-
-- /* Assume that everything coming in as a HDC is RGB24 */
-- format = CAIRO_FORMAT_RGB24;
--
- surface = malloc (sizeof (cairo_win32_surface_t));
- if (surface == NULL)
- return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
-
- if (_cairo_win32_save_initial_clip (hdc, surface) != CAIRO_STATUS_SUCCESS) {
- free (surface);
- return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
- }
-@@ -1765,17 +1748,58 @@ cairo_win32_surface_create (HDC hdc)
- surface->extents.width = rect.right - rect.left;
- surface->extents.height = rect.bottom - rect.top;
-
- surface->flags = _cairo_win32_flags_for_dc (surface->dc);
-
- _cairo_surface_init (&surface->base, &cairo_win32_surface_backend,
- _cairo_content_from_format (format));
-
-- return (cairo_surface_t *)surface;
-+ return &surface->base;
-+}
-+
-+/**
-+ * cairo_win32_surface_create:
-+ * @hdc: the DC to create a surface for
-+ *
-+ * Creates a cairo surface that targets the given DC. The DC will be
-+ * queried for its initial clip extents, and this will be used as the
-+ * size of the cairo surface. The resulting surface will always be of
-+ * format %CAIRO_FORMAT_RGB24; should you need another surface format,
-+ * you will need to create one through
-+ * cairo_win32_surface_create_with_dib() or call
-+ * cairo_win32_surface_create_with_alpha.
-+ *
-+ * Return value: the newly created surface
-+ **/
-+cairo_surface_t *
-+cairo_win32_surface_create (HDC hdc)
-+{
-+ /* Assume everything comes in as RGB24 */
-+ return cairo_win32_surface_create_internal(hdc, CAIRO_FORMAT_RGB24);
-+}
-+
-+/**
-+ * cairo_win32_surface_create_with_alpha:
-+ * @hdc: the DC to create a surface for
-+ *
-+ * Creates a cairo surface that targets the given DC. The DC will be
-+ * queried for its initial clip extents, and this will be used as the
-+ * size of the cairo surface. The resulting surface will always be of
-+ * format %CAIRO_FORMAT_ARGB32; this format is used when drawing into
-+ * transparent windows.
-+ *
-+ * Return value: the newly created surface
-+ *
-+ * Since: 1.10
-+ **/
-+cairo_surface_t *
-+cairo_win32_surface_create_with_alpha (HDC hdc)
-+{
-+ return cairo_win32_surface_create_internal(hdc, CAIRO_FORMAT_ARGB32);
- }
-
- /**
- * cairo_win32_surface_create_with_dib:
- * @format: format of pixels in the surface to create
- * @width: width of the surface, in pixels
- * @height: height of the surface, in pixels
- *
-diff --git a/gfx/cairo/cairo/src/cairo-win32.h b/gfx/cairo/cairo/src/cairo-win32.h
---- a/gfx/cairo/cairo/src/cairo-win32.h
-+++ b/gfx/cairo/cairo/src/cairo-win32.h
-@@ -44,16 +44,19 @@
- #include <windows.h>
-
- CAIRO_BEGIN_DECLS
-
- cairo_public cairo_surface_t *
- cairo_win32_surface_create (HDC hdc);
-
- cairo_public cairo_surface_t *
-+cairo_win32_surface_create_with_alpha (HDC hdc);
-+
-+cairo_public cairo_surface_t *
- cairo_win32_printing_surface_create (HDC hdc);
-
- cairo_public cairo_surface_t *
- cairo_win32_surface_create_with_ddb (HDC hdc,
- cairo_format_t format,
- int width,
- int height);
-
diff --git a/gfx/cairo/win32-vertically-offset-glyph.patch b/gfx/cairo/win32-vertically-offset-glyph.patch
deleted file mode 100644
index ffdf63b4a..000000000
--- a/gfx/cairo/win32-vertically-offset-glyph.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
---- a/gfx/cairo/cairo/src/cairo-win32-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
-@@ -1742,17 +1742,18 @@ _cairo_win32_surface_show_glyphs (void
-
- cairo_matrix_transform_point(&device_to_logical,
- &next_user_x, &next_user_y);
-
- next_logical_x = _cairo_lround (next_user_x);
- next_logical_y = _cairo_lround (next_user_y);
-
- dxy_buf[j] = _cairo_lround (next_logical_x - logical_x);
-- dxy_buf[j+1] = _cairo_lround (next_logical_y - logical_y);
-+ dxy_buf[j+1] = _cairo_lround (logical_y - next_logical_y);
-+ /* note that GDI coordinate system is inverted */
-
- logical_x = next_logical_x;
- logical_y = next_logical_y;
- }
- }
-
- /* Using glyph indices for a Type 1 font does not work on a
- * printer DC. The win32 printing surface will convert the the
diff --git a/gfx/cairo/wrap-source_image.patch b/gfx/cairo/wrap-source_image.patch
deleted file mode 100644
index 89da5a08d..000000000
--- a/gfx/cairo/wrap-source_image.patch
+++ /dev/null
@@ -1,105 +0,0 @@
-Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
-diff --git a/src/cairo-surface.c b/src/cairo-surface.c
-index 8278694..12f6242 100644
---- a/src/cairo-surface.c
-+++ b/src/cairo-surface.c
-@@ -1530,6 +1530,70 @@ _cairo_recording_surface_clone_similar (cairo_surface_t *surface,
- return CAIRO_STATUS_SUCCESS;
- }
-
-+struct acquire_source_image_data
-+{
-+ cairo_surface_t *src;
-+ cairo_image_surface_t *image;
-+ void *image_extra;
-+};
-+
-+static void
-+_wrap_release_source_image (void *data)
-+{
-+ struct acquire_source_image_data *acquire_data = data;
-+ _cairo_surface_release_source_image (acquire_data->src,
-+ acquire_data->image,
-+ acquire_data->image_extra);
-+ free(data);
-+}
-+
-+static cairo_status_t
-+_wrap_image (cairo_surface_t *src,
-+ cairo_image_surface_t *image,
-+ void *image_extra,
-+ cairo_image_surface_t **out)
-+{
-+ static cairo_user_data_key_t wrap_image_key;
-+ cairo_image_surface_t *surface;
-+ cairo_status_t status;
-+
-+ struct acquire_source_image_data *data = malloc (sizeof (*data));
-+ if (unlikely (data == NULL))
-+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-+ data->src = src;
-+ data->image = image;
-+ data->image_extra = image_extra;
-+
-+ surface = (cairo_image_surface_t *)
-+ _cairo_image_surface_create_with_pixman_format (image->data,
-+ image->pixman_format,
-+ image->width,
-+ image->height,
-+ image->stride);
-+ status = surface->base.status;
-+ if (status) {
-+ free (data);
-+ return status;
-+ }
-+
-+ status = _cairo_user_data_array_set_data (&surface->base.user_data,
-+ &wrap_image_key,
-+ data,
-+ _wrap_release_source_image);
-+ if (status) {
-+ cairo_surface_destroy (&surface->base);
-+ free (data);
-+ return status;
-+ }
-+
-+ pixman_image_set_component_alpha (
-+ surface->pixman_image,
-+ pixman_image_get_component_alpha (surface->pixman_image));
-+
-+ *out = surface;
-+ return CAIRO_STATUS_SUCCESS;
-+}
-+
- /**
- * _cairo_surface_clone_similar:
- * @surface: a #cairo_surface_t
-@@ -1606,15 +1670,19 @@ _cairo_surface_clone_similar (cairo_surface_t *surface,
- /* If we failed, try again with an image surface */
- status = _cairo_surface_acquire_source_image (src, &image, &image_extra);
- if (status == CAIRO_STATUS_SUCCESS) {
-- status =
-- surface->backend->clone_similar (surface, &image->base,
-- src_x, src_y,
-- width, height,
-- clone_offset_x,
-- clone_offset_y,
-- clone_out);
--
-- _cairo_surface_release_source_image (src, image, image_extra);
-+ status = _wrap_image(src, image, image_extra, &image);
-+ if (status != CAIRO_STATUS_SUCCESS) {
-+ _cairo_surface_release_source_image (src, image, image_extra);
-+ } else {
-+ status =
-+ surface->backend->clone_similar (surface, &image->base,
-+ src_x, src_y,
-+ width, height,
-+ clone_offset_x,
-+ clone_offset_y,
-+ clone_out);
-+ cairo_surface_destroy(&image->base);
-+ }
- }
- }
- }
diff --git a/gfx/cairo/xlib-flush-glyphs.patch b/gfx/cairo/xlib-flush-glyphs.patch
deleted file mode 100644
index 78a19d0dd..000000000
--- a/gfx/cairo/xlib-flush-glyphs.patch
+++ /dev/null
@@ -1,66 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-xlib-surface.c b/gfx/cairo/cairo/src/cairo-xlib-surface.c
-index f0de3c7..e24c962 100644
---- a/gfx/cairo/cairo/src/cairo-xlib-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c
-@@ -50,35 +50,36 @@
- #include "cairo-xlib-private.h"
- #include "cairo-xlib-surface-private.h"
- #include "cairo-clip-private.h"
- #include "cairo-error-private.h"
- #include "cairo-scaled-font-private.h"
- #include "cairo-surface-snapshot-private.h"
- #include "cairo-surface-subsurface-private.h"
- #include "cairo-region-private.h"
-+#include "cairo-xlib-xrender-private.h"
-
- #include <X11/Xutil.h> /* for XDestroyImage */
-+#include <X11/Xlibint.h> /* for access to XDisplay's innards */
-
- #define XLIB_COORD_MAX 32767
-
- #define DEBUG 0
-
- #if DEBUG
- #define UNSUPPORTED(reason) \
- fprintf (stderr, \
- "cairo-xlib: hit unsupported operation %s(), line %d: %s\n", \
- __FUNCTION__, __LINE__, reason), \
- CAIRO_INT_STATUS_UNSUPPORTED
- #else
- #define UNSUPPORTED(reason) CAIRO_INT_STATUS_UNSUPPORTED
- #endif
-
- #if DEBUG
--#include <X11/Xlibint.h>
- static void CAIRO_PRINTF_FORMAT (2, 3)
- _x_bread_crumb (Display *dpy,
- const char *fmt,
- ...)
- {
- xReq *req;
- char buf[2048];
- unsigned int len, len_dwords;
-@@ -4313,16 +4314,23 @@ _cairo_xlib_surface_add_glyph (cairo_xlib_display_t *display,
- }
- break;
- default:
- ASSERT_NOT_REACHED;
- break;
- }
- /* XXX assume X server wants pixman padding. Xft assumes this as well */
-
-+ struct _XDisplay *dpy = (struct _XDisplay *) display->display;
-+ int req_length = sz_xRenderAddGlyphsReq + 4;
-+ if (req_length & 3)
-+ req_length += 4 - (req_length & 3);
-+ if (dpy->bufptr + req_length > dpy->bufmax)
-+ XFlush (display->display);
-+
- XRenderAddGlyphs (display->display, glyphset_info->glyphset,
- &glyph_index, &glyph_info, 1,
- (char *) data,
- glyph_surface->stride * glyph_surface->height);
-
- if (data != glyph_surface->data)
- free (data);
-
diff --git a/gfx/cairo/xlib-glyph-clip-region.patch b/gfx/cairo/xlib-glyph-clip-region.patch
deleted file mode 100644
index 50ff7f951..000000000
--- a/gfx/cairo/xlib-glyph-clip-region.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-diff --git a/gfx/cairo/cairo/src/cairo-xlib-surface.c b/gfx/cairo/cairo/src/cairo-xlib-surface.c
---- a/gfx/cairo/cairo/src/cairo-xlib-surface.c
-+++ b/gfx/cairo/cairo/src/cairo-xlib-surface.c
-@@ -4806,30 +4806,30 @@ static cairo_int_status_t
- }
-
- X_DEBUG ((display->display, "show_glyphs (dst=%x)", (unsigned int) dst->drawable));
-
- if (clip_region != NULL &&
- cairo_region_num_rectangles (clip_region) == 1)
- {
- cairo_rectangle_int_t glyph_extents;
-- const cairo_rectangle_int_t *clip_extents;
-+ cairo_rectangle_int_t clip_extents;
-
- /* Can we do without the clip?
- * Around 50% of the time the clip is redundant (firefox).
- */
- _cairo_scaled_font_glyph_approximate_extents (scaled_font,
- glyphs, num_glyphs,
- &glyph_extents);
-
-- clip_extents = &clip->path->extents;
-- if (clip_extents->x <= glyph_extents.x &&
-- clip_extents->y <= glyph_extents.y &&
-- clip_extents->x + clip_extents->width >= glyph_extents.x + glyph_extents.width &&
-- clip_extents->y + clip_extents->height >= glyph_extents.y + glyph_extents.height)
-+ cairo_region_get_extents(clip_region, &clip_extents);
-+ if (clip_extents.x <= glyph_extents.x &&
-+ clip_extents.y <= glyph_extents.y &&
-+ clip_extents.x + clip_extents.width >= glyph_extents.x + glyph_extents.width &&
-+ clip_extents.y + clip_extents.height >= glyph_extents.y + glyph_extents.height)
- {
- clip_region = NULL;
- }
- }
-
- status = _cairo_xlib_surface_set_clip_region (dst, clip_region);
- if (unlikely (status))
- goto BAIL0;
diff --git a/gfx/cairo/xlib-initialize-members.patch b/gfx/cairo/xlib-initialize-members.patch
deleted file mode 100644
index 0066ceb34..000000000
--- a/gfx/cairo/xlib-initialize-members.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-diff -r 059e9961a122 gfx/cairo/cairo/src/cairo-xlib-display.c
---- a/gfx/cairo/cairo/src/cairo-xlib-display.c Thu Feb 25 03:59:05 2010 -0800
-+++ b/gfx/cairo/cairo/src/cairo-xlib-display.c Fri Feb 26 16:15:29 2010 +0100
-@@ -259,7 +259,14 @@
- * add our hook. For now, that means Render, so we call into its
- * QueryVersion function to ensure it gets initialized.
- */
-- XRenderQueryVersion (dpy, &render_major, &render_minor);
-+ Status s = XRenderQueryVersion (dpy, &render_major, &render_minor);
-+ if (s == 0) {
-+ /* XRenderQueryVersion failed, possibly because the server
-+ * doesn't have the RENDER extension. Don't leave the version
-+ * numbers uninitialised. See #548793.
-+ */
-+ render_major = render_minor = 0;
-+ }
-
- codes = XAddExtension (dpy);
- if (unlikely (codes == NULL)) {
diff --git a/gfx/cairo/zero-sized.patch b/gfx/cairo/zero-sized.patch
deleted file mode 100644
index bdd6ca798..000000000
--- a/gfx/cairo/zero-sized.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
-index e9e544d..cde68a1 100644
---- a/src/cairo-image-surface.c
-+++ b/src/cairo-image-surface.c
-@@ -324,8 +324,8 @@ _cairo_image_surface_create_with_pixman_format (unsigned char *data,
- cairo_surface_t *surface;
- pixman_image_t *pixman_image;
-
-- pixman_image = pixman_image_create_bits (pixman_format, width, height,
-- (uint32_t *) data, stride);
-+ pixman_image = pixman_image_create_bits (pixman_format, width ? width : 1, height ? height : 1,
-+ (uint32_t *) data, stride ? stride : 4);
-
- if (unlikely (pixman_image == NULL))
- return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
-diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
-index f86a133..ddcb600 100644
---- a/src/cairo-xlib-surface.c
-+++ b/src/cairo-xlib-surface.c
-@@ -675,7 +675,8 @@ _get_image_surface (cairo_xlib_surface_t *surface,
-
- pixmap = XCreatePixmap (surface->dpy,
- surface->drawable,
-- extents.width, extents.height,
-+ extents.width <= 0 ? 1 : extents.width,
-+ extents.height <= 0 ? 1 : extents.height,
- surface->depth);
- if (pixmap) {
- XCopyArea (surface->dpy, surface->drawable, pixmap, surface->gc,
-@@ -686,7 +687,8 @@ _get_image_surface (cairo_xlib_surface_t *surface,
- ximage = XGetImage (surface->dpy,
- pixmap,
- 0, 0,
-- extents.width, extents.height,
-+ extents.width <= 0 ? 1 : extents.width,
-+ extents.height <= 0 ? 1 : extents.height,
- AllPlanes, ZPixmap);
-
- XFreePixmap (surface->dpy, pixmap);
diff --git a/gfx/cairo/zombie-face.patch b/gfx/cairo/zombie-face.patch
deleted file mode 100644
index a4175fecc..000000000
--- a/gfx/cairo/zombie-face.patch
+++ /dev/null
@@ -1,119 +0,0 @@
-From 0238fe2cafea2e1ed19bb222117bd73ee6898d4d Mon Sep 17 00:00:00 2001
-From: Karl Tomlinson <karlt+@karlt.net>
-Date: Thu, 14 May 2009 10:46:29 +0000
-Subject: [ft] Resolve mutual referencing problems with zombie faces
-
-Bug 21706 -- zombie ft_font_face / ft_unscaled_font mutual
- referencing problems
-[http://bugs.freedesktop.org/show_bug.cgi?id=21706]
-
-There can be more than one zombie font_face belonging to an unscaled_font,
-but only the first is destroyed. This leaks the client's FT_Face
-(and associated font data) as release of the FT_Face depends on release
-of the font_face.
-
-(The reason why Firefox ends up with two different font_faces for one
-unscaled_font is that load_flags for faces with artificial oblique have
-FT_LOAD_NO_BITMAP set.
-https://bugzilla.mozilla.org/show_bug.cgi?id=486974)
-
-Also it's possible for _cairo_ft_font_face_create to pull out a zombie
-font_face from the unscaled_font, which would crash
-_cairo_ft_font_face_scaled_font_create, as that expects non-null
-font_face->unscaled (if !font-face->pattern).
----
-diff --git a/AUTHORS b/AUTHORS
-index 289fecb..8c06174 100644
---- a/AUTHORS
-+++ b/AUTHORS
-@@ -86,7 +86,7 @@ Travis Spencer <tspencer@cs.pdx.edu> XCB backend fix
- Bill Spitzak <spitzak@d2.com> Build fix to find Xrender.h without xrender.pc
- Zhe Su <james.su@gmail.com> Add support for fontconfig's embeddedbitmap option
- Owen Taylor <otaylor@redhat.com> Font rewrite, documentation, win32 backend
--Karl Tomlinson <karlt+@karlt.net>
-+Karl Tomlinson <karlt+@karlt.net> Optimisation and obscure bug fixes (mozilla)
- Alp Toker <alp@atoker.com> Fix several code/comment typos
- Malcolm Tredinnick <malcolm@commsecure.com.au> Documentation fixes
- David Turner <david@freetype.org> Optimize gradient calculations
-diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
-index 1e2a18e..f9ff0b1 100644
---- a/src/cairo-ft-font.c
-+++ b/src/cairo-ft-font.c
-@@ -543,8 +543,10 @@ _cairo_ft_unscaled_font_destroy (void *abstract_font)
- /* See comments in _ft_font_face_destroy about the "zombie" state
- * for a _ft_font_face.
- */
-- if (unscaled->faces && !unscaled->faces->unscaled)
-+ if (unscaled->faces && unscaled->faces->unscaled == NULL) {
-+ assert (unscaled->faces->next == NULL);
- cairo_font_face_destroy (&unscaled->faces->base);
-+ }
- } else {
- _font_map_release_face_lock_held (font_map, unscaled);
- }
-@@ -2233,9 +2235,10 @@ _cairo_ft_font_face_destroy (void *abstract_face)
- if (font_face == NULL)
- return;
-
-- /* When destroying the face created by cairo_ft_font_face_create_for_ft_face,
-+ /* When destroying a face created by cairo_ft_font_face_create_for_ft_face,
- * we have a special "zombie" state for the face when the unscaled font
-- * is still alive but there are no public references to the font face.
-+ * is still alive but there are no other references to a font face with
-+ * the same FT_Face.
- *
- * We go from:
- *
-@@ -2249,6 +2252,8 @@ _cairo_ft_font_face_destroy (void *abstract_face)
-
- if (font_face->unscaled &&
- font_face->unscaled->from_face &&
-+ font_face->next == NULL &&
-+ font_face->unscaled->faces == font_face &&
- CAIRO_REFERENCE_COUNT_GET_VALUE (&font_face->unscaled->base.ref_count) > 1)
- {
- cairo_font_face_reference (&font_face->base);
-@@ -2394,12 +2399,21 @@ _cairo_ft_font_face_create (cairo_ft_unscaled_font_t *unscaled,
- font_face->ft_options.extra_flags == ft_options->extra_flags &&
- cairo_font_options_equal (&font_face->ft_options.base, &ft_options->base))
- {
-- if (font_face->base.status == CAIRO_STATUS_SUCCESS)
-- return cairo_font_face_reference (&font_face->base);
-+ if (font_face->base.status) {
-+ /* The font_face has been left in an error state, abandon it. */
-+ *prev_font_face = font_face->next;
-+ break;
-+ }
-
-- /* The font_face has been left in an error state, abandon it. */
-- *prev_font_face = font_face->next;
-- break;
-+ if (font_face->unscaled == NULL) {
-+ /* Resurrect this "zombie" font_face (from
-+ * _cairo_ft_font_face_destroy), switching its unscaled_font
-+ * from owner to ownee. */
-+ font_face->unscaled = unscaled;
-+ _cairo_unscaled_font_reference (&unscaled->base);
-+ return &font_face->base;
-+ } else
-+ return cairo_font_face_reference (&font_face->base);
- }
- }
-
-@@ -2415,6 +2429,14 @@ _cairo_ft_font_face_create (cairo_ft_unscaled_font_t *unscaled,
-
- font_face->ft_options = *ft_options;
-
-+ if (unscaled->faces && unscaled->faces->unscaled == NULL) {
-+ /* This "zombie" font_face (from _cairo_ft_font_face_destroy)
-+ * is no longer needed. */
-+ assert (unscaled->from_face && unscaled->faces->next == NULL);
-+ cairo_font_face_destroy (&unscaled->faces->base);
-+ unscaled->faces = NULL;
-+ }
-+
- font_face->next = unscaled->faces;
- unscaled->faces = font_face;
-
---
-cgit v0.8.2
diff --git a/gfx/ots/LICENSE b/gfx/ots/LICENSE
index a7531cf7c..d5e3bff5a 100644
--- a/gfx/ots/LICENSE
+++ b/gfx/ots/LICENSE
@@ -1,27 +1,27 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/gfx/ots/README.mozilla b/gfx/ots/README.mozilla
index b96826735..0353a99c5 100644
--- a/gfx/ots/README.mozilla
+++ b/gfx/ots/README.mozilla
@@ -2,10 +2,11 @@ This is the Sanitiser for OpenType project, from http://code.google.com/p/ots/.
Our reference repository is https://github.com/khaledhosny/ots/.
-Current revision: ba8417620956a920ed1f05a2f666fb6317fb10cb
+Current revision: 8bba749d9d5401726a7d7609ab914fdb5e92bfbe (8.0.0)
-Upstream files included: LICENSE, src/, include/
+Upstream files included: LICENSE, src/, include/, tests/*.cc
Additional files: README.mozilla, src/moz.build
Additional patch: ots-visibility.patch (bug 711079).
+Additional patch: ots-lz4.patch
diff --git a/gfx/ots/include/opentype-sanitiser.h b/gfx/ots/include/opentype-sanitiser.h
index 87d0f3d28..52cbd3aee 100644
--- a/gfx/ots/include/opentype-sanitiser.h
+++ b/gfx/ots/include/opentype-sanitiser.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -35,13 +35,17 @@ typedef int int32_t;
typedef unsigned int uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
-#define ntohl(x) _byteswap_ulong (x)
-#define ntohs(x) _byteswap_ushort (x)
-#define htonl(x) _byteswap_ulong (x)
-#define htons(x) _byteswap_ushort (x)
+#define ots_ntohl(x) _byteswap_ulong (x)
+#define ots_ntohs(x) _byteswap_ushort (x)
+#define ots_htonl(x) _byteswap_ulong (x)
+#define ots_htons(x) _byteswap_ushort (x)
#else
#include <arpa/inet.h>
#include <stdint.h>
+#define ots_ntohl(x) ntohl (x)
+#define ots_ntohs(x) ntohs (x)
+#define ots_htonl(x) htonl (x)
+#define ots_htons(x) htons (x)
#endif
#include <sys/types.h>
@@ -52,7 +56,7 @@ typedef unsigned __int64 uint64_t;
#include <cstring>
#define OTS_TAG(c1,c2,c3,c4) ((uint32_t)((((uint8_t)(c1))<<24)|(((uint8_t)(c2))<<16)|(((uint8_t)(c3))<<8)|((uint8_t)(c4))))
-#define OTS_UNTAG(tag) ((uint8_t)((tag)>>24)), ((uint8_t)((tag)>>16)), ((uint8_t)((tag)>>8)), ((uint8_t)(tag))
+#define OTS_UNTAG(tag) ((char)((tag)>>24)), ((char)((tag)>>16)), ((char)((tag)>>8)), ((char)(tag))
namespace ots {
@@ -80,7 +84,7 @@ class OTSStream {
const size_t l = std::min(length, static_cast<size_t>(4) - chksum_offset);
uint32_t tmp = 0;
std::memcpy(reinterpret_cast<uint8_t *>(&tmp) + chksum_offset, data, l);
- chksum_ += ntohl(tmp);
+ chksum_ += ots_ntohl(tmp);
length -= l;
offset += l;
}
@@ -89,7 +93,7 @@ class OTSStream {
uint32_t tmp;
std::memcpy(&tmp, reinterpret_cast<const uint8_t *>(data) + offset,
sizeof(uint32_t));
- chksum_ += ntohl(tmp);
+ chksum_ += ots_ntohl(tmp);
length -= 4;
offset += 4;
}
@@ -99,7 +103,7 @@ class OTSStream {
uint32_t tmp = 0;
std::memcpy(&tmp,
reinterpret_cast<const uint8_t*>(data) + offset, length);
- chksum_ += ntohl(tmp);
+ chksum_ += ots_ntohl(tmp);
}
return WriteRaw(data, orig_length);
@@ -127,27 +131,27 @@ class OTSStream {
}
bool WriteU16(uint16_t v) {
- v = htons(v);
+ v = ots_htons(v);
return Write(&v, sizeof(v));
}
bool WriteS16(int16_t v) {
- v = htons(v);
+ v = ots_htons(v);
return Write(&v, sizeof(v));
}
bool WriteU24(uint32_t v) {
- v = htonl(v);
+ v = ots_htonl(v);
return Write(reinterpret_cast<uint8_t*>(&v)+1, 3);
}
bool WriteU32(uint32_t v) {
- v = htonl(v);
+ v = ots_htonl(v);
return Write(&v, sizeof(v));
}
bool WriteS32(int32_t v) {
- v = htonl(v);
+ v = ots_htonl(v);
return Write(&v, sizeof(v));
}
@@ -176,7 +180,7 @@ class OTSStream {
enum TableAction {
TABLE_ACTION_DEFAULT, // Use OTS's default action for that table
- TABLE_ACTION_SANITIZE, // Sanitize the table, potentially droping it
+ TABLE_ACTION_SANITIZE, // Sanitize the table, potentially dropping it
TABLE_ACTION_PASSTHRU, // Serialize the table unchanged
TABLE_ACTION_DROP // Drop the table
};
@@ -186,7 +190,7 @@ class OTS_API OTSContext {
OTSContext() {}
virtual ~OTSContext() {}
- // Process a given OpenType file and write out a sanitised version
+ // Process a given OpenType file and write out a sanitized version
// output: a pointer to an object implementing the OTSStream interface. The
// sanitisied output will be written to this. In the even of a failure,
// partial output may have been written.
diff --git a/gfx/ots/include/ots-memory-stream.h b/gfx/ots/include/ots-memory-stream.h
index 579da616f..cd5b089fa 100644
--- a/gfx/ots/include/ots-memory-stream.h
+++ b/gfx/ots/include/ots-memory-stream.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
diff --git a/gfx/ots/ots-lz4.patch b/gfx/ots/ots-lz4.patch
new file mode 100644
index 000000000..4251e72d6
--- /dev/null
+++ b/gfx/ots/ots-lz4.patch
@@ -0,0 +1,74 @@
+diff --git a/gfx/ots/src/glat.cc b/gfx/ots/src/glat.cc
+--- a/gfx/ots/src/glat.cc
++++ b/gfx/ots/src/glat.cc
+@@ -4,9 +4,9 @@
+
+ #include "glat.h"
+
+ #include "gloc.h"
+-#include "lz4.h"
++#include "mozilla/Compression.h"
+ #include <list>
+
+ namespace ots {
+
+@@ -212,16 +212,17 @@ bool OpenTypeGLAT_v3::Parse(const uint8_
+ return DropGraphite("Decompressed size exceeds 30MB: %gMB",
+ decompressed_size / (1024.0 * 1024.0));
+ }
+ std::vector<uint8_t> decompressed(decompressed_size);
+- int ret = LZ4_decompress_safe_partial(
++ size_t outputSize = 0;
++ bool ret = mozilla::Compression::LZ4::decompressPartial(
+ reinterpret_cast<const char*>(data + table.offset()),
+- reinterpret_cast<char*>(decompressed.data()),
+ table.remaining(), // input buffer size (input size + padding)
++ reinterpret_cast<char*>(decompressed.data()),
+ decompressed.size(), // target output size
+- decompressed.size()); // output buffer size
+- if (ret < 0 || unsigned(ret) != decompressed.size()) {
+- return DropGraphite("Decompression failed with error code %d", ret);
++ &outputSize); // return output size
++ if (!ret || outputSize != decompressed.size()) {
++ return DropGraphite("Decompression failed");
+ }
+ return this->Parse(decompressed.data(), decompressed.size(), true);
+ }
+ default:
+diff --git a/gfx/ots/src/silf.cc b/gfx/ots/src/silf.cc
+--- a/gfx/ots/src/silf.cc
++++ b/gfx/ots/src/silf.cc
+@@ -4,9 +4,9 @@
+
+ #include "silf.h"
+
+ #include "name.h"
+-#include "lz4.h"
++#include "mozilla/Compression.h"
+ #include <cmath>
+
+ namespace ots {
+
+@@ -50,16 +50,17 @@ bool OpenTypeSILF::Parse(const uint8_t*
+ return DropGraphite("Decompressed size exceeds 30MB: %gMB",
+ decompressed_size / (1024.0 * 1024.0));
+ }
+ std::vector<uint8_t> decompressed(decompressed_size);
+- int ret = LZ4_decompress_safe_partial(
++ size_t outputSize = 0;
++ bool ret = mozilla::Compression::LZ4::decompressPartial(
+ reinterpret_cast<const char*>(data + table.offset()),
+- reinterpret_cast<char*>(decompressed.data()),
+ table.remaining(), // input buffer size (input size + padding)
++ reinterpret_cast<char*>(decompressed.data()),
+ decompressed.size(), // target output size
+- decompressed.size()); // output buffer size
+- if (ret < 0 || unsigned(ret) != decompressed.size()) {
+- return DropGraphite("Decompression failed with error code %d", ret);
++ &outputSize); // return output size
++ if (!ret || outputSize != decompressed.size()) {
++ return DropGraphite("Decompression failed");
+ }
+ return this->Parse(decompressed.data(), decompressed.size(), true);
+ }
+ default:
diff --git a/gfx/ots/ots-visibility.patch b/gfx/ots/ots-visibility.patch
index aeac81c4d..c1265472b 100644
--- a/gfx/ots/ots-visibility.patch
+++ b/gfx/ots/ots-visibility.patch
@@ -1,10 +1,7 @@
diff --git a/gfx/ots/include/opentype-sanitiser.h b/gfx/ots/include/opentype-sanitiser.h
--- a/gfx/ots/include/opentype-sanitiser.h
+++ b/gfx/ots/include/opentype-sanitiser.h
-@@ -1,15 +1,35 @@
- // Copyright (c) 2009 The Chromium Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
+@@ -4,8 +4,28 @@
#ifndef OPENTYPE_SANITISER_H_
#define OPENTYPE_SANITISER_H_
@@ -33,15 +30,7 @@ diff --git a/gfx/ots/include/opentype-sanitiser.h b/gfx/ots/include/opentype-san
#include <stdlib.h>
typedef signed char int8_t;
typedef unsigned char uint8_t;
- typedef short int16_t;
- typedef unsigned short uint16_t;
- typedef int int32_t;
- typedef unsigned int uint32_t;
-@@ -187,17 +207,17 @@ class OTSStream {
-
- enum TableAction {
- TABLE_ACTION_DEFAULT, // Use OTS's default action for that table
- TABLE_ACTION_SANITIZE, // Sanitize the table, potentially droping it
+@@ -164,9 +184,9 @@ enum TableAction {
TABLE_ACTION_PASSTHRU, // Serialize the table unchanged
TABLE_ACTION_DROP // Drop the table
};
@@ -52,7 +41,3 @@ diff --git a/gfx/ots/include/opentype-sanitiser.h b/gfx/ots/include/opentype-san
OTSContext() {}
virtual ~OTSContext() {}
- // Process a given OpenType file and write out a sanitised version
- // output: a pointer to an object implementing the OTSStream interface. The
- // sanitisied output will be written to this. In the even of a failure,
- // partial output may have been written.
diff --git a/gfx/ots/src/avar.cc b/gfx/ots/src/avar.cc
new file mode 100644
index 000000000..2a431b1c2
--- /dev/null
+++ b/gfx/ots/src/avar.cc
@@ -0,0 +1,109 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "avar.h"
+
+#include "fvar.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeAVAR
+// -----------------------------------------------------------------------------
+
+bool OpenTypeAVAR::Parse(const uint8_t* data, size_t length) {
+ Buffer table(data, length);
+ if (!table.ReadU16(&this->majorVersion) ||
+ !table.ReadU16(&this->minorVersion) ||
+ !table.ReadU16(&this->reserved) ||
+ !table.ReadU16(&this->axisCount)) {
+ return Drop("Failed to read table header");
+ }
+ if (this->majorVersion != 1) {
+ return Drop("Unknown table version");
+ }
+ if (this->minorVersion > 0) {
+ // we only know how to serialize version 1.0
+ Warning("Downgrading minor version to 0");
+ this->minorVersion = 0;
+ }
+ if (this->reserved != 0) {
+ Warning("Expected reserved=0");
+ this->reserved = 0;
+ }
+
+ OpenTypeFVAR* fvar = static_cast<OpenTypeFVAR*>(
+ GetFont()->GetTypedTable(OTS_TAG_FVAR));
+ if (!fvar) {
+ return DropVariations("Required fvar table is missing");
+ }
+ if (axisCount != fvar->AxisCount()) {
+ return Drop("Axis count mismatch");
+ }
+
+ for (size_t i = 0; i < this->axisCount; i++) {
+ this->axisSegmentMaps.emplace_back();
+ uint16_t positionMapCount;
+ if (!table.ReadU16(&positionMapCount)) {
+ return Drop("Failed to read position map count");
+ }
+ int foundRequiredMappings = 0;
+ for (size_t j = 0; j < positionMapCount; j++) {
+ AxisValueMap map;
+ if (!table.ReadS16(&map.fromCoordinate) ||
+ !table.ReadS16(&map.toCoordinate)) {
+ return Drop("Failed to read axis value map");
+ }
+ if (map.fromCoordinate < -0x4000 ||
+ map.fromCoordinate > 0x4000 ||
+ map.toCoordinate < -0x4000 ||
+ map.toCoordinate > 0x4000) {
+ return Drop("Axis value map coordinate out of range");
+ }
+ if (j > 0) {
+ if (map.fromCoordinate <= this->axisSegmentMaps[i].back().fromCoordinate ||
+ map.toCoordinate < this->axisSegmentMaps[i].back().toCoordinate) {
+ return Drop("Axis value map out of order");
+ }
+ }
+ if ((map.fromCoordinate == -0x4000 && map.toCoordinate == -0x4000) ||
+ (map.fromCoordinate == 0 && map.toCoordinate == 0) ||
+ (map.fromCoordinate == 0x4000 && map.toCoordinate == 0x4000)) {
+ ++foundRequiredMappings;
+ }
+ this->axisSegmentMaps[i].push_back(map);
+ }
+ if (positionMapCount > 0 && foundRequiredMappings != 3) {
+ return Drop("A required mapping (for -1, 0 or 1) is missing");
+ }
+ }
+
+ return true;
+}
+
+bool OpenTypeAVAR::Serialize(OTSStream* out) {
+ if (!out->WriteU16(this->majorVersion) ||
+ !out->WriteU16(this->minorVersion) ||
+ !out->WriteU16(this->reserved) ||
+ !out->WriteU16(this->axisCount)) {
+ return Error("Failed to write table");
+ }
+
+ for (size_t i = 0; i < this->axisCount; i++) {
+ const auto& axisValueMap = this->axisSegmentMaps[i];
+ if (!out->WriteU16(axisValueMap.size())) {
+ return Error("Failed to write table");
+ }
+ for (size_t j = 0; j < axisValueMap.size(); j++) {
+ if (!out->WriteS16(axisValueMap[j].fromCoordinate) ||
+ !out->WriteS16(axisValueMap[j].toCoordinate)) {
+ return Error("Failed to write table");
+ }
+ }
+ }
+
+ return true;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/avar.h b/gfx/ots/src/avar.h
new file mode 100644
index 000000000..756651c04
--- /dev/null
+++ b/gfx/ots/src/avar.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_AVAR_H_
+#define OTS_AVAR_H_
+
+#include "ots.h"
+
+#include <vector>
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeAVAR Interface
+// -----------------------------------------------------------------------------
+
+class OpenTypeAVAR : public Table {
+ public:
+ explicit OpenTypeAVAR(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ uint16_t majorVersion;
+ uint16_t minorVersion;
+ uint16_t reserved;
+ uint16_t axisCount;
+
+ struct AxisValueMap {
+ int16_t fromCoordinate;
+ int16_t toCoordinate;
+ };
+
+ std::vector<std::vector<AxisValueMap>> axisSegmentMaps;
+};
+
+} // namespace ots
+
+#endif // OTS_AVAR_H_
diff --git a/gfx/ots/src/cff.cc b/gfx/ots/src/cff.cc
index 23b6dadac..b0affd510 100644
--- a/gfx/ots/src/cff.cc
+++ b/gfx/ots/src/cff.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,7 +9,8 @@
#include <vector>
#include "maxp.h"
-#include "cff_type2_charstring.h"
+#include "cff_charstring.h"
+#include "variations.h"
// CFF - PostScript font program (Compact Font Format) table
// http://www.microsoft.com/typography/otspec/cff.htm
@@ -28,6 +29,7 @@ enum DICT_OPERAND_TYPE {
enum DICT_DATA_TYPE {
DICT_DATA_TOPLEVEL,
DICT_DATA_FDARRAY,
+ DICT_DATA_PRIVATE,
};
enum FONT_FORMAT {
@@ -39,7 +41,9 @@ enum FONT_FORMAT {
// see Appendix. A
const size_t kNStdString = 390;
-bool ReadOffset(ots::Buffer *table, uint8_t off_size, uint32_t *offset) {
+typedef std::pair<uint32_t, DICT_OPERAND_TYPE> Operand;
+
+bool ReadOffset(ots::Buffer &table, uint8_t off_size, uint32_t *offset) {
if (off_size > 4) {
return OTS_FAILURE();
}
@@ -47,7 +51,7 @@ bool ReadOffset(ots::Buffer *table, uint8_t off_size, uint32_t *offset) {
uint32_t tmp32 = 0;
for (unsigned i = 0; i < off_size; ++i) {
uint8_t tmp8 = 0;
- if (!table->ReadU8(&tmp8)) {
+ if (!table.ReadU8(&tmp8)) {
return OTS_FAILURE();
}
tmp32 <<= 8;
@@ -57,39 +61,47 @@ bool ReadOffset(ots::Buffer *table, uint8_t off_size, uint32_t *offset) {
return true;
}
-bool ParseIndex(ots::Buffer *table, ots::CFFIndex *index) {
- index->off_size = 0;
- index->offsets.clear();
+bool ParseIndex(ots::Buffer &table, ots::CFFIndex &index, bool cff2 = false) {
+ index.off_size = 0;
+ index.offsets.clear();
- if (!table->ReadU16(&(index->count))) {
- return OTS_FAILURE();
+ if (cff2) {
+ if (!table.ReadU32(&(index.count))) {
+ return OTS_FAILURE();
+ }
+ } else {
+ uint16_t count;
+ if (!table.ReadU16(&count)) {
+ return OTS_FAILURE();
+ }
+ index.count = count;
}
- if (index->count == 0) {
+
+ if (index.count == 0) {
// An empty INDEX.
- index->offset_to_next = table->offset();
+ index.offset_to_next = table.offset();
return true;
}
- if (!table->ReadU8(&(index->off_size))) {
+ if (!table.ReadU8(&(index.off_size))) {
return OTS_FAILURE();
}
- if ((index->off_size == 0) ||
- (index->off_size > 4)) {
+ if (index.off_size < 1 || index.off_size > 4) {
return OTS_FAILURE();
}
- const size_t array_size = (index->count + 1) * index->off_size;
+ const size_t array_size = (index.count + 1) * index.off_size;
// less than ((64k + 1) * 4), thus does not overflow.
- const size_t object_data_offset = table->offset() + array_size;
+ const size_t object_data_offset = table.offset() + array_size;
// does not overflow too, since offset() <= 1GB.
- if (object_data_offset >= table->length()) {
+ if (object_data_offset >= table.length()) {
return OTS_FAILURE();
}
- for (unsigned i = 0; i <= index->count; ++i) { // '<=' is not a typo.
+ for (unsigned i = 0; i <= index.count; ++i) { // '<=' is not a typo.
uint32_t rel_offset = 0;
- if (!ReadOffset(table, index->off_size, &rel_offset)) {
+ if (!ReadOffset(table, index.off_size, &rel_offset)) {
return OTS_FAILURE();
}
if (rel_offset < 1) {
@@ -99,60 +111,56 @@ bool ParseIndex(ots::Buffer *table, ots::CFFIndex *index) {
return OTS_FAILURE();
}
- if (rel_offset > table->length()) {
+ if (rel_offset > table.length()) {
return OTS_FAILURE();
}
// does not underflow.
- if (object_data_offset > table->length() - (rel_offset - 1)) {
+ if (object_data_offset > table.length() - (rel_offset - 1)) {
return OTS_FAILURE();
}
- index->offsets.push_back(
+ index.offsets.push_back(
object_data_offset + (rel_offset - 1)); // less than length(), 1GB.
}
- for (unsigned i = 1; i < index->offsets.size(); ++i) {
+ for (unsigned i = 1; i < index.offsets.size(); ++i) {
// We allow consecutive identical offsets here for zero-length strings.
// See http://crbug.com/69341 for more details.
- if (index->offsets[i] < index->offsets[i - 1]) {
+ if (index.offsets[i] < index.offsets[i - 1]) {
return OTS_FAILURE();
}
}
- index->offset_to_next = index->offsets.back();
+ index.offset_to_next = index.offsets.back();
return true;
}
bool ParseNameData(
ots::Buffer *table, const ots::CFFIndex &index, std::string* out_name) {
uint8_t name[256] = {0};
- if (index.offsets.size() == 0) { // just in case.
+
+ const size_t length = index.offsets[1] - index.offsets[0];
+ // font names should be no longer than 127 characters.
+ if (length > 127) {
return OTS_FAILURE();
}
- for (unsigned i = 1; i < index.offsets.size(); ++i) {
- const size_t length = index.offsets[i] - index.offsets[i - 1];
- // font names should be no longer than 127 characters.
- if (length > 127) {
- return OTS_FAILURE();
- }
- table->set_offset(index.offsets[i - 1]);
- if (!table->Read(name, length)) {
+ table->set_offset(index.offsets[0]);
+ if (!table->Read(name, length)) {
+ return OTS_FAILURE();
+ }
+
+ for (size_t i = 0; i < length; ++i) {
+ // setting the first byte to NUL is allowed.
+ if (i == 0 && name[i] == 0) continue;
+ // non-ASCII characters are not recommended (except the first character).
+ if (name[i] < 33 || name[i] > 126) {
return OTS_FAILURE();
}
-
- for (size_t j = 0; j < length; ++j) {
- // setting the first byte to NUL is allowed.
- if (j == 0 && name[j] == 0) continue;
- // non-ASCII characters are not recommended (except the first character).
- if (name[j] < 33 || name[j] > 126) {
- return OTS_FAILURE();
- }
- // [, ], ... are not allowed.
- if (std::strchr("[](){}<>/% ", name[j])) {
- return OTS_FAILURE();
- }
+ // [, ], ... are not allowed.
+ if (std::strchr("[](){}<>/% ", name[i])) {
+ return OTS_FAILURE();
}
}
@@ -160,8 +168,7 @@ bool ParseNameData(
return true;
}
-bool CheckOffset(const std::pair<uint32_t, DICT_OPERAND_TYPE>& operand,
- size_t table_length) {
+bool CheckOffset(const Operand& operand, size_t table_length) {
if (operand.second != DICT_OPERAND_INTEGER) {
return OTS_FAILURE();
}
@@ -171,8 +178,7 @@ bool CheckOffset(const std::pair<uint32_t, DICT_OPERAND_TYPE>& operand,
return true;
}
-bool CheckSid(const std::pair<uint32_t, DICT_OPERAND_TYPE>& operand,
- size_t sid_max) {
+bool CheckSid(const Operand& operand, size_t sid_max) {
if (operand.second != DICT_OPERAND_INTEGER) {
return OTS_FAILURE();
}
@@ -182,30 +188,28 @@ bool CheckSid(const std::pair<uint32_t, DICT_OPERAND_TYPE>& operand,
return true;
}
-bool ParseDictDataBcd(
- ots::Buffer *table,
- std::vector<std::pair<uint32_t, DICT_OPERAND_TYPE> > *operands) {
+bool ParseDictDataBcd(ots::Buffer &table, std::vector<Operand> &operands) {
bool read_decimal_point = false;
bool read_e = false;
uint8_t nibble = 0;
size_t count = 0;
while (true) {
- if (!table->ReadU8(&nibble)) {
+ if (!table.ReadU8(&nibble)) {
return OTS_FAILURE();
}
if ((nibble & 0xf0) == 0xf0) {
if ((nibble & 0xf) == 0xf) {
// TODO(yusukes): would be better to store actual double value,
// rather than the dummy integer.
- operands->push_back(std::make_pair(static_cast<uint32_t>(0),
+ operands.push_back(std::make_pair(static_cast<uint32_t>(0),
DICT_OPERAND_REAL));
return true;
}
return OTS_FAILURE();
}
if ((nibble & 0x0f) == 0x0f) {
- operands->push_back(std::make_pair(static_cast<uint32_t>(0),
+ operands.push_back(std::make_pair(static_cast<uint32_t>(0),
DICT_OPERAND_REAL));
return true;
}
@@ -242,18 +246,17 @@ bool ParseDictDataBcd(
}
}
-bool ParseDictDataEscapedOperator(
- ots::Buffer *table,
- std::vector<std::pair<uint32_t, DICT_OPERAND_TYPE> > *operands) {
+bool ParseDictDataEscapedOperator(ots::Buffer &table,
+ std::vector<Operand> &operands) {
uint8_t op = 0;
- if (!table->ReadU8(&op)) {
+ if (!table.ReadU8(&op)) {
return OTS_FAILURE();
}
if ((op <= 14) ||
(op >= 17 && op <= 23) ||
(op >= 30 && op <= 38)) {
- operands->push_back(std::make_pair((12U << 8) + op, DICT_OPERATOR));
+ operands.push_back(std::make_pair((12U << 8) + op, DICT_OPERATOR));
return true;
}
@@ -261,9 +264,8 @@ bool ParseDictDataEscapedOperator(
return OTS_FAILURE();
}
-bool ParseDictDataNumber(
- ots::Buffer *table, uint8_t b0,
- std::vector<std::pair<uint32_t, DICT_OPERAND_TYPE> > *operands) {
+bool ParseDictDataNumber(ots::Buffer &table, uint8_t b0,
+ std::vector<Operand> &operands) {
uint8_t b1 = 0;
uint8_t b2 = 0;
uint8_t b3 = 0;
@@ -271,22 +273,22 @@ bool ParseDictDataNumber(
switch (b0) {
case 28: // shortint
- if (!table->ReadU8(&b1) ||
- !table->ReadU8(&b2)) {
+ if (!table.ReadU8(&b1) ||
+ !table.ReadU8(&b2)) {
return OTS_FAILURE();
}
- operands->push_back(std::make_pair(
+ operands.push_back(std::make_pair(
static_cast<uint32_t>((b1 << 8) + b2), DICT_OPERAND_INTEGER));
return true;
case 29: // longint
- if (!table->ReadU8(&b1) ||
- !table->ReadU8(&b2) ||
- !table->ReadU8(&b3) ||
- !table->ReadU8(&b4)) {
+ if (!table.ReadU8(&b1) ||
+ !table.ReadU8(&b2) ||
+ !table.ReadU8(&b3) ||
+ !table.ReadU8(&b4)) {
return OTS_FAILURE();
}
- operands->push_back(std::make_pair(
+ operands.push_back(std::make_pair(
static_cast<uint32_t>((b1 << 24) + (b2 << 16) + (b3 << 8) + b4),
DICT_OPERAND_INTEGER));
return true;
@@ -302,12 +304,12 @@ bool ParseDictDataNumber(
if (b0 >=32 && b0 <=246) {
result = b0 - 139;
} else if (b0 >=247 && b0 <= 250) {
- if (!table->ReadU8(&b1)) {
+ if (!table.ReadU8(&b1)) {
return OTS_FAILURE();
}
result = (b0 - 247) * 256 + b1 + 108;
} else if (b0 >= 251 && b0 <= 254) {
- if (!table->ReadU8(&b1)) {
+ if (!table.ReadU8(&b1)) {
return OTS_FAILURE();
}
result = -(b0 - 251) * 256 + b1 - 108;
@@ -315,22 +317,21 @@ bool ParseDictDataNumber(
return OTS_FAILURE();
}
- operands->push_back(std::make_pair(result, DICT_OPERAND_INTEGER));
+ operands.push_back(std::make_pair(result, DICT_OPERAND_INTEGER));
return true;
}
-bool ParseDictDataReadNext(
- ots::Buffer *table,
- std::vector<std::pair<uint32_t, DICT_OPERAND_TYPE> > *operands) {
+bool ParseDictDataReadNext(ots::Buffer &table,
+ std::vector<Operand> &operands) {
uint8_t op = 0;
- if (!table->ReadU8(&op)) {
+ if (!table.ReadU8(&op)) {
return OTS_FAILURE();
}
- if (op <= 21) {
+ if (op <= 24) {
if (op == 12) {
return ParseDictDataEscapedOperator(table, operands);
}
- operands->push_back(std::make_pair(
+ operands.push_back(std::make_pair(
static_cast<uint32_t>(op), DICT_OPERATOR));
return true;
} else if (op <= 27 || op == 31 || op == 255) {
@@ -341,12 +342,69 @@ bool ParseDictDataReadNext(
return ParseDictDataNumber(table, op, operands);
}
+bool OperandsOverflow(std::vector<Operand>& operands, bool cff2) {
+ // An operator may be preceded by up to a maximum of 48 operands in CFF1 and
+ // 513 operands in CFF2.
+ if ((cff2 && operands.size() > ots::kMaxCFF2ArgumentStack) ||
+ (!cff2 && operands.size() > ots::kMaxCFF1ArgumentStack)) {
+ return true;
+ }
+ return false;
+}
+
+bool ParseDictDataReadOperands(ots::Buffer& dict,
+ std::vector<Operand>& operands,
+ bool cff2) {
+ if (!ParseDictDataReadNext(dict, operands)) {
+ return OTS_FAILURE();
+ }
+ if (operands.empty()) {
+ return OTS_FAILURE();
+ }
+ if (OperandsOverflow(operands, cff2)) {
+ return OTS_FAILURE();
+ }
+ return true;
+}
+
+bool ValidCFF2DictOp(uint32_t op, DICT_DATA_TYPE type) {
+ if (type == DICT_DATA_TOPLEVEL) {
+ switch (op) {
+ case (12U << 8) + 7: // FontMatrix
+ case 17: // CharStrings
+ case (12U << 8) + 36: // FDArray
+ case (12U << 8) + 37: // FDSelect
+ case 24: // vstore
+ return true;
+ default:
+ return false;
+ }
+ } else if (type == DICT_DATA_FDARRAY) {
+ if (op == 18) // Private DICT
+ return true;
+ } else if (type == DICT_DATA_PRIVATE) {
+ switch (op) {
+ case (12U << 8) + 14: // ForceBold
+ case (12U << 8) + 19: // initialRandomSeed
+ case 20: // defaultWidthX
+ case 21: // nominalWidthX
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ return false;
+}
+
bool ParsePrivateDictData(
- const uint8_t *data,
- size_t table_length, size_t offset, size_t dict_length,
+ ots::Buffer &table, size_t offset, size_t dict_length,
DICT_DATA_TYPE type, ots::OpenTypeCFF *out_cff) {
- ots::Buffer table(data + offset, dict_length);
- std::vector<std::pair<uint32_t, DICT_OPERAND_TYPE> > operands;
+ ots::Buffer dict(table.buffer() + offset, dict_length);
+ std::vector<Operand> operands;
+ bool cff2 = (out_cff->major == 2);
+ bool blend_seen = false;
+ uint32_t vsindex = 0;
// Since a Private DICT for FDArray might not have a Local Subr (e.g. Hiragino
// Kaku Gothic Std W8), we create an empty Local Subr here to match the size
@@ -355,15 +413,8 @@ bool ParsePrivateDictData(
out_cff->local_subrs_per_font.push_back(new ots::CFFIndex);
}
- while (table.offset() < dict_length) {
- if (!ParseDictDataReadNext(&table, &operands)) {
- return OTS_FAILURE();
- }
- if (operands.empty()) {
- return OTS_FAILURE();
- }
- if (operands.size() > 48) {
- // An operator may be preceded by up to a maximum of 48 operands.
+ while (dict.offset() < dict.length()) {
+ if (!ParseDictDataReadOperands(dict, operands, cff2)) {
return OTS_FAILURE();
}
if (operands.back().second != DICT_OPERATOR) {
@@ -374,13 +425,18 @@ bool ParsePrivateDictData(
const uint32_t op = operands.back().first;
operands.pop_back();
+ if (cff2 && !ValidCFF2DictOp(op, DICT_DATA_PRIVATE)) {
+ return OTS_FAILURE();
+ }
+
+ bool clear_operands = true;
switch (op) {
// hints
case 6: // BlueValues
case 7: // OtherBlues
case 8: // FamilyBlues
case 9: // FamilyOtherBlues
- if (operands.empty() || (operands.size() % 2) != 0) {
+ if ((operands.size() % 2) != 0) {
return OTS_FAILURE();
}
break;
@@ -420,12 +476,11 @@ bool ParsePrivateDictData(
if (operands.back().first >= 1024 * 1024 * 1024) {
return OTS_FAILURE();
}
- if (operands.back().first + offset >= table_length) {
+ if (operands.back().first + offset >= table.length()) {
return OTS_FAILURE();
}
// parse "16. Local Subrs INDEX"
- ots::Buffer cff_table(data, table_length);
- cff_table.set_offset(operands.back().first + offset);
+ table.set_offset(operands.back().first + offset);
ots::CFFIndex *local_subrs_index = NULL;
if (type == DICT_DATA_FDARRAY) {
if (out_cff->local_subrs_per_font.empty()) {
@@ -439,7 +494,7 @@ bool ParsePrivateDictData(
local_subrs_index = new ots::CFFIndex;
out_cff->local_subrs = local_subrs_index;
}
- if (!ParseIndex(&cff_table, local_subrs_index)) {
+ if (!ParseIndex(table, *local_subrs_index, cff2)) {
return OTS_FAILURE();
}
break;
@@ -458,42 +513,125 @@ bool ParsePrivateDictData(
}
break;
+ case 22: { // vsindex
+ if (!cff2) {
+ return OTS_FAILURE();
+ }
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ if (operands.back().second != DICT_OPERAND_INTEGER) {
+ return OTS_FAILURE();
+ }
+ if (blend_seen) {
+ return OTS_FAILURE();
+ }
+ vsindex = operands.back().first;
+ if (vsindex >= out_cff->region_index_count.size()) {
+ return OTS_FAILURE();
+ }
+ break;
+ }
+
+ case 23: { // blend
+ if (!cff2) {
+ return OTS_FAILURE();
+ }
+ if (operands.size() < 1) {
+ return OTS_FAILURE();
+ }
+ if (vsindex >= out_cff->region_index_count.size()) {
+ return OTS_FAILURE();
+ }
+ uint16_t k = out_cff->region_index_count.at(vsindex);
+ uint16_t n = operands.back().first;
+ if (operands.size() < n * (k + 1) + 1) {
+ return OTS_FAILURE();
+ }
+ size_t operands_size = operands.size();
+ // Keep the 1st n operands on the stack for the next operator to use
+ // and pop the rest. There can be multiple consecutive blend operator,
+ // so this makes sure the operands of all of them are kept on the
+ // stack.
+ while (operands.size() > operands_size - ((n * k) + 1))
+ operands.pop_back();
+ clear_operands = false;
+ blend_seen = true;
+ break;
+ }
+
default:
return OTS_FAILURE();
}
- operands.clear();
+ if (clear_operands) {
+ operands.clear();
+ }
}
return true;
}
-bool ParseDictData(const uint8_t *data, size_t table_length,
- const ots::CFFIndex &index, uint16_t glyphs,
- size_t sid_max, DICT_DATA_TYPE type,
+bool ParseVariationStore(ots::OpenTypeCFF& out_cff, ots::Buffer& table) {
+ uint16_t length;
+
+ if (!table.ReadU16(&length)) {
+ return OTS_FAILURE();
+ }
+
+ // Empty VariationStore is allowed.
+ if (!length) {
+ return true;
+ }
+
+ if (length > table.remaining()) {
+ return OTS_FAILURE();
+ }
+
+ if (!ParseItemVariationStore(out_cff.GetFont(),
+ table.buffer() + table.offset(), length,
+ &(out_cff.region_index_count))) {
+ return OTS_FAILURE();
+ }
+
+ return true;
+}
+
+bool ParseDictData(ots::Buffer& table, ots::Buffer& dict,
+ uint16_t glyphs, size_t sid_max, DICT_DATA_TYPE type,
+ ots::OpenTypeCFF *out_cff);
+
+bool ParseDictData(ots::Buffer& table, const ots::CFFIndex &index,
+ uint16_t glyphs, size_t sid_max, DICT_DATA_TYPE type,
ots::OpenTypeCFF *out_cff) {
for (unsigned i = 1; i < index.offsets.size(); ++i) {
- if (type == DICT_DATA_TOPLEVEL) {
- out_cff->char_strings_array.push_back(new ots::CFFIndex);
- }
size_t dict_length = index.offsets[i] - index.offsets[i - 1];
- ots::Buffer table(data + index.offsets[i - 1], dict_length);
-
- std::vector<std::pair<uint32_t, DICT_OPERAND_TYPE> > operands;
+ ots::Buffer dict(table.buffer() + index.offsets[i - 1], dict_length);
- FONT_FORMAT font_format = FORMAT_UNKNOWN;
- bool have_ros = false;
- uint16_t charstring_glyphs = 0;
- size_t charset_offset = 0;
+ if (!ParseDictData(table, dict, glyphs, sid_max, type, out_cff)) {
+ return OTS_FAILURE();
+ }
+ }
+ return true;
+}
- while (table.offset() < dict_length) {
- if (!ParseDictDataReadNext(&table, &operands)) {
- return OTS_FAILURE();
- }
- if (operands.empty()) {
- return OTS_FAILURE();
- }
- if (operands.size() > 48) {
- // An operator may be preceded by up to a maximum of 48 operands.
+bool ParseDictData(ots::Buffer& table, ots::Buffer& dict,
+ uint16_t glyphs, size_t sid_max, DICT_DATA_TYPE type,
+ ots::OpenTypeCFF *out_cff) {
+ bool cff2 = (out_cff->major == 2);
+ std::vector<Operand> operands;
+
+ FONT_FORMAT font_format = FORMAT_UNKNOWN;
+ bool have_ros = false;
+ bool have_charstrings = false;
+ bool have_vstore = false;
+ size_t charset_offset = 0;
+
+ if (cff2) {
+ // Parse VariationStore first, since it might be referenced in other places
+ // (e.g. FDArray) that might be parsed after it.
+ size_t dict_offset = dict.offset();
+ while (dict.offset() < dict.length()) {
+ if (!ParseDictDataReadOperands(dict, operands, cff2)) {
return OTS_FAILURE();
}
if (operands.back().second != DICT_OPERATOR) continue;
@@ -502,399 +640,503 @@ bool ParseDictData(const uint8_t *data, size_t table_length,
const uint32_t op = operands.back().first;
operands.pop_back();
- switch (op) {
- // SID
- case 0: // version
- case 1: // Notice
- case 2: // Copyright
- case 3: // FullName
- case 4: // FamilyName
- case (12U << 8) + 0: // Copyright
- case (12U << 8) + 21: // PostScript
- case (12U << 8) + 22: // BaseFontName
- case (12U << 8) + 38: // FontName
- if (operands.size() != 1) {
- return OTS_FAILURE();
- }
- if (!CheckSid(operands.back(), sid_max)) {
- return OTS_FAILURE();
- }
- break;
+ if (op == 24) { // vstore
+ if (type != DICT_DATA_TOPLEVEL) {
+ return OTS_FAILURE();
+ }
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ if (!CheckOffset(operands.back(), table.length())) {
+ return OTS_FAILURE();
+ }
+ // parse "VariationStore Data Contents"
+ table.set_offset(operands.back().first);
+ if (!ParseVariationStore(*out_cff, table)) {
+ return OTS_FAILURE();
+ }
+ break;
+ }
+ operands.clear();
+ }
+ operands.clear();
+ dict.set_offset(dict_offset);
+ }
- // array
- case 5: // FontBBox
- case 14: // XUID
- case (12U << 8) + 7: // FontMatrix
- case (12U << 8) + 23: // BaseFontBlend (delta)
- if (operands.empty()) {
- return OTS_FAILURE();
- }
- break;
+ while (dict.offset() < dict.length()) {
+ if (!ParseDictDataReadOperands(dict, operands, cff2)) {
+ return OTS_FAILURE();
+ }
+ if (operands.back().second != DICT_OPERATOR) continue;
- // number
- case 13: // UniqueID
- case (12U << 8) + 2: // ItalicAngle
- case (12U << 8) + 3: // UnderlinePosition
- case (12U << 8) + 4: // UnderlineThickness
- case (12U << 8) + 5: // PaintType
- case (12U << 8) + 8: // StrokeWidth
- case (12U << 8) + 20: // SyntheticBase
- if (operands.size() != 1) {
- return OTS_FAILURE();
- }
- break;
- case (12U << 8) + 31: // CIDFontVersion
- case (12U << 8) + 32: // CIDFontRevision
- case (12U << 8) + 33: // CIDFontType
- case (12U << 8) + 34: // CIDCount
- case (12U << 8) + 35: // UIDBase
- if (operands.size() != 1) {
- return OTS_FAILURE();
- }
- if (font_format != FORMAT_CID_KEYED) {
- return OTS_FAILURE();
- }
- break;
- case (12U << 8) + 6: // CharstringType
- if (operands.size() != 1) {
- return OTS_FAILURE();
- }
- if(operands.back().second != DICT_OPERAND_INTEGER) {
- return OTS_FAILURE();
- }
- if (operands.back().first != 2) {
- // We only support the "Type 2 Charstring Format."
- // TODO(yusukes): Support Type 1 format? Is that still in use?
- return OTS_FAILURE();
- }
- break;
+ // got operator
+ const uint32_t op = operands.back().first;
+ operands.pop_back();
- // boolean
- case (12U << 8) + 1: // isFixedPitch
- if (operands.size() != 1) {
- return OTS_FAILURE();
- }
- if (operands.back().second != DICT_OPERAND_INTEGER) {
- return OTS_FAILURE();
- }
- if (operands.back().first >= 2) {
- return OTS_FAILURE();
- }
- break;
+ if (cff2 && !ValidCFF2DictOp(op, type)) {
+ return OTS_FAILURE();
+ }
- // offset(0)
- case 15: // charset
- if (operands.size() != 1) {
- return OTS_FAILURE();
- }
- if (operands.back().first <= 2) {
- // predefined charset, ISOAdobe, Expert or ExpertSubset, is used.
- break;
- }
- if (!CheckOffset(operands.back(), table_length)) {
- return OTS_FAILURE();
- }
- if (charset_offset) {
- return OTS_FAILURE(); // multiple charset tables?
- }
- charset_offset = operands.back().first;
- break;
+ switch (op) {
+ // SID
+ case 0: // version
+ case 1: // Notice
+ case 2: // Copyright
+ case 3: // FullName
+ case 4: // FamilyName
+ case (12U << 8) + 0: // Copyright
+ case (12U << 8) + 21: // PostScript
+ case (12U << 8) + 22: // BaseFontName
+ case (12U << 8) + 38: // FontName
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ if (!CheckSid(operands.back(), sid_max)) {
+ return OTS_FAILURE();
+ }
+ break;
- case 16: { // Encoding
- if (operands.size() != 1) {
- return OTS_FAILURE();
- }
- if (operands.back().first <= 1) {
- break; // predefined encoding, "Standard" or "Expert", is used.
- }
- if (!CheckOffset(operands.back(), table_length)) {
- return OTS_FAILURE();
- }
+ // array
+ case 5: // FontBBox
+ case 14: // XUID
+ case (12U << 8) + 7: // FontMatrix
+ case (12U << 8) + 23: // BaseFontBlend (delta)
+ if (operands.empty()) {
+ return OTS_FAILURE();
+ }
+ break;
- // parse sub dictionary INDEX.
- ots::Buffer cff_table(data, table_length);
- cff_table.set_offset(operands.back().first);
- uint8_t format = 0;
- if (!cff_table.ReadU8(&format)) {
- return OTS_FAILURE();
- }
- if (format & 0x80) {
- // supplemental encoding is not supported at the moment.
- return OTS_FAILURE();
- }
- // TODO(yusukes): support & parse supplemental encoding tables.
- break;
+ // number
+ case 13: // UniqueID
+ case (12U << 8) + 2: // ItalicAngle
+ case (12U << 8) + 3: // UnderlinePosition
+ case (12U << 8) + 4: // UnderlineThickness
+ case (12U << 8) + 5: // PaintType
+ case (12U << 8) + 8: // StrokeWidth
+ case (12U << 8) + 20: // SyntheticBase
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ break;
+ case (12U << 8) + 31: // CIDFontVersion
+ case (12U << 8) + 32: // CIDFontRevision
+ case (12U << 8) + 33: // CIDFontType
+ case (12U << 8) + 34: // CIDCount
+ case (12U << 8) + 35: // UIDBase
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ if (font_format != FORMAT_CID_KEYED) {
+ return OTS_FAILURE();
+ }
+ break;
+ case (12U << 8) + 6: // CharstringType
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ if(operands.back().second != DICT_OPERAND_INTEGER) {
+ return OTS_FAILURE();
+ }
+ if (operands.back().first != 2) {
+ // We only support the "Type 2 Charstring Format."
+ // TODO(yusukes): Support Type 1 format? Is that still in use?
+ return OTS_FAILURE();
}
+ break;
- case 17: { // CharStrings
- if (type != DICT_DATA_TOPLEVEL) {
- return OTS_FAILURE();
- }
- if (operands.size() != 1) {
- return OTS_FAILURE();
- }
- if (!CheckOffset(operands.back(), table_length)) {
- return OTS_FAILURE();
- }
- // parse "14. CharStrings INDEX"
- ots::Buffer cff_table(data, table_length);
- cff_table.set_offset(operands.back().first);
- ots::CFFIndex *charstring_index = out_cff->char_strings_array.back();
- if (!ParseIndex(&cff_table, charstring_index)) {
- return OTS_FAILURE();
- }
- if (charstring_index->count < 2) {
- return OTS_FAILURE();
- }
- if (charstring_glyphs) {
- return OTS_FAILURE(); // multiple charstring tables?
- }
- charstring_glyphs = charstring_index->count;
- if (charstring_glyphs != glyphs) {
- return OTS_FAILURE(); // CFF and maxp have different number of glyphs?
- }
+ // boolean
+ case (12U << 8) + 1: // isFixedPitch
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ if (operands.back().second != DICT_OPERAND_INTEGER) {
+ return OTS_FAILURE();
+ }
+ if (operands.back().first >= 2) {
+ return OTS_FAILURE();
+ }
+ break;
+
+ // offset(0)
+ case 15: // charset
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ if (operands.back().first <= 2) {
+ // predefined charset, ISOAdobe, Expert or ExpertSubset, is used.
break;
}
+ if (!CheckOffset(operands.back(), table.length())) {
+ return OTS_FAILURE();
+ }
+ if (charset_offset) {
+ return OTS_FAILURE(); // multiple charset tables?
+ }
+ charset_offset = operands.back().first;
+ break;
- case (12U << 8) + 36: { // FDArray
- if (type != DICT_DATA_TOPLEVEL) {
- return OTS_FAILURE();
- }
- if (operands.size() != 1) {
- return OTS_FAILURE();
- }
- if (!CheckOffset(operands.back(), table_length)) {
- return OTS_FAILURE();
- }
+ case 16: { // Encoding
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ if (operands.back().first <= 1) {
+ break; // predefined encoding, "Standard" or "Expert", is used.
+ }
+ if (!CheckOffset(operands.back(), table.length())) {
+ return OTS_FAILURE();
+ }
- // parse sub dictionary INDEX.
- ots::Buffer cff_table(data, table_length);
- cff_table.set_offset(operands.back().first);
- ots::CFFIndex sub_dict_index;
- if (!ParseIndex(&cff_table, &sub_dict_index)) {
- return OTS_FAILURE();
- }
- if (!ParseDictData(data, table_length,
- sub_dict_index,
- glyphs, sid_max, DICT_DATA_FDARRAY,
- out_cff)) {
- return OTS_FAILURE();
- }
- if (out_cff->font_dict_length != 0) {
- return OTS_FAILURE(); // two or more FDArray found.
- }
- out_cff->font_dict_length = sub_dict_index.count;
- break;
+ table.set_offset(operands.back().first);
+ uint8_t format = 0;
+ if (!table.ReadU8(&format)) {
+ return OTS_FAILURE();
}
+ if (format & 0x80) {
+ // supplemental encoding is not supported at the moment.
+ return OTS_FAILURE();
+ }
+ // TODO(yusukes): support & parse supplemental encoding tables.
+ break;
+ }
- case (12U << 8) + 37: { // FDSelect
- if (type != DICT_DATA_TOPLEVEL) {
- return OTS_FAILURE();
+ case 17: { // CharStrings
+ if (type != DICT_DATA_TOPLEVEL) {
+ return OTS_FAILURE();
+ }
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ if (!CheckOffset(operands.back(), table.length())) {
+ return OTS_FAILURE();
+ }
+ // parse "14. CharStrings INDEX"
+ table.set_offset(operands.back().first);
+ ots::CFFIndex *charstring_index = out_cff->charstrings_index;
+ if (!ParseIndex(table, *charstring_index, cff2)) {
+ return OTS_FAILURE();
+ }
+ if (charstring_index->count < 2) {
+ return OTS_FAILURE();
+ }
+ if (have_charstrings) {
+ return OTS_FAILURE(); // multiple charstring tables?
+ }
+ have_charstrings = true;
+ if (charstring_index->count != glyphs) {
+ return OTS_FAILURE(); // CFF and maxp have different number of glyphs?
+ }
+ break;
+ }
+
+ case 24: { // vstore
+ if (!cff2) {
+ return OTS_FAILURE();
+ }
+ if (have_vstore) {
+ return OTS_FAILURE(); // multiple vstore tables?
+ }
+ have_vstore = true;
+ // parsed above.
+ break;
+ }
+
+ case (12U << 8) + 36: { // FDArray
+ if (type != DICT_DATA_TOPLEVEL) {
+ return OTS_FAILURE();
+ }
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ if (!CheckOffset(operands.back(), table.length())) {
+ return OTS_FAILURE();
+ }
+
+ // parse Font DICT INDEX.
+ table.set_offset(operands.back().first);
+ ots::CFFIndex sub_dict_index;
+ if (!ParseIndex(table, sub_dict_index, cff2)) {
+ return OTS_FAILURE();
+ }
+ if (!ParseDictData(table, sub_dict_index,
+ glyphs, sid_max, DICT_DATA_FDARRAY,
+ out_cff)) {
+ return OTS_FAILURE();
+ }
+ if (out_cff->font_dict_length != 0) {
+ return OTS_FAILURE(); // two or more FDArray found.
+ }
+ out_cff->font_dict_length = sub_dict_index.count;
+ break;
+ }
+
+ case (12U << 8) + 37: { // FDSelect
+ if (type != DICT_DATA_TOPLEVEL) {
+ return OTS_FAILURE();
+ }
+ if (operands.size() != 1) {
+ return OTS_FAILURE();
+ }
+ if (!CheckOffset(operands.back(), table.length())) {
+ return OTS_FAILURE();
+ }
+
+ // parse FDSelect data structure
+ table.set_offset(operands.back().first);
+ uint8_t format = 0;
+ if (!table.ReadU8(&format)) {
+ return OTS_FAILURE();
+ }
+ if (format == 0) {
+ for (uint16_t j = 0; j < glyphs; ++j) {
+ uint8_t fd_index = 0;
+ if (!table.ReadU8(&fd_index)) {
+ return OTS_FAILURE();
+ }
+ (out_cff->fd_select)[j] = fd_index;
}
- if (operands.size() != 1) {
+ } else if (format == 3) {
+ uint16_t n_ranges = 0;
+ if (!table.ReadU16(&n_ranges)) {
return OTS_FAILURE();
}
- if (!CheckOffset(operands.back(), table_length)) {
+ if (n_ranges == 0) {
return OTS_FAILURE();
}
- // parse FDSelect data structure
- ots::Buffer cff_table(data, table_length);
- cff_table.set_offset(operands.back().first);
- uint8_t format = 0;
- if (!cff_table.ReadU8(&format)) {
- return OTS_FAILURE();
- }
- if (format == 0) {
- for (uint16_t j = 0; j < glyphs; ++j) {
- uint8_t fd_index = 0;
- if (!cff_table.ReadU8(&fd_index)) {
- return OTS_FAILURE();
- }
- (out_cff->fd_select)[j] = fd_index;
- }
- } else if (format == 3) {
- uint16_t n_ranges = 0;
- if (!cff_table.ReadU16(&n_ranges)) {
+ uint16_t last_gid = 0;
+ uint8_t fd_index = 0;
+ for (unsigned j = 0; j < n_ranges; ++j) {
+ uint16_t first = 0; // GID
+ if (!table.ReadU16(&first)) {
return OTS_FAILURE();
}
- if (n_ranges == 0) {
+
+ // Sanity checks.
+ if ((j == 0) && (first != 0)) {
return OTS_FAILURE();
}
+ if ((j != 0) && (last_gid >= first)) {
+ return OTS_FAILURE(); // not increasing order.
+ }
+ if (first >= glyphs) {
+ return OTS_FAILURE(); // invalid gid.
+ }
- uint16_t last_gid = 0;
- uint8_t fd_index = 0;
- for (unsigned j = 0; j < n_ranges; ++j) {
- uint16_t first = 0; // GID
- if (!cff_table.ReadU16(&first)) {
- return OTS_FAILURE();
- }
-
- // Sanity checks.
- if ((j == 0) && (first != 0)) {
- return OTS_FAILURE();
- }
- if ((j != 0) && (last_gid >= first)) {
- return OTS_FAILURE(); // not increasing order.
- }
-
- // Copy the mapping to |out_cff->fd_select|.
- if (j != 0) {
- for (uint16_t k = last_gid; k < first; ++k) {
- if (!out_cff->fd_select.insert(
- std::make_pair(k, fd_index)).second) {
- return OTS_FAILURE();
- }
+ // Copy the mapping to |out_cff->fd_select|.
+ if (j != 0) {
+ for (auto k = last_gid; k < first; ++k) {
+ if (!out_cff->fd_select.insert(
+ std::make_pair(k, fd_index)).second) {
+ return OTS_FAILURE();
}
}
-
- if (!cff_table.ReadU8(&fd_index)) {
- return OTS_FAILURE();
- }
- last_gid = first;
- // TODO(yusukes): check GID?
- }
- uint16_t sentinel = 0;
- if (!cff_table.ReadU16(&sentinel)) {
- return OTS_FAILURE();
}
- if (last_gid >= sentinel) {
+
+ if (!table.ReadU8(&fd_index)) {
return OTS_FAILURE();
}
- for (uint16_t k = last_gid; k < sentinel; ++k) {
- if (!out_cff->fd_select.insert(
- std::make_pair(k, fd_index)).second) {
- return OTS_FAILURE();
- }
- }
- } else {
- // unknown format
- return OTS_FAILURE();
- }
- break;
- }
-
- // Private DICT (2 * number)
- case 18: {
- if (operands.size() != 2) {
- return OTS_FAILURE();
+ last_gid = first;
}
- if (operands.back().second != DICT_OPERAND_INTEGER) {
+ uint16_t sentinel = 0;
+ if (!table.ReadU16(&sentinel)) {
return OTS_FAILURE();
}
- const uint32_t private_offset = operands.back().first;
- operands.pop_back();
- if (operands.back().second != DICT_OPERAND_INTEGER) {
+ if (last_gid >= sentinel) {
return OTS_FAILURE();
}
- const uint32_t private_length = operands.back().first;
- if (private_offset > table_length) {
- return OTS_FAILURE();
+ if (sentinel > glyphs) {
+ return OTS_FAILURE(); // invalid gid.
}
- if (private_length >= table_length) {
- return OTS_FAILURE();
+ for (auto k = last_gid; k < sentinel; ++k) {
+ if (!out_cff->fd_select.insert(
+ std::make_pair(k, fd_index)).second) {
+ return OTS_FAILURE();
+ }
}
- if (private_length + private_offset > table_length) {
+ } else if (cff2 && format == 4) {
+ uint32_t n_ranges = 0;
+ if (!table.ReadU32(&n_ranges)) {
return OTS_FAILURE();
}
- // parse "15. Private DICT Data"
- if (!ParsePrivateDictData(data, table_length,
- private_offset, private_length,
- type, out_cff)) {
+ if (n_ranges == 0) {
return OTS_FAILURE();
}
- break;
- }
- // ROS
- case (12U << 8) + 30:
- if (font_format != FORMAT_UNKNOWN) {
- return OTS_FAILURE();
+ uint32_t last_gid = 0;
+ uint16_t fd_index = 0;
+ for (unsigned j = 0; j < n_ranges; ++j) {
+ uint32_t first = 0; // GID
+ if (!table.ReadU32(&first)) {
+ return OTS_FAILURE();
+ }
+
+ // Sanity checks.
+ if ((j == 0) && (first != 0)) {
+ return OTS_FAILURE();
+ }
+ if ((j != 0) && (last_gid >= first)) {
+ return OTS_FAILURE(); // not increasing order.
+ }
+ if (first >= glyphs) {
+ return OTS_FAILURE(); // invalid gid.
+ }
+
+ // Copy the mapping to |out_cff->fd_select|.
+ if (j != 0) {
+ for (auto k = last_gid; k < first; ++k) {
+ if (!out_cff->fd_select.insert(
+ std::make_pair(k, fd_index)).second) {
+ return OTS_FAILURE();
+ }
+ }
+ }
+
+ if (!table.ReadU16(&fd_index)) {
+ return OTS_FAILURE();
+ }
+ last_gid = first;
}
- font_format = FORMAT_CID_KEYED;
- if (operands.size() != 3) {
+ uint32_t sentinel = 0;
+ if (!table.ReadU32(&sentinel)) {
return OTS_FAILURE();
}
- // check SIDs
- operands.pop_back(); // ignore the first number.
- if (!CheckSid(operands.back(), sid_max)) {
+ if (last_gid >= sentinel) {
return OTS_FAILURE();
}
- operands.pop_back();
- if (!CheckSid(operands.back(), sid_max)) {
- return OTS_FAILURE();
+ if (sentinel > glyphs) {
+ return OTS_FAILURE(); // invalid gid.
}
- if (have_ros) {
- return OTS_FAILURE(); // multiple ROS tables?
+ for (auto k = last_gid; k < sentinel; ++k) {
+ if (!out_cff->fd_select.insert(
+ std::make_pair(k, fd_index)).second) {
+ return OTS_FAILURE();
+ }
}
- have_ros = true;
- break;
-
- default:
+ } else {
+ // unknown format
return OTS_FAILURE();
+ }
+ break;
}
- operands.clear();
- if (font_format == FORMAT_UNKNOWN) {
- font_format = FORMAT_OTHER;
+ // Private DICT (2 * number)
+ case 18: {
+ if (operands.size() != 2) {
+ return OTS_FAILURE();
+ }
+ if (operands.back().second != DICT_OPERAND_INTEGER) {
+ return OTS_FAILURE();
+ }
+ const uint32_t private_offset = operands.back().first;
+ operands.pop_back();
+ if (operands.back().second != DICT_OPERAND_INTEGER) {
+ return OTS_FAILURE();
+ }
+ const uint32_t private_length = operands.back().first;
+ if (private_offset > table.length()) {
+ return OTS_FAILURE();
+ }
+ if (private_length >= table.length()) {
+ return OTS_FAILURE();
+ }
+ if (private_length + private_offset > table.length()) {
+ return OTS_FAILURE();
+ }
+ // parse "15. Private DICT data"
+ if (!ParsePrivateDictData(table, private_offset, private_length,
+ type, out_cff)) {
+ return OTS_FAILURE();
+ }
+ break;
}
- }
- // parse "13. Charsets"
- if (charset_offset) {
- ots::Buffer cff_table(data, table_length);
- cff_table.set_offset(charset_offset);
- uint8_t format = 0;
- if (!cff_table.ReadU8(&format)) {
+ // ROS
+ case (12U << 8) + 30:
+ if (font_format != FORMAT_UNKNOWN) {
+ return OTS_FAILURE();
+ }
+ font_format = FORMAT_CID_KEYED;
+ if (operands.size() != 3) {
+ return OTS_FAILURE();
+ }
+ // check SIDs
+ operands.pop_back(); // ignore the first number.
+ if (!CheckSid(operands.back(), sid_max)) {
+ return OTS_FAILURE();
+ }
+ operands.pop_back();
+ if (!CheckSid(operands.back(), sid_max)) {
+ return OTS_FAILURE();
+ }
+ if (have_ros) {
+ return OTS_FAILURE(); // multiple ROS tables?
+ }
+ have_ros = true;
+ break;
+
+ default:
return OTS_FAILURE();
- }
- switch (format) {
- case 0:
- for (uint16_t j = 1 /* .notdef is omitted */; j < glyphs; ++j) {
- uint16_t sid = 0;
- if (!cff_table.ReadU16(&sid)) {
- return OTS_FAILURE();
- }
- if (!have_ros && (sid > sid_max)) {
- return OTS_FAILURE();
- }
- // TODO(yusukes): check CIDs when have_ros is true.
+ }
+ operands.clear();
+
+ if (font_format == FORMAT_UNKNOWN) {
+ font_format = FORMAT_OTHER;
+ }
+ }
+
+ // parse "13. Charsets"
+ if (charset_offset) {
+ table.set_offset(charset_offset);
+ uint8_t format = 0;
+ if (!table.ReadU8(&format)) {
+ return OTS_FAILURE();
+ }
+ switch (format) {
+ case 0:
+ for (uint16_t j = 1 /* .notdef is omitted */; j < glyphs; ++j) {
+ uint16_t sid = 0;
+ if (!table.ReadU16(&sid)) {
+ return OTS_FAILURE();
}
- break;
+ if (!have_ros && (sid > sid_max)) {
+ return OTS_FAILURE();
+ }
+ // TODO(yusukes): check CIDs when have_ros is true.
+ }
+ break;
+
+ case 1:
+ case 2: {
+ uint32_t total = 1; // .notdef is omitted.
+ while (total < glyphs) {
+ uint16_t sid = 0;
+ if (!table.ReadU16(&sid)) {
+ return OTS_FAILURE();
+ }
+ if (!have_ros && (sid > sid_max)) {
+ return OTS_FAILURE();
+ }
+ // TODO(yusukes): check CIDs when have_ros is true.
- case 1:
- case 2: {
- uint32_t total = 1; // .notdef is omitted.
- while (total < glyphs) {
- uint16_t sid = 0;
- if (!cff_table.ReadU16(&sid)) {
+ if (format == 1) {
+ uint8_t left = 0;
+ if (!table.ReadU8(&left)) {
return OTS_FAILURE();
}
- if (!have_ros && (sid > sid_max)) {
+ total += (left + 1);
+ } else {
+ uint16_t left = 0;
+ if (!table.ReadU16(&left)) {
return OTS_FAILURE();
}
- // TODO(yusukes): check CIDs when have_ros is true.
-
- if (format == 1) {
- uint8_t left = 0;
- if (!cff_table.ReadU8(&left)) {
- return OTS_FAILURE();
- }
- total += (left + 1);
- } else {
- uint16_t left = 0;
- if (!cff_table.ReadU16(&left)) {
- return OTS_FAILURE();
- }
- total += (left + 1);
- }
+ total += (left + 1);
}
- break;
}
-
- default:
- return OTS_FAILURE();
+ break;
}
+
+ default:
+ return OTS_FAILURE();
}
}
return true;
@@ -904,147 +1146,218 @@ bool ParseDictData(const uint8_t *data, size_t table_length,
namespace ots {
-bool ots_cff_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeCFF::ValidateFDSelect(uint16_t num_glyphs) {
+ for (const auto& fd_select : this->fd_select) {
+ if (fd_select.first >= num_glyphs) {
+ return Error("Invalid glyph index in FDSelect: %d >= %d\n",
+ fd_select.first, num_glyphs);
+ }
+ if (fd_select.second >= this->font_dict_length) {
+ return Error("Invalid FD index: %d >= %d\n",
+ fd_select.second, this->font_dict_length);
+ }
+ }
+ return true;
+}
+
+bool OpenTypeCFF::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- font->cff = new OpenTypeCFF;
- font->cff->data = data;
- font->cff->length = length;
- font->cff->font_dict_length = 0;
- font->cff->local_subrs = NULL;
+ Font *font = GetFont();
+
+ this->m_data = data;
+ this->m_length = length;
// parse "6. Header" in the Adobe Compact Font Format Specification
uint8_t major = 0;
uint8_t minor = 0;
uint8_t hdr_size = 0;
uint8_t off_size = 0;
- if (!table.ReadU8(&major)) {
- return OTS_FAILURE();
+ if (!table.ReadU8(&major) ||
+ !table.ReadU8(&minor) ||
+ !table.ReadU8(&hdr_size) ||
+ !table.ReadU8(&off_size)) {
+ return Error("Failed to read table header");
}
- if (!table.ReadU8(&minor)) {
- return OTS_FAILURE();
- }
- if (!table.ReadU8(&hdr_size)) {
- return OTS_FAILURE();
- }
- if (!table.ReadU8(&off_size)) {
- return OTS_FAILURE();
- }
- if ((off_size == 0) || (off_size > 4)) {
- return OTS_FAILURE();
+
+ if (off_size < 1 || off_size > 4) {
+ return Error("Bad offSize: %d", off_size);
}
- if ((major != 1) ||
- (minor != 0) ||
- (hdr_size != 4)) {
- return OTS_FAILURE();
+ if (major != 1 || minor != 0) {
+ return Error("Unsupported table version: %d.%d", major, minor);
}
- if (hdr_size >= length) {
- return OTS_FAILURE();
+
+ this->major = major;
+
+ if (hdr_size != 4 || hdr_size >= length) {
+ return Error("Bad hdrSize: %d", hdr_size);
}
// parse "7. Name INDEX"
table.set_offset(hdr_size);
CFFIndex name_index;
- if (!ParseIndex(&table, &name_index)) {
- return OTS_FAILURE();
+ if (!ParseIndex(table, name_index)) {
+ return Error("Failed to parse Name INDEX");
}
- if (!ParseNameData(&table, name_index, &(font->cff->name))) {
- return OTS_FAILURE();
+ if (name_index.count != 1 || name_index.offsets.size() != 2) {
+ return Error("Name INDEX must contain only one entry, not %d",
+ name_index.count);
+ }
+ if (!ParseNameData(&table, name_index, &(this->name))) {
+ return Error("Failed to parse Name INDEX data");
}
// parse "8. Top DICT INDEX"
table.set_offset(name_index.offset_to_next);
CFFIndex top_dict_index;
- if (!ParseIndex(&table, &top_dict_index)) {
- return OTS_FAILURE();
+ if (!ParseIndex(table, top_dict_index)) {
+ return Error("Failed to parse Top DICT INDEX");
}
- if (name_index.count != top_dict_index.count) {
- return OTS_FAILURE();
+ if (top_dict_index.count != 1) {
+ return Error("Top DICT INDEX must contain only one entry, not %d",
+ top_dict_index.count);
}
// parse "10. String INDEX"
table.set_offset(top_dict_index.offset_to_next);
CFFIndex string_index;
- if (!ParseIndex(&table, &string_index)) {
- return OTS_FAILURE();
+ if (!ParseIndex(table, string_index)) {
+ return Error("Failed to parse String INDEX");
}
if (string_index.count >= 65000 - kNStdString) {
- return OTS_FAILURE();
+ return Error("Too many entries in String INDEX: %d", string_index.count);
}
- const uint16_t num_glyphs = font->maxp->num_glyphs;
+ OpenTypeMAXP *maxp = static_cast<OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return Error("Required maxp table missing");
+ }
+ const uint16_t num_glyphs = maxp->num_glyphs;
const size_t sid_max = string_index.count + kNStdString;
// string_index.count == 0 is allowed.
// parse "9. Top DICT Data"
- if (!ParseDictData(data, length, top_dict_index,
+ this->charstrings_index = new ots::CFFIndex;
+ if (!ParseDictData(table, top_dict_index,
num_glyphs, sid_max,
- DICT_DATA_TOPLEVEL, font->cff)) {
- return OTS_FAILURE();
+ DICT_DATA_TOPLEVEL, this)) {
+ return Error("Failed to parse Top DICT Data");
}
// parse "16. Global Subrs INDEX"
table.set_offset(string_index.offset_to_next);
CFFIndex global_subrs_index;
- if (!ParseIndex(&table, &global_subrs_index)) {
- return OTS_FAILURE();
+ if (!ParseIndex(table, global_subrs_index)) {
+ return Error("Failed to parse Global Subrs INDEX");
}
- // Check if all fd_index in FDSelect are valid.
- std::map<uint16_t, uint8_t>::const_iterator iter;
- std::map<uint16_t, uint8_t>::const_iterator end = font->cff->fd_select.end();
- for (iter = font->cff->fd_select.begin(); iter != end; ++iter) {
- if (iter->second >= font->cff->font_dict_length) {
- return OTS_FAILURE();
- }
+ // Check if all fd and glyph indices in FDSelect are valid.
+ if (!ValidateFDSelect(num_glyphs)) {
+ return Error("Failed to validate FDSelect");
}
// Check if all charstrings (font hinting code for each glyph) are valid.
- for (size_t i = 0; i < font->cff->char_strings_array.size(); ++i) {
- if (!ValidateType2CharStringIndex(font,
- *(font->cff->char_strings_array.at(i)),
- global_subrs_index,
- font->cff->fd_select,
- font->cff->local_subrs_per_font,
- font->cff->local_subrs,
- &table)) {
- return OTS_FAILURE_MSG("Failed validating charstring set %d", (int) i);
- }
+ if (!ValidateCFFCharStrings(*this, global_subrs_index, &table)) {
+ return Error("Failed validating CharStrings INDEX");
}
return true;
}
-bool ots_cff_should_serialise(Font *font) {
- return font->cff != NULL;
+bool OpenTypeCFF::Serialize(OTSStream *out) {
+ if (!out->Write(this->m_data, this->m_length)) {
+ return Error("Failed to write table");
+ }
+ return true;
}
-bool ots_cff_serialise(OTSStream *out, Font *font) {
- // TODO(yusukes): would be better to transcode the data,
- // rather than simple memcpy.
- if (!out->Write(font->cff->data, font->cff->length)) {
- return OTS_FAILURE();
+OpenTypeCFF::~OpenTypeCFF() {
+ for (size_t i = 0; i < this->local_subrs_per_font.size(); ++i) {
+ delete (this->local_subrs_per_font)[i];
}
- return true;
+ delete this->charstrings_index;
+ delete this->local_subrs;
}
-void ots_cff_reuse(Font *font, Font *other) {
- font->cff = other->cff;
- font->cff_reused = true;
+bool OpenTypeCFF2::Parse(const uint8_t *data, size_t length) {
+ Buffer table(data, length);
+
+ Font *font = GetFont();
+
+ this->m_data = data;
+ this->m_length = length;
+
+ // parse "6. Header"
+ uint8_t major = 0;
+ uint8_t minor = 0;
+ uint8_t hdr_size = 0;
+ uint16_t top_dict_size = 0;
+ if (!table.ReadU8(&major) ||
+ !table.ReadU8(&minor) ||
+ !table.ReadU8(&hdr_size) ||
+ !table.ReadU16(&top_dict_size)) {
+ return Error("Failed to read table header");
+ }
+
+ if (major != 2 || minor != 0) {
+ return Error("Unsupported table version: %d.%d", major, minor);
+ }
+
+ this->major = major;
+
+ if (hdr_size >= length) {
+ return Error("Bad hdrSize: %d", hdr_size);
+ }
+
+ if (top_dict_size == 0 || hdr_size + top_dict_size > length) {
+ return Error("Bad topDictLength: %d", top_dict_size);
+ }
+
+ OpenTypeMAXP *maxp = static_cast<OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return Error("Required maxp table missing");
+ }
+ const uint16_t num_glyphs = maxp->num_glyphs;
+ const size_t sid_max = kNStdString;
+
+ // parse "7. Top DICT Data"
+ ots::Buffer top_dict(data + hdr_size, top_dict_size);
+ table.set_offset(hdr_size);
+ this->charstrings_index = new ots::CFFIndex;
+ if (!ParseDictData(table, top_dict,
+ num_glyphs, sid_max,
+ DICT_DATA_TOPLEVEL, this)) {
+ return Error("Failed to parse Top DICT Data");
+ }
+
+ // parse "9. Global Subrs INDEX"
+ table.set_offset(hdr_size + top_dict_size);
+ CFFIndex global_subrs_index;
+ if (!ParseIndex(table, global_subrs_index, true)) {
+ return Error("Failed to parse Global Subrs INDEX");
+ }
+
+ // Check if all fd and glyph indices in FDSelect are valid.
+ if (!ValidateFDSelect(num_glyphs)) {
+ return Error("Failed to validate FDSelect");
+ }
+
+ // Check if all charstrings (font hinting code for each glyph) are valid.
+ if (!ValidateCFFCharStrings(*this, global_subrs_index, &table)) {
+ return Error("Failed validating CharStrings INDEX");
+ }
+
+ return true;
}
-void ots_cff_free(Font *font) {
- if (font->cff) {
- for (size_t i = 0; i < font->cff->char_strings_array.size(); ++i) {
- delete (font->cff->char_strings_array)[i];
- }
- for (size_t i = 0; i < font->cff->local_subrs_per_font.size(); ++i) {
- delete (font->cff->local_subrs_per_font)[i];
- }
- delete font->cff->local_subrs;
- delete font->cff;
+bool OpenTypeCFF2::Serialize(OTSStream *out) {
+ if (!out->Write(this->m_data, this->m_length)) {
+ return Error("Failed to write table");
}
+ return true;
}
} // namespace ots
diff --git a/gfx/ots/src/cff.h b/gfx/ots/src/cff.h
index 5584acc62..cfce9ab91 100644
--- a/gfx/ots/src/cff.h
+++ b/gfx/ots/src/cff.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,34 +11,81 @@
#include <string>
#include <vector>
+#undef major // glibc defines major!
+
namespace ots {
struct CFFIndex {
CFFIndex()
: count(0), off_size(0), offset_to_next(0) {}
- uint16_t count;
+ uint32_t count;
uint8_t off_size;
std::vector<uint32_t> offsets;
uint32_t offset_to_next;
};
-struct OpenTypeCFF {
- const uint8_t *data;
- size_t length;
+typedef std::map<uint32_t, uint16_t> CFFFDSelect;
+
+class OpenTypeCFF : public Table {
+ public:
+ explicit OpenTypeCFF(Font *font, uint32_t tag)
+ : Table(font, tag, tag),
+ major(0),
+ font_dict_length(0),
+ charstrings_index(NULL),
+ local_subrs(NULL),
+ m_data(NULL),
+ m_length(0) {
+ }
+
+ ~OpenTypeCFF();
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
+ // Major version number.
+ uint8_t major;
+
// Name INDEX. This name is used in name.cc as a postscript font name.
std::string name;
// The number of fonts the file has.
size_t font_dict_length;
// A map from glyph # to font #.
- std::map<uint16_t, uint8_t> fd_select;
+ CFFFDSelect fd_select;
// A list of char strings.
- std::vector<CFFIndex *> char_strings_array;
+ CFFIndex* charstrings_index;
// A list of Local Subrs associated with FDArrays. Can be empty.
std::vector<CFFIndex *> local_subrs_per_font;
// A Local Subrs associated with Top DICT. Can be NULL.
CFFIndex *local_subrs;
+
+ // CFF2 VariationStore regionIndexCount.
+ std::vector<uint16_t> region_index_count;
+
+ protected:
+ bool ValidateFDSelect(uint16_t num_glyphs);
+
+ private:
+ const uint8_t *m_data;
+ size_t m_length;
+};
+
+class OpenTypeCFF2 : public OpenTypeCFF {
+ public:
+ explicit OpenTypeCFF2(Font *font, uint32_t tag)
+ : OpenTypeCFF(font, tag),
+ m_data(NULL),
+ m_length(0) {
+ }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
+ private:
+ const uint8_t *m_data;
+ size_t m_length;
};
} // namespace ots
diff --git a/gfx/ots/src/cff_type2_charstring.cc b/gfx/ots/src/cff_charstring.cc
index 8c5544b2e..23c17d183 100644
--- a/gfx/ots/src/cff_type2_charstring.cc
+++ b/gfx/ots/src/cff_charstring.cc
@@ -1,11 +1,11 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// A parser for the Type 2 Charstring Format.
// http://www.adobe.com/devnet/font/pdfs/5177.Type2.pdf
-#include "cff_type2_charstring.h"
+#include "cff_charstring.h"
#include <climits>
#include <cstdio>
@@ -22,7 +22,6 @@ namespace {
// Note #5177.
const int32_t kMaxSubrsCount = 65536;
const size_t kMaxCharStringLength = 65535;
-const size_t kMaxArgumentStack = 48;
const size_t kMaxNumberOfStemHints = 96;
const size_t kMaxSubrNesting = 10;
@@ -30,117 +29,130 @@ const size_t kMaxSubrNesting = 10;
// will fail with the dummy value.
const int32_t dummy_result = INT_MAX;
-bool ExecuteType2CharString(ots::Font *font,
- size_t call_depth,
- const ots::CFFIndex& global_subrs_index,
- const ots::CFFIndex& local_subrs_index,
- ots::Buffer *cff_table,
- ots::Buffer *char_string,
- std::stack<int32_t> *argument_stack,
- bool *out_found_endchar,
- bool *out_found_width,
- size_t *in_out_num_stems);
+bool ExecuteCharString(ots::OpenTypeCFF& cff,
+ size_t call_depth,
+ const ots::CFFIndex& global_subrs_index,
+ const ots::CFFIndex& local_subrs_index,
+ ots::Buffer *cff_table,
+ ots::Buffer *char_string,
+ std::stack<int32_t> *argument_stack,
+ bool *out_found_endchar,
+ bool *out_found_width,
+ size_t *in_out_num_stems,
+ bool cff2);
+
+bool ArgumentStackOverflows(std::stack<int32_t> *argument_stack, bool cff2) {
+ if ((cff2 && argument_stack->size() > ots::kMaxCFF2ArgumentStack) ||
+ (!cff2 && argument_stack->size() > ots::kMaxCFF1ArgumentStack)) {
+ return true;
+ }
+ return false;
+}
#ifdef DUMP_T2CHARSTRING
// Converts |op| to a string and returns it.
-const char *Type2CharStringOperatorToString(ots::Type2CharStringOperator op) {
+const char *CharStringOperatorToString(ots::CharStringOperator op) {
switch (op) {
case ots::kHStem:
- return "HStem";
+ return "hstem";
case ots::kVStem:
- return "VStem";
+ return "vstem";
case ots::kVMoveTo:
- return "VMoveTo";
+ return "vmoveto";
case ots::kRLineTo:
- return "RLineTo";
+ return "rlineto";
case ots::kHLineTo:
- return "HLineTo";
+ return "hlineto";
case ots::kVLineTo:
- return "VLineTo";
+ return "vlineto";
case ots::kRRCurveTo:
- return "RRCurveTo";
+ return "rrcurveto";
case ots::kCallSubr:
- return "CallSubr";
+ return "callsubr";
case ots::kReturn:
- return "Return";
+ return "return";
case ots::kEndChar:
- return "EndChar";
+ return "endchar";
+ case ots::kVSIndex:
+ return "vsindex";
+ case ots::kBlend:
+ return "blend";
case ots::kHStemHm:
- return "HStemHm";
+ return "hstemhm";
case ots::kHintMask:
- return "HintMask";
+ return "hintmask";
case ots::kCntrMask:
- return "CntrMask";
+ return "cntrmask";
case ots::kRMoveTo:
- return "RMoveTo";
+ return "rmoveto";
case ots::kHMoveTo:
- return "HMoveTo";
+ return "hmoveto";
case ots::kVStemHm:
- return "VStemHm";
+ return "vstemhm";
case ots::kRCurveLine:
- return "RCurveLine";
+ return "rcurveline";
case ots::kRLineCurve:
- return "RLineCurve";
+ return "rlinecurve";
case ots::kVVCurveTo:
return "VVCurveTo";
case ots::kHHCurveTo:
- return "HHCurveTo";
+ return "hhcurveto";
case ots::kCallGSubr:
- return "CallGSubr";
+ return "callgsubr";
case ots::kVHCurveTo:
- return "VHCurveTo";
+ return "vhcurveto";
case ots::kHVCurveTo:
return "HVCurveTo";
case ots::kDotSection:
- return "DotSection";
+ return "dotsection";
case ots::kAnd:
- return "And";
+ return "and";
case ots::kOr:
- return "Or";
+ return "or";
case ots::kNot:
- return "Not";
+ return "not";
case ots::kAbs:
- return "Abs";
+ return "abs";
case ots::kAdd:
- return "Add";
+ return "add";
case ots::kSub:
- return "Sub";
+ return "sub";
case ots::kDiv:
- return "Div";
+ return "div";
case ots::kNeg:
- return "Neg";
+ return "neg";
case ots::kEq:
- return "Eq";
+ return "eq";
case ots::kDrop:
- return "Drop";
+ return "drop";
case ots::kPut:
- return "Put";
+ return "put";
case ots::kGet:
- return "Get";
+ return "get";
case ots::kIfElse:
- return "IfElse";
+ return "ifelse";
case ots::kRandom:
- return "Random";
+ return "random";
case ots::kMul:
- return "Mul";
+ return "mul";
case ots::kSqrt:
- return "Sqrt";
+ return "sqrt";
case ots::kDup:
- return "Dup";
+ return "dup";
case ots::kExch:
- return "Exch";
+ return "exch";
case ots::kIndex:
- return "Index";
+ return "index";
case ots::kRoll:
- return "Roll";
+ return "roll";
case ots::kHFlex:
- return "HFlex";
+ return "hflex";
case ots::kFlex:
- return "Flex";
+ return "flex";
case ots::kHFlex1:
- return "HFlex1";
+ return "hflex1";
case ots::kFlex1:
- return "Flex1";
+ return "flex1";
}
return "UNKNOWN";
@@ -150,9 +162,9 @@ const char *Type2CharStringOperatorToString(ots::Type2CharStringOperator op) {
// Read one or more bytes from the |char_string| buffer and stores the number
// read on |out_number|. If the number read is an operator (ex 'vstem'), sets
// true on |out_is_operator|. Returns true if the function read a number.
-bool ReadNextNumberFromType2CharString(ots::Buffer *char_string,
- int32_t *out_number,
- bool *out_is_operator) {
+bool ReadNextNumberFromCharString(ots::Buffer *char_string,
+ int32_t *out_number,
+ bool *out_is_operator) {
uint8_t v = 0;
if (!char_string->ReadU8(&v)) {
return OTS_FAILURE();
@@ -174,7 +186,7 @@ bool ReadNextNumberFromType2CharString(ots::Buffer *char_string,
*out_is_operator = true;
} else if (v <= 27) {
// Special handling for v==19 and v==20 are implemented in
- // ExecuteType2CharStringOperator().
+ // ExecuteCharStringOperator().
*out_number = v;
*out_is_operator = true;
} else if (v == 28) {
@@ -221,23 +233,63 @@ bool ReadNextNumberFromType2CharString(ots::Buffer *char_string,
return true;
}
+bool ValidCFF2Operator(int32_t op) {
+ switch (op) {
+ case ots::kReturn:
+ case ots::kEndChar:
+ case ots::kAbs:
+ case ots::kAdd:
+ case ots::kSub:
+ case ots::kDiv:
+ case ots::kNeg:
+ case ots::kRandom:
+ case ots::kMul:
+ case ots::kSqrt:
+ case ots::kDrop:
+ case ots::kExch:
+ case ots::kIndex:
+ case ots::kRoll:
+ case ots::kDup:
+ case ots::kPut:
+ case ots::kGet:
+ case ots::kDotSection:
+ case ots::kAnd:
+ case ots::kOr:
+ case ots::kNot:
+ case ots::kEq:
+ case ots::kIfElse:
+ return false;
+ }
+
+ return true;
+}
+
// Executes |op| and updates |argument_stack|. Returns true if the execution
// succeeds. If the |op| is kCallSubr or kCallGSubr, the function recursively
-// calls ExecuteType2CharString() function. The arguments other than |op| and
+// calls ExecuteCharString() function. The arguments other than |op| and
// |argument_stack| are passed for that reason.
-bool ExecuteType2CharStringOperator(ots::Font *font,
- int32_t op,
- size_t call_depth,
- const ots::CFFIndex& global_subrs_index,
- const ots::CFFIndex& local_subrs_index,
- ots::Buffer *cff_table,
- ots::Buffer *char_string,
- std::stack<int32_t> *argument_stack,
- bool *out_found_endchar,
- bool *in_out_found_width,
- size_t *in_out_num_stems) {
+bool ExecuteCharStringOperator(ots::OpenTypeCFF& cff,
+ int32_t op,
+ size_t call_depth,
+ const ots::CFFIndex& global_subrs_index,
+ const ots::CFFIndex& local_subrs_index,
+ ots::Buffer *cff_table,
+ ots::Buffer *char_string,
+ std::stack<int32_t> *argument_stack,
+ bool *out_found_endchar,
+ bool *in_out_found_width,
+ size_t *in_out_num_stems,
+ bool *in_out_have_blend,
+ bool *in_out_have_visindex,
+ int32_t *in_out_vsindex,
+ bool cff2) {
+ ots::Font* font = cff.GetFont();
const size_t stack_size = argument_stack->size();
+ if (cff2 && !ValidCFF2Operator(op)) {
+ return OTS_FAILURE();
+ }
+
switch (op) {
case ots::kCallSubr:
case ots::kCallGSubr: {
@@ -290,16 +342,17 @@ bool ExecuteType2CharStringOperator(ots::Font *font,
}
ots::Buffer char_string_to_jump(cff_table->buffer() + offset, length);
- return ExecuteType2CharString(font,
- call_depth + 1,
- global_subrs_index,
- local_subrs_index,
- cff_table,
- &char_string_to_jump,
- argument_stack,
- out_found_endchar,
- in_out_found_width,
- in_out_num_stems);
+ return ExecuteCharString(cff,
+ call_depth + 1,
+ global_subrs_index,
+ local_subrs_index,
+ cff_table,
+ &char_string_to_jump,
+ argument_stack,
+ out_found_endchar,
+ in_out_found_width,
+ in_out_num_stems,
+ cff2);
}
case ots::kReturn:
@@ -310,6 +363,51 @@ bool ExecuteType2CharStringOperator(ots::Font *font,
*in_out_found_width = true; // just in case.
return true;
+ case ots::kVSIndex: {
+ if (!cff2) {
+ return OTS_FAILURE();
+ }
+ if (stack_size != 1) {
+ return OTS_FAILURE();
+ }
+ if (*in_out_have_blend || *in_out_have_visindex) {
+ return OTS_FAILURE();
+ }
+ if (argument_stack->top() >= cff.region_index_count.size()) {
+ return OTS_FAILURE();
+ }
+ *in_out_have_visindex = true;
+ *in_out_vsindex = argument_stack->top();
+ while (!argument_stack->empty())
+ argument_stack->pop();
+ return true;
+ }
+
+ case ots::kBlend: {
+ if (!cff2) {
+ return OTS_FAILURE();
+ }
+ if (stack_size < 1) {
+ return OTS_FAILURE();
+ }
+ if (*in_out_vsindex >= cff.region_index_count.size()) {
+ return OTS_FAILURE();
+ }
+ uint16_t k = cff.region_index_count.at(*in_out_vsindex);
+ uint16_t n = argument_stack->top();
+ if (stack_size < n * (k + 1) + 1) {
+ return OTS_FAILURE();
+ }
+
+ // Keep the 1st n operands on the stack for the next operator to use and
+ // pop the rest. There can be multiple consecutive blend operator, so this
+ // makes sure the operands of all of them are kept on the stack.
+ while (argument_stack->size() > stack_size - ((n * k) + 1))
+ argument_stack->pop();
+ *in_out_have_blend = true;
+ return true;
+ }
+
case ots::kHStem:
case ots::kVStem:
case ots::kHStemHm:
@@ -649,7 +747,7 @@ bool ExecuteType2CharStringOperator(ots::Font *font,
argument_stack->pop();
argument_stack->push(dummy_result);
argument_stack->push(dummy_result);
- if (argument_stack->size() > kMaxArgumentStack) {
+ if (ArgumentStackOverflows(argument_stack, cff2)) {
return OTS_FAILURE();
}
// TODO(yusukes): Implement this. We should push a real value for all
@@ -729,26 +827,29 @@ bool ExecuteType2CharStringOperator(ots::Font *font,
// in_out_found_width: true is set if |char_string| contains 'width' byte (which
// is 0 or 1 byte.)
// in_out_num_stems: total number of hstems and vstems processed so far.
-bool ExecuteType2CharString(ots::Font *font,
- size_t call_depth,
- const ots::CFFIndex& global_subrs_index,
- const ots::CFFIndex& local_subrs_index,
- ots::Buffer *cff_table,
- ots::Buffer *char_string,
- std::stack<int32_t> *argument_stack,
- bool *out_found_endchar,
- bool *in_out_found_width,
- size_t *in_out_num_stems) {
+bool ExecuteCharString(ots::OpenTypeCFF& cff,
+ size_t call_depth,
+ const ots::CFFIndex& global_subrs_index,
+ const ots::CFFIndex& local_subrs_index,
+ ots::Buffer *cff_table,
+ ots::Buffer *char_string,
+ std::stack<int32_t> *argument_stack,
+ bool *out_found_endchar,
+ bool *in_out_found_width,
+ size_t *in_out_num_stems,
+ bool cff2) {
if (call_depth > kMaxSubrNesting) {
return OTS_FAILURE();
}
*out_found_endchar = false;
+ bool in_out_have_blend = false, in_out_have_visindex = false;
+ int32_t in_out_vsindex = 0;
const size_t length = char_string->length();
while (char_string->offset() < length) {
int32_t operator_or_operand = 0;
bool is_operator = false;
- if (!ReadNextNumberFromType2CharString(char_string,
+ if (!ReadNextNumberFromCharString(char_string,
&operator_or_operand,
&is_operator)) {
return OTS_FAILURE();
@@ -761,35 +862,39 @@ bool ExecuteType2CharString(ots::Font *font,
*/
if (!is_operator) {
- std::fprintf(stderr, "#%d# ", operator_or_operand);
+ std::fprintf(stderr, "%d ", operator_or_operand);
} else {
- std::fprintf(stderr, "#%s#\n",
- Type2CharStringOperatorToString(
- ots::Type2CharStringOperator(operator_or_operand))
+ std::fprintf(stderr, "%s\n",
+ CharStringOperatorToString(
+ ots::CharStringOperator(operator_or_operand))
);
}
#endif
if (!is_operator) {
argument_stack->push(operator_or_operand);
- if (argument_stack->size() > kMaxArgumentStack) {
+ if (ArgumentStackOverflows(argument_stack, cff2)) {
return OTS_FAILURE();
}
continue;
}
// An operator is found. Execute it.
- if (!ExecuteType2CharStringOperator(font,
- operator_or_operand,
- call_depth,
- global_subrs_index,
- local_subrs_index,
- cff_table,
- char_string,
- argument_stack,
- out_found_endchar,
- in_out_found_width,
- in_out_num_stems)) {
+ if (!ExecuteCharStringOperator(cff,
+ operator_or_operand,
+ call_depth,
+ global_subrs_index,
+ local_subrs_index,
+ cff_table,
+ char_string,
+ argument_stack,
+ out_found_endchar,
+ in_out_found_width,
+ in_out_num_stems,
+ &in_out_have_blend,
+ &in_out_have_visindex,
+ &in_out_vsindex,
+ cff2)) {
return OTS_FAILURE();
}
if (*out_found_endchar) {
@@ -801,37 +906,39 @@ bool ExecuteType2CharString(ots::Font *font,
}
// No endchar operator is found.
+ if (cff2)
+ return true;
return OTS_FAILURE();
}
// Selects a set of subroutings for |glyph_index| from |cff| and sets it on
// |out_local_subrs_to_use|. Returns true on success.
-bool SelectLocalSubr(const std::map<uint16_t, uint8_t> &fd_select,
- const std::vector<ots::CFFIndex *> &local_subrs_per_font,
- const ots::CFFIndex *local_subrs,
+bool SelectLocalSubr(const ots::OpenTypeCFF& cff,
uint16_t glyph_index, // 0-origin
const ots::CFFIndex **out_local_subrs_to_use) {
+ bool cff2 = (cff.major == 2);
*out_local_subrs_to_use = NULL;
// First, find local subrs from |local_subrs_per_font|.
- if ((fd_select.size() > 0) &&
- (!local_subrs_per_font.empty())) {
+ if ((cff.fd_select.size() > 0) &&
+ (!cff.local_subrs_per_font.empty())) {
// Look up FDArray index for the glyph.
- std::map<uint16_t, uint8_t>::const_iterator iter =
- fd_select.find(glyph_index);
- if (iter == fd_select.end()) {
+ const auto& iter = cff.fd_select.find(glyph_index);
+ if (iter == cff.fd_select.end()) {
return OTS_FAILURE();
}
- const uint8_t fd_index = iter->second;
- if (fd_index >= local_subrs_per_font.size()) {
+ const auto fd_index = iter->second;
+ if (fd_index >= cff.local_subrs_per_font.size()) {
return OTS_FAILURE();
}
- *out_local_subrs_to_use = local_subrs_per_font.at(fd_index);
- } else if (local_subrs) {
+ *out_local_subrs_to_use = cff.local_subrs_per_font.at(fd_index);
+ } else if (cff.local_subrs) {
// Second, try to use |local_subrs|. Most Latin fonts don't have FDSelect
// entries. If The font has a local subrs index associated with the Top
// DICT (not FDArrays), use it.
- *out_local_subrs_to_use = local_subrs;
+ *out_local_subrs_to_use = cff.local_subrs;
+ } else if (cff2 && cff.local_subrs_per_font.size() == 1) {
+ *out_local_subrs_to_use = cff.local_subrs_per_font.at(0);
} else {
// Just return NULL.
*out_local_subrs_to_use = NULL;
@@ -844,18 +951,16 @@ bool SelectLocalSubr(const std::map<uint16_t, uint8_t> &fd_select,
namespace ots {
-bool ValidateType2CharStringIndex(
- ots::Font *font,
- const CFFIndex& char_strings_index,
+bool ValidateCFFCharStrings(
+ ots::OpenTypeCFF& cff,
const CFFIndex& global_subrs_index,
- const std::map<uint16_t, uint8_t> &fd_select,
- const std::vector<CFFIndex *> &local_subrs_per_font,
- const CFFIndex *local_subrs,
Buffer* cff_table) {
+ const CFFIndex& char_strings_index = *(cff.charstrings_index);
if (char_strings_index.offsets.size() == 0) {
return OTS_FAILURE(); // no charstring.
}
+ bool cff2 = (cff.major == 2);
// For each glyph, validate the corresponding charstring.
for (unsigned i = 1; i < char_strings_index.offsets.size(); ++i) {
// Prepare a Buffer object, |char_string|, which contains the charstring
@@ -875,9 +980,7 @@ bool ValidateType2CharStringIndex(
// Get a local subrs for the glyph.
const unsigned glyph_index = i - 1; // index in the map is 0-origin.
const CFFIndex *local_subrs_to_use = NULL;
- if (!SelectLocalSubr(fd_select,
- local_subrs_per_font,
- local_subrs,
+ if (!SelectLocalSubr(cff,
glyph_index,
&local_subrs_to_use)) {
return OTS_FAILURE();
@@ -891,16 +994,19 @@ bool ValidateType2CharStringIndex(
// Check a charstring for the |i|-th glyph.
std::stack<int32_t> argument_stack;
bool found_endchar = false;
- bool found_width = false;
+ // CFF2 CharString has no value for width, so we start with true here to
+ // error out if width is found.
+ bool found_width = cff2;
size_t num_stems = 0;
- if (!ExecuteType2CharString(font,
- 0 /* initial call_depth is zero */,
- global_subrs_index, *local_subrs_to_use,
- cff_table, &char_string, &argument_stack,
- &found_endchar, &found_width, &num_stems)) {
+ if (!ExecuteCharString(cff,
+ 0 /* initial call_depth is zero */,
+ global_subrs_index, *local_subrs_to_use,
+ cff_table, &char_string, &argument_stack,
+ &found_endchar, &found_width, &num_stems,
+ cff2)) {
return OTS_FAILURE();
}
- if (!found_endchar) {
+ if (!cff2 && !found_endchar) {
return OTS_FAILURE();
}
}
diff --git a/gfx/ots/src/cff_type2_charstring.h b/gfx/ots/src/cff_charstring.h
index be44bc72c..5a2fa9ff2 100644
--- a/gfx/ots/src/cff_type2_charstring.h
+++ b/gfx/ots/src/cff_charstring.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,6 +13,9 @@
namespace ots {
+const size_t kMaxCFF1ArgumentStack = 48;
+const size_t kMaxCFF2ArgumentStack = 513;
+
// Validates all charstrings in |char_strings_index|. Charstring is a small
// language for font hinting defined in Adobe Technical Note #5177.
// http://www.adobe.com/devnet/font/pdfs/5177.Type2.pdf
@@ -34,17 +37,14 @@ namespace ots {
// local_subrs: A Local Subrs associated with Top DICT. Can be NULL.
// cff_table: A buffer which contains actual byte code of charstring, global
// subroutines and local subroutines.
-bool ValidateType2CharStringIndex(
- Font *font,
- const CFFIndex &char_strings_index,
+bool ValidateCFFCharStrings(
+ OpenTypeCFF& cff,
const CFFIndex &global_subrs_index,
- const std::map<uint16_t, uint8_t> &fd_select,
- const std::vector<CFFIndex *> &local_subrs_per_font,
- const CFFIndex *local_subrs,
Buffer *cff_table);
// The list of Operators. See Appendix. A in Adobe Technical Note #5177.
-enum Type2CharStringOperator {
+// and https://docs.microsoft.com/en-us/typography/opentype/spec/cff2charstr
+enum CharStringOperator {
kHStem = 1,
kVStem = 3,
kVMoveTo = 4,
@@ -55,6 +55,8 @@ enum Type2CharStringOperator {
kCallSubr = 10,
kReturn = 11,
kEndChar = 14,
+ kVSIndex = 15,
+ kBlend = 16,
kHStemHm = 18,
kHintMask = 19,
kCntrMask = 20,
diff --git a/gfx/ots/src/cmap.cc b/gfx/ots/src/cmap.cc
index 325f8e0d1..72c2a20fc 100644
--- a/gfx/ots/src/cmap.cc
+++ b/gfx/ots/src/cmap.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,8 +15,6 @@
// cmap - Character To Glyph Index Mapping Table
// http://www.microsoft.com/typography/otspec/cmap.htm
-#define TABLE_NAME "cmap"
-
namespace {
struct CMAPSubtableHeader {
@@ -56,8 +54,12 @@ const uint32_t kIVSStart = 0xE0100;
const uint32_t kIVSEnd = 0xE01EF;
const uint32_t kUVSUpperLimit = 0xFFFFFF;
+} // namespace
+
+namespace ots {
+
// Parses Format 4 tables
-bool ParseFormat4(ots::Font *font, int platform, int encoding,
+bool OpenTypeCMAP::ParseFormat4(int platform, int encoding,
const uint8_t *data, size_t length, uint16_t num_glyphs) {
ots::Buffer subtable(data, length);
@@ -65,20 +67,22 @@ bool ParseFormat4(ots::Font *font, int platform, int encoding,
// whole thing and recompacting it, we validate it and include it verbatim
// in the output.
- if (!font->os2) {
- return OTS_FAILURE_MSG("Required OS/2 table missing");
+ OpenTypeOS2 *os2 = static_cast<OpenTypeOS2*>(
+ GetFont()->GetTypedTable(OTS_TAG_OS2));
+ if (!os2) {
+ return Error("Required OS/2 table missing");
}
if (!subtable.Skip(4)) {
- return OTS_FAILURE_MSG("Can't read 4 bytes at start of cmap format 4 subtable");
+ return Error("Can't read 4 bytes at start of cmap format 4 subtable");
}
uint16_t language = 0;
if (!subtable.ReadU16(&language)) {
- return OTS_FAILURE_MSG("Can't read language");
+ return Error("Can't read language");
}
if (language) {
// Platform ID 3 (windows) subtables should have language '0'.
- return OTS_FAILURE_MSG("Languages should be 0 (%d)", language);
+ return Error("Languages should be 0 (%d)", language);
}
uint16_t segcountx2, search_range, entry_selector, range_shift;
@@ -87,16 +91,16 @@ bool ParseFormat4(ots::Font *font, int platform, int encoding,
!subtable.ReadU16(&search_range) ||
!subtable.ReadU16(&entry_selector) ||
!subtable.ReadU16(&range_shift)) {
- return OTS_FAILURE_MSG("Failed to read subcmap structure");
+ return Error("Failed to read subcmap structure");
}
if (segcountx2 & 1 || search_range & 1) {
- return OTS_FAILURE_MSG("Bad subcmap structure");
+ return Error("Bad subcmap structure");
}
const uint16_t segcount = segcountx2 >> 1;
// There must be at least one segment according the spec.
if (segcount < 1) {
- return OTS_FAILURE_MSG("Segcount < 1 (%d)", segcount);
+ return Error("Segcount < 1 (%d)", segcount);
}
// log2segcount is the maximal x s.t. 2^x < segcount
@@ -107,48 +111,48 @@ bool ParseFormat4(ots::Font *font, int platform, int encoding,
const uint16_t expected_search_range = 2 * 1u << log2segcount;
if (expected_search_range != search_range) {
- return OTS_FAILURE_MSG("expected search range != search range (%d != %d)", expected_search_range, search_range);
+ return Error("expected search range != search range (%d != %d)", expected_search_range, search_range);
}
if (entry_selector != log2segcount) {
- return OTS_FAILURE_MSG("entry selector != log2(segement count) (%d != %d)", entry_selector, log2segcount);
+ return Error("entry selector != log2(segement count) (%d != %d)", entry_selector, log2segcount);
}
const uint16_t expected_range_shift = segcountx2 - search_range;
if (range_shift != expected_range_shift) {
- return OTS_FAILURE_MSG("unexpected range shift (%d != %d)", range_shift, expected_range_shift);
+ return Error("unexpected range shift (%d != %d)", range_shift, expected_range_shift);
}
std::vector<Subtable314Range> ranges(segcount);
for (unsigned i = 0; i < segcount; ++i) {
if (!subtable.ReadU16(&ranges[i].end_range)) {
- return OTS_FAILURE_MSG("Failed to read segment %d", i);
+ return Error("Failed to read segment %d", i);
}
}
uint16_t padding;
if (!subtable.ReadU16(&padding)) {
- return OTS_FAILURE_MSG("Failed to read cmap subtable segment padding");
+ return Error("Failed to read cmap subtable segment padding");
}
if (padding) {
- return OTS_FAILURE_MSG("Non zero cmap subtable segment padding (%d)", padding);
+ return Error("Non zero cmap subtable segment padding (%d)", padding);
}
for (unsigned i = 0; i < segcount; ++i) {
if (!subtable.ReadU16(&ranges[i].start_range)) {
- return OTS_FAILURE_MSG("Failed to read segment start range %d", i);
+ return Error("Failed to read segment start range %d", i);
}
}
for (unsigned i = 0; i < segcount; ++i) {
if (!subtable.ReadS16(&ranges[i].id_delta)) {
- return OTS_FAILURE_MSG("Failed to read segment delta %d", i);
+ return Error("Failed to read segment delta %d", i);
}
}
for (unsigned i = 0; i < segcount; ++i) {
ranges[i].id_range_offset_offset = subtable.offset();
if (!subtable.ReadU16(&ranges[i].id_range_offset)) {
- return OTS_FAILURE_MSG("Failed to read segment range offset %d", i);
+ return Error("Failed to read segment range offset %d", i);
}
if (ranges[i].id_range_offset & 1) {
@@ -156,12 +160,12 @@ bool ParseFormat4(ots::Font *font, int platform, int encoding,
// for 0xFFFF-0xFFFF range.
// (e.g., many fonts in http://www.princexml.com/fonts/)
if (i == segcount - 1u) {
- OTS_WARNING("bad id_range_offset");
+ Warning("bad id_range_offset");
ranges[i].id_range_offset = 0;
// The id_range_offset value in the transcoded font will not change
// since this table is not actually "transcoded" yet.
} else {
- return OTS_FAILURE_MSG("Bad segment offset (%d)", ranges[i].id_range_offset);
+ return Error("Bad segment offset (%d)", ranges[i].id_range_offset);
}
}
}
@@ -176,36 +180,36 @@ bool ParseFormat4(ots::Font *font, int platform, int encoding,
(ranges[i].end_range == 0xffff)) {
// Some fonts (e.g., Germania.ttf) have multiple 0xffff terminators.
// We'll accept them as an exception.
- OTS_WARNING("multiple 0xffff terminators found");
+ Warning("multiple 0xffff terminators found");
continue;
}
// Note: some Linux fonts (e.g., LucidaSansOblique.ttf, bsmi00lp.ttf) have
// unsorted table...
if (ranges[i].end_range <= ranges[i - 1].end_range) {
- return OTS_FAILURE_MSG("Out of order end range (%d <= %d)", ranges[i].end_range, ranges[i-1].end_range);
+ return Error("Out of order end range (%d <= %d)", ranges[i].end_range, ranges[i-1].end_range);
}
if (ranges[i].start_range <= ranges[i - 1].end_range) {
- return OTS_FAILURE_MSG("out of order start range (%d <= %d)", ranges[i].start_range, ranges[i-1].end_range);
+ return Error("out of order start range (%d <= %d)", ranges[i].start_range, ranges[i-1].end_range);
}
// On many fonts, the value of {first, last}_char_index are incorrect.
// Fix them.
- if (font->os2->first_char_index != 0xFFFF &&
+ if (os2->table.first_char_index != 0xFFFF &&
ranges[i].start_range != 0xFFFF &&
- font->os2->first_char_index > ranges[i].start_range) {
- font->os2->first_char_index = ranges[i].start_range;
+ os2->table.first_char_index > ranges[i].start_range) {
+ os2->table.first_char_index = ranges[i].start_range;
}
- if (font->os2->last_char_index != 0xFFFF &&
+ if (os2->table.last_char_index != 0xFFFF &&
ranges[i].end_range != 0xFFFF &&
- font->os2->last_char_index < ranges[i].end_range) {
- font->os2->last_char_index = ranges[i].end_range;
+ os2->table.last_char_index < ranges[i].end_range) {
+ os2->table.last_char_index = ranges[i].end_range;
}
}
// The last range must end at 0xffff
if (ranges[segcount - 1].start_range != 0xffff || ranges[segcount - 1].end_range != 0xffff) {
- return OTS_FAILURE_MSG("Final segment start and end must be 0xFFFF (0x%04X-0x%04X)",
+ return Error("Final segment start and end must be 0xFFFF (0x%04X-0x%04X)",
ranges[segcount - 1].start_range, ranges[segcount - 1].end_range);
}
@@ -219,7 +223,7 @@ bool ParseFormat4(ots::Font *font, int platform, int encoding,
// this is explictly allowed to overflow in the spec
const uint16_t glyph = code_point + ranges[i].id_delta;
if (glyph >= num_glyphs) {
- return OTS_FAILURE_MSG("Range glyph reference too high (%d > %d)", glyph, num_glyphs - 1);
+ return Error("Range glyph reference too high (%d > %d)", glyph, num_glyphs - 1);
}
} else {
const uint16_t range_delta = code_point - ranges[i].start_range;
@@ -230,13 +234,13 @@ bool ParseFormat4(ots::Font *font, int platform, int encoding,
range_delta * 2;
// We need to be able to access a 16-bit value from this offset
if (glyph_id_offset + 1 >= length) {
- return OTS_FAILURE_MSG("bad glyph id offset (%d > %ld)", glyph_id_offset, length);
+ return Error("bad glyph id offset (%d > %ld)", glyph_id_offset, length);
}
uint16_t glyph;
std::memcpy(&glyph, data + glyph_id_offset, 2);
- glyph = ntohs(glyph);
+ glyph = ots_ntohs(glyph);
if (glyph >= num_glyphs) {
- return OTS_FAILURE_MSG("Range glyph reference too high (%d > %d)", glyph, num_glyphs - 1);
+ return Error("Range glyph reference too high (%d > %d)", glyph, num_glyphs - 1);
}
}
}
@@ -245,85 +249,85 @@ bool ParseFormat4(ots::Font *font, int platform, int encoding,
// We accept the table.
// TODO(yusukes): transcode the subtable.
if (platform == 3 && encoding == 0) {
- font->cmap->subtable_3_0_4_data = data;
- font->cmap->subtable_3_0_4_length = length;
+ this->subtable_3_0_4_data = data;
+ this->subtable_3_0_4_length = length;
} else if (platform == 3 && encoding == 1) {
- font->cmap->subtable_3_1_4_data = data;
- font->cmap->subtable_3_1_4_length = length;
+ this->subtable_3_1_4_data = data;
+ this->subtable_3_1_4_length = length;
} else if (platform == 0 && encoding == 3) {
- font->cmap->subtable_0_3_4_data = data;
- font->cmap->subtable_0_3_4_length = length;
+ this->subtable_0_3_4_data = data;
+ this->subtable_0_3_4_length = length;
} else {
- return OTS_FAILURE_MSG("Unknown cmap subtable type (platform=%d, encoding=%d)", platform, encoding);
+ return Error("Unknown cmap subtable type (platform=%d, encoding=%d)", platform, encoding);
}
return true;
}
-bool Parse31012(ots::Font *font,
- const uint8_t *data, size_t length, uint16_t num_glyphs) {
+bool OpenTypeCMAP::Parse31012(const uint8_t *data, size_t length,
+ uint16_t num_glyphs) {
ots::Buffer subtable(data, length);
// Format 12 tables are simple. We parse these and fully serialise them
// later.
if (!subtable.Skip(8)) {
- return OTS_FAILURE_MSG("failed to skip the first 8 bytes of format 12 subtable");
+ return Error("failed to skip the first 8 bytes of format 12 subtable");
}
uint32_t language = 0;
if (!subtable.ReadU32(&language)) {
- return OTS_FAILURE_MSG("can't read format 12 subtable language");
+ return Error("can't read format 12 subtable language");
}
if (language) {
- return OTS_FAILURE_MSG("format 12 subtable language should be zero (%d)", language);
+ return Error("format 12 subtable language should be zero (%d)", language);
}
uint32_t num_groups = 0;
if (!subtable.ReadU32(&num_groups)) {
- return OTS_FAILURE_MSG("can't read number of format 12 subtable groups");
+ return Error("can't read number of format 12 subtable groups");
}
if (num_groups == 0 || subtable.remaining() / 12 < num_groups) {
- return OTS_FAILURE_MSG("Bad format 12 subtable group count %d", num_groups);
+ return Error("Bad format 12 subtable group count %d", num_groups);
}
std::vector<ots::OpenTypeCMAPSubtableRange> &groups
- = font->cmap->subtable_3_10_12;
+ = this->subtable_3_10_12;
groups.resize(num_groups);
for (unsigned i = 0; i < num_groups; ++i) {
if (!subtable.ReadU32(&groups[i].start_range) ||
!subtable.ReadU32(&groups[i].end_range) ||
!subtable.ReadU32(&groups[i].start_glyph_id)) {
- return OTS_FAILURE_MSG("can't read format 12 subtable group");
+ return Error("can't read format 12 subtable group");
}
if (groups[i].start_range > kUnicodeUpperLimit ||
groups[i].end_range > kUnicodeUpperLimit ||
groups[i].start_glyph_id > 0xFFFF) {
- return OTS_FAILURE_MSG("bad format 12 subtable group (startCharCode=0x%4X, endCharCode=0x%4X, startGlyphID=%d)",
+ return Error("bad format 12 subtable group (startCharCode=0x%4X, endCharCode=0x%4X, startGlyphID=%d)",
groups[i].start_range, groups[i].end_range, groups[i].start_glyph_id);
}
// We assert that the glyph value is within range. Because of the range
// limits, above, we don't need to worry about overflow.
if (groups[i].end_range < groups[i].start_range) {
- return OTS_FAILURE_MSG("format 12 subtable group endCharCode before startCharCode (0x%4X < 0x%4X)",
+ return Error("format 12 subtable group endCharCode before startCharCode (0x%4X < 0x%4X)",
groups[i].end_range, groups[i].start_range);
}
if ((groups[i].end_range - groups[i].start_range) +
groups[i].start_glyph_id > num_glyphs) {
- return OTS_FAILURE_MSG("bad format 12 subtable group startGlyphID (%d)", groups[i].start_glyph_id);
+ return Error("bad format 12 subtable group startGlyphID (%d)", groups[i].start_glyph_id);
}
}
// the groups must be sorted by start code and may not overlap
for (unsigned i = 1; i < num_groups; ++i) {
if (groups[i].start_range <= groups[i - 1].start_range) {
- return OTS_FAILURE_MSG("out of order format 12 subtable group (startCharCode=0x%4X <= startCharCode=0x%4X of previous group)",
+ return Error("out of order format 12 subtable group (startCharCode=0x%4X <= startCharCode=0x%4X of previous group)",
groups[i].start_range, groups[i-1].start_range);
}
if (groups[i].start_range <= groups[i - 1].end_range) {
- return OTS_FAILURE_MSG("overlapping format 12 subtable groups (startCharCode=0x%4X <= endCharCode=0x%4X of previous group)",
+ return Error("overlapping format 12 subtable groups (startCharCode=0x%4X <= endCharCode=0x%4X of previous group)",
groups[i].start_range, groups[i-1].end_range);
}
}
@@ -331,44 +335,43 @@ bool Parse31012(ots::Font *font,
return true;
}
-bool Parse31013(ots::Font *font,
- const uint8_t *data, size_t length, uint16_t num_glyphs) {
+bool OpenTypeCMAP::Parse31013(const uint8_t *data, size_t length,
+ uint16_t num_glyphs) {
ots::Buffer subtable(data, length);
// Format 13 tables are simple. We parse these and fully serialise them
// later.
if (!subtable.Skip(8)) {
- return OTS_FAILURE_MSG("Bad cmap subtable length");
+ return Error("Bad cmap subtable length");
}
uint32_t language = 0;
if (!subtable.ReadU32(&language)) {
- return OTS_FAILURE_MSG("Can't read cmap subtable language");
+ return Error("Can't read cmap subtable language");
}
if (language) {
- return OTS_FAILURE_MSG("Cmap subtable language should be zero but is %d", language);
+ return Error("Cmap subtable language should be zero but is %d", language);
}
uint32_t num_groups = 0;
if (!subtable.ReadU32(&num_groups)) {
- return OTS_FAILURE_MSG("Can't read number of groups in a cmap subtable");
+ return Error("Can't read number of groups in a cmap subtable");
}
// We limit the number of groups in the same way as in 3.10.12 tables. See
// the comment there in
if (num_groups == 0 || subtable.remaining() / 12 < num_groups) {
- return OTS_FAILURE_MSG("Bad format 13 subtable group count %d", num_groups);
+ return Error("Bad format 13 subtable group count %d", num_groups);
}
- std::vector<ots::OpenTypeCMAPSubtableRange> &groups
- = font->cmap->subtable_3_10_13;
+ std::vector<ots::OpenTypeCMAPSubtableRange> &groups = this->subtable_3_10_13;
groups.resize(num_groups);
for (unsigned i = 0; i < num_groups; ++i) {
if (!subtable.ReadU32(&groups[i].start_range) ||
!subtable.ReadU32(&groups[i].end_range) ||
!subtable.ReadU32(&groups[i].start_glyph_id)) {
- return OTS_FAILURE_MSG("Can't read subrange structure in a cmap subtable");
+ return Error("Can't read subrange structure in a cmap subtable");
}
// We conservatively limit all of the values to protect some parsers from
@@ -376,29 +379,29 @@ bool Parse31013(ots::Font *font,
if (groups[i].start_range > kUnicodeUpperLimit ||
groups[i].end_range > kUnicodeUpperLimit ||
groups[i].start_glyph_id > 0xFFFF) {
- return OTS_FAILURE_MSG("Bad subrange with start_range=%d, end_range=%d, start_glyph_id=%d", groups[i].start_range, groups[i].end_range, groups[i].start_glyph_id);
+ return Error("Bad subrange with start_range=%d, end_range=%d, start_glyph_id=%d", groups[i].start_range, groups[i].end_range, groups[i].start_glyph_id);
}
if (groups[i].start_glyph_id >= num_glyphs) {
- return OTS_FAILURE_MSG("Subrange starting glyph id too high (%d > %d)", groups[i].start_glyph_id, num_glyphs);
+ return Error("Subrange starting glyph id too high (%d > %d)", groups[i].start_glyph_id, num_glyphs);
}
}
// the groups must be sorted by start code and may not overlap
for (unsigned i = 1; i < num_groups; ++i) {
if (groups[i].start_range <= groups[i - 1].start_range) {
- return OTS_FAILURE_MSG("Overlapping subrange starts (%d >= %d)", groups[i]. start_range, groups[i-1].start_range);
+ return Error("Overlapping subrange starts (%d >= %d)", groups[i]. start_range, groups[i-1].start_range);
}
if (groups[i].start_range <= groups[i - 1].end_range) {
- return OTS_FAILURE_MSG("Overlapping subranges (%d <= %d)", groups[i].start_range, groups[i-1].end_range);
+ return Error("Overlapping subranges (%d <= %d)", groups[i].start_range, groups[i-1].end_range);
}
}
return true;
}
-bool Parse0514(ots::Font *font,
- const uint8_t *data, size_t length, uint16_t num_glyphs) {
+bool OpenTypeCMAP::Parse0514(const uint8_t *data, size_t length,
+ uint16_t num_glyphs) {
// Unicode Variation Selector table
ots::Buffer subtable(data, length);
@@ -407,26 +410,26 @@ bool Parse0514(ots::Font *font,
// Skip format (USHORT) and length (ULONG)
if (!subtable.Skip(6)) {
- return OTS_FAILURE_MSG("Can't read start of cmap subtable");
+ return Error("Can't read start of cmap subtable");
}
uint32_t num_records = 0;
if (!subtable.ReadU32(&num_records)) {
- return OTS_FAILURE_MSG("Can't read number of records in cmap subtable");
+ return Error("Can't read number of records in cmap subtable");
}
if (num_records == 0 || num_records > kMaxCMAPSelectorRecords) {
- return OTS_FAILURE_MSG("Bad format 14 subtable records count %d", num_records);
+ return Error("Bad format 14 subtable records count %d", num_records);
}
std::vector<ots::OpenTypeCMAPSubtableVSRecord>& records
- = font->cmap->subtable_0_5_14;
+ = this->subtable_0_5_14;
records.resize(num_records);
for (unsigned i = 0; i < num_records; ++i) {
if (!subtable.ReadU24(&records[i].var_selector) ||
!subtable.ReadU32(&records[i].default_offset) ||
!subtable.ReadU32(&records[i].non_default_offset)) {
- return OTS_FAILURE_MSG("Can't read record structure of record %d in cmap subtale", i);
+ return Error("Can't read record structure of record %d in cmap subtale", i);
}
// Checks the value of variation selector
if (!((records[i].var_selector >= kMongolianVSStart &&
@@ -435,24 +438,24 @@ bool Parse0514(ots::Font *font,
records[i].var_selector <= kVSEnd) ||
(records[i].var_selector >= kIVSStart &&
records[i].var_selector <= kIVSEnd))) {
- return OTS_FAILURE_MSG("Bad record variation selector (%04X) in record %i", records[i].var_selector, i);
+ return Error("Bad record variation selector (%04X) in record %i", records[i].var_selector, i);
}
if (i > 0 &&
records[i-1].var_selector >= records[i].var_selector) {
- return OTS_FAILURE_MSG("Out of order variation selector (%04X >= %04X) in record %d", records[i-1].var_selector, records[i].var_selector, i);
+ return Error("Out of order variation selector (%04X >= %04X) in record %d", records[i-1].var_selector, records[i].var_selector, i);
}
// Checks offsets
if (!records[i].default_offset && !records[i].non_default_offset) {
- return OTS_FAILURE_MSG("No default aoffset in variation selector record %d", i);
+ return Error("No default aoffset in variation selector record %d", i);
}
if (records[i].default_offset &&
records[i].default_offset >= length) {
- return OTS_FAILURE_MSG("Default offset too high (%d >= %ld) in record %d", records[i].default_offset, length, i);
+ return Error("Default offset too high (%d >= %ld) in record %d", records[i].default_offset, length, i);
}
if (records[i].non_default_offset &&
records[i].non_default_offset >= length) {
- return OTS_FAILURE_MSG("Non default offset too high (%d >= %ld) in record %d", records[i].non_default_offset, length, i);
+ return Error("Non default offset too high (%d >= %ld) in record %d", records[i].non_default_offset, length, i);
}
}
@@ -462,10 +465,10 @@ bool Parse0514(ots::Font *font,
subtable.set_offset(records[i].default_offset);
uint32_t num_ranges = 0;
if (!subtable.ReadU32(&num_ranges)) {
- return OTS_FAILURE_MSG("Can't read number of ranges in record %d", i);
+ return Error("Can't read number of ranges in record %d", i);
}
if (num_ranges == 0 || subtable.remaining() / 4 < num_ranges) {
- return OTS_FAILURE_MSG("Bad number of ranges (%d) in record %d", num_ranges, i);
+ return Error("Bad number of ranges (%d) in record %d", num_ranges, i);
}
uint32_t last_unicode_value = 0;
@@ -476,7 +479,7 @@ bool Parse0514(ots::Font *font,
for (unsigned j = 0; j < num_ranges; ++j) {
if (!subtable.ReadU24(&ranges[j].unicode_value) ||
!subtable.ReadU8(&ranges[j].additional_count)) {
- return OTS_FAILURE_MSG("Can't read range info in variation selector record %d", i);
+ return Error("Can't read range info in variation selector record %d", i);
}
const uint32_t check_value =
ranges[j].unicode_value + ranges[j].additional_count;
@@ -485,7 +488,7 @@ bool Parse0514(ots::Font *font,
check_value > kUVSUpperLimit ||
(last_unicode_value &&
ranges[j].unicode_value <= last_unicode_value)) {
- return OTS_FAILURE_MSG("Bad Unicode value *%04X) in variation selector range %d record %d", ranges[j].unicode_value, j, i);
+ return Error("Bad Unicode value *%04X) in variation selector range %d record %d", ranges[j].unicode_value, j, i);
}
last_unicode_value = check_value;
}
@@ -496,10 +499,10 @@ bool Parse0514(ots::Font *font,
subtable.set_offset(records[i].non_default_offset);
uint32_t num_mappings = 0;
if (!subtable.ReadU32(&num_mappings)) {
- return OTS_FAILURE_MSG("Can't read number of mappings in variation selector record %d", i);
+ return Error("Can't read number of mappings in variation selector record %d", i);
}
if (num_mappings == 0 || subtable.remaining() / 5 < num_mappings) {
- return OTS_FAILURE_MSG("Bad number of mappings (%d) in variation selector record %d", num_mappings, i);
+ return Error("Bad number of mappings (%d) in variation selector record %d", num_mappings, i);
}
uint32_t last_unicode_value = 0;
@@ -510,14 +513,14 @@ bool Parse0514(ots::Font *font,
for (unsigned j = 0; j < num_mappings; ++j) {
if (!subtable.ReadU24(&mappings[j].unicode_value) ||
!subtable.ReadU16(&mappings[j].glyph_id)) {
- return OTS_FAILURE_MSG("Can't read mapping %d in variation selector record %d", j, i);
+ return Error("Can't read mapping %d in variation selector record %d", j, i);
}
if (mappings[j].glyph_id == 0 ||
mappings[j].unicode_value == 0 ||
mappings[j].unicode_value > kUnicodeUpperLimit ||
(last_unicode_value &&
mappings[j].unicode_value <= last_unicode_value)) {
- return OTS_FAILURE_MSG("Bad mapping (%04X -> %d) in mapping %d of variation selector %d", mappings[j].unicode_value, mappings[j].glyph_id, j, i);
+ return Error("Bad mapping (%04X -> %d) in mapping %d of variation selector %d", mappings[j].unicode_value, mappings[j].glyph_id, j, i);
}
last_unicode_value = mappings[j].unicode_value;
}
@@ -525,60 +528,55 @@ bool Parse0514(ots::Font *font,
}
if (subtable.offset() != length) {
- return OTS_FAILURE_MSG("Bad subtable offset (%ld != %ld)", subtable.offset(), length);
+ return Error("Bad subtable offset (%ld != %ld)", subtable.offset(), length);
}
- font->cmap->subtable_0_5_14_length = subtable.offset();
+ this->subtable_0_5_14_length = subtable.offset();
return true;
}
-bool Parse100(ots::Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeCMAP::Parse100(const uint8_t *data, size_t length) {
// Mac Roman table
ots::Buffer subtable(data, length);
if (!subtable.Skip(4)) {
- return OTS_FAILURE_MSG("Bad cmap subtable");
+ return Error("Bad cmap subtable");
}
uint16_t language = 0;
if (!subtable.ReadU16(&language)) {
- return OTS_FAILURE_MSG("Can't read language in cmap subtable");
+ return Error("Can't read language in cmap subtable");
}
if (language) {
// simsun.ttf has non-zero language id.
- OTS_WARNING("language id should be zero: %u", language);
+ Warning("language id should be zero: %u", language);
}
- font->cmap->subtable_1_0_0.reserve(kFormat0ArraySize);
+ this->subtable_1_0_0.reserve(kFormat0ArraySize);
for (size_t i = 0; i < kFormat0ArraySize; ++i) {
uint8_t glyph_id = 0;
if (!subtable.ReadU8(&glyph_id)) {
- return OTS_FAILURE_MSG("Can't read glyph id at array[%ld] in cmap subtable", i);
+ return Error("Can't read glyph id at array[%ld] in cmap subtable", i);
}
- font->cmap->subtable_1_0_0.push_back(glyph_id);
+ this->subtable_1_0_0.push_back(glyph_id);
}
return true;
}
-} // namespace
-
-namespace ots {
-
-bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeCMAP::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- font->cmap = new OpenTypeCMAP;
uint16_t version = 0;
uint16_t num_tables = 0;
if (!table.ReadU16(&version) ||
!table.ReadU16(&num_tables)) {
- return OTS_FAILURE_MSG("Can't read structure of cmap");
+ return Error("Can't read structure of cmap");
}
if (version != 0) {
- return OTS_FAILURE_MSG("Non zero cmap version (%d)", version);
+ return Error("Non zero cmap version (%d)", version);
}
if (!num_tables) {
- return OTS_FAILURE_MSG("No subtables in cmap!");
+ return Error("No subtables in cmap!");
}
std::vector<CMAPSubtableHeader> subtable_headers;
@@ -591,7 +589,7 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
if (!table.ReadU16(&subt.platform) ||
!table.ReadU16(&subt.encoding) ||
!table.ReadU32(&subt.offset)) {
- return OTS_FAILURE_MSG("Can't read subtable information cmap subtable %d", i);
+ return Error("Can't read subtable information cmap subtable %d", i);
}
subtable_headers.push_back(subt);
@@ -602,11 +600,11 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
// make sure that all the offsets are valid.
for (unsigned i = 0; i < num_tables; ++i) {
if (subtable_headers[i].offset > 1024 * 1024 * 1024) {
- return OTS_FAILURE_MSG("Bad subtable offset in cmap subtable %d", i);
+ return Error("Bad subtable offset in cmap subtable %d", i);
}
if (subtable_headers[i].offset < data_offset ||
subtable_headers[i].offset >= length) {
- return OTS_FAILURE_MSG("Bad subtable offset (%d) in cmap subtable %d", subtable_headers[i].offset, i);
+ return Error("Bad subtable offset (%d) in cmap subtable %d", subtable_headers[i].offset, i);
}
}
@@ -615,7 +613,7 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
for (unsigned i = 0; i < num_tables; ++i) {
table.set_offset(subtable_headers[i].offset);
if (!table.ReadU16(&subtable_headers[i].format)) {
- return OTS_FAILURE_MSG("Can't read cmap subtable header format %d", i);
+ return Error("Can't read cmap subtable header format %d", i);
}
uint16_t len = 0;
@@ -624,10 +622,10 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
case 0:
case 4:
if (!table.ReadU16(&len)) {
- return OTS_FAILURE_MSG("Can't read cmap subtable %d length", i);
+ return Error("Can't read cmap subtable %d length", i);
}
if (!table.ReadU16(&lang)) {
- return OTS_FAILURE_MSG("Can't read cmap subtable %d language", i);
+ return Error("Can't read cmap subtable %d language", i);
}
subtable_headers[i].length = len;
subtable_headers[i].language = lang;
@@ -635,18 +633,18 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
case 12:
case 13:
if (!table.Skip(2)) {
- return OTS_FAILURE_MSG("Bad cmap subtable %d structure", i);
+ return Error("Bad cmap subtable %d structure", i);
}
if (!table.ReadU32(&subtable_headers[i].length)) {
- return OTS_FAILURE_MSG("Can read cmap subtable %d length", i);
+ return Error("Can read cmap subtable %d length", i);
}
if (!table.ReadU32(&subtable_headers[i].language)) {
- return OTS_FAILURE_MSG("Can't read cmap subtable %d language", i);
+ return Error("Can't read cmap subtable %d language", i);
}
break;
case 14:
if (!table.ReadU32(&subtable_headers[i].length)) {
- return OTS_FAILURE_MSG("Can't read cmap subtable %d length", i);
+ return Error("Can't read cmap subtable %d length", i);
}
subtable_headers[i].language = 0;
break;
@@ -664,7 +662,7 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
(subtable_headers[i - 1].encoding > subtable_headers[i].encoding ||
(subtable_headers[i - 1].encoding == subtable_headers[i].encoding &&
subtable_headers[i - 1].language > subtable_headers[i].language))))
- OTS_WARNING("subtable %d with platform ID %d, encoding ID %d, language ID %d "
+ Warning("subtable %d with platform ID %d, encoding ID %d, language ID %d "
"following subtable with platform ID %d, encoding ID %d, language ID %d",
i,
subtable_headers[i].platform,
@@ -679,14 +677,14 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
for (unsigned i = 0; i < num_tables; ++i) {
if (!subtable_headers[i].length) continue;
if (subtable_headers[i].length > 1024 * 1024 * 1024) {
- return OTS_FAILURE_MSG("Bad cmap subtable %d length", i);
+ return Error("Bad cmap subtable %d length", i);
}
// We know that both the offset and length are < 1GB, so the following
// addition doesn't overflow
const uint32_t end_byte
= subtable_headers[i].offset + subtable_headers[i].length;
if (end_byte > length) {
- return OTS_FAILURE_MSG("Over long cmap subtable %d @ %d for %d", i, subtable_headers[i].offset, subtable_headers[i].length);
+ return Error("Over long cmap subtable %d @ %d for %d", i, subtable_headers[i].offset, subtable_headers[i].length);
}
}
@@ -714,16 +712,18 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
for (unsigned i = 0; i < overlap_checker.size(); ++i) {
overlap_count += (overlap_checker[i].second ? 1 : -1);
if (overlap_count > 1) {
- return OTS_FAILURE_MSG("Excessive overlap count %d", overlap_count);
+ return Error("Excessive overlap count %d", overlap_count);
}
}
// we grab the number of glyphs in the file from the maxp table to make sure
// that the character map isn't referencing anything beyound this range.
- if (!font->maxp) {
- return OTS_FAILURE_MSG("No maxp table in font! Needed by cmap.");
+ OpenTypeMAXP *maxp = static_cast<OpenTypeMAXP*>(
+ GetFont()->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return Error("No maxp table in font! Needed by cmap.");
}
- const uint16_t num_glyphs = font->maxp->num_glyphs;
+ const uint16_t num_glyphs = maxp->num_glyphs;
// We only support a subset of the possible character map tables. Microsoft
// 'strongly recommends' that everyone supports the Unicode BMP table with
@@ -760,29 +760,30 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
// table actually points to MS symbol data and thus should be parsed as
// 3-0-4 table (e.g., marqueem.ttf and quixotic.ttf). This error will be
// recovered in ots_cmap_serialise().
- if (!ParseFormat4(font, 3, 1, data + subtable_headers[i].offset,
+ if (!ParseFormat4(3, 1, data + subtable_headers[i].offset,
subtable_headers[i].length, num_glyphs)) {
- return OTS_FAILURE_MSG("Failed to parse format 4 cmap subtable %d", i);
+ return Error("Failed to parse format 4 cmap subtable %d", i);
}
} else if ((subtable_headers[i].encoding == 3) &&
(subtable_headers[i].format == 4)) {
// parse and output the 0-3-4 table as 0-3-4 table.
- if (!ParseFormat4(font, 0, 3, data + subtable_headers[i].offset,
+ if (!ParseFormat4(0, 3, data + subtable_headers[i].offset,
subtable_headers[i].length, num_glyphs)) {
- return OTS_FAILURE_MSG("Failed to parse format 4 cmap subtable %d", i);
+ return Error("Failed to parse format 4 cmap subtable %d", i);
}
- } else if ((subtable_headers[i].encoding == 3) &&
+ } else if ((subtable_headers[i].encoding == 3 ||
+ subtable_headers[i].encoding == 4) &&
(subtable_headers[i].format == 12)) {
- // parse and output the 0-3-12 table as 3-10-12 table.
- if (!Parse31012(font, data + subtable_headers[i].offset,
+ // parse and output the 0-3-12 or 0-4-12 tables as 3-10-12 table.
+ if (!Parse31012(data + subtable_headers[i].offset,
subtable_headers[i].length, num_glyphs)) {
- return OTS_FAILURE_MSG("Failed to parse format 12 cmap subtable %d", i);
+ return Error("Failed to parse format 12 cmap subtable %d", i);
}
} else if ((subtable_headers[i].encoding == 5) &&
(subtable_headers[i].format == 14)) {
- if (!Parse0514(font, data + subtable_headers[i].offset,
+ if (!Parse0514(data + subtable_headers[i].offset,
subtable_headers[i].length, num_glyphs)) {
- return OTS_FAILURE_MSG("Failed to parse format 14 cmap subtable %d", i);
+ return Error("Failed to parse format 14 cmap subtable %d", i);
}
}
} else if (subtable_headers[i].platform == 1) {
@@ -791,7 +792,7 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
if ((subtable_headers[i].encoding == 0) &&
(subtable_headers[i].format == 0)) {
// parse and output the 1-0-0 table.
- if (!Parse100(font, data + subtable_headers[i].offset,
+ if (!Parse100(data + subtable_headers[i].offset,
subtable_headers[i].length)) {
return OTS_FAILURE();
}
@@ -804,7 +805,7 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
case 1:
if (subtable_headers[i].format == 4) {
// parse 3-0-4 or 3-1-4 table.
- if (!ParseFormat4(font, subtable_headers[i].platform,
+ if (!ParseFormat4(subtable_headers[i].platform,
subtable_headers[i].encoding,
data + subtable_headers[i].offset,
subtable_headers[i].length, num_glyphs)) {
@@ -814,14 +815,14 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
break;
case 10:
if (subtable_headers[i].format == 12) {
- font->cmap->subtable_3_10_12.clear();
- if (!Parse31012(font, data + subtable_headers[i].offset,
+ this->subtable_3_10_12.clear();
+ if (!Parse31012(data + subtable_headers[i].offset,
subtable_headers[i].length, num_glyphs)) {
return OTS_FAILURE();
}
} else if (subtable_headers[i].format == 13) {
- font->cmap->subtable_3_10_13.clear();
- if (!Parse31013(font, data + subtable_headers[i].offset,
+ this->subtable_3_10_13.clear();
+ if (!Parse31013(data + subtable_headers[i].offset,
subtable_headers[i].length, num_glyphs)) {
return OTS_FAILURE();
}
@@ -834,20 +835,16 @@ bool ots_cmap_parse(Font *font, const uint8_t *data, size_t length) {
return true;
}
-bool ots_cmap_should_serialise(Font *font) {
- return font->cmap != NULL;
-}
-
-bool ots_cmap_serialise(OTSStream *out, Font *font) {
- const bool have_034 = font->cmap->subtable_0_3_4_data != NULL;
- const bool have_0514 = font->cmap->subtable_0_5_14.size() != 0;
- const bool have_100 = font->cmap->subtable_1_0_0.size() != 0;
- const bool have_304 = font->cmap->subtable_3_0_4_data != NULL;
+bool OpenTypeCMAP::Serialize(OTSStream *out) {
+ const bool have_034 = this->subtable_0_3_4_data != NULL;
+ const bool have_0514 = this->subtable_0_5_14.size() != 0;
+ const bool have_100 = this->subtable_1_0_0.size() != 0;
+ const bool have_304 = this->subtable_3_0_4_data != NULL;
// MS Symbol and MS Unicode tables should not co-exist.
// See the comment above in 0-0-4 parser.
- const bool have_314 = (!have_304) && font->cmap->subtable_3_1_4_data;
- const bool have_31012 = font->cmap->subtable_3_10_12.size() != 0;
- const bool have_31013 = font->cmap->subtable_3_10_13.size() != 0;
+ const bool have_314 = (!have_304) && this->subtable_3_1_4_data;
+ const bool have_31012 = this->subtable_3_10_12.size() != 0;
+ const bool have_31013 = this->subtable_3_10_13.size() != 0;
const uint16_t num_subtables = static_cast<uint16_t>(have_034) +
static_cast<uint16_t>(have_0514) +
static_cast<uint16_t>(have_100) +
@@ -860,7 +857,7 @@ bool ots_cmap_serialise(OTSStream *out, Font *font) {
// Some fonts don't have 3-0-4 MS Symbol nor 3-1-4 Unicode BMP tables
// (e.g., old fonts for Mac). We don't support them.
if (!have_304 && !have_314 && !have_034 && !have_31012 && !have_31013) {
- return OTS_FAILURE_MSG("no supported subtables were found");
+ return Error("no supported subtables were found");
}
if (!out->WriteU16(0) ||
@@ -875,8 +872,8 @@ bool ots_cmap_serialise(OTSStream *out, Font *font) {
const off_t offset_034 = out->Tell();
if (have_034) {
- if (!out->Write(font->cmap->subtable_0_3_4_data,
- font->cmap->subtable_0_3_4_length)) {
+ if (!out->Write(this->subtable_0_3_4_data,
+ this->subtable_0_3_4_length)) {
return OTS_FAILURE();
}
}
@@ -884,10 +881,10 @@ bool ots_cmap_serialise(OTSStream *out, Font *font) {
const off_t offset_0514 = out->Tell();
if (have_0514) {
const std::vector<ots::OpenTypeCMAPSubtableVSRecord> &records
- = font->cmap->subtable_0_5_14;
+ = this->subtable_0_5_14;
const unsigned num_records = records.size();
if (!out->WriteU16(14) ||
- !out->WriteU32(font->cmap->subtable_0_5_14_length) ||
+ !out->WriteU32(this->subtable_0_5_14_length) ||
!out->WriteU32(num_records)) {
return OTS_FAILURE();
}
@@ -939,23 +936,23 @@ bool ots_cmap_serialise(OTSStream *out, Font *font) {
!out->WriteU16(0)) { // language
return OTS_FAILURE();
}
- if (!out->Write(&(font->cmap->subtable_1_0_0[0]), kFormat0ArraySize)) {
+ if (!out->Write(&(this->subtable_1_0_0[0]), kFormat0ArraySize)) {
return OTS_FAILURE();
}
}
const off_t offset_304 = out->Tell();
if (have_304) {
- if (!out->Write(font->cmap->subtable_3_0_4_data,
- font->cmap->subtable_3_0_4_length)) {
+ if (!out->Write(this->subtable_3_0_4_data,
+ this->subtable_3_0_4_length)) {
return OTS_FAILURE();
}
}
const off_t offset_314 = out->Tell();
if (have_314) {
- if (!out->Write(font->cmap->subtable_3_1_4_data,
- font->cmap->subtable_3_1_4_length)) {
+ if (!out->Write(this->subtable_3_1_4_data,
+ this->subtable_3_1_4_length)) {
return OTS_FAILURE();
}
}
@@ -963,7 +960,7 @@ bool ots_cmap_serialise(OTSStream *out, Font *font) {
const off_t offset_31012 = out->Tell();
if (have_31012) {
std::vector<OpenTypeCMAPSubtableRange> &groups
- = font->cmap->subtable_3_10_12;
+ = this->subtable_3_10_12;
const unsigned num_groups = groups.size();
if (!out->WriteU16(12) ||
!out->WriteU16(0) ||
@@ -985,7 +982,7 @@ bool ots_cmap_serialise(OTSStream *out, Font *font) {
const off_t offset_31013 = out->Tell();
if (have_31013) {
std::vector<OpenTypeCMAPSubtableRange> &groups
- = font->cmap->subtable_3_10_13;
+ = this->subtable_3_10_13;
const unsigned num_groups = groups.size();
if (!out->WriteU16(13) ||
!out->WriteU16(0) ||
@@ -1074,15 +1071,4 @@ bool ots_cmap_serialise(OTSStream *out, Font *font) {
return true;
}
-void ots_cmap_reuse(Font *font, Font *other) {
- font->cmap = other->cmap;
- font->cmap_reused = true;
-}
-
-void ots_cmap_free(Font *font) {
- delete font->cmap;
-}
-
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/cmap.h b/gfx/ots/src/cmap.h
index 5b09556b7..feddbc696 100644
--- a/gfx/ots/src/cmap.h
+++ b/gfx/ots/src/cmap.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -35,9 +35,11 @@ struct OpenTypeCMAPSubtableVSRecord {
std::vector<OpenTypeCMAPSubtableVSMapping> mappings;
};
-struct OpenTypeCMAP {
- OpenTypeCMAP()
- : subtable_0_3_4_data(NULL),
+class OpenTypeCMAP : public Table {
+ public:
+ explicit OpenTypeCMAP(Font *font, uint32_t tag)
+ : Table(font, tag, tag),
+ subtable_0_3_4_data(NULL),
subtable_0_3_4_length(0),
subtable_0_5_14_length(0),
subtable_3_0_4_data(NULL),
@@ -46,6 +48,10 @@ struct OpenTypeCMAP {
subtable_3_1_4_length(0) {
}
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
+ private:
// Platform 0, Encoding 3, Format 4, Unicode BMP table.
const uint8_t *subtable_0_3_4_data;
size_t subtable_0_3_4_length;
@@ -67,6 +73,13 @@ struct OpenTypeCMAP {
std::vector<OpenTypeCMAPSubtableRange> subtable_3_10_13;
// Platform 1, Encoding 0, Format 0, Mac Roman table.
std::vector<uint8_t> subtable_1_0_0;
+
+ bool ParseFormat4(int platform, int encoding, const uint8_t *data,
+ size_t length, uint16_t num_glyphs);
+ bool Parse31012(const uint8_t *data, size_t length, uint16_t num_glyphs);
+ bool Parse31013(const uint8_t *data, size_t length, uint16_t num_glyphs);
+ bool Parse0514(const uint8_t *data, size_t length, uint16_t num_glyphs);
+ bool Parse100(const uint8_t *data, size_t length);
};
} // namespace ots
diff --git a/gfx/ots/src/cvar.cc b/gfx/ots/src/cvar.cc
new file mode 100644
index 000000000..a2bad7a15
--- /dev/null
+++ b/gfx/ots/src/cvar.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cvar.h"
+
+#include "fvar.h"
+#include "variations.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeCVAR
+// -----------------------------------------------------------------------------
+
+bool OpenTypeCVAR::Parse(const uint8_t* data, size_t length) {
+ Buffer table(data, length);
+
+ uint16_t majorVersion;
+ uint16_t minorVersion;
+
+ if (!table.ReadU16(&majorVersion) ||
+ !table.ReadU16(&minorVersion)) {
+ return Drop("Failed to read table header");
+ }
+
+ if (majorVersion != 1) {
+ return Drop("Unknown table version");
+ }
+
+ OpenTypeFVAR* fvar = static_cast<OpenTypeFVAR*>(
+ GetFont()->GetTypedTable(OTS_TAG_FVAR));
+ if (!fvar) {
+ return DropVariations("Required fvar table is missing");
+ }
+
+ if (!ParseVariationData(GetFont(), data + table.offset(), length - table.offset(),
+ fvar->AxisCount(), 0)) {
+ return Drop("Failed to parse variation data");
+ }
+
+ this->m_data = data;
+ this->m_length = length;
+
+ return true;
+}
+
+bool OpenTypeCVAR::Serialize(OTSStream* out) {
+ if (!out->Write(this->m_data, this->m_length)) {
+ return Error("Failed to write cvar table");
+ }
+
+ return true;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/cvar.h b/gfx/ots/src/cvar.h
new file mode 100644
index 000000000..8f31e98cd
--- /dev/null
+++ b/gfx/ots/src/cvar.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_CVAR_H_
+#define OTS_CVAR_H_
+
+#include "ots.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeCVAR Interface
+// -----------------------------------------------------------------------------
+
+class OpenTypeCVAR : public Table {
+ public:
+ explicit OpenTypeCVAR(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ const uint8_t *m_data;
+ size_t m_length;
+};
+
+} // namespace ots
+
+#endif // OTS_CVAR_H_
diff --git a/gfx/ots/src/cvt.cc b/gfx/ots/src/cvt.cc
index 1402e7c06..2e0257889 100644
--- a/gfx/ots/src/cvt.cc
+++ b/gfx/ots/src/cvt.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,59 +7,40 @@
// cvt - Control Value Table
// http://www.microsoft.com/typography/otspec/cvt.htm
-#define TABLE_NAME "cvt"
-
namespace ots {
-bool ots_cvt_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeCVT::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- OpenTypeCVT *cvt = new OpenTypeCVT;
- font->cvt = cvt;
-
if (length >= 128 * 1024u) {
- return OTS_FAILURE_MSG("Length (%d) > 120K"); // almost all cvt tables are less than 4k bytes.
+ return Error("Length (%d) > 120K"); // almost all cvt tables are less than 4k bytes.
}
if (length % 2 != 0) {
- return OTS_FAILURE_MSG("Uneven cvt length (%d)", length);
+ return Error("Uneven table length (%d)", length);
}
if (!table.Skip(length)) {
- return OTS_FAILURE_MSG("Length too high");
+ return Error("Table length too high");
}
- cvt->data = data;
- cvt->length = length;
+ this->data = data;
+ this->length = length;
return true;
}
-bool ots_cvt_should_serialise(Font *font) {
- if (!font->glyf) {
- return false; // this table is not for CFF fonts.
- }
- return font->cvt != NULL;
-}
-
-bool ots_cvt_serialise(OTSStream *out, Font *font) {
- const OpenTypeCVT *cvt = font->cvt;
-
- if (!out->Write(cvt->data, cvt->length)) {
- return OTS_FAILURE_MSG("Failed to write CVT table");
+bool OpenTypeCVT::Serialize(OTSStream *out) {
+ if (!out->Write(this->data, this->length)) {
+ return Error("Failed to write cvt table");
}
return true;
}
-void ots_cvt_reuse(Font *font, Font *other) {
- font->cvt = other->cvt;
- font->cvt_reused = true;
-}
-
-void ots_cvt_free(Font *font) {
- delete font->cvt;
+bool OpenTypeCVT::ShouldSerialize() {
+ return Table::ShouldSerialize() &&
+ // this table is not for CFF fonts.
+ GetFont()->GetTable(OTS_TAG_GLYF) != NULL;
}
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/cvt.h b/gfx/ots/src/cvt.h
index 3c25f06f6..88a96ca20 100644
--- a/gfx/ots/src/cvt.h
+++ b/gfx/ots/src/cvt.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,7 +9,16 @@
namespace ots {
-struct OpenTypeCVT {
+class OpenTypeCVT : public Table {
+ public:
+ explicit OpenTypeCVT(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool ShouldSerialize();
+
+ private:
const uint8_t *data;
uint32_t length;
};
diff --git a/gfx/ots/src/feat.cc b/gfx/ots/src/feat.cc
new file mode 100644
index 000000000..374a7ae9f
--- /dev/null
+++ b/gfx/ots/src/feat.cc
@@ -0,0 +1,193 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "feat.h"
+
+#include "name.h"
+
+namespace ots {
+
+bool OpenTypeFEAT::Parse(const uint8_t* data, size_t length) {
+ if (GetFont()->dropped_graphite) {
+ return Drop("Skipping Graphite table");
+ }
+ Buffer table(data, length);
+
+ if (!table.ReadU32(&this->version)) {
+ return DropGraphite("Failed to read version");
+ }
+ if (this->version >> 16 != 1 && this->version >> 16 != 2) {
+ return DropGraphite("Unsupported table version: %u", this->version >> 16);
+ }
+ if (!table.ReadU16(&this->numFeat)) {
+ return DropGraphite("Failed to read numFeat");
+ }
+ if (!table.ReadU16(&this->reserved)) {
+ return DropGraphite("Failed to read reserved");
+ }
+ if (this->reserved != 0) {
+ Warning("Nonzero reserved");
+ }
+ if (!table.ReadU32(&this->reserved2)) {
+ return DropGraphite("Failed to read valid reserved2");
+ }
+ if (this->reserved2 != 0) {
+ Warning("Nonzero reserved2");
+ }
+
+ std::unordered_set<size_t> unverified;
+ //this->features.resize(this->numFeat, this);
+ for (unsigned i = 0; i < this->numFeat; ++i) {
+ this->features.emplace_back(this);
+ FeatureDefn& feature = this->features[i];
+ if (!feature.ParsePart(table)) {
+ return DropGraphite("Failed to read features[%u]", i);
+ }
+ this->feature_ids.insert(feature.id);
+ for (unsigned j = 0; j < feature.numSettings; ++j) {
+ size_t offset = feature.offset + j * 4;
+ if (offset < feature.offset || offset > length) {
+ return DropGraphite("Invalid FeatSettingDefn offset %zu/%zu",
+ offset, length);
+ }
+ unverified.insert(offset);
+ // need to verify that this FeatureDefn points to valid
+ // FeatureSettingDefn
+ }
+ }
+
+ while (table.remaining()) {
+ bool used = unverified.erase(table.offset());
+ FeatureSettingDefn featSetting(this);
+ if (!featSetting.ParsePart(table, used)) {
+ return DropGraphite("Failed to read a FeatureSettingDefn");
+ }
+ featSettings.push_back(featSetting);
+ }
+
+ if (!unverified.empty()) {
+ return DropGraphite("%zu incorrect offsets into featSettings",
+ unverified.size());
+ }
+ if (table.remaining()) {
+ return Warning("%zu bytes unparsed", table.remaining());
+ }
+ return true;
+}
+
+bool OpenTypeFEAT::Serialize(OTSStream* out) {
+ if (!out->WriteU32(this->version) ||
+ !out->WriteU16(this->numFeat) ||
+ !out->WriteU16(this->reserved) ||
+ !out->WriteU32(this->reserved2) ||
+ !SerializeParts(this->features, out) ||
+ !SerializeParts(this->featSettings, out)) {
+ return Error("Failed to write table");
+ }
+ return true;
+}
+
+bool OpenTypeFEAT::IsValidFeatureId(uint32_t id) const {
+ return feature_ids.count(id);
+}
+
+bool OpenTypeFEAT::FeatureDefn::ParsePart(Buffer& table) {
+ OpenTypeNAME* name = static_cast<OpenTypeNAME*>(
+ parent->GetFont()->GetTypedTable(OTS_TAG_NAME));
+ if (!name) {
+ return parent->Error("FeatureDefn: Required name table is missing");
+ }
+
+ if (parent->version >> 16 >= 2 && !table.ReadU32(&this->id)) {
+ return parent->Error("FeatureDefn: Failed to read id");
+ }
+ if (parent->version >> 16 == 1) {
+ uint16_t id;
+ if (!table.ReadU16(&id)) {
+ return parent->Error("FeatureDefn: Failed to read id");
+ }
+ this->id = id;
+ }
+ if (!table.ReadU16(&this->numSettings)) {
+ return parent->Error("FeatureDefn: Failed to read numSettings");
+ }
+ if (parent->version >> 16 >= 2) {
+ if (!table.ReadU16(&this->reserved)) {
+ return parent->Error("FeatureDefn: Failed to read reserved");
+ }
+ if (this->reserved != 0) {
+ parent->Warning("FeatureDefn: Nonzero reserved");
+ }
+ }
+ if (!table.ReadU32(&this->offset)) {
+ return parent->Error("FeatureDefn: Failed to read offset");
+ } // validity of offset verified in OpenTypeFEAT::Parse
+ if (!table.ReadU16(&this->flags)) {
+ return parent->Error("FeatureDefn: Failed to read flags");
+ }
+ if ((this->flags & RESERVED) != 0) {
+ this->flags &= ~RESERVED;
+ parent->Warning("FeatureDefn: Nonzero (flags & 0x%x) repaired", RESERVED);
+ }
+ if (this->flags & HAS_DEFAULT_SETTING &&
+ (this->flags & DEFAULT_SETTING) >= this->numSettings) {
+ return parent->Error("FeatureDefn: (flags & 0x%x) is set but (flags & 0x%x "
+ "is not a valid setting index", HAS_DEFAULT_SETTING,
+ DEFAULT_SETTING);
+ }
+ if (!table.ReadU16(&this->label)) {
+ return parent->Error("FeatureDefn: Failed to read label");
+ }
+ if (!name->IsValidNameId(this->label)) {
+ if (this->id == 1 && name->IsValidNameId(this->label, true)) {
+ parent->Warning("FeatureDefn: Missing NameRecord repaired for feature"
+ " with id=%u, label=%u", this->id, this->label);
+ }
+ else {
+ return parent->Error("FeatureDefn: Invalid label");
+ }
+ }
+ return true;
+}
+
+bool OpenTypeFEAT::FeatureDefn::SerializePart(OTSStream* out) const {
+ if ((parent->version >> 16 >= 2 && !out->WriteU32(this->id)) ||
+ (parent->version >> 16 == 1 &&
+ !out->WriteU16(static_cast<uint16_t>(this->id))) ||
+ !out->WriteU16(this->numSettings) ||
+ (parent->version >> 16 >= 2 && !out->WriteU16(this->reserved)) ||
+ !out->WriteU32(this->offset) ||
+ !out->WriteU16(this->flags) ||
+ !out->WriteU16(this->label)) {
+ return parent->Error("FeatureDefn: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeFEAT::FeatureSettingDefn::ParsePart(Buffer& table, bool used) {
+ OpenTypeNAME* name = static_cast<OpenTypeNAME*>(
+ parent->GetFont()->GetTypedTable(OTS_TAG_NAME));
+ if (!name) {
+ return parent->Error("FeatureSettingDefn: Required name table is missing");
+ }
+
+ if (!table.ReadS16(&this->value)) {
+ return parent->Error("FeatureSettingDefn: Failed to read value");
+ }
+ if (!table.ReadU16(&this->label) ||
+ (used && !name->IsValidNameId(this->label))) {
+ return parent->Error("FeatureSettingDefn: Failed to read valid label");
+ }
+ return true;
+}
+
+bool OpenTypeFEAT::FeatureSettingDefn::SerializePart(OTSStream* out) const {
+ if (!out->WriteS16(this->value) ||
+ !out->WriteU16(this->label)) {
+ return parent->Error("FeatureSettingDefn: Failed to write");
+ }
+ return true;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/feat.h b/gfx/ots/src/feat.h
new file mode 100644
index 000000000..29c2656ff
--- /dev/null
+++ b/gfx/ots/src/feat.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_FEAT_H_
+#define OTS_FEAT_H_
+
+#include <vector>
+#include <unordered_set>
+
+#include "ots.h"
+#include "graphite.h"
+
+namespace ots {
+
+class OpenTypeFEAT : public Table {
+ public:
+ explicit OpenTypeFEAT(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+ bool IsValidFeatureId(uint32_t id) const;
+
+ private:
+ struct FeatureDefn : public TablePart<OpenTypeFEAT> {
+ explicit FeatureDefn(OpenTypeFEAT* parent)
+ : TablePart<OpenTypeFEAT>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ uint32_t id;
+ uint16_t numSettings;
+ uint16_t reserved;
+ uint32_t offset;
+ uint16_t flags;
+ static const uint16_t HAS_DEFAULT_SETTING = 0x4000;
+ static const uint16_t RESERVED = 0x3F00;
+ static const uint16_t DEFAULT_SETTING = 0x00FF;
+ uint16_t label;
+ };
+ struct FeatureSettingDefn : public TablePart<OpenTypeFEAT> {
+ explicit FeatureSettingDefn(OpenTypeFEAT* parent)
+ : TablePart<OpenTypeFEAT>(parent) { }
+ bool ParsePart(Buffer& table) { return ParsePart(table, true); }
+ bool ParsePart(Buffer& table, bool used);
+ bool SerializePart(OTSStream* out) const;
+ int16_t value;
+ uint16_t label;
+ };
+ uint32_t version;
+ uint16_t numFeat;
+ uint16_t reserved;
+ uint32_t reserved2;
+ std::vector<FeatureDefn> features;
+ std::vector<FeatureSettingDefn> featSettings;
+ std::unordered_set<uint32_t> feature_ids;
+};
+
+} // namespace ots
+
+#endif // OTS_FEAT_H_
diff --git a/gfx/ots/src/fpgm.cc b/gfx/ots/src/fpgm.cc
index faa9a2392..bb52b367f 100644
--- a/gfx/ots/src/fpgm.cc
+++ b/gfx/ots/src/fpgm.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,53 +7,36 @@
// fpgm - Font Program
// http://www.microsoft.com/typography/otspec/fpgm.htm
-#define TABLE_NAME "fpgm"
-
namespace ots {
-bool ots_fpgm_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeFPGM::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- OpenTypeFPGM *fpgm = new OpenTypeFPGM;
- font->fpgm = fpgm;
-
if (length >= 128 * 1024u) {
- return OTS_FAILURE_MSG("length (%ld) > 120", length); // almost all fpgm tables are less than 5k bytes.
+ return Error("length (%ld) > 120", length); // almost all fpgm tables are less than 5k bytes.
}
if (!table.Skip(length)) {
- return OTS_FAILURE_MSG("Bad fpgm length");
+ return Error("Bad table length");
}
- fpgm->data = data;
- fpgm->length = length;
+ this->data = data;
+ this->length = length;
return true;
}
-bool ots_fpgm_should_serialise(Font *font) {
- if (!font->glyf) return false; // this table is not for CFF fonts.
- return font->fpgm != NULL;
-}
-
-bool ots_fpgm_serialise(OTSStream *out, Font *font) {
- const OpenTypeFPGM *fpgm = font->fpgm;
-
- if (!out->Write(fpgm->data, fpgm->length)) {
- return OTS_FAILURE_MSG("Failed to write fpgm");
+bool OpenTypeFPGM::Serialize(OTSStream *out) {
+ if (!out->Write(this->data, this->length)) {
+ return Error("Failed to write fpgm table");
}
return true;
}
-void ots_fpgm_reuse(Font *font, Font *other) {
- font->fpgm = other->fpgm;
- font->fpgm_reused = true;
-}
-
-void ots_fpgm_free(Font *font) {
- delete font->fpgm;
+bool OpenTypeFPGM::ShouldSerialize() {
+ return Table::ShouldSerialize() &&
+ // this table is not for CFF fonts.
+ GetFont()->GetTable(OTS_TAG_GLYF) != NULL;
}
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/fpgm.h b/gfx/ots/src/fpgm.h
index 8fabac36d..9ed6b34bf 100644
--- a/gfx/ots/src/fpgm.h
+++ b/gfx/ots/src/fpgm.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,7 +9,16 @@
namespace ots {
-struct OpenTypeFPGM {
+class OpenTypeFPGM : public Table {
+ public:
+ explicit OpenTypeFPGM(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool ShouldSerialize();
+
+ private:
const uint8_t *data;
uint32_t length;
};
diff --git a/gfx/ots/src/fvar.cc b/gfx/ots/src/fvar.cc
new file mode 100644
index 000000000..6f9b4d6eb
--- /dev/null
+++ b/gfx/ots/src/fvar.cc
@@ -0,0 +1,164 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "fvar.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeFVAR
+// -----------------------------------------------------------------------------
+
+bool OpenTypeFVAR::Parse(const uint8_t* data, size_t length) {
+ Buffer table(data, length);
+ if (!table.ReadU16(&this->majorVersion) ||
+ !table.ReadU16(&this->minorVersion) ||
+ !table.ReadU16(&this->axesArrayOffset) ||
+ !table.ReadU16(&this->reserved) ||
+ !table.ReadU16(&this->axisCount) ||
+ !table.ReadU16(&this->axisSize) ||
+ !table.ReadU16(&this->instanceCount) ||
+ !table.ReadU16(&this->instanceSize)) {
+ return DropVariations("Failed to read table header");
+ }
+ if (this->majorVersion != 1) {
+ return DropVariations("Unknown table version");
+ }
+ if (this->minorVersion > 0) {
+ Warning("Downgrading minor version to 0");
+ this->minorVersion = 0;
+ }
+ if (this->axesArrayOffset > length || this->axesArrayOffset < table.offset()) {
+ return DropVariations("Bad axesArrayOffset");
+ }
+ if (this->reserved != 2) {
+ Warning("Expected reserved=2");
+ this->reserved = 2;
+ }
+ if (this->axisCount == 0) {
+ return DropVariations("No variation axes");
+ }
+ if (this->axisSize != 20) {
+ return DropVariations("Invalid axisSize");
+ }
+ // instanceCount is not validated
+ if (this->instanceSize == this->axisCount * sizeof(Fixed) + 6) {
+ this->instancesHavePostScriptNameID = true;
+ } else if (this->instanceSize == this->axisCount * sizeof(Fixed) + 4) {
+ this->instancesHavePostScriptNameID = false;
+ } else {
+ return DropVariations("Invalid instanceSize");
+ }
+
+ // When we serialize, the axes array will go here, even if it was
+ // originally at a different offset. So we update the axesArrayOffset
+ // field for the header.
+ uint32_t origAxesArrayOffset = this->axesArrayOffset;
+ this->axesArrayOffset = table.offset();
+
+ table.set_offset(origAxesArrayOffset);
+ for (unsigned i = 0; i < this->axisCount; i++) {
+ this->axes.emplace_back();
+ auto& axis = this->axes[i];
+ if (!table.ReadU32(&axis.axisTag) ||
+ !table.ReadS32(&axis.minValue) ||
+ !table.ReadS32(&axis.defaultValue) ||
+ !table.ReadS32(&axis.maxValue) ||
+ !table.ReadU16(&axis.flags) ||
+ !table.ReadU16(&axis.axisNameID)) {
+ return DropVariations("Failed to read axis record");
+ }
+ if (!CheckTag(axis.axisTag)) {
+ return DropVariations("Bad axis tag");
+ }
+ if (!(axis.minValue <= axis.defaultValue && axis.defaultValue <= axis.maxValue)) {
+ return DropVariations("Bad axis value range");
+ }
+ if ((axis.flags & 0xFFFEu) != 0) {
+ Warning("Discarding unknown axis flags");
+ axis.flags &= ~0xFFFEu;
+ }
+ if (axis.axisNameID <= 255 || axis.axisNameID >= 32768) {
+ Warning("Axis nameID out of range");
+ // We don't check that the name actually exists -- assume the client can handle
+ // a missing name when it tries to read the table.
+ }
+ }
+
+ for (unsigned i = 0; i < this->instanceCount; i++) {
+ this->instances.emplace_back();
+ auto& inst = this->instances[i];
+ if (!table.ReadU16(&inst.subfamilyNameID) ||
+ !table.ReadU16(&inst.flags)) {
+ return DropVariations("Failed to read instance record");
+ }
+ inst.coordinates.reserve(this->axisCount);
+ for (unsigned j = 0; j < this->axisCount; j++) {
+ inst.coordinates.emplace_back();
+ auto& coord = inst.coordinates[j];
+ if (!table.ReadS32(&coord)) {
+ return DropVariations("Failed to read instance coordinates");
+ }
+ }
+ if (this->instancesHavePostScriptNameID) {
+ if (!table.ReadU16(&inst.postScriptNameID)) {
+ return DropVariations("Failed to read instance psname ID");
+ }
+ }
+ }
+
+ if (table.remaining()) {
+ return Warning("%zu bytes unparsed", table.remaining());
+ }
+
+ return true;
+}
+
+bool OpenTypeFVAR::Serialize(OTSStream* out) {
+ if (!out->WriteU16(this->majorVersion) ||
+ !out->WriteU16(this->minorVersion) ||
+ !out->WriteU16(this->axesArrayOffset) ||
+ !out->WriteU16(this->reserved) ||
+ !out->WriteU16(this->axisCount) ||
+ !out->WriteU16(this->axisSize) ||
+ !out->WriteU16(this->instanceCount) ||
+ !out->WriteU16(this->instanceSize)) {
+ return Error("Failed to write table");
+ }
+
+ for (unsigned i = 0; i < this->axisCount; i++) {
+ const auto& axis = this->axes[i];
+ if (!out->WriteU32(axis.axisTag) ||
+ !out->WriteS32(axis.minValue) ||
+ !out->WriteS32(axis.defaultValue) ||
+ !out->WriteS32(axis.maxValue) ||
+ !out->WriteU16(axis.flags) ||
+ !out->WriteU16(axis.axisNameID)) {
+ return Error("Failed to write table");
+ }
+ }
+
+ for (unsigned i = 0; i < this->instanceCount; i++) {
+ const auto& inst = this->instances[i];
+ if (!out->WriteU16(inst.subfamilyNameID) ||
+ !out->WriteU16(inst.flags)) {
+ return Error("Failed to write table");
+ }
+ for (unsigned j = 0; j < this->axisCount; j++) {
+ const auto& coord = inst.coordinates[j];
+ if (!out->WriteS32(coord)) {
+ return Error("Failed to write table");
+ }
+ }
+ if (this->instancesHavePostScriptNameID) {
+ if (!out->WriteU16(inst.postScriptNameID)) {
+ return Error("Failed to write table");
+ }
+ }
+ }
+
+ return true;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/fvar.h b/gfx/ots/src/fvar.h
new file mode 100644
index 000000000..a469c8cdd
--- /dev/null
+++ b/gfx/ots/src/fvar.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_FVAR_H_
+#define OTS_FVAR_H_
+
+#include <vector>
+
+#include "ots.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeFVAR Interface
+// -----------------------------------------------------------------------------
+
+class OpenTypeFVAR : public Table {
+ public:
+ explicit OpenTypeFVAR(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ uint16_t AxisCount() const { return axisCount; }
+
+ private:
+ uint16_t majorVersion;
+ uint16_t minorVersion;
+ uint16_t axesArrayOffset;
+ uint16_t reserved;
+ uint16_t axisCount;
+ uint16_t axisSize;
+ uint16_t instanceCount;
+ uint16_t instanceSize;
+
+ typedef int32_t Fixed; /* 16.16 fixed-point value */
+
+ struct VariationAxisRecord {
+ uint32_t axisTag;
+ Fixed minValue;
+ Fixed defaultValue;
+ Fixed maxValue;
+ uint16_t flags;
+ uint16_t axisNameID;
+ };
+ std::vector<VariationAxisRecord> axes;
+
+ struct InstanceRecord {
+ uint16_t subfamilyNameID;
+ uint16_t flags;
+ std::vector<Fixed> coordinates;
+ uint16_t postScriptNameID; // optional
+ };
+ std::vector<InstanceRecord> instances;
+
+ bool instancesHavePostScriptNameID;
+};
+
+} // namespace ots
+
+#endif // OTS_FVAR_H_
diff --git a/gfx/ots/src/gasp.cc b/gfx/ots/src/gasp.cc
index 5ebf5d84b..2a03c831f 100644
--- a/gfx/ots/src/gasp.cc
+++ b/gfx/ots/src/gasp.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,113 +7,78 @@
// gasp - Grid-fitting And Scan-conversion Procedure
// http://www.microsoft.com/typography/otspec/gasp.htm
-#define TABLE_NAME "gasp"
-
-#define DROP_THIS_TABLE(...) \
- do { \
- OTS_FAILURE_MSG_(font->file, TABLE_NAME ": " __VA_ARGS__); \
- OTS_FAILURE_MSG("Table discarded"); \
- delete font->gasp; \
- font->gasp = 0; \
- } while (0)
-
namespace ots {
-bool ots_gasp_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeGASP::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- OpenTypeGASP *gasp = new OpenTypeGASP;
- font->gasp = gasp;
-
uint16_t num_ranges = 0;
- if (!table.ReadU16(&gasp->version) ||
+ if (!table.ReadU16(&this->version) ||
!table.ReadU16(&num_ranges)) {
- return OTS_FAILURE_MSG("Failed to read table header");
+ return Error("Failed to read table header");
}
- if (gasp->version > 1) {
+ if (this->version > 1) {
// Lots of Linux fonts have bad version numbers...
- DROP_THIS_TABLE("bad version: %u", gasp->version);
- return true;
+ return Drop("Unsupported version: %u", this->version);
}
if (num_ranges == 0) {
- DROP_THIS_TABLE("num_ranges is zero");
- return true;
+ return Drop("numRanges is zero");
}
- gasp->gasp_ranges.reserve(num_ranges);
+ this->gasp_ranges.reserve(num_ranges);
for (unsigned i = 0; i < num_ranges; ++i) {
uint16_t max_ppem = 0;
uint16_t behavior = 0;
if (!table.ReadU16(&max_ppem) ||
!table.ReadU16(&behavior)) {
- return OTS_FAILURE_MSG("Failed to read subrange %d", i);
+ return Error("Failed to read GASPRANGE %d", i);
}
- if ((i > 0) && (gasp->gasp_ranges[i - 1].first >= max_ppem)) {
+ if ((i > 0) && (this->gasp_ranges[i - 1].first >= max_ppem)) {
// The records in the gaspRange[] array must be sorted in order of
// increasing rangeMaxPPEM value.
- DROP_THIS_TABLE("ranges are not sorted");
- return true;
+ return Drop("Ranges are not sorted");
}
if ((i == num_ranges - 1u) && // never underflow.
(max_ppem != 0xffffu)) {
- DROP_THIS_TABLE("The last record should be 0xFFFF as a sentinel value "
+ return Drop("The last record should be 0xFFFF as a sentinel value "
"for rangeMaxPPEM");
- return true;
}
if (behavior >> 8) {
- OTS_WARNING("undefined bits are used: %x", behavior);
+ Warning("Undefined bits are used: %x", behavior);
// mask undefined bits.
behavior &= 0x000fu;
}
- if (gasp->version == 0 && (behavior >> 2) != 0) {
- OTS_WARNING("changed the version number to 1");
- gasp->version = 1;
+ if (this->version == 0 && (behavior >> 2) != 0) {
+ Warning("Changed the version number to 1");
+ this->version = 1;
}
- gasp->gasp_ranges.push_back(std::make_pair(max_ppem, behavior));
+ this->gasp_ranges.push_back(std::make_pair(max_ppem, behavior));
}
return true;
}
-bool ots_gasp_should_serialise(Font *font) {
- return font->gasp != NULL;
-}
-
-bool ots_gasp_serialise(OTSStream *out, Font *font) {
- const OpenTypeGASP *gasp = font->gasp;
-
- const uint16_t num_ranges = static_cast<uint16_t>(gasp->gasp_ranges.size());
- if (num_ranges != gasp->gasp_ranges.size() ||
- !out->WriteU16(gasp->version) ||
+bool OpenTypeGASP::Serialize(OTSStream *out) {
+ const uint16_t num_ranges = static_cast<uint16_t>(this->gasp_ranges.size());
+ if (num_ranges != this->gasp_ranges.size() ||
+ !out->WriteU16(this->version) ||
!out->WriteU16(num_ranges)) {
- return OTS_FAILURE_MSG("failed to write gasp header");
+ return Error("Failed to write table header");
}
for (uint16_t i = 0; i < num_ranges; ++i) {
- if (!out->WriteU16(gasp->gasp_ranges[i].first) ||
- !out->WriteU16(gasp->gasp_ranges[i].second)) {
- return OTS_FAILURE_MSG("Failed to write gasp subtable %d", i);
+ if (!out->WriteU16(this->gasp_ranges[i].first) ||
+ !out->WriteU16(this->gasp_ranges[i].second)) {
+ return Error("Failed to write GASPRANGE %d", i);
}
}
return true;
}
-void ots_gasp_reuse(Font *font, Font *other) {
- font->gasp = other->gasp;
- font->gasp_reused = true;
-}
-
-void ots_gasp_free(Font *font) {
- delete font->gasp;
-}
-
} // namespace ots
-
-#undef TABLE_NAME
-#undef DROP_THIS_TABLE
diff --git a/gfx/ots/src/gasp.h b/gfx/ots/src/gasp.h
index 48d7e7c16..ce9e987aa 100644
--- a/gfx/ots/src/gasp.h
+++ b/gfx/ots/src/gasp.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,7 +13,15 @@
namespace ots {
-struct OpenTypeGASP {
+class OpenTypeGASP : public Table {
+ public:
+ explicit OpenTypeGASP(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
+ private:
uint16_t version;
// A array of (max PPEM, GASP behavior) pairs.
std::vector<std::pair<uint16_t, uint16_t> > gasp_ranges;
diff --git a/gfx/ots/src/gdef.cc b/gfx/ots/src/gdef.cc
index 71c6fc592..71e1075e3 100644
--- a/gfx/ots/src/gdef.cc
+++ b/gfx/ots/src/gdef.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,68 +11,60 @@
#include "gsub.h"
#include "layout.h"
#include "maxp.h"
+#include "variations.h"
// GDEF - The Glyph Definition Table
// http://www.microsoft.com/typography/otspec/gdef.htm
-#define TABLE_NAME "GDEF"
-
namespace {
-// The maximum class value in class definition tables.
-const uint16_t kMaxClassDefValue = 0xFFFF;
// The maximum class value in the glyph class definision table.
const uint16_t kMaxGlyphClassDefValue = 4;
// The maximum format number of caret value tables.
-// We don't support format 3 for now. See the comment in
-// ParseLigCaretListTable() for the reason.
-const uint16_t kMaxCaretValueFormat = 2;
-
-bool ParseGlyphClassDefTable(ots::Font *font, const uint8_t *data,
- size_t length, const uint16_t num_glyphs) {
- return ots::ParseClassDefTable(font, data, length, num_glyphs,
- kMaxGlyphClassDefValue);
-}
+const uint16_t kMaxCaretValueFormat = 3;
+
+} // namespace
-bool ParseAttachListTable(ots::Font *font, const uint8_t *data,
- size_t length, const uint16_t num_glyphs) {
+namespace ots {
+
+bool OpenTypeGDEF::ParseAttachListTable(const uint8_t *data, size_t length) {
ots::Buffer subtable(data, length);
uint16_t offset_coverage = 0;
uint16_t glyph_count = 0;
if (!subtable.ReadU16(&offset_coverage) ||
!subtable.ReadU16(&glyph_count)) {
- return OTS_FAILURE_MSG("Failed to read gdef header");
+ return Error("Failed to read gdef header");
}
const unsigned attach_points_end =
2 * static_cast<unsigned>(glyph_count) + 4;
if (attach_points_end > std::numeric_limits<uint16_t>::max()) {
- return OTS_FAILURE_MSG("Bad glyph count in gdef");
+ return Error("Bad glyph count in gdef");
}
if (offset_coverage == 0 || offset_coverage >= length ||
offset_coverage < attach_points_end) {
- return OTS_FAILURE_MSG("Bad coverage offset %d", offset_coverage);
+ return Error("Bad coverage offset %d", offset_coverage);
}
- if (glyph_count > num_glyphs) {
- return OTS_FAILURE_MSG("Bad glyph count %u", glyph_count);
+ if (glyph_count > this->m_num_glyphs) {
+ return Error("Bad glyph count %u", glyph_count);
}
std::vector<uint16_t> attach_points;
attach_points.resize(glyph_count);
for (unsigned i = 0; i < glyph_count; ++i) {
if (!subtable.ReadU16(&attach_points[i])) {
- return OTS_FAILURE_MSG("Can't read attachment point %d", i);
+ return Error("Can't read attachment point %d", i);
}
if (attach_points[i] >= length ||
attach_points[i] < attach_points_end) {
- return OTS_FAILURE_MSG("Bad attachment point %d of %d", i, attach_points[i]);
+ return Error("Bad attachment point %d of %d", i, attach_points[i]);
}
}
// Parse coverage table
- if (!ots::ParseCoverageTable(font, data + offset_coverage,
- length - offset_coverage, num_glyphs)) {
- return OTS_FAILURE_MSG("Bad coverage table");
+ if (!ots::ParseCoverageTable(GetFont(), data + offset_coverage,
+ length - offset_coverage, this->m_num_glyphs)) {
+ return Error("Bad coverage table");
}
// Parse attach point table
@@ -80,20 +72,20 @@ bool ParseAttachListTable(ots::Font *font, const uint8_t *data,
subtable.set_offset(attach_points[i]);
uint16_t point_count = 0;
if (!subtable.ReadU16(&point_count)) {
- return OTS_FAILURE_MSG("Can't read point count %d", i);
+ return Error("Can't read point count %d", i);
}
if (point_count == 0) {
- return OTS_FAILURE_MSG("zero point count %d", i);
+ return Error("zero point count %d", i);
}
uint16_t last_point_index = 0;
uint16_t point_index = 0;
for (unsigned j = 0; j < point_count; ++j) {
if (!subtable.ReadU16(&point_index)) {
- return OTS_FAILURE_MSG("Can't read point index %d in point %d", j, i);
+ return Error("Can't read point index %d in point %d", j, i);
}
// Contour point indeces are in increasing numerical order
if (last_point_index != 0 && last_point_index >= point_index) {
- return OTS_FAILURE_MSG("bad contour indeces: %u >= %u",
+ return Error("bad contour indeces: %u >= %u",
last_point_index, point_index);
}
last_point_index = point_index;
@@ -102,43 +94,42 @@ bool ParseAttachListTable(ots::Font *font, const uint8_t *data,
return true;
}
-bool ParseLigCaretListTable(ots::Font *font, const uint8_t *data,
- size_t length, const uint16_t num_glyphs) {
+bool OpenTypeGDEF::ParseLigCaretListTable(const uint8_t *data, size_t length) {
ots::Buffer subtable(data, length);
uint16_t offset_coverage = 0;
uint16_t lig_glyph_count = 0;
if (!subtable.ReadU16(&offset_coverage) ||
!subtable.ReadU16(&lig_glyph_count)) {
- return OTS_FAILURE_MSG("Can't read caret structure");
+ return Error("Can't read caret structure");
}
const unsigned lig_glyphs_end =
2 * static_cast<unsigned>(lig_glyph_count) + 4;
if (lig_glyphs_end > std::numeric_limits<uint16_t>::max()) {
- return OTS_FAILURE_MSG("Bad caret structure");
+ return Error("Bad caret structure");
}
if (offset_coverage == 0 || offset_coverage >= length ||
offset_coverage < lig_glyphs_end) {
- return OTS_FAILURE_MSG("Bad caret coverate offset %d", offset_coverage);
+ return Error("Bad caret coverate offset %d", offset_coverage);
}
- if (lig_glyph_count > num_glyphs) {
- return OTS_FAILURE_MSG("bad ligature glyph count: %u", lig_glyph_count);
+ if (lig_glyph_count > this->m_num_glyphs) {
+ return Error("bad ligature glyph count: %u", lig_glyph_count);
}
std::vector<uint16_t> lig_glyphs;
lig_glyphs.resize(lig_glyph_count);
for (unsigned i = 0; i < lig_glyph_count; ++i) {
if (!subtable.ReadU16(&lig_glyphs[i])) {
- return OTS_FAILURE_MSG("Can't read ligature glyph location %d", i);
+ return Error("Can't read ligature glyph location %d", i);
}
if (lig_glyphs[i] >= length || lig_glyphs[i] < lig_glyphs_end) {
- return OTS_FAILURE_MSG("Bad ligature glyph location %d in glyph %d", lig_glyphs[i], i);
+ return Error("Bad ligature glyph location %d in glyph %d", lig_glyphs[i], i);
}
}
// Parse coverage table
- if (!ots::ParseCoverageTable(font, data + offset_coverage,
- length - offset_coverage, num_glyphs)) {
- return OTS_FAILURE_MSG("Can't parse caret coverage table");
+ if (!ots::ParseCoverageTable(GetFont(), data + offset_coverage,
+ length - offset_coverage, this->m_num_glyphs)) {
+ return Error("Can't parse caret coverage table");
}
// Parse ligature glyph table
@@ -146,10 +137,10 @@ bool ParseLigCaretListTable(ots::Font *font, const uint8_t *data,
subtable.set_offset(lig_glyphs[i]);
uint16_t caret_count = 0;
if (!subtable.ReadU16(&caret_count)) {
- return OTS_FAILURE_MSG("Can't read caret count for glyph %d", i);
+ return Error("Can't read caret count for glyph %d", i);
}
if (caret_count == 0) {
- return OTS_FAILURE_MSG("bad caret value count: %u", caret_count);
+ return Error("bad caret value count: %u", caret_count);
}
std::vector<uint16_t> caret_value_offsets;
@@ -157,10 +148,10 @@ bool ParseLigCaretListTable(ots::Font *font, const uint8_t *data,
unsigned caret_value_offsets_end = 2 * static_cast<unsigned>(caret_count) + 2;
for (unsigned j = 0; j < caret_count; ++j) {
if (!subtable.ReadU16(&caret_value_offsets[j])) {
- return OTS_FAILURE_MSG("Can't read caret offset %d for glyph %d", j, i);
+ return Error("Can't read caret offset %d for glyph %d", j, i);
}
if (caret_value_offsets[j] >= length || caret_value_offsets[j] < caret_value_offsets_end) {
- return OTS_FAILURE_MSG("Bad caret offset %d for caret %d glyph %d", caret_value_offsets[j], j, i);
+ return Error("Bad caret offset %d for caret %d glyph %d", caret_value_offsets[j], j, i);
}
}
@@ -169,91 +160,93 @@ bool ParseLigCaretListTable(ots::Font *font, const uint8_t *data,
subtable.set_offset(lig_glyphs[i] + caret_value_offsets[j]);
uint16_t caret_format = 0;
if (!subtable.ReadU16(&caret_format)) {
- return OTS_FAILURE_MSG("Can't read caret values table %d in glyph %d", j, i);
+ return Error("Can't read caret values table %d in glyph %d", j, i);
}
- // TODO(bashi): We only support caret value format 1 and 2 for now
- // because there are no fonts which contain caret value format 3
- // as far as we investigated.
if (caret_format == 0 || caret_format > kMaxCaretValueFormat) {
- return OTS_FAILURE_MSG("bad caret value format: %u", caret_format);
+ return Error("bad caret value format: %u", caret_format);
}
// CaretValueFormats contain a 2-byte field which could be
// arbitrary value.
if (!subtable.Skip(2)) {
- return OTS_FAILURE_MSG("Bad caret value table structure %d in glyph %d", j, i);
+ return Error("Bad caret value table structure %d in glyph %d", j, i);
+ }
+ if (caret_format == 3) {
+ uint16_t offset_device = 0;
+ if (!subtable.ReadU16(&offset_device)) {
+ return Error("Can't read device offset for caret value %d "
+ "in glyph %d", j, i);
+ }
+ uint16_t absolute_offset = lig_glyphs[i] + caret_value_offsets[j]
+ + offset_device;
+ if (offset_device == 0 || absolute_offset >= length) {
+ return Error("Bad device offset for caret value %d in glyph %d: %d",
+ j, i, offset_device);
+ }
+ if (!ots::ParseDeviceTable(GetFont(), data + absolute_offset,
+ length - absolute_offset)) {
+ return Error("Bad device table for caret value %d in glyph %d",
+ j, i, offset_device);
+ }
}
}
}
return true;
}
-bool ParseMarkAttachClassDefTable(ots::Font *font, const uint8_t *data,
- size_t length, const uint16_t num_glyphs) {
- return ots::ParseClassDefTable(font, data, length, num_glyphs, kMaxClassDefValue);
-}
-
-bool ParseMarkGlyphSetsDefTable(ots::Font *font, const uint8_t *data,
- size_t length, const uint16_t num_glyphs) {
+bool OpenTypeGDEF::ParseMarkGlyphSetsDefTable(const uint8_t *data, size_t length) {
ots::Buffer subtable(data, length);
uint16_t format = 0;
uint16_t mark_set_count = 0;
if (!subtable.ReadU16(&format) ||
!subtable.ReadU16(&mark_set_count)) {
- return OTS_FAILURE_MSG("Can' read mark glyph table structure");
+ return Error("Can' read mark glyph table structure");
}
if (format != 1) {
- return OTS_FAILURE_MSG("bad mark glyph set table format: %u", format);
+ return Error("bad mark glyph set table format: %u", format);
}
const unsigned mark_sets_end = 2 * static_cast<unsigned>(mark_set_count) + 4;
if (mark_sets_end > std::numeric_limits<uint16_t>::max()) {
- return OTS_FAILURE_MSG("Bad mark_set %d", mark_sets_end);
+ return Error("Bad mark_set %d", mark_sets_end);
}
for (unsigned i = 0; i < mark_set_count; ++i) {
uint32_t offset_coverage = 0;
if (!subtable.ReadU32(&offset_coverage)) {
- return OTS_FAILURE_MSG("Can't read covrage location for mark set %d", i);
+ return Error("Can't read covrage location for mark set %d", i);
}
if (offset_coverage >= length ||
offset_coverage < mark_sets_end) {
- return OTS_FAILURE_MSG("Bad coverage location %d for mark set %d", offset_coverage, i);
+ return Error("Bad coverage location %d for mark set %d", offset_coverage, i);
}
- if (!ots::ParseCoverageTable(font, data + offset_coverage,
- length - offset_coverage, num_glyphs)) {
- return OTS_FAILURE_MSG("Failed to parse coverage table for mark set %d", i);
+ if (!ots::ParseCoverageTable(GetFont(), data + offset_coverage,
+ length - offset_coverage, this->m_num_glyphs)) {
+ return Error("Failed to parse coverage table for mark set %d", i);
}
}
- font->gdef->num_mark_glyph_sets = mark_set_count;
+ this->num_mark_glyph_sets = mark_set_count;
return true;
}
-} // namespace
+bool OpenTypeGDEF::Parse(const uint8_t *data, size_t length) {
+ OpenTypeMAXP *maxp = static_cast<OpenTypeMAXP*>(
+ GetFont()->GetTypedTable(OTS_TAG_MAXP));
-namespace ots {
-
-bool ots_gdef_parse(Font *font, const uint8_t *data, size_t length) {
// Grab the number of glyphs in the font from the maxp table to check
// GlyphIDs in GDEF table.
- if (!font->maxp) {
- return OTS_FAILURE_MSG("No maxp table in font, needed by GDEF");
+ if (!maxp) {
+ return Error("No maxp table in font, needed by GDEF");
}
- const uint16_t num_glyphs = font->maxp->num_glyphs;
+ this->m_num_glyphs = maxp->num_glyphs;
Buffer table(data, length);
- OpenTypeGDEF *gdef = new OpenTypeGDEF;
- font->gdef = gdef;
-
- uint32_t version = 0;
- if (!table.ReadU32(&version)) {
- return OTS_FAILURE_MSG("Incomplete table");
+ uint16_t version_major = 0, version_minor = 0;
+ if (!table.ReadU16(&version_major) ||
+ !table.ReadU16(&version_minor)) {
+ return Error("Incomplete table");
}
- if (version < 0x00010000 || version == 0x00010001) {
- return OTS_FAILURE_MSG("Bad version");
- }
-
- if (version >= 0x00010002) {
- gdef->version_2 = true;
+ if (version_major != 1 || version_minor == 1) { // there is no v1.1
+ return Error("Bad version");
}
uint16_t offset_glyph_class_def = 0;
@@ -264,110 +257,108 @@ bool ots_gdef_parse(Font *font, const uint8_t *data, size_t length) {
!table.ReadU16(&offset_attach_list) ||
!table.ReadU16(&offset_lig_caret_list) ||
!table.ReadU16(&offset_mark_attach_class_def)) {
- return OTS_FAILURE_MSG("Incomplete table");
+ return Error("Incomplete table");
}
uint16_t offset_mark_glyph_sets_def = 0;
- if (gdef->version_2) {
+ if (version_minor >= 2) {
if (!table.ReadU16(&offset_mark_glyph_sets_def)) {
- return OTS_FAILURE_MSG("Incomplete table");
+ return Error("Incomplete table");
+ }
+ }
+ uint32_t item_var_store_offset = 0;
+ if (version_minor >= 3) {
+ if (!table.ReadU32(&item_var_store_offset)) {
+ return Error("Incomplete table");
}
}
unsigned gdef_header_end = 4 + 4 * 2;
- if (gdef->version_2)
+ if (version_minor >= 2)
gdef_header_end += 2;
+ if (version_minor >= 3)
+ gdef_header_end += 4;
// Parse subtables
if (offset_glyph_class_def) {
if (offset_glyph_class_def >= length ||
offset_glyph_class_def < gdef_header_end) {
- return OTS_FAILURE_MSG("Invalid offset to glyph classes");
+ return Error("Invalid offset to glyph classes");
}
- if (!ParseGlyphClassDefTable(font, data + offset_glyph_class_def,
+ if (!ots::ParseClassDefTable(GetFont(), data + offset_glyph_class_def,
length - offset_glyph_class_def,
- num_glyphs)) {
- return OTS_FAILURE_MSG("Invalid glyph classes");
+ this->m_num_glyphs, kMaxGlyphClassDefValue)) {
+ return Error("Invalid glyph classes");
}
- gdef->has_glyph_class_def = true;
}
if (offset_attach_list) {
if (offset_attach_list >= length ||
offset_attach_list < gdef_header_end) {
- return OTS_FAILURE_MSG("Invalid offset to attachment list");
+ return Error("Invalid offset to attachment list");
}
- if (!ParseAttachListTable(font, data + offset_attach_list,
- length - offset_attach_list,
- num_glyphs)) {
- return OTS_FAILURE_MSG("Invalid attachment list");
+ if (!ParseAttachListTable(data + offset_attach_list,
+ length - offset_attach_list)) {
+ return Error("Invalid attachment list");
}
}
if (offset_lig_caret_list) {
if (offset_lig_caret_list >= length ||
offset_lig_caret_list < gdef_header_end) {
- return OTS_FAILURE_MSG("Invalid offset to ligature caret list");
+ return Error("Invalid offset to ligature caret list");
}
- if (!ParseLigCaretListTable(font, data + offset_lig_caret_list,
- length - offset_lig_caret_list,
- num_glyphs)) {
- return OTS_FAILURE_MSG("Invalid ligature caret list");
+ if (!ParseLigCaretListTable(data + offset_lig_caret_list,
+ length - offset_lig_caret_list)) {
+ return Error("Invalid ligature caret list");
}
}
if (offset_mark_attach_class_def) {
if (offset_mark_attach_class_def >= length ||
offset_mark_attach_class_def < gdef_header_end) {
- return OTS_FAILURE_MSG("Invalid offset to mark attachment list");
+ return Error("Invalid offset to mark attachment list");
}
- if (!ParseMarkAttachClassDefTable(font,
- data + offset_mark_attach_class_def,
- length - offset_mark_attach_class_def,
- num_glyphs)) {
- return OTS_FAILURE_MSG("Invalid mark attachment list");
+ if (!ots::ParseClassDefTable(GetFont(),
+ data + offset_mark_attach_class_def,
+ length - offset_mark_attach_class_def,
+ this->m_num_glyphs, kMaxClassDefValue)) {
+ return Error("Invalid mark attachment list");
}
- gdef->has_mark_attachment_class_def = true;
}
if (offset_mark_glyph_sets_def) {
if (offset_mark_glyph_sets_def >= length ||
offset_mark_glyph_sets_def < gdef_header_end) {
- return OTS_FAILURE_MSG("invalid offset to mark glyph sets");
+ return Error("invalid offset to mark glyph sets");
}
- if (!ParseMarkGlyphSetsDefTable(font,
- data + offset_mark_glyph_sets_def,
- length - offset_mark_glyph_sets_def,
- num_glyphs)) {
- return OTS_FAILURE_MSG("Invalid mark glyph sets");
+ if (!ParseMarkGlyphSetsDefTable(data + offset_mark_glyph_sets_def,
+ length - offset_mark_glyph_sets_def)) {
+ return Error("Invalid mark glyph sets");
}
- gdef->has_mark_glyph_sets_def = true;
}
- gdef->data = data;
- gdef->length = length;
- return true;
-}
-
-bool ots_gdef_should_serialise(Font *font) {
- return font->gdef != NULL && font->gdef->data != NULL;
-}
-bool ots_gdef_serialise(OTSStream *out, Font *font) {
- if (!out->Write(font->gdef->data, font->gdef->length)) {
- return OTS_FAILURE_MSG("Failed to write GDEF table");
+ if (item_var_store_offset) {
+ if (item_var_store_offset >= length ||
+ item_var_store_offset < gdef_header_end) {
+ return Error("invalid offset to item variation store");
+ }
+ if (!ParseItemVariationStore(GetFont(), data + item_var_store_offset,
+ length - item_var_store_offset)) {
+ return Error("Invalid item variation store");
+ }
}
+ this->m_data = data;
+ this->m_length = length;
return true;
}
-void ots_gdef_reuse(Font *font, Font *other) {
- font->gdef = other->gdef;
- font->gdef_reused = true;
-}
+bool OpenTypeGDEF::Serialize(OTSStream *out) {
+ if (!out->Write(this->m_data, this->m_length)) {
+ return Error("Failed to write table");
+ }
-void ots_gdef_free(Font *font) {
- delete font->gdef;
+ return true;
}
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/gdef.h b/gfx/ots/src/gdef.h
index f46f419c7..7c7cc0ce5 100644
--- a/gfx/ots/src/gdef.h
+++ b/gfx/ots/src/gdef.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,25 +9,29 @@
namespace ots {
-struct OpenTypeGDEF {
- OpenTypeGDEF()
- : version_2(false),
- has_glyph_class_def(false),
- has_mark_attachment_class_def(false),
- has_mark_glyph_sets_def(false),
+class OpenTypeGDEF : public Table {
+ public:
+ explicit OpenTypeGDEF(Font *font, uint32_t tag)
+ : Table(font, tag, tag),
num_mark_glyph_sets(0),
- data(NULL),
- length(0) {
+ m_data(NULL),
+ m_length(0),
+ m_num_glyphs(0) {
}
- bool version_2;
- bool has_glyph_class_def;
- bool has_mark_attachment_class_def;
- bool has_mark_glyph_sets_def;
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
uint16_t num_mark_glyph_sets;
- const uint8_t *data;
- size_t length;
+ private:
+ bool ParseAttachListTable(const uint8_t *data, size_t length);
+ bool ParseLigCaretListTable(const uint8_t *data, size_t length);
+ bool ParseMarkGlyphSetsDefTable(const uint8_t *data, size_t length);
+
+ const uint8_t *m_data;
+ size_t m_length;
+ uint16_t m_num_glyphs;
};
} // namespace ots
diff --git a/gfx/ots/src/glat.cc b/gfx/ots/src/glat.cc
new file mode 100644
index 000000000..23f7dfd9a
--- /dev/null
+++ b/gfx/ots/src/glat.cc
@@ -0,0 +1,459 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "glat.h"
+
+#include "gloc.h"
+#include "mozilla/Compression.h"
+#include <list>
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeGLAT_v1
+// -----------------------------------------------------------------------------
+
+bool OpenTypeGLAT_v1::Parse(const uint8_t* data, size_t length) {
+ Buffer table(data, length);
+ OpenTypeGLOC* gloc = static_cast<OpenTypeGLOC*>(
+ GetFont()->GetTypedTable(OTS_TAG_GLOC));
+ if (!gloc) {
+ return DropGraphite("Required Gloc table is missing");
+ }
+
+ if (!table.ReadU32(&this->version) || this->version >> 16 != 1) {
+ return DropGraphite("Failed to read version");
+ }
+
+ const std::vector<uint32_t>& locations = gloc->GetLocations();
+ if (locations.empty()) {
+ return DropGraphite("No locations from Gloc table");
+ }
+ std::list<uint32_t> unverified(locations.begin(), locations.end());
+ while (table.remaining()) {
+ GlatEntry entry(this);
+ if (table.offset() > unverified.front()) {
+ return DropGraphite("Offset check failed for a GlatEntry");
+ }
+ if (table.offset() == unverified.front()) {
+ unverified.pop_front();
+ }
+ if (unverified.empty()) {
+ return DropGraphite("Expected more locations");
+ }
+ if (!entry.ParsePart(table)) {
+ return DropGraphite("Failed to read a GlatEntry");
+ }
+ this->entries.push_back(entry);
+ }
+
+ if (unverified.size() != 1 || unverified.front() != table.offset()) {
+ return DropGraphite("%zu location(s) could not be verified", unverified.size());
+ }
+ if (table.remaining()) {
+ return Warning("%zu bytes unparsed", table.remaining());
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v1::Serialize(OTSStream* out) {
+ if (!out->WriteU32(this->version) ||
+ !SerializeParts(this->entries, out)) {
+ return Error("Failed to write table");
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v1::GlatEntry::ParsePart(Buffer& table) {
+ if (!table.ReadU8(&this->attNum)) {
+ return parent->Error("GlatEntry: Failed to read attNum");
+ }
+ if (!table.ReadU8(&this->num)) {
+ return parent->Error("GlatEntry: Failed to read num");
+ }
+
+ //this->attributes.resize(this->num);
+ for (int i = 0; i < this->num; ++i) {
+ this->attributes.emplace_back();
+ if (!table.ReadS16(&this->attributes[i])) {
+ return parent->Error("GlatEntry: Failed to read attribute %u", i);
+ }
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v1::GlatEntry::SerializePart(OTSStream* out) const {
+ if (!out->WriteU8(this->attNum) ||
+ !out->WriteU8(this->num) ||
+ !SerializeParts(this->attributes, out)) {
+ return parent->Error("GlatEntry: Failed to write");
+ }
+ return true;
+}
+
+// -----------------------------------------------------------------------------
+// OpenTypeGLAT_v2
+// -----------------------------------------------------------------------------
+
+bool OpenTypeGLAT_v2::Parse(const uint8_t* data, size_t length) {
+ Buffer table(data, length);
+ OpenTypeGLOC* gloc = static_cast<OpenTypeGLOC*>(
+ GetFont()->GetTypedTable(OTS_TAG_GLOC));
+ if (!gloc) {
+ return DropGraphite("Required Gloc table is missing");
+ }
+
+ if (!table.ReadU32(&this->version) || this->version >> 16 != 1) {
+ return DropGraphite("Failed to read version");
+ }
+
+ const std::vector<uint32_t>& locations = gloc->GetLocations();
+ if (locations.empty()) {
+ return DropGraphite("No locations from Gloc table");
+ }
+ std::list<uint32_t> unverified(locations.begin(), locations.end());
+ while (table.remaining()) {
+ GlatEntry entry(this);
+ if (table.offset() > unverified.front()) {
+ return DropGraphite("Offset check failed for a GlatEntry");
+ }
+ if (table.offset() == unverified.front()) {
+ unverified.pop_front();
+ }
+ if (unverified.empty()) {
+ return DropGraphite("Expected more locations");
+ }
+ if (!entry.ParsePart(table)) {
+ return DropGraphite("Failed to read a GlatEntry");
+ }
+ this->entries.push_back(entry);
+ }
+
+ if (unverified.size() != 1 || unverified.front() != table.offset()) {
+ return DropGraphite("%zu location(s) could not be verified", unverified.size());
+ }
+ if (table.remaining()) {
+ return Warning("%zu bytes unparsed", table.remaining());
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v2::Serialize(OTSStream* out) {
+ if (!out->WriteU32(this->version) ||
+ !SerializeParts(this->entries, out)) {
+ return Error("Failed to write table");
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v2::GlatEntry::ParsePart(Buffer& table) {
+ if (!table.ReadS16(&this->attNum)) {
+ return parent->Error("GlatEntry: Failed to read attNum");
+ }
+ if (!table.ReadS16(&this->num) || this->num < 0) {
+ return parent->Error("GlatEntry: Failed to read valid num");
+ }
+
+ //this->attributes.resize(this->num);
+ for (int i = 0; i < this->num; ++i) {
+ this->attributes.emplace_back();
+ if (!table.ReadS16(&this->attributes[i])) {
+ return parent->Error("GlatEntry: Failed to read attribute %u", i);
+ }
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v2::GlatEntry::SerializePart(OTSStream* out) const {
+ if (!out->WriteS16(this->attNum) ||
+ !out->WriteS16(this->num) ||
+ !SerializeParts(this->attributes, out)) {
+ return parent->Error("GlatEntry: Failed to write");
+ }
+ return true;
+}
+
+// -----------------------------------------------------------------------------
+// OpenTypeGLAT_v3
+// -----------------------------------------------------------------------------
+
+bool OpenTypeGLAT_v3::Parse(const uint8_t* data, size_t length,
+ bool prevent_decompression) {
+ Buffer table(data, length);
+ OpenTypeGLOC* gloc = static_cast<OpenTypeGLOC*>(
+ GetFont()->GetTypedTable(OTS_TAG_GLOC));
+ if (!gloc) {
+ return DropGraphite("Required Gloc table is missing");
+ }
+
+ if (!table.ReadU32(&this->version) || this->version >> 16 != 3) {
+ return DropGraphite("Failed to read version");
+ }
+ if (!table.ReadU32(&this->compHead)) {
+ return DropGraphite("Failed to read compression header");
+ }
+ switch ((this->compHead & SCHEME) >> 27) {
+ case 0: // uncompressed
+ break;
+ case 1: { // lz4
+ if (prevent_decompression) {
+ return DropGraphite("Illegal nested compression");
+ }
+ size_t decompressed_size = this->compHead & FULL_SIZE;
+ if (decompressed_size < length) {
+ return DropGraphite("Decompressed size is less than compressed size");
+ }
+ if (decompressed_size == 0) {
+ return DropGraphite("Decompressed size is set to 0");
+ }
+ // decompressed table must be <= 30MB
+ if (decompressed_size > 30 * 1024 * 1024) {
+ return DropGraphite("Decompressed size exceeds 30MB: %gMB",
+ decompressed_size / (1024.0 * 1024.0));
+ }
+ std::vector<uint8_t> decompressed(decompressed_size);
+ size_t outputSize = 0;
+ bool ret = mozilla::Compression::LZ4::decompressPartial(
+ reinterpret_cast<const char*>(data + table.offset()),
+ table.remaining(), // input buffer size (input size + padding)
+ reinterpret_cast<char*>(decompressed.data()),
+ decompressed.size(), // target output size
+ &outputSize); // return output size
+ if (!ret || outputSize != decompressed.size()) {
+ return DropGraphite("Decompression failed");
+ }
+ return this->Parse(decompressed.data(), decompressed.size(), true);
+ }
+ default:
+ return DropGraphite("Unknown compression scheme");
+ }
+ if (this->compHead & RESERVED) {
+ Warning("Nonzero reserved");
+ }
+
+ const std::vector<uint32_t>& locations = gloc->GetLocations();
+ if (locations.empty()) {
+ return DropGraphite("No locations from Gloc table");
+ }
+ std::list<uint32_t> unverified(locations.begin(), locations.end());
+ //this->entries.resize(locations.size() - 1, this);
+ for (size_t i = 0; i < locations.size() - 1; ++i) {
+ this->entries.emplace_back(this);
+ if (table.offset() != unverified.front()) {
+ return DropGraphite("Offset check failed for a GlyphAttrs");
+ }
+ unverified.pop_front();
+ if (!this->entries[i].ParsePart(table,
+ unverified.front() - table.offset())) {
+ // unverified.front() is guaranteed to exist because of the number of
+ // iterations of this loop
+ return DropGraphite("Failed to read a GlyphAttrs");
+ }
+ }
+
+ if (unverified.size() != 1 || unverified.front() != table.offset()) {
+ return DropGraphite("%zu location(s) could not be verified", unverified.size());
+ }
+ if (table.remaining()) {
+ return Warning("%zu bytes unparsed", table.remaining());
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v3::Serialize(OTSStream* out) {
+ if (!out->WriteU32(this->version) ||
+ !out->WriteU32(this->compHead) ||
+ !SerializeParts(this->entries, out)) {
+ return Error("Failed to write table");
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v3::GlyphAttrs::ParsePart(Buffer& table, const size_t size) {
+ size_t init_offset = table.offset();
+ if (parent->compHead & OCTABOXES && !octabox.ParsePart(table)) {
+ // parent->flags & 0b1: octaboxes are present flag
+ return parent->Error("GlyphAttrs: Failed to read octabox");
+ }
+
+ while (table.offset() < init_offset + size) {
+ GlatEntry entry(parent);
+ if (!entry.ParsePart(table)) {
+ return parent->Error("GlyphAttrs: Failed to read a GlatEntry");
+ }
+ this->entries.push_back(entry);
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v3::GlyphAttrs::SerializePart(OTSStream* out) const {
+ if ((parent->compHead & OCTABOXES && !octabox.SerializePart(out)) ||
+ !SerializeParts(this->entries, out)) {
+ return parent->Error("GlyphAttrs: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v3::GlyphAttrs::
+OctaboxMetrics::ParsePart(Buffer& table) {
+ if (!table.ReadU16(&this->subbox_bitmap)) {
+ return parent->Error("OctaboxMetrics: Failed to read subbox_bitmap");
+ }
+ if (!table.ReadU8(&this->diag_neg_min)) {
+ return parent->Error("OctaboxMetrics: Failed to read diag_neg_min");
+ }
+ if (!table.ReadU8(&this->diag_neg_max) ||
+ this->diag_neg_max < this->diag_neg_min) {
+ return parent->Error("OctaboxMetrics: Failed to read valid diag_neg_max");
+ }
+ if (!table.ReadU8(&this->diag_pos_min)) {
+ return parent->Error("OctaboxMetrics: Failed to read diag_pos_min");
+ }
+ if (!table.ReadU8(&this->diag_pos_max) ||
+ this->diag_pos_max < this->diag_pos_min) {
+ return parent->Error("OctaboxMetrics: Failed to read valid diag_pos_max");
+ }
+
+ unsigned subboxes_len = 0; // count of 1's in this->subbox_bitmap
+ for (uint16_t i = this->subbox_bitmap; i; i >>= 1) {
+ if (i & 0b1) {
+ ++subboxes_len;
+ }
+ }
+ //this->subboxes.resize(subboxes_len, parent);
+ for (unsigned i = 0; i < subboxes_len; i++) {
+ this->subboxes.emplace_back(parent);
+ if (!this->subboxes[i].ParsePart(table)) {
+ return parent->Error("OctaboxMetrics: Failed to read subbox[%u]", i);
+ }
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v3::GlyphAttrs::
+OctaboxMetrics::SerializePart(OTSStream* out) const {
+ if (!out->WriteU16(this->subbox_bitmap) ||
+ !out->WriteU8(this->diag_neg_min) ||
+ !out->WriteU8(this->diag_neg_max) ||
+ !out->WriteU8(this->diag_pos_min) ||
+ !out->WriteU8(this->diag_pos_max) ||
+ !SerializeParts(this->subboxes, out)) {
+ return parent->Error("OctaboxMetrics: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v3::GlyphAttrs::OctaboxMetrics::
+SubboxEntry::ParsePart(Buffer& table) {
+ if (!table.ReadU8(&this->left)) {
+ return parent->Error("SubboxEntry: Failed to read left");
+ }
+ if (!table.ReadU8(&this->right) || this->right < this->left) {
+ return parent->Error("SubboxEntry: Failed to read valid right");
+ }
+ if (!table.ReadU8(&this->bottom)) {
+ return parent->Error("SubboxEntry: Failed to read bottom");
+ }
+ if (!table.ReadU8(&this->top) || this->top < this->bottom) {
+ return parent->Error("SubboxEntry: Failed to read valid top");
+ }
+ if (!table.ReadU8(&this->diag_pos_min)) {
+ return parent->Error("SubboxEntry: Failed to read diag_pos_min");
+ }
+ if (!table.ReadU8(&this->diag_pos_max) ||
+ this->diag_pos_max < this->diag_pos_min) {
+ return parent->Error("SubboxEntry: Failed to read valid diag_pos_max");
+ }
+ if (!table.ReadU8(&this->diag_neg_min)) {
+ return parent->Error("SubboxEntry: Failed to read diag_neg_min");
+ }
+ if (!table.ReadU8(&this->diag_neg_max) ||
+ this->diag_neg_max < this->diag_neg_min) {
+ return parent->Error("SubboxEntry: Failed to read valid diag_neg_max");
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v3::GlyphAttrs::OctaboxMetrics::
+SubboxEntry::SerializePart(OTSStream* out) const {
+ if (!out->WriteU8(this->left) ||
+ !out->WriteU8(this->right) ||
+ !out->WriteU8(this->bottom) ||
+ !out->WriteU8(this->top) ||
+ !out->WriteU8(this->diag_pos_min) ||
+ !out->WriteU8(this->diag_pos_max) ||
+ !out->WriteU8(this->diag_neg_min) ||
+ !out->WriteU8(this->diag_neg_max)) {
+ return parent->Error("SubboxEntry: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v3::GlyphAttrs::
+GlatEntry::ParsePart(Buffer& table) {
+ if (!table.ReadS16(&this->attNum)) {
+ return parent->Error("GlatEntry: Failed to read attNum");
+ }
+ if (!table.ReadS16(&this->num) || this->num < 0) {
+ return parent->Error("GlatEntry: Failed to read valid num");
+ }
+
+ //this->attributes.resize(this->num);
+ for (int i = 0; i < this->num; ++i) {
+ this->attributes.emplace_back();
+ if (!table.ReadS16(&this->attributes[i])) {
+ return parent->Error("GlatEntry: Failed to read attribute %u", i);
+ }
+ }
+ return true;
+}
+
+bool OpenTypeGLAT_v3::GlyphAttrs::
+GlatEntry::SerializePart(OTSStream* out) const {
+ if (!out->WriteS16(this->attNum) ||
+ !out->WriteS16(this->num) ||
+ !SerializeParts(this->attributes, out)) {
+ return parent->Error("GlatEntry: Failed to write");
+ }
+ return true;
+}
+
+// -----------------------------------------------------------------------------
+// OpenTypeGLAT
+// -----------------------------------------------------------------------------
+
+bool OpenTypeGLAT::Parse(const uint8_t* data, size_t length) {
+ if (GetFont()->dropped_graphite) {
+ return Drop("Skipping Graphite table");
+ }
+ Buffer table(data, length);
+ uint32_t version;
+ if (!table.ReadU32(&version)) {
+ return DropGraphite("Failed to read version");
+ }
+ switch (version >> 16) {
+ case 1:
+ this->handler = new OpenTypeGLAT_v1(this->font, this->tag);
+ break;
+ case 2:
+ this->handler = new OpenTypeGLAT_v2(this->font, this->tag);
+ break;
+ case 3: {
+ this->handler = new OpenTypeGLAT_v3(this->font, this->tag);
+ break;
+ }
+ default:
+ return DropGraphite("Unsupported table version: %u", version >> 16);
+ }
+ return this->handler->Parse(data, length);
+}
+
+bool OpenTypeGLAT::Serialize(OTSStream* out) {
+ if (!this->handler) {
+ return Error("No Glat table parsed");
+ }
+ return this->handler->Serialize(out);
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/glat.h b/gfx/ots/src/glat.h
new file mode 100644
index 000000000..04c9c1cce
--- /dev/null
+++ b/gfx/ots/src/glat.h
@@ -0,0 +1,172 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_GLAT_H_
+#define OTS_GLAT_H_
+
+#include <vector>
+
+#include "ots.h"
+#include "graphite.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeGLAT_Basic Interface
+// -----------------------------------------------------------------------------
+
+class OpenTypeGLAT_Basic : public Table {
+ public:
+ explicit OpenTypeGLAT_Basic(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ virtual bool Parse(const uint8_t* data, size_t length) = 0;
+ virtual bool Serialize(OTSStream* out) = 0;
+};
+
+// -----------------------------------------------------------------------------
+// OpenTypeGLAT_v1
+// -----------------------------------------------------------------------------
+
+class OpenTypeGLAT_v1 : public OpenTypeGLAT_Basic {
+ public:
+ explicit OpenTypeGLAT_v1(Font* font, uint32_t tag)
+ : OpenTypeGLAT_Basic(font, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ struct GlatEntry : public TablePart<OpenTypeGLAT_v1> {
+ explicit GlatEntry(OpenTypeGLAT_v1* parent)
+ : TablePart<OpenTypeGLAT_v1>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ uint8_t attNum;
+ uint8_t num;
+ std::vector<int16_t> attributes;
+ };
+ uint32_t version;
+ std::vector<GlatEntry> entries;
+};
+
+// -----------------------------------------------------------------------------
+// OpenTypeGLAT_v2
+// -----------------------------------------------------------------------------
+
+class OpenTypeGLAT_v2 : public OpenTypeGLAT_Basic {
+ public:
+ explicit OpenTypeGLAT_v2(Font* font, uint32_t tag)
+ : OpenTypeGLAT_Basic(font, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ struct GlatEntry : public TablePart<OpenTypeGLAT_v2> {
+ explicit GlatEntry(OpenTypeGLAT_v2* parent)
+ : TablePart<OpenTypeGLAT_v2>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ int16_t attNum;
+ int16_t num;
+ std::vector<int16_t> attributes;
+ };
+ uint32_t version;
+ std::vector<GlatEntry> entries;
+};
+
+// -----------------------------------------------------------------------------
+// OpenTypeGLAT_v3
+// -----------------------------------------------------------------------------
+
+class OpenTypeGLAT_v3 : public OpenTypeGLAT_Basic {
+ public:
+ explicit OpenTypeGLAT_v3(Font* font, uint32_t tag)
+ : OpenTypeGLAT_Basic(font, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length) {
+ return this->Parse(data, length, false);
+ }
+ bool Serialize(OTSStream* out);
+
+ private:
+ bool Parse(const uint8_t* data, size_t length, bool prevent_decompression);
+ struct GlyphAttrs : public TablePart<OpenTypeGLAT_v3> {
+ explicit GlyphAttrs(OpenTypeGLAT_v3* parent)
+ : TablePart<OpenTypeGLAT_v3>(parent), octabox(parent) { }
+ bool ParsePart(Buffer& table) { return false; }
+ bool ParsePart(Buffer& table, const size_t size);
+ bool SerializePart(OTSStream* out) const;
+ struct OctaboxMetrics : public TablePart<OpenTypeGLAT_v3> {
+ explicit OctaboxMetrics(OpenTypeGLAT_v3* parent)
+ : TablePart<OpenTypeGLAT_v3>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ struct SubboxEntry : public TablePart<OpenTypeGLAT_v3> {
+ explicit SubboxEntry(OpenTypeGLAT_v3* parent)
+ : TablePart<OpenTypeGLAT_v3>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ uint8_t left;
+ uint8_t right;
+ uint8_t bottom;
+ uint8_t top;
+ uint8_t diag_pos_min;
+ uint8_t diag_pos_max;
+ uint8_t diag_neg_min;
+ uint8_t diag_neg_max;
+ };
+ uint16_t subbox_bitmap;
+ uint8_t diag_neg_min;
+ uint8_t diag_neg_max;
+ uint8_t diag_pos_min;
+ uint8_t diag_pos_max;
+ std::vector<SubboxEntry> subboxes;
+ };
+ struct GlatEntry : public TablePart<OpenTypeGLAT_v3> {
+ explicit GlatEntry(OpenTypeGLAT_v3* parent)
+ : TablePart<OpenTypeGLAT_v3>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ int16_t attNum;
+ int16_t num;
+ std::vector<int16_t> attributes;
+ };
+ OctaboxMetrics octabox;
+ std::vector<GlatEntry> entries;
+ };
+ uint32_t version;
+ uint32_t compHead; // compression header
+ static const uint32_t SCHEME = 0xF8000000;
+ static const uint32_t FULL_SIZE = 0x07FFFFFF;
+ static const uint32_t RESERVED = 0x07FFFFFE;
+ static const uint32_t OCTABOXES = 0x00000001;
+ std::vector<GlyphAttrs> entries;
+};
+
+// -----------------------------------------------------------------------------
+// OpenTypeGLAT
+// -----------------------------------------------------------------------------
+
+class OpenTypeGLAT : public Table {
+ public:
+ explicit OpenTypeGLAT(Font* font, uint32_t tag)
+ : Table(font, tag, tag), font(font), tag(tag) { }
+ OpenTypeGLAT(const OpenTypeGLAT& other) = delete;
+ OpenTypeGLAT& operator=(const OpenTypeGLAT& other) = delete;
+ ~OpenTypeGLAT() { delete handler; }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ Font* font;
+ uint32_t tag;
+ OpenTypeGLAT_Basic* handler = nullptr;
+};
+
+} // namespace ots
+
+#endif // OTS_GLAT_H_
diff --git a/gfx/ots/src/gloc.cc b/gfx/ots/src/gloc.cc
new file mode 100644
index 000000000..9c5ee3bdf
--- /dev/null
+++ b/gfx/ots/src/gloc.cc
@@ -0,0 +1,108 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gloc.h"
+
+#include "name.h"
+
+namespace ots {
+
+bool OpenTypeGLOC::Parse(const uint8_t* data, size_t length) {
+ if (GetFont()->dropped_graphite) {
+ return Drop("Skipping Graphite table");
+ }
+ Buffer table(data, length);
+ OpenTypeNAME* name = static_cast<OpenTypeNAME*>(
+ GetFont()->GetTypedTable(OTS_TAG_NAME));
+ if (!name) {
+ return DropGraphite("Required name table is missing");
+ }
+
+ if (!table.ReadU32(&this->version)) {
+ return DropGraphite("Failed to read version");
+ }
+ if (this->version >> 16 != 1) {
+ return DropGraphite("Unsupported table version: %u", this->version >> 16);
+ }
+ if (!table.ReadU16(&this->flags) || this->flags > 0b11) {
+ return DropGraphite("Failed to read valid flags");
+ }
+ if (!table.ReadU16(&this->numAttribs)) {
+ return DropGraphite("Failed to read numAttribs");
+ }
+
+ if (this->flags & ATTRIB_IDS && this->numAttribs * sizeof(uint16_t) >
+ table.remaining()) {
+ return DropGraphite("Failed to calulate length of locations");
+ }
+ size_t locations_len = (table.remaining() -
+ (this->flags & ATTRIB_IDS ? this->numAttribs * sizeof(uint16_t) : 0)) /
+ (this->flags & LONG_FORMAT ? sizeof(uint32_t) : sizeof(uint16_t));
+ //this->locations.resize(locations_len);
+ if (this->flags & LONG_FORMAT) {
+ unsigned long last_location = 0;
+ for (size_t i = 0; i < locations_len; ++i) {
+ this->locations.emplace_back();
+ uint32_t& location = this->locations[i];
+ if (!table.ReadU32(&location) || location < last_location) {
+ return DropGraphite("Failed to read valid locations[%lu]", i);
+ }
+ last_location = location;
+ }
+ } else { // short (16-bit) offsets
+ unsigned last_location = 0;
+ for (size_t i = 0; i < locations_len; ++i) {
+ uint16_t location;
+ if (!table.ReadU16(&location) || location < last_location) {
+ return DropGraphite("Failed to read valid locations[%lu]", i);
+ }
+ last_location = location;
+ this->locations.push_back(static_cast<uint32_t>(location));
+ }
+ }
+ if (this->locations.empty()) {
+ return DropGraphite("No locations");
+ }
+
+ if (this->flags & ATTRIB_IDS) { // attribIds array present
+ //this->attribIds.resize(numAttribs);
+ for (unsigned i = 0; i < this->numAttribs; ++i) {
+ this->attribIds.emplace_back();
+ if (!table.ReadU16(&this->attribIds[i]) ||
+ !name->IsValidNameId(this->attribIds[i])) {
+ return DropGraphite("Failed to read valid attribIds[%u]", i);
+ }
+ }
+ }
+
+ if (table.remaining()) {
+ return Warning("%zu bytes unparsed", table.remaining());
+ }
+ return true;
+}
+
+bool OpenTypeGLOC::Serialize(OTSStream* out) {
+ if (!out->WriteU32(this->version) ||
+ !out->WriteU16(this->flags) ||
+ !out->WriteU16(this->numAttribs) ||
+ (this->flags & LONG_FORMAT ? !SerializeParts(this->locations, out) :
+ ![&] {
+ for (uint32_t location : this->locations) {
+ if (!out->WriteU16(static_cast<uint16_t>(location))) {
+ return false;
+ }
+ }
+ return true;
+ }()) ||
+ (this->flags & ATTRIB_IDS && !SerializeParts(this->attribIds, out))) {
+ return Error("Failed to write table");
+ }
+ return true;
+}
+
+const std::vector<uint32_t>& OpenTypeGLOC::GetLocations() {
+ return this->locations;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/gloc.h b/gfx/ots/src/gloc.h
new file mode 100644
index 000000000..60184ffb9
--- /dev/null
+++ b/gfx/ots/src/gloc.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_GLOC_H_
+#define OTS_GLOC_H_
+
+#include <vector>
+
+#include "ots.h"
+#include "graphite.h"
+
+namespace ots {
+
+class OpenTypeGLOC : public Table {
+ public:
+ explicit OpenTypeGLOC(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+ const std::vector<uint32_t>& GetLocations();
+
+ private:
+ uint32_t version;
+ uint16_t flags;
+ static const uint16_t LONG_FORMAT = 0b1;
+ static const uint16_t ATTRIB_IDS = 0b10;
+ uint16_t numAttribs;
+ std::vector<uint32_t> locations;
+ std::vector<uint16_t> attribIds;
+};
+
+} // namespace ots
+
+#endif // OTS_GLOC_H_
diff --git a/gfx/ots/src/glyf.cc b/gfx/ots/src/glyf.cc
index 311916dc0..0c19d6d7b 100644
--- a/gfx/ots/src/glyf.cc
+++ b/gfx/ots/src/glyf.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,20 +14,15 @@
// glyf - Glyph Data
// http://www.microsoft.com/typography/otspec/glyf.htm
-#define TABLE_NAME "glyf"
-
-namespace {
+namespace ots {
-bool ParseFlagsForSimpleGlyph(ots::Font *font,
- ots::Buffer *table,
- uint32_t gly_length,
- uint32_t num_flags,
- uint32_t *flags_count_logical,
- uint32_t *flags_count_physical,
- uint32_t *xy_coordinates_length) {
+bool OpenTypeGLYF::ParseFlagsForSimpleGlyph(Buffer &glyph,
+ uint32_t num_flags,
+ uint32_t *flag_index,
+ uint32_t *coordinates_length) {
uint8_t flag = 0;
- if (!table->ReadU8(&flag)) {
- return OTS_FAILURE_MSG("Can't read flag");
+ if (!glyph.ReadU8(&flag)) {
+ return Error("Can't read flag");
}
uint32_t delta = 0;
@@ -43,140 +38,205 @@ bool ParseFlagsForSimpleGlyph(ots::Font *font,
delta += 2;
}
+ /* MS and Apple specs say this bit is reserved and must be set to zero, but
+ * Apple spec then contradicts itself and says it should be set on the first
+ * contour flag for simple glyphs with overlapping contours:
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6AATIntro.html
+ * (“Overlapping contours†section) */
+ if (flag & (1u << 6) && *flag_index != 0) {
+ return Error("Bad glyph flag (%d), "
+ "bit 6 must be set to zero for flag %d", flag, *flag_index);
+ }
+
if (flag & (1u << 3)) { // repeat
- if (*flags_count_logical + 1 >= num_flags) {
- return OTS_FAILURE_MSG("Count too high (%d + 1 >= %d)", *flags_count_logical, num_flags);
+ if (*flag_index + 1 >= num_flags) {
+ return Error("Count too high (%d + 1 >= %d)", *flag_index, num_flags);
}
uint8_t repeat = 0;
- if (!table->ReadU8(&repeat)) {
- return OTS_FAILURE_MSG("Can't read repeat value");
+ if (!glyph.ReadU8(&repeat)) {
+ return Error("Can't read repeat value");
}
if (repeat == 0) {
- return OTS_FAILURE_MSG("Zero repeat");
+ return Error("Zero repeat");
}
delta += (delta * repeat);
- *flags_count_logical += repeat;
- if (*flags_count_logical >= num_flags) {
- return OTS_FAILURE_MSG("Count too high (%d >= %d)", *flags_count_logical, num_flags);
+ *flag_index += repeat;
+ if (*flag_index >= num_flags) {
+ return Error("Count too high (%d >= %d)", *flag_index, num_flags);
}
- ++(*flags_count_physical);
}
- if ((flag & (1u << 6)) || (flag & (1u << 7))) { // reserved flags
- return OTS_FAILURE_MSG("Bad glyph flag value (%d), reserved flags must be set to zero", flag);
+ if (flag & (1u << 7)) { // reserved flag
+ return Error("Bad glyph flag (%d), reserved bit 7 must be set to zero", flag);
}
- *xy_coordinates_length += delta;
- if (gly_length < *xy_coordinates_length) {
- return OTS_FAILURE_MSG("Glyph coordinates length too low (%d < %d)", gly_length, *xy_coordinates_length);
+ *coordinates_length += delta;
+ if (glyph.length() < *coordinates_length) {
+ return Error("Glyph coordinates length bigger than glyph length (%d > %d)",
+ *coordinates_length, glyph.length());
}
return true;
}
-bool ParseSimpleGlyph(ots::Font *font, const uint8_t *data,
- ots::Buffer *table, int16_t num_contours,
- uint32_t gly_offset, uint32_t gly_length,
- uint32_t *new_size) {
- ots::OpenTypeGLYF *glyf = font->glyf;
-
+bool OpenTypeGLYF::ParseSimpleGlyph(Buffer &glyph,
+ int16_t num_contours) {
// read the end-points array
uint16_t num_flags = 0;
for (int i = 0; i < num_contours; ++i) {
uint16_t tmp_index = 0;
- if (!table->ReadU16(&tmp_index)) {
- return OTS_FAILURE_MSG("Can't read contour index %d", i);
+ if (!glyph.ReadU16(&tmp_index)) {
+ return Error("Can't read contour index %d", i);
}
if (tmp_index == 0xffffu) {
- return OTS_FAILURE_MSG("Bad contour index %d", i);
+ return Error("Bad contour index %d", i);
}
// check if the indices are monotonically increasing
if (i && (tmp_index + 1 <= num_flags)) {
- return OTS_FAILURE_MSG("Decreasing contour index %d + 1 <= %d", tmp_index, num_flags);
+ return Error("Decreasing contour index %d + 1 <= %d", tmp_index, num_flags);
}
num_flags = tmp_index + 1;
}
uint16_t bytecode_length = 0;
- if (!table->ReadU16(&bytecode_length)) {
- return OTS_FAILURE_MSG("Can't read bytecode length");
- }
- if ((font->maxp->version_1) &&
- (font->maxp->max_size_glyf_instructions < bytecode_length)) {
- return OTS_FAILURE_MSG("Bytecode length too high %d", bytecode_length);
+ if (!glyph.ReadU16(&bytecode_length)) {
+ return Error("Can't read bytecode length");
}
- const uint32_t gly_header_length = 10 + num_contours * 2 + 2;
- if (gly_length < (gly_header_length + bytecode_length)) {
- return OTS_FAILURE_MSG("Glyph header length too high %d", gly_header_length);
+ if (this->maxp->version_1 &&
+ this->maxp->max_size_glyf_instructions < bytecode_length) {
+ this->maxp->max_size_glyf_instructions = bytecode_length;
+ Warning("Bytecode length is bigger than maxp.maxSizeOfInstructions %d: %d",
+ this->maxp->max_size_glyf_instructions, bytecode_length);
}
- glyf->iov.push_back(std::make_pair(
- data + gly_offset,
- static_cast<size_t>(gly_header_length + bytecode_length)));
-
- if (!table->Skip(bytecode_length)) {
- return OTS_FAILURE_MSG("Can't skip bytecode of length %d", bytecode_length);
+ if (!glyph.Skip(bytecode_length)) {
+ return Error("Can't read bytecode of length %d", bytecode_length);
}
- uint32_t flags_count_physical = 0; // on memory
- uint32_t xy_coordinates_length = 0;
- for (uint32_t flags_count_logical = 0;
- flags_count_logical < num_flags;
- ++flags_count_logical, ++flags_count_physical) {
- if (!ParseFlagsForSimpleGlyph(font,
- table,
- gly_length,
- num_flags,
- &flags_count_logical,
- &flags_count_physical,
- &xy_coordinates_length)) {
- return OTS_FAILURE_MSG("Failed to parse glyph flags %d", flags_count_logical);
+ uint32_t coordinates_length = 0;
+ for (uint32_t i = 0; i < num_flags; ++i) {
+ if (!ParseFlagsForSimpleGlyph(glyph, num_flags, &i, &coordinates_length)) {
+ return Error("Failed to parse glyph flags %d", i);
}
}
- if (gly_length < (gly_header_length + bytecode_length +
- flags_count_physical + xy_coordinates_length)) {
- return OTS_FAILURE_MSG("Glyph too short %d", gly_length);
+ if (!glyph.Skip(coordinates_length)) {
+ return Error("Glyph too short %d", glyph.length());
}
- if (gly_length - (gly_header_length + bytecode_length +
- flags_count_physical + xy_coordinates_length) > 3) {
+ if (glyph.remaining() > 3) {
// We allow 0-3 bytes difference since gly_length is 4-bytes aligned,
// zero-padded length.
- return OTS_FAILURE_MSG("Invalid glyph length %d", gly_length);
+ Warning("Extra bytes at end of the glyph: %d", glyph.remaining());
}
- glyf->iov.push_back(std::make_pair(
- data + gly_offset + gly_header_length + bytecode_length,
- static_cast<size_t>(flags_count_physical + xy_coordinates_length)));
-
- *new_size
- = gly_header_length + flags_count_physical + xy_coordinates_length + bytecode_length;
+ this->iov.push_back(std::make_pair(glyph.buffer(), glyph.offset()));
return true;
}
-} // namespace
+#define ARG_1_AND_2_ARE_WORDS (1u << 0)
+#define WE_HAVE_A_SCALE (1u << 3)
+#define MORE_COMPONENTS (1u << 5)
+#define WE_HAVE_AN_X_AND_Y_SCALE (1u << 6)
+#define WE_HAVE_A_TWO_BY_TWO (1u << 7)
+#define WE_HAVE_INSTRUCTIONS (1u << 8)
+
+bool OpenTypeGLYF::ParseCompositeGlyph(Buffer &glyph) {
+ uint16_t flags = 0;
+ uint16_t gid = 0;
+ do {
+ if (!glyph.ReadU16(&flags) || !glyph.ReadU16(&gid)) {
+ return Error("Can't read composite glyph flags or glyphIndex");
+ }
-namespace ots {
+ if (gid >= this->maxp->num_glyphs) {
+ return Error("Invalid glyph id used in composite glyph: %d", gid);
+ }
+
+ if (flags & ARG_1_AND_2_ARE_WORDS) {
+ int16_t argument1;
+ int16_t argument2;
+ if (!glyph.ReadS16(&argument1) || !glyph.ReadS16(&argument2)) {
+ return Error("Can't read argument1 or argument2");
+ }
+ } else {
+ uint8_t argument1;
+ uint8_t argument2;
+ if (!glyph.ReadU8(&argument1) || !glyph.ReadU8(&argument2)) {
+ return Error("Can't read argument1 or argument2");
+ }
+ }
+
+ if (flags & WE_HAVE_A_SCALE) {
+ int16_t scale;
+ if (!glyph.ReadS16(&scale)) {
+ return Error("Can't read scale");
+ }
+ } else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
+ int16_t xscale;
+ int16_t yscale;
+ if (!glyph.ReadS16(&xscale) || !glyph.ReadS16(&yscale)) {
+ return Error("Can't read xscale or yscale");
+ }
+ } else if (flags & WE_HAVE_A_TWO_BY_TWO) {
+ int16_t xscale;
+ int16_t scale01;
+ int16_t scale10;
+ int16_t yscale;
+ if (!glyph.ReadS16(&xscale) ||
+ !glyph.ReadS16(&scale01) ||
+ !glyph.ReadS16(&scale10) ||
+ !glyph.ReadS16(&yscale)) {
+ return Error("Can't read transform");
+ }
+ }
+ } while (flags & MORE_COMPONENTS);
+
+ if (flags & WE_HAVE_INSTRUCTIONS) {
+ uint16_t bytecode_length;
+ if (!glyph.ReadU16(&bytecode_length)) {
+ return Error("Can't read instructions size");
+ }
-bool ots_glyf_parse(Font *font, const uint8_t *data, size_t length) {
- Buffer table(data, length);
+ if (this->maxp->version_1 &&
+ this->maxp->max_size_glyf_instructions < bytecode_length) {
+ this->maxp->max_size_glyf_instructions = bytecode_length;
+ Warning("Bytecode length is bigger than maxp.maxSizeOfInstructions "
+ "%d: %d",
+ this->maxp->max_size_glyf_instructions, bytecode_length);
+ }
- if (!font->maxp || !font->loca || !font->head) {
- return OTS_FAILURE_MSG("Missing maxp or loca or head table needed by glyf table");
+ if (!glyph.Skip(bytecode_length)) {
+ return Error("Can't read bytecode of length %d", bytecode_length);
+ }
}
- OpenTypeGLYF *glyf = new OpenTypeGLYF;
- font->glyf = glyf;
+ this->iov.push_back(std::make_pair(glyph.buffer(), glyph.offset()));
- const unsigned num_glyphs = font->maxp->num_glyphs;
- std::vector<uint32_t> &offsets = font->loca->offsets;
+ return true;
+}
+
+bool OpenTypeGLYF::Parse(const uint8_t *data, size_t length) {
+ OpenTypeMAXP *maxp = static_cast<OpenTypeMAXP*>(
+ GetFont()->GetTypedTable(OTS_TAG_MAXP));
+ OpenTypeLOCA *loca = static_cast<OpenTypeLOCA*>(
+ GetFont()->GetTypedTable(OTS_TAG_LOCA));
+ OpenTypeHEAD *head = static_cast<OpenTypeHEAD*>(
+ GetFont()->GetTypedTable(OTS_TAG_HEAD));
+ if (!maxp || !loca || !head) {
+ return Error("Missing maxp or loca or head table needed by glyf table");
+ }
+
+ this->maxp = maxp;
+
+ const unsigned num_glyphs = maxp->num_glyphs;
+ std::vector<uint32_t> &offsets = loca->offsets;
if (offsets.size() != num_glyphs + 1) {
- return OTS_FAILURE_MSG("Invalide glyph offsets size %ld != %d", offsets.size(), num_glyphs + 1);
+ return Error("Invalide glyph offsets size %ld != %d", offsets.size(), num_glyphs + 1);
}
std::vector<uint32_t> resulting_offsets(num_glyphs + 1);
@@ -193,30 +253,31 @@ bool ots_glyf_parse(Font *font, const uint8_t *data, size_t length) {
}
if (gly_offset >= length) {
- return OTS_FAILURE_MSG("Glyph %d offset %d too high %ld", i, gly_offset, length);
+ return Error("Glyph %d offset %d too high %ld", i, gly_offset, length);
}
// Since these are unsigned types, the compiler is not allowed to assume
// that they never overflow.
if (gly_offset + gly_length < gly_offset) {
- return OTS_FAILURE_MSG("Glyph %d length (%d < 0)!", i, gly_length);
+ return Error("Glyph %d length (%d < 0)!", i, gly_length);
}
if (gly_offset + gly_length > length) {
- return OTS_FAILURE_MSG("Glyph %d length %d too high", i, gly_length);
+ return Error("Glyph %d length %d too high", i, gly_length);
}
- table.set_offset(gly_offset);
+ Buffer glyph(data + gly_offset, gly_length);
+
int16_t num_contours, xmin, ymin, xmax, ymax;
- if (!table.ReadS16(&num_contours) ||
- !table.ReadS16(&xmin) ||
- !table.ReadS16(&ymin) ||
- !table.ReadS16(&xmax) ||
- !table.ReadS16(&ymax)) {
- return OTS_FAILURE_MSG("Can't read glyph %d header", i);
+ if (!glyph.ReadS16(&num_contours) ||
+ !glyph.ReadS16(&xmin) ||
+ !glyph.ReadS16(&ymin) ||
+ !glyph.ReadS16(&xmax) ||
+ !glyph.ReadS16(&ymax)) {
+ return Error("Can't read glyph %d header", i);
}
if (num_contours <= -2) {
// -2, -3, -4, ... are reserved for future use.
- return OTS_FAILURE_MSG("Bad number of contours %d in glyph %d", num_contours, i);
+ return Error("Bad number of contours %d in glyph %d", num_contours, i);
}
// workaround for fonts in http://www.princexml.com/fonts/
@@ -224,35 +285,36 @@ bool ots_glyf_parse(Font *font, const uint8_t *data, size_t length) {
(xmax == -32767) &&
(ymin == 32767) &&
(ymax == -32767)) {
- OTS_WARNING("bad xmin/xmax/ymin/ymax values");
+ Warning("bad xmin/xmax/ymin/ymax values");
xmin = xmax = ymin = ymax = 0;
}
if (xmin > xmax || ymin > ymax) {
- return OTS_FAILURE_MSG("Bad bounding box values bl=(%d, %d), tr=(%d, %d) in glyph %d", xmin, ymin, xmax, ymax, i);
+ return Error("Bad bounding box values bl=(%d, %d), tr=(%d, %d) in glyph %d", xmin, ymin, xmax, ymax, i);
}
- unsigned new_size = 0;
- if (num_contours >= 0) {
- // this is a simple glyph and might contain bytecode
- if (!ParseSimpleGlyph(font, data, &table,
- num_contours, gly_offset, gly_length, &new_size)) {
- return OTS_FAILURE_MSG("Failed to parse glyph %d", i);
+ if (num_contours == 0) {
+ // This is an empty glyph and shouldn’t have any glyph data, but if it
+ // does we will simply ignore it.
+ glyph.set_offset(0);
+ } else if (num_contours > 0) {
+ if (!ParseSimpleGlyph(glyph, num_contours)) {
+ return Error("Failed to parse glyph %d", i);
}
} else {
- // it's a composite glyph without any bytecode. Enqueue the whole thing
- glyf->iov.push_back(std::make_pair(data + gly_offset,
- static_cast<size_t>(gly_length)));
- new_size = gly_length;
+ if (!ParseCompositeGlyph(glyph)) {
+ return Error("Failed to parse glyph %d", i);
+ }
}
+ size_t new_size = glyph.offset();
resulting_offsets[i] = current_offset;
// glyphs must be four byte aligned
// TODO(yusukes): investigate whether this padding is really necessary.
// Which part of the spec requires this?
const unsigned padding = (4 - (new_size & 3)) % 4;
if (padding) {
- glyf->iov.push_back(std::make_pair(
+ this->iov.push_back(std::make_pair(
reinterpret_cast<const uint8_t*>("\x00\x00\x00\x00"),
static_cast<size_t>(padding)));
new_size += padding;
@@ -264,40 +326,32 @@ bool ots_glyf_parse(Font *font, const uint8_t *data, size_t length) {
const uint16_t max16 = std::numeric_limits<uint16_t>::max();
if ((*std::max_element(resulting_offsets.begin(),
resulting_offsets.end()) >= (max16 * 2u)) &&
- (font->head->index_to_loc_format != 1)) {
- OTS_WARNING("2-bytes indexing is not possible (due to the padding above)");
- font->head->index_to_loc_format = 1;
+ (head->index_to_loc_format != 1)) {
+ head->index_to_loc_format = 1;
}
- font->loca->offsets = resulting_offsets;
- return true;
-}
-
-bool ots_glyf_should_serialise(Font *font) {
- return font->glyf != NULL;
-}
-
-bool ots_glyf_serialise(OTSStream *out, Font *font) {
- const OpenTypeGLYF *glyf = font->glyf;
+ loca->offsets = resulting_offsets;
- for (unsigned i = 0; i < glyf->iov.size(); ++i) {
- if (!out->Write(glyf->iov[i].first, glyf->iov[i].second)) {
- return OTS_FAILURE_MSG("Falied to write glyph %d", i);
- }
+ if (this->iov.empty()) {
+ // As a special case when all glyph in the font are empty, add a zero byte
+ // to the table, so that we don’t reject it down the way, and to make the
+ // table work on Windows as well.
+ // See https://github.com/khaledhosny/ots/issues/52
+ static const uint8_t kZero = 0;
+ this->iov.push_back(std::make_pair(&kZero, 1));
}
return true;
}
-void ots_glyf_reuse(Font *font, Font *other) {
- font->glyf = other->glyf;
- font->glyf_reused = true;
-}
+bool OpenTypeGLYF::Serialize(OTSStream *out) {
+ for (unsigned i = 0; i < this->iov.size(); ++i) {
+ if (!out->Write(this->iov[i].first, this->iov[i].second)) {
+ return Error("Falied to write glyph %d", i);
+ }
+ }
-void ots_glyf_free(Font *font) {
- delete font->glyf;
+ return true;
}
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/glyf.h b/gfx/ots/src/glyf.h
index 9a8baf5ec..1da94e4b9 100644
--- a/gfx/ots/src/glyf.h
+++ b/gfx/ots/src/glyf.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,8 +12,26 @@
#include "ots.h"
namespace ots {
+class OpenTypeMAXP;
+
+class OpenTypeGLYF : public Table {
+ public:
+ explicit OpenTypeGLYF(Font *font, uint32_t tag)
+ : Table(font, tag, tag), maxp(NULL) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
+ private:
+ bool ParseFlagsForSimpleGlyph(Buffer &glyph,
+ uint32_t num_flags,
+ uint32_t *flag_index,
+ uint32_t *coordinates_length);
+ bool ParseSimpleGlyph(Buffer &glyph, int16_t num_contours);
+ bool ParseCompositeGlyph(Buffer &glyph);
+
+ OpenTypeMAXP* maxp;
-struct OpenTypeGLYF {
std::vector<std::pair<const uint8_t*, size_t> > iov;
};
diff --git a/gfx/ots/src/gpos.cc b/gfx/ots/src/gpos.cc
index 83d9ab053..034f9799d 100644
--- a/gfx/ots/src/gpos.cc
+++ b/gfx/ots/src/gpos.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -30,12 +30,12 @@ enum GPOS_TYPE {
GPOS_TYPE_RESERVED = 10
};
-// The size of gpos header.
-const unsigned kGposHeaderSize = 10;
+// The size of gpos header, version 1.0.
+const unsigned kGposHeaderSize_1_0 = 10;
+// The size of gpos header, version 1.1.
+const unsigned kGposHeaderSize_1_1 = 14;
// The maximum format number for anchor tables.
const uint16_t kMaxAnchorFormat = 3;
-// The maximum number of class value.
-const uint16_t kMaxClassDefValue = 0xFFFF;
// Lookup type parsers.
bool ParseSingleAdjustment(const ots::Font *font,
@@ -76,9 +76,23 @@ const ots::LookupSubtableParser kGposLookupSubtableParser = {
// Shared Tables: ValueRecord, Anchor Table, and MarkArray
+size_t CalcValueRecordSize(const uint16_t value_format) {
+ size_t size = 0;
+ for (unsigned i = 0; i < 8; ++i) {
+ if ((value_format >> i) & 0x1) {
+ size += 2;
+ }
+ }
+
+ return size;
+}
+
bool ParseValueRecord(const ots::Font *font,
- ots::Buffer* subtable, const uint8_t *data,
- const size_t length, const uint16_t value_format) {
+ ots::Buffer* subtable,
+ const uint16_t value_format) {
+ const uint8_t *data = subtable->buffer();
+ const size_t length = subtable->length();
+
// Check existence of adjustment fields.
for (unsigned i = 0; i < 4; ++i) {
if ((value_format >> i) & 0x1) {
@@ -207,6 +221,12 @@ bool ParseSingleAdjustment(const ots::Font *font, const uint8_t *data,
const size_t length) {
ots::Buffer subtable(data, length);
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+
uint16_t format = 0;
uint16_t offset_coverage = 0;
uint16_t value_format = 0;
@@ -218,7 +238,7 @@ bool ParseSingleAdjustment(const ots::Font *font, const uint8_t *data,
if (format == 1) {
// Format 1 exactly one value record.
- if (!ParseValueRecord(font, &subtable, data, length, value_format)) {
+ if (!ParseValueRecord(font, &subtable, value_format)) {
return OTS_FAILURE_MSG("Failed to parse format 1 single adjustment table");
}
} else if (format == 2) {
@@ -227,7 +247,7 @@ bool ParseSingleAdjustment(const ots::Font *font, const uint8_t *data,
return OTS_FAILURE_MSG("Failed to parse format 2 single adjustment table");
}
for (unsigned i = 0; i < value_count; ++i) {
- if (!ParseValueRecord(font, &subtable, data, length, value_format)) {
+ if (!ParseValueRecord(font, &subtable, value_format)) {
return OTS_FAILURE_MSG("Failed to parse value record %d in format 2 single adjustment table", i);
}
}
@@ -241,7 +261,7 @@ bool ParseSingleAdjustment(const ots::Font *font, const uint8_t *data,
if (!ots::ParseCoverageTable(font, data + offset_coverage,
length - offset_coverage,
- font->maxp->num_glyphs)) {
+ maxp->num_glyphs)) {
return OTS_FAILURE_MSG("Failed to parse coverage table in single adjustment table");
}
@@ -268,10 +288,10 @@ bool ParsePairSetTable(const ots::Font *font,
if (glyph_id >= num_glyphs) {
return OTS_FAILURE_MSG("glyph id %d too high >= %d", glyph_id, num_glyphs);
}
- if (!ParseValueRecord(font, &subtable, data, length, value_format1)) {
+ if (!ParseValueRecord(font, &subtable, value_format1)) {
return OTS_FAILURE_MSG("Failed to parse value record in format 1 pair set table");
}
- if (!ParseValueRecord(font, &subtable, data, length, value_format2)) {
+ if (!ParseValueRecord(font, &subtable, value_format2)) {
return OTS_FAILURE_MSG("Failed to parse value record in format 2 pair set table");
}
}
@@ -341,34 +361,44 @@ bool ParsePairPosFormat2(const ots::Font *font,
return OTS_FAILURE_MSG("Failed to read pair pos format 2 data");
}
+ size_t value_record1_size = CalcValueRecordSize(value_format1);
+ size_t value_record2_size = CalcValueRecordSize(value_format2);
+ size_t value_records_size = size_t(class1_count) * size_t(class2_count) *
+ (value_record1_size + value_record2_size);
+
+ // Check the validity of class definition offsets.
+ if (offset_class_def1 < subtable.offset() + value_records_size ||
+ offset_class_def2 < subtable.offset() + value_records_size ||
+ offset_class_def1 >= length || offset_class_def2 >= length) {
+ return OTS_FAILURE_MSG("Bad ParsePairPosFormat2 class definition offsets %d or %d", offset_class_def1, offset_class_def2);
+ }
+
// Check class 1 records.
- for (unsigned i = 0; i < class1_count; ++i) {
- // Check class 2 records.
- for (unsigned j = 0; j < class2_count; ++j) {
- if (value_format1 && !ParseValueRecord(font, &subtable, data, length,
- value_format1)) {
- return OTS_FAILURE_MSG("Failed to parse value record 1 %d and %d", j, i);
- }
- if (value_format2 && !ParseValueRecord(font, &subtable, data, length,
- value_format2)) {
- return OTS_FAILURE_MSG("Falied to parse value record 2 %d and %d", j, i);
+ if (value_record1_size || value_record2_size) {
+ for (unsigned i = 0; i < class1_count; ++i) {
+ // Check class 2 records.
+ for (unsigned j = 0; j < class2_count; ++j) {
+ if (value_format1 && value_record2_size &&
+ !ParseValueRecord(font, &subtable, value_format1)) {
+ return OTS_FAILURE_MSG("Failed to parse value record 1 %d and %d", j, i);
+ }
+ if (value_format2 && value_record2_size &&
+ !ParseValueRecord(font, &subtable, value_format2)) {
+ return OTS_FAILURE_MSG("Falied to parse value record 2 %d and %d", j, i);
+ }
}
}
}
// Check class definition tables.
- if (offset_class_def1 < subtable.offset() || offset_class_def1 >= length ||
- offset_class_def2 < subtable.offset() || offset_class_def2 >= length) {
- return OTS_FAILURE_MSG("Bad class definition table offsets %d or %d", offset_class_def1, offset_class_def2);
- }
if (!ots::ParseClassDefTable(font, data + offset_class_def1,
length - offset_class_def1,
- num_glyphs, kMaxClassDefValue)) {
+ num_glyphs, ots::kMaxClassDefValue)) {
return OTS_FAILURE_MSG("Failed to parse class definition table 1");
}
if (!ots::ParseClassDefTable(font, data + offset_class_def2,
length - offset_class_def2,
- num_glyphs, kMaxClassDefValue)) {
+ num_glyphs, ots::kMaxClassDefValue)) {
return OTS_FAILURE_MSG("Failed to parse class definition table 2");
}
@@ -381,6 +411,12 @@ bool ParsePairAdjustment(const ots::Font *font, const uint8_t *data,
const size_t length) {
ots::Buffer subtable(data, length);
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+
uint16_t format = 0;
uint16_t offset_coverage = 0;
uint16_t value_format1 = 0;
@@ -394,12 +430,12 @@ bool ParsePairAdjustment(const ots::Font *font, const uint8_t *data,
if (format == 1) {
if (!ParsePairPosFormat1(font, data, length, value_format1, value_format2,
- font->maxp->num_glyphs)) {
+ maxp->num_glyphs)) {
return OTS_FAILURE_MSG("Failed to parse pair pos format 1");
}
} else if (format == 2) {
if (!ParsePairPosFormat2(font, data, length, value_format1, value_format2,
- font->maxp->num_glyphs)) {
+ maxp->num_glyphs)) {
return OTS_FAILURE_MSG("Failed to parse pair format 2");
}
} else {
@@ -411,7 +447,7 @@ bool ParsePairAdjustment(const ots::Font *font, const uint8_t *data,
}
if (!ots::ParseCoverageTable(font, data + offset_coverage,
length - offset_coverage,
- font->maxp->num_glyphs)) {
+ maxp->num_glyphs)) {
return OTS_FAILURE_MSG("Failed to parse coverage table");
}
@@ -424,6 +460,12 @@ bool ParseCursiveAttachment(const ots::Font *font, const uint8_t *data,
const size_t length) {
ots::Buffer subtable(data, length);
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+
uint16_t format = 0;
uint16_t offset_coverage = 0;
uint16_t entry_exit_count = 0;
@@ -478,7 +520,7 @@ bool ParseCursiveAttachment(const ots::Font *font, const uint8_t *data,
}
if (!ots::ParseCoverageTable(font, data + offset_coverage,
length - offset_coverage,
- font->maxp->num_glyphs)) {
+ maxp->num_glyphs)) {
return OTS_FAILURE_MSG("Failed to parse coverage table in cursive attachment");
}
@@ -552,6 +594,12 @@ bool ParseMarkToAttachmentSubtables(const ots::Font *font,
const GPOS_TYPE type) {
ots::Buffer subtable(data, length);
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+
uint16_t format = 0;
uint16_t offset_coverage1 = 0;
uint16_t offset_coverage2 = 0;
@@ -580,7 +628,7 @@ bool ParseMarkToAttachmentSubtables(const ots::Font *font,
}
if (!ots::ParseCoverageTable(font, data + offset_coverage1,
length - offset_coverage1,
- font->maxp->num_glyphs)) {
+ maxp->num_glyphs)) {
return OTS_FAILURE_MSG("Failed to parse converge 1 table");
}
if (offset_coverage2 < header_end || offset_coverage2 >= length) {
@@ -588,7 +636,7 @@ bool ParseMarkToAttachmentSubtables(const ots::Font *font,
}
if (!ots::ParseCoverageTable(font, data + offset_coverage2,
length - offset_coverage2,
- font->maxp->num_glyphs)) {
+ maxp->num_glyphs)) {
return OTS_FAILURE_MSG("Failed to parse coverage table 2");
}
@@ -652,17 +700,37 @@ bool ParseMarkToMarkAttachment(const ots::Font *font,
// Contextual Positioning Subtables
bool ParseContextPositioning(const ots::Font *font,
const uint8_t *data, const size_t length) {
- return ots::ParseContextSubtable(font, data, length, font->maxp->num_glyphs,
- font->gpos->num_lookups);
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+ ots::OpenTypeGPOS *gpos = static_cast<ots::OpenTypeGPOS*>(
+ font->GetTypedTable(OTS_TAG_GPOS));
+ if (!gpos) {
+ return OTS_FAILURE_MSG("Internal error!");
+ }
+ return ots::ParseContextSubtable(font, data, length, maxp->num_glyphs,
+ gpos->num_lookups);
}
// Lookup Type 8:
// Chaining Contexual Positioning Subtable
bool ParseChainedContextPositioning(const ots::Font *font,
const uint8_t *data, const size_t length) {
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+ ots::OpenTypeGPOS *gpos = static_cast<ots::OpenTypeGPOS*>(
+ font->GetTypedTable(OTS_TAG_GPOS));
+ if (!gpos) {
+ return OTS_FAILURE_MSG("Internal error!");
+ }
return ots::ParseChainingContextSubtable(font, data, length,
- font->maxp->num_glyphs,
- font->gpos->num_lookups);
+ maxp->num_glyphs,
+ gpos->num_lookups);
}
// Lookup Type 9:
@@ -677,139 +745,96 @@ bool ParseExtensionPositioning(const ots::Font *font,
namespace ots {
-// As far as I checked, following fonts contain invalid GPOS table and
-// OTS will drop their GPOS table.
-//
-// # invalid delta format in device table
-// samanata.ttf
-//
-// # bad size range in device table
-// Sarai_07.ttf
-//
-// # bad offset to PairSetTable
-// chandas1-2.ttf
-//
-// # bad offset to FeatureTable
-// glrso12.ttf
-// gllr12.ttf
-// glbo12.ttf
-// glb12.ttf
-// glro12.ttf
-// glbso12.ttf
-// glrc12.ttf
-// glrsc12.ttf
-// glbs12.ttf
-// glrs12.ttf
-// glr12.ttf
-//
-// # ScriptRecords aren't sorted by tag
-// Garogier_unhinted.otf
-//
-// # bad start coverage index in CoverageFormat2
-// AndBasR.ttf
-// CharisSILB.ttf
-// CharisSILBI.ttf
-// CharisSILI.ttf
-// CharisSILR.ttf
-// DoulosSILR.ttf
-// GenBasBI.ttf
-// GenBasI.ttf
-// GenBkBasI.ttf
-// GenBkBasB.ttf
-// GenBkBasR.ttf
-// Padauk-Bold.ttf
-// Padauk.ttf
-//
-// # Contour point indexes aren't sorted
-// Arial Unicode.ttf
-
-bool ots_gpos_parse(Font *font, const uint8_t *data, size_t length) {
- // Parsing GPOS table requires num_glyphs which is contained in maxp table.
- if (!font->maxp) {
- return OTS_FAILURE_MSG("missing maxp table needed in GPOS");
- }
-
+bool OpenTypeGPOS::Parse(const uint8_t *data, size_t length) {
+ Font *font = GetFont();
Buffer table(data, length);
- OpenTypeGPOS *gpos = new OpenTypeGPOS;
- font->gpos = gpos;
-
- uint32_t version = 0;
+ uint16_t version_major = 0, version_minor = 0;
uint16_t offset_script_list = 0;
uint16_t offset_feature_list = 0;
uint16_t offset_lookup_list = 0;
- if (!table.ReadU32(&version) ||
+ uint32_t offset_feature_variations = 0;
+ if (!table.ReadU16(&version_major) ||
+ !table.ReadU16(&version_minor) ||
!table.ReadU16(&offset_script_list) ||
!table.ReadU16(&offset_feature_list) ||
!table.ReadU16(&offset_lookup_list)) {
- return OTS_FAILURE_MSG("Incomplete table");
+ return Error("Incomplete table");
}
- if (version != 0x00010000) {
- return OTS_FAILURE_MSG("Bad version");
+ if (version_major != 1 || version_minor > 1) {
+ return Error("Bad version");
+ }
+
+ if (version_minor > 0) {
+ if (!table.ReadU32(&offset_feature_variations)) {
+ return Error("Incomplete table");
+ }
}
+ const size_t header_size =
+ (version_minor == 0) ? kGposHeaderSize_1_0 : kGposHeaderSize_1_1;
+
if (offset_lookup_list) {
- if (offset_lookup_list < kGposHeaderSize || offset_lookup_list >= length) {
- return OTS_FAILURE_MSG("Bad lookup list offset in table header");
+ if (offset_lookup_list < header_size || offset_lookup_list >= length) {
+ return Error("Bad lookup list offset in table header");
}
if (!ParseLookupListTable(font, data + offset_lookup_list,
length - offset_lookup_list,
&kGposLookupSubtableParser,
- &gpos->num_lookups)) {
- return OTS_FAILURE_MSG("Failed to parse lookup list table");
+ &this->num_lookups)) {
+ return Error("Failed to parse lookup list table");
}
}
uint16_t num_features = 0;
if (offset_feature_list) {
- if (offset_feature_list < kGposHeaderSize || offset_feature_list >= length) {
- return OTS_FAILURE_MSG("Bad feature list offset in table header");
+ if (offset_feature_list < header_size || offset_feature_list >= length) {
+ return Error("Bad feature list offset in table header");
}
if (!ParseFeatureListTable(font, data + offset_feature_list,
- length - offset_feature_list, gpos->num_lookups,
+ length - offset_feature_list, this->num_lookups,
&num_features)) {
- return OTS_FAILURE_MSG("Failed to parse feature list table");
+ return Error("Failed to parse feature list table");
}
}
if (offset_script_list) {
- if (offset_script_list < kGposHeaderSize || offset_script_list >= length) {
- return OTS_FAILURE_MSG("Bad script list offset in table header");
+ if (offset_script_list < header_size || offset_script_list >= length) {
+ return Error("Bad script list offset in table header");
}
if (!ParseScriptListTable(font, data + offset_script_list,
length - offset_script_list, num_features)) {
- return OTS_FAILURE_MSG("Failed to parse script list table");
+ return Error("Failed to parse script list table");
}
}
- gpos->data = data;
- gpos->length = length;
- return true;
-}
-
-bool ots_gpos_should_serialise(Font *font) {
- return font->gpos != NULL && font->gpos->data != NULL;
-}
+ if (offset_feature_variations) {
+ if (offset_feature_variations < header_size || offset_feature_variations >= length) {
+ return Error("Bad feature variations offset in table header");
+ }
-bool ots_gpos_serialise(OTSStream *out, Font *font) {
- if (!out->Write(font->gpos->data, font->gpos->length)) {
- return OTS_FAILURE_MSG("Failed to write GPOS table");
+ if (!ParseFeatureVariationsTable(font, data + offset_feature_variations,
+ length - offset_feature_variations,
+ this->num_lookups)) {
+ return Error("Failed to parse feature variations table");
+ }
}
+ this->m_data = data;
+ this->m_length = length;
return true;
}
-void ots_gpos_reuse(Font *font, Font *other) {
- font->gpos = other->gpos;
- font->gpos_reused = true;
-}
+bool OpenTypeGPOS::Serialize(OTSStream *out) {
+ if (!out->Write(this->m_data, this->m_length)) {
+ return Error("Failed to write GPOS table");
+ }
-void ots_gpos_free(Font *font) {
- delete font->gpos;
+ return true;
}
} // namespace ots
diff --git a/gfx/ots/src/gpos.h b/gfx/ots/src/gpos.h
index 3a4034f6f..423c8ae83 100644
--- a/gfx/ots/src/gpos.h
+++ b/gfx/ots/src/gpos.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,18 +9,24 @@
namespace ots {
-struct OpenTypeGPOS {
- OpenTypeGPOS()
- : num_lookups(0),
- data(NULL),
- length(0) {
+class OpenTypeGPOS : public Table {
+ public:
+ explicit OpenTypeGPOS(Font *font, uint32_t tag)
+ : Table(font, tag, tag),
+ num_lookups(0),
+ m_data(NULL),
+ m_length(0) {
}
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
// Number of lookups in GPOS table
uint16_t num_lookups;
- const uint8_t *data;
- size_t length;
+ private:
+ const uint8_t *m_data;
+ size_t m_length;
};
} // namespace ots
diff --git a/gfx/ots/src/graphite.h b/gfx/ots/src/graphite.h
new file mode 100644
index 000000000..452cb26a8
--- /dev/null
+++ b/gfx/ots/src/graphite.h
@@ -0,0 +1,96 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_GRAPHITE_H_
+#define OTS_GRAPHITE_H_
+
+#include <vector>
+#include <type_traits>
+
+namespace ots {
+
+template<typename ParentType>
+class TablePart {
+ public:
+ TablePart(ParentType* parent) : parent(parent) { }
+ virtual ~TablePart() { }
+ virtual bool ParsePart(Buffer& table) = 0;
+ virtual bool SerializePart(OTSStream* out) const = 0;
+ protected:
+ ParentType* parent;
+};
+
+template<typename T>
+bool SerializeParts(const std::vector<T>& vec, OTSStream* out) {
+ for (const T& part : vec) {
+ if (!part.SerializePart(out)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+template<typename T>
+bool SerializeParts(const std::vector<std::vector<T>>& vec, OTSStream* out) {
+ for (const std::vector<T>& part : vec) {
+ if (!SerializeParts(part, out)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline bool SerializeParts(const std::vector<uint8_t>& vec, OTSStream* out) {
+ for (uint8_t part : vec) {
+ if (!out->WriteU8(part)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline bool SerializeParts(const std::vector<uint16_t>& vec, OTSStream* out) {
+ for (uint16_t part : vec) {
+ if (!out->WriteU16(part)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline bool SerializeParts(const std::vector<int16_t>& vec, OTSStream* out) {
+ for (int16_t part : vec) {
+ if (!out->WriteS16(part)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline bool SerializeParts(const std::vector<uint32_t>& vec, OTSStream* out) {
+ for (uint32_t part : vec) {
+ if (!out->WriteU32(part)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+inline bool SerializeParts(const std::vector<int32_t>& vec, OTSStream* out) {
+ for (int32_t part : vec) {
+ if (!out->WriteS32(part)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+template<typename T>
+size_t datasize(std::vector<T> vec) {
+ return sizeof(T) * vec.size();
+}
+
+} // namespace ots
+
+#endif // OTS_GRAPHITE_H_
diff --git a/gfx/ots/src/gsub.cc b/gfx/ots/src/gsub.cc
index 9baf2e88b..c90fb48f3 100644
--- a/gfx/ots/src/gsub.cc
+++ b/gfx/ots/src/gsub.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -17,8 +17,10 @@
namespace {
-// The GSUB header size
-const size_t kGsubHeaderSize = 4 + 3 * 2;
+// The GSUB header size for table version 1.0
+const size_t kGsubHeaderSize_1_0 = 4 + 3 * 2;
+// GSUB header size v1.1
+const size_t kGsubHeaderSize_1_1 = 4 + 3 * 2 + 4;
enum GSUB_TYPE {
GSUB_TYPE_SINGLE = 1,
@@ -82,7 +84,12 @@ bool ParseSingleSubstitution(const ots::Font *font,
return OTS_FAILURE_MSG("Failed to read single subst table header");
}
- const uint16_t num_glyphs = font->maxp->num_glyphs;
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+ const uint16_t num_glyphs = maxp->num_glyphs;
if (format == 1) {
// Parse SingleSubstFormat1
int16_t delta_glyph_id = 0;
@@ -170,7 +177,12 @@ bool ParseMutipleSubstitution(const ots::Font *font,
return OTS_FAILURE_MSG("Bad multiple subst table format %d", format);
}
- const uint16_t num_glyphs = font->maxp->num_glyphs;
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+ const uint16_t num_glyphs = maxp->num_glyphs;
const unsigned sequence_end = static_cast<unsigned>(6) +
sequence_count * 2;
if (sequence_end > std::numeric_limits<uint16_t>::max()) {
@@ -245,7 +257,12 @@ bool ParseAlternateSubstitution(const ots::Font *font,
return OTS_FAILURE_MSG("Bad alternate subst table format %d", format);
}
- const uint16_t num_glyphs = font->maxp->num_glyphs;
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+ const uint16_t num_glyphs = maxp->num_glyphs;
const unsigned alternate_set_end = static_cast<unsigned>(6) +
alternate_set_count * 2;
if (alternate_set_end > std::numeric_limits<uint16_t>::max()) {
@@ -362,7 +379,12 @@ bool ParseLigatureSubstitution(const ots::Font *font,
return OTS_FAILURE_MSG("Bad ligature substitution table format %d", format);
}
- const uint16_t num_glyphs = font->maxp->num_glyphs;
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+ const uint16_t num_glyphs = maxp->num_glyphs;
const unsigned ligature_set_end = static_cast<unsigned>(6) +
lig_set_count * 2;
if (ligature_set_end > std::numeric_limits<uint16_t>::max()) {
@@ -398,8 +420,18 @@ bool ParseLigatureSubstitution(const ots::Font *font,
// Contextual Substitution Subtable
bool ParseContextSubstitution(const ots::Font *font,
const uint8_t *data, const size_t length) {
- return ots::ParseContextSubtable(font, data, length, font->maxp->num_glyphs,
- font->gsub->num_lookups);
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+ ots::OpenTypeGSUB *gsub = static_cast<ots::OpenTypeGSUB*>(
+ font->GetTypedTable(OTS_TAG_GSUB));
+ if (!gsub) {
+ return OTS_FAILURE_MSG("Internal error!");
+ }
+ return ots::ParseContextSubtable(font, data, length, maxp->num_glyphs,
+ gsub->num_lookups);
}
// Lookup Type 6:
@@ -407,9 +439,19 @@ bool ParseContextSubstitution(const ots::Font *font,
bool ParseChainingContextSubstitution(const ots::Font *font,
const uint8_t *data,
const size_t length) {
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+ ots::OpenTypeGSUB *gsub = static_cast<ots::OpenTypeGSUB*>(
+ font->GetTypedTable(OTS_TAG_GSUB));
+ if (!gsub) {
+ return OTS_FAILURE_MSG("Internal error!");
+ }
return ots::ParseChainingContextSubtable(font, data, length,
- font->maxp->num_glyphs,
- font->gsub->num_lookups);
+ maxp->num_glyphs,
+ gsub->num_lookups);
}
// Lookup Type 7:
@@ -434,7 +476,12 @@ bool ParseReverseChainingContextSingleSubstitution(
return OTS_FAILURE_MSG("Failed to read reverse chaining header");
}
- const uint16_t num_glyphs = font->maxp->num_glyphs;
+ ots::OpenTypeMAXP *maxp = static_cast<ots::OpenTypeMAXP*>(
+ font->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return OTS_FAILURE_MSG("Required maxp table missing");
+ }
+ const uint16_t num_glyphs = maxp->num_glyphs;
uint16_t backtrack_glyph_count = 0;
if (!subtable.ReadU16(&backtrack_glyph_count)) {
@@ -530,143 +577,97 @@ bool ParseReverseChainingContextSingleSubstitution(
namespace ots {
-// As far as I checked, following fonts contain invalid values in GSUB table.
-// OTS will drop their GSUB table.
-//
-// # too large substitute (value is 0xFFFF)
-// kaiu.ttf
-// mingliub2.ttf
-// mingliub1.ttf
-// mingliub0.ttf
-// GraublauWeb.otf
-// GraublauWebBold.otf
-//
-// # too large alternate (value is 0xFFFF)
-// ManchuFont.ttf
-//
-// # bad offset to lang sys table (NULL offset)
-// DejaVuMonoSansBold.ttf
-// DejaVuMonoSansBoldOblique.ttf
-// DejaVuMonoSansOblique.ttf
-// DejaVuSansMono-BoldOblique.ttf
-// DejaVuSansMono-Oblique.ttf
-// DejaVuSansMono-Bold.ttf
-//
-// # bad start coverage index
-// GenBasBI.ttf
-// GenBasI.ttf
-// AndBasR.ttf
-// GenBkBasI.ttf
-// CharisSILR.ttf
-// CharisSILBI.ttf
-// CharisSILI.ttf
-// CharisSILB.ttf
-// DoulosSILR.ttf
-// CharisSILBI.ttf
-// GenBkBasB.ttf
-// GenBkBasR.ttf
-// GenBkBasBI.ttf
-// GenBasB.ttf
-// GenBasR.ttf
-//
-// # glyph range is overlapping
-// KacstTitleL.ttf
-// KacstDecorative.ttf
-// KacstTitle.ttf
-// KacstArt.ttf
-// KacstPoster.ttf
-// KacstQurn.ttf
-// KacstDigital.ttf
-// KacstBook.ttf
-// KacstFarsi.ttf
-
-bool ots_gsub_parse(Font *font, const uint8_t *data, size_t length) {
- // Parsing gsub table requires |font->maxp->num_glyphs|
- if (!font->maxp) {
- return OTS_FAILURE_MSG("Missing maxp table in font, needed by GSUB");
- }
-
+bool OpenTypeGSUB::Parse(const uint8_t *data, size_t length) {
+ // Parsing gsub table requires |maxp->num_glyphs|
+ Font *font = GetFont();
Buffer table(data, length);
- OpenTypeGSUB *gsub = new OpenTypeGSUB;
- font->gsub = gsub;
-
- uint32_t version = 0;
+ uint16_t version_major = 0, version_minor = 0;
uint16_t offset_script_list = 0;
uint16_t offset_feature_list = 0;
uint16_t offset_lookup_list = 0;
- if (!table.ReadU32(&version) ||
+ uint32_t offset_feature_variations = 0;
+ if (!table.ReadU16(&version_major) ||
+ !table.ReadU16(&version_minor) ||
!table.ReadU16(&offset_script_list) ||
!table.ReadU16(&offset_feature_list) ||
!table.ReadU16(&offset_lookup_list)) {
- return OTS_FAILURE_MSG("Incomplete table");
+ return Error("Incomplete table");
}
- if (version != 0x00010000) {
- return OTS_FAILURE_MSG("Bad version");
+ if (version_major != 1 || version_minor > 1) {
+ return Error("Bad version");
}
+ if (version_minor > 0) {
+ if (!table.ReadU32(&offset_feature_variations)) {
+ return Error("Incomplete table");
+ }
+ }
+
+ const size_t header_size =
+ (version_minor == 0) ? kGsubHeaderSize_1_0 : kGsubHeaderSize_1_1;
+
if (offset_lookup_list) {
- if (offset_lookup_list < kGsubHeaderSize || offset_lookup_list >= length) {
- return OTS_FAILURE_MSG("Bad lookup list offset in table header");
+ if (offset_lookup_list < header_size || offset_lookup_list >= length) {
+ return Error("Bad lookup list offset in table header");
}
if (!ParseLookupListTable(font, data + offset_lookup_list,
length - offset_lookup_list,
&kGsubLookupSubtableParser,
- &gsub->num_lookups)) {
- return OTS_FAILURE_MSG("Failed to parse lookup list table");
+ &this->num_lookups)) {
+ return Error("Failed to parse lookup list table");
}
}
uint16_t num_features = 0;
if (offset_feature_list) {
- if (offset_feature_list < kGsubHeaderSize || offset_feature_list >= length) {
- return OTS_FAILURE_MSG("Bad feature list offset in table header");
+ if (offset_feature_list < header_size || offset_feature_list >= length) {
+ return Error("Bad feature list offset in table header");
}
if (!ParseFeatureListTable(font, data + offset_feature_list,
- length - offset_feature_list, gsub->num_lookups,
+ length - offset_feature_list, this->num_lookups,
&num_features)) {
- return OTS_FAILURE_MSG("Failed to parse feature list table");
+ return Error("Failed to parse feature list table");
}
}
if (offset_script_list) {
- if (offset_script_list < kGsubHeaderSize || offset_script_list >= length) {
- return OTS_FAILURE_MSG("Bad script list offset in table header");
+ if (offset_script_list < header_size || offset_script_list >= length) {
+ return Error("Bad script list offset in table header");
}
if (!ParseScriptListTable(font, data + offset_script_list,
length - offset_script_list, num_features)) {
- return OTS_FAILURE_MSG("Failed to parse script list table");
+ return Error("Failed to parse script list table");
}
}
- gsub->data = data;
- gsub->length = length;
- return true;
-}
-
-bool ots_gsub_should_serialise(Font *font) {
- return font->gsub != NULL && font->gsub->data != NULL;
-}
+ if (offset_feature_variations) {
+ if (offset_feature_variations < header_size || offset_feature_variations >= length) {
+ return Error("Bad feature variations offset in table header");
+ }
-bool ots_gsub_serialise(OTSStream *out, Font *font) {
- if (!out->Write(font->gsub->data, font->gsub->length)) {
- return OTS_FAILURE_MSG("Failed to write GSUB table");
+ if (!ParseFeatureVariationsTable(font, data + offset_feature_variations,
+ length - offset_feature_variations,
+ this->num_lookups)) {
+ return Error("Failed to parse feature variations table");
+ }
}
+ this->m_data = data;
+ this->m_length = length;
return true;
}
-void ots_gsub_reuse(Font *font, Font *other) {
- font->gsub = other->gsub;
- font->gsub_reused = true;
-}
+bool OpenTypeGSUB::Serialize(OTSStream *out) {
+ if (!out->Write(this->m_data, this->m_length)) {
+ return Error("Failed to write GSUB table");
+ }
-void ots_gsub_free(Font *font) {
- delete font->gsub;
+ return true;
}
} // namespace ots
diff --git a/gfx/ots/src/gsub.h b/gfx/ots/src/gsub.h
index f6f8cd3b1..76c990465 100644
--- a/gfx/ots/src/gsub.h
+++ b/gfx/ots/src/gsub.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,18 +9,24 @@
namespace ots {
-struct OpenTypeGSUB {
- OpenTypeGSUB()
- : num_lookups(0),
- data(NULL),
- length(0) {
+class OpenTypeGSUB : public Table {
+ public:
+ explicit OpenTypeGSUB(Font *font, uint32_t tag)
+ : Table(font, tag, tag),
+ num_lookups(0),
+ m_data(NULL),
+ m_length(0) {
}
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
// Number of lookups in GPSUB table
uint16_t num_lookups;
- const uint8_t *data;
- size_t length;
+ //private:
+ const uint8_t *m_data;
+ size_t m_length;
};
} // namespace ots
diff --git a/gfx/ots/src/gvar.cc b/gfx/ots/src/gvar.cc
new file mode 100644
index 000000000..324a0fc83
--- /dev/null
+++ b/gfx/ots/src/gvar.cc
@@ -0,0 +1,158 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gvar.h"
+
+#include "fvar.h"
+#include "maxp.h"
+#include "variations.h"
+
+#define TABLE_NAME "gvar"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeGVAR
+// -----------------------------------------------------------------------------
+
+static bool ParseSharedTuples(const Font* font, const uint8_t* data, size_t length,
+ size_t sharedTupleCount, size_t axisCount) {
+ Buffer subtable(data, length);
+ for (unsigned i = 0; i < sharedTupleCount; i++) {
+ for (unsigned j = 0; j < axisCount; j++) {
+ int16_t coordinate;
+ if (!subtable.ReadS16(&coordinate)) {
+ return OTS_FAILURE_MSG("Failed to read shared tuple coordinate");
+ }
+ }
+ }
+ return true;
+}
+
+static bool ParseGlyphVariationDataArray(const Font* font, const uint8_t* data, size_t length,
+ uint16_t flags, size_t glyphCount, size_t axisCount,
+ size_t sharedTupleCount,
+ const uint8_t* glyphVariationData,
+ size_t glyphVariationDataLength) {
+ Buffer subtable(data, length);
+
+ bool glyphVariationDataOffsetsAreLong = (flags & 0x0001u);
+ uint32_t prevOffset = 0;
+ for (size_t i = 0; i < glyphCount + 1; i++) {
+ uint32_t offset;
+ if (glyphVariationDataOffsetsAreLong) {
+ if (!subtable.ReadU32(&offset)) {
+ return OTS_FAILURE_MSG("Failed to read GlyphVariationData offset");
+ }
+ } else {
+ uint16_t halfOffset;
+ if (!subtable.ReadU16(&halfOffset)) {
+ return OTS_FAILURE_MSG("Failed to read GlyphVariationData offset");
+ }
+ offset = halfOffset * 2;
+ }
+
+ if (i > 0 && offset > prevOffset) {
+ if (prevOffset > glyphVariationDataLength) {
+ return OTS_FAILURE_MSG("Invalid GlyphVariationData offset");
+ }
+ if (!ParseVariationData(font, glyphVariationData + prevOffset,
+ glyphVariationDataLength - prevOffset,
+ axisCount, sharedTupleCount)) {
+ return OTS_FAILURE_MSG("Failed to parse GlyphVariationData");
+ }
+ }
+ prevOffset = offset;
+ }
+
+ return true;
+}
+
+bool OpenTypeGVAR::Parse(const uint8_t* data, size_t length) {
+ Buffer table(data, length);
+
+ uint16_t majorVersion;
+ uint16_t minorVersion;
+ uint16_t axisCount;
+ uint16_t sharedTupleCount;
+ uint32_t sharedTuplesOffset;
+ uint16_t glyphCount;
+ uint16_t flags;
+ uint32_t glyphVariationDataArrayOffset;
+
+ if (!table.ReadU16(&majorVersion) ||
+ !table.ReadU16(&minorVersion) ||
+ !table.ReadU16(&axisCount) ||
+ !table.ReadU16(&sharedTupleCount) ||
+ !table.ReadU32(&sharedTuplesOffset) ||
+ !table.ReadU16(&glyphCount) ||
+ !table.ReadU16(&flags) ||
+ !table.ReadU32(&glyphVariationDataArrayOffset)) {
+ return DropVariations("Failed to read table header");
+ }
+ if (majorVersion != 1) {
+ return DropVariations("Unknown table version");
+ }
+
+ // check axisCount == fvar->axisCount
+ OpenTypeFVAR* fvar = static_cast<OpenTypeFVAR*>(
+ GetFont()->GetTypedTable(OTS_TAG_FVAR));
+ if (!fvar) {
+ return DropVariations("Required fvar table is missing");
+ }
+ if (axisCount != fvar->AxisCount()) {
+ return DropVariations("Axis count mismatch");
+ }
+
+ // check glyphCount == maxp->num_glyphs
+ OpenTypeMAXP* maxp = static_cast<OpenTypeMAXP*>(
+ GetFont()->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return DropVariations("Required maxp table is missing");
+ }
+ if (glyphCount != maxp->num_glyphs) {
+ return DropVariations("Glyph count mismatch");
+ }
+
+ if (sharedTupleCount > 0) {
+ if (sharedTuplesOffset < table.offset() || sharedTuplesOffset > length) {
+ return DropVariations("Invalid sharedTuplesOffset");
+ }
+ if (!ParseSharedTuples(GetFont(),
+ data + sharedTuplesOffset, length - sharedTuplesOffset,
+ sharedTupleCount, axisCount)) {
+ return DropVariations("Failed to parse shared tuples");
+ }
+ }
+
+ if (glyphVariationDataArrayOffset) {
+ if (glyphVariationDataArrayOffset > length) {
+ return DropVariations("Invalid glyphVariationDataArrayOffset");
+ }
+ if (!ParseGlyphVariationDataArray(GetFont(),
+ data + table.offset(), length - table.offset(),
+ flags, glyphCount, axisCount, sharedTupleCount,
+ data + glyphVariationDataArrayOffset,
+ length - glyphVariationDataArrayOffset)) {
+ return DropVariations("Failed to read glyph variation data array");
+ }
+ }
+
+ this->m_data = data;
+ this->m_length = length;
+
+ return true;
+}
+
+bool OpenTypeGVAR::Serialize(OTSStream* out) {
+ if (!out->Write(this->m_data, this->m_length)) {
+ return Error("Failed to write gvar table");
+ }
+
+ return true;
+}
+
+} // namespace ots
+
+#undef TABLE_NAME
diff --git a/gfx/ots/src/gvar.h b/gfx/ots/src/gvar.h
new file mode 100644
index 000000000..8a90c57a3
--- /dev/null
+++ b/gfx/ots/src/gvar.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_GVAR_H_
+#define OTS_GVAR_H_
+
+#include "ots.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeGVAR Interface
+// -----------------------------------------------------------------------------
+
+class OpenTypeGVAR : public Table {
+ public:
+ explicit OpenTypeGVAR(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ const uint8_t *m_data;
+ size_t m_length;
+};
+
+} // namespace ots
+
+#endif // OTS_GVAR_H_
diff --git a/gfx/ots/src/hdmx.cc b/gfx/ots/src/hdmx.cc
index f57b71f59..42ac9de8d 100644
--- a/gfx/ots/src/hdmx.cc
+++ b/gfx/ots/src/hdmx.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,139 +9,112 @@
// hdmx - Horizontal Device Metrics
// http://www.microsoft.com/typography/otspec/hdmx.htm
-#define TABLE_NAME "hdmx"
-
-#define DROP_THIS_TABLE(...) \
- do { \
- OTS_FAILURE_MSG_(font->file, TABLE_NAME ": " __VA_ARGS__); \
- OTS_FAILURE_MSG("Table discarded"); \
- delete font->hdmx; \
- font->hdmx = 0; \
- } while (0)
-
namespace ots {
-bool ots_hdmx_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeHDMX::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- font->hdmx = new OpenTypeHDMX;
- OpenTypeHDMX * const hdmx = font->hdmx;
- if (!font->head || !font->maxp) {
- return OTS_FAILURE_MSG("Missing maxp or head tables in font, needed by hdmx");
+ OpenTypeMAXP *maxp = static_cast<OpenTypeMAXP*>(
+ GetFont()->GetTypedTable(OTS_TAG_MAXP));
+ OpenTypeHEAD *head = static_cast<OpenTypeHEAD*>(
+ GetFont()->GetTypedTable(OTS_TAG_HEAD));
+ if (!head || !maxp) {
+ return Error("Missing maxp or head tables in font, needed by hdmx");
}
- if ((font->head->flags & 0x14) == 0) {
- // http://www.microsoft.com/typography/otspec/recom.htm
- DROP_THIS_TABLE("the table should not be present when bit 2 and 4 of the "
- "head->flags are not set");
- return true;
+ if ((head->flags & 0x14) == 0) {
+ // http://www.microsoft.com/typography/otspec/recom.htm#hdmx
+ return Drop("the table should not be present when bit 2 and 4 of the "
+ "head->flags are not set");
}
int16_t num_recs;
- if (!table.ReadU16(&hdmx->version) ||
+ if (!table.ReadU16(&this->version) ||
!table.ReadS16(&num_recs) ||
- !table.ReadS32(&hdmx->size_device_record)) {
- return OTS_FAILURE_MSG("Failed to read hdmx header");
+ !table.ReadS32(&this->size_device_record)) {
+ return Error("Failed to read table header");
}
- if (hdmx->version != 0) {
- DROP_THIS_TABLE("bad version: %u", hdmx->version);
- return true;
+ if (this->version != 0) {
+ return Drop("Unsupported version: %u", this->version);
}
if (num_recs <= 0) {
- DROP_THIS_TABLE("bad num_recs: %d", num_recs);
- return true;
+ return Drop("Bad numRecords: %d", num_recs);
}
- const int32_t actual_size_device_record = font->maxp->num_glyphs + 2;
- if (hdmx->size_device_record < actual_size_device_record) {
- DROP_THIS_TABLE("bad hdmx->size_device_record: %d", hdmx->size_device_record);
- return true;
+ const int32_t actual_size_device_record = maxp->num_glyphs + 2;
+ if (this->size_device_record < actual_size_device_record) {
+ return Drop("Bad sizeDeviceRecord: %d", this->size_device_record);
}
- hdmx->pad_len = hdmx->size_device_record - actual_size_device_record;
- if (hdmx->pad_len > 3) {
- return OTS_FAILURE_MSG("Bad padding %d", hdmx->pad_len);
+ this->pad_len = this->size_device_record - actual_size_device_record;
+ if (this->pad_len > 3) {
+ return Error("Bad DeviceRecord padding %d", this->pad_len);
}
uint8_t last_pixel_size = 0;
- hdmx->records.reserve(num_recs);
+ this->records.reserve(num_recs);
for (int i = 0; i < num_recs; ++i) {
OpenTypeHDMXDeviceRecord rec;
if (!table.ReadU8(&rec.pixel_size) ||
!table.ReadU8(&rec.max_width)) {
- return OTS_FAILURE_MSG("Failed to read hdmx record %d", i);
+ return Error("Failed to read DeviceRecord %d", i);
}
if ((i != 0) &&
(rec.pixel_size <= last_pixel_size)) {
- DROP_THIS_TABLE("records are not sorted");
- return true;
+ return Drop("DeviceRecord's are not sorted");
}
last_pixel_size = rec.pixel_size;
- rec.widths.reserve(font->maxp->num_glyphs);
- for (unsigned j = 0; j < font->maxp->num_glyphs; ++j) {
+ rec.widths.reserve(maxp->num_glyphs);
+ for (unsigned j = 0; j < maxp->num_glyphs; ++j) {
uint8_t width;
if (!table.ReadU8(&width)) {
- return OTS_FAILURE_MSG("Failed to read glyph width %d in record %d", j, i);
+ return Error("Failed to read glyph width %d in DeviceRecord %d", j, i);
}
rec.widths.push_back(width);
}
- if ((hdmx->pad_len > 0) &&
- !table.Skip(hdmx->pad_len)) {
- return OTS_FAILURE_MSG("Failed to skip padding %d", hdmx->pad_len);
+ if ((this->pad_len > 0) &&
+ !table.Skip(this->pad_len)) {
+ return Error("DeviceRecord %d should be padded by %d", i, this->pad_len);
}
- hdmx->records.push_back(rec);
+ this->records.push_back(rec);
}
return true;
}
-bool ots_hdmx_should_serialise(Font *font) {
- if (!font->hdmx) return false;
- if (!font->glyf) return false; // this table is not for CFF fonts.
- return true;
+bool OpenTypeHDMX::ShouldSerialize() {
+ return Table::ShouldSerialize() &&
+ // this table is not for CFF fonts.
+ GetFont()->GetTable(OTS_TAG_GLYF) != NULL;
}
-bool ots_hdmx_serialise(OTSStream *out, Font *font) {
- OpenTypeHDMX * const hdmx = font->hdmx;
-
- const int16_t num_recs = static_cast<int16_t>(hdmx->records.size());
- if (hdmx->records.size() >
+bool OpenTypeHDMX::Serialize(OTSStream *out) {
+ const int16_t num_recs = static_cast<int16_t>(this->records.size());
+ if (this->records.size() >
static_cast<size_t>(std::numeric_limits<int16_t>::max()) ||
- !out->WriteU16(hdmx->version) ||
+ !out->WriteU16(this->version) ||
!out->WriteS16(num_recs) ||
- !out->WriteS32(hdmx->size_device_record)) {
- return OTS_FAILURE_MSG("Failed to write hdmx header");
+ !out->WriteS32(this->size_device_record)) {
+ return Error("Failed to write table header");
}
for (int16_t i = 0; i < num_recs; ++i) {
- const OpenTypeHDMXDeviceRecord& rec = hdmx->records[i];
+ const OpenTypeHDMXDeviceRecord& rec = this->records[i];
if (!out->Write(&rec.pixel_size, 1) ||
!out->Write(&rec.max_width, 1) ||
!out->Write(&rec.widths[0], rec.widths.size())) {
- return OTS_FAILURE_MSG("Failed to write hdmx record %d", i);
+ return Error("Failed to write DeviceRecord %d", i);
}
- if ((hdmx->pad_len > 0) &&
- !out->Write((const uint8_t *)"\x00\x00\x00", hdmx->pad_len)) {
- return OTS_FAILURE_MSG("Failed to write hdmx padding of length %d", hdmx->pad_len);
+ if ((this->pad_len > 0) &&
+ !out->Write((const uint8_t *)"\x00\x00\x00", this->pad_len)) {
+ return Error("Failed to write padding of length %d", this->pad_len);
}
}
return true;
}
-void ots_hdmx_reuse(Font *font, Font *other) {
- font->hdmx = other->hdmx;
- font->hdmx_reused = true;
-}
-
-void ots_hdmx_free(Font *font) {
- delete font->hdmx;
-}
-
} // namespace ots
-
-#undef TABLE_NAME
-#undef DROP_THIS_TABLE
diff --git a/gfx/ots/src/hdmx.h b/gfx/ots/src/hdmx.h
index 9ec212437..5d323dd7e 100644
--- a/gfx/ots/src/hdmx.h
+++ b/gfx/ots/src/hdmx.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -17,7 +17,16 @@ struct OpenTypeHDMXDeviceRecord {
std::vector<uint8_t> widths;
};
-struct OpenTypeHDMX {
+class OpenTypeHDMX : public Table {
+ public:
+ explicit OpenTypeHDMX(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool ShouldSerialize();
+
+ private:
uint16_t version;
int32_t size_device_record;
int32_t pad_len;
diff --git a/gfx/ots/src/head.cc b/gfx/ots/src/head.cc
index 229ea71f9..6088504c8 100644
--- a/gfx/ots/src/head.cc
+++ b/gfx/ots/src/head.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,151 +9,124 @@
// head - Font Header
// http://www.microsoft.com/typography/otspec/head.htm
-#define TABLE_NAME "head"
-
namespace ots {
-bool ots_head_parse(Font* font, const uint8_t *data, size_t length) {
+bool OpenTypeHEAD::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- OpenTypeHEAD *head = new OpenTypeHEAD;
- font->head = head;
uint32_t version = 0;
if (!table.ReadU32(&version) ||
- !table.ReadU32(&head->revision)) {
- return OTS_FAILURE_MSG("Failed to read head header");
+ !table.ReadU32(&this->revision)) {
+ return Error("Failed to read table header");
}
if (version >> 16 != 1) {
- return OTS_FAILURE_MSG("Bad head table version of %d", version);
+ return Error("Unsupported majorVersion: %d", version >> 16);
}
// Skip the checksum adjustment
if (!table.Skip(4)) {
- return OTS_FAILURE_MSG("Failed to read checksum");
+ return Error("Failed to read checksum");
}
uint32_t magic;
if (!table.ReadU32(&magic) || magic != 0x5F0F3CF5) {
- return OTS_FAILURE_MSG("Failed to read font magic number");
+ return Error("Failed to read or incorrect magicNumber");
}
- if (!table.ReadU16(&head->flags)) {
- return OTS_FAILURE_MSG("Failed to read head flags");
+ if (!table.ReadU16(&this->flags)) {
+ return Error("Failed to read flags");
}
// We allow bits 0..4, 11..13
- head->flags &= 0x381f;
-
- if (!table.ReadU16(&head->ppem)) {
- return OTS_FAILURE_MSG("Failed to read pixels per em");
- }
+ this->flags &= 0x381f;
- // ppem must be in range
- if (head->ppem < 16 ||
- head->ppem > 16384) {
- return OTS_FAILURE_MSG("Bad ppm of %d", head->ppem);
+ if (!table.ReadU16(&this->upem)) {
+ return Error("Failed to read unitsPerEm");
}
- // ppem must be a power of two
-#if 0
- // We don't call ots_failure() for now since lots of TrueType fonts are
- // not following this rule. Putting OTS_WARNING here is too noisy.
- if ((head->ppem - 1) & head->ppem) {
- return OTS_FAILURE_MSG("ppm not a power of two: %d", head->ppem);
+ // upem must be in range
+ if (this->upem < 16 ||
+ this->upem > 16384) {
+ return Error("unitsPerEm on in the range [16, 16384]: %d", this->upem);
}
-#endif
- if (!table.ReadR64(&head->created) ||
- !table.ReadR64(&head->modified)) {
- return OTS_FAILURE_MSG("Can't read font dates");
+ if (!table.ReadR64(&this->created) ||
+ !table.ReadR64(&this->modified)) {
+ return Error("Can't read font dates");
}
- if (!table.ReadS16(&head->xmin) ||
- !table.ReadS16(&head->ymin) ||
- !table.ReadS16(&head->xmax) ||
- !table.ReadS16(&head->ymax)) {
- return OTS_FAILURE_MSG("Failed to read font bounding box");
+ if (!table.ReadS16(&this->xmin) ||
+ !table.ReadS16(&this->ymin) ||
+ !table.ReadS16(&this->xmax) ||
+ !table.ReadS16(&this->ymax)) {
+ return Error("Failed to read font bounding box");
}
- if (head->xmin > head->xmax) {
- return OTS_FAILURE_MSG("Bad x dimension in the font bounding box (%d, %d)", head->xmin, head->xmax);
+ if (this->xmin > this->xmax) {
+ return Error("Bad x dimension in the font bounding box (%d, %d)",
+ this->xmin, this->xmax);
}
- if (head->ymin > head->ymax) {
- return OTS_FAILURE_MSG("Bad y dimension in the font bounding box (%d, %d)", head->ymin, head->ymax);
+ if (this->ymin > this->ymax) {
+ return Error("Bad y dimension in the font bounding box (%d, %d)",
+ this->ymin, this->ymax);
}
- if (!table.ReadU16(&head->mac_style)) {
- return OTS_FAILURE_MSG("Failed to read font style");
+ if (!table.ReadU16(&this->mac_style)) {
+ return Error("Failed to read macStyle");
}
// We allow bits 0..6
- head->mac_style &= 0x7f;
+ this->mac_style &= 0x7f;
- if (!table.ReadU16(&head->min_ppem)) {
- return OTS_FAILURE_MSG("Failed to read font minimum ppm");
+ if (!table.ReadU16(&this->min_ppem)) {
+ return Error("Failed to read lowestRecPPEM");
}
// We don't care about the font direction hint
if (!table.Skip(2)) {
- return OTS_FAILURE_MSG("Failed to skip font direction hint");
+ return Error("Failed to read fontDirectionHint");
}
- if (!table.ReadS16(&head->index_to_loc_format)) {
- return OTS_FAILURE_MSG("Failed to read index to loc format");
+ if (!table.ReadS16(&this->index_to_loc_format)) {
+ return Error("Failed to read indexToLocFormat");
}
- if (head->index_to_loc_format < 0 ||
- head->index_to_loc_format > 1) {
- return OTS_FAILURE_MSG("Bad index to loc format %d", head->index_to_loc_format);
+ if (this->index_to_loc_format < 0 ||
+ this->index_to_loc_format > 1) {
+ return Error("Bad indexToLocFormat %d", this->index_to_loc_format);
}
int16_t glyph_data_format;
if (!table.ReadS16(&glyph_data_format) ||
glyph_data_format) {
- return OTS_FAILURE_MSG("Failed to read glyph data format");
+ return Error("Failed to read or bad glyphDataFormat");
}
return true;
}
-bool ots_head_should_serialise(Font *font) {
- return font->head != NULL;
-}
-
-bool ots_head_serialise(OTSStream *out, Font *font) {
- const OpenTypeHEAD *head = font->head;
+bool OpenTypeHEAD::Serialize(OTSStream *out) {
if (!out->WriteU32(0x00010000) ||
- !out->WriteU32(head->revision) ||
+ !out->WriteU32(this->revision) ||
!out->WriteU32(0) || // check sum not filled in yet
!out->WriteU32(0x5F0F3CF5) ||
- !out->WriteU16(head->flags) ||
- !out->WriteU16(head->ppem) ||
- !out->WriteR64(head->created) ||
- !out->WriteR64(head->modified) ||
- !out->WriteS16(head->xmin) ||
- !out->WriteS16(head->ymin) ||
- !out->WriteS16(head->xmax) ||
- !out->WriteS16(head->ymax) ||
- !out->WriteU16(head->mac_style) ||
- !out->WriteU16(head->min_ppem) ||
+ !out->WriteU16(this->flags) ||
+ !out->WriteU16(this->upem) ||
+ !out->WriteR64(this->created) ||
+ !out->WriteR64(this->modified) ||
+ !out->WriteS16(this->xmin) ||
+ !out->WriteS16(this->ymin) ||
+ !out->WriteS16(this->xmax) ||
+ !out->WriteS16(this->ymax) ||
+ !out->WriteU16(this->mac_style) ||
+ !out->WriteU16(this->min_ppem) ||
!out->WriteS16(2) ||
- !out->WriteS16(head->index_to_loc_format) ||
+ !out->WriteS16(this->index_to_loc_format) ||
!out->WriteS16(0)) {
- return OTS_FAILURE_MSG("Failed to write head table");
+ return Error("Failed to write table");
}
return true;
}
-void ots_head_reuse(Font *font, Font *other) {
- font->head = other->head;
- font->head_reused = true;
-}
-
-void ots_head_free(Font *font) {
- delete font->head;
-}
-
} // namespace
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/head.h b/gfx/ots/src/head.h
index 5967c4b89..a040fcf24 100644
--- a/gfx/ots/src/head.h
+++ b/gfx/ots/src/head.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,10 +9,17 @@
namespace ots {
-struct OpenTypeHEAD {
+class OpenTypeHEAD : public Table {
+ public:
+ explicit OpenTypeHEAD(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
uint32_t revision;
uint16_t flags;
- uint16_t ppem;
+ uint16_t upem;
uint64_t created;
uint64_t modified;
diff --git a/gfx/ots/src/hhea.cc b/gfx/ots/src/hhea.cc
index 624287280..d024aaac4 100644
--- a/gfx/ots/src/hhea.cc
+++ b/gfx/ots/src/hhea.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,49 +10,23 @@
// hhea - Horizontal Header
// http://www.microsoft.com/typography/otspec/hhea.htm
-#define TABLE_NAME "hhea"
-
namespace ots {
-bool ots_hhea_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeHHEA::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- OpenTypeHHEA *hhea = new OpenTypeHHEA;
- font->hhea = hhea;
- if (!table.ReadU32(&hhea->header.version)) {
- return OTS_FAILURE_MSG("Failed to read hhea version");
- }
- if (hhea->header.version >> 16 != 1) {
- return OTS_FAILURE_MSG("Bad hhea version of %d", hhea->header.version);
+ if (!table.ReadU32(&this->version)) {
+ return Error("Failed to read table version");
}
-
- if (!ParseMetricsHeader(font, &table, &hhea->header)) {
- return OTS_FAILURE_MSG("Failed to parse horizontal metrics");
+ if (this->version >> 16 != 1) {
+ return Error("Unsupported majorVersion: %d", this->version >> 16);
}
- return true;
+ return OpenTypeMetricsHeader::Parse(data, length);
}
-bool ots_hhea_should_serialise(Font *font) {
- return font->hhea != NULL;
-}
-
-bool ots_hhea_serialise(OTSStream *out, Font *font) {
- if (!SerialiseMetricsHeader(font, out, &font->hhea->header)) {
- return OTS_FAILURE_MSG("Failed to serialise horizontal metrics");
- }
- return true;
-}
-
-void ots_hhea_reuse(Font *font, Font *other) {
- font->hhea = other->hhea;
- font->hhea_reused = true;
-}
-
-void ots_hhea_free(Font *font) {
- delete font->hhea;
+bool OpenTypeHHEA::Serialize(OTSStream *out) {
+ return OpenTypeMetricsHeader::Serialize(out);
}
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/hhea.h b/gfx/ots/src/hhea.h
index bdea9aa0d..0405bd9d1 100644
--- a/gfx/ots/src/hhea.h
+++ b/gfx/ots/src/hhea.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,8 +10,13 @@
namespace ots {
-struct OpenTypeHHEA {
- OpenTypeMetricsHeader header;
+class OpenTypeHHEA : public OpenTypeMetricsHeader {
+ public:
+ explicit OpenTypeHHEA(Font *font, uint32_t tag)
+ : OpenTypeMetricsHeader(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
};
} // namespace ots
diff --git a/gfx/ots/src/hmtx.cc b/gfx/ots/src/hmtx.cc
index 667d1fe6f..2ef7771fd 100644
--- a/gfx/ots/src/hmtx.cc
+++ b/gfx/ots/src/hmtx.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,47 +10,14 @@
// hmtx - Horizontal Metrics
// http://www.microsoft.com/typography/otspec/hmtx.htm
-#define TABLE_NAME "hmtx"
-
namespace ots {
-bool ots_hmtx_parse(Font *font, const uint8_t *data, size_t length) {
- Buffer table(data, length);
- OpenTypeHMTX *hmtx = new OpenTypeHMTX;
- font->hmtx = hmtx;
-
- if (!font->hhea || !font->maxp) {
- return OTS_FAILURE_MSG("Missing hhea or maxp tables in font, needed by hmtx");
- }
-
- if (!ParseMetricsTable(font, &table, font->maxp->num_glyphs,
- &font->hhea->header, &hmtx->metrics)) {
- return OTS_FAILURE_MSG("Failed to parse hmtx metrics");
- }
-
- return true;
-}
-
-bool ots_hmtx_should_serialise(Font *font) {
- return font->hmtx != NULL;
+bool OpenTypeHMTX::Parse(const uint8_t *data, size_t length) {
+ return OpenTypeMetricsTable::Parse(data, length);
}
-bool ots_hmtx_serialise(OTSStream *out, Font *font) {
- if (!SerialiseMetricsTable(font, out, &font->hmtx->metrics)) {
- return OTS_FAILURE_MSG("Failed to serialise htmx metrics");
- }
- return true;
-}
-
-void ots_hmtx_reuse(Font *font, Font *other) {
- font->hmtx = other->hmtx;
- font->hmtx_reused = true;
-}
-
-void ots_hmtx_free(Font *font) {
- delete font->hmtx;
+bool OpenTypeHMTX::Serialize(OTSStream *out) {
+ return OpenTypeMetricsTable::Serialize(out);
}
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/hmtx.h b/gfx/ots/src/hmtx.h
index 435949c5e..dbea9c80c 100644
--- a/gfx/ots/src/hmtx.h
+++ b/gfx/ots/src/hmtx.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,12 +6,18 @@
#define OTS_HMTX_H_
#include "metrics.h"
+#include "hhea.h"
#include "ots.h"
namespace ots {
-struct OpenTypeHMTX {
- OpenTypeMetricsTable metrics;
+class OpenTypeHMTX : public OpenTypeMetricsTable {
+ public:
+ explicit OpenTypeHMTX(Font *font, uint32_t tag)
+ : OpenTypeMetricsTable(font, tag, tag, OTS_TAG_HHEA) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
};
} // namespace ots
diff --git a/gfx/ots/src/hvar.cc b/gfx/ots/src/hvar.cc
new file mode 100644
index 000000000..2bcea8680
--- /dev/null
+++ b/gfx/ots/src/hvar.cc
@@ -0,0 +1,85 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "hvar.h"
+
+#include "variations.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeHVAR
+// -----------------------------------------------------------------------------
+
+bool OpenTypeHVAR::Parse(const uint8_t* data, size_t length) {
+ Buffer table(data, length);
+
+ uint16_t majorVersion;
+ uint16_t minorVersion;
+ uint32_t itemVariationStoreOffset;
+ uint32_t advanceWidthMappingOffset;
+ uint32_t lsbMappingOffset;
+ uint32_t rsbMappingOffset;
+
+ if (!table.ReadU16(&majorVersion) ||
+ !table.ReadU16(&minorVersion) ||
+ !table.ReadU32(&itemVariationStoreOffset) ||
+ !table.ReadU32(&advanceWidthMappingOffset) ||
+ !table.ReadU32(&lsbMappingOffset) ||
+ !table.ReadU32(&rsbMappingOffset)) {
+ return DropVariations("Failed to read table header");
+ }
+
+ if (majorVersion != 1) {
+ return DropVariations("Unknown table version");
+ }
+
+ if (itemVariationStoreOffset > length ||
+ advanceWidthMappingOffset > length ||
+ lsbMappingOffset > length ||
+ rsbMappingOffset > length) {
+ return DropVariations("Invalid subtable offset");
+ }
+
+ if (!ParseItemVariationStore(GetFont(), data + itemVariationStoreOffset,
+ length - itemVariationStoreOffset)) {
+ return DropVariations("Failed to parse item variation store");
+ }
+
+ if (advanceWidthMappingOffset) {
+ if (!ParseDeltaSetIndexMap(GetFont(), data + advanceWidthMappingOffset,
+ length - advanceWidthMappingOffset)) {
+ return DropVariations("Failed to parse advance width mappings");
+ }
+ }
+
+ if (lsbMappingOffset) {
+ if (!ParseDeltaSetIndexMap(GetFont(), data + lsbMappingOffset,
+ length - lsbMappingOffset)) {
+ return DropVariations("Failed to parse LSB mappings");
+ }
+ }
+
+ if (rsbMappingOffset) {
+ if (!ParseDeltaSetIndexMap(GetFont(), data + rsbMappingOffset,
+ length - rsbMappingOffset)) {
+ return DropVariations("Failed to parse RSB mappings");
+ }
+ }
+
+ this->m_data = data;
+ this->m_length = length;
+
+ return true;
+}
+
+bool OpenTypeHVAR::Serialize(OTSStream* out) {
+ if (!out->Write(this->m_data, this->m_length)) {
+ return Error("Failed to write HVAR table");
+ }
+
+ return true;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/hvar.h b/gfx/ots/src/hvar.h
new file mode 100644
index 000000000..5bfd2e4ea
--- /dev/null
+++ b/gfx/ots/src/hvar.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_HVAR_H_
+#define OTS_HVAR_H_
+
+#include "ots.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeHVAR Interface
+// -----------------------------------------------------------------------------
+
+class OpenTypeHVAR : public Table {
+ public:
+ explicit OpenTypeHVAR(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ const uint8_t *m_data;
+ size_t m_length;
+};
+
+} // namespace ots
+
+#endif // OTS_HVAR_H_
diff --git a/gfx/ots/src/kern.cc b/gfx/ots/src/kern.cc
index d4ae8fcc4..ec41dfb9c 100644
--- a/gfx/ots/src/kern.cc
+++ b/gfx/ots/src/kern.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,75 +7,61 @@
// kern - Kerning
// http://www.microsoft.com/typography/otspec/kern.htm
-#define TABLE_NAME "kern"
-
-#define DROP_THIS_TABLE(msg_) \
- do { \
- OTS_FAILURE_MSG(msg_ ", table discarded"); \
- delete font->kern; \
- font->kern = 0; \
- } while (0)
-
namespace ots {
-bool ots_kern_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeKERN::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- OpenTypeKERN *kern = new OpenTypeKERN;
- font->kern = kern;
-
uint16_t num_tables = 0;
- if (!table.ReadU16(&kern->version) ||
+ if (!table.ReadU16(&this->version) ||
!table.ReadU16(&num_tables)) {
- return OTS_FAILURE_MSG("Failed to read kern header");
+ return Error("Failed to read table header");
}
- if (kern->version > 0) {
- DROP_THIS_TABLE("bad table version");
- return true;
+ if (this->version > 0) {
+ return Drop("Unsupported table version: %d", this->version);
}
if (num_tables == 0) {
- DROP_THIS_TABLE("num_tables is zero");
- return true;
+ return Drop("nTables is zero");
}
- kern->subtables.reserve(num_tables);
+ this->subtables.reserve(num_tables);
for (unsigned i = 0; i < num_tables; ++i) {
OpenTypeKERNFormat0 subtable;
uint16_t sub_length = 0;
if (!table.ReadU16(&subtable.version) ||
!table.ReadU16(&sub_length)) {
- return OTS_FAILURE_MSG("Failed to read kern subtable %d header", i);
+ return Error("Failed to read subtable %d header", i);
}
if (subtable.version > 0) {
- OTS_WARNING("Bad subtable version: %d", subtable.version);
+ Warning("Ignoring subtable %d with unsupported version: %d",
+ i, subtable.version);
continue;
}
const size_t current_offset = table.offset();
if (current_offset - 4 + sub_length > length) {
- return OTS_FAILURE_MSG("Bad kern subtable %d offset %ld", i, current_offset);
+ return Error("Bad subtable %d offset %ld", i, current_offset);
}
if (!table.ReadU16(&subtable.coverage)) {
- return OTS_FAILURE_MSG("Cailed to read kern subtable %d coverage", i);
+ return Error("Failed to read subtable %d coverage", i);
}
if (!(subtable.coverage & 0x1)) {
- OTS_WARNING(
+ Warning(
"We don't support vertical data as the renderer doesn't support it.");
continue;
}
if (subtable.coverage & 0xF0) {
- DROP_THIS_TABLE("Reserved fields should zero-filled");
- return true;
+ return Drop("Reserved fields should be zero");
}
const uint32_t format = (subtable.coverage & 0xFF00) >> 8;
if (format != 0) {
- OTS_WARNING("Format %d is not supported.", format);
+ Warning("Ignoring subtable %d with unsupported format: %d", i, format);
continue;
}
@@ -85,12 +71,11 @@ bool ots_kern_parse(Font *font, const uint8_t *data, size_t length) {
!table.ReadU16(&subtable.search_range) ||
!table.ReadU16(&subtable.entry_selector) ||
!table.ReadU16(&subtable.range_shift)) {
- return OTS_FAILURE_MSG("Failed to read kern subtable %d format 0 fields", i);
+ return Error("Failed to read subtable %d format 0 fields", i);
}
if (!num_pairs) {
- DROP_THIS_TABLE("Zero length subtable is found");
- return true;
+ return Drop("Zero length subtable is found");
}
// Sanity checks for search_range, entry_selector, and range_shift. See the
@@ -98,8 +83,7 @@ bool ots_kern_parse(Font *font, const uint8_t *data, size_t length) {
const size_t kFormat0PairSize = 6; // left, right, and value. 2 bytes each.
if (num_pairs > (65536 / kFormat0PairSize)) {
// Some fonts (e.g. calibri.ttf, pykes_peak_zero.ttf) have pairs >= 10923.
- DROP_THIS_TABLE("Too large subtable");
- return true;
+ return Drop("Too large subtable");
}
unsigned max_pow2 = 0;
while (1u << (max_pow2 + 1) <= num_pairs) {
@@ -107,16 +91,16 @@ bool ots_kern_parse(Font *font, const uint8_t *data, size_t length) {
}
const uint16_t expected_search_range = (1u << max_pow2) * kFormat0PairSize;
if (subtable.search_range != expected_search_range) {
- OTS_WARNING("bad search range");
+ Warning("bad search range");
subtable.search_range = expected_search_range;
}
if (subtable.entry_selector != max_pow2) {
- return OTS_FAILURE_MSG("Bad subtable %d entry selector %d", i, subtable.entry_selector);
+ return Error("Bad subtable %d entry selector %d", i, subtable.entry_selector);
}
const uint16_t expected_range_shift =
kFormat0PairSize * num_pairs - subtable.search_range;
if (subtable.range_shift != expected_range_shift) {
- OTS_WARNING("bad range shift");
+ Warning("bad range shift");
subtable.range_shift = expected_range_shift;
}
@@ -128,64 +112,55 @@ bool ots_kern_parse(Font *font, const uint8_t *data, size_t length) {
if (!table.ReadU16(&kerning_pair.left) ||
!table.ReadU16(&kerning_pair.right) ||
!table.ReadS16(&kerning_pair.value)) {
- return OTS_FAILURE_MSG("Failed to read subtable %d kerning pair %d", i, j);
+ return Error("Failed to read subtable %d kerning pair %d", i, j);
}
const uint32_t current_pair
= (kerning_pair.left << 16) + kerning_pair.right;
if (j != 0 && current_pair <= last_pair) {
// Many free fonts don't follow this rule, so we don't call OTS_FAILURE
// in order to support these fonts.
- DROP_THIS_TABLE("Kerning pairs are not sorted");
- return true;
+ return Drop("Kerning pairs are not sorted");
}
last_pair = current_pair;
subtable.pairs.push_back(kerning_pair);
}
- kern->subtables.push_back(subtable);
+ this->subtables.push_back(subtable);
}
- if (!kern->subtables.size()) {
- DROP_THIS_TABLE("All subtables are removed");
- return true;
+ if (!this->subtables.size()) {
+ return Drop("All subtables were removed");
}
return true;
}
-bool ots_kern_should_serialise(Font *font) {
- if (!font->glyf) return false; // this table is not for CFF fonts.
- return font->kern != NULL;
-}
-
-bool ots_kern_serialise(OTSStream *out, Font *font) {
- const OpenTypeKERN *kern = font->kern;
-
- const uint16_t num_subtables = static_cast<uint16_t>(kern->subtables.size());
- if (num_subtables != kern->subtables.size() ||
- !out->WriteU16(kern->version) ||
+bool OpenTypeKERN::Serialize(OTSStream *out) {
+ const uint16_t num_subtables = static_cast<uint16_t>(this->subtables.size());
+ if (num_subtables != this->subtables.size() ||
+ !out->WriteU16(this->version) ||
!out->WriteU16(num_subtables)) {
- return OTS_FAILURE_MSG("Can't write kern table header");
+ return Error("Failed to write kern table header");
}
for (uint16_t i = 0; i < num_subtables; ++i) {
- const size_t length = 14 + (6 * kern->subtables[i].pairs.size());
+ const size_t length = 14 + (6 * this->subtables[i].pairs.size());
if (length > std::numeric_limits<uint16_t>::max() ||
- !out->WriteU16(kern->subtables[i].version) ||
+ !out->WriteU16(this->subtables[i].version) ||
!out->WriteU16(static_cast<uint16_t>(length)) ||
- !out->WriteU16(kern->subtables[i].coverage) ||
+ !out->WriteU16(this->subtables[i].coverage) ||
!out->WriteU16(
- static_cast<uint16_t>(kern->subtables[i].pairs.size())) ||
- !out->WriteU16(kern->subtables[i].search_range) ||
- !out->WriteU16(kern->subtables[i].entry_selector) ||
- !out->WriteU16(kern->subtables[i].range_shift)) {
- return OTS_FAILURE_MSG("Failed to write kern subtable %d", i);
- }
- for (unsigned j = 0; j < kern->subtables[i].pairs.size(); ++j) {
- if (!out->WriteU16(kern->subtables[i].pairs[j].left) ||
- !out->WriteU16(kern->subtables[i].pairs[j].right) ||
- !out->WriteS16(kern->subtables[i].pairs[j].value)) {
- return OTS_FAILURE_MSG("Failed to write kern pair %d for subtable %d", j, i);
+ static_cast<uint16_t>(this->subtables[i].pairs.size())) ||
+ !out->WriteU16(this->subtables[i].search_range) ||
+ !out->WriteU16(this->subtables[i].entry_selector) ||
+ !out->WriteU16(this->subtables[i].range_shift)) {
+ return Error("Failed to write kern subtable %d", i);
+ }
+ for (unsigned j = 0; j < this->subtables[i].pairs.size(); ++j) {
+ if (!out->WriteU16(this->subtables[i].pairs[j].left) ||
+ !out->WriteU16(this->subtables[i].pairs[j].right) ||
+ !out->WriteS16(this->subtables[i].pairs[j].value)) {
+ return Error("Failed to write kern pair %d for subtable %d", j, i);
}
}
}
@@ -193,16 +168,10 @@ bool ots_kern_serialise(OTSStream *out, Font *font) {
return true;
}
-void ots_kern_reuse(Font *font, Font *other) {
- font->kern = other->kern;
- font->kern_reused = true;
-}
-
-void ots_kern_free(Font *font) {
- delete font->kern;
+bool OpenTypeKERN::ShouldSerialize() {
+ return Table::ShouldSerialize() &&
+ // this table is not for CFF fonts.
+ GetFont()->GetTable(OTS_TAG_GLYF) != NULL;
}
} // namespace ots
-
-#undef TABLE_NAME
-#undef DROP_THIS_TABLE
diff --git a/gfx/ots/src/kern.h b/gfx/ots/src/kern.h
index 9350ef7f8..38f056851 100644
--- a/gfx/ots/src/kern.h
+++ b/gfx/ots/src/kern.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -30,7 +30,16 @@ struct OpenTypeKERNFormat0 {
// WebFonts unlikely use it. I've checked thousands of proprietary fonts and
// free fonts, and found no font uses the format.
-struct OpenTypeKERN {
+class OpenTypeKERN : public Table {
+ public:
+ explicit OpenTypeKERN(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool ShouldSerialize();
+
+ private:
uint16_t version;
std::vector<OpenTypeKERNFormat0> subtables;
};
diff --git a/gfx/ots/src/layout.cc b/gfx/ots/src/layout.cc
index 1d87b53d4..8e99f573d 100644
--- a/gfx/ots/src/layout.cc
+++ b/gfx/ots/src/layout.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,6 +7,7 @@
#include <limits>
#include <vector>
+#include "fvar.h"
#include "gdef.h"
// OpenType Layout Common Table Formats
@@ -22,14 +23,11 @@ const uint32_t kScriptTableTagDflt = 0x44464c54;
const uint16_t kNoRequiredFeatureIndexDefined = 0xFFFF;
// The lookup flag bit which indicates existence of MarkFilteringSet.
const uint16_t kUseMarkFilteringSetBit = 0x0010;
-// The lookup flags which require GDEF table.
-const uint16_t kGdefRequiredFlags = 0x0002 | 0x0004 | 0x0008;
-// The mask for MarkAttachmentType.
-const uint16_t kMarkAttachmentTypeMask = 0xFF00;
// The maximum type number of format for device tables.
const uint16_t kMaxDeltaFormatType = 3;
-// The maximum number of class value.
-const uint16_t kMaxClassDefValue = 0xFFFF;
+// In variation fonts, Device Tables are replaced by VariationIndex tables,
+// indicated by this flag in the deltaFormat field.
+const uint16_t kVariationIndex = 0x8000;
struct ScriptRecord {
uint32_t tag;
@@ -94,15 +92,12 @@ bool ParseScriptTable(const ots::Font *font,
}
// The spec requires a script table for 'DFLT' tag must contain non-NULL
- // |offset_default_lang_sys| and |lang_sys_count| == 0
+ // |offset_default_lang_sys|.
// https://www.microsoft.com/typography/otspec/chapter2.htm
if (tag == kScriptTableTagDflt) {
if (offset_default_lang_sys == 0) {
return OTS_FAILURE_MSG("DFLT script doesn't satisfy the spec. DefaultLangSys is NULL");
}
- if (lang_sys_count != 0) {
- return OTS_FAILURE_MSG("DFLT script doesn't satisfy the spec. LangSysCount is not zero: %d", lang_sys_count);
- }
}
const unsigned lang_sys_record_end =
@@ -197,27 +192,7 @@ bool ParseLookupTable(ots::Font *font, const uint8_t *data,
return OTS_FAILURE_MSG("Bad lookup type %d", lookup_type);
}
- // Check lookup flags.
- if ((lookup_flag & kGdefRequiredFlags) &&
- (!font->gdef || !font->gdef->has_glyph_class_def)) {
- return OTS_FAILURE_MSG("Lookup flags require GDEF table, "
- "but none was found: %d", lookup_flag);
- }
- if ((lookup_flag & kMarkAttachmentTypeMask) &&
- (!font->gdef || !font->gdef->has_mark_attachment_class_def)) {
- return OTS_FAILURE_MSG("Lookup flags ask for mark attachment, "
- "but there is no GDEF table or it has no "
- "mark attachment classes: %d", lookup_flag);
- }
- bool use_mark_filtering_set = false;
- if (lookup_flag & kUseMarkFilteringSetBit) {
- if (!font->gdef || !font->gdef->has_mark_glyph_sets_def) {
- return OTS_FAILURE_MSG("Lookup flags ask for mark filtering, "
- "but there is no GDEF table or it has no "
- "mark filtering sets: %d", lookup_flag);
- }
- use_mark_filtering_set = true;
- }
+ bool use_mark_filtering_set = lookup_flag & kUseMarkFilteringSetBit;
std::vector<uint16_t> subtables;
subtables.reserve(subtable_count);
@@ -248,8 +223,12 @@ bool ParseLookupTable(ots::Font *font, const uint8_t *data,
if (!subtable.ReadU16(&mark_filtering_set)) {
return OTS_FAILURE_MSG("Failed to read mark filtering set");
}
- if (font->gdef->num_mark_glyph_sets == 0 ||
- mark_filtering_set >= font->gdef->num_mark_glyph_sets) {
+
+ ots::OpenTypeGDEF *gdef = static_cast<ots::OpenTypeGDEF*>(
+ font->GetTypedTable(OTS_TAG_GDEF));
+
+ if (gdef && (gdef->num_mark_glyph_sets == 0 ||
+ mark_filtering_set >= gdef->num_mark_glyph_sets)) {
return OTS_FAILURE_MSG("Bad mark filtering set %d", mark_filtering_set);
}
}
@@ -311,15 +290,15 @@ bool ParseClassDefFormat2(const ots::Font *font,
// Skip format field.
if (!subtable.Skip(2)) {
- return OTS_FAILURE_MSG("Failed to skip format of class defintion header");
+ return OTS_FAILURE_MSG("Failed to read class definition format");
}
uint16_t range_count = 0;
if (!subtable.ReadU16(&range_count)) {
- return OTS_FAILURE_MSG("Failed to read range count in class definition");
+ return OTS_FAILURE_MSG("Failed to read classRangeCount");
}
if (range_count > num_glyphs) {
- return OTS_FAILURE_MSG("bad range count: %u", range_count);
+ return OTS_FAILURE_MSG("classRangeCount > glyph count: %u > %u", range_count, num_glyphs);
}
uint16_t last_end = 0;
@@ -330,13 +309,16 @@ bool ParseClassDefFormat2(const ots::Font *font,
if (!subtable.ReadU16(&start) ||
!subtable.ReadU16(&end) ||
!subtable.ReadU16(&class_value)) {
- return OTS_FAILURE_MSG("Failed to read class definition reange %d", i);
+ return OTS_FAILURE_MSG("Failed to read ClassRangeRecord %d", i);
+ }
+ if (start > end) {
+ return OTS_FAILURE_MSG("ClassRangeRecord %d, start > end: %u > %u", i, start, end);
}
- if (start > end || (last_end && start <= last_end)) {
- return OTS_FAILURE_MSG("glyph range is overlapping.in range %d", i);
+ if (last_end && start <= last_end) {
+ return OTS_FAILURE_MSG("ClassRangeRecord %d start overlaps with end of the previous one: %u <= %u", i, start, last_end);
}
if (class_value > num_classes) {
- return OTS_FAILURE_MSG("bad class value: %u", class_value);
+ return OTS_FAILURE_MSG("ClassRangeRecord %d class > number of classes: %u > %u", i, class_value, num_classes);
}
last_end = end;
}
@@ -661,7 +643,7 @@ bool ParseContextFormat2(const ots::Font *font,
}
if (!ots::ParseClassDefTable(font, data + offset_class_def,
length - offset_class_def,
- num_glyphs, kMaxClassDefValue)) {
+ num_glyphs, ots::kMaxClassDefValue)) {
return OTS_FAILURE_MSG("Failed to parse class definition table in context format 2");
}
@@ -1014,7 +996,7 @@ bool ParseChainContextFormat2(const ots::Font *font,
}
if (!ots::ParseClassDefTable(font, data + offset_backtrack_class_def,
length - offset_backtrack_class_def,
- num_glyphs, kMaxClassDefValue)) {
+ num_glyphs, ots::kMaxClassDefValue)) {
return OTS_FAILURE_MSG("Failed to parse backtrack class defn table in chain context format 2");
}
}
@@ -1025,7 +1007,7 @@ bool ParseChainContextFormat2(const ots::Font *font,
}
if (!ots::ParseClassDefTable(font, data + offset_input_class_def,
length - offset_input_class_def,
- num_glyphs, kMaxClassDefValue)) {
+ num_glyphs, ots::kMaxClassDefValue)) {
return OTS_FAILURE_MSG("Failed to parse input class defn in chain context format 2");
}
@@ -1036,7 +1018,7 @@ bool ParseChainContextFormat2(const ots::Font *font,
}
if (!ots::ParseClassDefTable(font, data + offset_lookahead_class_def,
length - offset_lookahead_class_def,
- num_glyphs, kMaxClassDefValue)) {
+ num_glyphs, ots::kMaxClassDefValue)) {
return OTS_FAILURE_MSG("Failed to parse lookahead class defn in chain context format 2");
}
}
@@ -1400,11 +1382,17 @@ bool ParseDeviceTable(const ots::Font *font,
!subtable.ReadU16(&delta_format)) {
return OTS_FAILURE_MSG("Failed to read device table header");
}
+ if (delta_format == kVariationIndex) {
+ // start_size and end_size are replaced by deltaSetOuterIndex
+ // and deltaSetInnerIndex respectively, but we don't attempt to
+ // check them here, so nothing more to do.
+ return true;
+ }
if (start_size > end_size) {
- return OTS_FAILURE_MSG("bad size range: %u > %u", start_size, end_size);
+ return OTS_FAILURE_MSG("Bad device table size range: %u > %u", start_size, end_size);
}
if (delta_format == 0 || delta_format > kMaxDeltaFormatType) {
- return OTS_FAILURE_MSG("bad delta format: %u", delta_format);
+ return OTS_FAILURE_MSG("Bad device table delta format: 0x%x", delta_format);
}
// The number of delta values per uint16. The device table should contain
// at least |num_units| * 2 bytes compressed data.
@@ -1516,6 +1504,173 @@ bool ParseExtensionSubtable(const Font *font,
return true;
}
+bool ParseConditionTable(const Font *font,
+ const uint8_t *data, const size_t length,
+ const uint16_t axis_count) {
+ Buffer subtable(data, length);
+
+ uint16_t format = 0;
+ if (!subtable.ReadU16(&format)) {
+ return OTS_FAILURE_MSG("Failed to read condition table format");
+ }
+
+ if (format != 1) {
+ // An unknown format is not an error, but should be ignored per spec.
+ return true;
+ }
+
+ uint16_t axis_index = 0;
+ int16_t filter_range_min_value = 0;
+ int16_t filter_range_max_value = 0;
+ if (!subtable.ReadU16(&axis_index) ||
+ !subtable.ReadS16(&filter_range_min_value) ||
+ !subtable.ReadS16(&filter_range_max_value)) {
+ return OTS_FAILURE_MSG("Failed to read condition table (format 1)");
+ }
+
+ if (axis_index >= axis_count) {
+ return OTS_FAILURE_MSG("Axis index out of range in condition");
+ }
+
+ // Check min/max values are within range -1.0 .. 1.0 and properly ordered
+ if (filter_range_min_value < -0x4000 || // -1.0 in F2DOT14 format
+ filter_range_max_value > 0x4000 || // +1.0 in F2DOT14 format
+ filter_range_min_value > filter_range_max_value) {
+ return OTS_FAILURE_MSG("Invalid filter range in condition");
+ }
+
+ return true;
+}
+
+bool ParseConditionSetTable(const Font *font,
+ const uint8_t *data, const size_t length,
+ const uint16_t axis_count) {
+ Buffer subtable(data, length);
+
+ uint16_t condition_count = 0;
+ if (!subtable.ReadU16(&condition_count)) {
+ return OTS_FAILURE_MSG("Failed to read condition count");
+ }
+
+ for (uint16_t i = 0; i < condition_count; i++) {
+ uint32_t condition_offset = 0;
+ if (!subtable.ReadU32(&condition_offset)) {
+ return OTS_FAILURE_MSG("Failed to read condition offset");
+ }
+ if (condition_offset < subtable.offset() || condition_offset >= length) {
+ return OTS_FAILURE_MSG("Offset out of range");
+ }
+ if (!ParseConditionTable(font, data + condition_offset, length - condition_offset,
+ axis_count)) {
+ return OTS_FAILURE_MSG("Failed to parse condition table");
+ }
+ }
+
+ return true;
+}
+
+bool ParseFeatureTableSubstitutionTable(const Font *font,
+ const uint8_t *data, const size_t length,
+ const uint16_t num_lookups) {
+ Buffer subtable(data, length);
+
+ uint16_t version_major = 0;
+ uint16_t version_minor = 0;
+ uint16_t substitution_count = 0;
+ const size_t kFeatureTableSubstitutionHeaderSize = 3 * sizeof(uint16_t);
+
+ if (!subtable.ReadU16(&version_major) ||
+ !subtable.ReadU16(&version_minor) ||
+ !subtable.ReadU16(&substitution_count)) {
+ return OTS_FAILURE_MSG("Failed to read feature table substitution table header");
+ }
+
+ for (uint16_t i = 0; i < substitution_count; i++) {
+ uint16_t feature_index = 0;
+ uint32_t alternate_feature_table_offset = 0;
+ const size_t kFeatureTableSubstitutionRecordSize = sizeof(uint16_t) + sizeof(uint32_t);
+
+ if (!subtable.ReadU16(&feature_index) ||
+ !subtable.ReadU32(&alternate_feature_table_offset)) {
+ return OTS_FAILURE_MSG("Failed to read feature table substitution record");
+ }
+
+ if (alternate_feature_table_offset < kFeatureTableSubstitutionHeaderSize +
+ kFeatureTableSubstitutionRecordSize * substitution_count ||
+ alternate_feature_table_offset >= length) {
+ return OTS_FAILURE_MSG("Invalid alternate feature table offset");
+ }
+
+ if (!ParseFeatureTable(font, data + alternate_feature_table_offset,
+ length - alternate_feature_table_offset, num_lookups)) {
+ return OTS_FAILURE_MSG("Failed to parse alternate feature table");
+ }
+ }
+
+ return true;
+}
+
+bool ParseFeatureVariationsTable(const Font *font,
+ const uint8_t *data, const size_t length,
+ const uint16_t num_lookups) {
+ Buffer subtable(data, length);
+
+ uint16_t version_major = 0;
+ uint16_t version_minor = 0;
+ uint32_t feature_variation_record_count = 0;
+
+ if (!subtable.ReadU16(&version_major) ||
+ !subtable.ReadU16(&version_minor) ||
+ !subtable.ReadU32(&feature_variation_record_count)) {
+ return OTS_FAILURE_MSG("Failed to read feature variations table header");
+ }
+
+ OpenTypeFVAR* fvar = static_cast<OpenTypeFVAR*>(font->GetTypedTable(OTS_TAG_FVAR));
+ if (!fvar) {
+ return OTS_FAILURE_MSG("Not a variation font");
+ }
+ const uint16_t axis_count = fvar->AxisCount();
+
+ const size_t kEndOfFeatureVariationRecords =
+ 2 * sizeof(uint16_t) + sizeof(uint32_t) +
+ feature_variation_record_count * 2 * sizeof(uint32_t);
+
+ for (uint32_t i = 0; i < feature_variation_record_count; i++) {
+ uint32_t condition_set_offset = 0;
+ uint32_t feature_table_substitution_offset = 0;
+ if (!subtable.ReadU32(&condition_set_offset) ||
+ !subtable.ReadU32(&feature_table_substitution_offset)) {
+ return OTS_FAILURE_MSG("Failed to read feature variation record");
+ }
+
+ if (condition_set_offset) {
+ if (condition_set_offset < kEndOfFeatureVariationRecords ||
+ condition_set_offset >= length) {
+ return OTS_FAILURE_MSG("Condition set offset out of range");
+ }
+ if (!ParseConditionSetTable(font, data + condition_set_offset,
+ length - condition_set_offset,
+ axis_count)) {
+ return OTS_FAILURE_MSG("Failed to parse condition set table");
+ }
+ }
+
+ if (feature_table_substitution_offset) {
+ if (feature_table_substitution_offset < kEndOfFeatureVariationRecords ||
+ feature_table_substitution_offset >= length) {
+ return OTS_FAILURE_MSG("Feature table substitution offset out of range");
+ }
+ if (!ParseFeatureTableSubstitutionTable(font, data + feature_table_substitution_offset,
+ length - feature_table_substitution_offset,
+ num_lookups)) {
+ return OTS_FAILURE_MSG("Failed to parse feature table substitution table");
+ }
+ }
+ }
+
+ return true;
+}
+
} // namespace ots
#undef TABLE_NAME
diff --git a/gfx/ots/src/layout.h b/gfx/ots/src/layout.h
index d195646d4..d10a3be5b 100644
--- a/gfx/ots/src/layout.h
+++ b/gfx/ots/src/layout.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,6 +12,8 @@
namespace ots {
+// The maximum number of class value.
+const uint16_t kMaxClassDefValue = 0xFFFF;
struct LookupSubtableParser {
struct TypeParser {
@@ -70,6 +72,23 @@ bool ParseExtensionSubtable(const Font *font,
const uint8_t *data, const size_t length,
const LookupSubtableParser* parser);
+// For feature variations table (in GSUB/GPOS v1.1)
+bool ParseConditionTable(const Font *font,
+ const uint8_t *data, const size_t length,
+ const uint16_t axis_count);
+
+bool ParseConditionSetTable(const Font *font,
+ const uint8_t *data, const size_t length,
+ const uint16_t axis_count);
+
+bool ParseFeatureTableSubstitutionTable(const Font *font,
+ const uint8_t *data, const size_t length,
+ const uint16_t num_lookups);
+
+bool ParseFeatureVariationsTable(const Font *font,
+ const uint8_t *data, const size_t length,
+ const uint16_t num_lookups);
+
} // namespace ots
#endif // OTS_LAYOUT_H_
diff --git a/gfx/ots/src/loca.cc b/gfx/ots/src/loca.cc
index aae04c25a..4f322027d 100644
--- a/gfx/ots/src/loca.cc
+++ b/gfx/ots/src/loca.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,84 +10,79 @@
// loca - Index to Location
// http://www.microsoft.com/typography/otspec/loca.htm
-#define TABLE_NAME "loca"
-
namespace ots {
-bool ots_loca_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeLOCA::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
// We can't do anything useful in validating this data except to ensure that
// the values are monotonically increasing.
- OpenTypeLOCA *loca = new OpenTypeLOCA;
- font->loca = loca;
-
- if (!font->maxp || !font->head) {
- return OTS_FAILURE_MSG("maxp or head tables missing from font, needed by loca");
+ OpenTypeMAXP *maxp = static_cast<OpenTypeMAXP*>(
+ GetFont()->GetTypedTable(OTS_TAG_MAXP));
+ OpenTypeHEAD *head = static_cast<OpenTypeHEAD*>(
+ GetFont()->GetTypedTable(OTS_TAG_HEAD));
+ if (!maxp || !head) {
+ return Error("Required maxp or head tables are missing");
}
- const unsigned num_glyphs = font->maxp->num_glyphs;
+ const unsigned num_glyphs = maxp->num_glyphs;
unsigned last_offset = 0;
- loca->offsets.resize(num_glyphs + 1);
+ this->offsets.resize(num_glyphs + 1);
// maxp->num_glyphs is uint16_t, thus the addition never overflows.
- if (font->head->index_to_loc_format == 0) {
+ if (head->index_to_loc_format == 0) {
// Note that the <= here (and below) is correct. There is one more offset
// than the number of glyphs in order to give the length of the final
// glyph.
for (unsigned i = 0; i <= num_glyphs; ++i) {
uint16_t offset = 0;
if (!table.ReadU16(&offset)) {
- return OTS_FAILURE_MSG("Failed to read offset for glyph %d", i);
+ return Error("Failed to read offset for glyph %d", i);
}
if (offset < last_offset) {
- return OTS_FAILURE_MSG("Out of order offset %d < %d for glyph %d", offset, last_offset, i);
+ return Error("Out of order offset %d < %d for glyph %d", offset, last_offset, i);
}
last_offset = offset;
- loca->offsets[i] = offset * 2;
+ this->offsets[i] = offset * 2;
}
} else {
for (unsigned i = 0; i <= num_glyphs; ++i) {
uint32_t offset = 0;
if (!table.ReadU32(&offset)) {
- return OTS_FAILURE_MSG("Failed to read offset for glyph %d", i);
+ return Error("Failed to read offset for glyph %d", i);
}
if (offset < last_offset) {
- return OTS_FAILURE_MSG("Out of order offset %d < %d for glyph %d", offset, last_offset, i);
+ return Error("Out of order offset %d < %d for glyph %d", offset, last_offset, i);
}
last_offset = offset;
- loca->offsets[i] = offset;
+ this->offsets[i] = offset;
}
}
return true;
}
-bool ots_loca_should_serialise(Font *font) {
- return font->loca != NULL;
-}
-
-bool ots_loca_serialise(OTSStream *out, Font *font) {
- const OpenTypeLOCA *loca = font->loca;
- const OpenTypeHEAD *head = font->head;
+bool OpenTypeLOCA::Serialize(OTSStream *out) {
+ OpenTypeHEAD *head = static_cast<OpenTypeHEAD*>(
+ GetFont()->GetTypedTable(OTS_TAG_HEAD));
if (!head) {
- return OTS_FAILURE_MSG("Missing head table in font needed by loca");
+ return Error("Required head table is missing");
}
if (head->index_to_loc_format == 0) {
- for (unsigned i = 0; i < loca->offsets.size(); ++i) {
- const uint16_t offset = static_cast<uint16_t>(loca->offsets[i] >> 1);
- if ((offset != (loca->offsets[i] >> 1)) ||
+ for (unsigned i = 0; i < this->offsets.size(); ++i) {
+ const uint16_t offset = static_cast<uint16_t>(this->offsets[i] >> 1);
+ if ((offset != (this->offsets[i] >> 1)) ||
!out->WriteU16(offset)) {
- return OTS_FAILURE_MSG("Failed to write glyph offset for glyph %d", i);
+ return Error("Failed to write glyph offset for glyph %d", i);
}
}
} else {
- for (unsigned i = 0; i < loca->offsets.size(); ++i) {
- if (!out->WriteU32(loca->offsets[i])) {
- return OTS_FAILURE_MSG("Failed to write glyph offset for glyph %d", i);
+ for (unsigned i = 0; i < this->offsets.size(); ++i) {
+ if (!out->WriteU32(this->offsets[i])) {
+ return Error("Failed to write glyph offset for glyph %d", i);
}
}
}
@@ -95,15 +90,4 @@ bool ots_loca_serialise(OTSStream *out, Font *font) {
return true;
}
-void ots_loca_reuse(Font *font, Font *other) {
- font->loca = other->loca;
- font->loca_reused = true;
-}
-
-void ots_loca_free(Font *font) {
- delete font->loca;
-}
-
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/loca.h b/gfx/ots/src/loca.h
index 255ef06ec..da3241842 100644
--- a/gfx/ots/src/loca.h
+++ b/gfx/ots/src/loca.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,7 +11,14 @@
namespace ots {
-struct OpenTypeLOCA {
+class OpenTypeLOCA : public Table {
+ public:
+ explicit OpenTypeLOCA(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
std::vector<uint32_t> offsets;
};
diff --git a/gfx/ots/src/ltsh.cc b/gfx/ots/src/ltsh.cc
index 5b34cf4ad..4c40c5eb7 100644
--- a/gfx/ots/src/ltsh.cc
+++ b/gfx/ots/src/ltsh.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,89 +9,63 @@
// LTSH - Linear Threshold
// http://www.microsoft.com/typography/otspec/ltsh.htm
-#define TABLE_NAME "LTSH"
-
-#define DROP_THIS_TABLE(...) \
- do { \
- OTS_FAILURE_MSG_(font->file, TABLE_NAME ": " __VA_ARGS__); \
- OTS_FAILURE_MSG("Table discarded"); \
- delete font->ltsh; \
- font->ltsh = 0; \
- } while (0)
-
namespace ots {
-bool ots_ltsh_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeLTSH::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- if (!font->maxp) {
- return OTS_FAILURE_MSG("Missing maxp table from font needed by ltsh");
+ OpenTypeMAXP *maxp = static_cast<OpenTypeMAXP*>(
+ GetFont()->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return Error("Required maxp table is missing");
}
- OpenTypeLTSH *ltsh = new OpenTypeLTSH;
- font->ltsh = ltsh;
-
uint16_t num_glyphs = 0;
- if (!table.ReadU16(&ltsh->version) ||
+ if (!table.ReadU16(&this->version) ||
!table.ReadU16(&num_glyphs)) {
- return OTS_FAILURE_MSG("Failed to read ltsh header");
+ return Error("Failed to read table header");
}
- if (ltsh->version != 0) {
- DROP_THIS_TABLE("bad version: %u", ltsh->version);
- return true;
+ if (this->version != 0) {
+ return Drop("Unsupported version: %u", this->version);
}
- if (num_glyphs != font->maxp->num_glyphs) {
- DROP_THIS_TABLE("bad num_glyphs: %u", num_glyphs);
- return true;
+ if (num_glyphs != maxp->num_glyphs) {
+ return Drop("Bad numGlyphs: %u", num_glyphs);
}
- ltsh->ypels.reserve(num_glyphs);
+ this->ypels.reserve(num_glyphs);
for (unsigned i = 0; i < num_glyphs; ++i) {
uint8_t pel = 0;
if (!table.ReadU8(&pel)) {
- return OTS_FAILURE_MSG("Failed to read pixels for glyph %d", i);
+ return Error("Failed to read pixels for glyph %d", i);
}
- ltsh->ypels.push_back(pel);
+ this->ypels.push_back(pel);
}
return true;
}
-bool ots_ltsh_should_serialise(Font *font) {
- if (!font->glyf) return false; // this table is not for CFF fonts.
- return font->ltsh != NULL;
-}
-
-bool ots_ltsh_serialise(OTSStream *out, Font *font) {
- const OpenTypeLTSH *ltsh = font->ltsh;
-
- const uint16_t num_ypels = static_cast<uint16_t>(ltsh->ypels.size());
- if (num_ypels != ltsh->ypels.size() ||
- !out->WriteU16(ltsh->version) ||
+bool OpenTypeLTSH::Serialize(OTSStream *out) {
+ const uint16_t num_ypels = static_cast<uint16_t>(this->ypels.size());
+ if (num_ypels != this->ypels.size() ||
+ !out->WriteU16(this->version) ||
!out->WriteU16(num_ypels)) {
- return OTS_FAILURE_MSG("Failed to write pels size");
+ return Error("Failed to write table header");
}
for (uint16_t i = 0; i < num_ypels; ++i) {
- if (!out->Write(&(ltsh->ypels[i]), 1)) {
- return OTS_FAILURE_MSG("Failed to write pixel size for glyph %d", i);
+ if (!out->Write(&(this->ypels[i]), 1)) {
+ return Error("Failed to write pixel size for glyph %d", i);
}
}
return true;
}
-void ots_ltsh_reuse(Font *font, Font *other) {
- font->ltsh = other->ltsh;
- font->ltsh_reused = true;
-}
-
-void ots_ltsh_free(Font *font) {
- delete font->ltsh;
+bool OpenTypeLTSH::ShouldSerialize() {
+ return Table::ShouldSerialize() &&
+ // this table is not for CFF fonts.
+ GetFont()->GetTable(OTS_TAG_GLYF) != NULL;
}
} // namespace ots
-
-#undef TABLE_NAME
-#undef DROP_THIS_TABLE
diff --git a/gfx/ots/src/ltsh.h b/gfx/ots/src/ltsh.h
index 23d97d784..cc9fbf62d 100644
--- a/gfx/ots/src/ltsh.h
+++ b/gfx/ots/src/ltsh.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,7 +11,16 @@
namespace ots {
-struct OpenTypeLTSH {
+class OpenTypeLTSH : public Table {
+ public:
+ explicit OpenTypeLTSH(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool ShouldSerialize();
+
+ private:
uint16_t version;
std::vector<uint8_t> ypels;
};
diff --git a/gfx/ots/src/math.cc b/gfx/ots/src/math.cc
index 36417dc29..c94e3bee3 100644
--- a/gfx/ots/src/math.cc
+++ b/gfx/ots/src/math.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Copyright (c) 2014-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,12 +12,7 @@
#include "maxp.h"
// MATH - The MATH Table
-// The specification is not yet public but has been submitted to the MPEG group
-// in response to the 'Call for Proposals for ISO/IEC 14496-22 "Open Font
-// Format" Color Font Technology and MATH layout support'. Meanwhile, you can
-// contact Microsoft's engineer Murray Sargent to obtain a copy.
-
-#define TABLE_NAME "MATH"
+// http://www.microsoft.com/typography/otspec/math.htm
namespace {
@@ -48,11 +43,15 @@ const unsigned kMathValueRecordSize = 2 * 2;
// PartFlags
const unsigned kGlyphPartRecordSize = 5 * 2;
+} // namespace
+
+namespace ots {
+
// Shared Table: MathValueRecord
-bool ParseMathValueRecord(const ots::Font *font,
- ots::Buffer* subtable, const uint8_t *data,
- const size_t length) {
+bool OpenTypeMATH::ParseMathValueRecord(ots::Buffer* subtable,
+ const uint8_t *data,
+ const size_t length) {
// Check the Value field.
if (!subtable->Skip(2)) {
return OTS_FAILURE();
@@ -67,7 +66,7 @@ bool ParseMathValueRecord(const ots::Font *font,
if (offset >= length) {
return OTS_FAILURE();
}
- if (!ots::ParseDeviceTable(font, data + offset, length - offset)) {
+ if (!ots::ParseDeviceTable(GetFont(), data + offset, length - offset)) {
return OTS_FAILURE();
}
}
@@ -75,8 +74,8 @@ bool ParseMathValueRecord(const ots::Font *font,
return true;
}
-bool ParseMathConstantsTable(const ots::Font *font,
- const uint8_t *data, size_t length) {
+bool OpenTypeMATH::ParseMathConstantsTable(const uint8_t *data,
+ size_t length) {
ots::Buffer subtable(data, length);
// Part 1: int16 or uint16 constants.
@@ -146,7 +145,7 @@ bool ParseMathConstantsTable(const ots::Font *font,
//
// RadicalKernAfterDegree
for (unsigned i = 0; i < static_cast<unsigned>(51); ++i) {
- if (!ParseMathValueRecord(font, &subtable, data, length)) {
+ if (!ParseMathValueRecord(&subtable, data, length)) {
return OTS_FAILURE();
}
}
@@ -160,11 +159,10 @@ bool ParseMathConstantsTable(const ots::Font *font,
return true;
}
-bool ParseMathValueRecordSequenceForGlyphs(const ots::Font *font,
- ots::Buffer* subtable,
- const uint8_t *data,
- const size_t length,
- const uint16_t num_glyphs) {
+bool OpenTypeMATH::ParseMathValueRecordSequenceForGlyphs(ots::Buffer* subtable,
+ const uint8_t *data,
+ const size_t length,
+ const uint16_t num_glyphs) {
// Check the header.
uint16_t offset_coverage = 0;
uint16_t sequence_count = 0;
@@ -183,7 +181,7 @@ bool ParseMathValueRecordSequenceForGlyphs(const ots::Font *font,
if (offset_coverage < sequence_end || offset_coverage >= length) {
return OTS_FAILURE();
}
- if (!ots::ParseCoverageTable(font, data + offset_coverage,
+ if (!ots::ParseCoverageTable(GetFont(), data + offset_coverage,
length - offset_coverage,
num_glyphs, sequence_count)) {
return OTS_FAILURE();
@@ -191,7 +189,7 @@ bool ParseMathValueRecordSequenceForGlyphs(const ots::Font *font,
// Check sequence.
for (unsigned i = 0; i < sequence_count; ++i) {
- if (!ParseMathValueRecord(font, subtable, data, length)) {
+ if (!ParseMathValueRecord(subtable, data, length)) {
return OTS_FAILURE();
}
}
@@ -199,26 +197,23 @@ bool ParseMathValueRecordSequenceForGlyphs(const ots::Font *font,
return true;
}
-bool ParseMathItalicsCorrectionInfoTable(const ots::Font *font,
- const uint8_t *data,
- size_t length,
- const uint16_t num_glyphs) {
+bool OpenTypeMATH::ParseMathItalicsCorrectionInfoTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs) {
ots::Buffer subtable(data, length);
- return ParseMathValueRecordSequenceForGlyphs(font, &subtable, data, length,
+ return ParseMathValueRecordSequenceForGlyphs(&subtable, data, length,
num_glyphs);
}
-bool ParseMathTopAccentAttachmentTable(const ots::Font *font,
- const uint8_t *data,
- size_t length,
- const uint16_t num_glyphs) {
+bool OpenTypeMATH::ParseMathTopAccentAttachmentTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs) {
ots::Buffer subtable(data, length);
- return ParseMathValueRecordSequenceForGlyphs(font, &subtable, data, length,
+ return ParseMathValueRecordSequenceForGlyphs(&subtable, data, length,
num_glyphs);
}
-bool ParseMathKernTable(const ots::Font *font,
- const uint8_t *data, size_t length) {
+bool OpenTypeMATH::ParseMathKernTable(const uint8_t *data, size_t length) {
ots::Buffer subtable(data, length);
// Check the Height count.
@@ -229,14 +224,14 @@ bool ParseMathKernTable(const ots::Font *font,
// Check the Correction Heights.
for (unsigned i = 0; i < height_count; ++i) {
- if (!ParseMathValueRecord(font, &subtable, data, length)) {
+ if (!ParseMathValueRecord(&subtable, data, length)) {
return OTS_FAILURE();
}
}
// Check the Kern Values.
for (unsigned i = 0; i <= height_count; ++i) {
- if (!ParseMathValueRecord(font, &subtable, data, length)) {
+ if (!ParseMathValueRecord(&subtable, data, length)) {
return OTS_FAILURE();
}
}
@@ -244,9 +239,9 @@ bool ParseMathKernTable(const ots::Font *font,
return true;
}
-bool ParseMathKernInfoTable(const ots::Font *font,
- const uint8_t *data, size_t length,
- const uint16_t num_glyphs) {
+bool OpenTypeMATH::ParseMathKernInfoTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs) {
ots::Buffer subtable(data, length);
// Check the header.
@@ -267,7 +262,7 @@ bool ParseMathKernInfoTable(const ots::Font *font,
if (offset_coverage < sequence_end || offset_coverage >= length) {
return OTS_FAILURE();
}
- if (!ots::ParseCoverageTable(font, data + offset_coverage, length - offset_coverage,
+ if (!ots::ParseCoverageTable(GetFont(), data + offset_coverage, length - offset_coverage,
num_glyphs, sequence_count)) {
return OTS_FAILURE();
}
@@ -282,7 +277,7 @@ bool ParseMathKernInfoTable(const ots::Font *font,
}
if (offset_math_kern) {
if (offset_math_kern < sequence_end || offset_math_kern >= length ||
- !ParseMathKernTable(font, data + offset_math_kern,
+ !ParseMathKernTable(data + offset_math_kern,
length - offset_math_kern)) {
return OTS_FAILURE();
}
@@ -293,9 +288,9 @@ bool ParseMathKernInfoTable(const ots::Font *font,
return true;
}
-bool ParseMathGlyphInfoTable(const ots::Font *font,
- const uint8_t *data, size_t length,
- const uint16_t num_glyphs) {
+bool OpenTypeMATH::ParseMathGlyphInfoTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs) {
ots::Buffer subtable(data, length);
// Check Header.
@@ -318,7 +313,7 @@ bool ParseMathGlyphInfoTable(const ots::Font *font,
if (offset_math_italics_correction_info >= length ||
offset_math_italics_correction_info < kMathGlyphInfoHeaderSize ||
!ParseMathItalicsCorrectionInfoTable(
- font, data + offset_math_italics_correction_info,
+ data + offset_math_italics_correction_info,
length - offset_math_italics_correction_info,
num_glyphs)) {
return OTS_FAILURE();
@@ -327,7 +322,7 @@ bool ParseMathGlyphInfoTable(const ots::Font *font,
if (offset_math_top_accent_attachment) {
if (offset_math_top_accent_attachment >= length ||
offset_math_top_accent_attachment < kMathGlyphInfoHeaderSize ||
- !ParseMathTopAccentAttachmentTable(font, data +
+ !ParseMathTopAccentAttachmentTable(data +
offset_math_top_accent_attachment,
length -
offset_math_top_accent_attachment,
@@ -338,7 +333,7 @@ bool ParseMathGlyphInfoTable(const ots::Font *font,
if (offset_extended_shaped_coverage) {
if (offset_extended_shaped_coverage >= length ||
offset_extended_shaped_coverage < kMathGlyphInfoHeaderSize ||
- !ots::ParseCoverageTable(font, data + offset_extended_shaped_coverage,
+ !ots::ParseCoverageTable(GetFont(), data + offset_extended_shaped_coverage,
length - offset_extended_shaped_coverage,
num_glyphs)) {
return OTS_FAILURE();
@@ -347,7 +342,7 @@ bool ParseMathGlyphInfoTable(const ots::Font *font,
if (offset_math_kern_info) {
if (offset_math_kern_info >= length ||
offset_math_kern_info < kMathGlyphInfoHeaderSize ||
- !ParseMathKernInfoTable(font, data + offset_math_kern_info,
+ !ParseMathKernInfoTable(data + offset_math_kern_info,
length - offset_math_kern_info, num_glyphs)) {
return OTS_FAILURE();
}
@@ -356,14 +351,14 @@ bool ParseMathGlyphInfoTable(const ots::Font *font,
return true;
}
-bool ParseGlyphAssemblyTable(const ots::Font *font,
- const uint8_t *data,
- size_t length, const uint16_t num_glyphs) {
+bool OpenTypeMATH::ParseGlyphAssemblyTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs) {
ots::Buffer subtable(data, length);
// Check the header.
uint16_t part_count = 0;
- if (!ParseMathValueRecord(font, &subtable, data, length) ||
+ if (!ParseMathValueRecord(&subtable, data, length) ||
!subtable.ReadU16(&part_count)) {
return OTS_FAILURE();
}
@@ -384,19 +379,19 @@ bool ParseGlyphAssemblyTable(const ots::Font *font,
return OTS_FAILURE();
}
if (glyph >= num_glyphs) {
- return OTS_FAILURE_MSG("bad glyph ID: %u", glyph);
+ return Error("bad glyph ID: %u", glyph);
}
if (part_flags & ~0x00000001) {
- return OTS_FAILURE_MSG("unknown part flag: %u", part_flags);
+ return Error("unknown part flag: %u", part_flags);
}
}
return true;
}
-bool ParseMathGlyphConstructionTable(const ots::Font *font,
- const uint8_t *data,
- size_t length, const uint16_t num_glyphs) {
+bool OpenTypeMATH::ParseMathGlyphConstructionTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs) {
ots::Buffer subtable(data, length);
// Check the header.
@@ -419,7 +414,7 @@ bool ParseMathGlyphConstructionTable(const ots::Font *font,
offset_glyph_assembly < sequence_end) {
return OTS_FAILURE();
}
- if (!ParseGlyphAssemblyTable(font, data + offset_glyph_assembly,
+ if (!ParseGlyphAssemblyTable(data + offset_glyph_assembly,
length - offset_glyph_assembly, num_glyphs)) {
return OTS_FAILURE();
}
@@ -433,21 +428,20 @@ bool ParseMathGlyphConstructionTable(const ots::Font *font,
return OTS_FAILURE();
}
if (glyph >= num_glyphs) {
- return OTS_FAILURE_MSG("bad glyph ID: %u", glyph);
+ return Error("bad glyph ID: %u", glyph);
}
}
return true;
}
-bool ParseMathGlyphConstructionSequence(const ots::Font *font,
- ots::Buffer* subtable,
- const uint8_t *data,
- size_t length,
- const uint16_t num_glyphs,
- uint16_t offset_coverage,
- uint16_t glyph_count,
- const unsigned sequence_end) {
+bool OpenTypeMATH::ParseMathGlyphConstructionSequence(ots::Buffer* subtable,
+ const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs,
+ uint16_t offset_coverage,
+ uint16_t glyph_count,
+ const unsigned sequence_end) {
// Zero glyph count, nothing to parse.
if (!glyph_count) {
return true;
@@ -457,7 +451,7 @@ bool ParseMathGlyphConstructionSequence(const ots::Font *font,
if (offset_coverage < sequence_end || offset_coverage >= length) {
return OTS_FAILURE();
}
- if (!ots::ParseCoverageTable(font, data + offset_coverage,
+ if (!ots::ParseCoverageTable(GetFont(), data + offset_coverage,
length - offset_coverage,
num_glyphs, glyph_count)) {
return OTS_FAILURE();
@@ -471,7 +465,7 @@ bool ParseMathGlyphConstructionSequence(const ots::Font *font,
}
if (offset_glyph_construction < sequence_end ||
offset_glyph_construction >= length ||
- !ParseMathGlyphConstructionTable(font, data + offset_glyph_construction,
+ !ParseMathGlyphConstructionTable(data + offset_glyph_construction,
length - offset_glyph_construction,
num_glyphs)) {
return OTS_FAILURE();
@@ -481,9 +475,9 @@ bool ParseMathGlyphConstructionSequence(const ots::Font *font,
return true;
}
-bool ParseMathVariantsTable(const ots::Font *font,
- const uint8_t *data,
- size_t length, const uint16_t num_glyphs) {
+bool OpenTypeMATH::ParseMathVariantsTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs) {
ots::Buffer subtable(data, length);
// Check the header.
@@ -505,11 +499,11 @@ bool ParseMathVariantsTable(const ots::Font *font,
return OTS_FAILURE();
}
- if (!ParseMathGlyphConstructionSequence(font, &subtable, data, length, num_glyphs,
+ if (!ParseMathGlyphConstructionSequence(&subtable, data, length, num_glyphs,
offset_vert_glyph_coverage,
vert_glyph_count,
sequence_end) ||
- !ParseMathGlyphConstructionSequence(font, &subtable, data, length, num_glyphs,
+ !ParseMathGlyphConstructionSequence(&subtable, data, length, num_glyphs,
offset_horiz_glyph_coverage,
horiz_glyph_count,
sequence_end)) {
@@ -519,37 +513,24 @@ bool ParseMathVariantsTable(const ots::Font *font,
return true;
}
-} // namespace
-
-#define DROP_THIS_TABLE(msg_) \
- do { \
- OTS_FAILURE_MSG(msg_ ", table discarded"); \
- font->math->data = 0; \
- font->math->length = 0; \
- } while (0)
-
-namespace ots {
-
-bool ots_math_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeMATH::Parse(const uint8_t *data, size_t length) {
// Grab the number of glyphs in the font from the maxp table to check
// GlyphIDs in MATH table.
- if (!font->maxp) {
- return OTS_FAILURE();
+ OpenTypeMAXP *maxp = static_cast<OpenTypeMAXP*>(
+ GetFont()->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return Error("Required maxp table missing");
}
- const uint16_t num_glyphs = font->maxp->num_glyphs;
+ const uint16_t num_glyphs = maxp->num_glyphs;
Buffer table(data, length);
- OpenTypeMATH* math = new OpenTypeMATH;
- font->math = math;
-
uint32_t version = 0;
if (!table.ReadU32(&version)) {
return OTS_FAILURE();
}
if (version != 0x00010000) {
- DROP_THIS_TABLE("bad MATH version");
- return true;
+ return Drop("bad MATH version");
}
uint16_t offset_math_constants = 0;
@@ -567,53 +548,37 @@ bool ots_math_parse(Font *font, const uint8_t *data, size_t length) {
offset_math_glyph_info < kMathHeaderSize ||
offset_math_variants >= length ||
offset_math_variants < kMathHeaderSize) {
- DROP_THIS_TABLE("bad offset in MATH header");
- return true;
+ return Drop("bad offset in MATH header");
}
- if (!ParseMathConstantsTable(font, data + offset_math_constants,
+ if (!ParseMathConstantsTable(data + offset_math_constants,
length - offset_math_constants)) {
- DROP_THIS_TABLE("failed to parse MathConstants table");
- return true;
+ return Drop("failed to parse MathConstants table");
}
- if (!ParseMathGlyphInfoTable(font, data + offset_math_glyph_info,
+ if (!ParseMathGlyphInfoTable(data + offset_math_glyph_info,
length - offset_math_glyph_info, num_glyphs)) {
- DROP_THIS_TABLE("failed to parse MathGlyphInfo table");
- return true;
+ return Drop("failed to parse MathGlyphInfo table");
}
- if (!ParseMathVariantsTable(font, data + offset_math_variants,
+ if (!ParseMathVariantsTable(data + offset_math_variants,
length - offset_math_variants, num_glyphs)) {
- DROP_THIS_TABLE("failed to parse MathVariants table");
- return true;
+ return Drop("failed to parse MathVariants table");
}
- math->data = data;
- math->length = length;
+ this->m_data = data;
+ this->m_length = length;
return true;
}
-bool ots_math_should_serialise(Font *font) {
- return font->math != NULL && font->math->data != NULL;
-}
-
-bool ots_math_serialise(OTSStream *out, Font *font) {
- if (!out->Write(font->math->data, font->math->length)) {
+bool OpenTypeMATH::Serialize(OTSStream *out) {
+ if (!out->Write(this->m_data, this->m_length)) {
return OTS_FAILURE();
}
return true;
}
-void ots_math_reuse(Font *font, Font *other) {
- font->math = other->math;
- font->math_reused = true;
-}
-
-void ots_math_free(Font *font) {
- delete font->math;
+bool OpenTypeMATH::ShouldSerialize() {
+ return Table::ShouldSerialize() && this->m_data != NULL;
}
} // namespace ots
-
-#undef TABLE_NAME
-#undef DROP_THIS_TABLE
diff --git a/gfx/ots/src/math_.h b/gfx/ots/src/math_.h
index 91c54dbe1..875cacd4d 100644
--- a/gfx/ots/src/math_.h
+++ b/gfx/ots/src/math_.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Copyright (c) 2014-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,14 +9,58 @@
namespace ots {
-struct OpenTypeMATH {
- OpenTypeMATH()
- : data(NULL),
- length(0) {
- }
+class OpenTypeMATH : public Table {
+ public:
+ explicit OpenTypeMATH(Font *font, uint32_t tag)
+ : Table(font, tag, tag),
+ m_data(NULL),
+ m_length(0) { }
- const uint8_t *data;
- size_t length;
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool ShouldSerialize();
+
+ private:
+ bool ParseMathValueRecord(ots::Buffer* subtable,
+ const uint8_t *data,
+ const size_t length);
+ bool ParseMathConstantsTable(const uint8_t *data, size_t length);
+ bool ParseMathValueRecordSequenceForGlyphs(ots::Buffer* subtable,
+ const uint8_t *data,
+ const size_t length,
+ const uint16_t num_glyphs);
+ bool ParseMathItalicsCorrectionInfoTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs);
+ bool ParseMathTopAccentAttachmentTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs);
+ bool ParseMathKernTable(const uint8_t *data, size_t length);
+ bool ParseMathKernInfoTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs);
+ bool ParseMathGlyphInfoTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs);
+ bool ParseGlyphAssemblyTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs);
+ bool ParseMathGlyphConstructionTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs);
+ bool ParseMathGlyphConstructionSequence(ots::Buffer* subtable,
+ const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs,
+ uint16_t offset_coverage,
+ uint16_t glyph_count,
+ const unsigned sequence_end);
+ bool ParseMathVariantsTable(const uint8_t *data,
+ size_t length,
+ const uint16_t num_glyphs);
+
+ const uint8_t *m_data;
+ size_t m_length;
};
} // namespace ots
diff --git a/gfx/ots/src/maxp.cc b/gfx/ots/src/maxp.cc
index 41e29a745..232e4a988 100644
--- a/gfx/ots/src/maxp.cc
+++ b/gfx/ots/src/maxp.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,119 +7,97 @@
// maxp - Maximum Profile
// http://www.microsoft.com/typography/otspec/maxp.htm
-#define TABLE_NAME "maxp"
-
namespace ots {
-bool ots_maxp_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeMAXP::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- OpenTypeMAXP *maxp = new OpenTypeMAXP;
- font->maxp = maxp;
-
uint32_t version = 0;
if (!table.ReadU32(&version)) {
- return OTS_FAILURE_MSG("Failed to read version of maxp table");
+ return Error("Failed to read table version");
}
if (version >> 16 > 1) {
- return OTS_FAILURE_MSG("Bad maxp version %d", version);
+ return Error("Unsupported table version 0x%x", version);
}
- if (!table.ReadU16(&maxp->num_glyphs)) {
- return OTS_FAILURE_MSG("Failed to read number of glyphs from maxp table");
+ if (!table.ReadU16(&this->num_glyphs)) {
+ return Error("Failed to read numGlyphs");
}
- if (!maxp->num_glyphs) {
- return OTS_FAILURE_MSG("Bad number of glyphs 0 in maxp table");
+ if (!this->num_glyphs) {
+ return Error("numGlyphs is 0");
}
if (version >> 16 == 1) {
- maxp->version_1 = true;
- if (!table.ReadU16(&maxp->max_points) ||
- !table.ReadU16(&maxp->max_contours) ||
- !table.ReadU16(&maxp->max_c_points) ||
- !table.ReadU16(&maxp->max_c_contours) ||
- !table.ReadU16(&maxp->max_zones) ||
- !table.ReadU16(&maxp->max_t_points) ||
- !table.ReadU16(&maxp->max_storage) ||
- !table.ReadU16(&maxp->max_fdefs) ||
- !table.ReadU16(&maxp->max_idefs) ||
- !table.ReadU16(&maxp->max_stack) ||
- !table.ReadU16(&maxp->max_size_glyf_instructions) ||
- !table.ReadU16(&maxp->max_c_components) ||
- !table.ReadU16(&maxp->max_c_depth)) {
- return OTS_FAILURE_MSG("Failed to read maxp table");
+ this->version_1 = true;
+ if (!table.ReadU16(&this->max_points) ||
+ !table.ReadU16(&this->max_contours) ||
+ !table.ReadU16(&this->max_c_points) ||
+ !table.ReadU16(&this->max_c_contours) ||
+ !table.ReadU16(&this->max_zones) ||
+ !table.ReadU16(&this->max_t_points) ||
+ !table.ReadU16(&this->max_storage) ||
+ !table.ReadU16(&this->max_fdefs) ||
+ !table.ReadU16(&this->max_idefs) ||
+ !table.ReadU16(&this->max_stack) ||
+ !table.ReadU16(&this->max_size_glyf_instructions) ||
+ !table.ReadU16(&this->max_c_components) ||
+ !table.ReadU16(&this->max_c_depth)) {
+ return Error("Failed to read version 1 table data");
}
- if (maxp->max_zones == 0) {
+ if (this->max_zones == 0) {
// workaround for ipa*.ttf Japanese fonts.
- OTS_WARNING("bad max_zones: %u", maxp->max_zones);
- maxp->max_zones = 1;
- } else if (maxp->max_zones == 3) {
+ Warning("Bad maxZones: %u", this->max_zones);
+ this->max_zones = 1;
+ } else if (this->max_zones == 3) {
// workaround for Ecolier-*.ttf fonts.
- OTS_WARNING("bad max_zones: %u", maxp->max_zones);
- maxp->max_zones = 2;
+ Warning("Bad maxZones: %u", this->max_zones);
+ this->max_zones = 2;
}
- if ((maxp->max_zones != 1) && (maxp->max_zones != 2)) {
- return OTS_FAILURE_MSG("Bad max zones %d in maxp", maxp->max_zones);
+ if ((this->max_zones != 1) && (this->max_zones != 2)) {
+ return Error("Bad maxZones: %u", this->max_zones);
}
} else {
- maxp->version_1 = false;
+ this->version_1 = false;
}
return true;
}
-bool ots_maxp_should_serialise(Font *font) {
- return font->maxp != NULL;
-}
-
-bool ots_maxp_serialise(OTSStream *out, Font *font) {
- const OpenTypeMAXP *maxp = font->maxp;
-
- if (!out->WriteU32(maxp->version_1 ? 0x00010000 : 0x00005000) ||
- !out->WriteU16(maxp->num_glyphs)) {
- return OTS_FAILURE_MSG("Failed to write maxp version or number of glyphs");
+bool OpenTypeMAXP::Serialize(OTSStream *out) {
+ if (!out->WriteU32(this->version_1 ? 0x00010000 : 0x00005000) ||
+ !out->WriteU16(this->num_glyphs)) {
+ return Error("Failed to write version or numGlyphs");
}
- if (!maxp->version_1) return true;
+ if (!this->version_1) return true;
- if (!out->WriteU16(maxp->max_points) ||
- !out->WriteU16(maxp->max_contours) ||
- !out->WriteU16(maxp->max_c_points) ||
- !out->WriteU16(maxp->max_c_contours)) {
- return OTS_FAILURE_MSG("Failed to write maxp");
+ if (!out->WriteU16(this->max_points) ||
+ !out->WriteU16(this->max_contours) ||
+ !out->WriteU16(this->max_c_points) ||
+ !out->WriteU16(this->max_c_contours)) {
+ return Error("Failed to write maxp");
}
- if (!out->WriteU16(maxp->max_zones) ||
- !out->WriteU16(maxp->max_t_points) ||
- !out->WriteU16(maxp->max_storage) ||
- !out->WriteU16(maxp->max_fdefs) ||
- !out->WriteU16(maxp->max_idefs) ||
- !out->WriteU16(maxp->max_stack) ||
- !out->WriteU16(maxp->max_size_glyf_instructions)) {
- return OTS_FAILURE_MSG("Failed to write more maxp");
+ if (!out->WriteU16(this->max_zones) ||
+ !out->WriteU16(this->max_t_points) ||
+ !out->WriteU16(this->max_storage) ||
+ !out->WriteU16(this->max_fdefs) ||
+ !out->WriteU16(this->max_idefs) ||
+ !out->WriteU16(this->max_stack) ||
+ !out->WriteU16(this->max_size_glyf_instructions)) {
+ return Error("Failed to write more maxp");
}
- if (!out->WriteU16(maxp->max_c_components) ||
- !out->WriteU16(maxp->max_c_depth)) {
- return OTS_FAILURE_MSG("Failed to write yet more maxp");
+ if (!out->WriteU16(this->max_c_components) ||
+ !out->WriteU16(this->max_c_depth)) {
+ return Error("Failed to write yet more maxp");
}
return true;
}
-void ots_maxp_reuse(Font *font, Font *other) {
- font->maxp = other->maxp;
- font->maxp_reused = true;
-}
-
-void ots_maxp_free(Font *font) {
- delete font->maxp;
-}
-
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/maxp.h b/gfx/ots/src/maxp.h
index efca0c91a..99dbdc439 100644
--- a/gfx/ots/src/maxp.h
+++ b/gfx/ots/src/maxp.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,7 +9,14 @@
namespace ots {
-struct OpenTypeMAXP {
+class OpenTypeMAXP : public Table {
+ public:
+ explicit OpenTypeMAXP(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
uint16_t num_glyphs;
bool version_1;
diff --git a/gfx/ots/src/metrics.cc b/gfx/ots/src/metrics.cc
index cd89f4555..b49d73c5d 100644
--- a/gfx/ots/src/metrics.cc
+++ b/gfx/ots/src/metrics.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,149 +11,163 @@
// http://www.microsoft.com/typography/otspec/hhea.htm
// http://www.microsoft.com/typography/otspec/vhea.htm
-#define TABLE_NAME "metrics" // XXX: use individual table names
-
namespace ots {
-bool ParseMetricsHeader(Font *font, Buffer *table,
- OpenTypeMetricsHeader *header) {
- if (!table->ReadS16(&header->ascent) ||
- !table->ReadS16(&header->descent) ||
- !table->ReadS16(&header->linegap) ||
- !table->ReadU16(&header->adv_width_max) ||
- !table->ReadS16(&header->min_sb1) ||
- !table->ReadS16(&header->min_sb2) ||
- !table->ReadS16(&header->max_extent) ||
- !table->ReadS16(&header->caret_slope_rise) ||
- !table->ReadS16(&header->caret_slope_run) ||
- !table->ReadS16(&header->caret_offset)) {
- return OTS_FAILURE_MSG("Failed to read metrics header");
+bool OpenTypeMetricsHeader::Parse(const uint8_t *data, size_t length) {
+ Buffer table(data, length);
+
+ // Skip already read version.
+ if (!table.Skip(4)) {
+ return false;
+ }
+
+ if (!table.ReadS16(&this->ascent) ||
+ !table.ReadS16(&this->descent) ||
+ !table.ReadS16(&this->linegap) ||
+ !table.ReadU16(&this->adv_width_max) ||
+ !table.ReadS16(&this->min_sb1) ||
+ !table.ReadS16(&this->min_sb2) ||
+ !table.ReadS16(&this->max_extent) ||
+ !table.ReadS16(&this->caret_slope_rise) ||
+ !table.ReadS16(&this->caret_slope_run) ||
+ !table.ReadS16(&this->caret_offset)) {
+ return Error("Failed to read table");
}
- if (header->ascent < 0) {
- OTS_WARNING("bad ascent: %d", header->ascent);
- header->ascent = 0;
+ if (this->ascent < 0) {
+ Warning("bad ascent: %d", this->ascent);
+ this->ascent = 0;
}
- if (header->linegap < 0) {
- OTS_WARNING("bad linegap: %d", header->linegap);
- header->linegap = 0;
+ if (this->linegap < 0) {
+ Warning("bad linegap: %d", this->linegap);
+ this->linegap = 0;
}
- if (!font->head) {
- return OTS_FAILURE_MSG("Missing head font table");
+ OpenTypeHEAD *head = static_cast<OpenTypeHEAD*>(
+ GetFont()->GetTypedTable(OTS_TAG_HEAD));
+ if (!head) {
+ return Error("Missing head font table");
}
// if the font is non-slanted, caret_offset should be zero.
- if (!(font->head->mac_style & 2) &&
- (header->caret_offset != 0)) {
- OTS_WARNING("bad caret offset: %d", header->caret_offset);
- header->caret_offset = 0;
+ if (!(head->mac_style & 2) &&
+ (this->caret_offset != 0)) {
+ Warning("bad caret offset: %d", this->caret_offset);
+ this->caret_offset = 0;
}
// skip the reserved bytes
- if (!table->Skip(8)) {
- return OTS_FAILURE_MSG("Failed to skip reserverd bytes");
+ if (!table.Skip(8)) {
+ return Error("Failed to read reserverd bytes");
}
int16_t data_format;
- if (!table->ReadS16(&data_format)) {
- return OTS_FAILURE_MSG("Failed to read data format");
+ if (!table.ReadS16(&data_format)) {
+ return Error("Failed to read metricDataFormat");
}
if (data_format) {
- return OTS_FAILURE_MSG("Bad data format %d", data_format);
+ return Error("Bad metricDataFormat: %d", data_format);
}
- if (!table->ReadU16(&header->num_metrics)) {
- return OTS_FAILURE_MSG("Failed to read number of metrics");
+ if (!table.ReadU16(&this->num_metrics)) {
+ return Error("Failed to read number of metrics");
}
- if (!font->maxp) {
- return OTS_FAILURE_MSG("Missing maxp font table");
+ OpenTypeMAXP *maxp = static_cast<OpenTypeMAXP*>(
+ GetFont()->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return Error("Missing maxp font table");
}
- if (header->num_metrics > font->maxp->num_glyphs) {
- return OTS_FAILURE_MSG("Bad number of metrics %d", header->num_metrics);
+ if (this->num_metrics > maxp->num_glyphs) {
+ return Error("Bad number of metrics %d", this->num_metrics);
}
return true;
}
-bool SerialiseMetricsHeader(const ots::Font *font,
- OTSStream *out,
- const OpenTypeMetricsHeader *header) {
- if (!out->WriteU32(header->version) ||
- !out->WriteS16(header->ascent) ||
- !out->WriteS16(header->descent) ||
- !out->WriteS16(header->linegap) ||
- !out->WriteU16(header->adv_width_max) ||
- !out->WriteS16(header->min_sb1) ||
- !out->WriteS16(header->min_sb2) ||
- !out->WriteS16(header->max_extent) ||
- !out->WriteS16(header->caret_slope_rise) ||
- !out->WriteS16(header->caret_slope_run) ||
- !out->WriteS16(header->caret_offset) ||
+bool OpenTypeMetricsHeader::Serialize(OTSStream *out) {
+ if (!out->WriteU32(this->version) ||
+ !out->WriteS16(this->ascent) ||
+ !out->WriteS16(this->descent) ||
+ !out->WriteS16(this->linegap) ||
+ !out->WriteU16(this->adv_width_max) ||
+ !out->WriteS16(this->min_sb1) ||
+ !out->WriteS16(this->min_sb2) ||
+ !out->WriteS16(this->max_extent) ||
+ !out->WriteS16(this->caret_slope_rise) ||
+ !out->WriteS16(this->caret_slope_run) ||
+ !out->WriteS16(this->caret_offset) ||
!out->WriteR64(0) || // reserved
!out->WriteS16(0) || // metric data format
- !out->WriteU16(header->num_metrics)) {
- return OTS_FAILURE_MSG("Failed to write metrics");
+ !out->WriteU16(this->num_metrics)) {
+ return Error("Failed to write metrics");
}
return true;
}
-bool ParseMetricsTable(const ots::Font *font,
- Buffer *table,
- const uint16_t num_glyphs,
- const OpenTypeMetricsHeader *header,
- OpenTypeMetricsTable *metrics) {
+bool OpenTypeMetricsTable::Parse(const uint8_t *data, size_t length) {
+ Buffer table(data, length);
+
+ // OpenTypeMetricsHeader is a superclass of both 'hhea' and 'vhea',
+ // so the cast here is OK, whichever m_header_tag we have.
+ OpenTypeMetricsHeader *header = static_cast<OpenTypeMetricsHeader*>(
+ GetFont()->GetTypedTable(m_header_tag));
+ if (!header) {
+ return Error("Required %c%c%c%c table missing", OTS_UNTAG(m_header_tag));
+ }
// |num_metrics| is a uint16_t, so it's bounded < 65536. This limits that
// amount of memory that we'll allocate for this to a sane amount.
const unsigned num_metrics = header->num_metrics;
- if (num_metrics > num_glyphs) {
- return OTS_FAILURE_MSG("Bad number of metrics %d", num_metrics);
+ OpenTypeMAXP *maxp = static_cast<OpenTypeMAXP*>(
+ GetFont()->GetTypedTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return Error("Required maxp table missing");
+ }
+ if (num_metrics > maxp->num_glyphs) {
+ return Error("Bad number of metrics %d", num_metrics);
}
if (!num_metrics) {
- return OTS_FAILURE_MSG("No metrics!");
+ return Error("No metrics!");
}
- const unsigned num_sbs = num_glyphs - num_metrics;
+ const unsigned num_sbs = maxp->num_glyphs - num_metrics;
- metrics->entries.reserve(num_metrics);
+ this->entries.reserve(num_metrics);
for (unsigned i = 0; i < num_metrics; ++i) {
uint16_t adv = 0;
int16_t sb = 0;
- if (!table->ReadU16(&adv) || !table->ReadS16(&sb)) {
- return OTS_FAILURE_MSG("Failed to read metric %d", i);
+ if (!table.ReadU16(&adv) || !table.ReadS16(&sb)) {
+ return Error("Failed to read metric %d", i);
}
- metrics->entries.push_back(std::make_pair(adv, sb));
+ this->entries.push_back(std::make_pair(adv, sb));
}
- metrics->sbs.reserve(num_sbs);
+ this->sbs.reserve(num_sbs);
for (unsigned i = 0; i < num_sbs; ++i) {
int16_t sb;
- if (!table->ReadS16(&sb)) {
+ if (!table.ReadS16(&sb)) {
// Some Japanese fonts (e.g., mona.ttf) fail this test.
- return OTS_FAILURE_MSG("Failed to read side bearing %d", i + num_metrics);
+ return Error("Failed to read side bearing %d", i + num_metrics);
}
- metrics->sbs.push_back(sb);
+ this->sbs.push_back(sb);
}
return true;
}
-bool SerialiseMetricsTable(const ots::Font *font,
- OTSStream *out,
- const OpenTypeMetricsTable *metrics) {
- for (unsigned i = 0; i < metrics->entries.size(); ++i) {
- if (!out->WriteU16(metrics->entries[i].first) ||
- !out->WriteS16(metrics->entries[i].second)) {
- return OTS_FAILURE_MSG("Failed to write metric %d", i);
+bool OpenTypeMetricsTable::Serialize(OTSStream *out) {
+ for (unsigned i = 0; i < this->entries.size(); ++i) {
+ if (!out->WriteU16(this->entries[i].first) ||
+ !out->WriteS16(this->entries[i].second)) {
+ return Error("Failed to write metric %d", i);
}
}
- for (unsigned i = 0; i < metrics->sbs.size(); ++i) {
- if (!out->WriteS16(metrics->sbs[i])) {
- return OTS_FAILURE_MSG("Failed to write side bearing %ld", i + metrics->entries.size());
+ for (unsigned i = 0; i < this->sbs.size(); ++i) {
+ if (!out->WriteS16(this->sbs[i])) {
+ return Error("Failed to write side bearing %ld", i + this->entries.size());
}
}
@@ -161,5 +175,3 @@ bool SerialiseMetricsTable(const ots::Font *font,
}
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/metrics.h b/gfx/ots/src/metrics.h
index 767be2fdb..efe14c070 100644
--- a/gfx/ots/src/metrics.h
+++ b/gfx/ots/src/metrics.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,7 +13,14 @@
namespace ots {
-struct OpenTypeMetricsHeader {
+class OpenTypeMetricsHeader : public Table {
+ public:
+ explicit OpenTypeMetricsHeader(Font *font, uint32_t tag, uint32_t type)
+ : Table(font, tag, type) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
uint32_t version;
int16_t ascent;
int16_t descent;
@@ -28,27 +35,22 @@ struct OpenTypeMetricsHeader {
uint16_t num_metrics;
};
-struct OpenTypeMetricsTable {
+struct OpenTypeMetricsTable : public Table {
+ public:
+ explicit OpenTypeMetricsTable(Font *font, uint32_t tag, uint32_t type,
+ uint32_t header_tag)
+ : Table(font, tag, type), m_header_tag(header_tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
+ private:
+ uint32_t m_header_tag;
+
std::vector<std::pair<uint16_t, int16_t> > entries;
std::vector<int16_t> sbs;
};
-bool ParseMetricsHeader(Font *font, Buffer *table,
- OpenTypeMetricsHeader *header);
-bool SerialiseMetricsHeader(const ots::Font *font,
- OTSStream *out,
- const OpenTypeMetricsHeader *header);
-
-bool ParseMetricsTable(const ots::Font *font,
- Buffer *table,
- const uint16_t num_glyphs,
- const OpenTypeMetricsHeader *header,
- OpenTypeMetricsTable *metrics);
-bool SerialiseMetricsTable(const ots::Font *font,
- OTSStream *out,
- const OpenTypeMetricsTable *metrics);
-
} // namespace ots
#endif // OTS_METRICS_H_
-
diff --git a/gfx/ots/src/moz.build b/gfx/ots/src/moz.build
index f8e60d5f8..962a86a5b 100644
--- a/gfx/ots/src/moz.build
+++ b/gfx/ots/src/moz.build
@@ -9,41 +9,52 @@ EXPORTS += [
'../include/ots-memory-stream.h',
]
-SOURCES += [
- # don't unify sources that use a (file-specific) DROP_THIS_TABLE macro
- 'gasp.cc',
- 'gdef.cc',
- 'gpos.cc',
- 'gsub.cc',
- 'hdmx.cc',
- 'kern.cc',
- 'ltsh.cc',
- 'math.cc',
- 'vdmx.cc',
- 'vorg.cc',
-]
-
UNIFIED_SOURCES += [
+ 'avar.cc',
'cff.cc',
- 'cff_type2_charstring.cc',
+ 'cff_charstring.cc',
'cmap.cc',
+ 'cvar.cc',
'cvt.cc',
+ 'feat.cc',
'fpgm.cc',
+ 'fvar.cc',
+ 'gasp.cc',
+ 'gdef.cc',
+ 'glat.cc',
+ 'gloc.cc',
'glyf.cc',
+ 'gpos.cc',
+ 'gsub.cc',
+ 'gvar.cc',
+ 'hdmx.cc',
'head.cc',
'hhea.cc',
'hmtx.cc',
+ 'hvar.cc',
+ 'kern.cc',
'layout.cc',
'loca.cc',
+ 'ltsh.cc',
+ 'math.cc',
'maxp.cc',
'metrics.cc',
+ 'mvar.cc',
'name.cc',
'os2.cc',
'ots.cc',
'post.cc',
'prep.cc',
+ 'sile.cc',
+ 'silf.cc',
+ 'sill.cc',
+ 'stat.cc',
+ 'variations.cc',
+ 'vdmx.cc',
'vhea.cc',
'vmtx.cc',
+ 'vorg.cc',
+ 'vvar.cc',
]
# We allow warnings for third-party code that can be updated from upstream.
@@ -53,8 +64,14 @@ FINAL_LIBRARY = 'gkmedias'
DEFINES['PACKAGE_VERSION'] = '"moz"'
DEFINES['PACKAGE_BUGREPORT'] = '"http://bugzilla.mozilla.org/"'
+DEFINES['OTS_GRAPHITE'] = 1
+DEFINES['OTS_VARIATIONS'] = 1
USE_LIBS += [
'brotli',
'woff2',
]
+
+LOCAL_INCLUDES += [
+ '/modules/woff2/src',
+]
diff --git a/gfx/ots/src/mvar.cc b/gfx/ots/src/mvar.cc
new file mode 100644
index 000000000..d021203d3
--- /dev/null
+++ b/gfx/ots/src/mvar.cc
@@ -0,0 +1,105 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mvar.h"
+
+#include "variations.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeMVAR
+// -----------------------------------------------------------------------------
+
+bool OpenTypeMVAR::Parse(const uint8_t* data, size_t length) {
+ Buffer table(data, length);
+
+ uint16_t majorVersion;
+ uint16_t minorVersion;
+ uint16_t reserved;
+ uint16_t valueRecordSize;
+ uint16_t valueRecordCount;
+ uint16_t itemVariationStoreOffset;
+
+ if (!table.ReadU16(&majorVersion) ||
+ !table.ReadU16(&minorVersion) ||
+ !table.ReadU16(&reserved) ||
+ !table.ReadU16(&valueRecordSize) ||
+ !table.ReadU16(&valueRecordCount) ||
+ !table.ReadU16(&itemVariationStoreOffset)) {
+ return DropVariations("Failed to read table header");
+ }
+
+ if (majorVersion != 1) {
+ return DropVariations("Unknown table version");
+ }
+
+ if (reserved != 0) {
+ Warning("Expected reserved=0");
+ }
+
+ // The spec says that valueRecordSize "must be greater than zero",
+ // but we don't enforce this in the case where valueRecordCount
+ // is zero.
+ // The minimum size for a valueRecord to be valid is 8, for the
+ // three fields currently defined in the record (see below).
+ if (valueRecordSize < 8) {
+ if (valueRecordCount != 0) {
+ return DropVariations("Value record size too small");
+ }
+ }
+
+ if (valueRecordCount == 0) {
+ if (itemVariationStoreOffset != 0) {
+ // The spec says "if valueRecordCount is zero, set to zero",
+ // but having a variation store even when record count is zero
+ // should be harmless -- it just won't be useful for anything.
+ // But we don't need to reject altogether.
+ Warning("Unexpected item variation store");
+ }
+ } else {
+ if (itemVariationStoreOffset < table.offset() || itemVariationStoreOffset > length) {
+ return DropVariations("Invalid item variation store offset");
+ }
+ if (!ParseItemVariationStore(GetFont(), data + itemVariationStoreOffset,
+ length - itemVariationStoreOffset)) {
+ return DropVariations("Failed to parse item variation store");
+ }
+ }
+
+ uint32_t prevTag = 0;
+ size_t offset = table.offset();
+ for (unsigned i = 0; i < valueRecordCount; i++) {
+ uint32_t tag;
+ uint16_t deltaSetOuterIndex, deltaSetInnerIndex;
+ if (!table.ReadU32(&tag) ||
+ !table.ReadU16(&deltaSetOuterIndex) ||
+ !table.ReadU16(&deltaSetInnerIndex)) {
+ return DropVariations("Failed to read value record");
+ }
+ if (tag <= prevTag) {
+ return DropVariations("Invalid or out-of-order value tag");
+ }
+ prevTag = tag;
+ // Adjust offset in case additional fields have been added to the
+ // valueRecord by a new minor version (allowed by spec).
+ offset += valueRecordSize;
+ table.set_offset(offset);
+ }
+
+ this->m_data = data;
+ this->m_length = length;
+
+ return true;
+}
+
+bool OpenTypeMVAR::Serialize(OTSStream* out) {
+ if (!out->Write(this->m_data, this->m_length)) {
+ return Error("Failed to write MVAR table");
+ }
+
+ return true;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/mvar.h b/gfx/ots/src/mvar.h
new file mode 100644
index 000000000..81fb6155d
--- /dev/null
+++ b/gfx/ots/src/mvar.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_MVAR_H_
+#define OTS_MVAR_H_
+
+#include "ots.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeMVAR Interface
+// -----------------------------------------------------------------------------
+
+class OpenTypeMVAR : public Table {
+ public:
+ explicit OpenTypeMVAR(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ const uint8_t *m_data;
+ size_t m_length;
+};
+
+} // namespace ots
+
+#endif // OTS_MVAR_H_
diff --git a/gfx/ots/src/name.cc b/gfx/ots/src/name.cc
index e55be7537..11deeecaa 100644
--- a/gfx/ots/src/name.cc
+++ b/gfx/ots/src/name.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,8 +10,6 @@
// name - Naming Table
// http://www.microsoft.com/typography/otspec/name.htm
-#define TABLE_NAME "name"
-
namespace {
bool ValidInPsName(char c) {
@@ -56,25 +54,22 @@ void AssignToUtf16BeFromAscii(std::string* target,
namespace ots {
-bool ots_name_parse(Font *font, const uint8_t* data, size_t length) {
+bool OpenTypeNAME::Parse(const uint8_t* data, size_t length) {
Buffer table(data, length);
- OpenTypeNAME* name = new OpenTypeNAME;
- font->name = name;
-
uint16_t format = 0;
if (!table.ReadU16(&format) || format > 1) {
- return OTS_FAILURE_MSG("Failed to read name table format or bad format %d", format);
+ return Error("Failed to read table format or bad format %d", format);
}
uint16_t count = 0;
if (!table.ReadU16(&count)) {
- return OTS_FAILURE_MSG("Failed to read name count");
+ return Error("Failed to read name count");
}
uint16_t string_offset = 0;
if (!table.ReadU16(&string_offset) || string_offset > length) {
- return OTS_FAILURE_MSG("Failed to read strings offset");
+ return Error("Failed to read or bad stringOffset");
}
const char* string_base = reinterpret_cast<const char*>(data) +
string_offset;
@@ -94,7 +89,7 @@ bool ots_name_parse(Font *font, const uint8_t* data, size_t length) {
!table.ReadU16(&rec.name_id) ||
!table.ReadU16(&name_length) ||
!table.ReadU16(&name_offset)) {
- return OTS_FAILURE_MSG("Failed to read name entry %d", i);
+ return Error("Failed to read name entry %d", i);
}
// check platform & encoding, discard names with unknown values
switch (rec.platform_id) {
@@ -148,40 +143,49 @@ bool ots_name_parse(Font *font, const uint8_t* data, size_t length) {
}
}
- if (!name->names.empty() && !(name->names.back() < rec)) {
- OTS_WARNING("name records are not sorted.");
+ if (!this->names.empty() && !(this->names.back() < rec)) {
+ Warning("name records are not sorted.");
sort_required = true;
}
- name->names.push_back(rec);
+ this->names.push_back(rec);
+ this->name_ids.insert(rec.name_id);
}
if (format == 1) {
// extended name table format with language tags
uint16_t lang_tag_count;
if (!table.ReadU16(&lang_tag_count)) {
- return OTS_FAILURE_MSG("Failed to read language tag count");
+ return Error("Failed to read langTagCount");
}
for (unsigned i = 0; i < lang_tag_count; ++i) {
uint16_t tag_length = 0;
uint16_t tag_offset = 0;
if (!table.ReadU16(&tag_length) || !table.ReadU16(&tag_offset)) {
- return OTS_FAILURE_MSG("Faile to read tag length or offset");
+ return Error("Faile to read length or offset for langTagRecord %d", i);
}
const unsigned tag_end = static_cast<unsigned>(string_offset) +
tag_offset + tag_length;
if (tag_end > length) {
- return OTS_FAILURE_MSG("bad end of tag %d > %ld for name entry %d", tag_end, length, i);
+ return Error("bad end of tag %d > %ld for langTagRecord %d", tag_end, length, i);
+ }
+ // Lang tag is BCP 47 tag per the spec, the recommonded BCP 47 max tag
+ // length is 35:
+ // https://tools.ietf.org/html/bcp47#section-4.4.1
+ // We are being too generous and allowing for 100 (multiplied by 2 since
+ // this is UTF-16 string).
+ if (tag_length > 100 * 2) {
+ return Error("Too long language tag for LangTagRecord %d: %d", i, tag_length);
}
std::string tag(string_base + tag_offset, tag_length);
- name->lang_tags.push_back(tag);
+ this->lang_tags.push_back(tag);
}
}
if (table.offset() > string_offset) {
// the string storage apparently overlapped the name/tag records;
// consider this font to be badly broken
- return OTS_FAILURE_MSG("Bad table offset %ld > %d", table.offset(), string_offset);
+ return Error("Bad table offset %ld > %d", table.offset(), string_offset);
}
// check existence of required name strings (synthesize if necessary)
@@ -207,17 +211,16 @@ bool ots_name_parse(Font *font, const uint8_t* data, size_t length) {
// if not, we'll add our fixed versions here
bool mac_name[kStdNameCount] = { 0 };
bool win_name[kStdNameCount] = { 0 };
- for (std::vector<NameRecord>::iterator name_iter = name->names.begin();
- name_iter != name->names.end(); ++name_iter) {
- const uint16_t id = name_iter->name_id;
+ for (const auto& name : this->names) {
+ const uint16_t id = name.name_id;
if (id >= kStdNameCount || kStdNames[id] == NULL) {
continue;
}
- if (name_iter->platform_id == 1) {
+ if (name.platform_id == 1) {
mac_name[id] = true;
continue;
}
- if (name_iter->platform_id == 3) {
+ if (name.platform_id == 3) {
win_name[id] = true;
continue;
}
@@ -236,49 +239,41 @@ bool ots_name_parse(Font *font, const uint8_t* data, size_t length) {
1033 /* language_id */ , i /* name_id */);
AssignToUtf16BeFromAscii(&win_rec.text, std::string(kStdNames[i]));
- name->names.push_back(mac_rec);
- name->names.push_back(win_rec);
+ this->names.push_back(mac_rec);
+ this->names.push_back(win_rec);
sort_required = true;
}
}
if (sort_required) {
- std::sort(name->names.begin(), name->names.end());
+ std::sort(this->names.begin(), this->names.end());
}
return true;
}
-bool ots_name_should_serialise(Font *font) {
- return font->name != NULL;
-}
-
-bool ots_name_serialise(OTSStream* out, Font *font) {
- const OpenTypeNAME* name = font->name;
-
- uint16_t name_count = static_cast<uint16_t>(name->names.size());
- uint16_t lang_tag_count = static_cast<uint16_t>(name->lang_tags.size());
+bool OpenTypeNAME::Serialize(OTSStream* out) {
+ uint16_t name_count = static_cast<uint16_t>(this->names.size());
+ uint16_t lang_tag_count = static_cast<uint16_t>(this->lang_tags.size());
uint16_t format = 0;
size_t string_offset = 6 + name_count * 12;
- if (name->lang_tags.size() > 0) {
+ if (this->lang_tags.size() > 0) {
// lang tags require a format-1 name table
format = 1;
string_offset += 2 + lang_tag_count * 4;
}
if (string_offset > 0xffff) {
- return OTS_FAILURE_MSG("Bad string offset %ld", string_offset);
+ return Error("Bad stringOffset: %ld", string_offset);
}
if (!out->WriteU16(format) ||
!out->WriteU16(name_count) ||
!out->WriteU16(static_cast<uint16_t>(string_offset))) {
- return OTS_FAILURE_MSG("Failed to write name header");
+ return Error("Failed to write name header");
}
std::string string_data;
- for (std::vector<NameRecord>::const_iterator name_iter = name->names.begin();
- name_iter != name->names.end(); ++name_iter) {
- const NameRecord& rec = *name_iter;
+ for (const auto& rec : this->names) {
if (string_data.size() + rec.text.size() >
std::numeric_limits<uint16_t>::max() ||
!out->WriteU16(rec.platform_id) ||
@@ -287,44 +282,77 @@ bool ots_name_serialise(OTSStream* out, Font *font) {
!out->WriteU16(rec.name_id) ||
!out->WriteU16(static_cast<uint16_t>(rec.text.size())) ||
!out->WriteU16(static_cast<uint16_t>(string_data.size())) ) {
- return OTS_FAILURE_MSG("Faile to write name entry");
+ return Error("Faile to write nameRecord");
}
string_data.append(rec.text);
}
if (format == 1) {
if (!out->WriteU16(lang_tag_count)) {
- return OTS_FAILURE_MSG("Faile to write language tag count");
+ return Error("Faile to write langTagCount");
}
- for (std::vector<std::string>::const_iterator tag_iter =
- name->lang_tags.begin();
- tag_iter != name->lang_tags.end(); ++tag_iter) {
- if (string_data.size() + tag_iter->size() >
+ for (const auto& tag : this->lang_tags) {
+ if (string_data.size() + tag.size() >
std::numeric_limits<uint16_t>::max() ||
- !out->WriteU16(static_cast<uint16_t>(tag_iter->size())) ||
+ !out->WriteU16(static_cast<uint16_t>(tag.size())) ||
!out->WriteU16(static_cast<uint16_t>(string_data.size()))) {
- return OTS_FAILURE_MSG("Failed to write string");
+ return Error("Failed to write langTagRecord");
}
- string_data.append(*tag_iter);
+ string_data.append(tag);
}
}
if (!out->Write(string_data.data(), string_data.size())) {
- return OTS_FAILURE_MSG("Faile to write string data");
+ return Error("Faile to write string data");
}
return true;
}
-void ots_name_reuse(Font *font, Font *other) {
- font->name = other->name;
- font->name_reused = true;
-}
-
-void ots_name_free(Font *font) {
- delete font->name;
+bool OpenTypeNAME::IsValidNameId(uint16_t nameID, bool addIfMissing) {
+ if (addIfMissing && !this->name_ids.count(nameID)) {
+ bool added_unicode = false;
+ bool added_macintosh = false;
+ bool added_windows = false;
+ const size_t names_size = this->names.size(); // original size
+ for (size_t i = 0; i < names_size; ++i) switch (names[i].platform_id) {
+ case 0:
+ if (!added_unicode) {
+ // If there is an existing NameRecord with platform_id == 0 (Unicode),
+ // then add a NameRecord for the the specified nameID with arguments
+ // 0 (Unicode), 0 (v1.0), 0 (unspecified language).
+ this->names.emplace_back(0, 0, 0, nameID);
+ this->names.back().text = "NoName";
+ added_unicode = true;
+ }
+ break;
+ case 1:
+ if (!added_macintosh) {
+ // If there is an existing NameRecord with platform_id == 1 (Macintosh),
+ // then add a NameRecord for the specified nameID with arguments
+ // 1 (Macintosh), 0 (Roman), 0 (English).
+ this->names.emplace_back(1, 0, 0, nameID);
+ this->names.back().text = "NoName";
+ added_macintosh = true;
+ }
+ break;
+ case 3:
+ if (!added_windows) {
+ // If there is an existing NameRecord with platform_id == 3 (Windows),
+ // then add a NameRecord for the specified nameID with arguments
+ // 3 (Windows), 1 (UCS), 1033 (US English).
+ this->names.emplace_back(3, 1, 1033, nameID);
+ this->names.back().text = "NoName";
+ added_windows = true;
+ }
+ break;
+ }
+ if (added_unicode || added_macintosh || added_windows) {
+ std::sort(this->names.begin(), this->names.end());
+ this->name_ids.insert(nameID);
+ }
+ }
+ return this->name_ids.count(nameID);
}
} // namespace
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/name.h b/gfx/ots/src/name.h
index a11965f46..68c7ac096 100644
--- a/gfx/ots/src/name.h
+++ b/gfx/ots/src/name.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,6 +9,7 @@
#include <string>
#include <utility>
#include <vector>
+#include <unordered_set>
#include "ots.h"
@@ -43,9 +44,19 @@ struct NameRecord {
}
};
-struct OpenTypeNAME {
+class OpenTypeNAME : public Table {
+ public:
+ explicit OpenTypeNAME(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool IsValidNameId(uint16_t nameID, bool addIfMissing = false);
+
+ private:
std::vector<NameRecord> names;
std::vector<std::string> lang_tags;
+ std::unordered_set<uint16_t> name_ids;
};
} // namespace ots
diff --git a/gfx/ots/src/os2.cc b/gfx/ots/src/os2.cc
index fd5cdd1d6..5376a1dbb 100644
--- a/gfx/ots/src/os2.cc
+++ b/gfx/ots/src/os2.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,77 +10,73 @@
// OS/2 - OS/2 and Windows Metrics
// http://www.microsoft.com/typography/otspec/os2.htm
-#define TABLE_NAME "OS/2"
-
namespace ots {
-bool ots_os2_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeOS2::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- OpenTypeOS2 *os2 = new OpenTypeOS2;
- font->os2 = os2;
-
- if (!table.ReadU16(&os2->version) ||
- !table.ReadS16(&os2->avg_char_width) ||
- !table.ReadU16(&os2->weight_class) ||
- !table.ReadU16(&os2->width_class) ||
- !table.ReadU16(&os2->type) ||
- !table.ReadS16(&os2->subscript_x_size) ||
- !table.ReadS16(&os2->subscript_y_size) ||
- !table.ReadS16(&os2->subscript_x_offset) ||
- !table.ReadS16(&os2->subscript_y_offset) ||
- !table.ReadS16(&os2->superscript_x_size) ||
- !table.ReadS16(&os2->superscript_y_size) ||
- !table.ReadS16(&os2->superscript_x_offset) ||
- !table.ReadS16(&os2->superscript_y_offset) ||
- !table.ReadS16(&os2->strikeout_size) ||
- !table.ReadS16(&os2->strikeout_position) ||
- !table.ReadS16(&os2->family_class)) {
- return OTS_FAILURE_MSG("Error reading basic table elements");
- }
-
- if (os2->version > 5) {
- return OTS_FAILURE_MSG("Unsupported table version: %u", os2->version);
- }
-
- // Follow WPF Font Selection Model's advice.
- if (1 <= os2->weight_class && os2->weight_class <= 9) {
- OTS_WARNING("Bad usWeightClass: %u, changing it to: %u", os2->weight_class, os2->weight_class * 100);
- os2->weight_class *= 100;
- }
- // Ditto.
- if (os2->weight_class > 999) {
- OTS_WARNING("Bad usWeightClass: %u, changing it to: %d", os2->weight_class, 999);
- os2->weight_class = 999;
- }
-
- if (os2->width_class < 1) {
- OTS_WARNING("Bad usWidthClass: %u, changing it to: %d", os2->width_class, 1);
- os2->width_class = 1;
- } else if (os2->width_class > 9) {
- OTS_WARNING("Bad usWidthClass: %u, changing it to: %d", os2->width_class, 9);
- os2->width_class = 9;
+ if (!table.ReadU16(&this->table.version) ||
+ !table.ReadS16(&this->table.avg_char_width) ||
+ !table.ReadU16(&this->table.weight_class) ||
+ !table.ReadU16(&this->table.width_class) ||
+ !table.ReadU16(&this->table.type) ||
+ !table.ReadS16(&this->table.subscript_x_size) ||
+ !table.ReadS16(&this->table.subscript_y_size) ||
+ !table.ReadS16(&this->table.subscript_x_offset) ||
+ !table.ReadS16(&this->table.subscript_y_offset) ||
+ !table.ReadS16(&this->table.superscript_x_size) ||
+ !table.ReadS16(&this->table.superscript_y_size) ||
+ !table.ReadS16(&this->table.superscript_x_offset) ||
+ !table.ReadS16(&this->table.superscript_y_offset) ||
+ !table.ReadS16(&this->table.strikeout_size) ||
+ !table.ReadS16(&this->table.strikeout_position) ||
+ !table.ReadS16(&this->table.family_class)) {
+ return Error("Error reading basic table elements");
+ }
+
+ if (this->table.version > 5) {
+ return Error("Unsupported table version: %u", this->table.version);
+ }
+
+ if (this->table.weight_class < 1) {
+ Warning("Bad usWeightClass: %u, changing it to %d",
+ this->table.weight_class, 1);
+ this->table.weight_class = 1;
+ } else if (this->table.weight_class > 1000) {
+ Warning("Bad usWeightClass: %u, changing it to %d",
+ this->table.weight_class, 1000);
+ this->table.weight_class = 1000;
+ }
+
+ if (this->table.width_class < 1) {
+ Warning("Bad usWidthClass: %u, changing it to %d",
+ this->table.width_class, 1);
+ this->table.width_class = 1;
+ } else if (this->table.width_class > 9) {
+ Warning("Bad usWidthClass: %u, changing it to %d",
+ this->table.width_class, 9);
+ this->table.width_class = 9;
}
// lowest 3 bits of fsType are exclusive.
- if (os2->type & 0x2) {
+ if (this->table.type & 0x2) {
// mask bits 2 & 3.
- os2->type &= 0xfff3u;
- } else if (os2->type & 0x4) {
+ this->table.type &= 0xfff3u;
+ } else if (this->table.type & 0x4) {
// mask bits 1 & 3.
- os2->type &= 0xfff4u;
- } else if (os2->type & 0x8) {
+ this->table.type &= 0xfff4u;
+ } else if (this->table.type & 0x8) {
// mask bits 1 & 2.
- os2->type &= 0xfff9u;
+ this->table.type &= 0xfff9u;
}
// mask reserved bits. use only 0..3, 8, 9 bits.
- os2->type &= 0x30f;
+ this->table.type &= 0x30f;
-#define SET_TO_ZERO(a, b) \
- if (os2->b < 0) { \
- OTS_WARNING("Bad " a ": %d, setting it to zero", os2->b); \
- os2->b = 0; \
+#define SET_TO_ZERO(a, b) \
+ if (this->table.b < 0) { \
+ Warning("Bad " a ": %d, setting it to zero", this->table.b); \
+ this->table.b = 0; \
}
SET_TO_ZERO("ySubscriptXSize", subscript_x_size);
@@ -90,7 +86,7 @@ bool ots_os2_parse(Font *font, const uint8_t *data, size_t length) {
SET_TO_ZERO("yStrikeoutSize", strikeout_size);
#undef SET_TO_ZERO
- static std::string panose_strings[10] = {
+ static const char* panose_strings[10] = {
"bFamilyType",
"bSerifStyle",
"bWeight",
@@ -103,234 +99,222 @@ bool ots_os2_parse(Font *font, const uint8_t *data, size_t length) {
"bXHeight",
};
for (unsigned i = 0; i < 10; ++i) {
- if (!table.ReadU8(&os2->panose[i])) {
- return OTS_FAILURE_MSG("Error reading PANOSE %s", panose_strings[i].c_str());
+ if (!table.ReadU8(&this->table.panose[i])) {
+ return Error("Failed to read PANOSE %s", panose_strings[i]);
}
}
- if (!table.ReadU32(&os2->unicode_range_1) ||
- !table.ReadU32(&os2->unicode_range_2) ||
- !table.ReadU32(&os2->unicode_range_3) ||
- !table.ReadU32(&os2->unicode_range_4) ||
- !table.ReadU32(&os2->vendor_id) ||
- !table.ReadU16(&os2->selection) ||
- !table.ReadU16(&os2->first_char_index) ||
- !table.ReadU16(&os2->last_char_index) ||
- !table.ReadS16(&os2->typo_ascender) ||
- !table.ReadS16(&os2->typo_descender) ||
- !table.ReadS16(&os2->typo_linegap) ||
- !table.ReadU16(&os2->win_ascent) ||
- !table.ReadU16(&os2->win_descent)) {
- return OTS_FAILURE_MSG("Error reading more basic table fields");
+ if (!table.ReadU32(&this->table.unicode_range_1) ||
+ !table.ReadU32(&this->table.unicode_range_2) ||
+ !table.ReadU32(&this->table.unicode_range_3) ||
+ !table.ReadU32(&this->table.unicode_range_4) ||
+ !table.ReadU32(&this->table.vendor_id) ||
+ !table.ReadU16(&this->table.selection) ||
+ !table.ReadU16(&this->table.first_char_index) ||
+ !table.ReadU16(&this->table.last_char_index) ||
+ !table.ReadS16(&this->table.typo_ascender) ||
+ !table.ReadS16(&this->table.typo_descender) ||
+ !table.ReadS16(&this->table.typo_linegap) ||
+ !table.ReadU16(&this->table.win_ascent) ||
+ !table.ReadU16(&this->table.win_descent)) {
+ return Error("Error reading more basic table fields");
}
// If bit 6 is set, then bits 0 and 5 must be clear.
- if (os2->selection & 0x40) {
- os2->selection &= 0xffdeu;
+ if (this->table.selection & 0x40) {
+ this->table.selection &= 0xffdeu;
}
// the settings of bits 0 and 1 must be reflected in the macStyle bits
// in the 'head' table.
- if (!font->head) {
- return OTS_FAILURE_MSG("Needed head table is missing from the font");
- }
- if ((os2->selection & 0x1) &&
- !(font->head->mac_style & 0x2)) {
- OTS_WARNING("adjusting Mac style (italic)");
- font->head->mac_style |= 0x2;
+ OpenTypeHEAD *head = static_cast<OpenTypeHEAD*>(
+ GetFont()->GetTypedTable(OTS_TAG_HEAD));
+
+ if ((this->table.selection & 0x1) &&
+ head && !(head->mac_style & 0x2)) {
+ Warning("Adjusting head.macStyle (italic) to match fsSelection");
+ head->mac_style |= 0x2;
}
- if ((os2->selection & 0x2) &&
- !(font->head->mac_style & 0x4)) {
- OTS_WARNING("adjusting Mac style (underscore)");
- font->head->mac_style |= 0x4;
+ if ((this->table.selection & 0x2) &&
+ head && !(head->mac_style & 0x4)) {
+ Warning("Adjusting head.macStyle (underscore) to match fsSelection");
+ head->mac_style |= 0x4;
}
// While bit 6 on implies that bits 0 and 1 of macStyle are clear,
// the reverse is not true.
- if ((os2->selection & 0x40) &&
- (font->head->mac_style & 0x3)) {
- OTS_WARNING("adjusting Mac style (regular)");
- font->head->mac_style &= 0xfffcu;
+ if ((this->table.selection & 0x40) &&
+ head && (head->mac_style & 0x3)) {
+ Warning("Adjusting head.macStyle (regular) to match fsSelection");
+ head->mac_style &= 0xfffcu;
}
- if ((os2->version < 4) &&
- (os2->selection & 0x300)) {
+ if ((this->table.version < 4) &&
+ (this->table.selection & 0x300)) {
// bit 8 and 9 must be unset in OS/2 table versions less than 4.
- return OTS_FAILURE_MSG("Version %d incompatible with selection %d", os2->version, os2->selection);
+ Warning("fsSelection bits 8 and 9 must be unset for table version %d",
+ this->table.version);
}
// mask reserved bits. use only 0..9 bits.
- os2->selection &= 0x3ff;
+ this->table.selection &= 0x3ff;
- if (os2->first_char_index > os2->last_char_index) {
- return OTS_FAILURE_MSG("first char index %d > last char index %d in os2", os2->first_char_index, os2->last_char_index);
+ if (this->table.first_char_index > this->table.last_char_index) {
+ Warning("usFirstCharIndex %d > usLastCharIndex %d",
+ this->table.first_char_index, this->table.last_char_index);
+ this->table.first_char_index = this->table.last_char_index;
}
- if (os2->typo_linegap < 0) {
- OTS_WARNING("bad linegap: %d", os2->typo_linegap);
- os2->typo_linegap = 0;
+ if (this->table.typo_linegap < 0) {
+ Warning("Bad sTypoLineGap, setting it to 0: %d", this->table.typo_linegap);
+ this->table.typo_linegap = 0;
}
- if (os2->version < 1) {
+ if (this->table.version < 1) {
// http://www.microsoft.com/typography/otspec/os2ver0.htm
return true;
}
- if (length < offsetof(OpenTypeOS2, code_page_range_2)) {
- OTS_WARNING("bad version number: %u", os2->version);
+ if (length < offsetof(OS2Data, code_page_range_2)) {
+ Warning("Bad version number, setting it to 0: %u", this->table.version);
// Some fonts (e.g., kredit1.ttf and quinquef.ttf) have weird version
// numbers. Fix them.
- os2->version = 0;
+ this->table.version = 0;
return true;
}
- if (!table.ReadU32(&os2->code_page_range_1) ||
- !table.ReadU32(&os2->code_page_range_2)) {
- return OTS_FAILURE_MSG("Failed to read codepage ranges");
+ if (!table.ReadU32(&this->table.code_page_range_1) ||
+ !table.ReadU32(&this->table.code_page_range_2)) {
+ return Error("Failed to read ulCodePageRange1 or ulCodePageRange2");
}
- if (os2->version < 2) {
+ if (this->table.version < 2) {
// http://www.microsoft.com/typography/otspec/os2ver1.htm
return true;
}
- if (length < offsetof(OpenTypeOS2, max_context)) {
- OTS_WARNING("bad version number: %u", os2->version);
+ if (length < offsetof(OS2Data, max_context)) {
+ Warning("Bad version number, setting it to 1: %u", this->table.version);
// some Japanese fonts (e.g., mona.ttf) have weird version number.
// fix them.
- os2->version = 1;
+ this->table.version = 1;
return true;
}
- if (!table.ReadS16(&os2->x_height) ||
- !table.ReadS16(&os2->cap_height) ||
- !table.ReadU16(&os2->default_char) ||
- !table.ReadU16(&os2->break_char) ||
- !table.ReadU16(&os2->max_context)) {
- return OTS_FAILURE_MSG("Failed to read version 2-specific fields");
+ if (!table.ReadS16(&this->table.x_height) ||
+ !table.ReadS16(&this->table.cap_height) ||
+ !table.ReadU16(&this->table.default_char) ||
+ !table.ReadU16(&this->table.break_char) ||
+ !table.ReadU16(&this->table.max_context)) {
+ return Error("Failed to read version 2-specific fields");
}
- if (os2->x_height < 0) {
- OTS_WARNING("bad x_height: %d", os2->x_height);
- os2->x_height = 0;
+ if (this->table.x_height < 0) {
+ Warning("Bad sxHeight settig it to 0: %d", this->table.x_height);
+ this->table.x_height = 0;
}
- if (os2->cap_height < 0) {
- OTS_WARNING("bad cap_height: %d", os2->cap_height);
- os2->cap_height = 0;
+ if (this->table.cap_height < 0) {
+ Warning("Bad sCapHeight setting it to 0: %d", this->table.cap_height);
+ this->table.cap_height = 0;
}
- if (os2->version < 5) {
+ if (this->table.version < 5) {
// http://www.microsoft.com/typography/otspec/os2ver4.htm
return true;
}
- if (!table.ReadU16(&os2->lower_optical_pointsize) ||
- !table.ReadU16(&os2->upper_optical_pointsize)) {
- return OTS_FAILURE_MSG("Failed to read version 5-specific fields");
+ if (!table.ReadU16(&this->table.lower_optical_pointsize) ||
+ !table.ReadU16(&this->table.upper_optical_pointsize)) {
+ return Error("Failed to read version 5-specific fields");
}
- if (os2->lower_optical_pointsize > 0xFFFE) {
- OTS_WARNING("'usLowerOpticalPointSize' is bigger than 0xFFFE: %d", os2->lower_optical_pointsize);
- os2->lower_optical_pointsize = 0xFFFE;
+ if (this->table.lower_optical_pointsize > 0xFFFE) {
+ Warning("usLowerOpticalPointSize is bigger than 0xFFFE: %d",
+ this->table.lower_optical_pointsize);
+ this->table.lower_optical_pointsize = 0xFFFE;
}
- if (os2->upper_optical_pointsize < 2) {
- OTS_WARNING("'usUpperOpticalPointSize' is lower than 2: %d", os2->upper_optical_pointsize);
- os2->upper_optical_pointsize = 2;
+ if (this->table.upper_optical_pointsize < 2) {
+ Warning("usUpperOpticalPointSize is lower than 2: %d",
+ this->table.upper_optical_pointsize);
+ this->table.upper_optical_pointsize = 2;
}
return true;
}
-bool ots_os2_should_serialise(Font *font) {
- return font->os2 != NULL;
-}
-
-bool ots_os2_serialise(OTSStream *out, Font *font) {
- const OpenTypeOS2 *os2 = font->os2;
-
- if (!out->WriteU16(os2->version) ||
- !out->WriteS16(os2->avg_char_width) ||
- !out->WriteU16(os2->weight_class) ||
- !out->WriteU16(os2->width_class) ||
- !out->WriteU16(os2->type) ||
- !out->WriteS16(os2->subscript_x_size) ||
- !out->WriteS16(os2->subscript_y_size) ||
- !out->WriteS16(os2->subscript_x_offset) ||
- !out->WriteS16(os2->subscript_y_offset) ||
- !out->WriteS16(os2->superscript_x_size) ||
- !out->WriteS16(os2->superscript_y_size) ||
- !out->WriteS16(os2->superscript_x_offset) ||
- !out->WriteS16(os2->superscript_y_offset) ||
- !out->WriteS16(os2->strikeout_size) ||
- !out->WriteS16(os2->strikeout_position) ||
- !out->WriteS16(os2->family_class)) {
- return OTS_FAILURE_MSG("Failed to write basic OS2 information");
+bool OpenTypeOS2::Serialize(OTSStream *out) {
+ if (!out->WriteU16(this->table.version) ||
+ !out->WriteS16(this->table.avg_char_width) ||
+ !out->WriteU16(this->table.weight_class) ||
+ !out->WriteU16(this->table.width_class) ||
+ !out->WriteU16(this->table.type) ||
+ !out->WriteS16(this->table.subscript_x_size) ||
+ !out->WriteS16(this->table.subscript_y_size) ||
+ !out->WriteS16(this->table.subscript_x_offset) ||
+ !out->WriteS16(this->table.subscript_y_offset) ||
+ !out->WriteS16(this->table.superscript_x_size) ||
+ !out->WriteS16(this->table.superscript_y_size) ||
+ !out->WriteS16(this->table.superscript_x_offset) ||
+ !out->WriteS16(this->table.superscript_y_offset) ||
+ !out->WriteS16(this->table.strikeout_size) ||
+ !out->WriteS16(this->table.strikeout_position) ||
+ !out->WriteS16(this->table.family_class)) {
+ return Error("Failed to write basic table data");
}
for (unsigned i = 0; i < 10; ++i) {
- if (!out->Write(&os2->panose[i], 1)) {
- return OTS_FAILURE_MSG("Failed to write os2 panose information");
+ if (!out->Write(&this->table.panose[i], 1)) {
+ return Error("Failed to write PANOSE data");
}
}
- if (!out->WriteU32(os2->unicode_range_1) ||
- !out->WriteU32(os2->unicode_range_2) ||
- !out->WriteU32(os2->unicode_range_3) ||
- !out->WriteU32(os2->unicode_range_4) ||
- !out->WriteU32(os2->vendor_id) ||
- !out->WriteU16(os2->selection) ||
- !out->WriteU16(os2->first_char_index) ||
- !out->WriteU16(os2->last_char_index) ||
- !out->WriteS16(os2->typo_ascender) ||
- !out->WriteS16(os2->typo_descender) ||
- !out->WriteS16(os2->typo_linegap) ||
- !out->WriteU16(os2->win_ascent) ||
- !out->WriteU16(os2->win_descent)) {
- return OTS_FAILURE_MSG("Failed to write version 1-specific fields");
+ if (!out->WriteU32(this->table.unicode_range_1) ||
+ !out->WriteU32(this->table.unicode_range_2) ||
+ !out->WriteU32(this->table.unicode_range_3) ||
+ !out->WriteU32(this->table.unicode_range_4) ||
+ !out->WriteU32(this->table.vendor_id) ||
+ !out->WriteU16(this->table.selection) ||
+ !out->WriteU16(this->table.first_char_index) ||
+ !out->WriteU16(this->table.last_char_index) ||
+ !out->WriteS16(this->table.typo_ascender) ||
+ !out->WriteS16(this->table.typo_descender) ||
+ !out->WriteS16(this->table.typo_linegap) ||
+ !out->WriteU16(this->table.win_ascent) ||
+ !out->WriteU16(this->table.win_descent)) {
+ return Error("Failed to write version 1-specific fields");
}
- if (os2->version < 1) {
+ if (this->table.version < 1) {
return true;
}
- if (!out->WriteU32(os2->code_page_range_1) ||
- !out->WriteU32(os2->code_page_range_2)) {
- return OTS_FAILURE_MSG("Failed to write codepage ranges");
+ if (!out->WriteU32(this->table.code_page_range_1) ||
+ !out->WriteU32(this->table.code_page_range_2)) {
+ return Error("Failed to write codepage ranges");
}
- if (os2->version < 2) {
+ if (this->table.version < 2) {
return true;
}
- if (!out->WriteS16(os2->x_height) ||
- !out->WriteS16(os2->cap_height) ||
- !out->WriteU16(os2->default_char) ||
- !out->WriteU16(os2->break_char) ||
- !out->WriteU16(os2->max_context)) {
- return OTS_FAILURE_MSG("Failed to write version 2-specific fields");
+ if (!out->WriteS16(this->table.x_height) ||
+ !out->WriteS16(this->table.cap_height) ||
+ !out->WriteU16(this->table.default_char) ||
+ !out->WriteU16(this->table.break_char) ||
+ !out->WriteU16(this->table.max_context)) {
+ return Error("Failed to write version 2-specific fields");
}
- if (os2->version < 5) {
+ if (this->table.version < 5) {
return true;
}
- if (!out->WriteU16(os2->lower_optical_pointsize) ||
- !out->WriteU16(os2->upper_optical_pointsize)) {
- return OTS_FAILURE_MSG("Failed to write version 5-specific fields");
+ if (!out->WriteU16(this->table.lower_optical_pointsize) ||
+ !out->WriteU16(this->table.upper_optical_pointsize)) {
+ return Error("Failed to write version 5-specific fields");
}
return true;
}
-void ots_os2_reuse(Font *font, Font *other) {
- font->os2 = other->os2;
- font->os2_reused = true;
-}
-
-void ots_os2_free(Font *font) {
- delete font->os2;
-}
-
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/os2.h b/gfx/ots/src/os2.h
index 01511c5dc..b3f1bad9b 100644
--- a/gfx/ots/src/os2.h
+++ b/gfx/ots/src/os2.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,7 +9,7 @@
namespace ots {
-struct OpenTypeOS2 {
+struct OS2Data {
uint16_t version;
int16_t avg_char_width;
uint16_t weight_class;
@@ -51,6 +51,17 @@ struct OpenTypeOS2 {
uint16_t upper_optical_pointsize;
};
+class OpenTypeOS2 : public Table {
+ public:
+ explicit OpenTypeOS2(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
+ OS2Data table;
+};
+
} // namespace ots
#endif // OTS_OS2_H_
diff --git a/gfx/ots/src/ots.cc b/gfx/ots/src/ots.cc
index 15794475a..38d97a9ed 100644
--- a/gfx/ots/src/ots.cc
+++ b/gfx/ots/src/ots.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,25 +14,75 @@
#include <map>
#include <vector>
-#include "woff2_dec.h"
+#include <woff2/decode.h>
// The OpenType Font File
-// http://www.microsoft.com/typography/otspec/cmap.htm
+// http://www.microsoft.com/typography/otspec/otff.htm
+
+#include "avar.h"
+#include "cff.h"
+#include "cmap.h"
+#include "cvar.h"
+#include "cvt.h"
+#include "fpgm.h"
+#include "fvar.h"
+#include "gasp.h"
+#include "gdef.h"
+#include "glyf.h"
+#include "gpos.h"
+#include "gsub.h"
+#include "gvar.h"
+#include "hdmx.h"
+#include "head.h"
+#include "hhea.h"
+#include "hmtx.h"
+#include "hvar.h"
+#include "kern.h"
+#include "loca.h"
+#include "ltsh.h"
+#include "math_.h"
+#include "maxp.h"
+#include "mvar.h"
+#include "name.h"
+#include "os2.h"
+#include "ots.h"
+#include "post.h"
+#include "prep.h"
+#include "stat.h"
+#include "vdmx.h"
+#include "vhea.h"
+#include "vmtx.h"
+#include "vorg.h"
+#include "vvar.h"
+
+// Graphite tables
+#ifdef OTS_GRAPHITE
+#include "feat.h"
+#include "glat.h"
+#include "gloc.h"
+#include "sile.h"
+#include "silf.h"
+#include "sill.h"
+#endif
-namespace {
+namespace ots {
-// Generate a message with or without a table tag, when 'header' is the OpenTypeFile pointer
-#define OTS_FAILURE_MSG_TAG(msg_,tag_) OTS_FAILURE_MSG_TAG_(header, msg_, tag_)
-#define OTS_FAILURE_MSG_HDR(msg_) OTS_FAILURE_MSG_(header, msg_)
-#define OTS_WARNING_MSG_HDR(msg_) OTS_WARNING_MSG_(header, msg_)
+struct Arena {
+ public:
+ ~Arena() {
+ for (auto& hunk : hunks_) {
+ delete[] hunk;
+ }
+ }
+ uint8_t* Allocate(size_t length) {
+ uint8_t* p = new uint8_t[length];
+ hunks_.push_back(p);
+ return p;
+ }
-struct OpenTypeTable {
- uint32_t tag;
- uint32_t chksum;
- uint32_t offset;
- uint32_t length;
- uint32_t uncompressed_length;
+ private:
+ std::vector<uint8_t*> hunks_;
};
bool CheckTag(uint32_t tag_value) {
@@ -46,99 +96,83 @@ bool CheckTag(uint32_t tag_value) {
return true;
}
-struct Arena {
- public:
- ~Arena() {
- for (std::vector<uint8_t*>::iterator
- i = hunks_.begin(); i != hunks_.end(); ++i) {
- delete[] *i;
- }
- }
+}; // namespace ots
- uint8_t* Allocate(size_t length) {
- uint8_t* p = new uint8_t[length];
- hunks_.push_back(p);
- return p;
- }
+namespace {
+
+#define OTS_MSG_TAG_(level,otf_,msg_,tag_) \
+ (OTS_MESSAGE_(level,otf_,"%c%c%c%c: %s", OTS_UNTAG(tag_), msg_), false)
+
+// Generate a message with or without a table tag, when 'header' is the FontFile pointer
+#define OTS_FAILURE_MSG_TAG(msg_,tag_) OTS_MSG_TAG_(0, header, msg_, tag_)
+#define OTS_FAILURE_MSG_HDR(...) OTS_FAILURE_MSG_(header, __VA_ARGS__)
+#define OTS_WARNING_MSG_HDR(...) OTS_WARNING_MSG_(header, __VA_ARGS__)
- private:
- std::vector<uint8_t*> hunks_;
-};
const struct {
uint32_t tag;
- bool (*parse)(ots::Font *font, const uint8_t *data, size_t length);
- bool (*serialise)(ots::OTSStream *out, ots::Font *font);
- bool (*should_serialise)(ots::Font *font);
- void (*reuse)(ots::Font *font, ots::Font *other);
bool required;
-} table_parsers[] = {
- { OTS_TAG('m','a','x','p'), ots::ots_maxp_parse, ots::ots_maxp_serialise,
- ots::ots_maxp_should_serialise, ots::ots_maxp_reuse, true },
- { OTS_TAG('h','e','a','d'), ots::ots_head_parse, ots::ots_head_serialise,
- ots::ots_head_should_serialise, ots::ots_head_reuse, true },
- { OTS_TAG('O','S','/','2'), ots::ots_os2_parse, ots::ots_os2_serialise,
- ots::ots_os2_should_serialise, ots::ots_os2_reuse, true },
- { OTS_TAG('c','m','a','p'), ots::ots_cmap_parse, ots::ots_cmap_serialise,
- ots::ots_cmap_should_serialise, ots::ots_cmap_reuse, true },
- { OTS_TAG('h','h','e','a'), ots::ots_hhea_parse, ots::ots_hhea_serialise,
- ots::ots_hhea_should_serialise, ots::ots_hhea_reuse, true },
- { OTS_TAG('h','m','t','x'), ots::ots_hmtx_parse, ots::ots_hmtx_serialise,
- ots::ots_hmtx_should_serialise, ots::ots_hmtx_reuse, true },
- { OTS_TAG('n','a','m','e'), ots::ots_name_parse, ots::ots_name_serialise,
- ots::ots_name_should_serialise, ots::ots_name_reuse, true },
- { OTS_TAG('p','o','s','t'), ots::ots_post_parse, ots::ots_post_serialise,
- ots::ots_post_should_serialise, ots::ots_post_reuse, true },
- { OTS_TAG('l','o','c','a'), ots::ots_loca_parse, ots::ots_loca_serialise,
- ots::ots_loca_should_serialise, ots::ots_loca_reuse, false },
- { OTS_TAG('g','l','y','f'), ots::ots_glyf_parse, ots::ots_glyf_serialise,
- ots::ots_glyf_should_serialise, ots::ots_glyf_reuse, false },
- { OTS_TAG('C','F','F',' '), ots::ots_cff_parse, ots::ots_cff_serialise,
- ots::ots_cff_should_serialise, ots::ots_cff_reuse, false },
- { OTS_TAG('V','D','M','X'), ots::ots_vdmx_parse, ots::ots_vdmx_serialise,
- ots::ots_vdmx_should_serialise, ots::ots_vdmx_reuse, false },
- { OTS_TAG('h','d','m','x'), ots::ots_hdmx_parse, ots::ots_hdmx_serialise,
- ots::ots_hdmx_should_serialise, ots::ots_hdmx_reuse, false },
- { OTS_TAG('g','a','s','p'), ots::ots_gasp_parse, ots::ots_gasp_serialise,
- ots::ots_gasp_should_serialise, ots::ots_gasp_reuse, false },
- { OTS_TAG('c','v','t',' '), ots::ots_cvt_parse, ots::ots_cvt_serialise,
- ots::ots_cvt_should_serialise, ots::ots_cvt_reuse, false },
- { OTS_TAG('f','p','g','m'), ots::ots_fpgm_parse, ots::ots_fpgm_serialise,
- ots::ots_fpgm_should_serialise, ots::ots_fpgm_reuse, false },
- { OTS_TAG('p','r','e','p'), ots::ots_prep_parse, ots::ots_prep_serialise,
- ots::ots_prep_should_serialise, ots::ots_prep_reuse, false },
- { OTS_TAG('L','T','S','H'), ots::ots_ltsh_parse, ots::ots_ltsh_serialise,
- ots::ots_ltsh_should_serialise, ots::ots_ltsh_reuse, false },
- { OTS_TAG('V','O','R','G'), ots::ots_vorg_parse, ots::ots_vorg_serialise,
- ots::ots_vorg_should_serialise, ots::ots_vorg_reuse, false },
- { OTS_TAG('k','e','r','n'), ots::ots_kern_parse, ots::ots_kern_serialise,
- ots::ots_kern_should_serialise, ots::ots_kern_reuse, false },
+} supported_tables[] = {
+ { OTS_TAG_MAXP, true },
+ { OTS_TAG_HEAD, true },
+ { OTS_TAG_OS2, true },
+ { OTS_TAG_CMAP, true },
+ { OTS_TAG_HHEA, true },
+ { OTS_TAG_HMTX, true },
+ { OTS_TAG_NAME, true },
+ { OTS_TAG_POST, true },
+ { OTS_TAG_LOCA, false },
+ { OTS_TAG_GLYF, false },
+ { OTS_TAG_CFF, false },
+ { OTS_TAG_VDMX, false },
+ { OTS_TAG_HDMX, false },
+ { OTS_TAG_GASP, false },
+ { OTS_TAG_CVT, false },
+ { OTS_TAG_FPGM, false },
+ { OTS_TAG_PREP, false },
+ { OTS_TAG_LTSH, false },
+ { OTS_TAG_VORG, false },
+ { OTS_TAG_KERN, false },
+ // We need to parse fvar table before other tables that may need to know
+ // the number of variation axes (if any)
+ { OTS_TAG_FVAR, false },
+ { OTS_TAG_AVAR, false },
+ { OTS_TAG_CVAR, false },
+ { OTS_TAG_GVAR, false },
+ { OTS_TAG_HVAR, false },
+ { OTS_TAG_MVAR, false },
+ { OTS_TAG_STAT, false },
+ { OTS_TAG_VVAR, false },
+ { OTS_TAG_CFF2, false },
// We need to parse GDEF table in advance of parsing GSUB/GPOS tables
// because they could refer GDEF table.
- { OTS_TAG('G','D','E','F'), ots::ots_gdef_parse, ots::ots_gdef_serialise,
- ots::ots_gdef_should_serialise, ots::ots_gdef_reuse, false },
- { OTS_TAG('G','P','O','S'), ots::ots_gpos_parse, ots::ots_gpos_serialise,
- ots::ots_gpos_should_serialise, ots::ots_gpos_reuse, false },
- { OTS_TAG('G','S','U','B'), ots::ots_gsub_parse, ots::ots_gsub_serialise,
- ots::ots_gsub_should_serialise, ots::ots_gsub_reuse, false },
- { OTS_TAG('v','h','e','a'), ots::ots_vhea_parse, ots::ots_vhea_serialise,
- ots::ots_vhea_should_serialise, ots::ots_vhea_reuse, false },
- { OTS_TAG('v','m','t','x'), ots::ots_vmtx_parse, ots::ots_vmtx_serialise,
- ots::ots_vmtx_should_serialise, ots::ots_vmtx_reuse, false },
- { OTS_TAG('M','A','T','H'), ots::ots_math_parse, ots::ots_math_serialise,
- ots::ots_math_should_serialise, ots::ots_math_reuse, false },
- { 0, NULL, NULL, NULL, NULL, false },
+ { OTS_TAG_GDEF, false },
+ { OTS_TAG_GPOS, false },
+ { OTS_TAG_GSUB, false },
+ { OTS_TAG_VHEA, false },
+ { OTS_TAG_VMTX, false },
+ { OTS_TAG_MATH, false },
+ // Graphite tables
+#ifdef OTS_GRAPHITE
+ { OTS_TAG_GLOC, false },
+ { OTS_TAG_GLAT, false },
+ { OTS_TAG_FEAT, false },
+ { OTS_TAG_SILF, false },
+ { OTS_TAG_SILE, false },
+ { OTS_TAG_SILL, false },
+#endif
+ { 0, false },
};
-bool ProcessGeneric(ots::OpenTypeFile *header,
+bool ProcessGeneric(ots::FontFile *header,
ots::Font *font,
uint32_t signature,
ots::OTSStream *output,
const uint8_t *data, size_t length,
- const std::vector<OpenTypeTable>& tables,
+ const std::vector<ots::TableEntry>& tables,
ots::Buffer& file);
-bool ProcessTTF(ots::OpenTypeFile *header,
+bool ProcessTTF(ots::FontFile *header,
ots::Font *font,
ots::OTSStream *output, const uint8_t *data, size_t length,
uint32_t offset = 0) {
@@ -202,10 +236,10 @@ bool ProcessTTF(ots::OpenTypeFile *header,
}
// Next up is the list of tables.
- std::vector<OpenTypeTable> tables;
+ std::vector<ots::TableEntry> tables;
for (unsigned i = 0; i < font->num_tables; ++i) {
- OpenTypeTable table;
+ ots::TableEntry table;
if (!file.ReadU32(&table.tag) ||
!file.ReadU32(&table.chksum) ||
!file.ReadU32(&table.offset) ||
@@ -221,7 +255,7 @@ bool ProcessTTF(ots::OpenTypeFile *header,
tables, file);
}
-bool ProcessTTC(ots::OpenTypeFile *header,
+bool ProcessTTC(ots::FontFile *header,
ots::OTSStream *output,
const uint8_t *data,
size_t length,
@@ -308,7 +342,7 @@ bool ProcessTTC(ots::OpenTypeFile *header,
}
}
-bool ProcessWOFF(ots::OpenTypeFile *header,
+bool ProcessWOFF(ots::FontFile *header,
ots::Font *font,
ots::OTSStream *output, const uint8_t *data, size_t length) {
ots::Buffer file(data, length);
@@ -388,14 +422,14 @@ bool ProcessWOFF(ots::OpenTypeFile *header,
}
// Next up is the list of tables.
- std::vector<OpenTypeTable> tables;
+ std::vector<ots::TableEntry> tables;
uint32_t first_index = 0;
uint32_t last_index = 0;
// Size of sfnt header plus size of table records.
uint64_t total_sfnt_size = 12 + 16 * font->num_tables;
for (unsigned i = 0; i < font->num_tables; ++i) {
- OpenTypeTable table;
+ ots::TableEntry table;
if (!file.ReadU32(&table.tag) ||
!file.ReadU32(&table.offset) ||
!file.ReadU32(&table.length) ||
@@ -463,13 +497,17 @@ bool ProcessWOFF(ots::OpenTypeFile *header,
return ProcessGeneric(header, font, woff_tag, output, data, length, tables, file);
}
-bool ProcessWOFF2(ots::OpenTypeFile *header,
+bool ProcessWOFF2(ots::FontFile *header,
ots::OTSStream *output,
const uint8_t *data,
size_t length,
uint32_t index) {
size_t decompressed_size = woff2::ComputeWOFF2FinalSize(data, length);
+ if (decompressed_size < length) {
+ return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 is less than compressed size");
+ }
+
if (decompressed_size == 0) {
return OTS_FAILURE_MSG_HDR("Size of decompressed WOFF 2.0 is set to 0");
}
@@ -493,16 +531,16 @@ bool ProcessWOFF2(ots::OpenTypeFile *header,
}
}
-ots::TableAction GetTableAction(ots::OpenTypeFile *header, uint32_t tag) {
+ots::TableAction GetTableAction(const ots::FontFile *header, uint32_t tag) {
ots::TableAction action = header->context->GetTableAction(tag);
if (action == ots::TABLE_ACTION_DEFAULT) {
action = ots::TABLE_ACTION_DROP;
for (unsigned i = 0; ; ++i) {
- if (table_parsers[i].parse == NULL) break;
+ if (supported_tables[i].tag == 0) break;
- if (table_parsers[i].tag == tag) {
+ if (supported_tables[i].tag == tag) {
action = ots::TABLE_ACTION_SANITIZE;
break;
}
@@ -514,14 +552,14 @@ ots::TableAction GetTableAction(ots::OpenTypeFile *header, uint32_t tag) {
}
bool GetTableData(const uint8_t *data,
- const OpenTypeTable& table,
- Arena *arena,
+ const ots::TableEntry& table,
+ ots::Arena &arena,
size_t *table_length,
const uint8_t **table_data) {
if (table.uncompressed_length != table.length) {
// Compressed table. Need to uncompress into memory first.
*table_length = table.uncompressed_length;
- *table_data = (*arena).Allocate(*table_length);
+ *table_data = arena.Allocate(*table_length);
uLongf dest_len = *table_length;
int r = uncompress((Bytef*) *table_data, &dest_len,
data + table.offset, table.length);
@@ -537,12 +575,12 @@ bool GetTableData(const uint8_t *data,
return true;
}
-bool ProcessGeneric(ots::OpenTypeFile *header,
+bool ProcessGeneric(ots::FontFile *header,
ots::Font *font,
uint32_t signature,
ots::OTSStream *output,
const uint8_t *data, size_t length,
- const std::vector<OpenTypeTable>& tables,
+ const std::vector<ots::TableEntry>& tables,
ots::Buffer& file) {
const size_t data_offset = file.offset();
@@ -560,8 +598,8 @@ bool ProcessGeneric(ots::OpenTypeFile *header,
}
// all tag names must be built from printable ASCII characters
- if (!CheckTag(tables[i].tag)) {
- return OTS_FAILURE_MSG_TAG("invalid table tag", tables[i].tag);
+ if (!ots::CheckTag(tables[i].tag)) {
+ OTS_WARNING_MSG_HDR("Invalid table tag: 0x%X", tables[i].tag);
}
// tables must be 4-byte aligned
@@ -616,11 +654,6 @@ bool ProcessGeneric(ots::OpenTypeFile *header,
return OTS_FAILURE_MSG_HDR("uncompressed sum exceeds 30MB");
}
- std::map<uint32_t, OpenTypeTable> table_map;
- for (unsigned i = 0; i < font->num_tables; ++i) {
- table_map[tables[i].tag] = tables[i];
- }
-
// check that the tables are not overlapping.
std::vector<std::pair<uint32_t, uint8_t> > overlap_checker;
for (unsigned i = 0; i < font->num_tables; ++i) {
@@ -639,80 +672,66 @@ bool ProcessGeneric(ots::OpenTypeFile *header,
}
}
- Arena arena;
+ std::map<uint32_t, ots::TableEntry> table_map;
+ for (unsigned i = 0; i < font->num_tables; ++i) {
+ table_map[tables[i].tag] = tables[i];
+ }
+ ots::Arena arena;
+ // Parse known tables first as we need to parse them in specific order.
for (unsigned i = 0; ; ++i) {
- if (table_parsers[i].parse == NULL) break;
-
- uint32_t tag = table_parsers[i].tag;
- const std::map<uint32_t, OpenTypeTable>::const_iterator it = table_map.find(tag);
+ if (supported_tables[i].tag == 0) break;
- ots::TableAction action = GetTableAction(header, tag);
- if (it == table_map.end()) {
- if (table_parsers[i].required && action == ots::TABLE_ACTION_SANITIZE) {
- return OTS_FAILURE_MSG_TAG("missing required table", table_parsers[i].tag);
+ uint32_t tag = supported_tables[i].tag;
+ const auto &it = table_map.find(tag);
+ if (it == table_map.cend()) {
+ if (supported_tables[i].required) {
+ return OTS_FAILURE_MSG_TAG("missing required table", tag);
}
- continue;
- }
-
- uint32_t input_offset = it->second.offset;
- const ots::TableMap::const_iterator ot = header->tables.find(input_offset);
- if (ot == header->tables.end()) {
- const uint8_t* table_data;
- size_t table_length;
-
- if (!GetTableData(data, it->second, &arena, &table_length, &table_data)) {
- return OTS_FAILURE_MSG_TAG("uncompress failed", table_parsers[i].tag);
+ } else {
+ if (!font->ParseTable(it->second, data, arena)) {
+ return OTS_FAILURE_MSG_TAG("Failed to parse table", tag);
}
+ }
+ }
- if (action == ots::TABLE_ACTION_SANITIZE &&
- !table_parsers[i].parse(font, table_data, table_length)) {
- return OTS_FAILURE();
+ // Then parse any tables left.
+ for (const auto &table_entry : tables) {
+ if (!font->GetTable(table_entry.tag)) {
+ if (!font->ParseTable(table_entry, data, arena)) {
+ return OTS_FAILURE_MSG_TAG("Failed to parse table", table_entry.tag);
}
- } else if (action == ots::TABLE_ACTION_SANITIZE) {
- table_parsers[i].reuse(font, ot->second.first);
}
}
- if (font->cff) {
+ if (font->GetTable(OTS_TAG_CFF) || font->GetTable(OTS_TAG_CFF2)) {
// font with PostScript glyph
if (font->version != OTS_TAG('O','T','T','O')) {
return OTS_FAILURE_MSG_HDR("wrong font version for PostScript glyph data");
}
- if (font->glyf || font->loca) {
+ if (font->GetTable(OTS_TAG_GLYF) || font->GetTable(OTS_TAG_LOCA)) {
// mixing outline formats is not recommended
return OTS_FAILURE_MSG_HDR("font contains both PS and TT glyphs");
}
} else {
- if (!font->glyf || !font->loca) {
+ if (!font->GetTable(OTS_TAG_GLYF) || !font->GetTable(OTS_TAG_LOCA)) {
// No TrueType glyph found.
-#define PASSTHRU_TABLE(tag_) (table_map.find(tag_) != table_map.end() && \
- GetTableAction(header, tag_) == ots::TABLE_ACTION_PASSTHRU)
- // We don't sanitise bitmap table, but don't reject bitmap-only fonts if
- // we keep the tables.
- if (!PASSTHRU_TABLE(OTS_TAG('C','B','D','T')) ||
- !PASSTHRU_TABLE(OTS_TAG('C','B','L','C'))) {
+ //
+ // We don't sanitize bitmap tables, but don’t reject bitmap-only fonts if
+ // we are asked to pass them thru.
+ // Also don’t reject if we are asked to pass glyf/loca thru.
+ if (!font->GetTable(OTS_TAG('C','B','D','T')) &&
+ !font->GetTable(OTS_TAG('C','B','L','C'))) {
return OTS_FAILURE_MSG_HDR("no supported glyph shapes table(s) present");
}
-#undef PASSTHRU_TABLE
}
}
uint16_t num_output_tables = 0;
- for (std::map<uint32_t, OpenTypeTable>::const_iterator it = table_map.begin();
- it != table_map.end(); ++it) {
- ots::TableAction action = GetTableAction(header, it->first);
- if (action == ots::TABLE_ACTION_PASSTHRU) {
+ for (const auto &it : table_map) {
+ ots::Table *table = font->GetTable(it.first);
+ if (table != NULL && table->ShouldSerialize())
num_output_tables++;
- } else {
- for (unsigned i = 0; table_parsers[i].parse != NULL; ++i) {
- if (table_parsers[i].tag == it->first &&
- table_parsers[i].should_serialise(font)) {
- num_output_tables++;
- break;
- }
- }
- }
}
uint16_t max_pow2 = 0;
@@ -738,85 +757,49 @@ bool ProcessGeneric(ots::OpenTypeFile *header,
return OTS_FAILURE_MSG_HDR("error writing output");
}
- std::vector<ots::OutputTable> out_tables;
+ std::vector<ots::TableEntry> out_tables;
size_t head_table_offset = 0;
- for (std::map<uint32_t, OpenTypeTable>::const_iterator it = table_map.begin();
- it != table_map.end(); ++it) {
- uint32_t input_offset = it->second.offset;
- const ots::TableMap::const_iterator ot = header->tables.find(input_offset);
- if (ot != header->tables.end()) {
- ots::OutputTable out = ot->second.second;
+ for (const auto &it : table_map) {
+ uint32_t input_offset = it.second.offset;
+ const auto &ot = header->table_entries.find(input_offset);
+ if (ot != header->table_entries.end()) {
+ ots::TableEntry out = ot->second;
if (out.tag == OTS_TAG('h','e','a','d')) {
head_table_offset = out.offset;
}
out_tables.push_back(out);
} else {
- ots::OutputTable out;
- out.tag = it->first;
+ ots::TableEntry out;
+ out.tag = it.first;
out.offset = output->Tell();
if (out.tag == OTS_TAG('h','e','a','d')) {
head_table_offset = out.offset;
}
- ots::TableAction action = GetTableAction(header, it->first);
- if (action == ots::TABLE_ACTION_PASSTHRU) {
+ ots::Table *table = font->GetTable(out.tag);
+ if (table != NULL && table->ShouldSerialize()) {
output->ResetChecksum();
- const uint8_t* table_data;
- size_t table_length;
-
- if (!GetTableData(data, it->second, &arena, &table_length, &table_data)) {
- return OTS_FAILURE_MSG_HDR("Failed to uncompress table");
- }
-
- if (!output->Write(table_data, table_length)) {
- return OTS_FAILURE_MSG_HDR("Failed to serialize table");
+ if (!table->Serialize(output)) {
+ return OTS_FAILURE_MSG_TAG("Failed to serialize table", out.tag);
}
const size_t end_offset = output->Tell();
if (end_offset <= out.offset) {
// paranoid check. |end_offset| is supposed to be greater than the offset,
// as long as the Tell() interface is implemented correctly.
- return OTS_FAILURE_MSG_HDR("error writing output");
+ return OTS_FAILURE_MSG_TAG("Table is empty or have -ve size", out.tag);
}
out.length = end_offset - out.offset;
// align tables to four bytes
if (!output->Pad((4 - (end_offset & 3)) % 4)) {
- return OTS_FAILURE_MSG_HDR("error writing output");
+ return OTS_FAILURE_MSG_TAG("Failed to pad table to 4 bytes", out.tag);
}
out.chksum = output->chksum();
out_tables.push_back(out);
- header->tables[input_offset] = std::make_pair(font, out);
- } else {
- for (unsigned i = 0; table_parsers[i].parse != NULL; ++i) {
- if (table_parsers[i].tag == it->first &&
- table_parsers[i].should_serialise(font)) {
- output->ResetChecksum();
- if (!table_parsers[i].serialise(output, font)) {
- return OTS_FAILURE_MSG_TAG("failed to serialize table", table_parsers[i].tag);
- }
-
- const size_t end_offset = output->Tell();
- if (end_offset <= out.offset) {
- // paranoid check. |end_offset| is supposed to be greater than the offset,
- // as long as the Tell() interface is implemented correctly.
- return OTS_FAILURE_MSG_HDR("error writing output");
- }
- out.length = end_offset - out.offset;
-
- // align tables to four bytes
- if (!output->Pad((4 - (end_offset & 3)) % 4)) {
- return OTS_FAILURE_MSG_HDR("error writing output");
- }
- out.chksum = output->chksum();
- out_tables.push_back(out);
- header->tables[input_offset] = std::make_pair(font, out);
-
- break;
- }
- }
+ header->table_entries[input_offset] = out;
}
}
}
@@ -869,6 +852,225 @@ bool ProcessGeneric(ots::OpenTypeFile *header,
namespace ots {
+FontFile::~FontFile() {
+ for (const auto& it : tables) {
+ delete it.second;
+ }
+ tables.clear();
+}
+
+bool Font::ParseTable(const TableEntry& table_entry, const uint8_t* data,
+ Arena &arena) {
+ uint32_t tag = table_entry.tag;
+ TableAction action = GetTableAction(file, tag);
+ if (action == TABLE_ACTION_DROP) {
+ return true;
+ }
+
+ const auto &it = file->tables.find(table_entry);
+ if (it != file->tables.end()) {
+ m_tables[tag] = it->second;
+ return true;
+ }
+
+ Table *table = NULL;
+ bool ret = false;
+
+ if (action == TABLE_ACTION_PASSTHRU) {
+ table = new TablePassthru(this, tag);
+ } else {
+ switch (tag) {
+ case OTS_TAG_AVAR: table = new OpenTypeAVAR(this, tag); break;
+ case OTS_TAG_CFF: table = new OpenTypeCFF(this, tag); break;
+ case OTS_TAG_CFF2: table = new OpenTypeCFF2(this, tag); break;
+ case OTS_TAG_CMAP: table = new OpenTypeCMAP(this, tag); break;
+ case OTS_TAG_CVAR: table = new OpenTypeCVAR(this, tag); break;
+ case OTS_TAG_CVT: table = new OpenTypeCVT(this, tag); break;
+ case OTS_TAG_FPGM: table = new OpenTypeFPGM(this, tag); break;
+ case OTS_TAG_FVAR: table = new OpenTypeFVAR(this, tag); break;
+ case OTS_TAG_GASP: table = new OpenTypeGASP(this, tag); break;
+ case OTS_TAG_GDEF: table = new OpenTypeGDEF(this, tag); break;
+ case OTS_TAG_GLYF: table = new OpenTypeGLYF(this, tag); break;
+ case OTS_TAG_GPOS: table = new OpenTypeGPOS(this, tag); break;
+ case OTS_TAG_GSUB: table = new OpenTypeGSUB(this, tag); break;
+ case OTS_TAG_GVAR: table = new OpenTypeGVAR(this, tag); break;
+ case OTS_TAG_HDMX: table = new OpenTypeHDMX(this, tag); break;
+ case OTS_TAG_HEAD: table = new OpenTypeHEAD(this, tag); break;
+ case OTS_TAG_HHEA: table = new OpenTypeHHEA(this, tag); break;
+ case OTS_TAG_HMTX: table = new OpenTypeHMTX(this, tag); break;
+ case OTS_TAG_HVAR: table = new OpenTypeHVAR(this, tag); break;
+ case OTS_TAG_KERN: table = new OpenTypeKERN(this, tag); break;
+ case OTS_TAG_LOCA: table = new OpenTypeLOCA(this, tag); break;
+ case OTS_TAG_LTSH: table = new OpenTypeLTSH(this, tag); break;
+ case OTS_TAG_MATH: table = new OpenTypeMATH(this, tag); break;
+ case OTS_TAG_MAXP: table = new OpenTypeMAXP(this, tag); break;
+ case OTS_TAG_MVAR: table = new OpenTypeMVAR(this, tag); break;
+ case OTS_TAG_NAME: table = new OpenTypeNAME(this, tag); break;
+ case OTS_TAG_OS2: table = new OpenTypeOS2(this, tag); break;
+ case OTS_TAG_POST: table = new OpenTypePOST(this, tag); break;
+ case OTS_TAG_PREP: table = new OpenTypePREP(this, tag); break;
+ case OTS_TAG_STAT: table = new OpenTypeSTAT(this, tag); break;
+ case OTS_TAG_VDMX: table = new OpenTypeVDMX(this, tag); break;
+ case OTS_TAG_VHEA: table = new OpenTypeVHEA(this, tag); break;
+ case OTS_TAG_VMTX: table = new OpenTypeVMTX(this, tag); break;
+ case OTS_TAG_VORG: table = new OpenTypeVORG(this, tag); break;
+ case OTS_TAG_VVAR: table = new OpenTypeVVAR(this, tag); break;
+ // Graphite tables
+#ifdef OTS_GRAPHITE
+ case OTS_TAG_FEAT: table = new OpenTypeFEAT(this, tag); break;
+ case OTS_TAG_GLAT: table = new OpenTypeGLAT(this, tag); break;
+ case OTS_TAG_GLOC: table = new OpenTypeGLOC(this, tag); break;
+ case OTS_TAG_SILE: table = new OpenTypeSILE(this, tag); break;
+ case OTS_TAG_SILF: table = new OpenTypeSILF(this, tag); break;
+ case OTS_TAG_SILL: table = new OpenTypeSILL(this, tag); break;
+#endif
+ default: break;
+ }
+ }
+
+ if (table) {
+ const uint8_t* table_data;
+ size_t table_length;
+
+ ret = GetTableData(data, table_entry, arena, &table_length, &table_data);
+ if (ret) {
+ // FIXME: Parsing some tables will fail if the table is not added to
+ // m_tables first.
+ m_tables[tag] = table;
+ ret = table->Parse(table_data, table_length);
+ if (ret)
+ file->tables[table_entry] = table;
+ else
+ m_tables.erase(tag);
+ }
+ }
+
+ if (!ret)
+ delete table;
+
+ return ret;
+}
+
+Table* Font::GetTable(uint32_t tag) const {
+ const auto &it = m_tables.find(tag);
+ if (it != m_tables.end())
+ return it->second;
+ return NULL;
+}
+
+Table* Font::GetTypedTable(uint32_t tag) const {
+ Table* t = GetTable(tag);
+ if (t && t->Type() == tag)
+ return t;
+ return NULL;
+}
+
+void Font::DropGraphite() {
+ file->context->Message(0, "Dropping all Graphite tables");
+ for (const std::pair<uint32_t, Table*> entry : m_tables) {
+ if (entry.first == OTS_TAG_FEAT ||
+ entry.first == OTS_TAG_GLAT ||
+ entry.first == OTS_TAG_GLOC ||
+ entry.first == OTS_TAG_SILE ||
+ entry.first == OTS_TAG_SILF ||
+ entry.first == OTS_TAG_SILL) {
+ entry.second->Drop("Discarding Graphite table");
+ }
+ }
+ dropped_graphite = true;
+}
+
+void Font::DropVariations() {
+ file->context->Message(0, "Dropping all Variation tables");
+ for (const std::pair<uint32_t, Table*> entry : m_tables) {
+ if (entry.first == OTS_TAG_AVAR ||
+ entry.first == OTS_TAG_CVAR ||
+ entry.first == OTS_TAG_FVAR ||
+ entry.first == OTS_TAG_GVAR ||
+ entry.first == OTS_TAG_HVAR ||
+ entry.first == OTS_TAG_MVAR ||
+ entry.first == OTS_TAG_STAT ||
+ entry.first == OTS_TAG_VVAR) {
+ entry.second->Drop("Discarding Variations table");
+ }
+ }
+ dropped_variations = true;
+}
+
+bool Table::ShouldSerialize() {
+ return m_shouldSerialize;
+}
+
+void Table::Message(int level, const char *format, va_list va) {
+ char msg[206] = { OTS_UNTAG(m_tag), ':', ' ' };
+ std::vsnprintf(msg + 6, 200, format, va);
+ m_font->file->context->Message(level, msg);
+}
+
+bool Table::Error(const char *format, ...) {
+ va_list va;
+ va_start(va, format);
+ Message(0, format, va);
+ va_end(va);
+
+ return false;
+}
+
+bool Table::Warning(const char *format, ...) {
+ va_list va;
+ va_start(va, format);
+ Message(1, format, va);
+ va_end(va);
+
+ return true;
+}
+
+bool Table::Drop(const char *format, ...) {
+ m_shouldSerialize = false;
+
+ va_list va;
+ va_start(va, format);
+ Message(0, format, va);
+ m_font->file->context->Message(0, "Table discarded");
+ va_end(va);
+
+ return true;
+}
+
+bool Table::DropGraphite(const char *format, ...) {
+ va_list va;
+ va_start(va, format);
+ Message(0, format, va);
+ va_end(va);
+
+ m_font->DropGraphite();
+ return true;
+}
+
+bool Table::DropVariations(const char *format, ...) {
+ va_list va;
+ va_start(va, format);
+ Message(0, format, va);
+ va_end(va);
+
+ m_font->DropVariations();
+ return true;
+}
+
+bool TablePassthru::Parse(const uint8_t *data, size_t length) {
+ m_data = data;
+ m_length = length;
+ return true;
+}
+
+bool TablePassthru::Serialize(OTSStream *out) {
+ if (!out->Write(m_data, m_length)) {
+ return Error("Failed to write table");
+ }
+
+ return true;
+}
+
bool IsValidVersionTag(uint32_t tag) {
return tag == 0x000010000 ||
// OpenType fonts with CFF data have 'OTTO' tag.
@@ -882,7 +1084,7 @@ bool OTSContext::Process(OTSStream *output,
const uint8_t *data,
size_t length,
uint32_t index) {
- OpenTypeFile header;
+ FontFile header;
Font font(&header);
header.context = this;
diff --git a/gfx/ots/src/ots.h b/gfx/ots/src/ots.h
index 2d13f8d6d..4d2be1689 100644
--- a/gfx/ots/src/ots.h
+++ b/gfx/ots/src/ots.h
@@ -1,10 +1,14 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef OTS_H_
#define OTS_H_
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stddef.h>
#include <cstdarg>
#include <cstddef>
@@ -54,13 +58,9 @@ namespace ots {
#define OTS_WARNING_MSG_(otf_,...) \
OTS_MESSAGE_(1,otf_,__VA_ARGS__)
-// Generate a message with an associated table tag
-#define OTS_FAILURE_MSG_TAG_(otf_,msg_,tag_) \
- (OTS_MESSAGE_(0,otf_,"%c%c%c%c: %s", OTS_UNTAG(tag_), msg_), false)
-
// Convenience macros for use in files that only handle a single table tag,
// defined as TABLE_NAME at the top of the file; the 'file' variable is
-// expected to be the current OpenTypeFile pointer.
+// expected to be the current FontFile pointer.
#define OTS_FAILURE_MSG(...) OTS_FAILURE_MSG_(font->file, TABLE_NAME ": " __VA_ARGS__)
#define OTS_WARNING(...) OTS_WARNING_MSG_(font->file, TABLE_NAME ": " __VA_ARGS__)
@@ -112,7 +112,7 @@ class Buffer {
return OTS_FAILURE();
}
std::memcpy(value, buffer_ + offset_, sizeof(uint16_t));
- *value = ntohs(*value);
+ *value = ots_ntohs(*value);
offset_ += 2;
return true;
}
@@ -137,7 +137,7 @@ class Buffer {
return OTS_FAILURE();
}
std::memcpy(value, buffer_ + offset_, sizeof(uint32_t));
- *value = ntohl(*value);
+ *value = ots_ntohl(*value);
offset_ += 4;
return true;
}
@@ -184,111 +184,175 @@ template<typename T> T Round2(T value) {
return (value + 1) & ~1;
}
+// Check that a tag consists entirely of printable ASCII characters
+bool CheckTag(uint32_t tag_value);
+
bool IsValidVersionTag(uint32_t tag);
-#define FOR_EACH_TABLE_TYPE \
- F(cff, CFF) \
- F(cmap, CMAP) \
- F(cvt, CVT) \
- F(fpgm, FPGM) \
- F(gasp, GASP) \
- F(gdef, GDEF) \
- F(glyf, GLYF) \
- F(gpos, GPOS) \
- F(gsub, GSUB) \
- F(hdmx, HDMX) \
- F(head, HEAD) \
- F(hhea, HHEA) \
- F(hmtx, HMTX) \
- F(kern, KERN) \
- F(loca, LOCA) \
- F(ltsh, LTSH) \
- F(math, MATH) \
- F(maxp, MAXP) \
- F(name, NAME) \
- F(os2, OS2) \
- F(post, POST) \
- F(prep, PREP) \
- F(vdmx, VDMX) \
- F(vorg, VORG) \
- F(vhea, VHEA) \
- F(vmtx, VMTX)
-
-#define F(name, capname) struct OpenType##capname;
-FOR_EACH_TABLE_TYPE
-#undef F
+#define OTS_TAG_CFF OTS_TAG('C','F','F',' ')
+#define OTS_TAG_CFF2 OTS_TAG('C','F','F','2')
+#define OTS_TAG_CMAP OTS_TAG('c','m','a','p')
+#define OTS_TAG_CVT OTS_TAG('c','v','t',' ')
+#define OTS_TAG_FEAT OTS_TAG('F','e','a','t')
+#define OTS_TAG_FPGM OTS_TAG('f','p','g','m')
+#define OTS_TAG_GASP OTS_TAG('g','a','s','p')
+#define OTS_TAG_GDEF OTS_TAG('G','D','E','F')
+#define OTS_TAG_GLAT OTS_TAG('G','l','a','t')
+#define OTS_TAG_GLOC OTS_TAG('G','l','o','c')
+#define OTS_TAG_GLYF OTS_TAG('g','l','y','f')
+#define OTS_TAG_GPOS OTS_TAG('G','P','O','S')
+#define OTS_TAG_GSUB OTS_TAG('G','S','U','B')
+#define OTS_TAG_HDMX OTS_TAG('h','d','m','x')
+#define OTS_TAG_HEAD OTS_TAG('h','e','a','d')
+#define OTS_TAG_HHEA OTS_TAG('h','h','e','a')
+#define OTS_TAG_HMTX OTS_TAG('h','m','t','x')
+#define OTS_TAG_KERN OTS_TAG('k','e','r','n')
+#define OTS_TAG_LOCA OTS_TAG('l','o','c','a')
+#define OTS_TAG_LTSH OTS_TAG('L','T','S','H')
+#define OTS_TAG_MATH OTS_TAG('M','A','T','H')
+#define OTS_TAG_MAXP OTS_TAG('m','a','x','p')
+#define OTS_TAG_NAME OTS_TAG('n','a','m','e')
+#define OTS_TAG_OS2 OTS_TAG('O','S','/','2')
+#define OTS_TAG_POST OTS_TAG('p','o','s','t')
+#define OTS_TAG_PREP OTS_TAG('p','r','e','p')
+#define OTS_TAG_SILE OTS_TAG('S','i','l','e')
+#define OTS_TAG_SILF OTS_TAG('S','i','l','f')
+#define OTS_TAG_SILL OTS_TAG('S','i','l','l')
+#define OTS_TAG_VDMX OTS_TAG('V','D','M','X')
+#define OTS_TAG_VHEA OTS_TAG('v','h','e','a')
+#define OTS_TAG_VMTX OTS_TAG('v','m','t','x')
+#define OTS_TAG_VORG OTS_TAG('V','O','R','G')
+
+#define OTS_TAG_AVAR OTS_TAG('a','v','a','r')
+#define OTS_TAG_CVAR OTS_TAG('c','v','a','r')
+#define OTS_TAG_FVAR OTS_TAG('f','v','a','r')
+#define OTS_TAG_GVAR OTS_TAG('g','v','a','r')
+#define OTS_TAG_HVAR OTS_TAG('H','V','A','R')
+#define OTS_TAG_MVAR OTS_TAG('M','V','A','R')
+#define OTS_TAG_VVAR OTS_TAG('V','V','A','R')
+#define OTS_TAG_STAT OTS_TAG('S','T','A','T')
struct Font;
-struct OpenTypeFile;
+struct FontFile;
+struct TableEntry;
+struct Arena;
+
+class Table {
+ public:
+ explicit Table(Font *font, uint32_t tag, uint32_t type)
+ : m_tag(tag),
+ m_type(type),
+ m_font(font),
+ m_shouldSerialize(true) {
+ }
+
+ virtual ~Table() { }
-#define F(name, capname) \
-bool ots_##name##_parse(Font *f, const uint8_t *d, size_t l); \
-bool ots_##name##_should_serialise(Font *f); \
-bool ots_##name##_serialise(OTSStream *s, Font *f); \
-void ots_##name##_reuse(Font *f, Font *o);\
-void ots_##name##_free(Font *f);
-FOR_EACH_TABLE_TYPE
-#undef F
+ virtual bool Parse(const uint8_t *data, size_t length) = 0;
+ virtual bool Serialize(OTSStream *out) = 0;
+ virtual bool ShouldSerialize();
+
+ // Return the tag (table type) this Table was parsed as, to support
+ // "poor man's RTTI" so that we know if we can safely down-cast to
+ // a specific Table subclass. The m_type field is initialized to the
+ // appropriate tag when a subclass is constructed, or to zero for
+ // TablePassthru (indicating unparsed data).
+ uint32_t Type() { return m_type; }
+
+ Font* GetFont() { return m_font; }
+
+ bool Error(const char *format, ...);
+ bool Warning(const char *format, ...);
+ bool Drop(const char *format, ...);
+ bool DropGraphite(const char *format, ...);
+ bool DropVariations(const char *format, ...);
+
+ private:
+ void Message(int level, const char *format, va_list va);
+
+ uint32_t m_tag;
+ uint32_t m_type;
+ Font *m_font;
+ bool m_shouldSerialize;
+};
+
+class TablePassthru : public Table {
+ public:
+ explicit TablePassthru(Font *font, uint32_t tag)
+ : Table(font, tag, 0),
+ m_data(NULL),
+ m_length(0) {
+ }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
+ private:
+ const uint8_t *m_data;
+ size_t m_length;
+};
struct Font {
- explicit Font(const OpenTypeFile *f)
+ explicit Font(FontFile *f)
: file(f),
version(0),
num_tables(0),
search_range(0),
entry_selector(0),
- range_shift(0) {
-#define F(name, capname) \
- name = NULL; \
- name##_reused = false;
- FOR_EACH_TABLE_TYPE
-#undef F
+ range_shift(0),
+ dropped_graphite(false),
+ dropped_variations(false) {
}
- ~Font() {
-#define F(name, capname) \
- if (!name##_reused) {\
- ots_##name##_free(this); \
- }
- FOR_EACH_TABLE_TYPE
-#undef F
- }
+ bool ParseTable(const TableEntry& tableinfo, const uint8_t* data,
+ Arena &arena);
+ Table* GetTable(uint32_t tag) const;
+
+ // This checks that the returned Table is actually of the correct subclass
+ // for |tag|, so it can safely be downcast to the corresponding OpenTypeXXXX;
+ // if not (i.e. if the table was treated as Passthru), it will return NULL.
+ Table* GetTypedTable(uint32_t tag) const;
+
+ // Drop all Graphite tables and don't parse new ones.
+ void DropGraphite();
- const OpenTypeFile *file;
+ // Drop all Variations tables and don't parse new ones.
+ void DropVariations();
+
+ FontFile *file;
uint32_t version;
uint16_t num_tables;
uint16_t search_range;
uint16_t entry_selector;
uint16_t range_shift;
+ bool dropped_graphite;
+ bool dropped_variations;
-#define F(name, capname) \
- OpenType##capname *name; \
- bool name##_reused;
-FOR_EACH_TABLE_TYPE
-#undef F
+ private:
+ std::map<uint32_t, Table*> m_tables;
};
-struct OutputTable {
+struct TableEntry {
uint32_t tag;
- size_t offset;
- size_t length;
+ uint32_t offset;
+ uint32_t length;
+ uint32_t uncompressed_length;
uint32_t chksum;
- bool operator<(const OutputTable& other) const {
+ bool operator<(const TableEntry& other) const {
return tag < other.tag;
}
};
-typedef std::map<uint32_t, std::pair<Font*, OutputTable> > TableMap;
+struct FontFile {
+ ~FontFile();
-struct OpenTypeFile {
OTSContext *context;
- TableMap tables;
+ std::map<TableEntry, Table*> tables;
+ std::map<uint32_t, TableEntry> table_entries;
};
} // namespace ots
-#undef FOR_EACH_TABLE_TYPE
-
#endif // OTS_H_
diff --git a/gfx/ots/src/post.cc b/gfx/ots/src/post.cc
index a110b2dea..704c32007 100644
--- a/gfx/ots/src/post.cc
+++ b/gfx/ots/src/post.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,74 +9,73 @@
// post - PostScript
// http://www.microsoft.com/typography/otspec/post.htm
-#define TABLE_NAME "post"
-
namespace ots {
-bool ots_post_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypePOST::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- OpenTypePOST *post = new OpenTypePOST;
- font->post = post;
+ if (!table.ReadU32(&this->version)) {
+ return Error("Failed to read table version");
+ }
- if (!table.ReadU32(&post->version) ||
- !table.ReadU32(&post->italic_angle) ||
- !table.ReadS16(&post->underline) ||
- !table.ReadS16(&post->underline_thickness) ||
- !table.ReadU32(&post->is_fixed_pitch)) {
- return OTS_FAILURE_MSG("Failed to read post header");
+ if (this->version != 0x00010000 &&
+ this->version != 0x00020000 &&
+ this->version != 0x00030000) {
+ // 0x00025000 is deprecated. We don't accept it.
+ return Error("Unsupported table version 0x%x", this->version);
}
- if (post->underline_thickness < 0) {
- post->underline_thickness = 1;
+ if (!table.ReadU32(&this->italic_angle) ||
+ !table.ReadS16(&this->underline) ||
+ !table.ReadS16(&this->underline_thickness) ||
+ !table.ReadU32(&this->is_fixed_pitch) ||
+ // We don't care about the memory usage fields. We'll set all these to
+ // zero when serialising
+ !table.Skip(16)) {
+ return Error("Failed to read table header");
}
- if (post->version == 0x00010000) {
- return true;
- } else if (post->version == 0x00030000) {
+ if (this->underline_thickness < 0) {
+ this->underline_thickness = 1;
+ }
+
+ if (this->version == 0x00010000 || this->version == 0x00030000) {
return true;
- } else if (post->version != 0x00020000) {
- // 0x00025000 is deprecated. We don't accept it.
- return OTS_FAILURE_MSG("Bad post version %x", post->version);
}
// We have a version 2 table with a list of Pascal strings at the end
- // We don't care about the memory usage fields. We'll set all these to zero
- // when serialising
- if (!table.Skip(16)) {
- return OTS_FAILURE_MSG("Failed to skip memory usage in post table");
- }
-
uint16_t num_glyphs = 0;
if (!table.ReadU16(&num_glyphs)) {
- return OTS_FAILURE_MSG("Failed to read number of glyphs");
+ return Error("Failed to read numberOfGlyphs");
}
- if (!font->maxp) {
- return OTS_FAILURE_MSG("No maxp table required by post table");
+ OpenTypeMAXP* maxp = static_cast<OpenTypeMAXP*>
+ (GetFont()->GetTable(OTS_TAG_MAXP));
+ if (!maxp) {
+ return Error("Missing required maxp table");
}
if (num_glyphs == 0) {
- if (font->maxp->num_glyphs > 258) {
- return OTS_FAILURE_MSG("Can't have no glyphs in the post table if there are more than 256 glyphs in the font");
+ if (maxp->num_glyphs > 258) {
+ return Error("Can't have no glyphs in the post table if there are more "
+ "than 258 glyphs in the font");
}
- OTS_WARNING("table version is 1, but no glyf names are found");
// workaround for fonts in http://www.fontsquirrel.com/fontface
// (e.g., yataghan.ttf).
- post->version = 0x00010000;
- return true;
+ this->version = 0x00010000;
+ return Warning("Table version is 1, but no glyph names are found");
}
- if (num_glyphs != font->maxp->num_glyphs) {
+ if (num_glyphs != maxp->num_glyphs) {
// Note: Fixedsys500c.ttf seems to have inconsistent num_glyphs values.
- return OTS_FAILURE_MSG("Bad number of glyphs in post table %d", num_glyphs);
+ return Error("Bad number of glyphs: %d", num_glyphs);
}
- post->glyph_name_index.resize(num_glyphs);
+ this->glyph_name_index.resize(num_glyphs);
for (unsigned i = 0; i < num_glyphs; ++i) {
- if (!table.ReadU16(&post->glyph_name_index[i])) {
- return OTS_FAILURE_MSG("Failed to read post information for glyph %d", i);
+ if (!table.ReadU16(&this->glyph_name_index[i])) {
+ return Error("Failed to read glyph name %d", i);
}
// Note: A strict interpretation of the specification requires name indexes
// are less than 32768. This, however, excludes fonts like unifont.ttf
@@ -93,101 +92,85 @@ bool ots_post_parse(Font *font, const uint8_t *data, size_t length) {
if (strings == strings_end) break;
const unsigned string_length = *strings;
if (strings + 1 + string_length > strings_end) {
- return OTS_FAILURE_MSG("Bad string length %d", string_length);
+ return Error("Bad string length %d", string_length);
}
if (std::memchr(strings + 1, '\0', string_length)) {
- return OTS_FAILURE_MSG("Bad string of length %d", string_length);
+ return Error("Bad string of length %d", string_length);
}
- post->names.push_back(
+ this->names.push_back(
std::string(reinterpret_cast<const char*>(strings + 1), string_length));
strings += 1 + string_length;
}
- const unsigned num_strings = post->names.size();
+ const unsigned num_strings = this->names.size();
// check that all the references are within bounds
for (unsigned i = 0; i < num_glyphs; ++i) {
- unsigned offset = post->glyph_name_index[i];
+ unsigned offset = this->glyph_name_index[i];
if (offset < 258) {
continue;
}
offset -= 258;
if (offset >= num_strings) {
- return OTS_FAILURE_MSG("Bad string index %d", offset);
+ return Error("Bad string index %d", offset);
}
}
return true;
}
-bool ots_post_should_serialise(Font *font) {
- return font->post != NULL;
-}
-
-bool ots_post_serialise(OTSStream *out, Font *font) {
- const OpenTypePOST *post = font->post;
-
+bool OpenTypePOST::Serialize(OTSStream *out) {
// OpenType with CFF glyphs must have v3 post table.
- if (post && font->cff && post->version != 0x00030000) {
- return OTS_FAILURE_MSG("Bad post version %x", post->version);
+ if (GetFont()->GetTable(OTS_TAG_CFF) && this->version != 0x00030000) {
+ return Error("Only version supported for fonts with CFF table is 0x00030000"
+ " not 0x%x", this->version);
}
- if (!out->WriteU32(post->version) ||
- !out->WriteU32(post->italic_angle) ||
- !out->WriteS16(post->underline) ||
- !out->WriteS16(post->underline_thickness) ||
- !out->WriteU32(post->is_fixed_pitch) ||
+ if (!out->WriteU32(this->version) ||
+ !out->WriteU32(this->italic_angle) ||
+ !out->WriteS16(this->underline) ||
+ !out->WriteS16(this->underline_thickness) ||
+ !out->WriteU32(this->is_fixed_pitch) ||
!out->WriteU32(0) ||
!out->WriteU32(0) ||
!out->WriteU32(0) ||
!out->WriteU32(0)) {
- return OTS_FAILURE_MSG("Failed to write post header");
+ return Error("Failed to write post header");
}
- if (post->version != 0x00020000) {
+ if (this->version != 0x00020000) {
return true; // v1.0 and v3.0 does not have glyph names.
}
const uint16_t num_indexes =
- static_cast<uint16_t>(post->glyph_name_index.size());
- if (num_indexes != post->glyph_name_index.size() ||
+ static_cast<uint16_t>(this->glyph_name_index.size());
+ if (num_indexes != this->glyph_name_index.size() ||
!out->WriteU16(num_indexes)) {
- return OTS_FAILURE_MSG("Failed to write number of indices");
+ return Error("Failed to write number of indices");
}
for (uint16_t i = 0; i < num_indexes; ++i) {
- if (!out->WriteU16(post->glyph_name_index[i])) {
- return OTS_FAILURE_MSG("Failed to write name index %d", i);
+ if (!out->WriteU16(this->glyph_name_index[i])) {
+ return Error("Failed to write name index %d", i);
}
}
// Now we just have to write out the strings in the correct order
- for (unsigned i = 0; i < post->names.size(); ++i) {
- const std::string& s = post->names[i];
+ for (unsigned i = 0; i < this->names.size(); ++i) {
+ const std::string& s = this->names[i];
const uint8_t string_length = static_cast<uint8_t>(s.size());
if (string_length != s.size() ||
!out->Write(&string_length, 1)) {
- return OTS_FAILURE_MSG("Failed to write string %d", i);
+ return Error("Failed to write string %d", i);
}
// Some ttf fonts (e.g., frank.ttf on Windows Vista) have zero-length name.
// We allow them.
if (string_length > 0 && !out->Write(s.data(), string_length)) {
- return OTS_FAILURE_MSG("Failed to write string length for string %d", i);
+ return Error("Failed to write string length for string %d", i);
}
}
return true;
}
-void ots_post_reuse(Font *font, Font *other) {
- font->post = other->post;
- font->post_reused = true;
-}
-
-void ots_post_free(Font *font) {
- delete font->post;
-}
-
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/post.h b/gfx/ots/src/post.h
index f220d4fc7..c341e391c 100644
--- a/gfx/ots/src/post.h
+++ b/gfx/ots/src/post.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,7 +13,15 @@
namespace ots {
-struct OpenTypePOST {
+class OpenTypePOST : public Table {
+ public:
+ explicit OpenTypePOST(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+
+private:
uint32_t version;
uint32_t italic_angle;
int16_t underline;
diff --git a/gfx/ots/src/prep.cc b/gfx/ots/src/prep.cc
index 1c9b45f91..943bb45b9 100644
--- a/gfx/ots/src/prep.cc
+++ b/gfx/ots/src/prep.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,53 +7,37 @@
// prep - Control Value Program
// http://www.microsoft.com/typography/otspec/prep.htm
-#define TABLE_NAME "prep"
-
namespace ots {
-bool ots_prep_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypePREP::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- OpenTypePREP *prep = new OpenTypePREP;
- font->prep = prep;
-
if (length >= 128 * 1024u) {
- return OTS_FAILURE_MSG("table length %ld > 120K", length); // almost all prep tables are less than 9k bytes.
+ // almost all prep tables are less than 9k bytes.
+ return Error("Table length %ld > 120K", length);
}
if (!table.Skip(length)) {
- return OTS_FAILURE_MSG("Failed to read table of length %ld", length);
+ return Error("Failed to read table of length %ld", length);
}
- prep->data = data;
- prep->length = length;
+ this->m_data = data;
+ this->m_length = length;
return true;
}
-bool ots_prep_should_serialise(Font *font) {
- if (!font->glyf) return false; // this table is not for CFF fonts.
- return font->prep != NULL;
-}
-
-bool ots_prep_serialise(OTSStream *out, Font *font) {
- const OpenTypePREP *prep = font->prep;
-
- if (!out->Write(prep->data, prep->length)) {
- return OTS_FAILURE_MSG("Failed to write table length");
+bool OpenTypePREP::Serialize(OTSStream *out) {
+ if (!out->Write(this->m_data, this->m_length)) {
+ return Error("Failed to write table length");
}
return true;
}
-void ots_prep_reuse(Font *font, Font *other) {
- font->prep = other->prep;
- font->prep_reused = true;
-}
-
-void ots_prep_free(Font *font) {
- delete font->prep;
+bool OpenTypePREP::ShouldSerialize() {
+ return Table::ShouldSerialize() &&
+ // this table is not for CFF fonts.
+ GetFont()->GetTable(OTS_TAG_GLYF) != NULL;
}
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/prep.h b/gfx/ots/src/prep.h
index 935ca111c..4d3eda2cd 100644
--- a/gfx/ots/src/prep.h
+++ b/gfx/ots/src/prep.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,9 +9,18 @@
namespace ots {
-struct OpenTypePREP {
- const uint8_t *data;
- uint32_t length;
+class OpenTypePREP : public Table {
+ public:
+ explicit OpenTypePREP(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool ShouldSerialize();
+
+ private:
+ const uint8_t *m_data;
+ uint32_t m_length;
};
} // namespace ots
diff --git a/gfx/ots/src/sile.cc b/gfx/ots/src/sile.cc
new file mode 100644
index 000000000..74405e56e
--- /dev/null
+++ b/gfx/ots/src/sile.cc
@@ -0,0 +1,74 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sile.h"
+
+namespace ots {
+
+bool OpenTypeSILE::Parse(const uint8_t* data, size_t length) {
+ if (GetFont()->dropped_graphite) {
+ return Drop("Skipping Graphite table");
+ }
+ Buffer table(data, length);
+
+ if (!table.ReadU32(&this->version) || this->version >> 16 != 1) {
+ return DropGraphite("Failed to read valid version");
+ }
+ if (!table.ReadU32(&this->checksum)) {
+ return DropGraphite("Failed to read checksum");
+ }
+ if (!table.ReadU32(&this->createTime[0]) ||
+ !table.ReadU32(&this->createTime[1])) {
+ return DropGraphite("Failed to read createTime");
+ }
+ if (!table.ReadU32(&this->modifyTime[0]) ||
+ !table.ReadU32(&this->modifyTime[1])) {
+ return DropGraphite("Failed to read modifyTime");
+ }
+
+ if (!table.ReadU16(&this->fontNameLength)) {
+ return DropGraphite("Failed to read fontNameLength");
+ }
+ //this->fontName.resize(this->fontNameLength);
+ for (unsigned i = 0; i < this->fontNameLength; ++i) {
+ this->fontName.emplace_back();
+ if (!table.ReadU16(&this->fontName[i])) {
+ return DropGraphite("Failed to read fontName[%u]", i);
+ }
+ }
+
+ if (!table.ReadU16(&this->fontFileLength)) {
+ return DropGraphite("Failed to read fontFileLength");
+ }
+ //this->baseFile.resize(this->fontFileLength);
+ for (unsigned i = 0; i < this->fontFileLength; ++i) {
+ this->baseFile.emplace_back();
+ if (!table.ReadU16(&this->baseFile[i])) {
+ return DropGraphite("Failed to read baseFile[%u]", i);
+ }
+ }
+
+ if (table.remaining()) {
+ return Warning("%zu bytes unparsed", table.remaining());
+ }
+ return true;
+}
+
+bool OpenTypeSILE::Serialize(OTSStream* out) {
+ if (!out->WriteU32(this->version) ||
+ !out->WriteU32(this->checksum) ||
+ !out->WriteU32(this->createTime[0]) ||
+ !out->WriteU32(this->createTime[1]) ||
+ !out->WriteU32(this->modifyTime[0]) ||
+ !out->WriteU32(this->modifyTime[1]) ||
+ !out->WriteU16(this->fontNameLength) ||
+ !SerializeParts(this->fontName, out) ||
+ !out->WriteU16(this->fontFileLength) ||
+ !SerializeParts(this->baseFile, out)) {
+ return Error("Failed to write table");
+ }
+ return true;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/sile.h b/gfx/ots/src/sile.h
new file mode 100644
index 000000000..bdb00606f
--- /dev/null
+++ b/gfx/ots/src/sile.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_SILE_H_
+#define OTS_SILE_H_
+
+#include "ots.h"
+#include "graphite.h"
+
+#include <vector>
+
+namespace ots {
+
+class OpenTypeSILE : public Table {
+ public:
+ explicit OpenTypeSILE(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ uint32_t version;
+ uint32_t checksum;
+ uint32_t createTime[2];
+ uint32_t modifyTime[2];
+ uint16_t fontNameLength;
+ std::vector<uint16_t> fontName;
+ uint16_t fontFileLength;
+ std::vector<uint16_t> baseFile;
+};
+
+} // namespace ots
+
+#endif // OTS_SILE_H_
diff --git a/gfx/ots/src/silf.cc b/gfx/ots/src/silf.cc
new file mode 100644
index 000000000..fa4e59e52
--- /dev/null
+++ b/gfx/ots/src/silf.cc
@@ -0,0 +1,977 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "silf.h"
+
+#include "name.h"
+#include "mozilla/Compression.h"
+#include <cmath>
+
+namespace ots {
+
+bool OpenTypeSILF::Parse(const uint8_t* data, size_t length,
+ bool prevent_decompression) {
+ if (GetFont()->dropped_graphite) {
+ return Drop("Skipping Graphite table");
+ }
+ Buffer table(data, length);
+
+ if (!table.ReadU32(&this->version)) {
+ return DropGraphite("Failed to read version");
+ }
+ if (this->version >> 16 != 1 &&
+ this->version >> 16 != 2 &&
+ this->version >> 16 != 3 &&
+ this->version >> 16 != 4 &&
+ this->version >> 16 != 5) {
+ return DropGraphite("Unsupported table version: %u", this->version >> 16);
+ }
+ if (this->version >> 16 >= 3 && !table.ReadU32(&this->compHead)) {
+ return DropGraphite("Failed to read compHead");
+ }
+ if (this->version >> 16 >= 5) {
+ switch ((this->compHead & SCHEME) >> 27) {
+ case 0: // uncompressed
+ break;
+ case 1: { // lz4
+ if (prevent_decompression) {
+ return DropGraphite("Illegal nested compression");
+ }
+ size_t decompressed_size = this->compHead & FULL_SIZE;
+ if (decompressed_size < length) {
+ return DropGraphite("Decompressed size is less than compressed size");
+ }
+ if (decompressed_size == 0) {
+ return DropGraphite("Decompressed size is set to 0");
+ }
+ // decompressed table must be <= 30MB
+ if (decompressed_size > 30 * 1024 * 1024) {
+ return DropGraphite("Decompressed size exceeds 30MB: %gMB",
+ decompressed_size / (1024.0 * 1024.0));
+ }
+ std::vector<uint8_t> decompressed(decompressed_size);
+ size_t outputSize = 0;
+ bool ret = mozilla::Compression::LZ4::decompressPartial(
+ reinterpret_cast<const char*>(data + table.offset()),
+ table.remaining(), // input buffer size (input size + padding)
+ reinterpret_cast<char*>(decompressed.data()),
+ decompressed.size(), // target output size
+ &outputSize); // return output size
+ if (!ret || outputSize != decompressed.size()) {
+ return DropGraphite("Decompression failed");
+ }
+ return this->Parse(decompressed.data(), decompressed.size(), true);
+ }
+ default:
+ return DropGraphite("Unknown compression scheme");
+ }
+ }
+ if (!table.ReadU16(&this->numSub)) {
+ return DropGraphite("Failed to read numSub");
+ }
+ if (this->version >> 16 >= 2 && !table.ReadU16(&this->reserved)) {
+ return DropGraphite("Failed to read reserved");
+ }
+ if (this->version >> 16 >= 2 && this->reserved != 0) {
+ Warning("Nonzero reserved");
+ }
+
+ unsigned long last_offset = 0;
+ //this->offset.resize(this->numSub);
+ for (unsigned i = 0; i < this->numSub; ++i) {
+ this->offset.emplace_back();
+ if (!table.ReadU32(&this->offset[i]) || this->offset[i] < last_offset) {
+ return DropGraphite("Failed to read offset[%u]", i);
+ }
+ last_offset = this->offset[i];
+ }
+
+ for (unsigned i = 0; i < this->numSub; ++i) {
+ if (table.offset() != this->offset[i]) {
+ return DropGraphite("Offset check failed for tables[%lu]", i);
+ }
+ SILSub subtable(this);
+ if (!subtable.ParsePart(table)) {
+ return DropGraphite("Failed to read tables[%u]", i);
+ }
+ tables.push_back(subtable);
+ }
+
+ if (table.remaining()) {
+ return Warning("%zu bytes unparsed", table.remaining());
+ }
+ return true;
+}
+
+bool OpenTypeSILF::Serialize(OTSStream* out) {
+ if (!out->WriteU32(this->version) ||
+ (this->version >> 16 >= 3 && !out->WriteU32(this->compHead)) ||
+ !out->WriteU16(this->numSub) ||
+ (this->version >> 16 >= 2 && !out->WriteU16(this->reserved)) ||
+ !SerializeParts(this->offset, out) ||
+ !SerializeParts(this->tables, out)) {
+ return Error("Failed to write table");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::ParsePart(Buffer& table) {
+ size_t init_offset = table.offset();
+ if (parent->version >> 16 >= 3) {
+ if (!table.ReadU32(&this->ruleVersion)) {
+ return parent->Error("SILSub: Failed to read ruleVersion");
+ }
+ if (!table.ReadU16(&this->passOffset)) {
+ return parent->Error("SILSub: Failed to read passOffset");
+ }
+ if (!table.ReadU16(&this->pseudosOffset)) {
+ return parent->Error("SILSub: Failed to read pseudosOffset");
+ }
+ }
+ if (!table.ReadU16(&this->maxGlyphID)) {
+ return parent->Error("SILSub: Failed to read maxGlyphID");
+ }
+ if (!table.ReadS16(&this->extraAscent)) {
+ return parent->Error("SILSub: Failed to read extraAscent");
+ }
+ if (!table.ReadS16(&this->extraDescent)) {
+ return parent->Error("SILSub: Failed to read extraDescent");
+ }
+ if (!table.ReadU8(&this->numPasses)) {
+ return parent->Error("SILSub: Failed to read numPasses");
+ }
+ if (!table.ReadU8(&this->iSubst) || this->iSubst > this->numPasses) {
+ return parent->Error("SILSub: Failed to read valid iSubst");
+ }
+ if (!table.ReadU8(&this->iPos) || this->iPos > this->numPasses) {
+ return parent->Error("SILSub: Failed to read valid iPos");
+ }
+ if (!table.ReadU8(&this->iJust) || this->iJust > this->numPasses) {
+ return parent->Error("SILSub: Failed to read valid iJust");
+ }
+ if (!table.ReadU8(&this->iBidi) ||
+ !(iBidi == 0xFF || this->iBidi <= this->iPos)) {
+ return parent->Error("SILSub: Failed to read valid iBidi");
+ }
+ if (!table.ReadU8(&this->flags)) {
+ return parent->Error("SILSub: Failed to read flags");
+ // checks omitted
+ }
+ if (!table.ReadU8(&this->maxPreContext)) {
+ return parent->Error("SILSub: Failed to read maxPreContext");
+ }
+ if (!table.ReadU8(&this->maxPostContext)) {
+ return parent->Error("SILSub: Failed to read maxPostContext");
+ }
+ if (!table.ReadU8(&this->attrPseudo)) {
+ return parent->Error("SILSub: Failed to read attrPseudo");
+ }
+ if (!table.ReadU8(&this->attrBreakWeight)) {
+ return parent->Error("SILSub: Failed to read attrBreakWeight");
+ }
+ if (!table.ReadU8(&this->attrDirectionality)) {
+ return parent->Error("SILSub: Failed to read attrDirectionality");
+ }
+ if (parent->version >> 16 >= 2) {
+ if (!table.ReadU8(&this->attrMirroring)) {
+ return parent->Error("SILSub: Failed to read attrMirroring");
+ }
+ if (!table.ReadU8(&this->attrSkipPasses)) {
+ return parent->Error("SILSub: Failed to read attrSkipPasses");
+ }
+
+ if (!table.ReadU8(&this->numJLevels)) {
+ return parent->Error("SILSub: Failed to read numJLevels");
+ }
+ //this->jLevels.resize(this->numJLevels, parent);
+ for (unsigned i = 0; i < this->numJLevels; ++i) {
+ this->jLevels.emplace_back(parent);
+ if (!this->jLevels[i].ParsePart(table)) {
+ return parent->Error("SILSub: Failed to read jLevels[%u]", i);
+ }
+ }
+ }
+
+ if (!table.ReadU16(&this->numLigComp)) {
+ return parent->Error("SILSub: Failed to read numLigComp");
+ }
+ if (!table.ReadU8(&this->numUserDefn)) {
+ return parent->Error("SILSub: Failed to read numUserDefn");
+ }
+ if (!table.ReadU8(&this->maxCompPerLig)) {
+ return parent->Error("SILSub: Failed to read maxCompPerLig");
+ }
+ if (!table.ReadU8(&this->direction)) {
+ return parent->Error("SILSub: Failed to read direction");
+ }
+ if (!table.ReadU8(&this->attCollisions)) {
+ return parent->Error("SILSub: Failed to read attCollisions");
+ }
+ if (parent->version >> 16 < 5 && this->attCollisions != 0) {
+ parent->Warning("SILSub: Nonzero attCollisions (reserved before v5)");
+ }
+ if (!table.ReadU8(&this->reserved4)) {
+ return parent->Error("SILSub: Failed to read reserved4");
+ }
+ if (this->reserved4 != 0) {
+ parent->Warning("SILSub: Nonzero reserved4");
+ }
+ if (!table.ReadU8(&this->reserved5)) {
+ return parent->Error("SILSub: Failed to read reserved5");
+ }
+ if (this->reserved5 != 0) {
+ parent->Warning("SILSub: Nonzero reserved5");
+ }
+ if (parent->version >> 16 >= 2) {
+ if (!table.ReadU8(&this->reserved6)) {
+ return parent->Error("SILSub: Failed to read reserved6");
+ }
+ if (this->reserved6 != 0) {
+ parent->Warning("SILSub: Nonzero reserved6");
+ }
+
+ if (!table.ReadU8(&this->numCritFeatures)) {
+ return parent->Error("SILSub: Failed to read numCritFeatures");
+ }
+ //this->critFeatures.resize(this->numCritFeatures);
+ for (unsigned i = 0; i < this->numCritFeatures; ++i) {
+ this->critFeatures.emplace_back();
+ if (!table.ReadU16(&this->critFeatures[i])) {
+ return parent->Error("SILSub: Failed to read critFeatures[%u]", i);
+ }
+ }
+
+ if (!table.ReadU8(&this->reserved7)) {
+ return parent->Error("SILSub: Failed to read reserved7");
+ }
+ if (this->reserved7 != 0) {
+ parent->Warning("SILSub: Nonzero reserved7");
+ }
+ }
+
+ if (!table.ReadU8(&this->numScriptTag)) {
+ return parent->Error("SILSub: Failed to read numScriptTag");
+ }
+ //this->scriptTag.resize(this->numScriptTag);
+ for (unsigned i = 0; i < this->numScriptTag; ++i) {
+ this->scriptTag.emplace_back();
+ if (!table.ReadU32(&this->scriptTag[i])) {
+ return parent->Error("SILSub: Failed to read scriptTag[%u]", i);
+ }
+ }
+
+ if (!table.ReadU16(&this->lbGID)) {
+ return parent->Error("SILSub: Failed to read lbGID");
+ }
+ if (this->lbGID > this->maxGlyphID) {
+ parent->Warning("SILSub: lbGID %u outside range 0..%u, replaced with 0",
+ this->lbGID, this->maxGlyphID);
+ this->lbGID = 0;
+ }
+
+ if (parent->version >> 16 >= 3 &&
+ table.offset() != init_offset + this->passOffset) {
+ return parent->Error("SILSub: passOffset check failed");
+ }
+ unsigned long last_oPass = 0;
+ //this->oPasses.resize(static_cast<unsigned>(this->numPasses) + 1);
+ for (unsigned i = 0; i <= this->numPasses; ++i) {
+ this->oPasses.emplace_back();
+ if (!table.ReadU32(&this->oPasses[i]) || this->oPasses[i] < last_oPass) {
+ return false;
+ }
+ last_oPass = this->oPasses[i];
+ }
+
+ if (parent->version >> 16 >= 3 &&
+ table.offset() != init_offset + this->pseudosOffset) {
+ return parent->Error("SILSub: pseudosOffset check failed");
+ }
+ if (!table.ReadU16(&this->numPseudo)) {
+ return parent->Error("SILSub: Failed to read numPseudo");
+ }
+
+ // The following three fields are deprecated and ignored. We fix them up here
+ // just for internal consistency, but the Graphite engine doesn't care.
+ if (!table.ReadU16(&this->searchPseudo) ||
+ !table.ReadU16(&this->pseudoSelector) ||
+ !table.ReadU16(&this->pseudoShift)) {
+ return parent->Error("SILSub: Failed to read searchPseudo..pseudoShift");
+ }
+ if (this->numPseudo == 0) {
+ if (this->searchPseudo != 0 || this->pseudoSelector != 0 || this->pseudoShift != 0) {
+ this->searchPseudo = this->pseudoSelector = this->pseudoShift = 0;
+ }
+ } else {
+ unsigned floorLog2 = std::floor(std::log2(this->numPseudo));
+ if (this->searchPseudo != 6 * (unsigned)std::pow(2, floorLog2) ||
+ this->pseudoSelector != floorLog2 ||
+ this->pseudoShift != 6 * this->numPseudo - this->searchPseudo) {
+ this->searchPseudo = 6 * (unsigned)std::pow(2, floorLog2);
+ this->pseudoSelector = floorLog2;
+ this->pseudoShift = 6 * this->numPseudo - this->searchPseudo;
+ }
+ }
+
+ //this->pMaps.resize(this->numPseudo, parent);
+ for (unsigned i = 0; i < numPseudo; i++) {
+ this->pMaps.emplace_back(parent);
+ if (!this->pMaps[i].ParsePart(table)) {
+ return parent->Error("SILSub: Failed to read pMaps[%u]", i);
+ }
+ }
+
+ if (!this->classes.ParsePart(table)) {
+ return parent->Error("SILSub: Failed to read classes");
+ }
+
+ //this->passes.resize(this->numPasses, parent);
+ for (unsigned i = 0; i < this->numPasses; ++i) {
+ this->passes.emplace_back(parent);
+ if (table.offset() != init_offset + this->oPasses[i]) {
+ return parent->Error("SILSub: Offset check failed for passes[%u]", i);
+ }
+ if (!this->passes[i].ParsePart(table, init_offset, this->oPasses[i+1])) {
+ return parent->Error("SILSub: Failed to read passes[%u]", i);
+ }
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::SerializePart(OTSStream* out) const {
+ if ((parent->version >> 16 >= 3 &&
+ (!out->WriteU32(this->ruleVersion) ||
+ !out->WriteU16(this->passOffset) ||
+ !out->WriteU16(this->pseudosOffset))) ||
+ !out->WriteU16(this->maxGlyphID) ||
+ !out->WriteS16(this->extraAscent) ||
+ !out->WriteS16(this->extraDescent) ||
+ !out->WriteU8(this->numPasses) ||
+ !out->WriteU8(this->iSubst) ||
+ !out->WriteU8(this->iPos) ||
+ !out->WriteU8(this->iJust) ||
+ !out->WriteU8(this->iBidi) ||
+ !out->WriteU8(this->flags) ||
+ !out->WriteU8(this->maxPreContext) ||
+ !out->WriteU8(this->maxPostContext) ||
+ !out->WriteU8(this->attrPseudo) ||
+ !out->WriteU8(this->attrBreakWeight) ||
+ !out->WriteU8(this->attrDirectionality) ||
+ (parent->version >> 16 >= 2 &&
+ (!out->WriteU8(this->attrMirroring) ||
+ !out->WriteU8(this->attrSkipPasses) ||
+ !out->WriteU8(this->numJLevels) ||
+ !SerializeParts(this->jLevels, out))) ||
+ !out->WriteU16(this->numLigComp) ||
+ !out->WriteU8(this->numUserDefn) ||
+ !out->WriteU8(this->maxCompPerLig) ||
+ !out->WriteU8(this->direction) ||
+ !out->WriteU8(this->attCollisions) ||
+ !out->WriteU8(this->reserved4) ||
+ !out->WriteU8(this->reserved5) ||
+ (parent->version >> 16 >= 2 &&
+ (!out->WriteU8(this->reserved6) ||
+ !out->WriteU8(this->numCritFeatures) ||
+ !SerializeParts(this->critFeatures, out) ||
+ !out->WriteU8(this->reserved7))) ||
+ !out->WriteU8(this->numScriptTag) ||
+ !SerializeParts(this->scriptTag, out) ||
+ !out->WriteU16(this->lbGID) ||
+ !SerializeParts(this->oPasses, out) ||
+ !out->WriteU16(this->numPseudo) ||
+ !out->WriteU16(this->searchPseudo) ||
+ !out->WriteU16(this->pseudoSelector) ||
+ !out->WriteU16(this->pseudoShift) ||
+ !SerializeParts(this->pMaps, out) ||
+ !this->classes.SerializePart(out) ||
+ !SerializeParts(this->passes, out)) {
+ return parent->Error("SILSub: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::
+JustificationLevel::ParsePart(Buffer& table) {
+ if (!table.ReadU8(&this->attrStretch)) {
+ return parent->Error("JustificationLevel: Failed to read attrStretch");
+ }
+ if (!table.ReadU8(&this->attrShrink)) {
+ return parent->Error("JustificationLevel: Failed to read attrShrink");
+ }
+ if (!table.ReadU8(&this->attrStep)) {
+ return parent->Error("JustificationLevel: Failed to read attrStep");
+ }
+ if (!table.ReadU8(&this->attrWeight)) {
+ return parent->Error("JustificationLevel: Failed to read attrWeight");
+ }
+ if (!table.ReadU8(&this->runto)) {
+ return parent->Error("JustificationLevel: Failed to read runto");
+ }
+ if (!table.ReadU8(&this->reserved)) {
+ return parent->Error("JustificationLevel: Failed to read reserved");
+ }
+ if (this->reserved != 0) {
+ parent->Warning("JustificationLevel: Nonzero reserved");
+ }
+ if (!table.ReadU8(&this->reserved2)) {
+ return parent->Error("JustificationLevel: Failed to read reserved2");
+ }
+ if (this->reserved2 != 0) {
+ parent->Warning("JustificationLevel: Nonzero reserved2");
+ }
+ if (!table.ReadU8(&this->reserved3)) {
+ return parent->Error("JustificationLevel: Failed to read reserved3");
+ }
+ if (this->reserved3 != 0) {
+ parent->Warning("JustificationLevel: Nonzero reserved3");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::
+JustificationLevel::SerializePart(OTSStream* out) const {
+ if (!out->WriteU8(this->attrStretch) ||
+ !out->WriteU8(this->attrShrink) ||
+ !out->WriteU8(this->attrStep) ||
+ !out->WriteU8(this->attrWeight) ||
+ !out->WriteU8(this->runto) ||
+ !out->WriteU8(this->reserved) ||
+ !out->WriteU8(this->reserved2) ||
+ !out->WriteU8(this->reserved3)) {
+ return parent->Error("JustificationLevel: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::
+PseudoMap::ParsePart(Buffer& table) {
+ if (parent->version >> 16 >= 2 && !table.ReadU32(&this->unicode)) {
+ return parent->Error("PseudoMap: Failed to read unicode");
+ }
+ if (parent->version >> 16 == 1) {
+ uint16_t unicode;
+ if (!table.ReadU16(&unicode)) {
+ return parent->Error("PseudoMap: Failed to read unicode");
+ }
+ this->unicode = unicode;
+ }
+ if (!table.ReadU16(&this->nPseudo)) {
+ return parent->Error("PseudoMap: Failed to read nPseudo");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::
+PseudoMap::SerializePart(OTSStream* out) const {
+ if ((parent->version >> 16 >= 2 && !out->WriteU32(this->unicode)) ||
+ (parent->version >> 16 == 1 &&
+ !out->WriteU16(static_cast<uint16_t>(this->unicode))) ||
+ !out->WriteU16(this->nPseudo)) {
+ return parent->Error("PseudoMap: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::
+ClassMap::ParsePart(Buffer& table) {
+ size_t init_offset = table.offset();
+ if (!table.ReadU16(&this->numClass)) {
+ return parent->Error("ClassMap: Failed to read numClass");
+ }
+ if (!table.ReadU16(&this->numLinear) || this->numLinear > this->numClass) {
+ return parent->Error("ClassMap: Failed to read valid numLinear");
+ }
+
+ //this->oClass.resize(static_cast<unsigned long>(this->numClass) + 1);
+ if (parent->version >> 16 >= 4) {
+ unsigned long last_oClass = 0;
+ for (unsigned long i = 0; i <= this->numClass; ++i) {
+ this->oClass.emplace_back();
+ if (!table.ReadU32(&this->oClass[i]) || this->oClass[i] < last_oClass) {
+ return parent->Error("ClassMap: Failed to read oClass[%lu]", i);
+ }
+ last_oClass = this->oClass[i];
+ }
+ }
+ if (parent->version >> 16 < 4) {
+ unsigned last_oClass = 0;
+ for (unsigned long i = 0; i <= this->numClass; ++i) {
+ uint16_t offset;
+ if (!table.ReadU16(&offset) || offset < last_oClass) {
+ return parent->Error("ClassMap: Failed to read oClass[%lu]", i);
+ }
+ last_oClass = offset;
+ this->oClass.push_back(static_cast<uint32_t>(offset));
+ }
+ }
+
+ if (table.offset() - init_offset > this->oClass[this->numLinear]) {
+ return parent->Error("ClassMap: Failed to calculate length of glyphs");
+ }
+ unsigned long glyphs_len = (this->oClass[this->numLinear] -
+ (table.offset() - init_offset))/2;
+ //this->glyphs.resize(glyphs_len);
+ for (unsigned long i = 0; i < glyphs_len; ++i) {
+ this->glyphs.emplace_back();
+ if (!table.ReadU16(&this->glyphs[i])) {
+ return parent->Error("ClassMap: Failed to read glyphs[%lu]", i);
+ }
+ }
+
+ unsigned lookups_len = this->numClass - this->numLinear;
+ // this->numLinear <= this->numClass
+ //this->lookups.resize(lookups_len, parent);
+ for (unsigned i = 0; i < lookups_len; ++i) {
+ this->lookups.emplace_back(parent);
+ if (table.offset() != init_offset + oClass[this->numLinear + i]) {
+ return parent->Error("ClassMap: Offset check failed for lookups[%u]", i);
+ }
+ if (!this->lookups[i].ParsePart(table)) {
+ return parent->Error("ClassMap: Failed to read lookups[%u]", i);
+ }
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::
+ClassMap::SerializePart(OTSStream* out) const {
+ if (!out->WriteU16(this->numClass) ||
+ !out->WriteU16(this->numLinear) ||
+ (parent->version >> 16 >= 4 && !SerializeParts(this->oClass, out)) ||
+ (parent->version >> 16 < 4 &&
+ ![&] {
+ for (uint32_t offset : this->oClass) {
+ if (!out->WriteU16(static_cast<uint16_t>(offset))) {
+ return false;
+ }
+ }
+ return true;
+ }()) ||
+ !SerializeParts(this->glyphs, out) ||
+ !SerializeParts(this->lookups, out)) {
+ return parent->Error("ClassMap: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::ClassMap::
+LookupClass::ParsePart(Buffer& table) {
+ if (!table.ReadU16(&this->numIDs)) {
+ return parent->Error("LookupClass: Failed to read numIDs");
+ }
+ if (!table.ReadU16(&this->searchRange) ||
+ !table.ReadU16(&this->entrySelector) ||
+ !table.ReadU16(&this->rangeShift)) {
+ return parent->Error("LookupClass: Failed to read searchRange..rangeShift");
+ }
+ if (this->numIDs == 0) {
+ if (this->searchRange != 0 || this->entrySelector != 0 || this->rangeShift != 0) {
+ parent->Warning("LookupClass: Correcting binary-search header for zero-length LookupPair list");
+ this->searchRange = this->entrySelector = this->rangeShift = 0;
+ }
+ } else {
+ unsigned floorLog2 = std::floor(std::log2(this->numIDs));
+ if (this->searchRange != (unsigned)std::pow(2, floorLog2) ||
+ this->entrySelector != floorLog2 ||
+ this->rangeShift != this->numIDs - this->searchRange) {
+ parent->Warning("LookupClass: Correcting binary-search header for LookupPair list");
+ this->searchRange = (unsigned)std::pow(2, floorLog2);
+ this->entrySelector = floorLog2;
+ this->rangeShift = this->numIDs - this->searchRange;
+ }
+ }
+
+ //this->lookups.resize(this->numIDs, parent);
+ for (unsigned i = 0; i < numIDs; ++i) {
+ this->lookups.emplace_back(parent);
+ if (!this->lookups[i].ParsePart(table)) {
+ return parent->Error("LookupClass: Failed to read lookups[%u]", i);
+ }
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::ClassMap::
+LookupClass::SerializePart(OTSStream* out) const {
+ if (!out->WriteU16(this->numIDs) ||
+ !out->WriteU16(this->searchRange) ||
+ !out->WriteU16(this->entrySelector) ||
+ !out->WriteU16(this->rangeShift) ||
+ !SerializeParts(this->lookups, out)) {
+ return parent->Error("LookupClass: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::ClassMap::LookupClass::
+LookupPair::ParsePart(Buffer& table) {
+ if (!table.ReadU16(&this->glyphId)) {
+ return parent->Error("LookupPair: Failed to read glyphId");
+ }
+ if (!table.ReadU16(&this->index)) {
+ return parent->Error("LookupPair: Failed to read index");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::ClassMap::LookupClass::
+LookupPair::SerializePart(OTSStream* out) const {
+ if (!out->WriteU16(this->glyphId) ||
+ !out->WriteU16(this->index)) {
+ return parent->Error("LookupPair: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::
+SILPass::ParsePart(Buffer& table, const size_t SILSub_init_offset,
+ const size_t next_pass_offset) {
+ size_t init_offset = table.offset();
+ if (!table.ReadU8(&this->flags)) {
+ return parent->Error("SILPass: Failed to read flags");
+ // checks omitted
+ }
+ if (!table.ReadU8(&this->maxRuleLoop)) {
+ return parent->Error("SILPass: Failed to read valid maxRuleLoop");
+ }
+ if (!table.ReadU8(&this->maxRuleContext)) {
+ return parent->Error("SILPass: Failed to read maxRuleContext");
+ }
+ if (!table.ReadU8(&this->maxBackup)) {
+ return parent->Error("SILPass: Failed to read maxBackup");
+ }
+ if (!table.ReadU16(&this->numRules)) {
+ return parent->Error("SILPass: Failed to read numRules");
+ }
+ if (parent->version >> 16 >= 2) {
+ if (!table.ReadU16(&this->fsmOffset)) {
+ return parent->Error("SILPass: Failed to read fsmOffset");
+ }
+ if (!table.ReadU32(&this->pcCode) ||
+ (parent->version >= 3 && this->pcCode < this->fsmOffset)) {
+ return parent->Error("SILPass: Failed to read pcCode");
+ }
+ }
+ if (!table.ReadU32(&this->rcCode) ||
+ (parent->version >> 16 >= 2 && this->rcCode < this->pcCode)) {
+ return parent->Error("SILPass: Failed to read valid rcCode");
+ }
+ if (!table.ReadU32(&this->aCode) || this->aCode < this->rcCode) {
+ return parent->Error("SILPass: Failed to read valid aCode");
+ }
+ if (!table.ReadU32(&this->oDebug) ||
+ (this->oDebug && this->oDebug < this->aCode)) {
+ return parent->Error("SILPass: Failed to read valid oDebug");
+ }
+ if (parent->version >> 16 >= 3 &&
+ table.offset() != init_offset + this->fsmOffset) {
+ return parent->Error("SILPass: fsmOffset check failed");
+ }
+ if (!table.ReadU16(&this->numRows) ||
+ (this->oDebug && this->numRows < this->numRules)) {
+ return parent->Error("SILPass: Failed to read valid numRows");
+ }
+ if (!table.ReadU16(&this->numTransitional)) {
+ return parent->Error("SILPass: Failed to read numTransitional");
+ }
+ if (!table.ReadU16(&this->numSuccess)) {
+ return parent->Error("SILPass: Failed to read numSuccess");
+ }
+ if (!table.ReadU16(&this->numColumns)) {
+ return parent->Error("SILPass: Failed to read numColumns");
+ }
+ if (!table.ReadU16(&this->numRange)) {
+ return parent->Error("SILPass: Failed to read numRange");
+ }
+
+ // The following three fields are deprecated and ignored. We fix them up here
+ // just for internal consistency, but the Graphite engine doesn't care.
+ if (!table.ReadU16(&this->searchRange) ||
+ !table.ReadU16(&this->entrySelector) ||
+ !table.ReadU16(&this->rangeShift)) {
+ return parent->Error("SILPass: Failed to read searchRange..rangeShift");
+ }
+ if (this->numRange == 0) {
+ if (this->searchRange != 0 || this->entrySelector != 0 || this->rangeShift != 0) {
+ this->searchRange = this->entrySelector = this->rangeShift = 0;
+ }
+ } else {
+ unsigned floorLog2 = std::floor(std::log2(this->numRange));
+ if (this->searchRange != 6 * (unsigned)std::pow(2, floorLog2) ||
+ this->entrySelector != floorLog2 ||
+ this->rangeShift != 6 * this->numRange - this->searchRange) {
+ this->searchRange = 6 * (unsigned)std::pow(2, floorLog2);
+ this->entrySelector = floorLog2;
+ this->rangeShift = 6 * this->numRange - this->searchRange;
+ }
+ }
+
+ //this->ranges.resize(this->numRange, parent);
+ for (unsigned i = 0 ; i < this->numRange; ++i) {
+ this->ranges.emplace_back(parent);
+ if (!this->ranges[i].ParsePart(table)) {
+ return parent->Error("SILPass: Failed to read ranges[%u]", i);
+ }
+ }
+ unsigned ruleMap_len = 0; // maximum value in oRuleMap
+ //this->oRuleMap.resize(static_cast<unsigned long>(this->numSuccess) + 1);
+ for (unsigned long i = 0; i <= this->numSuccess; ++i) {
+ this->oRuleMap.emplace_back();
+ if (!table.ReadU16(&this->oRuleMap[i])) {
+ return parent->Error("SILPass: Failed to read oRuleMap[%u]", i);
+ }
+ if (oRuleMap[i] > ruleMap_len) {
+ ruleMap_len = oRuleMap[i];
+ }
+ }
+
+ //this->ruleMap.resize(ruleMap_len);
+ for (unsigned i = 0; i < ruleMap_len; ++i) {
+ this->ruleMap.emplace_back();
+ if (!table.ReadU16(&this->ruleMap[i])) {
+ return parent->Error("SILPass: Failed to read ruleMap[%u]", i);
+ }
+ }
+
+ if (!table.ReadU8(&this->minRulePreContext)) {
+ return parent->Error("SILPass: Failed to read minRulePreContext");
+ }
+ if (!table.ReadU8(&this->maxRulePreContext) ||
+ this->maxRulePreContext < this->minRulePreContext) {
+ return parent->Error("SILPass: Failed to read valid maxRulePreContext");
+ }
+
+ unsigned startStates_len = this->maxRulePreContext - this->minRulePreContext
+ + 1;
+ // this->minRulePreContext <= this->maxRulePreContext
+ //this->startStates.resize(startStates_len);
+ for (unsigned i = 0; i < startStates_len; ++i) {
+ this->startStates.emplace_back();
+ if (!table.ReadS16(&this->startStates[i])) {
+ return parent->Error("SILPass: Failed to read startStates[%u]", i);
+ }
+ }
+
+ //this->ruleSortKeys.resize(this->numRules);
+ for (unsigned i = 0; i < this->numRules; ++i) {
+ this->ruleSortKeys.emplace_back();
+ if (!table.ReadU16(&this->ruleSortKeys[i])) {
+ return parent->Error("SILPass: Failed to read ruleSortKeys[%u]", i);
+ }
+ }
+
+ //this->rulePreContext.resize(this->numRules);
+ for (unsigned i = 0; i < this->numRules; ++i) {
+ this->rulePreContext.emplace_back();
+ if (!table.ReadU8(&this->rulePreContext[i])) {
+ return parent->Error("SILPass: Failed to read rulePreContext[%u]", i);
+ }
+ }
+
+ if (parent->version >> 16 >= 2) {
+ if (!table.ReadU8(&this->collisionThreshold)) {
+ return parent->Error("SILPass: Failed to read collisionThreshold");
+ }
+ if (!table.ReadU16(&this->pConstraint)) {
+ return parent->Error("SILPass: Failed to read pConstraint");
+ }
+ }
+
+ unsigned long ruleConstraints_len = this->aCode - this->rcCode;
+ // this->rcCode <= this->aCode
+ //this->oConstraints.resize(static_cast<unsigned long>(this->numRules) + 1);
+ for (unsigned long i = 0; i <= this->numRules; ++i) {
+ this->oConstraints.emplace_back();
+ if (!table.ReadU16(&this->oConstraints[i]) ||
+ this->oConstraints[i] > ruleConstraints_len) {
+ return parent->Error("SILPass: Failed to read valid oConstraints[%lu]",
+ i);
+ }
+ }
+
+ if (!this->oDebug && this->aCode > next_pass_offset) {
+ return parent->Error("SILPass: Failed to calculate length of actions");
+ }
+ unsigned long actions_len = this->oDebug ? this->oDebug - this->aCode :
+ next_pass_offset - this->aCode;
+ // if this->oDebug, then this->aCode <= this->oDebug
+ //this->oActions.resize(static_cast<unsigned long>(this->numRules) + 1);
+ for (unsigned long i = 0; i <= this->numRules; ++i) {
+ this->oActions.emplace_back();
+ if (!table.ReadU16(&this->oActions[i]) ||
+ (this->oActions[i] > actions_len)) {
+ return parent->Error("SILPass: Failed to read valid oActions[%lu]", i);
+ }
+ }
+
+ //this->stateTrans.resize(this->numTransitional);
+ for (unsigned i = 0; i < this->numTransitional; ++i) {
+ this->stateTrans.emplace_back();
+ //this->stateTrans[i].resize(this->numColumns);
+ for (unsigned j = 0; j < this->numColumns; ++j) {
+ this->stateTrans[i].emplace_back();
+ if (!table.ReadU16(&stateTrans[i][j])) {
+ return parent->Error("SILPass: Failed to read stateTrans[%u][%u]",
+ i, j);
+ }
+ }
+ }
+
+ if (parent->version >> 16 >= 2) {
+ if (!table.ReadU8(&this->reserved2)) {
+ return parent->Error("SILPass: Failed to read reserved2");
+ }
+ if (this->reserved2 != 0) {
+ parent->Warning("SILPass: Nonzero reserved2");
+ }
+
+ if (table.offset() != SILSub_init_offset + this->pcCode) {
+ return parent->Error("SILPass: pcCode check failed");
+ }
+ //this->passConstraints.resize(this->pConstraint);
+ for (unsigned i = 0; i < this->pConstraint; ++i) {
+ this->passConstraints.emplace_back();
+ if (!table.ReadU8(&this->passConstraints[i])) {
+ return parent->Error("SILPass: Failed to read passConstraints[%u]", i);
+ }
+ }
+ }
+
+ if (table.offset() != SILSub_init_offset + this->rcCode) {
+ return parent->Error("SILPass: rcCode check failed");
+ }
+ //this->ruleConstraints.resize(ruleConstraints_len); // calculated above
+ for (unsigned long i = 0; i < ruleConstraints_len; ++i) {
+ this->ruleConstraints.emplace_back();
+ if (!table.ReadU8(&this->ruleConstraints[i])) {
+ return parent->Error("SILPass: Failed to read ruleConstraints[%u]", i);
+ }
+ }
+
+ if (table.offset() != SILSub_init_offset + this->aCode) {
+ return parent->Error("SILPass: aCode check failed");
+ }
+ //this->actions.resize(actions_len); // calculated above
+ for (unsigned long i = 0; i < actions_len; ++i) {
+ this->actions.emplace_back();
+ if (!table.ReadU8(&this->actions[i])) {
+ return parent->Error("SILPass: Failed to read actions[%u]", i);
+ }
+ }
+
+ if (this->oDebug) {
+ OpenTypeNAME* name = static_cast<OpenTypeNAME*>(
+ parent->GetFont()->GetTypedTable(OTS_TAG_NAME));
+ if (!name) {
+ return parent->Error("SILPass: Required name table is missing");
+ }
+
+ if (table.offset() != SILSub_init_offset + this->oDebug) {
+ return parent->Error("SILPass: oDebug check failed");
+ }
+ //this->dActions.resize(this->numRules);
+ for (unsigned i = 0; i < this->numRules; ++i) {
+ this->dActions.emplace_back();
+ if (!table.ReadU16(&this->dActions[i]) ||
+ !name->IsValidNameId(this->dActions[i])) {
+ return parent->Error("SILPass: Failed to read valid dActions[%u]", i);
+ }
+ }
+
+ unsigned dStates_len = this->numRows - this->numRules;
+ // this->numRules <= this->numRows
+ //this->dStates.resize(dStates_len);
+ for (unsigned i = 0; i < dStates_len; ++i) {
+ this->dStates.emplace_back();
+ if (!table.ReadU16(&this->dStates[i]) ||
+ !name->IsValidNameId(this->dStates[i])) {
+ return parent->Error("SILPass: Failed to read valid dStates[%u]", i);
+ }
+ }
+
+ //this->dCols.resize(this->numRules);
+ for (unsigned i = 0; i < this->numRules; ++i) {
+ this->dCols.emplace_back();
+ if (!table.ReadU16(&this->dCols[i]) ||
+ !name->IsValidNameId(this->dCols[i])) {
+ return parent->Error("SILPass: Failed to read valid dCols[%u]");
+ }
+ }
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::
+SILPass::SerializePart(OTSStream* out) const {
+ if (!out->WriteU8(this->flags) ||
+ !out->WriteU8(this->maxRuleLoop) ||
+ !out->WriteU8(this->maxRuleContext) ||
+ !out->WriteU8(this->maxBackup) ||
+ !out->WriteU16(this->numRules) ||
+ (parent->version >> 16 >= 2 &&
+ (!out->WriteU16(this->fsmOffset) ||
+ !out->WriteU32(this->pcCode))) ||
+ !out->WriteU32(this->rcCode) ||
+ !out->WriteU32(this->aCode) ||
+ !out->WriteU32(this->oDebug) ||
+ !out->WriteU16(this->numRows) ||
+ !out->WriteU16(this->numTransitional) ||
+ !out->WriteU16(this->numSuccess) ||
+ !out->WriteU16(this->numColumns) ||
+ !out->WriteU16(this->numRange) ||
+ !out->WriteU16(this->searchRange) ||
+ !out->WriteU16(this->entrySelector) ||
+ !out->WriteU16(this->rangeShift) ||
+ !SerializeParts(this->ranges, out) ||
+ !SerializeParts(this->oRuleMap, out) ||
+ !SerializeParts(this->ruleMap, out) ||
+ !out->WriteU8(this->minRulePreContext) ||
+ !out->WriteU8(this->maxRulePreContext) ||
+ !SerializeParts(this->startStates, out) ||
+ !SerializeParts(this->ruleSortKeys, out) ||
+ !SerializeParts(this->rulePreContext, out) ||
+ (parent->version >> 16 >= 2 &&
+ (!out->WriteU8(this->collisionThreshold) ||
+ !out->WriteU16(this->pConstraint))) ||
+ !SerializeParts(this->oConstraints, out) ||
+ !SerializeParts(this->oActions, out) ||
+ !SerializeParts(this->stateTrans, out) ||
+ (parent->version >> 16 >= 2 &&
+ (!out->WriteU8(this->reserved2) ||
+ !SerializeParts(this->passConstraints, out))) ||
+ !SerializeParts(this->ruleConstraints, out) ||
+ !SerializeParts(this->actions, out) ||
+ !SerializeParts(this->dActions, out) ||
+ !SerializeParts(this->dStates, out) ||
+ !SerializeParts(this->dCols, out)) {
+ return parent->Error("SILPass: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::SILPass::
+PassRange::ParsePart(Buffer& table) {
+ if (!table.ReadU16(&this->firstId)) {
+ return parent->Error("PassRange: Failed to read firstId");
+ }
+ if (!table.ReadU16(&this->lastId)) {
+ return parent->Error("PassRange: Failed to read lastId");
+ }
+ if (!table.ReadU16(&this->colId)) {
+ return parent->Error("PassRange: Failed to read colId");
+ }
+ return true;
+}
+
+bool OpenTypeSILF::SILSub::SILPass::
+PassRange::SerializePart(OTSStream* out) const {
+ if (!out->WriteU16(this->firstId) ||
+ !out->WriteU16(this->lastId) ||
+ !out->WriteU16(this->colId)) {
+ return parent->Error("PassRange: Failed to write");
+ }
+ return true;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/silf.h b/gfx/ots/src/silf.h
new file mode 100644
index 000000000..b6c08032f
--- /dev/null
+++ b/gfx/ots/src/silf.h
@@ -0,0 +1,196 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_SILF_H_
+#define OTS_SILF_H_
+
+#include <vector>
+
+#include "ots.h"
+#include "graphite.h"
+
+namespace ots {
+
+class OpenTypeSILF : public Table {
+ public:
+ explicit OpenTypeSILF(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length) {
+ return this->Parse(data, length, false);
+ }
+ bool Serialize(OTSStream* out);
+
+ private:
+ bool Parse(const uint8_t* data, size_t length, bool prevent_decompression);
+ struct SILSub : public TablePart<OpenTypeSILF> {
+ explicit SILSub(OpenTypeSILF* parent)
+ : TablePart<OpenTypeSILF>(parent), classes(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ struct JustificationLevel : public TablePart<OpenTypeSILF> {
+ explicit JustificationLevel(OpenTypeSILF* parent)
+ : TablePart<OpenTypeSILF>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ uint8_t attrStretch;
+ uint8_t attrShrink;
+ uint8_t attrStep;
+ uint8_t attrWeight;
+ uint8_t runto;
+ uint8_t reserved;
+ uint8_t reserved2;
+ uint8_t reserved3;
+ };
+ struct PseudoMap : public TablePart<OpenTypeSILF> {
+ explicit PseudoMap(OpenTypeSILF* parent)
+ : TablePart<OpenTypeSILF>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ uint32_t unicode;
+ uint16_t nPseudo;
+ };
+ struct ClassMap : public TablePart<OpenTypeSILF> {
+ explicit ClassMap(OpenTypeSILF* parent)
+ : TablePart<OpenTypeSILF>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ struct LookupClass : public TablePart<OpenTypeSILF> {
+ explicit LookupClass(OpenTypeSILF* parent)
+ : TablePart<OpenTypeSILF>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ struct LookupPair : public TablePart<OpenTypeSILF> {
+ explicit LookupPair(OpenTypeSILF* parent)
+ : TablePart<OpenTypeSILF>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ uint16_t glyphId;
+ uint16_t index;
+ };
+ uint16_t numIDs;
+ uint16_t searchRange;
+ uint16_t entrySelector;
+ uint16_t rangeShift;
+ std::vector<LookupPair> lookups;
+ };
+ uint16_t numClass;
+ uint16_t numLinear;
+ std::vector<uint32_t> oClass; // uint16_t before v4
+ std::vector<uint16_t> glyphs;
+ std::vector<LookupClass> lookups;
+ };
+ struct SILPass : public TablePart<OpenTypeSILF> {
+ explicit SILPass(OpenTypeSILF* parent)
+ : TablePart<OpenTypeSILF>(parent) { }
+ bool ParsePart(Buffer& table) { return false; }
+ bool ParsePart(Buffer& table, const size_t SILSub_init_offset,
+ const size_t next_pass_offset);
+ bool SerializePart(OTSStream* out) const;
+ struct PassRange : public TablePart<OpenTypeSILF> {
+ explicit PassRange(OpenTypeSILF* parent)
+ : TablePart<OpenTypeSILF>(parent) { }
+ bool ParsePart(Buffer& table);
+ bool SerializePart(OTSStream* out) const;
+ uint16_t firstId;
+ uint16_t lastId;
+ uint16_t colId;
+ };
+ uint8_t flags;
+ uint8_t maxRuleLoop;
+ uint8_t maxRuleContext;
+ uint8_t maxBackup;
+ uint16_t numRules;
+ uint16_t fsmOffset;
+ uint32_t pcCode;
+ uint32_t rcCode;
+ uint32_t aCode;
+ uint32_t oDebug;
+ uint16_t numRows;
+ uint16_t numTransitional;
+ uint16_t numSuccess;
+ uint16_t numColumns;
+ uint16_t numRange;
+ uint16_t searchRange;
+ uint16_t entrySelector;
+ uint16_t rangeShift;
+ std::vector<PassRange> ranges;
+ std::vector<uint16_t> oRuleMap;
+ std::vector<uint16_t> ruleMap;
+ uint8_t minRulePreContext;
+ uint8_t maxRulePreContext;
+ std::vector<int16_t> startStates;
+ std::vector<uint16_t> ruleSortKeys;
+ std::vector<uint8_t> rulePreContext;
+ uint8_t collisionThreshold; // reserved before v5
+ uint16_t pConstraint;
+ std::vector<uint16_t> oConstraints;
+ std::vector<uint16_t> oActions;
+ std::vector<std::vector<uint16_t>> stateTrans;
+ uint8_t reserved2;
+ std::vector<uint8_t> passConstraints;
+ std::vector<uint8_t> ruleConstraints;
+ std::vector<uint8_t> actions;
+ std::vector<uint16_t> dActions;
+ std::vector<uint16_t> dStates;
+ std::vector<uint16_t> dCols;
+ };
+ uint32_t ruleVersion;
+ uint16_t passOffset;
+ uint16_t pseudosOffset;
+ uint16_t maxGlyphID;
+ int16_t extraAscent;
+ int16_t extraDescent;
+ uint8_t numPasses;
+ uint8_t iSubst;
+ uint8_t iPos;
+ uint8_t iJust;
+ uint8_t iBidi;
+ uint8_t flags;
+ uint8_t maxPreContext;
+ uint8_t maxPostContext;
+ uint8_t attrPseudo;
+ uint8_t attrBreakWeight;
+ uint8_t attrDirectionality;
+ uint8_t attrMirroring; // reserved before v4
+ uint8_t attrSkipPasses; // reserved2 before v4
+ uint8_t numJLevels;
+ std::vector<JustificationLevel> jLevels;
+ uint16_t numLigComp;
+ uint8_t numUserDefn;
+ uint8_t maxCompPerLig;
+ uint8_t direction;
+ uint8_t attCollisions; // reserved3 before v5
+ uint8_t reserved4;
+ uint8_t reserved5;
+ uint8_t reserved6;
+ uint8_t numCritFeatures;
+ std::vector<uint16_t> critFeatures;
+ uint8_t reserved7;
+ uint8_t numScriptTag;
+ std::vector<uint32_t> scriptTag;
+ uint16_t lbGID;
+ std::vector<uint32_t> oPasses;
+ uint16_t numPseudo;
+ uint16_t searchPseudo;
+ uint16_t pseudoSelector;
+ uint16_t pseudoShift;
+ std::vector<PseudoMap> pMaps;
+ ClassMap classes;
+ std::vector<SILPass> passes;
+ };
+ uint32_t version;
+ uint32_t compHead; // compression header
+ static const uint32_t SCHEME = 0xF8000000;
+ static const uint32_t FULL_SIZE = 0x07FFFFFF;
+ static const uint32_t COMPILER_VERSION = 0x07FFFFFF;
+ uint16_t numSub;
+ uint16_t reserved;
+ std::vector<uint32_t> offset;
+ std::vector<SILSub> tables;
+};
+
+} // namespace ots
+
+#endif // OTS_SILF_H_
diff --git a/gfx/ots/src/sill.cc b/gfx/ots/src/sill.cc
new file mode 100644
index 000000000..c7b20a980
--- /dev/null
+++ b/gfx/ots/src/sill.cc
@@ -0,0 +1,159 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sill.h"
+
+#include "feat.h"
+#include <cmath>
+#include <unordered_set>
+
+namespace ots {
+
+bool OpenTypeSILL::Parse(const uint8_t* data, size_t length) {
+ if (GetFont()->dropped_graphite) {
+ return Drop("Skipping Graphite table");
+ }
+ Buffer table(data, length);
+
+ if (!table.ReadU32(&this->version) || this->version >> 16 != 1) {
+ return Drop("Failed to read valid version");
+ }
+ if (!table.ReadU16(&this->numLangs)) {
+ return Drop("Failed to read numLangs");
+ }
+
+ // The following three fields are deprecated and ignored. We fix them up here
+ // just for internal consistency, but the Graphite engine doesn't care.
+ if (!table.ReadU16(&this->searchRange) ||
+ !table.ReadU16(&this->entrySelector) ||
+ !table.ReadU16(&this->rangeShift)) {
+ return Drop("Failed to read searchRange..rangeShift");
+ }
+ if (this->numLangs == 0) {
+ if (this->searchRange != 0 || this->entrySelector != 0 || this->rangeShift != 0) {
+ this->searchRange = this->entrySelector = this->rangeShift = 0;
+ }
+ } else {
+ unsigned floorLog2 = std::floor(std::log2(this->numLangs));
+ if (this->searchRange != (unsigned)std::pow(2, floorLog2) ||
+ this->entrySelector != floorLog2 ||
+ this->rangeShift != this->numLangs - this->searchRange) {
+ this->searchRange = (unsigned)std::pow(2, floorLog2);
+ this->entrySelector = floorLog2;
+ this->rangeShift = this->numLangs - this->searchRange;
+ }
+ }
+
+ std::unordered_set<size_t> unverified;
+ //this->entries.resize(static_cast<unsigned long>(this->numLangs) + 1, this);
+ for (unsigned long i = 0; i <= this->numLangs; ++i) {
+ this->entries.emplace_back(this);
+ LanguageEntry& entry = this->entries[i];
+ if (!entry.ParsePart(table)) {
+ return Drop("Failed to read entries[%u]", i);
+ }
+ for (unsigned j = 0; j < entry.numSettings; ++j) {
+ size_t offset = entry.offset + j * 8;
+ if (offset < entry.offset || offset > length) {
+ return DropGraphite("Invalid LangFeatureSetting offset %zu/%zu",
+ offset, length);
+ }
+ unverified.insert(offset);
+ // need to verify that this LanguageEntry points to valid
+ // LangFeatureSetting
+ }
+ }
+
+ while (table.remaining()) {
+ unverified.erase(table.offset());
+ LangFeatureSetting setting(this);
+ if (!setting.ParsePart(table)) {
+ return Drop("Failed to read a LangFeatureSetting");
+ }
+ settings.push_back(setting);
+ }
+
+ if (!unverified.empty()) {
+ return Drop("%zu incorrect offsets into settings", unverified.size());
+ }
+ if (table.remaining()) {
+ return Warning("%zu bytes unparsed", table.remaining());
+ }
+ return true;
+}
+
+bool OpenTypeSILL::Serialize(OTSStream* out) {
+ if (!out->WriteU32(this->version) ||
+ !out->WriteU16(this->numLangs) ||
+ !out->WriteU16(this->searchRange) ||
+ !out->WriteU16(this->entrySelector) ||
+ !out->WriteU16(this->rangeShift) ||
+ !SerializeParts(this->entries, out) ||
+ !SerializeParts(this->settings, out)) {
+ return Error("Failed to write table");
+ }
+ return true;
+}
+
+bool OpenTypeSILL::LanguageEntry::ParsePart(Buffer& table) {
+ if (!table.ReadU8(&this->langcode[0]) ||
+ !table.ReadU8(&this->langcode[1]) ||
+ !table.ReadU8(&this->langcode[2]) ||
+ !table.ReadU8(&this->langcode[3])) {
+ return parent->Error("LanguageEntry: Failed to read langcode");
+ }
+ if (!table.ReadU16(&this->numSettings)) {
+ return parent->Error("LanguageEntry: Failed to read numSettings");
+ }
+ if (!table.ReadU16(&this->offset)) {
+ return parent->Error("LanguageEntry: Failed to read offset");
+ }
+ return true;
+}
+
+bool OpenTypeSILL::LanguageEntry::SerializePart(OTSStream* out) const {
+ if (!out->WriteU8(this->langcode[0]) ||
+ !out->WriteU8(this->langcode[1]) ||
+ !out->WriteU8(this->langcode[2]) ||
+ !out->WriteU8(this->langcode[3]) ||
+ !out->WriteU16(this->numSettings) ||
+ !out->WriteU16(this->offset)) {
+ return parent->Error("LanguageEntry: Failed to write");
+ }
+ return true;
+}
+
+bool OpenTypeSILL::LangFeatureSetting::ParsePart(Buffer& table) {
+ OpenTypeFEAT* feat = static_cast<OpenTypeFEAT*>(
+ parent->GetFont()->GetTypedTable(OTS_TAG_FEAT));
+ if (!feat) {
+ return parent->Error("FeatureDefn: Required Feat table is missing");
+ }
+
+ if (!table.ReadU32(&this->featureId) ||
+ !feat->IsValidFeatureId(this->featureId)) {
+ return parent->Error("LangFeatureSetting: Failed to read valid featureId");
+ }
+ if (!table.ReadS16(&this->value)) {
+ return parent->Error("LangFeatureSetting: Failed to read value");
+ }
+ if (!table.ReadU16(&this->reserved)) {
+ return parent->Error("LangFeatureSetting: Failed to read reserved");
+ }
+ if (this->reserved != 0) {
+ parent->Warning("LangFeatureSetting: Nonzero reserved");
+ }
+ return true;
+}
+
+bool OpenTypeSILL::LangFeatureSetting::SerializePart(OTSStream* out) const {
+ if (!out->WriteU32(this->featureId) ||
+ !out->WriteS16(this->value) ||
+ !out->WriteU16(this->reserved)) {
+ return parent->Error("LangFeatureSetting: Failed to read reserved");
+ }
+ return true;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/sill.h b/gfx/ots/src/sill.h
new file mode 100644
index 000000000..30f9b8d83
--- /dev/null
+++ b/gfx/ots/src/sill.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_SILL_H_
+#define OTS_SILL_H_
+
+#include "ots.h"
+#include "graphite.h"
+
+#include <vector>
+
+namespace ots {
+
+class OpenTypeSILL : public Table {
+ public:
+ explicit OpenTypeSILL(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ struct LanguageEntry : public TablePart<OpenTypeSILL> {
+ explicit LanguageEntry(OpenTypeSILL* parent)
+ : TablePart<OpenTypeSILL>(parent) { }
+ bool ParsePart(Buffer &table);
+ bool SerializePart(OTSStream* out) const;
+ uint8_t langcode[4];
+ uint16_t numSettings;
+ uint16_t offset;
+ };
+ struct LangFeatureSetting : public TablePart<OpenTypeSILL> {
+ explicit LangFeatureSetting(OpenTypeSILL* parent)
+ : TablePart<OpenTypeSILL>(parent) { }
+ bool ParsePart(Buffer &table);
+ bool SerializePart(OTSStream* out) const;
+ uint32_t featureId;
+ int16_t value;
+ uint16_t reserved;
+ };
+ uint32_t version;
+ uint16_t numLangs;
+ uint16_t searchRange;
+ uint16_t entrySelector;
+ uint16_t rangeShift;
+ std::vector<LanguageEntry> entries;
+ std::vector<LangFeatureSetting> settings;
+};
+
+} // namespace ots
+
+#endif // OTS_SILL_H_
diff --git a/gfx/ots/src/stat.cc b/gfx/ots/src/stat.cc
new file mode 100644
index 000000000..9b7828109
--- /dev/null
+++ b/gfx/ots/src/stat.cc
@@ -0,0 +1,347 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "stat.h"
+#include "name.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeSTAT
+// -----------------------------------------------------------------------------
+
+bool OpenTypeSTAT::ValidateNameId(uint16_t nameid, bool allowPredefined) {
+ OpenTypeNAME* name = static_cast<OpenTypeNAME*>(
+ GetFont()->GetTypedTable(OTS_TAG_NAME));
+
+ if (!name || !name->IsValidNameId(nameid)) {
+ Drop("Invalid nameID: %d", nameid);
+ return false;
+ }
+
+ if (!allowPredefined && nameid < 26) {
+ Warning("nameID out of range: %d", nameid);
+ return true;
+ }
+
+ if ((nameid >= 26 && nameid <= 255) || nameid >= 32768) {
+ Warning("nameID out of range: %d", nameid);
+ return true;
+ }
+
+ return true;
+}
+
+bool OpenTypeSTAT::Parse(const uint8_t* data, size_t length) {
+ Buffer table(data, length);
+ if (!table.ReadU16(&this->majorVersion) ||
+ !table.ReadU16(&this->minorVersion) ||
+ !table.ReadU16(&this->designAxisSize) ||
+ !table.ReadU16(&this->designAxisCount) ||
+ !table.ReadU32(&this->designAxesOffset) ||
+ !table.ReadU16(&this->axisValueCount) ||
+ !table.ReadU32(&this->offsetToAxisValueOffsets) ||
+ !(this->minorVersion < 1 || table.ReadU16(&this->elidedFallbackNameID))) {
+ return Drop("Failed to read table header");
+ }
+ if (this->majorVersion != 1) {
+ return Drop("Unknown table version");
+ }
+ if (this->minorVersion > 2) {
+ Warning("Unknown minor version, downgrading to 2");
+ this->minorVersion = 2;
+ }
+
+ if (this->designAxisSize < sizeof(AxisRecord)) {
+ return Drop("Invalid designAxisSize");
+ }
+
+ size_t headerEnd = table.offset();
+
+ if (this->designAxisCount == 0) {
+ if (this->designAxesOffset != 0) {
+ Warning("Unexpected non-zero designAxesOffset");
+ this->designAxesOffset = 0;
+ }
+ } else {
+ if (this->designAxesOffset < headerEnd ||
+ size_t(this->designAxesOffset) +
+ size_t(this->designAxisCount) * size_t(this->designAxisSize) > length) {
+ return Drop("Invalid designAxesOffset");
+ }
+ }
+
+ for (size_t i = 0; i < this->designAxisCount; i++) {
+ table.set_offset(this->designAxesOffset + i * this->designAxisSize);
+ this->designAxes.emplace_back();
+ auto& axis = this->designAxes[i];
+ if (!table.ReadU32(&axis.axisTag) ||
+ !table.ReadU16(&axis.axisNameID) ||
+ !table.ReadU16(&axis.axisOrdering)) {
+ return Drop("Failed to read design axis");
+ }
+ if (!CheckTag(axis.axisTag)) {
+ return Drop("Bad design axis tag");
+ }
+ if (!ValidateNameId(axis.axisNameID, false)) {
+ return true;
+ }
+ }
+
+ // TODO
+ // - check that all axes defined in fvar are covered by STAT
+ // - check that axisOrdering values are not duplicated (warn only)
+
+ if (this->axisValueCount == 0) {
+ if (this->offsetToAxisValueOffsets != 0) {
+ Warning("Unexpected non-zero offsetToAxisValueOffsets");
+ this->offsetToAxisValueOffsets = 0;
+ }
+ } else {
+ if (this->offsetToAxisValueOffsets < headerEnd ||
+ size_t(this->offsetToAxisValueOffsets) +
+ size_t(this->axisValueCount) * sizeof(uint16_t) > length) {
+ return Drop("Invalid offsetToAxisValueOffsets");
+ }
+ }
+
+ for (size_t i = 0; i < this->axisValueCount; i++) {
+ table.set_offset(this->offsetToAxisValueOffsets + i * sizeof(uint16_t));
+ uint16_t axisValueOffset;
+ if (!table.ReadU16(&axisValueOffset)) {
+ return Drop("Failed to read axis value offset");
+ }
+ if (this->offsetToAxisValueOffsets + axisValueOffset > length) {
+ return Drop("Invalid axis value offset");
+ }
+ table.set_offset(this->offsetToAxisValueOffsets + axisValueOffset);
+ uint16_t format;
+ if (!table.ReadU16(&format)) {
+ return Drop("Failed to read axis value format");
+ }
+ this->axisValues.emplace_back(format);
+ auto& axisValue = axisValues[i];
+ switch (format) {
+ case 1:
+ if (!table.ReadU16(&axisValue.format1.axisIndex) ||
+ !table.ReadU16(&axisValue.format1.flags) ||
+ !table.ReadU16(&axisValue.format1.valueNameID) ||
+ !table.ReadS32(&axisValue.format1.value)) {
+ return Drop("Failed to read axis value (format 1)");
+ }
+ if (axisValue.format1.axisIndex >= this->designAxisCount) {
+ return Drop("Axis index out of range");
+ }
+ if ((axisValue.format1.flags & 0xFFFCu) != 0) {
+ Warning("Unexpected axis value flags");
+ axisValue.format1.flags &= ~0xFFFCu;
+ }
+ if (!ValidateNameId(axisValue.format1.valueNameID)) {
+ return true;
+ }
+ break;
+ case 2:
+ if (!table.ReadU16(&axisValue.format2.axisIndex) ||
+ !table.ReadU16(&axisValue.format2.flags) ||
+ !table.ReadU16(&axisValue.format2.valueNameID) ||
+ !table.ReadS32(&axisValue.format2.nominalValue) ||
+ !table.ReadS32(&axisValue.format2.rangeMinValue) ||
+ !table.ReadS32(&axisValue.format2.rangeMaxValue)) {
+ return Drop("Failed to read axis value (format 2)");
+ }
+ if (axisValue.format2.axisIndex >= this->designAxisCount) {
+ return Drop("Axis index out of range");
+ }
+ if ((axisValue.format2.flags & 0xFFFCu) != 0) {
+ Warning("Unexpected axis value flags");
+ axisValue.format1.flags &= ~0xFFFCu;
+ }
+ if (!ValidateNameId(axisValue.format2.valueNameID)) {
+ return true;
+ }
+ if (!(axisValue.format2.rangeMinValue <= axisValue.format2.nominalValue &&
+ axisValue.format2.nominalValue <= axisValue.format2.rangeMaxValue)) {
+ Warning("Bad axis value range or nominal value");
+ }
+ break;
+ case 3:
+ if (!table.ReadU16(&axisValue.format3.axisIndex) ||
+ !table.ReadU16(&axisValue.format3.flags) ||
+ !table.ReadU16(&axisValue.format3.valueNameID) ||
+ !table.ReadS32(&axisValue.format3.value) ||
+ !table.ReadS32(&axisValue.format3.linkedValue)) {
+ return Drop("Failed to read axis value (format 3)");
+ }
+ if (axisValue.format3.axisIndex >= this->designAxisCount) {
+ return Drop("Axis index out of range");
+ }
+ if ((axisValue.format3.flags & 0xFFFCu) != 0) {
+ Warning("Unexpected axis value flags");
+ axisValue.format3.flags &= ~0xFFFCu;
+ }
+ if (!ValidateNameId(axisValue.format3.valueNameID)) {
+ return true;
+ }
+ break;
+ case 4:
+ if (this->minorVersion < 2) {
+ Warning("Invalid table version for format 4 axis values - updating");
+ this->minorVersion = 2;
+ }
+ if (!table.ReadU16(&axisValue.format4.axisCount) ||
+ !table.ReadU16(&axisValue.format4.flags) ||
+ !table.ReadU16(&axisValue.format4.valueNameID)) {
+ return Drop("Failed to read axis value (format 4)");
+ }
+ if (axisValue.format4.axisCount > this->designAxisCount) {
+ return Drop("Axis count out of range");
+ }
+ if ((axisValue.format4.flags & 0xFFFCu) != 0) {
+ Warning("Unexpected axis value flags");
+ axisValue.format4.flags &= ~0xFFFCu;
+ }
+ if (!ValidateNameId(axisValue.format4.valueNameID)) {
+ return true;
+ }
+ for (unsigned j = 0; j < axisValue.format4.axisCount; j++) {
+ axisValue.format4.axisValues.emplace_back();
+ auto& v = axisValue.format4.axisValues[j];
+ if (!table.ReadU16(&v.axisIndex) ||
+ !table.ReadS32(&v.value)) {
+ return Drop("Failed to read axis value");
+ }
+ if (v.axisIndex >= this->designAxisCount) {
+ return Drop("Axis index out of range");
+ }
+ }
+ break;
+ default:
+ return Drop("Unknown axis value format");
+ }
+ }
+
+ return true;
+}
+
+bool OpenTypeSTAT::Serialize(OTSStream* out) {
+ off_t tableStart = out->Tell();
+
+ size_t headerSize = 5 * sizeof(uint16_t) + 2 * sizeof(uint32_t);
+ if (this->minorVersion >= 1) {
+ headerSize += sizeof(uint16_t);
+ }
+
+ if (this->designAxisCount == 0) {
+ this->designAxesOffset = 0;
+ } else {
+ this->designAxesOffset = headerSize;
+ }
+
+ this->designAxisSize = sizeof(AxisRecord);
+
+ if (this->axisValueCount == 0) {
+ this->offsetToAxisValueOffsets = 0;
+ } else {
+ if (this->designAxesOffset == 0) {
+ this->offsetToAxisValueOffsets = headerSize;
+ } else {
+ this->offsetToAxisValueOffsets = this->designAxesOffset + this->designAxisCount * this->designAxisSize;
+ }
+ }
+
+ if (!out->WriteU16(this->majorVersion) ||
+ !out->WriteU16(this->minorVersion) ||
+ !out->WriteU16(this->designAxisSize) ||
+ !out->WriteU16(this->designAxisCount) ||
+ !out->WriteU32(this->designAxesOffset) ||
+ !out->WriteU16(this->axisValueCount) ||
+ !out->WriteU32(this->offsetToAxisValueOffsets) ||
+ !(this->minorVersion < 1 || out->WriteU16(this->elidedFallbackNameID))) {
+ return Error("Failed to write table header");
+ }
+
+ if (this->designAxisCount > 0) {
+ if (out->Tell() - tableStart != this->designAxesOffset) {
+ return Error("Error computing designAxesOffset");
+ }
+ }
+
+ for (unsigned i = 0; i < this->designAxisCount; i++) {
+ const auto& axis = this->designAxes[i];
+ if (!out->WriteU32(axis.axisTag) ||
+ !out->WriteU16(axis.axisNameID) ||
+ !out->WriteU16(axis.axisOrdering)) {
+ return Error("Failed to write design axis");
+ }
+ }
+
+ if (this->axisValueCount > 0) {
+ if (out->Tell() - tableStart != this->offsetToAxisValueOffsets) {
+ return Error("Error computing offsetToAxisValueOffsets");
+ }
+ }
+
+ uint32_t axisValueOffset = this->axisValueCount * sizeof(uint16_t);
+ for (unsigned i = 0; i < this->axisValueCount; i++) {
+ const auto& value = this->axisValues[i];
+ if (!out->WriteU16(axisValueOffset)) {
+ return Error("Failed to write axis value offset");
+ }
+ axisValueOffset += value.Length();
+ }
+ for (unsigned i = 0; i < this->axisValueCount; i++) {
+ const auto& value = this->axisValues[i];
+ if (!out->WriteU16(value.format)) {
+ return Error("Failed to write axis value");
+ }
+ switch (value.format) {
+ case 1:
+ if (!out->WriteU16(value.format1.axisIndex) ||
+ !out->WriteU16(value.format1.flags) ||
+ !out->WriteU16(value.format1.valueNameID) ||
+ !out->WriteS32(value.format1.value)) {
+ return Error("Failed to write axis value");
+ }
+ break;
+ case 2:
+ if (!out->WriteU16(value.format2.axisIndex) ||
+ !out->WriteU16(value.format2.flags) ||
+ !out->WriteU16(value.format2.valueNameID) ||
+ !out->WriteS32(value.format2.nominalValue) ||
+ !out->WriteS32(value.format2.rangeMinValue) ||
+ !out->WriteS32(value.format2.rangeMaxValue)) {
+ return Error("Failed to write axis value");
+ }
+ break;
+ case 3:
+ if (!out->WriteU16(value.format3.axisIndex) ||
+ !out->WriteU16(value.format3.flags) ||
+ !out->WriteU16(value.format3.valueNameID) ||
+ !out->WriteS32(value.format3.value) ||
+ !out->WriteS32(value.format3.linkedValue)) {
+ return Error("Failed to write axis value");
+ }
+ break;
+ case 4:
+ if (!out->WriteU16(value.format4.axisCount) ||
+ !out->WriteU16(value.format4.flags) ||
+ !out->WriteU16(value.format4.valueNameID)) {
+ return Error("Failed to write axis value");
+ }
+ for (unsigned j = 0; j < value.format4.axisValues.size(); j++) {
+ if (!out->WriteU16(value.format4.axisValues[j].axisIndex) ||
+ !out->WriteS32(value.format4.axisValues[j].value)) {
+ return Error("Failed to write axis value");
+ }
+ }
+ break;
+ default:
+ return Error("Bad value format");
+ }
+ }
+
+ return true;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/stat.h b/gfx/ots/src/stat.h
new file mode 100644
index 000000000..873d08edc
--- /dev/null
+++ b/gfx/ots/src/stat.h
@@ -0,0 +1,155 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_STAT_H_
+#define OTS_STAT_H_
+
+#include <vector>
+
+#include "ots.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeSTAT Interface
+// -----------------------------------------------------------------------------
+
+class OpenTypeSTAT : public Table {
+ public:
+ explicit OpenTypeSTAT(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ bool ValidateNameId(uint16_t nameid, bool allowPredefined = true);
+
+ uint16_t majorVersion;
+ uint16_t minorVersion;
+ uint16_t designAxisSize;
+ uint16_t designAxisCount;
+ uint32_t designAxesOffset;
+ uint16_t axisValueCount;
+ uint32_t offsetToAxisValueOffsets;
+ uint16_t elidedFallbackNameID;
+
+ struct AxisRecord {
+ uint32_t axisTag;
+ uint16_t axisNameID;
+ uint16_t axisOrdering;
+ };
+ std::vector<AxisRecord> designAxes;
+
+ typedef int32_t Fixed; /* 16.16 fixed-point value */
+
+ struct AxisValueFormat1 {
+ uint16_t axisIndex;
+ uint16_t flags;
+ uint16_t valueNameID;
+ Fixed value;
+ static size_t Length() {
+ return 3 * sizeof(uint16_t) + sizeof(Fixed);
+ }
+ };
+
+ struct AxisValueFormat2 {
+ uint16_t axisIndex;
+ uint16_t flags;
+ uint16_t valueNameID;
+ Fixed nominalValue;
+ Fixed rangeMinValue;
+ Fixed rangeMaxValue;
+ static size_t Length() {
+ return 3 * sizeof(uint16_t) + 3 * sizeof(Fixed);
+ }
+ };
+
+ struct AxisValueFormat3 {
+ uint16_t axisIndex;
+ uint16_t flags;
+ uint16_t valueNameID;
+ Fixed value;
+ Fixed linkedValue;
+ static size_t Length() {
+ return 3 * sizeof(uint16_t) + 2 * sizeof(Fixed);
+ }
+ };
+
+ struct AxisValueFormat4 {
+ uint16_t axisCount;
+ uint16_t flags;
+ uint16_t valueNameID;
+ struct AxisValue {
+ uint16_t axisIndex;
+ Fixed value;
+ };
+ std::vector<AxisValue> axisValues;
+ size_t Length() const {
+ return 3 * sizeof(uint16_t) + axisValues.size() * (sizeof(uint16_t) + sizeof(Fixed));
+ }
+ };
+
+ struct AxisValueRecord {
+ uint16_t format;
+ union {
+ AxisValueFormat1 format1;
+ AxisValueFormat2 format2;
+ AxisValueFormat3 format3;
+ AxisValueFormat4 format4;
+ };
+ explicit AxisValueRecord(uint16_t format_)
+ : format(format_)
+ {
+ if (format == 4) {
+ new (&this->format4) AxisValueFormat4();
+ }
+ }
+ AxisValueRecord(const AxisValueRecord& other_)
+ : format(other_.format)
+ {
+ switch (format) {
+ case 1:
+ format1 = other_.format1;
+ break;
+ case 2:
+ format2 = other_.format2;
+ break;
+ case 3:
+ format3 = other_.format3;
+ break;
+ case 4:
+ new (&this->format4) AxisValueFormat4();
+ format4 = other_.format4;
+ break;
+ }
+ }
+ ~AxisValueRecord() {
+ if (format == 4) {
+ this->format4.~AxisValueFormat4();
+ }
+ }
+ uint32_t Length() const {
+ switch (format) {
+ case 1:
+ return sizeof(uint16_t) + format1.Length();
+ case 2:
+ return sizeof(uint16_t) + format2.Length();
+ case 3:
+ return sizeof(uint16_t) + format3.Length();
+ case 4:
+ return sizeof(uint16_t) + format4.Length();
+ default:
+ // can't happen
+ return 0;
+ }
+ }
+ };
+
+ std::vector<AxisValueRecord> axisValues;
+};
+
+} // namespace ots
+
+#endif // OTS_STAT_H_
diff --git a/gfx/ots/src/variations.cc b/gfx/ots/src/variations.cc
new file mode 100644
index 000000000..cb7e5fb32
--- /dev/null
+++ b/gfx/ots/src/variations.cc
@@ -0,0 +1,261 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "layout.h"
+
+#include "fvar.h"
+
+// OpenType Variations Common Table Formats
+
+#define TABLE_NAME "Variations" // XXX: use individual table names
+
+namespace {
+
+bool ParseVariationRegionList(const ots::Font* font, const uint8_t* data, const size_t length,
+ uint16_t* regionCount) {
+ ots::Buffer subtable(data, length);
+
+ uint16_t axisCount;
+
+ if (!subtable.ReadU16(&axisCount) ||
+ !subtable.ReadU16(regionCount)) {
+ return OTS_FAILURE_MSG("Failed to read variation region list header");
+ }
+
+ if (*regionCount == 0) {
+ return true;
+ }
+
+ const ots::OpenTypeFVAR* fvar =
+ static_cast<ots::OpenTypeFVAR*>(font->GetTypedTable(OTS_TAG_FVAR));
+ if (!fvar) {
+ return OTS_FAILURE_MSG("Required fvar table is missing");
+ }
+ if (axisCount != fvar->AxisCount()) {
+ return OTS_FAILURE_MSG("Axis count mismatch");
+ }
+
+ for (unsigned i = 0; i < *regionCount; i++) {
+ for (unsigned j = 0; j < axisCount; j++) {
+ int16_t startCoord, peakCoord, endCoord;
+ if (!subtable.ReadS16(&startCoord) ||
+ !subtable.ReadS16(&peakCoord) ||
+ !subtable.ReadS16(&endCoord)) {
+ return OTS_FAILURE_MSG("Failed to read region axis coordinates");
+ }
+ if (startCoord > peakCoord || peakCoord > endCoord) {
+ return OTS_FAILURE_MSG("Region axis coordinates out of order");
+ }
+ if (startCoord < -0x4000 || endCoord > 0x4000) {
+ return OTS_FAILURE_MSG("Region axis coordinate out of range");
+ }
+ if ((peakCoord < 0 && endCoord > 0) ||
+ (peakCoord > 0 && startCoord < 0)) {
+ return OTS_FAILURE_MSG("Invalid region axis coordinates");
+ }
+ }
+ }
+
+ return true;
+}
+
+bool
+ParseVariationDataSubtable(const ots::Font* font, const uint8_t* data, const size_t length,
+ const uint16_t regionCount,
+ uint16_t* regionIndexCount) {
+ ots::Buffer subtable(data, length);
+
+ uint16_t itemCount;
+ uint16_t shortDeltaCount;
+
+ if (!subtable.ReadU16(&itemCount) ||
+ !subtable.ReadU16(&shortDeltaCount) ||
+ !subtable.ReadU16(regionIndexCount)) {
+ return OTS_FAILURE_MSG("Failed to read variation data subtable header");
+ }
+
+ for (unsigned i = 0; i < *regionIndexCount; i++) {
+ uint16_t regionIndex;
+ if (!subtable.ReadU16(&regionIndex) || regionIndex >= regionCount) {
+ return OTS_FAILURE_MSG("Bad region index");
+ }
+ }
+
+ if (!subtable.Skip(size_t(itemCount) * (size_t(shortDeltaCount) + size_t(*regionIndexCount)))) {
+ return OTS_FAILURE_MSG("Failed to read delta data");
+ }
+
+ return true;
+}
+
+} // namespace
+
+namespace ots {
+
+bool
+ParseItemVariationStore(const Font* font,
+ const uint8_t* data, const size_t length,
+ std::vector<uint16_t>* regionIndexCounts) {
+ Buffer subtable(data, length);
+
+ uint16_t format;
+ uint32_t variationRegionListOffset;
+ uint16_t itemVariationDataCount;
+
+ if (!subtable.ReadU16(&format) ||
+ !subtable.ReadU32(&variationRegionListOffset) ||
+ !subtable.ReadU16(&itemVariationDataCount)) {
+ return OTS_FAILURE_MSG("Failed to read item variation store header");
+ }
+
+ if (format != 1) {
+ return OTS_FAILURE_MSG("Unknown item variation store format");
+ }
+
+ if (variationRegionListOffset < subtable.offset() + 4 * itemVariationDataCount ||
+ variationRegionListOffset > length) {
+ return OTS_FAILURE_MSG("Invalid variation region list offset");
+ }
+
+ uint16_t regionCount;
+ if (!ParseVariationRegionList(font,
+ data + variationRegionListOffset,
+ length - variationRegionListOffset,
+ &regionCount)) {
+ return OTS_FAILURE_MSG("Failed to parse variation region list");
+ }
+
+ for (unsigned i = 0; i < itemVariationDataCount; i++) {
+ uint32_t offset;
+ if (!subtable.ReadU32(&offset)) {
+ return OTS_FAILURE_MSG("Failed to read variation data subtable offset");
+ }
+ if (offset >= length) {
+ return OTS_FAILURE_MSG("Bad offset to variation data subtable");
+ }
+ uint16_t regionIndexCount = 0;
+ if (!ParseVariationDataSubtable(font, data + offset, length - offset,
+ regionCount,
+ &regionIndexCount)) {
+ return OTS_FAILURE_MSG("Failed to parse variation data subtable");
+ }
+ if (regionIndexCounts) {
+ regionIndexCounts->push_back(regionIndexCount);
+ }
+ }
+
+ return true;
+}
+
+bool ParseDeltaSetIndexMap(const Font* font, const uint8_t* data, const size_t length) {
+ Buffer subtable(data, length);
+
+ uint16_t entryFormat;
+ uint16_t mapCount;
+
+ if (!subtable.ReadU16(&entryFormat) ||
+ !subtable.ReadU16(&mapCount)) {
+ return OTS_FAILURE_MSG("Failed to read delta set index map header");
+ }
+
+ const uint16_t MAP_ENTRY_SIZE_MASK = 0x0030;
+
+ const uint16_t entrySize = (((entryFormat & MAP_ENTRY_SIZE_MASK) >> 4) + 1);
+ if (!subtable.Skip(entrySize * mapCount)) {
+ return OTS_FAILURE_MSG("Failed to read delta set index map data");
+ }
+
+ return true;
+}
+
+bool ParseVariationData(const Font* font, const uint8_t* data, size_t length,
+ size_t axisCount, size_t sharedTupleCount) {
+ Buffer subtable(data, length);
+
+ uint16_t tupleVariationCount;
+ uint16_t dataOffset;
+ if (!subtable.ReadU16(&tupleVariationCount) ||
+ !subtable.ReadU16(&dataOffset)) {
+ return OTS_FAILURE_MSG("Failed to read variation data header");
+ }
+
+ if (dataOffset > length) {
+ return OTS_FAILURE_MSG("Invalid serialized data offset");
+ }
+
+ tupleVariationCount &= 0x0FFF; // mask off flags
+
+ const uint16_t EMBEDDED_PEAK_TUPLE = 0x8000;
+ const uint16_t INTERMEDIATE_REGION = 0x4000;
+ const uint16_t TUPLE_INDEX_MASK = 0x0FFF;
+
+ for (unsigned i = 0; i < tupleVariationCount; i++) {
+ uint16_t variationDataSize;
+ uint16_t tupleIndex;
+
+ if (!subtable.ReadU16(&variationDataSize) ||
+ !subtable.ReadU16(&tupleIndex)) {
+ return OTS_FAILURE_MSG("Failed to read tuple variation header");
+ }
+
+ if (tupleIndex & EMBEDDED_PEAK_TUPLE) {
+ for (unsigned axis = 0; axis < axisCount; axis++) {
+ int16_t coordinate;
+ if (!subtable.ReadS16(&coordinate)) {
+ return OTS_FAILURE_MSG("Failed to read tuple coordinate");
+ }
+ if (coordinate < -0x4000 || coordinate > 0x4000) {
+ return OTS_FAILURE_MSG("Invalid tuple coordinate");
+ }
+ }
+ }
+
+ if (tupleIndex & INTERMEDIATE_REGION) {
+ std::vector<int16_t> startTuple(axisCount);
+ for (unsigned axis = 0; axis < axisCount; axis++) {
+ int16_t coordinate;
+ if (!subtable.ReadS16(&coordinate)) {
+ return OTS_FAILURE_MSG("Failed to read tuple coordinate");
+ }
+ if (coordinate < -0x4000 || coordinate > 0x4000) {
+ return OTS_FAILURE_MSG("Invalid tuple coordinate");
+ }
+ startTuple.push_back(coordinate);
+ }
+
+ std::vector<int16_t> endTuple(axisCount);
+ for (unsigned axis = 0; axis < axisCount; axis++) {
+ int16_t coordinate;
+ if (!subtable.ReadS16(&coordinate)) {
+ return OTS_FAILURE_MSG("Failed to read tuple coordinate");
+ }
+ if (coordinate < -0x4000 || coordinate > 0x4000) {
+ return OTS_FAILURE_MSG("Invalid tuple coordinate");
+ }
+ endTuple.push_back(coordinate);
+ }
+
+ for (unsigned axis = 0; axis < axisCount; axis++) {
+ if (startTuple[axis] > endTuple[axis]) {
+ return OTS_FAILURE_MSG("Invalid intermediate range");
+ }
+ }
+ }
+
+ if (!(tupleIndex & EMBEDDED_PEAK_TUPLE)) {
+ tupleIndex &= TUPLE_INDEX_MASK;
+ if (tupleIndex >= sharedTupleCount) {
+ return OTS_FAILURE_MSG("Tuple index out of range");
+ }
+ }
+ }
+
+ // TODO: we don't attempt to interpret the serialized data block
+
+ return true;
+}
+
+} // namespace ots
+
+#undef TABLE_NAME
diff --git a/gfx/ots/src/variations.h b/gfx/ots/src/variations.h
new file mode 100644
index 000000000..aaaac1784
--- /dev/null
+++ b/gfx/ots/src/variations.h
@@ -0,0 +1,26 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_VARIATIONS_H_
+#define OTS_VARIATIONS_H_
+
+#include <vector>
+#include "ots.h"
+
+// Utility functions for OpenType variations common table formats.
+
+namespace ots {
+
+bool ParseItemVariationStore(const Font* font,
+ const uint8_t* data, const size_t length,
+ std::vector<uint16_t>* out_region_index_count = NULL);
+
+bool ParseDeltaSetIndexMap(const Font* font, const uint8_t* data, const size_t length);
+
+bool ParseVariationData(const Font* font, const uint8_t* data, size_t length,
+ size_t axisCount, size_t sharedTupleCount);
+
+} // namespace ots
+
+#endif // OTS_VARIATIONS_H_
diff --git a/gfx/ots/src/vdmx.cc b/gfx/ots/src/vdmx.cc
index cd80946ae..54055777a 100644
--- a/gfx/ots/src/vdmx.cc
+++ b/gfx/ots/src/vdmx.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,91 +7,75 @@
// VDMX - Vertical Device Metrics
// http://www.microsoft.com/typography/otspec/vdmx.htm
-#define TABLE_NAME "VDMX"
-
-#define DROP_THIS_TABLE(...) \
- do { \
- OTS_FAILURE_MSG_(font->file, TABLE_NAME ": " __VA_ARGS__); \
- OTS_FAILURE_MSG("Table discarded"); \
- delete font->vdmx; \
- font->vdmx = 0; \
- } while (0)
-
namespace ots {
-bool ots_vdmx_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeVDMX::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- font->vdmx = new OpenTypeVDMX;
- OpenTypeVDMX * const vdmx = font->vdmx;
- if (!table.ReadU16(&vdmx->version) ||
- !table.ReadU16(&vdmx->num_recs) ||
- !table.ReadU16(&vdmx->num_ratios)) {
- return OTS_FAILURE_MSG("Failed to read table header");
+ if (!table.ReadU16(&this->version) ||
+ !table.ReadU16(&this->num_recs) ||
+ !table.ReadU16(&this->num_ratios)) {
+ return Error("Failed to read table header");
}
- if (vdmx->version > 1) {
- DROP_THIS_TABLE("bad version: %u", vdmx->version);
- return true; // continue transcoding
+ if (this->version > 1) {
+ return Drop("Unsupported table version: %u", this->version);
}
- vdmx->rat_ranges.reserve(vdmx->num_ratios);
- for (unsigned i = 0; i < vdmx->num_ratios; ++i) {
+ this->rat_ranges.reserve(this->num_ratios);
+ for (unsigned i = 0; i < this->num_ratios; ++i) {
OpenTypeVDMXRatioRecord rec;
if (!table.ReadU8(&rec.charset) ||
!table.ReadU8(&rec.x_ratio) ||
!table.ReadU8(&rec.y_start_ratio) ||
!table.ReadU8(&rec.y_end_ratio)) {
- return OTS_FAILURE_MSG("Failed to read ratio header %d", i);
+ return Error("Failed to read RatioRange record %d", i);
}
if (rec.charset > 1) {
- DROP_THIS_TABLE("bad charset: %u", rec.charset);
- return true;
+ return Drop("Unsupported character set: %u", rec.charset);
}
if (rec.y_start_ratio > rec.y_end_ratio) {
- DROP_THIS_TABLE("bad y ratio");
- return true;
+ return Drop("Bad y ratio");
}
// All values set to zero signal the default grouping to use;
// if present, this must be the last Ratio group in the table.
- if ((i < vdmx->num_ratios - 1u) &&
+ if ((i < this->num_ratios - 1u) &&
(rec.x_ratio == 0) &&
(rec.y_start_ratio == 0) &&
(rec.y_end_ratio == 0)) {
// workaround for fonts which have 2 or more {0, 0, 0} terminators.
- DROP_THIS_TABLE("superfluous terminator found");
- return true;
+ return Drop("Superfluous terminator found");
}
- vdmx->rat_ranges.push_back(rec);
+ this->rat_ranges.push_back(rec);
}
- vdmx->offsets.reserve(vdmx->num_ratios);
+ this->offsets.reserve(this->num_ratios);
const size_t current_offset = table.offset();
// current_offset is less than (2 bytes * 3) + (4 bytes * USHRT_MAX) = 256k.
- for (unsigned i = 0; i < vdmx->num_ratios; ++i) {
+ for (unsigned i = 0; i < this->num_ratios; ++i) {
uint16_t offset;
if (!table.ReadU16(&offset)) {
- return OTS_FAILURE_MSG("Failed to read ratio offset %d", i);
+ return Error("Failed to read ratio offset %d", i);
}
if (current_offset + offset >= length) { // thus doesn't overflow.
- return OTS_FAILURE_MSG("Bad ratio offset %d for ration %d", offset, i);
+ return Error("Bad ratio offset %d for ration %d", offset, i);
}
- vdmx->offsets.push_back(offset);
+ this->offsets.push_back(offset);
}
- vdmx->groups.reserve(vdmx->num_recs);
- for (unsigned i = 0; i < vdmx->num_recs; ++i) {
+ this->groups.reserve(this->num_recs);
+ for (unsigned i = 0; i < this->num_recs; ++i) {
OpenTypeVDMXGroup group;
if (!table.ReadU16(&group.recs) ||
!table.ReadU8(&group.startsz) ||
!table.ReadU8(&group.endsz)) {
- return OTS_FAILURE_MSG("Failed to read record header %d", i);
+ return Error("Failed to read record header %d", i);
}
group.entries.reserve(group.recs);
for (unsigned j = 0; j < group.recs; ++j) {
@@ -99,71 +83,68 @@ bool ots_vdmx_parse(Font *font, const uint8_t *data, size_t length) {
if (!table.ReadU16(&vt.y_pel_height) ||
!table.ReadS16(&vt.y_max) ||
!table.ReadS16(&vt.y_min)) {
- return OTS_FAILURE_MSG("Failed to read reacord %d group %d", i, j);
+ return Error("Failed to read reacord %d group %d", i, j);
}
if (vt.y_max < vt.y_min) {
- DROP_THIS_TABLE("bad y min/max");
- return true;
+ return Drop("bad y min/max");
}
// This table must appear in sorted order (sorted by yPelHeight),
// but need not be continuous.
if ((j != 0) && (group.entries[j - 1].y_pel_height >= vt.y_pel_height)) {
- DROP_THIS_TABLE("the table is not sorted");
- return true;
+ return Drop("The table is not sorted");
}
group.entries.push_back(vt);
}
- vdmx->groups.push_back(group);
+ this->groups.push_back(group);
}
return true;
}
-bool ots_vdmx_should_serialise(Font *font) {
- if (!font->glyf) return false; // this table is not for CFF fonts.
- return font->vdmx != NULL;
+bool OpenTypeVDMX::ShouldSerialize() {
+ return Table::ShouldSerialize() &&
+ // this table is not for CFF fonts.
+ GetFont()->GetTable(OTS_TAG_GLYF) != NULL;
}
-bool ots_vdmx_serialise(OTSStream *out, Font *font) {
- OpenTypeVDMX * const vdmx = font->vdmx;
-
- if (!out->WriteU16(vdmx->version) ||
- !out->WriteU16(vdmx->num_recs) ||
- !out->WriteU16(vdmx->num_ratios)) {
- return OTS_FAILURE_MSG("Failed to write table header");
+bool OpenTypeVDMX::Serialize(OTSStream *out) {
+ if (!out->WriteU16(this->version) ||
+ !out->WriteU16(this->num_recs) ||
+ !out->WriteU16(this->num_ratios)) {
+ return Error("Failed to write table header");
}
- for (unsigned i = 0; i < vdmx->rat_ranges.size(); ++i) {
- const OpenTypeVDMXRatioRecord& rec = vdmx->rat_ranges[i];
+ for (unsigned i = 0; i < this->rat_ranges.size(); ++i) {
+ const OpenTypeVDMXRatioRecord& rec = this->rat_ranges[i];
if (!out->Write(&rec.charset, 1) ||
!out->Write(&rec.x_ratio, 1) ||
!out->Write(&rec.y_start_ratio, 1) ||
!out->Write(&rec.y_end_ratio, 1)) {
- return OTS_FAILURE_MSG("Failed to write ratio %d", i);
+ return Error("Failed to write RatioRange record %d", i);
}
}
- for (unsigned i = 0; i < vdmx->offsets.size(); ++i) {
- if (!out->WriteU16(vdmx->offsets[i])) {
- return OTS_FAILURE_MSG("Failed to write ratio offset %d", i);
+ for (unsigned i = 0; i < this->offsets.size(); ++i) {
+ if (!out->WriteU16(this->offsets[i])) {
+ return Error("Failed to write ratio offset %d", i);
}
}
- for (unsigned i = 0; i < vdmx->groups.size(); ++i) {
- const OpenTypeVDMXGroup& group = vdmx->groups[i];
+ for (unsigned i = 0; i < this->groups.size(); ++i) {
+ const OpenTypeVDMXGroup& group = this->groups[i];
if (!out->WriteU16(group.recs) ||
!out->Write(&group.startsz, 1) ||
!out->Write(&group.endsz, 1)) {
- return OTS_FAILURE_MSG("Failed to write group %d", i);
+ return Error("Failed to write group %d", i);
}
for (unsigned j = 0; j < group.entries.size(); ++j) {
const OpenTypeVDMXVTable& vt = group.entries[j];
if (!out->WriteU16(vt.y_pel_height) ||
!out->WriteS16(vt.y_max) ||
!out->WriteS16(vt.y_min)) {
- return OTS_FAILURE_MSG("Failed to write group %d entry %d", i, j);
+ return Error("Failed to write group %d entry %d", i, j);
}
}
}
@@ -171,16 +152,4 @@ bool ots_vdmx_serialise(OTSStream *out, Font *font) {
return true;
}
-void ots_vdmx_reuse(Font *font, Font *other) {
- font->vdmx = other->vdmx;
- font->vdmx_reused = true;
-}
-
-void ots_vdmx_free(Font *font) {
- delete font->vdmx;
-}
-
} // namespace ots
-
-#undef TABLE_NAME
-#undef DROP_THIS_TABLE
diff --git a/gfx/ots/src/vdmx.h b/gfx/ots/src/vdmx.h
index 1d959efe5..6ccf6dc1b 100644
--- a/gfx/ots/src/vdmx.h
+++ b/gfx/ots/src/vdmx.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,7 +31,16 @@ struct OpenTypeVDMXGroup {
std::vector<OpenTypeVDMXVTable> entries;
};
-struct OpenTypeVDMX {
+class OpenTypeVDMX : public Table {
+ public:
+ explicit OpenTypeVDMX(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool ShouldSerialize();
+
+ private:
uint16_t version;
uint16_t num_recs;
uint16_t num_ratios;
diff --git a/gfx/ots/src/vhea.cc b/gfx/ots/src/vhea.cc
index e721b971e..e44bedf20 100644
--- a/gfx/ots/src/vhea.cc
+++ b/gfx/ots/src/vhea.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,51 +10,30 @@
// vhea - Vertical Header Table
// http://www.microsoft.com/typography/otspec/vhea.htm
-#define TABLE_NAME "vhea"
-
namespace ots {
-bool ots_vhea_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeVHEA::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- OpenTypeVHEA *vhea = new OpenTypeVHEA;
- font->vhea = vhea;
- if (!table.ReadU32(&vhea->header.version)) {
- return OTS_FAILURE_MSG("Failed to read version");
- }
- if (vhea->header.version != 0x00010000 &&
- vhea->header.version != 0x00011000) {
- return OTS_FAILURE_MSG("Bad vhea version %x", vhea->header.version);
+ if (!table.ReadU32(&this->version)) {
+ return Error("Failed to read version");
}
-
- if (!ParseMetricsHeader(font, &table, &vhea->header)) {
- return OTS_FAILURE_MSG("Failed to parse metrics in vhea");
+ if (this->version != 0x00010000 &&
+ this->version != 0x00011000) {
+ return Error("Unsupported table version: 0x%x", this->version);
}
- return true;
+ return OpenTypeMetricsHeader::Parse(data, length);
}
-bool ots_vhea_should_serialise(Font *font) {
- // vhea should'nt serialise when vmtx doesn't exist.
- return font->vhea != NULL && font->vmtx != NULL;
+bool OpenTypeVHEA::Serialize(OTSStream *out) {
+ return OpenTypeMetricsHeader::Serialize(out);
}
-bool ots_vhea_serialise(OTSStream *out, Font *font) {
- if (!SerialiseMetricsHeader(font, out, &font->vhea->header)) {
- return OTS_FAILURE_MSG("Failed to write vhea metrics");
- }
- return true;
-}
-
-void ots_vhea_reuse(Font *font, Font *other) {
- font->vhea = other->vhea;
- font->vhea_reused = true;
-}
-
-void ots_vhea_free(Font *font) {
- delete font->vhea;
+bool OpenTypeVHEA::ShouldSerialize() {
+ return OpenTypeMetricsHeader::ShouldSerialize() &&
+ // vhea shouldn't serialise when vmtx doesn't exist.
+ GetFont()->GetTable(OTS_TAG_VMTX) != NULL;
}
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/vhea.h b/gfx/ots/src/vhea.h
index f8efde731..8776acd11 100644
--- a/gfx/ots/src/vhea.h
+++ b/gfx/ots/src/vhea.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,8 +10,14 @@
namespace ots {
-struct OpenTypeVHEA {
- OpenTypeMetricsHeader header;
+class OpenTypeVHEA : public OpenTypeMetricsHeader {
+ public:
+ explicit OpenTypeVHEA(Font *font, uint32_t tag)
+ : OpenTypeMetricsHeader(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool ShouldSerialize();
};
} // namespace ots
diff --git a/gfx/ots/src/vmtx.cc b/gfx/ots/src/vmtx.cc
index 64a706148..d576ae294 100644
--- a/gfx/ots/src/vmtx.cc
+++ b/gfx/ots/src/vmtx.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,48 +10,20 @@
// vmtx - Vertical Metrics Table
// http://www.microsoft.com/typography/otspec/vmtx.htm
-#define TABLE_NAME "vmtx"
-
namespace ots {
-bool ots_vmtx_parse(Font *font, const uint8_t *data, size_t length) {
- Buffer table(data, length);
- OpenTypeVMTX *vmtx = new OpenTypeVMTX;
- font->vmtx = vmtx;
-
- if (!font->vhea || !font->maxp) {
- return OTS_FAILURE_MSG("vhea or maxp table missing as needed by vmtx");
- }
-
- if (!ParseMetricsTable(font, &table, font->maxp->num_glyphs,
- &font->vhea->header, &vmtx->metrics)) {
- return OTS_FAILURE_MSG("Failed to parse vmtx metrics");
- }
-
- return true;
+bool OpenTypeVMTX::Parse(const uint8_t *data, size_t length) {
+ return OpenTypeMetricsTable::Parse(data, length);
}
-bool ots_vmtx_should_serialise(Font *font) {
- // vmtx should serialise when vhea is preserved.
- return font->vmtx != NULL && font->vhea != NULL;
+bool OpenTypeVMTX::Serialize(OTSStream *out) {
+ return OpenTypeMetricsTable::Serialize(out);
}
-bool ots_vmtx_serialise(OTSStream *out, Font *font) {
- if (!SerialiseMetricsTable(font, out, &font->vmtx->metrics)) {
- return OTS_FAILURE_MSG("Failed to write vmtx metrics");
- }
- return true;
-}
-
-void ots_vmtx_reuse(Font *font, Font *other) {
- font->vmtx = other->vmtx;
- font->vmtx_reused = true;
-}
-
-void ots_vmtx_free(Font *font) {
- delete font->vmtx;
+bool OpenTypeVMTX::ShouldSerialize() {
+ return OpenTypeMetricsTable::ShouldSerialize() &&
+ // vmtx should serialise when vhea is preserved.
+ GetFont()->GetTable(OTS_TAG_VHEA) != NULL;
}
} // namespace ots
-
-#undef TABLE_NAME
diff --git a/gfx/ots/src/vmtx.h b/gfx/ots/src/vmtx.h
index 061dc73ed..b243fe214 100644
--- a/gfx/ots/src/vmtx.h
+++ b/gfx/ots/src/vmtx.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,12 +6,19 @@
#define OTS_VMTX_H_
#include "metrics.h"
+#include "vhea.h"
#include "ots.h"
namespace ots {
-struct OpenTypeVMTX {
- OpenTypeMetricsTable metrics;
+struct OpenTypeVMTX : public OpenTypeMetricsTable {
+ public:
+ explicit OpenTypeVMTX(Font *font, uint32_t tag)
+ : OpenTypeMetricsTable(font, tag, tag, OTS_TAG_VHEA) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool ShouldSerialize();
};
} // namespace ots
diff --git a/gfx/ots/src/vorg.cc b/gfx/ots/src/vorg.cc
index 358923125..3b4b51c53 100644
--- a/gfx/ots/src/vorg.cc
+++ b/gfx/ots/src/vorg.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,37 +9,23 @@
// VORG - Vertical Origin Table
// http://www.microsoft.com/typography/otspec/vorg.htm
-#define TABLE_NAME "VORG"
-
-#define DROP_THIS_TABLE(...) \
- do { \
- OTS_FAILURE_MSG_(font->file, TABLE_NAME ": " __VA_ARGS__); \
- OTS_FAILURE_MSG("Table discarded"); \
- delete font->vorg; \
- font->vorg = 0; \
- } while (0)
-
namespace ots {
-bool ots_vorg_parse(Font *font, const uint8_t *data, size_t length) {
+bool OpenTypeVORG::Parse(const uint8_t *data, size_t length) {
Buffer table(data, length);
- font->vorg = new OpenTypeVORG;
- OpenTypeVORG * const vorg = font->vorg;
uint16_t num_recs;
- if (!table.ReadU16(&vorg->major_version) ||
- !table.ReadU16(&vorg->minor_version) ||
- !table.ReadS16(&vorg->default_vert_origin_y) ||
+ if (!table.ReadU16(&this->major_version) ||
+ !table.ReadU16(&this->minor_version) ||
+ !table.ReadS16(&this->default_vert_origin_y) ||
!table.ReadU16(&num_recs)) {
- return OTS_FAILURE_MSG("Failed to read header");
+ return Error("Failed to read header");
}
- if (vorg->major_version != 1) {
- DROP_THIS_TABLE("bad major version: %u", vorg->major_version);
- return true;
+ if (this->major_version != 1) {
+ return Drop("Unsupported majorVersion: %u", this->major_version);
}
- if (vorg->minor_version != 0) {
- DROP_THIS_TABLE("bad minor version: %u", vorg->minor_version);
- return true;
+ if (this->minor_version != 0) {
+ return Drop("Unsupported minorVersion: %u", this->minor_version);
}
// num_recs might be zero (e.g., DFHSMinchoPro5-W3-Demo.otf).
@@ -48,64 +34,50 @@ bool ots_vorg_parse(Font *font, const uint8_t *data, size_t length) {
}
uint16_t last_glyph_index = 0;
- vorg->metrics.reserve(num_recs);
+ this->metrics.reserve(num_recs);
for (unsigned i = 0; i < num_recs; ++i) {
OpenTypeVORGMetrics rec;
if (!table.ReadU16(&rec.glyph_index) ||
!table.ReadS16(&rec.vert_origin_y)) {
- return OTS_FAILURE_MSG("Failed to read record %d", i);
+ return Error("Failed to read record %d", i);
}
if ((i != 0) && (rec.glyph_index <= last_glyph_index)) {
- DROP_THIS_TABLE("the table is not sorted");
- return true;
+ return Drop("The table is not sorted");
}
last_glyph_index = rec.glyph_index;
- vorg->metrics.push_back(rec);
+ this->metrics.push_back(rec);
}
return true;
}
-bool ots_vorg_should_serialise(Font *font) {
- if (!font->cff) return false; // this table is not for fonts with TT glyphs.
- return font->vorg != NULL;
-}
-
-bool ots_vorg_serialise(OTSStream *out, Font *font) {
- OpenTypeVORG * const vorg = font->vorg;
-
- const uint16_t num_metrics = static_cast<uint16_t>(vorg->metrics.size());
- if (num_metrics != vorg->metrics.size() ||
- !out->WriteU16(vorg->major_version) ||
- !out->WriteU16(vorg->minor_version) ||
- !out->WriteS16(vorg->default_vert_origin_y) ||
+bool OpenTypeVORG::Serialize(OTSStream *out) {
+ const uint16_t num_metrics = static_cast<uint16_t>(this->metrics.size());
+ if (num_metrics != this->metrics.size() ||
+ !out->WriteU16(this->major_version) ||
+ !out->WriteU16(this->minor_version) ||
+ !out->WriteS16(this->default_vert_origin_y) ||
!out->WriteU16(num_metrics)) {
- return OTS_FAILURE_MSG("Failed to write table header");
+ return Error("Failed to write table header");
}
for (uint16_t i = 0; i < num_metrics; ++i) {
- const OpenTypeVORGMetrics& rec = vorg->metrics[i];
+ const OpenTypeVORGMetrics& rec = this->metrics[i];
if (!out->WriteU16(rec.glyph_index) ||
!out->WriteS16(rec.vert_origin_y)) {
- return OTS_FAILURE_MSG("Failed to write record %d", i);
+ return Error("Failed to write record %d", i);
}
}
return true;
}
-void ots_vorg_reuse(Font *font, Font *other) {
- font->vorg = other->vorg;
- font->vorg_reused = true;
-}
-
-void ots_vorg_free(Font *font) {
- delete font->vorg;
+bool OpenTypeVORG::ShouldSerialize() {
+ return Table::ShouldSerialize() &&
+ // this table is not for fonts with TT glyphs.
+ GetFont()->GetTable(OTS_TAG_CFF) != NULL;
}
} // namespace ots
-
-#undef TABLE_NAME
-#undef DROP_THIS_TABLE
diff --git a/gfx/ots/src/vorg.h b/gfx/ots/src/vorg.h
index c3d3ffdae..caffea875 100644
--- a/gfx/ots/src/vorg.h
+++ b/gfx/ots/src/vorg.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -16,7 +16,16 @@ struct OpenTypeVORGMetrics {
int16_t vert_origin_y;
};
-struct OpenTypeVORG {
+class OpenTypeVORG : public Table {
+ public:
+ explicit OpenTypeVORG(Font *font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t *data, size_t length);
+ bool Serialize(OTSStream *out);
+ bool ShouldSerialize();
+
+ private:
uint16_t major_version;
uint16_t minor_version;
int16_t default_vert_origin_y;
diff --git a/gfx/ots/src/vvar.cc b/gfx/ots/src/vvar.cc
new file mode 100644
index 000000000..b47ea479d
--- /dev/null
+++ b/gfx/ots/src/vvar.cc
@@ -0,0 +1,95 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "vvar.h"
+
+#include "variations.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeVVAR
+// -----------------------------------------------------------------------------
+
+bool OpenTypeVVAR::Parse(const uint8_t* data, size_t length) {
+ Buffer table(data, length);
+
+ uint16_t majorVersion;
+ uint16_t minorVersion;
+ uint32_t itemVariationStoreOffset;
+ uint32_t advanceHeightMappingOffset;
+ uint32_t tsbMappingOffset;
+ uint32_t bsbMappingOffset;
+ uint32_t vOrgMappingOffset;
+
+ if (!table.ReadU16(&majorVersion) ||
+ !table.ReadU16(&minorVersion) ||
+ !table.ReadU32(&itemVariationStoreOffset) ||
+ !table.ReadU32(&advanceHeightMappingOffset) ||
+ !table.ReadU32(&tsbMappingOffset) ||
+ !table.ReadU32(&bsbMappingOffset) ||
+ !table.ReadU32(&vOrgMappingOffset)) {
+ return DropVariations("Failed to read table header");
+ }
+
+ if (majorVersion != 1) {
+ return DropVariations("Unknown table version");
+ }
+
+ if (itemVariationStoreOffset > length ||
+ advanceHeightMappingOffset > length ||
+ tsbMappingOffset > length ||
+ bsbMappingOffset > length ||
+ vOrgMappingOffset > length) {
+ return DropVariations("Invalid subtable offset");
+ }
+
+ if (!ParseItemVariationStore(GetFont(), data + itemVariationStoreOffset,
+ length - itemVariationStoreOffset)) {
+ return DropVariations("Failed to parse item variation store");
+ }
+
+ if (advanceHeightMappingOffset) {
+ if (!ParseDeltaSetIndexMap(GetFont(), data + advanceHeightMappingOffset,
+ length - advanceHeightMappingOffset)) {
+ return DropVariations("Failed to parse advance height mappings");
+ }
+ }
+
+ if (tsbMappingOffset) {
+ if (!ParseDeltaSetIndexMap(GetFont(), data + tsbMappingOffset,
+ length - tsbMappingOffset)) {
+ return DropVariations("Failed to parse TSB mappings");
+ }
+ }
+
+ if (bsbMappingOffset) {
+ if (!ParseDeltaSetIndexMap(GetFont(), data + bsbMappingOffset,
+ length - bsbMappingOffset)) {
+ return DropVariations("Failed to parse BSB mappings");
+ }
+ }
+
+ if (vOrgMappingOffset) {
+ if (!ParseDeltaSetIndexMap(GetFont(), data + vOrgMappingOffset,
+ length - vOrgMappingOffset)) {
+ return DropVariations("Failed to parse vOrg mappings");
+ }
+ }
+
+ this->m_data = data;
+ this->m_length = length;
+
+ return true;
+}
+
+bool OpenTypeVVAR::Serialize(OTSStream* out) {
+ if (!out->Write(this->m_data, this->m_length)) {
+ return Error("Failed to write VVAR table");
+ }
+
+ return true;
+}
+
+} // namespace ots
diff --git a/gfx/ots/src/vvar.h b/gfx/ots/src/vvar.h
new file mode 100644
index 000000000..15d435745
--- /dev/null
+++ b/gfx/ots/src/vvar.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2018 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef OTS_VVAR_H_
+#define OTS_VVAR_H_
+
+#include "ots.h"
+
+namespace ots {
+
+// -----------------------------------------------------------------------------
+// OpenTypeVVAR Interface
+// -----------------------------------------------------------------------------
+
+class OpenTypeVVAR : public Table {
+ public:
+ explicit OpenTypeVVAR(Font* font, uint32_t tag)
+ : Table(font, tag, tag) { }
+
+ bool Parse(const uint8_t* data, size_t length);
+ bool Serialize(OTSStream* out);
+
+ private:
+ const uint8_t *m_data;
+ size_t m_length;
+};
+
+} // namespace ots
+
+#endif // OTS_VVAR_H_
diff --git a/gfx/ots/sync.sh b/gfx/ots/sync.sh
index 5a7e54b0a..81738f9e1 100755
--- a/gfx/ots/sync.sh
+++ b/gfx/ots/sync.sh
@@ -20,10 +20,19 @@ echo "Updating include..."
rm -rf include/
cp -r $1/include .
+echo "Updating tests..."
+rm -rf tests/*
+mkdir -p tests
+cp -r $1/tests/*.cc tests
+
echo "Updating README.mozilla..."
REVISION=`cd $1; git log | head -1 | sed "s/commit //"`
-sed -e "s/\(Current revision: \).*/\1$REVISION/" README.mozilla > README.tmp
+VERSION=`cd $1; git describe | cut -d '-' -f 1 | sed 's/v//'`
+sed -e "s/\(Current revision: \).*/\1$REVISION \($VERSION\)/" README.mozilla > README.tmp
mv README.tmp README.mozilla
echo "Applying ots-visibility.patch..."
patch -p3 < ots-visibility.patch
+
+echo "Applying ots-lz4.patch..."
+patch -p3 < ots-lz4.patch
diff --git a/gfx/ots/tests/cff_charstring_test.cc b/gfx/ots/tests/cff_charstring_test.cc
new file mode 100644
index 000000000..18e077e8f
--- /dev/null
+++ b/gfx/ots/tests/cff_charstring_test.cc
@@ -0,0 +1,1588 @@
+// Copyright (c) 2010-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cff_charstring.h"
+
+#include <gtest/gtest.h>
+
+#include <climits>
+#include <vector>
+
+#include "cff.h"
+
+// Returns a biased number for callsubr and callgsubr operators.
+#define GET_SUBR_NUMBER(n) ((n) - 107)
+#define ARRAYSIZE(a) (sizeof(a) / sizeof(a[0]))
+
+namespace {
+
+// A constant which is used in AddSubr function below.
+const int kOpPrefix = INT_MAX;
+
+// Encodes an operator |op| to 1 or more bytes and pushes them to |out_bytes|.
+// Returns true if the conversion succeeds.
+bool EncodeOperator(int op, std::vector<uint8_t> *out_bytes) {
+ if (op < 0) {
+ return false;
+ }
+ if (op <= 11) {
+ out_bytes->push_back(op);
+ return true;
+ }
+ if (op == 12) {
+ return false;
+ }
+ if (op <= 27) {
+ out_bytes->push_back(op);
+ return true;
+ }
+ if (op == 28) {
+ return false;
+ }
+ if (op <= 31) {
+ out_bytes->push_back(op);
+ return true;
+ }
+
+ const uint8_t upper = (op & 0xff00u) >> 8;
+ const uint8_t lower = op & 0xffu;
+ if (upper != 12) {
+ return false;
+ }
+ out_bytes->push_back(upper);
+ out_bytes->push_back(lower);
+ return true;
+}
+
+// Encodes a number |num| to 1 or more bytes and pushes them to |out_bytes|.
+// Returns true if the conversion succeeds. The function does not support 16.16
+// Fixed number.
+bool EncodeNumber(int num, std::vector<uint8_t> *out_bytes) {
+ if (num >= -107 && num <= 107) {
+ out_bytes->push_back(num + 139);
+ return true;
+ }
+ if (num >= 108 && num <= 1131) {
+ const uint8_t v = ((num - 108) / 256) + 247;
+ const uint8_t w = (num - 108) % 256;
+ out_bytes->push_back(v);
+ out_bytes->push_back(w);
+ return true;
+ }
+ if (num <= -108 && num >= -1131) {
+ const uint8_t v = (-(num + 108) / 256) + 251;
+ const uint8_t w = -(num + 108) % 256;
+ out_bytes->push_back(v);
+ out_bytes->push_back(w);
+ return true;
+ }
+ if (num <= 32768 && num >= -32767) {
+ const uint8_t v = (num % 0xff00u) >> 8;
+ const uint8_t w = num % 0xffu;
+ out_bytes->push_back(28);
+ out_bytes->push_back(v);
+ out_bytes->push_back(w);
+ return true;
+ }
+ return false;
+}
+
+// Adds a subroutine |subr| to |out_buffer| and |out_subr|. The contents of the
+// subroutine is copied to |out_buffer|, and then the position of the subroutine
+// in |out_buffer| is written to |out_subr|. Returns true on success.
+bool AddSubr(const int *subr, size_t subr_len,
+ std::vector<uint8_t>* out_buffer, ots::CFFIndex *out_subr) {
+ size_t pre_offset = out_buffer->size();
+ for (size_t i = 0; i < subr_len; ++i) {
+ if (subr[i] != kOpPrefix) {
+ if (!EncodeNumber(subr[i], out_buffer)) {
+ return false;
+ }
+ } else {
+ if (i + 1 == subr_len) {
+ return false;
+ }
+ ++i;
+ if (!EncodeOperator(subr[i], out_buffer)) {
+ return false;
+ }
+ }
+ }
+
+ ++(out_subr->count);
+ out_subr->off_size = 1;
+ if (out_subr->offsets.empty()) {
+ out_subr->offsets.push_back(pre_offset);
+ }
+ out_subr->offsets.push_back(out_buffer->size());
+ return true;
+}
+
+// Validates |char_string| and returns true if it's valid.
+bool Validate(const int *char_string, size_t char_string_len,
+ const int *global_subrs, size_t global_subrs_len,
+ const int *local_subrs, size_t local_subrs_len) {
+ std::vector<uint8_t> buffer;
+ ots::CFFIndex* char_strings_index = new ots::CFFIndex;
+ ots::CFFIndex global_subrs_index;
+ ots::CFFIndex* local_subrs_index = new ots::CFFIndex;
+
+ if (char_string) {
+ if (!AddSubr(char_string, char_string_len,
+ &buffer, char_strings_index)) {
+ return false;
+ }
+ }
+ if (global_subrs) {
+ if (!AddSubr(global_subrs, global_subrs_len,
+ &buffer, &global_subrs_index)) {
+ return false;
+ }
+ }
+ if (local_subrs) {
+ if (!AddSubr(local_subrs, local_subrs_len,
+ &buffer, local_subrs_index)) {
+ return false;
+ }
+ }
+
+ ots::Buffer ots_buffer(&buffer[0], buffer.size());
+
+ ots::FontFile* file = new ots::FontFile();
+ file->context = new ots::OTSContext();
+ ots::Font* font = new ots::Font(file);
+ ots::OpenTypeCFF* cff = new ots::OpenTypeCFF(font, OTS_TAG_CFF);
+ cff->charstrings_index = char_strings_index;
+ cff->local_subrs = local_subrs_index;
+ bool ret = ots::ValidateCFFCharStrings(*cff,
+ global_subrs_index,
+ &ots_buffer);
+ delete file->context;
+ delete file;
+ delete font;
+ delete cff;
+
+ return ret;
+}
+
+// Validates |char_string| and returns true if it's valid.
+bool ValidateCharStrings(const int *char_string, size_t char_string_len) {
+ return Validate(char_string, char_string_len, NULL, 0, NULL, 0);
+}
+
+} // namespace
+
+TEST(ValidateTest, TestRMoveTo) {
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kRMoveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, // width
+ 1, 2, kOpPrefix, ots::kRMoveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kRMoveTo,
+ 1, 2, 3, kOpPrefix, ots::kRMoveTo, // invalid number of args
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestHMoveTo) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kHMoveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, // width
+ 1, kOpPrefix, ots::kHMoveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kHMoveTo,
+ 1, 2, kOpPrefix, ots::kHMoveTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestVMoveTo) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, // width
+ 1, kOpPrefix, ots::kVMoveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, kOpPrefix, ots::kVMoveTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestRLineTo) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, kOpPrefix, ots::kRLineTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, kOpPrefix, ots::kRLineTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, kOpPrefix, ots::kRLineTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kRLineTo, // can't be the first op.
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestHLineTo) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, kOpPrefix, ots::kHLineTo,
+ 1, 2, kOpPrefix, ots::kHLineTo,
+ 1, 2, 3, kOpPrefix, ots::kHLineTo,
+ 1, 2, 3, 4, kOpPrefix, ots::kHLineTo,
+ 1, 2, 3, 4, 5, kOpPrefix, ots::kHLineTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ kOpPrefix, ots::kHLineTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kHLineTo, // can't be the first op.
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestVLineTo) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, kOpPrefix, ots::kVLineTo,
+ 1, 2, kOpPrefix, ots::kVLineTo,
+ 1, 2, 3, kOpPrefix, ots::kVLineTo,
+ 1, 2, 3, 4, kOpPrefix, ots::kVLineTo,
+ 1, 2, 3, 4, 5, kOpPrefix, ots::kVLineTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ kOpPrefix, ots::kVLineTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVLineTo, // can't be the first op.
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestRRCurveTo) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, kOpPrefix, ots::kRRCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, kOpPrefix, ots::kRRCurveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ kOpPrefix, ots::kRRCurveTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, 5, 6, kOpPrefix, ots::kRRCurveTo, // can't be the first op.
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestHHCurveTo) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, kOpPrefix, ots::kHHCurveTo,
+ 1, 2, 3, 4, 5, kOpPrefix, ots::kHHCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kHHCurveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, kOpPrefix, ots::kHHCurveTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, kOpPrefix, ots::kHHCurveTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, 5, kOpPrefix, ots::kHHCurveTo, // can't be the first op.
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestHVCurveTo) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ // The first form.
+ 1, 2, 3, 4, kOpPrefix, ots::kHVCurveTo,
+ 1, 2, 3, 4, 5, kOpPrefix, ots::kHVCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, kOpPrefix, ots::kHVCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+ kOpPrefix, ots::kHVCurveTo,
+ // The second form.
+ 1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kHVCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kHVCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
+ kOpPrefix, ots::kHVCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+ 22, 23, 24, 25, kOpPrefix, ots::kHVCurveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, kOpPrefix, ots::kHVCurveTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, kOpPrefix, ots::kHVCurveTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, kOpPrefix, ots::kHVCurveTo, // can't be the first op.
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestRCurveLine) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kRCurveLine,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ kOpPrefix, ots::kRCurveLine,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, 7, kOpPrefix, ots::kRCurveLine, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ // can't be the first op.
+ 1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kRCurveLine,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestRLineCurve) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kRLineCurve,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, kOpPrefix, ots::kRLineCurve,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, 7, kOpPrefix, ots::kRLineCurve, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ // can't be the first op.
+ 1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kRLineCurve,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestVHCurveTo) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ // The first form.
+ 1, 2, 3, 4, kOpPrefix, ots::kVHCurveTo,
+ 1, 2, 3, 4, 5, kOpPrefix, ots::kVHCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, kOpPrefix, ots::kVHCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+ kOpPrefix, ots::kVHCurveTo,
+ // The second form.
+ 1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kVHCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kVHCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
+ kOpPrefix, ots::kVHCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+ 22, 23, 24, 25, kOpPrefix, ots::kVHCurveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, kOpPrefix, ots::kVHCurveTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, kOpPrefix, ots::kVHCurveTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, kOpPrefix, ots::kVHCurveTo, // can't be the first op.
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestVVCurveTo) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, kOpPrefix, ots::kVVCurveTo,
+ 1, 2, 3, 4, 5, kOpPrefix, ots::kVVCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kVVCurveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kVVCurveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ kOpPrefix, ots::kVVCurveTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, kOpPrefix, ots::kVVCurveTo, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, kOpPrefix, ots::kVVCurveTo, // can't be the first op.
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestFlex) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, kOpPrefix, ots::kFlex,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ kOpPrefix, ots::kFlex, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, kOpPrefix, ots::kFlex, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, kOpPrefix, ots::kFlex,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestHFlex) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, 7, kOpPrefix, ots::kHFlex,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ kOpPrefix, ots::kHFlex, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, kOpPrefix, ots::kHFlex, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, 5, 6, 7, kOpPrefix, ots::kHFlex,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestHFlex1) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kHFlex1,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ kOpPrefix, ots::kHFlex1, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kHFlex1, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kHFlex1,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestFlex1) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, kOpPrefix, ots::kFlex1,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ kOpPrefix, ots::kFlex1, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, kOpPrefix, ots::kFlex1, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, kOpPrefix, ots::kFlex1,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestEndChar) {
+ {
+ const int char_string[] = {
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
+ };
+ const int local_subrs[] = {
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(Validate(char_string, ARRAYSIZE(char_string),
+ NULL, 0,
+ local_subrs, ARRAYSIZE(local_subrs)));
+ }
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
+ };
+ const int global_subrs[] = {
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(Validate(char_string, ARRAYSIZE(char_string),
+ global_subrs, ARRAYSIZE(global_subrs),
+ NULL, 0));
+ }
+}
+
+TEST(ValidateTest, TestHStem) {
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 0, // width
+ 1, 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 0, 1, 2, kOpPrefix, ots::kHStem, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, kOpPrefix, ots::kHStem, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestVStem) {
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kVStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, kOpPrefix, ots::kVStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 0, // width
+ 1, 2, kOpPrefix, ots::kVStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 0, 1, 2, kOpPrefix, ots::kVStem, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, kOpPrefix, ots::kVStem, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestHStemHm) {
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kHStemHm,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, kOpPrefix, ots::kHStemHm,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 0, // width
+ 1, 2, kOpPrefix, ots::kHStemHm,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 0, 1, 2, kOpPrefix, ots::kHStemHm, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, kOpPrefix, ots::kHStemHm, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestVStemHm) {
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kVStemHm,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, kOpPrefix, ots::kVStemHm,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 0, // width
+ 1, 2, kOpPrefix, ots::kVStemHm,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 0, 1, 2, kOpPrefix, ots::kVStemHm, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kVMoveTo,
+ 1, 2, 3, 4, 5, kOpPrefix, ots::kVStemHm, // invalid
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestHintMask) {
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kHintMask, 0x00,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kHStem,
+ 3, 4, 5, 6, kOpPrefix, ots::kHintMask, 0x00, // vstem
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ kOpPrefix, ots::kHintMask, 0x00, // no stems to mask
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kHStem,
+ 3, 4, 5, kOpPrefix, ots::kHintMask, 0x00, // invalid vstem
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestCntrMask) {
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kCntrMask, 0x00,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kHStem,
+ 3, 4, 5, 6, kOpPrefix, ots::kCntrMask, 0x00, // vstem
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ kOpPrefix, ots::kCntrMask, 0x00, // no stems to mask
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, kOpPrefix, ots::kHStem,
+ 3, 4, 5, kOpPrefix, ots::kCntrMask, 0x00, // invalid vstem
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestAbs) {
+ {
+ const int char_string[] = {
+ -1, kOpPrefix, ots::kAbs,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ kOpPrefix, ots::kAbs, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestAdd) {
+ {
+ const int char_string[] = {
+ 0, 1, kOpPrefix, ots::kAdd,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kAdd, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestSub) {
+ {
+ const int char_string[] = {
+ 2, 1, kOpPrefix, ots::kSub,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kSub, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestDiv) {
+ // TODO(yusukes): Test div-by-zero.
+ {
+ const int char_string[] = {
+ 2, 1, kOpPrefix, ots::kDiv,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kDiv, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestNeg) {
+ {
+ const int char_string[] = {
+ -1, kOpPrefix, ots::kNeg,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ kOpPrefix, ots::kNeg, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestRandom) {
+ {
+ const int char_string[] = {
+ kOpPrefix, ots::kRandom, // OTS rejects the operator.
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestMul) {
+ {
+ const int char_string[] = {
+ 2, 1, kOpPrefix, ots::kMul,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kMul, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestSqrt) {
+ // TODO(yusukes): Test negative numbers.
+ {
+ const int char_string[] = {
+ 4, kOpPrefix, ots::kSqrt,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ kOpPrefix, ots::kSqrt, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestDrop) {
+ {
+ const int char_string[] = {
+ 1, 1, kOpPrefix, ots::kAdd,
+ kOpPrefix, ots::kDrop,
+ 1, 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ kOpPrefix, ots::kDrop, // invalid
+ 1, 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestExch) {
+ {
+ const int char_string[] = {
+ 1, 1, kOpPrefix, ots::kAdd,
+ kOpPrefix, ots::kDup,
+ kOpPrefix, ots::kExch,
+ kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 1, kOpPrefix, ots::kAdd,
+ kOpPrefix, ots::kExch, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestIndex) {
+ {
+ const int char_string[] = {
+ 1, 2, 3, -1, kOpPrefix, ots::kIndex, // OTS rejects the operator.
+ kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestRoll) {
+ {
+ const int char_string[] = {
+ 1, 2, 2, 1, kOpPrefix, ots::kRoll, // OTS rejects the operator.
+ kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestDup) {
+ {
+ const int char_string[] = {
+ 1, 1, kOpPrefix, ots::kAdd,
+ kOpPrefix, ots::kDup,
+ kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ kOpPrefix, ots::kDup, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestPut) {
+ {
+ const int char_string[] = {
+ 1, 10, kOpPrefix, ots::kPut, // OTS rejects the operator.
+ 1, 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestGet) {
+ {
+ const int char_string[] = {
+ 1, 10, kOpPrefix, ots::kGet, // OTS rejects the operator.
+ 1, 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestAnd) {
+ {
+ const int char_string[] = {
+ 2, 1, kOpPrefix, ots::kAnd,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kAnd, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestOr) {
+ {
+ const int char_string[] = {
+ 2, 1, kOpPrefix, ots::kOr,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kOr, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestNot) {
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kNot,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ kOpPrefix, ots::kNot, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestEq) {
+ {
+ const int char_string[] = {
+ 2, 1, kOpPrefix, ots::kEq,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, kOpPrefix, ots::kEq, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestIfElse) {
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, kOpPrefix, ots::kIfElse,
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, kOpPrefix, ots::kIfElse, // invalid
+ 2, kOpPrefix, ots::kHStem,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestCallSubr) {
+ // Call valid subr.
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
+ };
+ const int local_subrs[] = {
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(Validate(char_string, ARRAYSIZE(char_string),
+ NULL, 0,
+ local_subrs, ARRAYSIZE(local_subrs)));
+ }
+ // Call undefined subr.
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(-1), kOpPrefix, ots::kCallSubr,
+ };
+ const int local_subrs[] = {
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
+ NULL, 0,
+ local_subrs, ARRAYSIZE(local_subrs)));
+ }
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(1), kOpPrefix, ots::kCallSubr,
+ };
+ const int local_subrs[] = {
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
+ NULL, 0,
+ local_subrs, ARRAYSIZE(local_subrs)));
+ }
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(-1), kOpPrefix, ots::kCallSubr,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(1), kOpPrefix, ots::kCallSubr,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestCallGSubr) {
+ // Call valid subr.
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
+ };
+ const int global_subrs[] = {
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(Validate(char_string, ARRAYSIZE(char_string),
+ global_subrs, ARRAYSIZE(global_subrs),
+ NULL, 0));
+ }
+ // Call undefined subr.
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(-1), kOpPrefix, ots::kCallGSubr,
+ };
+ const int global_subrs[] = {
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
+ global_subrs, ARRAYSIZE(global_subrs),
+ NULL, 0));
+ }
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(1), kOpPrefix, ots::kCallGSubr,
+ };
+ const int global_subrs[] = {
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
+ global_subrs, ARRAYSIZE(global_subrs),
+ NULL, 0));
+ }
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(-1), kOpPrefix, ots::kCallGSubr,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(1), kOpPrefix, ots::kCallGSubr,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestCallGSubrWithComputedValues) {
+ {
+ // OTS does not allow to call(g)subr with a subroutine number which is
+ // not a immediate value for safety.
+ const int char_string[] = {
+ 0, 0, kOpPrefix, ots::kAdd,
+ kOpPrefix, ots::kCallGSubr,
+ };
+ const int global_subrs[] = {
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
+ global_subrs, ARRAYSIZE(global_subrs),
+ NULL, 0));
+ }
+}
+
+TEST(ValidateTest, TestInfiniteLoop) {
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
+ };
+ const int local_subrs[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
+ };
+ EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
+ NULL, 0,
+ local_subrs, ARRAYSIZE(local_subrs)));
+ }
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
+ };
+ const int global_subrs[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
+ };
+ EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
+ global_subrs, ARRAYSIZE(global_subrs),
+ NULL, 0));
+ }
+ // mutual recursion which doesn't stop.
+ {
+ const int char_string[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
+ };
+ const int global_subrs[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
+ };
+ const int local_subrs[] = {
+ GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
+ };
+ EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
+ global_subrs, ARRAYSIZE(global_subrs),
+ local_subrs, ARRAYSIZE(local_subrs)));
+ }
+}
+
+TEST(ValidateTest, TestStackOverflow) {
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 1, 2, 3, 4, 5, 6, 7, 8,
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, // overflow
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestDeprecatedOperators) {
+ {
+ const int char_string[] = {
+ kOpPrefix, 16, // 'blend'.
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ kOpPrefix, (12 << 8) + 8, // 'store'.
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ kOpPrefix, (12 << 8) + 13, // 'load'.
+ kOpPrefix, ots::kEndChar,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
+
+TEST(ValidateTest, TestUnterminatedCharString) {
+ // No endchar operator.
+ {
+ const int char_string[] = {
+ 123,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 123, 456,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+ {
+ const int char_string[] = {
+ 123, 456, kOpPrefix, ots::kReturn,
+ };
+ EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
+ }
+}
diff --git a/gfx/ots/tests/layout_common_table_test.cc b/gfx/ots/tests/layout_common_table_test.cc
new file mode 100644
index 000000000..91e429741
--- /dev/null
+++ b/gfx/ots/tests/layout_common_table_test.cc
@@ -0,0 +1,770 @@
+// Copyright (c) 2011-2017 The OTS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cmath>
+#include <vector>
+#include <gtest/gtest.h>
+
+#include "layout.h"
+#include "ots-memory-stream.h"
+
+namespace {
+
+const uint32_t kFakeTag = 0x00000000;
+const size_t kScriptRecordSize = 6;
+const size_t kLangSysRecordSize = 6;
+
+bool BuildFakeScriptListTable(ots::OTSStream *out, const uint16_t script_count,
+ const uint16_t langsys_count,
+ const uint16_t feature_count) {
+ if (!out->WriteU16(script_count)) {
+ return false;
+ }
+ const off_t script_record_end = out->Tell() +
+ kScriptRecordSize * script_count;
+ const size_t script_table_size = 4 + kLangSysRecordSize * langsys_count;
+ for (unsigned i = 0; i < script_count; ++i) {
+ if (!out->WriteU32(kFakeTag) ||
+ !out->WriteU16(script_record_end + i * script_table_size)) {
+ return false;
+ }
+ }
+
+ // Offsets to LangSys tables are measured from the beginning of each
+ // script table.
+ const off_t langsys_record_end = 4 + kLangSysRecordSize * langsys_count;
+ const size_t langsys_table_size = 6 + 2 * feature_count;
+ // Write Fake Script tables.
+ for (unsigned i = 0; i < script_count; ++i) {
+ if (!out->WriteU16(0x0000) ||
+ !out->WriteU16(langsys_count)) {
+ return false;
+ }
+ for (unsigned j = 0; j < langsys_count; ++j) {
+ if (!out->WriteU32(kFakeTag) ||
+ !out->WriteU16(langsys_record_end + j * langsys_table_size)) {
+ return false;
+ }
+ }
+ }
+
+ // Write Fake LangSys tables.
+ for (unsigned i = 0; i < langsys_count; ++i) {
+ if (!out->WriteU16(0x0000) ||
+ !out->WriteU16(0xFFFF) ||
+ !out->WriteU16(feature_count)) {
+ return false;
+ }
+ for (unsigned j = 0; j < feature_count; ++j) {
+ if (!out->WriteU16(j)) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+const size_t kFeatureRecordSize = 6;
+
+bool BuildFakeFeatureListTable(ots::OTSStream *out,
+ const uint16_t feature_count,
+ const uint16_t lookup_count) {
+ if (!out->WriteU16(feature_count)) {
+ return false;
+ }
+ const off_t feature_record_end = out->Tell() +
+ kFeatureRecordSize * feature_count;
+ const size_t feature_table_size = 4 + 2 * lookup_count;
+ for (unsigned i = 0; i < feature_count; ++i) {
+ if (!out->WriteU32(kFakeTag) ||
+ !out->WriteU16(feature_record_end + i * feature_table_size)) {
+ return false;
+ }
+ }
+
+ // Write FeatureTable
+ for (unsigned i = 0; i < feature_count; ++i) {
+ if (!out->WriteU16(0x0000) ||
+ !out->WriteU16(lookup_count)) {
+ return false;
+ }
+ for (uint16_t j = 0; j < lookup_count; ++j) {
+ if (!out->WriteU16(j)) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+bool BuildFakeLookupListTable(ots::OTSStream *out, const uint16_t lookup_count,
+ const uint16_t subtable_count) {
+ if (!out->WriteU16(lookup_count)) {
+ return false;
+ }
+ const off_t base_offset_lookup = out->Tell();
+ if (!out->Pad(2 * lookup_count)) {
+ return false;
+ }
+
+ std::vector<off_t> offsets_lookup(lookup_count, 0);
+ for (uint16_t i = 0; i < lookup_count; ++i) {
+ offsets_lookup[i] = out->Tell();
+ if (!out->WriteU16(i + 1) ||
+ !out->WriteU16(0) ||
+ !out->WriteU16(subtable_count) ||
+ !out->Pad(2 * subtable_count) ||
+ !out->WriteU16(0)) {
+ return false;
+ }
+ }
+
+ const off_t offset_lookup_table_end = out->Tell();
+ // Allocate 256 bytes for each subtable.
+ if (!out->Pad(256 * lookup_count * subtable_count)) {
+ return false;
+ }
+
+ if (!out->Seek(base_offset_lookup)) {
+ return false;
+ }
+ for (unsigned i = 0; i < lookup_count; ++i) {
+ if (!out->WriteU16(offsets_lookup[i])) {
+ return false;
+ }
+ }
+
+ for (unsigned i = 0; i < lookup_count; ++i) {
+ if (!out->Seek(offsets_lookup[i] + 6)) {
+ return false;
+ }
+ for (unsigned j = 0; j < subtable_count; ++j) {
+ if (!out->WriteU16(offset_lookup_table_end +
+ 256*i*subtable_count + 256*j)) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+bool BuildFakeCoverageFormat1(ots::OTSStream *out, const uint16_t glyph_count) {
+ if (!out->WriteU16(1) || !out->WriteU16(glyph_count)) {
+ return false;
+ }
+ for (uint16_t glyph_id = 1; glyph_id <= glyph_count; ++glyph_id) {
+ if (!out->WriteU16(glyph_id)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool BuildFakeCoverageFormat2(ots::OTSStream *out, const uint16_t range_count) {
+ if (!out->WriteU16(2) || !out->WriteU16(range_count)) {
+ return false;
+ }
+ uint16_t glyph_id = 1;
+ uint16_t start_coverage_index = 0;
+ for (unsigned i = 0; i < range_count; ++i) {
+ // Write consecutive ranges in which each range consists of two glyph id.
+ if (!out->WriteU16(glyph_id) ||
+ !out->WriteU16(glyph_id + 1) ||
+ !out->WriteU16(start_coverage_index)) {
+ return false;
+ }
+ glyph_id += 2;
+ start_coverage_index += 2;
+ }
+ return true;
+}
+
+bool BuildFakeClassDefFormat1(ots::OTSStream *out, const uint16_t glyph_count) {
+ if (!out->WriteU16(1) ||
+ !out->WriteU16(1) ||
+ !out->WriteU16(glyph_count)) {
+ return false;
+ }
+ for (uint16_t class_value = 1; class_value <= glyph_count; ++class_value) {
+ if (!out->WriteU16(class_value)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool BuildFakeClassDefFormat2(ots::OTSStream *out, const uint16_t range_count) {
+ if (!out->WriteU16(2) || !out->WriteU16(range_count)) {
+ return false;
+ }
+ uint16_t glyph_id = 1;
+ for (uint16_t class_value = 1; class_value <= range_count; ++class_value) {
+ // Write consecutive ranges in which each range consists of one glyph id.
+ if (!out->WriteU16(glyph_id) ||
+ !out->WriteU16(glyph_id + 1) ||
+ !out->WriteU16(class_value)) {
+ return false;
+ }
+ glyph_id += 2;
+ }
+ return true;
+}
+
+bool BuildFakeDeviceTable(ots::OTSStream *out, const uint16_t start_size,
+ const uint16_t end_size, const uint16_t format) {
+ if (!out->WriteU16(start_size) ||
+ !out->WriteU16(end_size) ||
+ !out->WriteU16(format)) {
+ return false;
+ }
+
+ const unsigned num_values = std::abs(end_size - start_size) + 1;
+ const unsigned num_bits = (1 << format) * num_values;
+ const unsigned num_units = (num_bits - 1) / 16 + 1;
+ if (!out->Pad(num_units * 2)) {
+ return false;
+ }
+ return true;
+}
+
+class TestStream : public ots::MemoryStream {
+ public:
+ TestStream()
+ : ots::MemoryStream(data_, sizeof(data_)), size_(0) {
+ std::memset(reinterpret_cast<char*>(data_), 0, sizeof(data_));
+ }
+
+ uint8_t* data() { return data_; }
+ size_t size() const { return size_; }
+
+ virtual bool WriteRaw(const void *d, size_t length) {
+ if (Tell() + length > size_) {
+ size_ = Tell() + length;
+ }
+ return ots::MemoryStream::WriteRaw(d, length);
+ }
+
+ private:
+ size_t size_;
+ uint8_t data_[4096];
+};
+
+class TableTest : public ::testing::Test {
+ protected:
+
+ virtual void SetUp() {
+ ots::FontFile *file = new ots::FontFile();
+ file->context = new ots::OTSContext();
+ font = new ots::Font(file);
+ }
+
+ virtual void TearDown() {
+ delete font->file->context;
+ delete font->file;
+ delete font;
+ }
+
+ TestStream out;
+ ots::Font *font;
+};
+
+class ScriptListTableTest : public TableTest { };
+class DeviceTableTest : public TableTest { };
+class CoverageTableTest : public TableTest { };
+class CoverageFormat1Test : public TableTest { };
+class CoverageFormat2Test : public TableTest { };
+class ClassDefTableTest : public TableTest { };
+class ClassDefFormat1Test : public TableTest { };
+class ClassDefFormat2Test : public TableTest { };
+class LookupSubtableParserTest : public TableTest { };
+
+class FeatureListTableTest : public TableTest {
+ protected:
+
+ virtual void SetUp() {
+ TableTest::SetUp();
+ num_features = 0;
+ }
+
+ uint16_t num_features;
+};
+
+bool fakeTypeParserReturnsTrue(const ots::Font*, const uint8_t *,
+ const size_t) {
+ return true;
+}
+
+bool fakeTypeParserReturnsFalse(const ots::Font*, const uint8_t *,
+ const size_t) {
+ return false;
+}
+
+const ots::LookupSubtableParser::TypeParser TypeParsersReturnTrue[] = {
+ {1, fakeTypeParserReturnsTrue},
+ {2, fakeTypeParserReturnsTrue},
+ {3, fakeTypeParserReturnsTrue},
+ {4, fakeTypeParserReturnsTrue},
+ {5, fakeTypeParserReturnsTrue}
+};
+
+// Fake lookup subtable parser which always returns true.
+const ots::LookupSubtableParser FakeLookupParserReturnsTrue = {
+ 5, 5, TypeParsersReturnTrue,
+};
+
+const ots::LookupSubtableParser::TypeParser TypeParsersReturnFalse[] = {
+ {1, fakeTypeParserReturnsFalse}
+};
+
+// Fake lookup subtable parser which always returns false.
+const ots::LookupSubtableParser FakeLookupParserReturnsFalse = {
+ 1, 1, TypeParsersReturnFalse
+};
+
+class LookupListTableTest : public TableTest {
+ protected:
+
+ virtual void SetUp() {
+ TableTest::SetUp();
+ num_lookups = 0;
+ }
+
+ bool Parse() {
+ return ots::ParseLookupListTable(font, out.data(), out.size(),
+ &FakeLookupParserReturnsTrue,
+ &num_lookups);
+ }
+
+ uint16_t num_lookups;
+};
+
+} // namespace
+
+TEST_F(ScriptListTableTest, TestSuccess) {
+ BuildFakeScriptListTable(&out, 1, 1, 1);
+ EXPECT_TRUE(ots::ParseScriptListTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(ScriptListTableTest, TestBadScriptCount) {
+ BuildFakeScriptListTable(&out, 1, 1, 1);
+ // Set too large script count.
+ out.Seek(0);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseScriptListTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(ScriptListTableTest, TestScriptRecordOffsetUnderflow) {
+ BuildFakeScriptListTable(&out, 1, 1, 1);
+ // Set bad offset to ScriptRecord[0].
+ out.Seek(6);
+ out.WriteU16(0);
+ EXPECT_FALSE(ots::ParseScriptListTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(ScriptListTableTest, TestScriptRecordOffsetOverflow) {
+ BuildFakeScriptListTable(&out, 1, 1, 1);
+ // Set bad offset to ScriptRecord[0].
+ out.Seek(6);
+ out.WriteU16(out.size());
+ EXPECT_FALSE(ots::ParseScriptListTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(ScriptListTableTest, TestBadLangSysCount) {
+ BuildFakeScriptListTable(&out, 1, 1, 1);
+ // Set too large langsys count.
+ out.Seek(10);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseScriptListTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(ScriptListTableTest, TestLangSysRecordOffsetUnderflow) {
+ BuildFakeScriptListTable(&out, 1, 1, 1);
+ // Set bad offset to LangSysRecord[0].
+ out.Seek(16);
+ out.WriteU16(0);
+ EXPECT_FALSE(ots::ParseScriptListTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(ScriptListTableTest, TestLangSysRecordOffsetOverflow) {
+ BuildFakeScriptListTable(&out, 1, 1, 1);
+ // Set bad offset to LangSysRecord[0].
+ out.Seek(16);
+ out.WriteU16(out.size());
+ EXPECT_FALSE(ots::ParseScriptListTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(ScriptListTableTest, TestBadReqFeatureIndex) {
+ BuildFakeScriptListTable(&out, 1, 1, 1);
+ // Set too large feature index to ReqFeatureIndex of LangSysTable[0].
+ out.Seek(20);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseScriptListTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(ScriptListTableTest, TestBadFeatureCount) {
+ BuildFakeScriptListTable(&out, 1, 1, 1);
+ // Set too large feature count to LangSysTable[0].
+ out.Seek(22);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseScriptListTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(ScriptListTableTest, TestBadFeatureIndex) {
+ BuildFakeScriptListTable(&out, 1, 1, 1);
+ // Set too large feature index to ReatureIndex[0] of LangSysTable[0].
+ out.Seek(24);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseScriptListTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(FeatureListTableTest, TestSuccess) {
+ BuildFakeFeatureListTable(&out, 1, 1);
+ EXPECT_TRUE(ots::ParseFeatureListTable(font, out.data(), out.size(), 1,
+ &num_features));
+ EXPECT_EQ(num_features, 1);
+}
+
+TEST_F(FeatureListTableTest, TestSuccess2) {
+ BuildFakeFeatureListTable(&out, 5, 1);
+ EXPECT_TRUE(ots::ParseFeatureListTable(font, out.data(), out.size(), 1,
+ &num_features));
+ EXPECT_EQ(num_features, 5);
+}
+
+TEST_F(FeatureListTableTest, TestBadFeatureCount) {
+ BuildFakeFeatureListTable(&out, 1, 1);
+ // Set too large feature count.
+ out.Seek(0);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseFeatureListTable(font, out.data(), out.size(), 1,
+ &num_features));
+}
+
+TEST_F(FeatureListTableTest, TestOffsetFeatureUnderflow) {
+ BuildFakeFeatureListTable(&out, 1, 1);
+ // Set bad offset to FeatureRecord[0].
+ out.Seek(6);
+ out.WriteU16(0);
+ EXPECT_FALSE(ots::ParseFeatureListTable(font, out.data(), out.size(), 1,
+ &num_features));
+}
+
+TEST_F(FeatureListTableTest, TestOffsetFeatureOverflow) {
+ BuildFakeFeatureListTable(&out, 1, 1);
+ // Set bad offset to FeatureRecord[0].
+ out.Seek(6);
+ out.WriteU16(out.size());
+ EXPECT_FALSE(ots::ParseFeatureListTable(font, out.data(), out.size(), 1,
+ &num_features));
+}
+
+TEST_F(FeatureListTableTest, TestBadLookupCount) {
+ BuildFakeFeatureListTable(&out, 1, 1);
+ // Set too large lookup count to FeatureTable[0].
+ out.Seek(10);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseFeatureListTable(font, out.data(), out.size(), 1,
+ &num_features));
+}
+
+TEST_F(LookupListTableTest, TestSuccess) {
+ BuildFakeLookupListTable(&out, 1, 1);
+ EXPECT_TRUE(Parse());
+ EXPECT_EQ(num_lookups, 1);
+}
+
+TEST_F(LookupListTableTest, TestSuccess2) {
+ BuildFakeLookupListTable(&out, 5, 1);
+ EXPECT_TRUE(Parse());
+ EXPECT_EQ(num_lookups, 5);
+}
+
+TEST_F(LookupListTableTest, TestOffsetLookupTableUnderflow) {
+ BuildFakeLookupListTable(&out, 1, 1);
+ // Set bad offset to Lookup[0].
+ out.Seek(2);
+ out.WriteU16(0);
+ EXPECT_FALSE(Parse());
+}
+
+TEST_F(LookupListTableTest, TestOffsetLookupTableOverflow) {
+ BuildFakeLookupListTable(&out, 1, 1);
+ // Set bad offset to Lookup[0].
+ out.Seek(2);
+ out.WriteU16(out.size());
+ EXPECT_FALSE(Parse());
+}
+
+TEST_F(LookupListTableTest, TestOffsetSubtableUnderflow) {
+ BuildFakeLookupListTable(&out, 1, 1);
+ // Set bad offset to SubTable[0] of LookupTable[0].
+ out.Seek(10);
+ out.WriteU16(0);
+ EXPECT_FALSE(Parse());
+}
+
+TEST_F(LookupListTableTest, TestOffsetSubtableOverflow) {
+ BuildFakeLookupListTable(&out, 1, 1);
+ // Set bad offset to SubTable[0] of LookupTable[0].
+ out.Seek(10);
+ out.WriteU16(out.size());
+ EXPECT_FALSE(Parse());
+}
+
+TEST_F(LookupListTableTest, TesBadLookupCount) {
+ BuildFakeLookupListTable(&out, 1, 1);
+ // Set too large lookup count of LookupTable[0].
+ out.Seek(0);
+ out.WriteU16(2);
+ EXPECT_FALSE(Parse());
+}
+
+TEST_F(LookupListTableTest, TesBadLookupType) {
+ BuildFakeLookupListTable(&out, 1, 1);
+ // Set too large lookup type of LookupTable[0].
+ out.Seek(4);
+ out.WriteU16(6);
+ EXPECT_FALSE(Parse());
+}
+
+TEST_F(LookupListTableTest, TesBadLookupFlag) {
+ BuildFakeLookupListTable(&out, 1, 1);
+ // Set IgnoreBaseGlyphs(0x0002) to the lookup flag of LookupTable[0].
+ out.Seek(6);
+ out.WriteU16(0x0002);
+ EXPECT_TRUE(Parse());
+}
+
+TEST_F(LookupListTableTest, TesBadSubtableCount) {
+ BuildFakeLookupListTable(&out, 1, 1);
+ // Set too large sutable count of LookupTable[0].
+ out.Seek(8);
+ out.WriteU16(2);
+ EXPECT_FALSE(Parse());
+}
+
+TEST_F(CoverageTableTest, TestSuccessFormat1) {
+ BuildFakeCoverageFormat1(&out, 1);
+ EXPECT_TRUE(ots::ParseCoverageTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(CoverageTableTest, TestSuccessFormat2) {
+ BuildFakeCoverageFormat2(&out, 1);
+ EXPECT_TRUE(ots::ParseCoverageTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(CoverageTableTest, TestBadFormat) {
+ BuildFakeCoverageFormat1(&out, 1);
+ // Set bad format.
+ out.Seek(0);
+ out.WriteU16(3);
+ EXPECT_FALSE(ots::ParseCoverageTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(CoverageFormat1Test, TestBadGlyphCount) {
+ BuildFakeCoverageFormat1(&out, 1);
+ // Set too large glyph count.
+ out.Seek(2);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseCoverageTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(CoverageFormat1Test, TestBadGlyphId) {
+ BuildFakeCoverageFormat1(&out, 1);
+ // Set too large glyph id.
+ out.Seek(4);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseCoverageTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(CoverageFormat2Test, TestBadRangeCount) {
+ BuildFakeCoverageFormat2(&out, 1);
+ // Set too large range count.
+ out.Seek(2);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseCoverageTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(CoverageFormat2Test, TestBadRange) {
+ BuildFakeCoverageFormat2(&out, 1);
+ // Set reverse order glyph id to start/end fields.
+ out.Seek(4);
+ out.WriteU16(2);
+ out.WriteU16(1);
+ EXPECT_FALSE(ots::ParseCoverageTable(font, out.data(), out.size(), 1));
+}
+
+TEST_F(CoverageFormat2Test, TestRangeOverlap) {
+ BuildFakeCoverageFormat2(&out, 2);
+ // Set overlapping glyph id to an end field.
+ out.Seek(12);
+ out.WriteU16(1);
+ EXPECT_FALSE(ots::ParseCoverageTable(font, out.data(), out.size(), 2));
+}
+
+TEST_F(CoverageFormat2Test, TestRangeOverlap2) {
+ BuildFakeCoverageFormat2(&out, 2);
+ // Set overlapping range.
+ out.Seek(10);
+ out.WriteU16(1);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseCoverageTable(font, out.data(), out.size(), 2));
+}
+
+TEST_F(ClassDefTableTest, TestSuccessFormat1) {
+ BuildFakeClassDefFormat1(&out, 1);
+ EXPECT_TRUE(ots::ParseClassDefTable(font, out.data(), out.size(), 1, 1));
+}
+
+TEST_F(ClassDefTableTest, TestSuccessFormat2) {
+ BuildFakeClassDefFormat2(&out, 1);
+ EXPECT_TRUE(ots::ParseClassDefTable(font, out.data(), out.size(), 1, 1));
+}
+
+TEST_F(ClassDefTableTest, TestBadFormat) {
+ BuildFakeClassDefFormat1(&out, 1);
+ // Set bad format.
+ out.Seek(0);
+ out.WriteU16(3);
+ EXPECT_FALSE(ots::ParseClassDefTable(font, out.data(), out.size(), 1, 1));
+}
+
+TEST_F(ClassDefFormat1Test, TestBadStartGlyph) {
+ BuildFakeClassDefFormat1(&out, 1);
+ // Set too large start glyph id.
+ out.Seek(2);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseClassDefTable(font, out.data(), out.size(), 1, 1));
+}
+
+TEST_F(ClassDefFormat1Test, TestBadGlyphCount) {
+ BuildFakeClassDefFormat1(&out, 1);
+ // Set too large glyph count.
+ out.Seek(4);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseClassDefTable(font, out.data(), out.size(), 1, 1));
+}
+
+TEST_F(ClassDefFormat1Test, TestBadClassValue) {
+ BuildFakeClassDefFormat1(&out, 1);
+ // Set too large class value.
+ out.Seek(6);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseClassDefTable(font, out.data(), out.size(), 1, 1));
+}
+
+TEST_F(ClassDefFormat2Test, TestBadRangeCount) {
+ BuildFakeClassDefFormat2(&out, 1);
+ // Set too large range count.
+ out.Seek(2);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseClassDefTable(font, out.data(), out.size(), 1, 1));
+}
+
+TEST_F(ClassDefFormat2Test, TestRangeOverlap) {
+ BuildFakeClassDefFormat2(&out, 2);
+ // Set overlapping glyph id to an end field.
+ out.Seek(12);
+ out.WriteU16(1);
+ EXPECT_FALSE(ots::ParseClassDefTable(font, out.data(), out.size(), 1, 1));
+}
+
+TEST_F(ClassDefFormat2Test, TestRangeOverlap2) {
+ BuildFakeClassDefFormat2(&out, 2);
+ // Set overlapping range.
+ out.Seek(10);
+ out.WriteU16(1);
+ out.WriteU16(2);
+ EXPECT_FALSE(ots::ParseClassDefTable(font, out.data(), out.size(), 1, 1));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat1Success) {
+ BuildFakeDeviceTable(&out, 1, 8, 1);
+ EXPECT_TRUE(ots::ParseDeviceTable(font, out.data(), out.size()));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat1Success2) {
+ BuildFakeDeviceTable(&out, 1, 9, 1);
+ EXPECT_TRUE(ots::ParseDeviceTable(font, out.data(), out.size()));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat1Fail) {
+ // Pass shorter length than expected.
+ BuildFakeDeviceTable(&out, 1, 8, 1);
+ EXPECT_FALSE(ots::ParseDeviceTable(font, out.data(), out.size() - 1));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat1Fail2) {
+ // Pass shorter length than expected.
+ BuildFakeDeviceTable(&out, 1, 9, 1);
+ EXPECT_FALSE(ots::ParseDeviceTable(font, out.data(), out.size() - 1));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat2Success) {
+ BuildFakeDeviceTable(&out, 1, 1, 2);
+ EXPECT_TRUE(ots::ParseDeviceTable(font, out.data(), out.size()));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat2Success2) {
+ BuildFakeDeviceTable(&out, 1, 8, 2);
+ EXPECT_TRUE(ots::ParseDeviceTable(font, out.data(), out.size()));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat2Fail) {
+ // Pass shorter length than expected.
+ BuildFakeDeviceTable(&out, 1, 8, 2);
+ EXPECT_FALSE(ots::ParseDeviceTable(font, out.data(), out.size() - 1));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat2Fail2) {
+ // Pass shorter length than expected.
+ BuildFakeDeviceTable(&out, 1, 9, 2);
+ EXPECT_FALSE(ots::ParseDeviceTable(font, out.data(), out.size() - 1));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat3Success) {
+ BuildFakeDeviceTable(&out, 1, 1, 3);
+ EXPECT_TRUE(ots::ParseDeviceTable(font, out.data(), out.size()));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat3Success2) {
+ BuildFakeDeviceTable(&out, 1, 8, 3);
+ EXPECT_TRUE(ots::ParseDeviceTable(font, out.data(), out.size()));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat3Fail) {
+ // Pass shorter length than expected.
+ BuildFakeDeviceTable(&out, 1, 8, 3);
+ EXPECT_FALSE(ots::ParseDeviceTable(font, out.data(), out.size() - 1));
+}
+
+TEST_F(DeviceTableTest, TestDeltaFormat3Fail2) {
+ // Pass shorter length than expected.
+ BuildFakeDeviceTable(&out, 1, 9, 3);
+ EXPECT_FALSE(ots::ParseDeviceTable(font, out.data(), out.size() - 1));
+}
+
+TEST_F(LookupSubtableParserTest, TestSuccess) {
+ {
+ EXPECT_TRUE(FakeLookupParserReturnsTrue.Parse(font, 0, 0, 1));
+ }
+ {
+ EXPECT_TRUE(FakeLookupParserReturnsTrue.Parse(font, 0, 0, 5));
+ }
+}
+
+TEST_F(LookupSubtableParserTest, TestFail) {
+ {
+ // Pass bad lookup type which less than the smallest type.
+ EXPECT_FALSE(FakeLookupParserReturnsTrue.Parse(font, 0, 0, 0));
+ }
+ {
+ // Pass bad lookup type which greater than the maximum type.
+ EXPECT_FALSE(FakeLookupParserReturnsTrue.Parse(font, 0, 0, 6));
+ }
+ {
+ // Check the type parser failure.
+ EXPECT_FALSE(FakeLookupParserReturnsFalse.Parse(font, 0, 0, 1));
+ }
+}
diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp
index 72c54d9b5..e1c55c334 100644
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -180,18 +180,9 @@ public:
virtual ots::TableAction GetTableAction(uint32_t aTag) override {
// Preserve Graphite, color glyph and SVG tables
- if (
-#ifdef RELEASE_OR_BETA // For Beta/Release, also allow OT Layout tables through
- // unchecked, and rely on harfbuzz to handle them safely.
- aTag == TRUETYPE_TAG('G', 'D', 'E', 'F') ||
+ if (aTag == TRUETYPE_TAG('G', 'D', 'E', 'F') ||
aTag == TRUETYPE_TAG('G', 'P', 'O', 'S') ||
aTag == TRUETYPE_TAG('G', 'S', 'U', 'B') ||
-#endif
- aTag == TRUETYPE_TAG('S', 'i', 'l', 'f') ||
- aTag == TRUETYPE_TAG('S', 'i', 'l', 'l') ||
- aTag == TRUETYPE_TAG('G', 'l', 'o', 'c') ||
- aTag == TRUETYPE_TAG('G', 'l', 'a', 't') ||
- aTag == TRUETYPE_TAG('F', 'e', 'a', 't') ||
aTag == TRUETYPE_TAG('S', 'V', 'G', ' ') ||
aTag == TRUETYPE_TAG('C', 'O', 'L', 'R') ||
aTag == TRUETYPE_TAG('C', 'P', 'A', 'L')) {