MythTV  master
bdoverlayscreen.cpp
Go to the documentation of this file.
1 #include <QPainter>
2 
3 #include "mythuiimage.h"
4 #include "mythpainter.h"
5 
6 #include "bdringbuffer.h"
7 #include "bdoverlayscreen.h"
8 
9 #define LOC QString("BDScreen: ")
10 
11 BDOverlayScreen::BDOverlayScreen(MythPlayer *player, const QString &name)
12  : MythScreenType((MythScreenType*)nullptr, name),
13  m_player(player)
14 {
15 }
16 
18 {
19  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + "dtor");
20 }
21 
23 {
24  if (!overlay || !m_player)
25  return;
26 
27  MythRect rect(overlay->m_x, overlay->m_y,
28  overlay->m_image.width(), overlay->m_image.height());
29  SetArea(rect);
31 
33  if (!vo)
34  return;
35 
36  QImage& img = overlay->m_image;
37 
38  // add to screen
39  QRect scaled = vo->GetImageRect(rect);
40  if (scaled.size() != rect.size())
41  {
42  img = img.scaled(scaled.width(), scaled.height(),
43  Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
44  }
45 
46  MythPainter *osd_painter = vo->GetOSDPainter();
47  MythImage* image = nullptr;
48  if (osd_painter)
49  image = osd_painter->GetFormatImage();
50 
51  if (image)
52  {
53  image->Assign(img);
54  auto *uiimage = new MythUIImage(this, "bdoverlay");
55  if (uiimage)
56  {
57  uiimage->SetImage(image);
58  uiimage->SetArea(MythRect(scaled));
59  }
60  image->DecrRef();
61  }
62 
63  SetRedraw();
64 
65  delete overlay;
66 }
QRect GetImageRect(const QRect &Rect, QRect *DisplayRect=nullptr)
translates caption/dvd button rectangle into 'screen' space
virtual MythPainter * GetOSDPainter(void)
Definition: mythvideoout.h:125
MythPlayer * m_player
void SetRedraw(void)
Definition: mythuitype.cpp:295
int DecrRef(void) override
Decrements reference count and deletes on 0.
Definition: mythimage.cpp:55
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
#define LOC
QImage m_image
Definition: bdringbuffer.h:62
void DeleteAllChildren(void)
Delete all child widgets.
Definition: mythuitype.cpp:204
BDOverlayScreen(MythPlayer *player, const QString &name)
MythVideoOutput * GetVideoOutput(void)
Definition: mythplayer.h:252
~BDOverlayScreen() override
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Definition: mythrect.h:17
virtual void SetArea(const MythRect &rect)
Definition: mythuitype.cpp:591
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
void DisplayBDOverlay(BDOverlay *overlay)
Screen in which all other widgets are contained and rendered.
void Assign(const QImage &img)
Definition: mythimage.cpp:80
MythImage * GetFormatImage()
Returns a blank reference counted image in the format required for the Draw functions for this painte...