The OpenGL missing segments (when small) are due to rounding in larger
coordinates. The GAL shader uses floats to represent int32 values for
position and distance. Thus, at larger coordinates, the smaller integer
values cannot be represented accurately. This tests for the rounding
error and, if it exists, draws a plain circle instead
Fixes https://gitlab.com/kicad/code/kicad/issues/5751
Cairo Polyline and Polygon draw functions share a common routine. While
Polygons must have 3 points to allow triangulation, a polyline (like our
text) need only have 2
This resolves a crash when passing an empty polygon and alerts debug
users to possible generation cases when bad polygons are created.
Thanks for Frans Zellman
(https://gitlab.com/kicad/code/kicad/-/merge_requests/365) for
identifying the issue.
The use of printf, wxLogDebug, and std::err/std::out causes excessive
debugging output which makes finding specific debugging messages more
difficult than it needs to be.
There is still some debugging output in test code that really needs to
be moved into a unit test.
Add debugging output section to the coding policy regarding debugging
output.
On platforms with limited framebuffer attachments, like GC7000L
driven by the open source etnaviv driver, we can still use
GPU acceleration by drawing directly to the main buffer.
EDA_DRAW_PANEL_GAL::onPaint checks if an overlay target is
available in the GAL, and if not, redraws the whole view if the
overlay target should be dirty.
Clearing of the overlay target is a no-op if there is no overlay
buffer.
Signed-off-by: Lukas F. Hartmann <lukas@mntre.com>
When drawing segments that are smaller than the segment width, OpenGL
did not use realistic values, leading to hidden, small tracks. Instead,
we set the track to only draw a segment when the length is at least 1
radius long (so that we can see the full semi-circle at the track end)
Fixes https://gitlab.com/kicad/code/kicad/issues/5009
- New public static function OPENGL_GAL::CheckFeatures() gets called in EDA_DRAW_PANEL_GAL::SwitchBackend() before switching to OPENGL_GAL
- Moved all OpenGL feature checks from OPENGL_GAL constructor to OPENGL_GAL::init()
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4714
Swap syncs can limit the redraw rate as the screen waits for previously
issued syncs. Setting this to -1 allows for adaptive swapping
(resorting to unsynced if it falls behind) if it is supported by the
card but will fall back to unsynced (0) if the adaptive is not
supported.
Fixes https://gitlab.com/kicad/code/kicad/issues/4226
The scaling factor stored inside the canvas is created by a DPI_SCALING
helper, which will call the platform-specific functions if no user scaling
is specified. This change only affects OSX and Retina displays, so this
now also allows custom scaling to be used on OSX if desired (although it
shouldn't be needed, since wx has detection for it in 3.0.4).
* Split up the thirdparty code into the thirdparty folder (#3637)
* Create a new kimath static library containing all the math functions
This is part of cleaning the build system for #1906.
This update replaces the existing uses of unique pointer creation with
the C++14 std::make_unique call that provides proper memory release in
event of an exception.
Note that since the markup might exist for other reasons, it has
to be turned on with a preference setting. (It goes through a set
of bitflags so the same architecture can be used for other markup
structures that we might want to support in the future.)
Note also that this is more about engineering nomenclature than
visual formatting. In that respect it's more similar to overbar
than italic or bold.
This allows a const BITMAP_BASE to expose const image
data. This is currently done with const_casts, which is
"OK", only as long as the source image is not declared
const, in which case it's undefined behaviour.
Also immediately dereference the pointer to a reference
if it's not checked to make the non-null requirements
explicit at the point of access.
Both Cairo and OpenGL had issues (different, though) with circles that are
thicker in line width than they have radius. This corrects the OpenGL
implementation (radius is calculated to the outer edge) as well as Cairo
(line width needs to be clamped to twice the radius)
Fixes: lp:1822765
* https://bugs.launchpad.net/kicad/+bug/1822765
First, add automatic detection of toolkit DPI scaling options. For now, this
is, in order,
* Check the GDK_SCALE option under GTK+ (users can set this to force the scaling)
* Check the value from WX's GetContentScalingFactor(). This will start to work
correctly from WX 3.1 and GTK+ 3.10.
Then, add a user-settable override in the main prefs panel, next to the icon
scaling. This is independent of the icon scaling options.
DPI handling is performed in a standalone class, so they can be shared between
the prefs UI and the OpenGL backend easily. Also means Cairo could use the same
interface in future.
Also adjust the OpenGL grid drawing code to use the computed scale factor,
which avoids over-thick grids in scaled environments (the user can manually
thicken the grid if wanted).
Fixes: lp:1797308
* https://bugs.launchpad.net/kicad/+bug/1797308
And filled but we don't use those yet. No pixel-alignment needed for
stroked semi-circles (I think) as we set the pixel width to be 1
regardless of the zoom level.
Fixes: lp:1816263
* https://bugs.launchpad.net/kicad/+bug/1816263
gal: pixel alignment for Cairo.
gal: pixel alignment for OpenGL
Cleanup of pixel alignment patches
gal/opengl: more pixel alignment patches:
- works on Retina displays now
- pixel alignment for circles
- correct 1-pixel strokes
- fixed unfinished 1-pixel line ends
GAL: Restore antialiasing options in Cairo
GAL: Fix arc drawing
Removes DrawArcSegment, which drew arcs whose edge was optionally
stroked (a feature that we did not use). Fixes Cairo arc drawing issue
where arcs were not visible in pcbnew.
gal: further cleanup
gal: removed unused shader parameter
Bitmaps loaded via wx can contain alpha channels. We utilize underlying
routines to correctly map the alpha. This also standardizes the Cairo
alpha calls to ensure correct display in Fallback for partially
transparent highlights
Fixes: lp:1809845
* https://bugs.launchpad.net/kicad/+bug/1809845
If a page layout contains bitmaps and is used in all sheets of a hierarchy, and in the board editor,
the cross-probing from pcbnew to eeschema invalidate textures associated to these shared bitmaps,
when switching active sheets.
Usually a crash happens after switching or when closing editors.
As a workaround, I disabled bitmaps (therefore associated textures) cache.
Not optimal, but at least it avoid crashes.
Display GALs had an incorrect world unit value set. Now the world unit
value says how many internal units are in an inch, in accord with the comments
in the GAL header. Bitmap drawing code relied on the information about DPI,
so scaling worked differently for display and print GALs.
Fixes a crash when typing fast in the place footprint filter box.
Also adds a bunch more checking to GAL locking, including making
sure the same person unlocks as locked, and preventing piece-meal
calls (the RAII objects must be used).
It happens when the char is not found in the font used to display netnames/pad names.
When happens, a wxASSERT is raised.
Unfortunately it can crash the application if it is during a paint event or some critical time.
This prevents deadlocks when exceptions are thrown and the context
ends up not getting unlocked.
It also removes an earlier hack to try and minimize this which
didn't work anyway.
Happens only in Opengl mode.
So enforce controls in 3 group function: DrawGroup, ChangeGroupColor, ChangeGroupDepth.
Fixes: lp:1795044
https://bugs.launchpad.net/kicad/+bug/1795044
Replaces Poly2Tri with updated code to process polygons faster and more
robustly. Notably, we can now handle overlapping holes in the polygons,
allowing us to cache the triangulation of complex boards
wxGLCanvas::IsDisplaySupported() handles wxGL_{MINOR,MAJOR}_VERSION
attributes only in 3.0.4. Since 3.1.0 the attributes are apparently not
supported, so instead wxGLContext::IsOK() is used (introduced in 3.1.0).
Fixes: lp:1775995
* https://bugs.launchpad.net/kicad/+bug/1775995
In Cairo mode, this function uses already the alpha color value setting.
Now for low alpha values (usually they are low, as said in many GAL comments),
Cairo mode and OpenGL mode should have a similar look.
In theory there should be no polygons with empty outline, but as you see
there was at least one leading to a crash.
Fixes: lp:1739455
* https://bugs.launchpad.net/kicad/+bug/1739455
The polygon drawing routing in the OpenGL-GAL did
not plot polygons which are "closed", i.e. have a segment
from their last point to their first point, correctly.
That segment was omitted.
This commit fixes this bug.
The OPENGL_GAL::drawPolygon function and all functions using it
did not respect the isFillEnabled member set by
GAL::SetIsFill. This is fixed by this patch.
Moved the code handling text overbars to a single function
(ProcessOverbars()) to replace similar pieces of code trying to do the
same thing.
Fixes: lp:1735906
* https://bugs.launchpad.net/kicad/+bug/1735906
Previous implementation uploaded only vertices with indices less
or equal to the number of stored vertices, which is invalid when
the container become fragmented.
Fixes: lp:1712887
* https://bugs.launchpad.net/kicad/+bug/1712887
- support for background color setting
- removed several global config settings (such as g_Drc_On)
- wrapped most of global config settings in PCB_GENERAL_SETTINGS class
- reorganized PCB general options dialog to clearly mark which options concern only the legacy canvas
- new GAL feature for legacy users: double-click (or E) to change track width available as an option.
Fixes: lp:1530543
* https://bugs.launchpad.net/kicad/+bug/1530543
Fixes: lp:1707145
* https://bugs.launchpad.net/kicad/+bug/1707145
The currentTarget member of OPENGL_GAL is not initialised, but the
currentManager member is.
This commit uses SetTarget to initialise both target and manager to a
consistent state at construction.
The motivation here is to concentrate display options in the GAL display
settings, ready for removal of legacy canvases. Instead of having the
property as a member of the DRAW_FRAME, with the GAL canvas retreiving
it from there, it is now in the GAL_DISPLAY_OPTIONS struct, and both GAL
and legacy get it from there.
The options for setting cursor shape are then moved out of the general
options dialog, and into the GAL display options widget, where they can
be used in all GAL-aware programs.
GAL cursor shape works on GAL, but not legacy, so the option is now
available on OSX (but only affects GAL, and is labelled as such).
This makes it clearer when a tool is active, otherwise interactive tool
effects like auto-pan can come as a surprise when the cursor is forced
to display all the time.
When drawing polylines using SHAPE_LINE_CHAIN, the polyline is always
was drawn closed in GAL and open in Cairo, regardless of the state of
SHAPE_LINE_CHAIN.
This allows the user to set a thicker grid line without causing the
grid lines to become over dense, or just make the grid denser according
to preference.
The term "density" is modified to "minimum grid spacing", which is
the pixel spacing between adjacent grid lines.
The spacing settings now comes in along, with other GAL display settings,
as part of GAL_DISPLAY_OPTIONS observer functionality. To this end, the
setter in GAL interface is removed, as an external user should be
setting this parameter via the GAL_DISPLAY_OPTIONS interface.
This adds a user-settable control for the grid line thickness on GAL
canvases to the display options dialog.
The thickness settings now comes in, along with other GAL display
settings, as part of GAL_DISPLAY_OPTIONS observer functionality. To this
end, the setter in GAL interface is removed, as an external user should
be setting this parameter via the GAL_DISPLAY_OPTIONS interface.
Fixes: lp:1662482
* https://bugs.launchpad.net/kicad/+bug/1662482
Some faults could result in a crash, as they were not properly
handled. Now the rendering loop is wrapped with try..catch block
which will revert to Cairo in case of an error and display an
error message.
Fixes: lp:1655766
* https://bugs.launchpad.net/kicad/+bug/1655766