Culling of the repaint of a surface behind an opaque surface on the
same plane was broken by commit 547149a9 [1]. The idea of that commit
is that the damage obscured by an overlay would remain on the primary
plane damage and be repainted when the overlay moved. However, in the
case the two surfaces are on the same plane, the opaque one is not
obscured, so it ends up being repainted.
This commit adds an opaque field to struct weston_plane, that is built
incrementally when accumulating damage. The opaque region of surfaces
on the same plane are removed from the plane's damage, restoring the
previous culling behavior. But since damage behind opaque region of
other planes is maintained, the bug solved in the mentioned commit is
not regressed.
https://bugs.freedesktop.org/show_bug.cgi?id=56537
Partial repaints have been broken since the introduction of the atomic
surface updates. The problem was that surface_commit would set the
geometry dirty flag unconditionally, causing transform updates on every
frame which would in turn cause weston_surface_damage_below() to damage
the whole surface area.
This patch changes this so that flag is only set if the pending buffer
has a different size, the location of the surface changed or the opaque
region changed.
Note that changing the opaque region will cause a full repaint of the
affected surface, because of the transform update.
https://bugs.freedesktop.org/show_bug.cgi?id=56538
When tiling window managers resize a non-resizable window they're violating
ICCCM. Not some hippie-community standard like EWMH, but ICCCM, which is
about as old and sacred as the constitution. If they want to force a window
to be a size it wasn't designed for, at least they could have the decency to
reparent the client window into a bigger containing window of whatever size
they think it should be. But apparently ICCCM compliance is too much to ask.
Anyway, all that just to say that it's really not our fault when we get an
enter event with coordinates outside the valid output region. But we'll
clip it anyway and work around mis-behaving tiling WMs.
Rather than delivering touch events directly to clients, we'll now
call through the touch grab handler. The default handler (in
wayland-server) will deliver these events the same way they worked
before.
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
libwayland-server was changed to emit the new drag icon signal instead
of faking an attach event with a NULL buffer so this has to be done on
this side.
event-test assumes, that even without the very first wl_surface.attach
(and commit), the surface will have infinite (previously undef) input
region. event-test simply has test-client to create a wl_surface, and
then it forcefully sets its position and size, and assumes the input
region is now the full surface, so that notify_motion() will hit it.
Change Weston to initialize the input region to infinite, instead of
empty.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Apply wl_surface.frame request only on the next wl_surface.commit
according to the new protocol.
This makes it explicit, which repaint actually triggered the frame
callback, since commit schedules a repaint. Otherwise, something causing
a repaint before a commit could trigger the frame callback too early.
Ensure all demo clients send commit after wl_surface.frame. Note, that
GL apps rely on eglSwapBuffers() sending commit. In toytoolkit, it is
assumed that window_flush() always does a commit.
compositor-wayland assumes renderer->repaint_output does a commit.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
In weston, the wl_resource:data field for a wl_surface object always
contains struct weston_surface *, never struct wl_surface *.
Even though this is just a cosmetic fix, it should reduce confusion.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Make input region double-buffered as specified in the new protocol.
While doing it, get rid of the undef region code, and instead use a
maximum sized real pixman region. This avoids special-casing regions
that might sometimes be undef.
As the input region is now usable by default instead of undef,
weston_surface_update_transform() does not need to reset the input
region anymore.
weston_surface_attach() no longer resets the input region on surface
size change. Therefore, also weston_seat_update_drag_surface() does not
need to reset it.
Update toytoolkit to set input region before calling wl_surface_commit()
or swapBuffers (which does commit).
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Make wl_surface.set_opaque_region double-buffered as required by the new
protocol. Also, do not reset the opaque region on surface size changes
anymore. Only explicit requests from the client will change the region
now.
In clients, make sure commit happens after setting the opaque region.
Mesa does not need a fix, as it never touches the opaque region.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This change depends on the Wayland commit
"protocol: double-buffered state for wl_surface".
Implement double-buffering of damage in the compositor as required by
the new protocol.
Ensure all Weston demo clients call wl_surface_commit() after
wl_surface_damage().
Mesa does not need a fix for this, as the patch adding
wl_surface_commit() call to Mesa already takes care of damage, too;
Mesa commit: "wayland: use wl_surface_commit()"
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This change depends on the Wayland commit
"protocol: double-buffered state for wl_surface".
Clients are now required to issue wl_surface.commit for the
wl_surface.attach to take effect.
While changing this, change the surface argument to
weston_surface_attach() from wl_surface into weston_surface, for
consistency.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Also make all the callers of weston_surface_assign_output() update the
transform instead. This makes sure that when the surface is assigned an
output its bouding box is valid.
This fixes a bug where a newly created surface would have a NULL output
assigned. This would cause weston_surface_schedule_repaint() to not
schedule a repaint, preventing the surface to be shown until something
else caused a repaint.
This is a more generic fix for the issue solved in 4f521731 where
damage obscured by overlays could be lost in one of the output buffers
due to rapid move of a surface in an overlay plane.
This changes the renderer so it keeps track of the damage in each
buffer. Every time a new frame is drawn, the damage of the frame is
added to all the buffers and the rendered regions are cleared from
the current buffer's damage.
Have only one text_model_factory instead of one per seat.
This commit also introduces destruction of an input method when the
corresponding seat is removed.
Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
When accumulating damage in the surfaces into the primary plane damage,
regions obscured by the opaque region would be excluded. This causes a
bug when a redraw of a surface is obscured by an opaque surface on
another plane. The drawing to the former surface is clipped but
its damage is never added to the primary plane and is just lost. Moving
the opaque window later reveals the not-up-to-date content below it.
We can now load any number of general modules, and the shell and xwayland
are just two of them. We continue to use the mechanism for testing but
custom input drivers or logging mechanisms, for example are other use cases.
We rename it flush_damage() as it's the point where we update our rendering
API source (eg, the gles2 texture) according to the accumulated damage,
if necessary.
We move the EGL and GLES2 output repaint code into a new gles2-render.c
file. The eglMakeCurrent, glViewPort, surface loop etc was duplicated
across all backends, but this patch moves it to a new file.
surface_accumulate_damage() will call surface_compute_bbox() with the
extents of the surface damage region, for transformed surfaces only. If
there is no damage, surface_compute_bbox() will round up the empty
rectangle to a 1x1 rectangle. Triangles are produced for this 1x1
rectangle intersected with the surface.
The problem showed up with the triangle fan debug, where some seemingly
garbage pixels showed up relative to rotated surfaces.
Fix this by explicitly checking, that the area, for which a bounding box
is being computed for, is not zero.
Note, that the bbox will also be empty if only one of width and height
is zero. We do not paint things with zero thickness.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Cc: Rob Clark <rob.clark@linaro.org>
The intersection of two rectangles is guaranteed to be convex. Therefore
we do not need a center vertex for the triangle fan, we can simply use
the whatever first vertex the intersection polygon has. This reduces the
number of triangles, while still painting the exact same area.
While at it, emit_vertex() nested function is factored into the
for-loop, since that is the only calling site left.
Comments are updated to reflect the changes, and some unrelated comment
fixes are in repaint_region().
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Cc: Rob Clark <rob.clark@linaro.org>
- make it respect output transforms by making sure the uniforms are
up-to-date
- properly restore the current shader program, in case it was
overridden
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
weston_surface_draw() is restructured so that it will always use the
RGBX shader for opaque regions, if the surface is assigned the RGBA
shader.
Previously for opaque regions, we simply assumed, that the texture alpha
would be 1.0. If it was not (which really is an application bug), the
region would be misrendered. The RGBX shader forces the texture alpha to
1.0.
Xwayland surfaces may have bad alpha data in the opaque client area. If
blending was enabled, the bad alpha would be used with the RGBA shader.
This patch fixes rendering opaque xwayland windows with full-surface
alpha applied.
Test case: xterm, with full-surface alpha one step below 1.0. Before,
black text was fully transparent, now it is correctly only slightly
transparent.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Remove weston_surface::opaque_rect completely.
Instead, set the opaque region in xwayland.
Before this patch, black text in xterm was transparent. Now it is not.
However, this patch fixes only a part of the alpha problem. If you apply
full-surface alpha with super+alt+wheel, the problem reappears. This
problem is still due to bad alpha channel contents on xwayland windows.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Draw the borders of all the triangles.
v1: original
v2: add keybinding to enable/disable fan debug (super-alt-space),
cycle colors to make it easier to see individual draws, and
redraw undamaged region to clean up previous frames debug
lines
Signed-off-by: Rob Clark <rob@ti.com>
We can use and render the opaque region only, if we are not applying a
full-surface alpha.
Test case: weston-terminal; use super+alt+mousewheel to adjust the
window transparency. Before it went black, now it blends correctly.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Remove the weston_surface::blend attribute, which really meant that the
texture produced valid alpha values. This was used to override the opaque
region for RGBX surfaces, which produce undefined values for alpha.
Instead, compile a new shader especially for RGBX surfaces, that
hardcodes the sampled alpha as 1.0.
Before "compositor: optimize/simplify shaders" there was a 'vec4 opaque'
in the shaders, that would cause part of the texture to be forced to
alpha=1.0. Now that is gone, and we need this replacement.
To test: launch simple-shm, and use the super+alt+mousewheel combination
to make it transparent. It should not show a light cross over the window.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Re-work how the shaders and emitted vertices work. Rather than always
rendering clip-rect sized quads and doing transformation in tex coords
(and requiring the corresponding clipping in frag shader), instead
emit transformed vertices, clipped wrt. dirty region, and use simpler
frag shaders. Also, split the rendering, so blended surfaces with an
opaque region have the opaque region drawn with blend disabled. The
result is considerably fewer pixels drawn with blend enabled, and much
fewer cycles in the frag shader.
This requires having some more complex logic to figure out the vertices
of the shape which forms the intersection of the clip rect and the
transformed surface. Which has perhaps got a few bugs or missing cases,
still (visual glitches in some cases) but at this point more or less is
starting to work. I think it is at least far enough along to get some
initial review.
The result, on small SoC GPU (omap4/pandaboard) on 1920x1080 display,
for simple stuff like moving windows around, I get 60fps (before 30fps
or less), and pushing YUV buffers for hw decoded 1080p video goes from
~6fps to 30fps, with no drop in framerate for transformed/rotated video
surface.
v1: original
v2: check that perpendicular intersect vertex falls within bounds of
transformed surface
v3: update w/ comments and fixes from Pekka Paalanen
v4: fix for full surface alpha from Pekka Paalanen, fix compositor-
wayland build
Signed-off-by: Rob Clark <rob@ti.com>
In cases where the GPU can natively handle certain YUV formats,
eglQueryWaylandBufferWL() can return the value EGL_TEXTURE_EXTERNAL_WL
and the compositor will treat the buffer as a single egl-image-external.
See:
http://www.khronos.org/registry/gles/extensions/OES/OES_EGL_image_external.txt
v1: original
v2: rename EGL_TEXTURE_EXTERNAL_OES -> EGL_TEXTURE_EXTERNAL_WL and query
for the extension
v3: fix build without updated mesa headers, if EGL_TEXTURE_EXTERNAL_WL
#define is missing from older mesa headers.
v4: resend without missing parts
Signed-off-by: Rob Clark <rob@ti.com>
This patch allows rotation and mirroring outputs for x11 and drm backends.
A new 'transform' key can be set in the [output] section. From the protocol:
"The flipped values correspond to an initial flip around a vertical axis
followed by rotation."
The transform key can be one of the following 8 strings:
normal
90
180
270
flipped
flipped-90
flipped-180
flipped-270
Instead of clearing the whole output region after a repaint, clear
only the regions that were actually painted. This way, the damage
added when a surface moves from the primary plane to another one is
kept while this region is obscured by the opaque region. This allows
the contents below an overlaid surface to be culled, but to make this
work properly, it is also necessary to change the way previous damage
is drawn.
Consider the following scenario: a surface is moved to an overlay plane
leaving some damage in the primary plane. On the following frame, the
surface on the overlay moves, revealing part of the damaged region on
the primary plane. On the frame after that, the overlaid surface moves
back to its previous position obscuring the region of the primary plane
repainted before. At this point, the repainted region was added to the
output's previous damage so that it is draw to both buffers. But since
this region is now obscured, the redrawing is skipped. If the overlaid
surface moves again revealing this region, one of the buffers actually
contains the wrong content.
To fix this problem, this patch ensures that any previous damage that
would be lost is actually preserved by folding it back into the
primary plane damage just before repainting.
This way we map the surface if it currently isn't mapped and avoid
duplicating some of the code already in pointer_cursor_surface_configure().
Without this, the cursor code relied on a wl_surface.attach() to show the
new pointer surface. If we're not changing the cursor buffer, we don't
get that, but we still need to map the cursor.
Add a wl_seat argument to the activate and deactivate requests of
text_method.
On activation a text_model gets assigned to the input_method of the
wl_seat specified in the activate request.