Audacity 3.2.0
Classes | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
anonymous_namespace{WaveformView.cpp}::WaveformPainter Class Referencefinal
Inheritance diagram for anonymous_namespace{WaveformView.cpp}::WaveformPainter:
[legend]
Collaboration diagram for anonymous_namespace{WaveformView.cpp}::WaveformPainter:
[legend]

Classes

struct  ChannelCaches
 

Public Member Functions

 WaveformPainter ()
 
WaveformPainterEnsureClip (const WaveClip &clip)
 
void SetSelection (const ZoomInfo &zoomInfo, float t0, float t1, bool selected)
 
void Draw (int channelIndex, wxDC &dc, const WavePaintParameters &params, const ZoomInfo &zoomInfo, const wxRect &targetRect, int leftOffset, double from, double to)
 
void MarkChanged () noexcept override
 
void Invalidate () override
 
std::unique_ptr< WaveClipListenerClone () const override
 
- Public Member Functions inherited from WaveClipListener
virtual ~WaveClipListener ()=0
 
virtual void MarkChanged () noexcept=0
 
virtual void Invalidate ()=0
 
virtual void WriteXMLAttributes (XMLWriter &writer) const
 
virtual bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 
virtual void MakeStereo (WaveClipListener &&other, bool aligned)
 
virtual void SwapChannels ()
 Default implementation does nothing. More...
 
virtual void Erase (size_t index)
 

Static Public Member Functions

static WaveformPainterGet (const WaveClip &clip)
 

Private Attributes

const WaveClipmWaveClip {}
 
std::vector< ChannelCachesmChannelCaches
 

Detailed Description

Definition at line 206 of file WaveformView.cpp.

Constructor & Destructor Documentation

◆ WaveformPainter()

anonymous_namespace{WaveformView.cpp}::WaveformPainter::WaveformPainter ( )
inline

Definition at line 213 of file WaveformView.cpp.

214 {
215 }

Member Function Documentation

◆ Clone()

std::unique_ptr< WaveClipListener > anonymous_namespace{WaveformView.cpp}::WaveformPainter::Clone ( ) const
inlineoverride

Definition at line 298 of file WaveformView.cpp.

299 {
300 return std::make_unique<WaveformPainter>();
301 }

◆ Draw()

void anonymous_namespace{WaveformView.cpp}::WaveformPainter::Draw ( int  channelIndex,
wxDC &  dc,
const WavePaintParameters params,
const ZoomInfo zoomInfo,
const wxRect &  targetRect,
int  leftOffset,
double  from,
double  to 
)
inline

Definition at line 252 of file WaveformView.cpp.

256 {
257 auto& channelCache = mChannelCaches[channelIndex];
258
259 channelCache.BitmapCache->SetPaintParameters(params);
260
261 auto range = channelCache.BitmapCache->PerformLookup(zoomInfo, from, to);
262
263 auto left = targetRect.x + leftOffset;
264 auto height = targetRect.height;
265
266 const auto top = targetRect.y;
267
268 wxMemoryDC memdc;
269 for (auto it = range.begin(); it != range.end(); ++it)
270 {
271 const auto elementLeftOffset = it.GetLeftOffset();
272 const auto elementRightOffset = it.GetRightOffset();
273
274 const auto width = WaveBitmapCache::CacheElementWidth -
275 elementLeftOffset - elementRightOffset;
276
277 auto& bitmap = static_cast<WaveBitmapCacheElementWX&>(*it).GetBitmap();
278 memdc.SelectObject(bitmap);
279 dc.Blit(
280 wxPoint(left, targetRect.y), wxSize(width, it->Height()), &memdc,
281 wxPoint(elementLeftOffset, 0));
282
283 left += width;
284 }
285 }
EffectDistortionSettings params
Definition: Distortion.cpp:77
static constexpr uint32_t CacheElementWidth

References GraphicsDataCacheBase::CacheElementWidth, anonymous_namespace{WaveformView.cpp}::WaveBitmapCacheElementWX::GetBitmap(), and params.

Here is the call graph for this function:

◆ EnsureClip()

WaveformPainter & anonymous_namespace{WaveformView.cpp}::WaveformPainter::EnsureClip ( const WaveClip clip)
inline

Definition at line 217 of file WaveformView.cpp.

218 {
219 if (&clip != mWaveClip)
220 mChannelCaches.clear();
221
222 const auto nChannels = clip.NChannels();
223
224 if (mChannelCaches.size() == nChannels)
225 return *this;
226
227 mWaveClip = &clip;
228
229 mChannelCaches.reserve(nChannels);
230
231 for (auto channelIndex = 0; channelIndex < nChannels; ++channelIndex)
232 {
233 auto dataCache = std::make_shared<WaveDataCache>(clip, channelIndex);
234
235 auto bitmapCache = std::make_unique<WaveBitmapCache>(
236 clip, dataCache,
237 [] { return std::make_unique<WaveBitmapCacheElementWX>(); });
238
239 mChannelCaches.push_back(
240 { std::move(dataCache), std::move(bitmapCache) });
241 }
242
243 return *this;
244 }
size_t NChannels() const override
How many Sequences the clip contains.
Definition: WaveClip.cpp:373

References WaveClip::NChannels().

Here is the call graph for this function:

◆ Get()

WaveformPainter & WaveformPainter::Get ( const WaveClip clip)
static

Definition at line 1160 of file WaveformView.cpp.

1161{
1162 return const_cast< WaveClip& >( clip ) // Consider it mutable data
1163 .Attachments::Get<WaveformPainter>(sKeyW).EnsureClip(clip);
1164}
static WaveClip::Attachments::RegisteredFactory sKeyW
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:238

References sKeyW.

◆ Invalidate()

void anonymous_namespace{WaveformView.cpp}::WaveformPainter::Invalidate ( )
inlineoverridevirtual

Implements WaveClipListener.

Definition at line 289 of file WaveformView.cpp.

290 {
291 for (auto& channelCache : mChannelCaches)
292 {
293 channelCache.DataCache->Invalidate();
294 channelCache.BitmapCache->Invalidate();
295 }
296 }

◆ MarkChanged()

void anonymous_namespace{WaveformView.cpp}::WaveformPainter::MarkChanged ( )
inlineoverridevirtualnoexcept

Implements WaveClipListener.

Definition at line 287 of file WaveformView.cpp.

287{ }

◆ SetSelection()

void anonymous_namespace{WaveformView.cpp}::WaveformPainter::SetSelection ( const ZoomInfo zoomInfo,
float  t0,
float  t1,
bool  selected 
)
inline

Definition at line 246 of file WaveformView.cpp.

247 {
248 for (auto& channelCache : mChannelCaches)
249 channelCache.BitmapCache->SetSelection(zoomInfo, t0, t1, selected);
250 }

Member Data Documentation

◆ mChannelCaches

std::vector<ChannelCaches> anonymous_namespace{WaveformView.cpp}::WaveformPainter::mChannelCaches
private

Definition at line 312 of file WaveformView.cpp.

◆ mWaveClip

const WaveClip* anonymous_namespace{WaveformView.cpp}::WaveformPainter::mWaveClip {}
private

Definition at line 304 of file WaveformView.cpp.


The documentation for this class was generated from the following file: