As weston_windowed_output_get_api needs ARRAY_LENGTH() move helpers to a
libweston/ so other users can re-use that instead of re-defining these
all over. Easier for other front-ends to make use of them.
With this change windowed-output-api.h also includes the helpers header.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
The debug clear region must be generated out of the current render
buffer's damage region, not out of the current damage region, unless
shadow 16F is enabled.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
eglSetDamageRegion() requires a postable surface and shouldn't be
called with EGL_NO_SURFACE.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Revert active unit to default value right after use so that other
functions can assume the default state. A best practices section is
added to the internal header for reference.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
The wireframe unit can only be used by the wireframe texture so
there's no need to bind it anymore before use.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Merge duplicated gl_renderer_attach_dmabuf() and
gl_renderer_attach_egl() functions into a single
gl_renderer_attach_buffer() one.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Revert pixel store's GL_UNPACK_* changes to default values right after
use so that other part of the code can assume the default state.
Fixes: #928
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Revert pixel store's GL_PACK_REVERSE_ROW_ORDER_ANGLE changes to default
value right after use so that other part of the code can assume the
default state.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Revert pixel store's GL_PACK_REVERSE_ROW_ORDER_ANGLE changes to
default value right after use so that other part of the code can
assume the default state.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Prepare gl_renderer_do_read_pixels() so that the default pixel storage
states can be more easily reverted to default before return.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
These were only necessary to allow surface_copy_content to return contents
that included recently attached (but not yet rendered) buffers.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Instead of attaching and flushing damage when performing
weston_surface_copy_content, just return the contents as the renderer
currently knows them.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
If the renderer uses the EGL_PLATFORM_GBM_KHR, the egl_native_display is already
a gbm_device and the renderer doesn't have to create another device.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
The GL renderer is able to use a gbm_device to allocate gbm_bos, which can be
used as DMABUFs.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Support importing dmabuf buffers as renderbuffers and binding them to
FBOs. These can then be rendered to directly, or they can be blitted
into from the shadow render buffer.
How to best create those dmabuf buffers in the backend is an open
question and may vary depending on what external API the backend is
interfacing with.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
The renderbuffer list is the reason for keeping a reference for the
renderbuffers in the gl-renderer. Add helper functions to make this explicit.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
The GL renderer uses the bottom left corner as origin. Therefore, the buffers
must be flipped when using ReadPixels to have a image in the correct orientation
for screenshots. If the rendered buffers are directly passed to a different
application without going through ReadPixels, the rendered buffer appears upside
down.
Flip the rendered image in the FBO to fix the orientation when directly using
the rendered buffer. Update read_pixels to not flip the image in these cases.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
read_pixels may use the top left or bottom left corner as origin.
As the renderer may render the image upside down based on the y_flip variable.
read_pixels must read the image with the same origin as used by the renderer to
produce a correct image.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
The GL renderer uses the bottom left corner as origin and several
transformations in the renderer assume this corner as origin.
Make this assumption explicit by introducing a y_flip variable that is used to
calculate transformation that are caused by this origin.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Avoid the calculation of the y-flipped coordinates when transforming the pixman
region to the vertex coordinates by initializing the projection matrix to
already include the y-flip.
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
This moves debug mode setup to a dedicated function because the
addition of new modes made it bigger.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
The shaders debug mode doesn't have much interest now that other more
specific debug modes show shaders too.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
The batches debug mode tints each batch of a repaint pass in a
different color in order to highlight batches.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
The wireframe debug mode needs to clear the current renderbuffer in
order to clean up old wireframes lying around. This commit makes this
system generic for upcoming debug modes with similar needs.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
In order to avoid the complexity of handling multiple debug modes at
the same time, this commit makes wireframe a proper debug mode. It
also uses the new tinting system to make the white wireframe pop over
a darkened damaged region.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Don't color sub-mesh differently in wireframe mode. There's not much
interest in being able to distinguish the sub-meshes in a paint node
and this allows to simplify the logic by removing the color vertex
stream.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Current green tint support is a hard-coded Porter-Duff premultiplied
blending of a green source (slightly skewed on the green channel) over
the updated damaged destination. This commit makes green tinting
generic by letting the shader user provide a custom tint color.
The goal is to reuse that system for the upcoming debug modes.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Set up debug mode initial infrastructure using a dedicated key binding
and make shaders debug a debug mode.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
After c08a6ff8 moved attach to the render loop, we have a bad situation
when clients delete an attached shm buffer. We try to query the stride
at attach time, but the shm_buffer has been destroyed, and we crash.
Instead of carefully fixing that, I've instead stored the stride at
buffer creation time (as we already do with buffer width and height).
This lets attach succeed in the gl-renderer, keeping the old texture data
available for any upcoming rendering.
Fixes: #927
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Tested-by: Connor Abbott <cwabbott0@gmail.com>
is_fully_opaque takes precedence over opaque region, so we shouldn't
replace surface_opaque with the opaque region when is_fully_opaque is
true.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We can skip posting damage beneath planes that are fully translucent,
but that doesn't mean we can skip posting damage beneath planes that
are not fully opaque.
Add a check for content that is entirely blended, and use that instead.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Render wireframe within paint nodes instead of drawing lines in a
second pass. The wireframe is blended over the node in a single draw
call. This slightly simplifies the logic by removing the computation
of a second set of indices and enables wireframe anti-aliasing using
Celes and Abraham's "Fast and versatile texture-based wireframe
rendering" paper from 2011.
Celes and Abraham use a one-dimensional set of texture coords for each
triangle edge, 1.0 for the 2 vertices defining the edge and 0.0 for
the other vertex, which basically define barycentric coords. Texture
mapping and the mip chain is then exploited to give a constant-width
edge. The main drawback of the technique is that contour edges of
node's damage mesh are drawn half as thick as interior lines since
each triangle draws half of each line's thickness.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
Wrap compiler builtins into shared functions with proper generic
implementations. __builtin_clz() isn't wrapped for now because its use
by screenshooter is pretty specific. It will be properly wrapped in
the next commit which needs a round up to the next power of 2
function.
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
With attach only being called at render time, the dmabuf can be deleted
along with its private data before we attach for the first time.
Let's move the first-time logic into its own callback to call at
buffer setup time instead.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
By moving this here we can use the information to disable damage tracking
for placeholder surfaces, as well as render them entirely opaquely.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We test if the surface is fully opaque during paint node updates, and
store that information. Now that we've refactored the blended calculations
a little bit, we can easily use this test to make paint_node->is_opaque
override the blend calculation entirely.
This is preparation for future patches that will override is_opaque
when performing content censoring or fallback rendering of solid colors
for weston_direct dmabufs.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
These should effectively be the same, thought the one we've calculated
may be clipped with the scissor. The end result of the math should be
identical.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Since we only call this from the paint node update code now, we can pass
the paint node directly.
A bit of internal refactoring is required to support copy_content.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Instead of doing this in several places, just do it when we're updating
the paint nodes in the repaint loop, or when we're about to copy
content via weston_surface_copy_content().
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Currently we're passing in a surface, a buffer, and an output. All of
these things are available in the paint node.
Further, if we pass in the paint node directly, we don't have to walk
a list of paint nodes to figure out if the texture is used in the
upcoming repaint.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>