Commit Graph

139 Commits

Author SHA1 Message Date
Jean-Philippe Andre d15308efef Evas filters: Add explicit exec flag in data_set
This flag should be set iif the string passed is to be executed
rather than assigned. This is used to pass complex arguments
as data, like tables (eg. color class).
2015-06-25 14:36:09 +09:00
Jean-Philippe Andre 15afea293f Edje & evas filters: Properly pass data from EDC to Lua
Also fix a few issues
2015-06-25 14:36:09 +09:00
Jean-Philippe Andre 0df37da435 Evas filters: Fix buffer_push and add support for color classes
Makes sure that buffers don't override already existing
globals vars such as 'mask' (a function name). Yeah, it happened
to me.

CC support is a little bit hackish. Need to find a better way.
2015-06-25 14:36:09 +09:00
Jean-Philippe Andre 0e8f890dfb Edje & evas filters: Add extra data from EDC to Lua program
This also supports color classes (really rough implementation for
now, but the API should remain stable).

@feature
2015-06-25 14:36:09 +09:00
Jean-Philippe Andre d00378edcf Edje/evas filters: Add filter.source support
This should preserve ABI stability with earlier versions of
edje_cc while still providing more advanced control over
proxy bindings for evas filters from EDC.

Also fix proxy binding for filters.

@feature
2015-06-25 14:36:09 +09:00
Jean-Philippe Andre 4882788527 Evas filters: Reduce debugging with default compile opts
When using debug compile flags, full-on filter debug will happen.
2015-06-25 14:36:08 +09:00
Jean-Philippe Andre f3e16bc485 Evas filters: Implement Lua classes for colors & buffer
Reuse previous code for buffer. Keeps API stability.

The new class "color" is here for a more convenient color
representation. This way, colors can be represented in more
natural ways like: {r,g,b[,a]}, 0xaarrggbb, "red", "#rrggbb"

Class color is implemented in pure Lua, and adds a .lua file
to Evas' share folder.
2015-06-25 14:36:08 +09:00
Jean-Philippe Andre 93797e3b0d Evas filters: Create specific log domain
This will improve the debug output of evas and specifically
allow setting "evas_filter" log level to a higher or lower
value depending on what you are debugging :)
2015-06-25 14:36:08 +09:00
Jean-Philippe Andre 225c0f937a Evas filters: Pass edje state name & value to the filters
From Edje, pass the current state info (name and value) as well
as the next state and the transition position when applicable.
2015-06-25 14:36:08 +09:00
Jean-Philippe Andre 4ade39c0ea Evas filters: Pass object scale to Lua state 2015-06-25 14:36:08 +09:00
Jean-Philippe Andre 70efb699a5 Evas filters: Implement table & function support for curve
Now the points can be specified by passing a table or a proper Lua
function. The previous functionality (parsing a string) is still
valid.
2015-06-25 14:36:08 +09:00
Jean-Philippe Andre 1b2819f2cb Evas filters: Implement __index for Lua buffer objects 2015-06-25 14:36:08 +09:00
Jean-Philippe Andre ffea07a049 Evas filters: Pass text colors to the parser
This does not implement the full feature yet (Lua variable
is not set). This commit also brings various fixes.
2015-06-25 14:36:08 +09:00
Jean-Philippe Andre d148c0f0d2 Evas filters: Fix runtime, allow state change on the fly
Now we're ready to implement runtime changes to the filters'
state (color classes, edje state, etc...), as the Lua function
will be run whenver required.
2015-06-25 14:36:08 +09:00
Jean-Philippe Andre 148a886cc7 Evas filters: Refactor parser code
This is to prepare the changeable states (animation, color, scale...)

- Remove use of Eina_Value (simplifies code)
- Use proper Lua type for buffers (with pretty __tostring)
   This adds the buffer methods: width, height, type, name, source
