Commit graph

8269 commits

Author SHA1 Message Date
Alexandros Frantzis
2472ed899c gl: Fix build issues for GLES2
The glReadBuffer/glDrawBuffer functions are not present in GLES2, only
a single buffer is supported.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:35:26 +01:00
Alexandros Frantzis
f84653422a gl: Add GLESv2 backend to build system
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:34:17 +01:00
Alexandros Frantzis
b990dfb067 gl: Require the GL_OES_texture_npot extension for GLES2
The default support for GLES2 NPOT textures is very limited. We need the
additional features provided by the GL_OES_texture_npot extension.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:34:07 +01:00
Alexandros Frantzis
faa031f6d5 gl: Use GL_MAX_TEXTURE_IMAGE_UNITS to query the maximum texture units
The previous used value, GL_MAX_TEXTURE_UNITS, is only appropriate for the
fixed pipeline. It is replaced with GL_MAX_TEXTURE_IMAGE_UNITS that refers to
the number of texture units available in the fragment shader.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:34:00 +01:00
Alexandros Frantzis
1f1255689b gl: Remove unnecessary call to glDisableClientState()
This function has no effect when using shaders and is not supported at all in
GLES2.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:33:52 +01:00
Alexandros Frantzis
bbb244c7f2 gl: Add GLES2 support for drawing image surfaces on gl surfaces
Work around GLES2 limitations in texture pixel formats and options for
pixel packing/unpacking.

Depending on the endianness and the image pixel format, we may need to
manually swap the elements in a pixel group. This is not currently
implemented, but for little-endian architectures the common pixman BGRA
formats don't need a swap.

Due to GL_UNPACK_ROW_LENGTH missing in GLES2 we have to extract the image
data ourselves in some cases, so we can provide it to glTexSubImage2D
using a layout it can understand. We must extract the pixels if:
a. we don't want full-length lines or
b. the row stride cannot be handled by GL itself using a 4 byte
   alignment constraint

We use GL_PACK_ALIGNMENT 4 by default because that is the default pixman
alignment value and in some cases it allows us to avoid the manual pixel
extraction. However, when we extract image data manually we use an alignment
of 1.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:33:40 +01:00
Alexandros Frantzis
14db3d23c7 gl: Add support for creating image surfaces for GLES2
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:31:42 +01:00
Alexandros Frantzis
0e41145a75 gl: Use conventional texture upload for GLES2
GLES2 doesn't support Pixel Buffer Objects. Use conventional texture upload
for GLES2 (using client-side memory).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:30:29 +01:00
Alexandros Frantzis
d20f66608c gl: Require the GL_EXT_texture_format_BGRA8888 extension for GLES2
This extension adds limited BGRA support to GLES2. It is better than
nothing...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:30:02 +01:00
Alexandros Frantzis
777ed8b4c4 Extract function to query endianness from xlib/xcb and make it common
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:27:27 +01:00
Alexandros Frantzis
7bfcf1deaf gl: Store gradients in 2D textures of height 1 instead of 1D textures
1D textures are not available in GLES2. We use 2D textures with height 1
instead, which are equivalent to 1D textures and exist across all GL flavors.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:20:54 +01:00
Alexandros Frantzis
d308eee918 gl: Provide a shader implementation of GL_CLAMP_TO_BORDER for GLES2
The GL_CLAMP_TO_BORDER wrapping method (used with CAIRO_EXTEND_NONE) is not
available in GLES2. We use shaders to implement similar functionality for
GLES2.

If bilinear filtering is used, the shader performs a linear fade to
transparency effect in the texel coordinate intervals [-1/2n, 1/2n]
and [1 - 1/2n, 1 + 1/2n] (n: texture size).

If nearest filtering is used, the shader ensures that a clear color is
used for all texel coordinate values outside [0, 1).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:19:52 +01:00
Alexandros Frantzis
63aa65cfbb gl: Add functions to get the filter and extend of gl operands.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:19:40 +01:00
Alexandros Frantzis
7185ce4ddb gl: Pass more information to the shader emitter functions
This makes the shader emitter functions more versatile. It allows them to use
all information provided by the operands and the context to decide what shader
to produce.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:19:16 +01:00
Alexandros Frantzis
1f9200ffbf gl: Add GLES2 support to dispatch table initialization
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:18:52 +01:00
Alexandros Frantzis
4804160fd1 gl: Store the GL flavor (Desktop or ES) in the device struct
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:18:15 +01:00
Alexandros Frantzis
f1eef40c2a gl: Correctly extract GL version from OpenGL ES version strings
The GL version string returned by glGetString() for GLES doesn't have the
version number at the beginning of the string.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 08:11:15 +01:00
Chris Wilson
b1c96f1852 Silence the compiler for another couple of RGB30 switches
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-04 08:04:43 +01:00
Chris Wilson
5559dd0bbc image: Fix pixman format to RGB30 conversion
Søren Sandmann Pedersen spotted that we had reversed the channel order
in the conversion back from the pixman format codes to
CAIRO_FORMAT_RGB30.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-04 08:02:56 +01:00
Jesse Barnes
356c4ed9cc Expose 30bpp/10bpc support: CAIRO_FORMAT_RGB30
This is a common format used by framebuffers to drive 10bpc displays
and is often hardware accelerated by XRender with underlying support
from pixman's x2r10g10b10 format (which provides coercion paths for
fallbacks).

Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-01 09:00:14 +01:00
Jeff Muizelaar
bf75c9542d win32: Explain the purpose of the surface extents
It wasn't immediately obvious to me what the purpose of having
extents instead of just a size was.
2011-04-21 17:53:21 -04:00
Jeff Muizelaar
9f92901b09 Remove quartz-image extents.
We never used the x,y portion of the extents so we might as well take it out.
2011-04-21 15:23:14 -04:00
Uli Schlachter
a80bf9ed43 image: Don't use the fast path if it's wrong
Fixes the new "operator-source" test and the original report from:
http://lists.cairographics.org/archives/cairo/2011-March/021827.html

