Commit Graph

13 Commits

Author SHA1 Message Date
Jean-Philippe Andre 0a450b3ace Evas filters: Fix blur with small buffers
If the buffer is smaller than the blur kernel, then artifacts appear
and CRASHES happen because we read/write out of the buffer bounds.

Output buffer must be larger than the kernel diameter.
Input buffer's size is used to reduce the blurring effect on the edges.
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre 91e20084c1 Evas filters: Clear buffers after allocation
malloc() and mmap() don't return empty buffers, so blending on top
will present tons of artifacts.
Visible mostly on very small buffers as they are malloc()'ed from
previously used memory segments.
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre aa945c25e0 Evas filters: Use strcasecmp in the parser
We don't care about the case for our language.
EVEN for buffer names, so beware :)
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre a5abbf784e Evas filters: Add basic support for clip in blend
Right now, clip is used only when blending RGBA surfaces.
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre a0634dc04e Evas filters: Allow empty commands
If an instruction line contains only ';', skip it.
This is a convenience for Textblock and C++ style comments.
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre 5e78ce5eeb Evas filters: Implement style parser
So, the (font) effects will be described by a string. It's
basically a new language (yeah yeah sorry), VERY simple, based
on function calls a la Python, with sequential and named arguments.

This string is intended to be passed directly to an evas text object
and embedded into the evas textblock's markup tags.

This file implements both the basic parsing functions, the
compilation of instructions into a queue of commands, and the glue
code for the rest of the filter infrastructure.
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre d7ed901ffd Evas filters: Implement bump maps
These bump maps implement two light effects at once:
- 3D Shadows
- Specular lights

The specular light is activated by a flag.
Another flag enables compensation for darkening/whitening of
horizontal surfaces.

NOTE: This implementation is VERY SLOW.
It uses double values and divisions all over the place.
It might be possible to optimize by computing two LUTs before
running the algorithm.
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre 40c7f90bdc Evas filters: Implement displacement maps
Displacement maps are a simple but powerful tool to move pixels
around in a buffer, based on a displacement map (image).

Currently, various modes are implemented:
- X, Y or XY displacement
- Alpha map or RGBA map where R and G only are used

An intensity parameter is given as well.

Some of these might not be useful, we can just strip them off when
the final API is decided.
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre 6458df7a65 Evas filters: Implement color curves filter
Color curves are a very simple tool to alter the colors of an image,
on a per-pixel basis. This implementation will simply map each pixel
to a 256 bytes buffer, provided by the application.

NOTE: There are no convenience functions yet for easy curve
generation, but this is the plan (give point A, B, B and interpolate
between them to generate the 256 values array).
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre 84caa5902e Evas filters: Implement blur functions
Currently supported:
- Box blur for Alpha and RGBA
- Gaussian blur for Alpha and RGBA

Motion blur is not implemented.

These effects are SLOW. Gaussian blur is based on a true gaussian
curve for small radii, or a sine-based approximation.
The true gaussian might need to be removed for consistency, since
it gives slightly different results from the sine one (less blur).

It is not possible to mix Alpha and RGBA surfaces in this filter.
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre 65d779c7a3 Evas filters: Implement other masking functions
These functions differ from normal blending as they will use
a mask on top of input and output buffers.
So, basically they blend input+mask into a third buffer output.

If output is RGBA then mask or input MUST be RGBA.
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre 3f0f703f50 Evas filters: Implement blend functions
Currently, blending supports the following:
- Alpha --> Alpha (simple alpha masking)
- Alpha + Color --> RGBA (same as mask)
- RGBA --> RGBA (normal blend)
- RGBA --> Alpha (desaturate using A=(R+G+B)/3)
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre af106ffc81 Evas filters: Import main implementation file
evas_filter.c contains the entry points for the evas filters subsystem,
in particular, the filter API, the (yet very basic) buffer management
system, the command queue and main context handling functions.

Right now, the Evas engine is left untouched, so these implementations
will work ONLY in the software engine.

NOTE: This will not compile on its own (thus, not added to Makefile.am),
as it will require the filter implementations to be linked.
2014-02-07 17:33:16 +09:00