2015-06-25 14:36:08 +09:00
Jean-Philippe Andre c25467ff5c Evas filters: Implement very basic print function 2015-06-25 14:36:08 +09:00
Jean-Philippe Andre 2faaef966e Evas filters: Add internal function _program_run
This will allow changing the state of the filter and re-run it
without re-creating the Lua_State object. This is to handle size,
color, animation state and scale changes (amongst other things).
2015-06-25 14:36:08 +09:00
Jean-Philippe ANDRE e096a3490b Evas filters: Fix parsing of argument lists
Make check would even fail on 32bit machines because of that:
Lua tables are not arrays and lua_next doesn't ensure the order
of the elements as I wrongly assumed.

@fix
Fixes T1615
2014-09-19 10:33:24 +09:00
Jean-Philippe Andre 793e2ee21e Evas filters: Report parsing error message from lua
Also, re-enable legacy code compatibility layer, as it
can still be used for compat with older code.
2014-06-11 10:02:42 +09:00
Jean-Philippe Andre f731f8ffb4 Evas filters: Fix NULL dereference (legacy_strdup)
CID 1210809
CID 1210813

+ remove comment
2014-05-14 18:42:05 +09:00
Jean-Philippe Andre 2a5b3e2482 Evas filters: Fix NULL dereferences
CID 1210807
CID 1210808
2014-05-14 18:39:53 +09:00
Jean-Philippe Andre 8c8816aca6 Evas filters: Fix some parsing errors 2014-05-09 16:57:39 +09:00
Jean-Philippe Andre 139f7bc178 Evas doc: Add example for padding_set (filters)
With preview and all.
2014-05-09 16:57:39 +09:00
Jean-Philippe Andre 87e09ff25e Evas doc: Move filters reference doc to Lua
Part 2: improve doc design, translate examples to Lua syntax and
        add a few words about Lua itself.
2014-05-09 16:57:39 +09:00
Jean-Philippe Andre 8a1b335bb1 Evas doc: Move filters examples to Lua
Part 1: auto-generated examples with previews
2014-05-09 16:57:39 +09:00
Jérémy Zurcher 9a79d1e864 silence a few warnings 2014-05-08 00:15:53 +02:00
Cedric Bail d590ad8041 evas: reuse buffer instead of leaking it.
CID 1210816
2014-05-04 00:18:55 +02:00
Jean-Philippe Andre 27650fb94a Evas filters: Fix parsing of instructions with unnamed arguments 2014-04-30 14:52:39 +09:00
Jean-Philippe Andre 64baafe176 Evas filters: Premultiply colors after parsing integers 2014-04-30 14:52:39 +09:00
Jean-Philippe Andre 59cf013db9 Evas filters: Add support for Evas_Object_Image
This adds filter support to Image objects as well.
The exact same filters can run on Text and on Images
(provided some colorspace limitations are respected).

This basically adds:
- Support for RGBA input buffer
- Eo entry points for Image filter support
- Implement basic filter support in Evas_Image
2014-04-27 17:41:40 +09:00
Jean-Philippe Andre de4969ccb2 Evas filters: Remove legacy code
The compatibility layer and Lua implementation are now complete.
2014-04-27 17:40:55 +09:00
Jean-Philippe Andre 103d8d08fa Evas filters: switch script language to Lua
It was a pretty stupid idea to write a parser for a custom language
when we already have Lua as a dependency and it's so beautiful and
easy.

There is a fallback function to allow for compatibility with legacy
filters. But that broken syntax is not recommended. I'll probably
remove it soon.

All the test cases I have in my example app work fine with this
compatibily layer.
2014-04-27 17:40:55 +09:00
Jean-Philippe Andre 27d97110cc Evas filters: Default mask fillmode should be repeat
Fillmode "NONE" has basically no practical use and shouldn't be
the default.
2014-03-26 10:48:12 +09:00
Jean-Philippe Andre 7e731ea10a Evas filters: Ignore ox,oy when stretching in the same direction
During padding calculation, ox and oy should be ignored unless the
blend operation is neither repeating nor stretching. Otherwise,
the buffer will grow without necessity.
2014-03-26 10:48:12 +09:00
Jean-Philippe Andre 91a471b4dc Evas filters: Add new instruction padding_set
This will allow forcing a specific value for the filter padding,
instead of relying on auto calculation.

