Bug 1857841 - pt 3. Add a new page kind named "fresh" r=glandium
[gecko.git] / gfx / cairo / 15-remove-quartz-surface-for-data.patch
bloba82d4aab2164e8f03169bed3977ca50acde208b2
1 diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
2 --- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
3 +++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
4 @@ -2856,117 +2856,6 @@ cairo_quartz_surface_create (cairo_forma
7 /**
8 - * cairo_quartz_surface_create_for_data
9 - * @data: a pointer to a buffer supplied by the application in which
10 - * to write contents. This pointer must be suitably aligned for any
11 - * kind of variable, (for example, a pointer returned by malloc).
12 - * @format: format of pixels in the surface to create
13 - * @width: width of the surface, in pixels
14 - * @height: height of the surface, in pixels
15 - *
16 - * Creates a Quartz surface backed by a CGBitmap. The surface is
17 - * created using the Device RGB (or Device Gray, for A8) color space.
18 - * All Cairo operations, including those that require software
19 - * rendering, will succeed on this surface.
20 - *
21 - * Return value: the newly created surface.
22 - *
23 - * Since: 1.12 [Mozilla addition]
24 - **/
25 -cairo_surface_t *
26 -cairo_quartz_surface_create_for_data (unsigned char *data,
27 - cairo_format_t format,
28 - unsigned int width,
29 - unsigned int height,
30 - unsigned int stride)
32 - cairo_quartz_surface_t *surf;
33 - CGContextRef cgc;
34 - CGColorSpaceRef cgColorspace;
35 - CGBitmapInfo bitinfo;
36 - void *imageData = data;
37 - int bitsPerComponent;
38 - unsigned int i;
40 - // verify width and height of surface
41 - if (!_cairo_quartz_verify_surface_size(width, height))
42 - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
44 - if (width == 0 || height == 0) {
45 - return (cairo_surface_t*) _cairo_quartz_surface_create_internal (NULL, _cairo_content_from_format (format),
46 - width, height);
47 - }
49 - if (format == CAIRO_FORMAT_ARGB32 ||
50 - format == CAIRO_FORMAT_RGB24)
51 - {
52 - cgColorspace = CGColorSpaceCreateDeviceRGB();
53 - bitinfo = kCGBitmapByteOrder32Host;
54 - if (format == CAIRO_FORMAT_ARGB32)
55 - bitinfo |= kCGImageAlphaPremultipliedFirst;
56 - else
57 - bitinfo |= kCGImageAlphaNoneSkipFirst;
58 - bitsPerComponent = 8;
59 - } else if (format == CAIRO_FORMAT_A8) {
60 - cgColorspace = NULL;
61 - bitinfo = kCGImageAlphaOnly;
62 - bitsPerComponent = 8;
63 - } else if (format == CAIRO_FORMAT_A1) {
64 - /* I don't think we can usefully support this, as defined by
65 - * cairo_format_t -- these are 1-bit pixels stored in 32-bit
66 - * quantities.
67 - */
68 - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
69 - } else {
70 - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
71 - }
73 - cgc = CGBitmapContextCreate (imageData,
74 - width,
75 - height,
76 - bitsPerComponent,
77 - stride,
78 - cgColorspace,
79 - bitinfo);
80 - CGColorSpaceRelease (cgColorspace);
82 - if (!cgc) {
83 - free (imageData);
84 - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
85 - }
87 - /* flip the Y axis */
88 - CGContextTranslateCTM (cgc, 0.0, height);
89 - CGContextScaleCTM (cgc, 1.0, -1.0);
91 - surf = _cairo_quartz_surface_create_internal (cgc, _cairo_content_from_format (format),
92 - width, height);
93 - if (surf->base.status) {
94 - CGContextRelease (cgc);
95 - free (imageData);
96 - // create_internal will have set an error
97 - return (cairo_surface_t*) surf;
98 - }
100 - surf->imageData = imageData;
102 - cairo_surface_t* tmpImageSurfaceEquiv =
103 - cairo_image_surface_create_for_data (imageData, format,
104 - width, height, stride);
106 - if (cairo_surface_status (tmpImageSurfaceEquiv)) {
107 - // Tried & failed to create an imageSurfaceEquiv!
108 - cairo_surface_destroy (tmpImageSurfaceEquiv);
109 - surf->imageSurfaceEquiv = NULL;
110 - } else {
111 - surf->imageSurfaceEquiv = tmpImageSurfaceEquiv;
112 - surf->ownsData = FALSE;
115 - return (cairo_surface_t *) surf;
118 -/**
119 * cairo_quartz_surface_get_cg_context:
120 * @surface: the Cairo Quartz surface
122 diff --git a/gfx/cairo/cairo/src/cairo-quartz.h b/gfx/cairo/cairo/src/cairo-quartz.h
123 --- a/gfx/cairo/cairo/src/cairo-quartz.h
124 +++ b/gfx/cairo/cairo/src/cairo-quartz.h
125 @@ -54,13 +54,6 @@ cairo_quartz_surface_create_for_cg_conte
126 unsigned int width,
127 unsigned int height);
129 -cairo_surface_t *
130 -cairo_quartz_surface_create_for_data (unsigned char *data,
131 - cairo_format_t format,
132 - unsigned int width,
133 - unsigned int height,
134 - unsigned int stride);
136 cairo_public cairo_surface_t *
137 cairo_quartz_surface_create_cg_layer (cairo_surface_t *surface,
138 cairo_content_t content,