mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Choose OpenGL / Raster in media viewer.
This commit is contained in:
parent
ccc599c83e
commit
c64e953174
9 changed files with 471 additions and 352 deletions
|
@ -107,7 +107,7 @@ Ui::GL::ChosenRenderer Panel::Incoming::chooseRenderer(
|
|||
}
|
||||
|
||||
void paintFallback(
|
||||
QPainter &&p,
|
||||
Painter &&p,
|
||||
const QRegion &clip,
|
||||
Ui::GL::Backend backend) override {
|
||||
_owner->paint(
|
||||
|
@ -121,11 +121,15 @@ Ui::GL::ChosenRenderer Panel::Incoming::chooseRenderer(
|
|||
|
||||
};
|
||||
|
||||
const auto use = Platform::IsMac()
|
||||
? true
|
||||
: Platform::IsWindows()
|
||||
? capabilities.supported
|
||||
: capabilities.transparency;
|
||||
LOG(("OpenGL: %1 (Incoming)").arg(Logs::b(use)));
|
||||
return {
|
||||
.renderer = std::make_unique<Renderer>(this),
|
||||
.backend = (capabilities.supported
|
||||
? Ui::GL::Backend::OpenGL
|
||||
: Ui::GL::Backend::Raster),
|
||||
.backend = (use ? Ui::GL::Backend::OpenGL : Ui::GL::Backend::Raster),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "calls/group/calls_group_common.h"
|
||||
#include "calls/group/calls_group_members_row.h"
|
||||
#include "media/view/media_view_pip.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "webrtc/webrtc_video_track.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/abstract_button.h"
|
||||
|
@ -87,10 +88,11 @@ Ui::GL::ChosenRenderer LargeVideo::chooseRenderer(
|
|||
}
|
||||
|
||||
void paintFallback(
|
||||
QPainter &&p,
|
||||
Painter &&p,
|
||||
const QRegion &clip,
|
||||
Ui::GL::Backend backend) override {
|
||||
_owner->paint(
|
||||
p,
|
||||
clip.boundingRect(),
|
||||
backend == Ui::GL::Backend::OpenGL);
|
||||
}
|
||||
|
@ -100,11 +102,15 @@ Ui::GL::ChosenRenderer LargeVideo::chooseRenderer(
|
|||
|
||||
};
|
||||
|
||||
const auto use = Platform::IsMac()
|
||||
? true
|
||||
: Platform::IsWindows()
|
||||
? capabilities.supported
|
||||
: capabilities.transparency;
|
||||
LOG(("OpenGL: %1 (LargeVideo)").arg(Logs::b(use)));
|
||||
return {
|
||||
.renderer = std::make_unique<Renderer>(this),
|
||||
.backend = (capabilities.supported
|
||||
? Ui::GL::Backend::OpenGL
|
||||
: Ui::GL::Backend::Raster),
|
||||
.backend = (use ? Ui::GL::Backend::OpenGL : Ui::GL::Backend::Raster),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -292,8 +298,7 @@ void LargeVideo::updateControlsGeometry() {
|
|||
}
|
||||
}
|
||||
|
||||
void LargeVideo::paint(QRect clip, bool opengl) {
|
||||
auto p = Painter(widget());
|
||||
void LargeVideo::paint(Painter &p, QRect clip, bool opengl) {
|
||||
const auto fill = [&](QRect rect) {
|
||||
if (rect.intersects(clip)) {
|
||||
p.fillRect(rect.intersected(clip), st::groupCallMembersBg);
|
||||
|
|
|
@ -87,7 +87,7 @@ private:
|
|||
rpl::producer<LargeVideoTrack> track,
|
||||
rpl::producer<bool> pinned);
|
||||
void setupControls(rpl::producer<bool> pinned);
|
||||
void paint(QRect clip, bool opengl);
|
||||
void paint(Painter &p, QRect clip, bool opengl);
|
||||
void paintControls(Painter &p, QRect clip);
|
||||
void updateControlsGeometry();
|
||||
void togglePinShown(bool shown);
|
||||
|
|
|
@ -368,8 +368,6 @@ void Application::showPhoto(not_null<PhotoData*> photo, HistoryItem *item) {
|
|||
Expects(_mediaView != nullptr);
|
||||
|
||||
_mediaView->showPhoto(photo, item);
|
||||
_mediaView->activateWindow();
|
||||
_mediaView->setFocus();
|
||||
}
|
||||
|
||||
void Application::showPhoto(
|
||||
|
@ -378,8 +376,6 @@ void Application::showPhoto(
|
|||
Expects(_mediaView != nullptr);
|
||||
|
||||
_mediaView->showPhoto(photo, peer);
|
||||
_mediaView->activateWindow();
|
||||
_mediaView->setFocus();
|
||||
}
|
||||
|
||||
void Application::showDocument(not_null<DocumentData*> document, HistoryItem *item) {
|
||||
|
@ -391,8 +387,6 @@ void Application::showDocument(not_null<DocumentData*> document, HistoryItem *it
|
|||
File::Launch(document->location(false).fname);
|
||||
} else {
|
||||
_mediaView->showDocument(document, item);
|
||||
_mediaView->activateWindow();
|
||||
_mediaView->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,8 +396,6 @@ void Application::showTheme(
|
|||
Expects(_mediaView != nullptr);
|
||||
|
||||
_mediaView->showTheme(document, cloud);
|
||||
_mediaView->activateWindow();
|
||||
_mediaView->setFocus();
|
||||
}
|
||||
|
||||
PeerData *Application::ui_getPeerForMouseAction() {
|
||||
|
@ -976,7 +968,7 @@ bool Application::minimizeActiveWindow() {
|
|||
}
|
||||
|
||||
QWidget *Application::getFileDialogParent() {
|
||||
return (_mediaView && _mediaView->isVisible())
|
||||
return (_mediaView && !_mediaView->isHidden())
|
||||
? (QWidget*)_mediaView.get()
|
||||
: activeWindow()
|
||||
? (QWidget*)activeWindow()->widget()
|
||||
|
@ -991,9 +983,7 @@ void Application::notifyFileDialogShown(bool shown) {
|
|||
|
||||
void Application::checkMediaViewActivation() {
|
||||
if (_mediaView && !_mediaView->isHidden()) {
|
||||
_mediaView->activateWindow();
|
||||
QApplication::setActiveWindow(_mediaView.get());
|
||||
_mediaView->setFocus();
|
||||
_mediaView->activate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -27,6 +27,10 @@ namespace Ui {
|
|||
class PopupMenu;
|
||||
class LinkButton;
|
||||
class RoundButton;
|
||||
namespace GL {
|
||||
struct ChosenRenderer;
|
||||
struct Capabilities;
|
||||
} // namespace GL
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
|
@ -52,25 +56,8 @@ namespace View {
|
|||
class GroupThumbs;
|
||||
class Pip;
|
||||
|
||||
#if 1
|
||||
#define USE_OPENGL_OVERLAY_WIDGET 1
|
||||
#else // Q_OS_MAC && !OS_MAC_OLD
|
||||
#define USE_OPENGL_OVERLAY_WIDGET 0
|
||||
#endif // Q_OS_MAC && !OS_MAC_OLD
|
||||
|
||||
struct OverlayParentTraits : Ui::RpWidgetDefaultTraits {
|
||||
static constexpr bool kSetZeroGeometry = false;
|
||||
};
|
||||
|
||||
#if USE_OPENGL_OVERLAY_WIDGET
|
||||
using OverlayParent = Ui::RpWidgetBase<QOpenGLWidget, OverlayParentTraits>;
|
||||
#else // USE_OPENGL_OVERLAY_WIDGET
|
||||
using OverlayParent = Ui::RpWidgetBase<QWidget, OverlayParentTraits>;
|
||||
#endif // USE_OPENGL_OVERLAY_WIDGET
|
||||
|
||||
class OverlayWidget final
|
||||
: public OverlayParent
|
||||
, public ClickHandlerHost
|
||||
: public ClickHandlerHost
|
||||
, private PlaybackControls::Delegate {
|
||||
public:
|
||||
OverlayWidget();
|
||||
|
@ -82,6 +69,12 @@ public:
|
|||
None,
|
||||
};
|
||||
|
||||
[[nodiscard]] bool isHidden() const;
|
||||
void hide();
|
||||
void setCursor(style::cursor cursor);
|
||||
void setFocus();
|
||||
void activate();
|
||||
|
||||
void showPhoto(not_null<PhotoData*> photo, HistoryItem *context);
|
||||
void showPhoto(not_null<PhotoData*> photo, not_null<PeerData*> context);
|
||||
void showDocument(
|
||||
|
@ -91,12 +84,14 @@ public:
|
|||
not_null<DocumentData*> document,
|
||||
const Data::CloudTheme &cloud);
|
||||
|
||||
void leaveToChildEvent(QEvent *e, QWidget *child) override { // e -- from enterEvent() of child TWidget
|
||||
updateOverState(OverNone);
|
||||
}
|
||||
void enterFromChildEvent(QEvent *e, QWidget *child) override { // e -- from leaveEvent() of child TWidget
|
||||
updateOver(mapFromGlobal(QCursor::pos()));
|
||||
}
|
||||
//void leaveToChildEvent(QEvent *e, QWidget *child) override {
|
||||
// // e -- from enterEvent() of child TWidget
|
||||
// updateOverState(OverNone);
|
||||
//}
|
||||
//void enterFromChildEvent(QEvent *e, QWidget *child) override {
|
||||
// // e -- from leaveEvent() of child TWidget
|
||||
// updateOver(mapFromGlobal(QCursor::pos()));
|
||||
//}
|
||||
|
||||
void activateControls();
|
||||
void close();
|
||||
|
@ -111,6 +106,8 @@ public:
|
|||
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
||||
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
||||
|
||||
rpl::lifetime &lifetime();
|
||||
|
||||
private:
|
||||
struct Streamed;
|
||||
struct PipWrap;
|
||||
|
@ -142,24 +139,29 @@ private:
|
|||
SaveAs,
|
||||
};
|
||||
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void moveEvent(QMoveEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
[[nodiscard]] not_null<QWindow*> window() const;
|
||||
[[nodiscard]] int width() const;
|
||||
[[nodiscard]] int height() const;
|
||||
void update();
|
||||
void update(const QRegion ®ion);
|
||||
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
void wheelEvent(QWheelEvent *e) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *e) override;
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||
void touchEvent(QTouchEvent *e);
|
||||
[[nodiscard]] Ui::GL::ChosenRenderer chooseRenderer(
|
||||
Ui::GL::Capabilities capabilities);
|
||||
void paint(Painter &p, const QRegion &clip);
|
||||
|
||||
bool eventHook(QEvent *e) override;
|
||||
bool eventFilter(QObject *obj, QEvent *e) override;
|
||||
|
||||
void setVisibleHook(bool visible) override;
|
||||
void handleMousePress(QPoint position, Qt::MouseButton button);
|
||||
void handleMouseRelease(QPoint position, Qt::MouseButton button);
|
||||
void handleMouseMove(QPoint position);
|
||||
bool handleContextMenu(std::optional<QPoint> position);
|
||||
bool handleDoubleClick(QPoint position);
|
||||
bool handleTouchEvent(not_null<QTouchEvent*> e);
|
||||
void handleWheelEvent(not_null<QWheelEvent*> e);
|
||||
void handleKeyPress(not_null<QKeyEvent*> e);
|
||||
|
||||
void toggleApplicationEventFilter(bool install);
|
||||
bool filterApplicationEvent(
|
||||
not_null<QObject*> object,
|
||||
not_null<QEvent*> e);
|
||||
void setSession(not_null<Main::Session*> session);
|
||||
|
||||
void playbackControlsPlay() override;
|
||||
|
@ -214,7 +216,6 @@ private:
|
|||
bool moveToNext(int delta);
|
||||
void preloadData(int delta);
|
||||
|
||||
void handleVisibleChanged(bool visible);
|
||||
void handleScreenChanged(QScreen *screen);
|
||||
|
||||
bool contentCanBeSaved() const;
|
||||
|
@ -379,6 +380,9 @@ private:
|
|||
|
||||
void applyHideWindowWorkaround();
|
||||
|
||||
bool _opengl = false;
|
||||
const std::unique_ptr<Ui::RpWidgetWrap> _surface;
|
||||
const not_null<QWidget*> _widget;
|
||||
QBrush _transparentBrush;
|
||||
|
||||
Main::Session *_session = nullptr;
|
||||
|
@ -435,7 +439,9 @@ private:
|
|||
int32 _dragging = 0;
|
||||
QPixmap _staticContent;
|
||||
bool _blurred = true;
|
||||
|
||||
rpl::lifetime _screenGeometryLifetime;
|
||||
std::unique_ptr<QObject> _applicationEventFilter;
|
||||
|
||||
std::unique_ptr<Streamed> _streamed;
|
||||
std::unique_ptr<PipWrap> _pip;
|
||||
|
@ -509,7 +515,6 @@ private:
|
|||
bool _touchRightButton = false;
|
||||
base::Timer _touchTimer;
|
||||
QPoint _touchStart;
|
||||
QPoint _accumScroll;
|
||||
|
||||
QString _saveMsgFilename;
|
||||
crl::time _saveMsgStarted = 0;
|
||||
|
|
|
@ -391,7 +391,7 @@ Ui::GL::ChosenRenderer PipPanel::chooseRenderer(
|
|||
}
|
||||
|
||||
void paintFallback(
|
||||
QPainter &&p,
|
||||
Painter &&p,
|
||||
const QRegion &clip,
|
||||
Ui::GL::Backend backend) override {
|
||||
_owner->paint(
|
||||
|
@ -405,11 +405,13 @@ Ui::GL::ChosenRenderer PipPanel::chooseRenderer(
|
|||
|
||||
};
|
||||
|
||||
const auto use = Platform::IsMac()
|
||||
? true
|
||||
: capabilities.transparency;
|
||||
LOG(("OpenGL: %1 (PipPanel)").arg(Logs::b(use)));
|
||||
return {
|
||||
.renderer = std::make_unique<Renderer>(this),
|
||||
.backend = (capabilities.supported
|
||||
? Ui::GL::Backend::OpenGL
|
||||
: Ui::GL::Backend::Raster),
|
||||
.backend = (use ? Ui::GL::Backend::OpenGL : Ui::GL::Backend::Raster),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -95,8 +95,8 @@ private:
|
|||
[[nodiscard]] Ui::GL::ChosenRenderer chooseRenderer(
|
||||
Ui::GL::Capabilities capabilities);
|
||||
|
||||
std::unique_ptr<Ui::RpWidgetWrap> _content;
|
||||
QPointer<QWidget> _parent;
|
||||
const std::unique_ptr<Ui::RpWidgetWrap> _content;
|
||||
const QPointer<QWidget> _parent;
|
||||
Fn<void(QPainter&, FrameRequest, bool)> _paint;
|
||||
RectParts _attached = RectParts();
|
||||
RectParts _snapped = RectParts();
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 95ee92088e62dfa20eb11d6fe59b0fb1834a1207
|
||||
Subproject commit ca5b2e6746447e39fc1e7deb1fa97e28d518bc7f
|
Loading…
Add table
Reference in a new issue