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