Two advantages:
- Auto calculation can't be perfect, since it will add as much
  padding as required for the full blur effect
- This prepares the path for animations with effects, where the
  object size does not change over time
2014-03-21 15:23:02 +09:00
Jean-Philippe Andre 2a1ba1b908 Evas filters: Use box blur by default
BOX blur is a lot faster (and easier to optimize, too)
than GAUSSIAN blur. Repeating 2x or 3x BOX blur will also
give similar results to GAUSSIAN blur (very smooth), but
in much less time.

Add a count parameter to the BOX blur instruction.
2014-03-12 14:08:02 +09:00
Jean-Philippe Andre a37a1d458d Evas filters: Fix uninitialized variable warning 2014-03-12 14:08:02 +09:00
Jean-Philippe Andre cc21f8f173 Evas filters: Clean up some duplicate includes
No functional change
2014-03-04 13:58:53 +09:00
Jean-Philippe ANDRE 7f63b4a3eb Evas filters: Avoid CRI message when using the GL engine
A CRItical message was always displayed when setting a filter
on a text object, saying that proxy rendering is not supported on GL.

Reduce CRI to ERR and skip proxy rendering altogether if there are
no proxy sources.

This @fix needs to be backported.

Thanks zmike for reporting this.

Signed-off-by: Jean-Philippe Andre <jp.andre@samsung.com>
2014-03-04 10:37:03 +09:00
Jean-Philippe Andre afcbabb004 Doc: Fix filters documentation
Since the doc mentions colors in the examples, fix it to match the
new dox theme :)
2014-02-24 11:18:10 +09:00
Jean-Philippe Andre bdb3ccd1dd Evas filters: Add a note to the transform doc
This is a special operation, with a simplistic implementation.
2014-02-20 13:27:43 +09:00
Jean-Philippe Andre c256bdc367 Evas filters: Fix documentation for color with rgba buffers
The documentation said color was used as a multiplier, but in
reality the image drawing functions don't use the context's
color when drawing. So the color is only defined for Alpha -> RGBA
operations.
2014-02-20 13:27:43 +09:00
Jean-Philippe Andre 74d8403217 Evas filters: Grow filter should gracefully blend
If grow() was used on top of another effect, it was simply
erasing all pixels. We need to use a temporary buffer and
blend it to the output.
2014-02-20 13:27:42 +09:00
Jean-Philippe Andre 0d9ffc2624 Evas filters: Fix padding in blur with offset
Test case was: blur(ox=40, rx=40);
This would crop the blurred text instead of having proper padding.
2014-02-20 13:27:42 +09:00
Jean-Philippe Andre 8a694314a4 Evas filters: Fix options parsing
Test case "blend() blend();" did not fail when it should have.
Also, return an error if the program was empty (all whitespaces).
2014-02-20 13:27:42 +09:00
Jean-Philippe Andre ddf267e506 Evas filters: Fix padding in blur filter
The wrong value was used for the command's padding.
Also, remove mention of "motion" blur which is not
implemented.
2014-02-20 13:27:42 +09:00
Jean-Philippe Andre 126cbbc7a9 Evas filters: Mark parser functions as EAPI for tests
The filter unit test case will directly call the parser functions.
2014-02-20 13:27:42 +09:00
Jean-Philippe Andre 6067c88b56 Evas filters: Use strtok instead of strtok_r for mingw
The Windows build (mingw) does not know about strtok_r.
So, let's use the non-safe variant strtok instead.
Currently, this function is called from the main thread only,
so this should be fine :)

In the future it would be nice to not use strtok anymore,
but strtok_r everywhere, and add it to evil. Considering the
release coming soon, I'm not going to change something like that
now.
2014-02-19 11:30:11 +09:00
Jean-Philippe Andre 54129dfcaa Evas filters: Fix documentation for displace
fillmode "none" is not supported, as it does not make much sense
(how do we displace pixels without an underlying displacement map?)
2014-02-18 10:22:50 +09:00
Jean-Philippe Andre ded097461d Evas filters: Fix padding with "blend"
Test case was:
buffer : a (alpha);
blur (20, dst = a);
blend (src = a, ox = 30);