I tested this code path with all operators and "source" is the only one which
causes issues with rendering outside of the boxes.

Possibly fixes: https://bugs.freedesktop.org/show_bug.cgi?id=35407

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-31 15:47:45 +02:00
Andrea Canciani
90156f6ab7 Fix visibility issues found by make check 2011-03-21 09:58:29 +01:00
Andrea Canciani
7ea7a7714b Fix warning by check-doc-syntax
The check-doc-syntax step of 'make check' reports:

./cairo-gl.h: * cairo_device_t, which represents an GL context created by the user.
Error: some function names in the docs are not followed by parentheses.
Fix this by searching for the following regexp in the above files:
    '^[^:]*:[/ ][*]\(\|[  ].*\)\([^#']\|^\)\<\(cairo_[][<>/0-9a-z_]*\>[^][<>(]\)'
2011-03-21 09:51:01 +01:00
Andrea Canciani
e4c042d059 Improve headers-standalone target
make check reports multiple:
warning: control reaches end of non-void function

and on MacOS X it complains that:
error: unable to open executable ''
2011-03-21 09:51:00 +01:00
Andrea Canciani
cec4c9c91a Revert "Add an implementation of fmax for use with MSVC"
This reverts commit de2c5bfa19.

fmax() is not used anymore and should not be used in future.
2011-03-19 15:29:03 +01:00
Andrea Canciani
5339533737 Do not use fmax()
fmin() and fmax() are not available on all the supported
architectures. MIN() and MAX() should be used in their place.
2011-03-19 15:29:03 +01:00
Andrea Canciani
058227004e Remove unused function declarations
These functions have no implementation and are never called.
2011-03-19 15:27:29 +01:00
Andrea Canciani
ab8c108b88 Do not warn when ignoring the return value of _cairo_rectangle_intersect()
gcc complains that

cairo-surface-wrapper.c:647: warning: ignoring return value of
‘_cairo_rectangle_intersect’, declared with attribute warn_unused_result

It can be silenced by making _cairo_rectangle_intersect()
cairo_private_no_warn. This makes it possible to avoid unused
temporary variables in other places and reduces the dead assignments
reported by clang static analyzer from 114 to 98.
2011-03-19 12:24:14 +01:00
Andrea Canciani
628ef17aca image: Silence gcc warning
gcc does not know thta num_glyph is guaranteed to be strictly
positive, so it complains that:

cairo-image-surface.c:3787: warning: ‘status’ may be used uninitialized in this function
2011-03-18 17:54:54 +01:00
Andrea Canciani
e0444a458a image: Silence missing enum value warning
cairo-image-surface.c:101: warning: enumeration value ‘PIXMAN_x14r6g6b6’ not handled in switch
2011-03-18 17:54:54 +01:00
Andrea Canciani
f2eb3f2178 Improve cairo_rectangle_list_t error handling
Unify the _cairo_rectangle_list_create_in_error() functions, keeping
the best features from both (the one in cairo-clip.c statically
allocates the most common cases, the one in cairo.c throws a NO_MEMORY
error when it cannot malloc() instead of rethrowing the same error).

The same function can be used to return an error-list in
_cairo_gstate_copy_clip_rectangle_list() when _cairo_clip_rectangle()
fails (for example becaouse of an OOM).
2011-03-18 17:54:54 +01:00
Andrea Canciani
8a4299bf7e quartz-font: Remove unused variables
x_scale and y_scale are computed but never used.
2011-03-18 11:46:15 +01:00
Andrea Canciani
fd1fca8010 Make cairo_set_font_size() a wrapper of cairo_set_font_matrix()
cairo_set_font_size() should be equivalent to setting the font matrix
to an appropriate scale matrix.

Implementing it this way saves some code and makes sure that the same
code path is used whenever the font matrix is changed.
2011-03-18 11:43:42 +01:00
Andrea Canciani
f99358acf7 script: Fix stroking of 3 sided boxes
3-sided boxes can be replaced with rectangles when clipping and
filling, but not when stroking. _emit_path() is used for all of these
operations, so it cannot perform the optimization except for 4-sided
boxes.

Fixes stroke-open-box.
2011-03-18 10:50:23 +01:00
Andrea Canciani
c0fe556515 path: Fix _cairo_path_fixed_is_rectangle()
__cairo_path_fixed_is_rectangle() is used by the PS and PDF backends
to check if a path is equivalent to a rectangle when stroking. This is
different from being a rectangle when filling, because of the implicit
close_path appended to every subpath when filling.

Fixes stroke-open-box.

See https://bugs.freedesktop.org/show_bug.cgi?id=34560
2011-03-18 10:30:25 +01:00
Andrea Canciani
6521bab6e8 xcb,xlib: Fallback upon generic radial gradients
The RENDER specification requires radial gradients to have the first
circle completely inside the second one, but the error is not actually
generated.

The implementation produces the expected results if either circle
contains the other one, so only fall back in these cases.
2011-03-18 09:48:56 +01:00
Andrea Canciani
426fe6fadf xcb,xlib: Fix 1-stop gradients
The RENDER specification does not specify the constraints on the
gradient stops, but its implementation returns an error if less than 2
stops are used.

Xlib and XCB can work around this because gradients with just one stop
are by-definition the same as gradients with that stop repeated twice.

Fixes radial-gradient-one-stop.
2011-03-18 09:48:56 +01:00
Andrea Canciani
c42d7f7acf quartz: Fix y glyph advance
The advances must be transformed by the "quartz inverse scale",
i.e. (scale_inverse * scale(1,-1)).

Fixes show-glyph-advance.
2011-03-18 09:41:55 +01:00
Uli Schlachter
ed78510154 xcb-drm: Fix undeclared variable error
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-16 16:01:35 +01:00
Chris Wilson
02b2e3c93f xcb: Compile fix when using xcb-drm
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=31368
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-16 15:56:10 +01:00
Uli Schlachter
f6e6891b59 xcb: Never return NULL from create_similar
Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-15 19:41:41 +01:00
Adrian Johnson
f2f65684f0 cff: Fix heap corruption
caused by holding a pointer into a cairo_array after a realloc

https://bugs.freedesktop.org/show_bug.cgi?id=35161
2011-03-13 21:16:14 +10:30
Uli Schlachter
f1d313e042 xcb: Remove _cairo_xcb_picture_copy
All cairo_xcb_picture_t now get their own, private Picture instead of possibly
sharing it with a cairo_xcb_surface_t.

This solves a cyclic dependency which caused cairo_xcb_picture_t to be leaked
until their device was finished.

When an xcb surface was used as a source, a cairo_xcb_picture_t was created
which kept a reference to the surface. This picture was then added as a snapshot
to the surface which caused the surface to own a reference to the picture.

As a result, the Picture and possibly its associated Pixmap were not freed on
the X11 server which could thus run out of memory.

This change causes more Pictures to be created which could possibly slow down
cairo-xcb. There seems to be no measurable difference with cairo-perf-trace. For
the micro benchmarks, this has the most impact on paint_similar-rgba_source.512:

       min(ticks)  min(ms) median(ms) stddev. iterations overhead
before     158732    0.159    0.159  0.11%   4: 1651.49
after      162579    0.163    0.163  0.18%   4: 1612.41

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=34912

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-03-04 16:37:13 +01:00
Jeff Muizelaar
de2c5bfa19 Add an implementation of fmax for use with MSVC 2011-03-03 16:34:43 -05:00
Jeff Muizelaar
aca492eb3f Add UINT32_MAX define.
This is needed for building with MSCV
2011-03-03 16:31:03 -05:00
Chris Wilson
9669b300a0 surface: Don't pass INT_UNSUPPORTED to _cairo_surface_set_error
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-02 18:31:28 +00:00
Uli Schlachter
c0dc933efd xcb: Remove CAIRO_XCB_RENDER_HAS_COMPOSITE_SPANS
This flag was only ever tested, but never set. Also, there is no X11 server out
there which actually supports this.

AFAIK it was just an experiment which turned into dead code.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-02-28 15:54:02 +01:00
Uli Schlachter
6cd96f966f xcb: Fix for PDF operators with RENDER 0.11
RENDER 0.11 added PDF operators and the cairo-xcb backend is already prepared
for handling them. However, it doesn't actually handle them.

If you used such an operator with RENDER 0.11, _operator_is_supported() would
return TRUE, but later on an ASSERT_NOT_REACHED in _render_operator() is hit.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2011-02-28 15:45:14 +01:00