We never want to update the transform and then damage below. Damage
below is always used to trigger a repaint where the surface used to be
so we need to record the damage before updating the transform.
Needed for implementing drag'n'drop icons. When a drag starts, the
compositor will position the top-left corner of the client supplied
icon surface at the cursor hotspot. On the first attach to that
surface, the client may want to reposition it but shell->map did not
take sx and sy parameters.
This changes shell->map interface to take sx and sy parameters and
change dekstop shell implementation to update the position of a
surface of type none according to those parameters. Since a surface
of type none won't actually be mapped, the effect of this change is
only visible for surfaces that are made visible by the compositor.
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Surfaces like drag'n'drop icons shouldn't receive events as a normal
surface but are still created by the client so add a way for the
compositor to enable or disable the picking of a client surface.
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
The condition to return from surface_attach with a null buffer involves
es->output being non-null. However if a surface was just created this
field would be null and an attach of a null buffer would cause the
compositor to crash.
The other crash happened if surface_attach was called twice with a
null buffer after a valid buffer was attached to the surface. Since
es->buffer was not being set to NULL, surface_attach() would call
wl_list_remove(&es->buffer_destroy_listener.link) twice for the same
surface.
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
I know it's hard to figure out what the shells or backends will be
using as internal API at this point but we can try to minimize the
amount of WL_EXPORT being used anyway.
[pq: redone due to my earlier changes]
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
As weston_surface_update_transform() automatically applies before and
after damage on surface geometry change, we don't need to explicitly add
the same damage in motion_notify() for the cursor surface.
We still need the side-effect, that is scheduling a repaint.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Round off fractions from non-transformed surface position coordinates.
Transformed surface moved by a client may have non-integer position
coordinates. That is required to prevent drifting on continuous
resizing.
We can round the position to integers when the surface is not (anymore)
transformed.
This change may fix a rounding inconsistency in the opaque region setup,
where the rectangle is initialised from the coordinates without explicit
rounding operation.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Move the call to assign an output from weston_surface_configure() to
weston_surface_update_transform().
As update_transform takes new geometry into use, it should also reassign
the output for the surface, but only if an output was already assigned.
Add explicit assing output calls to where we relied on
weston_surface_configure() unconditionally assigning the output.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Move the surface opaque region setup from weston_surface_configure() to
weston_surface_update_transform(), so we have less reason to call
update_transform from configure. Opaque region depends on geometry,
after all.
Also move the opaque field from weston_surface to
weston_surface::transform to make this obvious.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Remove redundant weston_surface_update_transform() calls from within
output repaint paths, and add a comment that we need to rely on
surface->geometry.dirty == 0 within the repaint sub-functions.
Now that weston_surface_update_transform() does damage as needed, and
weston_output_repaint() explicitly calls update_transform, we can reduce
the updates in rotate_grab_motion() to simply scheduling a repaint. This
will guarantee that the change in rotation ends up on screen ASAP.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
weston_surface_update_transform() is similar to
weston_surface_configure() in that it changes the surface region on
screen. Unlike configure, update_transform forgets to deal damage at
all, yet it is the only place where we can do damage_below() as needed.
Add a damage_below call to deal damage for the old surface region only
when needed. This uses the cached state from surface->transform to get
the old region.
Add a damage call to deal damage for the new surface region, after
updating the cached state.
Add a repaint call, since we have changed the scene and should render it
out.
This change fixes the rotation not updating the screen properly.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
The non-transformed case looked a little odd, calling
weston_surface_to_global(), since it already tests for transform.enabled
and simply uses width, height for the box.
Streamline it, by open-coding weston_surface_to_global(), and avoiding
another call into weston_surface_update_transform(). This way it does
not look suspicious to me.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
In surface_compute_bbox(), call surface_to_global_float() instead of
weston_surface_to_global(). This avoids the recursion:
weston_surface_update_transform()
weston_surface_update_transform_enable()
surface_compute_bbox()
weston_surface_to_global()
weston_surface_update_transform()
which might be non-obvious when reading the code.
Computing the min and max coordinates in floats, we can have a tight
rounding margin by using floor() and ceil().
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Split two helper functions out of weston_surface_update_transform() to:
- make the code clearer
- update the bounding box properly even if transformation fails
- unify the return point
Also add a comment on what matrix.d[12] is.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Extract the core into a function that does not call
weston_surface_update_transform() or schedule repaint.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Computing the real maximal opaque screen aligned rectangle of a
transformed surface is hard. Let's drop the opaque optimisation
instead.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
When a transformed (rotated) surface is continuously resized from its
top-left corner, its location will drift. This is due to accumulating
rounding errors in transforming an offset from surface-local to global
coordinates in surface_attach().
Diminish the drift down to unobservable level by changing the
weston_surface global position from integer to float.
The offset transformation is now done without rounding. To preserve the
precision, wl_shell::configure() interface must use floats, and so does
weston_surface_configure(), too.
The con of this patch is that it adds inconsistency to the surface
position coordinates: sometimes they are floats, sometimes integers.
Commit a0d6dc4f26 lost one line of code in
the refactoring, and so did not reset the surface damage on repaint
anymore. This causes damage to only accumulate, leading to a full
display redraw every cycle and hiding damage tracking issues.
Put the damage clear back.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
The uniform location variables should be signed, according to the OpenGL
ES 2 specification. Moreover, GL_NONE, i.e. 0, is not an invalid nor
special location; it is actually used as a valid uniform location.
Change struct weston_shader uniform members to signed.
Stop using 0 for identifying a non-existing uniform, use -1 instead.
Furthermore, as the spec says a) glGetUniformLocation() will return -1
for non-active/existing uniforms, and b) glUniform*() function will
simply ignore all calls with location -1, we can simplify the code. We
don't have to avoid locating uniforms that don't exist, and we don't
need to test for them in weston_surface_draw() either.
Remove the micro-optimisation that avoids setting 'alpha' uniform if it
has not changed, in the name of simplification.
Unify shader creation by dropping init_solid_shader(), and calling
weston_shader_init() instead. The downside is that we compile the vertex
shader twice at startup now.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
The x, y offsets in attach request are in surface-local coordinates, as
that is the only coordinate system the clients know about. The offset
must be transformed to global coordinate system to be applied properly.
This approximately fixes the top-left resizing of transformed surfaces.
However, it suffers from drift due to accumulating rounding errors in
continuous resizing.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Change weston_surface_damage*() functions to use the full surface
bounding box or call surface_compute_bbox() to find the bounding box for
an arbitrary rectangle.
This should fix all rendering artifacts for non-opaque (i.e. ARGB)
transformed surfaces.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Use the bounding box to compute an approximation of which output
contains most of the surface.
Move the region32 init outside the loop, and fini it, too.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
If we ever have transformed cursor surfaces, we would better use the
bounding box to check if it is on the given output.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Use the proper bounding box in clipping the surface repaint area. Fixes
excessive clipping for transformed surfaces.
Also don't leak the region32 on early return.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
weston_surface::transform.boundingbox depends on width and height, and
therefore geometry.dirty flag, so move width and height into geometry.
Fix all users and check that the dirty flag is set.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Compute a surface bounding box, especially for transformed surfaces, for
which one cannot simply use x,y,width,height.
The bounding box depends on width and height, so these are now under the
geometry.dirty flag.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
weston_surface::transform.position depends on x,y, and therefore the
dirty flag, so move x and y into geometry.
Also add the missing dirty flags.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>