diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 022a25c8b..7fb81f588 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -619,23 +619,18 @@ void SendFilesBox::pushBlock(int from, int till) { crl::guard(this, callback)); }, widget->lifetime()); - const auto pp = std::make_shared(); block.itemModifyRequest( ) | rpl::start_with_next([=, controller = _controller](int index) { auto &file = _list.files[index]; if (file.type != Ui::PreparedFile::Type::Photo) { return; } - using Image = Ui::PreparedFileInformation::Image; - const auto image = std::get_if(&file.information->media); + using ImageInfo = Ui::PreparedFileInformation::Image; + const auto image = std::get_if(&file.information->media); if (!image) { return; } - *pp = QPixmap::fromImage( - image->data, - Qt::ColorOnly); - auto callback = [=](const Editor::PhotoModifications &mods) { image->modifications = mods; Storage::UpdateImageDetails( @@ -643,12 +638,13 @@ void SendFilesBox::pushBlock(int from, int till) { st::sendMediaPreviewSize); refreshAllAfterChanges(from); }; - + auto copy = image->data; + const auto fileImage = std::make_shared(std::move(copy)); controller->showLayer( std::make_unique( this, &controller->window(), - pp, + fileImage, image->modifications, std::move(callback)), Ui::LayerOption::KeepOther); diff --git a/Telegram/SourceFiles/editor/photo_editor.cpp b/Telegram/SourceFiles/editor/photo_editor.cpp index ad5628eda..3cca94298 100644 --- a/Telegram/SourceFiles/editor/photo_editor.cpp +++ b/Telegram/SourceFiles/editor/photo_editor.cpp @@ -45,7 +45,7 @@ constexpr auto kPrecision = 100000; PhotoEditor::PhotoEditor( not_null parent, - std::shared_ptr photo, + std::shared_ptr photo, PhotoModifications modifications) : RpWidget(parent) , _modifications(std::move(modifications)) diff --git a/Telegram/SourceFiles/editor/photo_editor.h b/Telegram/SourceFiles/editor/photo_editor.h index 79974aade..6d9c7cea9 100644 --- a/Telegram/SourceFiles/editor/photo_editor.h +++ b/Telegram/SourceFiles/editor/photo_editor.h @@ -9,9 +9,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" -#include "editor/photo_editor_common.h" - #include "base/unique_qptr.h" +#include "editor/photo_editor_common.h" +#include "ui/image/image.h" namespace Editor { @@ -24,7 +24,7 @@ class PhotoEditor final : public Ui::RpWidget { public: PhotoEditor( not_null parent, - std::shared_ptr photo, + std::shared_ptr photo, PhotoModifications modifications); void save(); diff --git a/Telegram/SourceFiles/editor/photo_editor_content.cpp b/Telegram/SourceFiles/editor/photo_editor_content.cpp index 42362e2f1..0564fe862 100644 --- a/Telegram/SourceFiles/editor/photo_editor_content.cpp +++ b/Telegram/SourceFiles/editor/photo_editor_content.cpp @@ -18,17 +18,18 @@ using Media::View::RotatedRect; PhotoEditorContent::PhotoEditorContent( not_null parent, - std::shared_ptr photo, + std::shared_ptr photo, PhotoModifications modifications, std::shared_ptr undoController) : RpWidget(parent) +, _photoSize(photo->size()) , _paint(base::make_unique_q( this, modifications, - photo->size(), + _photoSize, std::move(undoController))) -, _crop(base::make_unique_q(this, modifications, photo->size())) -, _photo(photo) +, _crop(base::make_unique_q(this, modifications, _photoSize)) +, _photo(std::move(photo)) , _modifications(modifications) { rpl::combine( @@ -45,7 +46,7 @@ PhotoEditorContent::PhotoEditorContent( const auto m = _crop->cropMargins(); const auto sizeForCrop = rotatedSize - QSize(m.left() + m.right(), m.top() + m.bottom()); - const auto originalSize = QSizeF(photo->size()); + const auto originalSize = QSizeF(_photoSize); if ((originalSize.width() > sizeForCrop.width()) || (originalSize.height() > sizeForCrop.height())) { return originalSize.scaled( @@ -82,7 +83,9 @@ PhotoEditorContent::PhotoEditorContent( p.setMatrix(_imageMatrix); - p.drawPixmap(_imageRect, *photo); + p.drawPixmap( + _imageRect, + _photo->pix(_imageRect.width(), _imageRect.height())); }, lifetime()); } diff --git a/Telegram/SourceFiles/editor/photo_editor_content.h b/Telegram/SourceFiles/editor/photo_editor_content.h index bf4a69da6..a8ce390df 100644 --- a/Telegram/SourceFiles/editor/photo_editor_content.h +++ b/Telegram/SourceFiles/editor/photo_editor_content.h @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rp_widget.h" #include "editor/photo_editor_common.h" +#include "ui/image/image.h" namespace Editor { @@ -21,7 +22,7 @@ class PhotoEditorContent final : public Ui::RpWidget { public: PhotoEditorContent( not_null parent, - std::shared_ptr photo, + std::shared_ptr photo, PhotoModifications modifications, std::shared_ptr undoController); @@ -32,9 +33,10 @@ public: private: + const QSize _photoSize; const base::unique_qptr _paint; const base::unique_qptr _crop; - const std::shared_ptr _photo; + const std::shared_ptr _photo; rpl::variable _modifications; diff --git a/Telegram/SourceFiles/editor/photo_editor_layer_widget.cpp b/Telegram/SourceFiles/editor/photo_editor_layer_widget.cpp index 8bbef6758..0db66252d 100644 --- a/Telegram/SourceFiles/editor/photo_editor_layer_widget.cpp +++ b/Telegram/SourceFiles/editor/photo_editor_layer_widget.cpp @@ -14,13 +14,13 @@ namespace Editor { LayerWidget::LayerWidget( not_null parent, not_null window, - std::shared_ptr photo, + std::shared_ptr photo, PhotoModifications modifications, Fn &&doneCallback) : Ui::LayerWidget(parent) , _content(base::make_unique_q( this, - std::move(photo), + photo, std::move(modifications))) { paintRequest( diff --git a/Telegram/SourceFiles/editor/photo_editor_layer_widget.h b/Telegram/SourceFiles/editor/photo_editor_layer_widget.h index c44f81c7a..ece6f151f 100644 --- a/Telegram/SourceFiles/editor/photo_editor_layer_widget.h +++ b/Telegram/SourceFiles/editor/photo_editor_layer_widget.h @@ -9,8 +9,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/layers/layer_widget.h" -#include "editor/photo_editor_common.h" #include "base/unique_qptr.h" +#include "editor/photo_editor_common.h" +#include "ui/image/image.h" namespace Window { class Controller; @@ -25,7 +26,7 @@ public: LayerWidget( not_null parent, not_null window, - std::shared_ptr photo, + std::shared_ptr photo, PhotoModifications modifications, Fn &&doneCallback);