In that case, padding was 20, 30, 20, 20.
So the blurred buffer was clipped on screen.
2014-02-18 10:22:50 +09:00
Jean-Philippe Andre 7cf02ca75b Evas filters doc: Add link to "fillmode" 2014-02-18 10:22:50 +09:00
Jean-Philippe Andre a4ecf34316 Evas filters: More clang fixes
NULL ptr dereference.
2014-02-14 13:06:05 +09:00
Jean-Philippe Andre 6642d16a7d Evas filters: Fix more clang stuff and add safety checks
The prepare function should not fail, unless something is very
wrong. Also, return NULL instead of EINA_FALSE.
2014-02-14 13:06:00 +09:00
Carsten Haitzler c7aa6039c8 evas filter - fix uninitialized pointer in evas
fixes CID 1174077
2014-02-13 19:05:43 +09:00
Carsten Haitzler b837cdb055 evas - filter - don't use longs when DATA32 is the right type
fixes CID 1174078
2014-02-13 18:59:16 +09:00
Jean-Philippe Andre 511049e20d Evas filters: Improve doc automatization
Include example filter codes from src/examples in Doxygen.
Use these examples for the generation as well.
2014-02-13 17:37:33 +09:00
Jean-Philippe Andre 9f1ae254db Evas filters: Add image for the Syntax example
And change it a bit so the glow is nicer :)
2014-02-13 17:37:33 +09:00
Jean-Philippe Andre 872ab8aa4d Evas filters: Add images to the html doc 2014-02-13 17:37:33 +09:00
Jean-Philippe Andre 93a608dc66 Evas filters: Buffer names are case-sensitive
Or so claims the documentation, so let's use strcmp
instead of strcasecmp.
2014-02-13 11:24:47 +09:00
Jean-Philippe Andre 36b0bca4aa Evas filters: Add the reference documentation (script language)
In Doxygen format, write the reference documentation for the filters.
It will contain a few examples only, should serve more as a reference
just like edcref.

This is for the script language itself, not for the Eo APIs or the
internal APIs (those are already documented).
2014-02-13 11:24:43 +09:00
Jean-Philippe Andre c6943bb32d Evas filters: in transform, dst must be specified
Since the transform operation is (for now) a very simple tool,
it only works when src and dst have the same colorspace.

This commit forces users to specify dst, since "input" and "output"
have different colorspaces.
2014-02-13 11:21:32 +09:00
Jean-Philippe Andre 62f0ea1d34 Evas filters: Improve displace flags in scripts
These flags were a dumb integer instead of being a human
readable string.

They define how to handle cases were a pixel is read from
out of boundaries.
2014-02-13 11:19:49 +09:00
Jean-Philippe Andre 56d73cb897 Evas filters: Fix warnings on shadowed variables
Also, remove globals A, R, G, B from parser.c... these are
temp variables used in a macro.

My CFLAGS didn't include -Wshadow so I missed those.
Thanks Tom for spotting :)
2014-02-12 10:36:11 +09:00
Carsten Haitzler 078099d63d fix warnings in evas filter plus a memleak in _vflip_cpu() 2014-02-08 12:15:35 +09:00
Jean-Philippe Andre 637416d62e Evas filters: Allow calling program_set and source_set in any order
If source_set was called after program_set, then parsing would fail.
It used to work because the program was re-parsed at source_set.
Now, save the code, mark the filter as changed, and reparse again
if the source changed (keep track of invalid programs to avoid
excessive parsing).
2014-02-07 17:59:18 +09:00
Jean-Philippe Andre 9d821a402a Evas filters: Fix proxy usage (source unset)
Proxy sources & objects were not properly unset.
This results either in crashes (especially in the Edje tests)
or dangling objects with tons of references.

