Commit Graph

319 Commits

Author SHA1 Message Date
Jeff Young 5888d376a7 Handle special cases for ending overbar text.
Fixes https://gitlab.com/kicad/code/kicad/issues/6695
2020-12-10 18:38:31 +00:00
Roberto Fernandez Bautista 33385d0bb0 Combine return statements in OPENGL_GAL::CheckFeatures 2020-10-30 20:17:27 +00:00
jean-pierre charras 73c7154891 Fix another Coverity warning. 2020-10-27 14:16:38 +01:00
Jeff Young 66e3e12a9d Allow screen rendering to be maxError out from WYSIWYG.
Correcting the error is more trouble than it is worth, and anyway
might not be corrected exactly the same way plotting/filling/DRC
is corrected anyway.
2020-10-24 19:39:19 +01:00
jean-pierre charras cc81d97f78 Opengl DrawArcSegment(): refinements for a better look of control points.
Use a segment count multiple of 2, because we have a control point on the
middle of the arc, and the look is better if it is on a segment junction
because there is no arc to segment approx error
2020-10-24 17:26:44 +02:00
jean-pierre charras 6d12a0c95b OPENGL_GAL, DrawArcSegment(): do not modify the radius of arc.
The radius correction does not fix correctly approximation errors,
and creates serious issues for thin arcs:
- control point outside the arc
- HitTest active area outside the arc shown on screen
- Cairo and opengl gives different arc positions.
- the formula used in radius correction is probably incorrect.
2020-10-24 16:29:26 +02:00
Jeff Young 58c006bc45 Register properties for ARC elements so we can get their netclass.
Also improves GAL arc drawing and polygonization.

Fixes https://gitlab.com/kicad/code/kicad/issues/6039
2020-10-23 14:27:36 +01:00
Marek Roszko ae6900e7d7 Suppress the opengl test from generating "ghost frames" on Windows which appear and quickly disappear 2020-10-18 13:48:45 -04:00
jean-pierre charras f6b4b66a86 Avoid include wx/wx.h in many files that do not actually use this include.
Including wx.h includes the full set of wxWidgets include files, that is not good,
and can create some conflicts with some Windows headers on msys2.
2020-10-18 18:21:34 +02:00
Seth Hillbrand 76e44c2f4b pcbnew: Really deal with missing segments this time
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
2020-09-21 16:59:31 -07:00
Seth Hillbrand c1a97fc0c3 GAL: Revision to 80af7b3158, allow LIB_POLYLINE
LIB_POLYLINE has a filled/not completely stroked draw mechanism that
allows stroking singular lines that will skip the fill
2020-08-21 16:02:13 -07:00
Seth Hillbrand 80af7b3158 Fix GAL check to account for shared function
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
2020-08-21 15:18:25 -07:00
Seth Hillbrand 7fc222db98 GAL: Check that polygons have at least 3 points
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.
2020-08-21 09:36:41 -07:00
Seth Hillbrand ab58b67842 Adding triangulation viewing to AC
This adds a helper routine to visualize the quality of our
triangulation.  It also renames an excessively long variable name for
the arc editor
2020-08-12 06:22:45 -07:00
mntmn bf60482b5c OpenGL GAL: support fallback without overlay buffer
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>
2020-08-07 13:27:47 +00:00
jean-pierre charras 2d9b0b255b Better fix for OPENGL_GAL::DrawSegment() than initial commit 294dab.
segments having a length <= 1 internal unit are not drawn  in opengl gal.
So these segments are drawn as circle.
2020-07-31 15:41:21 +02:00
Seth Hillbrand 294dabf640 GAL: Fix issue with small tracks being hidden
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
2020-07-30 15:11:39 -07:00
jean-pierre charras 9f20c61fa7 Remove creation on the fly of a wxPaintEvent instance (fix previous commit). 2020-07-15 14:56:35 +02:00
jean-pierre charras 6366aa3ede Remove creation on the fly of a wxPaintEvent instance (final step).
This is not allowed in 3.1.4 wxWidgets.
2020-07-15 12:58:43 +02:00
Qbort f3f17401dc Fix OPENGL_GAL initialization sequence
- 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
2020-07-04 10:54:30 +00:00
Seth Hillbrand a210fd570f Set VSYNC to adaptive (if available)
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
2020-07-03 13:27:48 +00:00
Ian McInerney ab83c86210 Remove the platform-specific GetBackendScalingFactor from HIDPI_GL_CANVAS
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).
2020-06-05 00:15:54 +00:00
Jeff Young 1fb51d29ab Reverse interpretation of triple-tilde.
Fixes https://gitlab.com/kicad/code/kicad/issues/4396
2020-05-11 22:56:09 +01:00
jean-pierre charras 79e7a27492 Fix a few Coverity warnings. 2020-02-02 08:55:24 +01:00
jean-pierre charras ad3c4b37ab Fix a few coverity warnings 2020-02-01 15:15:51 +01:00
Ian McInerney 13b6028e1b Refactor all math into a new kimath library
* 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.
2020-01-07 17:12:59 +00:00
Ian McInerney 6faa2188ed Silence warnings on MacOS about OpenGL deprecation
Apple has apparently deprecated OpenGL and replaced it with
their Metal API. It still works for now though.
2019-12-28 16:05:03 +00:00
Seth Hillbrand b5f021ff9f Cleanup: Replace push_back with emplace_back
In cases where we create a new item and immediately push into a
container, the emplace idiom is faster and more efficient.
2019-12-05 13:41:21 -08:00
Seth Hillbrand a2edf9c442 Unified update to C++14 std::make_unique
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.
2019-12-05 10:43:55 -08:00
Jeff Young 89ace3b0d0 Apply the overbar fixes from the stroke font to bitmap text.
Fixes: lp:1852037
* https://bugs.launchpad.net/kicad/+bug/1852037
2019-11-18 11:36:30 +00:00
jean-pierre charras 01553a6bd1 FIX: add parameter to GAL::DrawCurve to control the curve to polyline conversion. Cairo supports curves, but not Opengl, that needs a conversion to polyline. This control allows optimization in conversion 2019-11-09 11:41:29 +01:00
jean-pierre charras 943858fd67 FIX: Bezier curves: replace previous algorithm to convert the curve to segments. In some cases it was not working well. Opengl was using an other algo (using the curve properties to create segments) Now only the OpenGL algo is used, with optimization to reduce the number of segments. 2019-11-09 11:41:29 +01:00
Jeff Young 35c8d64f98 Add super- and subscript support to Eeschema.
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.
2019-11-05 17:22:51 +00:00
Seth Hillbrand c3e07a5886 Cleaning Cairo GAL
Removed extra allocations that were not used.
Removed unneeded shared pointer
Corrected storage type from RGB to ARGB
2019-08-28 19:29:47 -07:00
Jeff Young a25368cc6b Improve spelling.
The groundwork here is thanks to kunda1.

