Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectorscope render fix #7652

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

michaelgregorius
Copy link
Contributor

The rendering of the Vectorscope is broken on Wayland if the size of the Vectorscope is increased. This is caused by using a QImage to render the scope traces which is then scaled up.

The fix introduce a new implementation of the paint method which simply paints lines or points that progressively get dimmer without using a QImage anymore. It is possible to switch between rendering lines or points using the "Lines" control.

The following shows a comparison between the old and the new implementation (using commit c0538b1). It shows the performance difference and switching between rendering lines and points with the new implementation:

LMMS-VectorScopeExecutionTimes.webm

Feature changes

It supports the following pre-existing features:

  • Log mode
  • Zooming
  • Rendering the drawing performance
  • Selecting a different color for the traces

It does not support anymore:

  • HQ Mode: The new implementation provides a performance that's equivalent to Non-HQ mode while looking better than the old HQ mode.
  • Persistence: It would likely only introduce clutter and might potentially decrease performance.

Style sheets

The Vectorscope now supports style sheets by introducing Qt properties for the relevant colors. The default theme gets the values from the code whereas the classic theme gets a trace with amber color.

Technical details

Rendering of the samples/trances uses the composition mode "Plus" so that overlapping elements will appear like adding brightness. Painting the grid and lines is done using the normal composition mode "Source Over" so that it simply replaces existing pixels.

Painting of the lines/points and the grids and lines is done in a "signal space", i.e. a transform where elements in the interval of [-1, 1] feel "natural". The text is painted in "widget space".

Other changes

  • Move the colors out of VecControls into VectorView as they are related to presentation.
  • Remove a friend relationship to VectorView from VecControls by introducing const getters for the models.
  • Remove the unnecessary member m_visible from VectorView. It was not initialized and only written to but never read.
  • Rename m_colorFG to m_colorTrace.
  • Remove unused member m_colorOutline.

Fixes #7518.

The rendering of the Vectorscope is broken on Wayland if the size of the
Vectorscope is increased. This is caused by using a `QImage` to render
the scope traces which is then scaled up.

Introduce a new way to paint the vector scope (goniometer) which simply
paints lines or points that progressively get dimmer and which does not
make use of a QImage anymore.

It supports the following features:
* Log mode
* Zooming
* Rendering the drawing performance
* Selecting a different color for the traces

It does not support:
* HQ Mode: The new implementation provides a performance that's
  equivalent to Non-HQ mode.
* Blurring of old data
* Persistence: Might be implemented by using a factor for the dimming

This commit introduces new controls:
* Lines mode: Switches between painting lines or points in the new
  implementation
* Legacy mode: Use to switch between the new and the old rendering. Only
  used during development as the old mode will be removed completely.

Rendering of the samples/trances uses the composition mode "Plus" so
that overlapping elements will appear like adding brightness. Painting
the grid and lines is done using the normal composition mode "Source
Over" so that it simply replaces existing pixels.

Painting of the lines/points and the grids and lines is done in a
"signal space", i.e. a transform where elements in the interval of
[-1, 1] feel "natural". The text is painted in "widget space".

The "HQ" button and the "Persistence" knob have been temporarily made
members so that they can be hidden in non-legacy mode. They will later
be removed completely.

Rendering in "Log" mode currently paints a horizontal line for silence.
It needs to be investigated why this is the case. It's likely caused by
the division by the distance of the points from the origin. If this
becomes very small (and non-zero) then the division might produce large
values.
Use the `SampleFrame` representation as long as possible when doing the
calculations in the paint method.
Remove HQ mode and persistence. Also remove the legacy option again.
This removes the models, loading, saving and the GUI controls.

Remove all unnecessary members from `VectorView`, adjust the
constructor. Move the implementation of `paintLinesMode` into
`paintEvent`. Remove methods `paintLegacyMode` and `paintLinesMode`.
Move the colors out of `VecControls` into `VectorView` as they are
related to presentation.
Remove a friend relationship to `VectorView` from `VecControls` by
introducing  const getters for the models.
Remove the unnecessary member `m_visible` from `VectorView`. It was not
initialized and only written to but never read.
Make the Vectorscope themeable by introducing Qt properties for the
relevant colors.

The default theme gets the values from the code whereas the classic
theme gets a trace with amber color.
Rename `m_colorFG` to `m_colorTrace`. Adjust the Qt property
accordingly.

Remove local variable `traceColor` from paint method and use member
`m_colorTrace` directly.
Remove unused member `m_colorOutline`.
Fix the horizontal lines that are rendered on silence. They seem to be
produced when rendering lines that start and end at the same point.

Therefore we only draw a point if the current and last point are the
same.
Add some margin to the rendering of the `VectorView` so that the circle
does not touch the bounary of the widget.
Clean up the layout of the Vectorscope. The checkboxes are not put on
top of the vector view anymore but are organized in a horizontal layout
beneath it. This gives a much tidier look.
@michaelgregorius
Copy link
Contributor Author

After adding some margins and cleaning up the layout the Vectorscope now looks like this:

7652-MarginAndCleanedLayout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken rendering of Vectorscope
1 participant