Remove the refcount increase/decrease, as it is redundant.
Store pairs proxy+source instead of just the source in all hashes,
so we can unset the is_proxy flag on the proxy when there are no
sources anymore.
2014-02-07 17:33:18 +09:00
Jean-Philippe Andre 748501a5af Evas filters: Add argument src for buffer declaration
Basically, in an edje file, we'll declare buffers manually,
using the "buffer:buf(src=part)" syntax.
2014-02-07 17:33:18 +09:00
Jean-Philippe Andre 28d469237b Evas filters: Avoid adding multiple sources under the same name 2014-02-07 17:33:18 +09:00
Jean-Philippe Andre 8570b38dd1 Evas filters: Rename bind to source_set
Because that's what we call it for proxy images :)
2014-02-07 17:33:18 +09:00
Jean-Philippe Andre 7043c8bb89 Evas filters: Disable gauss blur
And fix doc in parser
2014-02-07 17:33:18 +09:00
Jean-Philippe Andre 43962135be Evas filters: Remove FIXME and unimplemented code
Remove compilation warnings: we don't really need cubic
interpolation at this point, we can still add it back
later if wanted.

Also, make it clear that buffer #2 is the output buffer.
Remove meaningless FIXME.
2014-02-07 17:33:17 +09:00
Jean-Philippe Andre 2e401c2e91 Evas filters: Allocate buffer in the main loop (part 2)
Now the allocation is really done in the main loop.
Rendering fails, only happens in case of redraw.
2014-02-07 17:33:17 +09:00
Jean-Philippe Andre 62d7a2cb3f Evas filters: Implement all rgba mask operation
RGBA + RGBA blended to an RGBA target.
Uses existing infrastructure to combine all buffers together.
2014-02-07 17:33:17 +09:00
Jean-Philippe Andre e08a8fd934 Evas filters: Remove (never implemented) motion blur 2014-02-07 17:33:17 +09:00
Jean-Philippe Andre 209a7077a0 Evas filters: Add offset parameter to vflip
It is not possible to logically handle padding and offset at the same
time for a proper mirror effect, unless this is handled directly at the
transformation level.

Also, add support for blend() operation padding computation.
2014-02-07 17:33:17 +09:00
Jean-Philippe Andre 388a30950a Evas filters: Add padding info to filter runtime context 2014-02-07 17:33:17 +09:00
Jean-Philippe Andre 2da17927da Evas filters: Implement fill with padding
Add parameters l, r, t, b to clip the fill area.
While l=x and t=y, the width and height of the clip are determined
at filter run-time, since we don't know the buffer size before.
2014-02-07 17:33:17 +09:00
Jean-Philippe Andre b5b6f6ef3c Evas filters: Fix padding in blur with offset
If ox, oy were set, the padding was wrong in blur.
2014-02-07 17:33:17 +09:00
Jean-Philippe Andre 82032d494f Evas filters: Implement curve script API
Currently supports interpolation modes "none" and "linear".
Cubic interpolation is not implemented yet.
2014-02-07 17:33:17 +09:00
Jean-Philippe Andre 9623e1f238 Evas filters: Pass fillmode to the filters
I just need to actually implement them, now :)
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre a87ef5735d Evas filters: Introduce "fill" mode in script API
This would mean: repeat (X,Y) or stretch (X,Y), for buffer
operations where it means something (blend, bump, ...)
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre 78a3eaaecd Evas filters: Change buffer creation API in script
Syntax was: buffer(name=bla,alpha=bool);
Changed to: buffer:bla(alpha);

There's a semicolon between buffer and its name because ALL whitespaces
are discarded. This might prove useful sometime in the future, so let's
keep it this way for now :)
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre 7fbbf9eabe Evas filters: Use common color parse function 2014-02-07 17:33:16 +09:00
Jean-Philippe Andre 0ad8b02c16 Evas filters: Fix compilation after merge from master
- CRIT becomes CRI
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre c0996b0669 Evas filters: Reduce padding to the minimum acceptable
Padding was brutally calculated by suming ALL the filters'
individual paddings. Now we try to be a bit smarter and propagate
the padding between buffers in the filter chain.
2014-02-07 17:33:16 +09:00
Jean-Philippe Andre 109894bb56 Evas filters: Add fill command
This will simply clear the target buffer with the specified color.
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 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