Fixes: lp:1831510
* https://bugs.launchpad.net/kicad/+bug/1831510
2019-08-20 19:14:05 +01:00
Jeff Young c71c1d4d1a Prevent infinite loop when grid size not defined. 2019-06-01 00:17:04 +01:00
Ian McInerney 45f10fcff1 gal: Decoupled X and Y grid step sizes
Made the X and Y step sizes for the grid separate in the GAL.

Cleaned up the types inside the DrawGrid functions.

Fixes: lp:1821416
* https://bugs.launchpad.net/kicad/+bug/1821416
2019-05-28 20:07:45 -07:00
John Beard 15bba27406 BITMAP_BASE: Add const image data accessor
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.
2019-04-24 17:31:22 +01:00
John Beard 567bdd9b9d Add configuration of Hi-DPI canvas scaling in OpenGL
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
2019-03-25 15:00:55 +00:00
jean-pierre charras 140abd3952 Pcbnew: fix missing vertical grid lines in flip board view
Fixes: lp:1818154
https://bugs.launchpad.net/kicad/+bug/1818154
2019-03-01 11:09:40 +01:00
Seth Hillbrand 269f420f8d OpenGL: Create shaders for each GL
Fixes: lp:1817284
* https://bugs.launchpad.net/kicad/+bug/1817284
2019-02-25 09:31:42 -08:00
Seth Hillbrand dae7b03465 gal: re-enable arc outline mode
Fixes: lp:1816373
* https://bugs.launchpad.net/kicad/+bug/1816373
2019-02-21 10:52:54 -08:00
Seth Hillbrand 066b1782bb cairo: Fix grid display
Grid points were uneven in Cairo compared to OpenGL.  This standardizes
the functions for grid types and simplifies the code
2019-02-21 10:49:56 -08:00
Seth Hillbrand f1a60832e0 opengl: Handle stroked semi-circles
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
2019-02-16 19:57:23 -08:00
Tomasz Włostowski 85a7ab7795 gal: minor cleanup & formatting 2019-02-16 20:25:10 +01:00
Tomasz Włostowski bbee30671a gal: pixel alignment hacks, works for Retina display too now.
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
2019-02-16 20:03:13 +01:00
Seth Hillbrand 5da4e18664 bitmaps: Handle mask colors
Some transparent bitmaps use masking colors to show the binary
opaque/transparent.

Fixes: lp:1814893
* https://bugs.launchpad.net/kicad/+bug/1814893
2019-02-07 21:27:43 -08:00
Seth Hillbrand 3a3bbbb545 GAL: Add transparency for bitmaps and Cairo draw
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
2019-01-04 13:40:19 -08:00
jean-pierre charras 26a337db18 Opengl engine: temporary disable bitmaps cache, because it creates serious issues in cross-probing in hierarchies.
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.
2018-12-30 20:30:43 +01:00
Tomasz Włostowski 3adb8d56c5 OPENGL_GAL: no need to draw line caps when drawing a polyline, the shader takes care of them already 2018-12-24 15:35:25 +01:00