]> git.lyx.org Git - lyx.git/blobdiff - src/graphics/GraphicsLoader.cpp
Rationalise includes
[lyx.git] / src / graphics / GraphicsLoader.cpp
index 9f873baf3db09e56c4fccd14b28e2c06b264d015..1fa5c65019a7fe687a9cc4024eb1cf1e1b8c6896 100644 (file)
@@ -22,8 +22,9 @@
 
 #include "support/bind.h"
 
-#include <set>
 #include <queue>
+#include <memory>
+#include <set>
 
 using namespace std;
 using namespace lyx::support;
@@ -71,12 +72,13 @@ private:
 };
 
 
-//static int s_numimages_ = 5;
-//static int s_millisecs_ = 500;
 
-static int s_numimages_ = 10;
-static int s_millisecs_ = 500;
+//static int const s_numimages_ = 5;
+static int const s_numimages_ = 10;
+static int const s_millisecs_ = 500;
+
 
+// FIXME THREAD
 LoaderQueue & LoaderQueue::get()
 {
        static LoaderQueue singleton;
@@ -158,9 +160,9 @@ void LoaderQueue::touch(Cache::ItemPtr const & item)
 //
 /////////////////////////////////////////////////////////////////////
 
-typedef shared_ptr<Image> ImagePtr;
+typedef std::shared_ptr<Image> ImagePtr;
 
-class Loader::Impl : public boost::signals::trackable {
+class Loader::Impl : public boost::signals2::trackable {
 public:
        ///
        Impl();
@@ -186,9 +188,18 @@ public:
        /// We modify a local copy of the image once it is loaded.
        ImagePtr image_;
        /// This signal is emitted when the image loading status changes.
-       boost::signal<void()> signal_;
+       boost::signals2::signal<void()> signal_;
        /// The connection of the signal StatusChanged  
-       boost::signals::connection sc_;
+       boost::signals2::connection sc_;
+
+       double displayPixelRatio() const
+       {
+               return params_.pixel_ratio;
+       }
+       void setDisplayPixelRatio(double scale)
+       {
+               params_.pixel_ratio = scale;
+       }
 
 private:
        ///
@@ -325,7 +336,19 @@ ImageStatus Loader::status() const
 }
 
 
-boost::signals::connection Loader::connect(slot_type const & slot) const
+double Loader::displayPixelRatio() const
+{
+       return pimpl_->displayPixelRatio();
+}
+
+
+void Loader::setDisplayPixelRatio(double scale)
+{
+       pimpl_->setDisplayPixelRatio(scale);
+}
+
+
+boost::signals2::connection Loader::connect(slot_type const & slot) const
 {
        return pimpl_->signal_.connect(slot);
 }
@@ -432,6 +455,16 @@ void Loader::Impl::createPixmap()
 
        image_.reset(cached_item_->image()->clone());
 
+       if (params_.pixel_ratio == 1.0) {
+               string filename = cached_item_->filename().absFileName();
+               size_t idx = filename.find_last_of('.');
+               if (idx != string::npos && idx > 3) {
+                       if (filename.substr(idx - 3, 3) == "@2x") {
+                               params_.pixel_ratio = 2.0;
+                       }
+               }
+       }
+
        bool const success = image_->setPixmap(params_);
 
        if (success) {