2016-05-07 17:00:48 +00:00
|
|
|
//
|
|
|
|
// OverlayPanel.h
|
|
|
|
// Audacity
|
|
|
|
//
|
|
|
|
// Created by Paul Licameli on 5/1/16.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_OVERLAY_PANEL__
|
|
|
|
#define __AUDACITY_OVERLAY_PANEL__
|
|
|
|
|
2019-01-24 01:53:37 +00:00
|
|
|
#include <memory>
|
2016-05-07 17:00:48 +00:00
|
|
|
#include <vector>
|
2019-03-30 19:17:49 +00:00
|
|
|
#include "BackedPanel.h" // to inherit
|
2016-05-07 17:00:48 +00:00
|
|
|
|
|
|
|
class Overlay;
|
|
|
|
|
|
|
|
class AUDACITY_DLL_API OverlayPanel /* not final */ : public BackedPanel {
|
|
|
|
public:
|
|
|
|
OverlayPanel(wxWindow * parent, wxWindowID id,
|
|
|
|
const wxPoint & pos,
|
|
|
|
const wxSize & size,
|
|
|
|
// default as for wxPanel:
|
|
|
|
long style = wxTAB_TRAVERSAL | wxNO_BORDER);
|
|
|
|
|
2019-01-24 01:53:37 +00:00
|
|
|
// Registers overlay objects.
|
2016-05-07 17:00:48 +00:00
|
|
|
// The sequence in which they were registered is the sequence in
|
|
|
|
// which they are painted.
|
|
|
|
// OverlayPanel is not responsible for their memory management.
|
2019-01-24 01:53:37 +00:00
|
|
|
void AddOverlay( const std::weak_ptr<Overlay> &pOverlay );
|
2016-05-07 17:00:48 +00:00
|
|
|
void ClearOverlays();
|
|
|
|
|
Reduced CPU usage of Audacity when idle.
Before this change, an idle Audacity on a recent Linux laptop uses 6%
of CPU. This is because DrawOverlays() is called every 50ms through a
timer in TrackPanel, which instanciates a wxClientDC. This is quite
expensive and dominates the profiles: creating wxClientDCs is 84% of
the CPU audacity spends while idle, according to callgrind. With this
change, we avoid creating wxClientDCs when it's not necessary.
After this change, and idle Audacity consumes 1.6% of CPU, and most of
the time is spend in gtk/wxwidgets processing events.
Here are the perf stats of an idle Audacity before the change:
524.425485 task-clock (msec) # 0.060 CPUs utilized
825 context-switches # 0.002 M/sec
36 cpu-migrations # 0.069 K/sec
0 page-faults # 0.000 K/sec
1,198,433,346 cycles # 2.285 GHz
1,243,329,771 instructions # 1.04 insn per cycle
308,073,049 branches # 587.449 M/sec
5,801,494 branch-misses # 1.88% of all branches
8.808129958 seconds time elapsed
and after:
149.110455 task-clock (msec) # 0.016 CPUs utilized
908 context-switches # 0.006 M/sec
32 cpu-migrations # 0.215 K/sec
0 page-faults # 0.000 K/sec
313,372,582 cycles # 2.102 GHz
167,401,770 instructions # 0.53 insn per cycle
41,857,947 branches # 280.718 M/sec
1,189,566 branch-misses # 2.84% of all branches
9.076940003 seconds time elapsed
2016-07-21 08:48:16 +00:00
|
|
|
// Erases and redraws to the client area the overlays that have
|
|
|
|
// been previously added with AddOverlay(). If "repaint_all" is
|
|
|
|
// true, all overlays will be erased and re-drawn. Otherwise, only
|
|
|
|
// the ones that are out-of-date, as well as the intersecting ones,
|
|
|
|
// will be erased and re-drawn.
|
|
|
|
// pDC can be null, in which case, DrawOverlays() will create a
|
|
|
|
// wxClientDC internally when necessary.
|
|
|
|
void DrawOverlays(bool repaint_all, wxDC *pDC = nullptr);
|
2016-05-07 17:00:48 +00:00
|
|
|
|
|
|
|
private:
|
2019-04-28 10:33:27 +00:00
|
|
|
using OverlayPtr = std::weak_ptr<Overlay>;
|
|
|
|
|
2019-01-24 01:53:37 +00:00
|
|
|
void Compress();
|
2019-04-28 10:33:27 +00:00
|
|
|
std::vector< OverlayPtr > mOverlays;
|
2016-05-07 17:00:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
Automation: AudacityCommand
This is a squash of 50 commits.
This merges the capabilities of BatchCommands and Effects using a new
AudacityCommand class. AudacityCommand provides one function to specify the
parameters, and then we leverage that one function in automation, whether by chains,
mod-script-pipe or (future) Nyquist.
- Now have AudacityCommand which is using the same mechanism as Effect
- Has configurable parameters
- Has data-entry GUI (built using shuttle GUI)
- Registers with PluginManager.
- Menu commands now provided in chains, and to python batch.
- Tested with Zoom Toggle.
- ShuttleParams now can set, get, set defaults, validate and specify
the parameters.
- Bugfix: Don't overwrite values with defaults first time out.
- Add DefineParams function for all built-in effects.
- Extend CommandContext to carry output channels for results.
We abuse EffectsManager. It handles both Effects and
AudacityCommands now. In time an Effect should become a special case of
AudacityCommand and we'll split and rename the EffectManager class.
- Don't use 'default' as a parameter name.
- Massive renaming for CommandDefinitionInterface
- EffectIdentInterface becomes EffectDefinitionInterface
- EffectAutomationParameters becomes CommandAutomationParameters
- PluginType is now a bit field.
This way we can search for related types at the same time.
- Most old batch commands made into AudacityCommands.
The ones that weren't are for a reason. They are used by mod-script-pipe
to carry commands and responses across from a non-GUI thread to the GUI
thread.
- Major tidy up of ScreenshotCommand
- Reworking of SelectCommand
- GetPreferenceCommand and SetPreferenceCommand
- GetTrackInfo and SetTrackInfo
- GetInfoCommand
- Help, Open, Save, Import and Export commands.
- Removed obsolete commands ExecMenu, GetProjectInfo and SetProjectInfo
which are now better handled by other commands.
- JSONify "GetInfo: Commands" output, i.e. commas in the right places.
- General work on better Doxygen.
- Lyrics -> LyricsPanel
- Meter -> MeterPanel
- Updated Linux makefile.
- Scripting commands added into Extra menu.
- Distinct names for previously duplicated find-clipping parameters.
- Fixed longstanding error with erroneous status field number which
previously caused an ASSERT in debug.
- Sensible formatting of numbers in Chains, 0.1 not 0.1000000000137
2018-01-14 18:51:41 +00:00
|
|
|
friend class GetInfoCommand;
|
2016-05-07 17:00:48 +00:00
|
|
|
};
|
|
|
|
|
2019-07-13 20:08:29 +00:00
|
|
|
/// Used to restore pen, brush and logical-op in a DC back to what they were.
|
2020-09-28 12:50:18 +00:00
|
|
|
struct AUDACITY_DLL_API DCUnchanger {
|
2019-07-13 20:08:29 +00:00
|
|
|
public:
|
|
|
|
DCUnchanger() {}
|
|
|
|
|
|
|
|
DCUnchanger(const wxBrush &brush_, const wxPen &pen_, long logicalOperation_)
|
|
|
|
: brush(brush_), pen(pen_), logicalOperation(logicalOperation_)
|
|
|
|
{}
|
|
|
|
|
|
|
|
void operator () (wxDC *pDC) const;
|
|
|
|
|
|
|
|
wxBrush brush {};
|
|
|
|
wxPen pen {};
|
|
|
|
long logicalOperation {};
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Makes temporary drawing context changes that you back out of, RAII style
|
|
|
|
// It's like wxDCPenChanger, etc., but simple and general
|
2020-09-28 12:50:18 +00:00
|
|
|
class AUDACITY_DLL_API ADCChanger : public std::unique_ptr<wxDC, ::DCUnchanger>
|
2019-07-13 20:08:29 +00:00
|
|
|
{
|
|
|
|
using Base = std::unique_ptr<wxDC, ::DCUnchanger>;
|
|
|
|
public:
|
|
|
|
ADCChanger() : Base{} {}
|
|
|
|
ADCChanger(wxDC *pDC);
|
|
|
|
};
|
|
|
|
|
2016-05-07 17:00:48 +00:00
|
|
|
#endif
|