]> git.lyx.org Git - lyx.git/commitdiff
#9130 Text in main work area isn't rendered with high resolution
authorStephan Witt <switt@lyx.org>
Sat, 18 Oct 2014 13:26:49 +0000 (15:26 +0200)
committerStephan Witt <switt@lyx.org>
Sat, 18 Oct 2014 13:26:49 +0000 (15:26 +0200)
Add pixel_ratio to graphics params to use it for displays with high resolution.
It holds the ratio between physical pixels and device-independent pixels of the graphics.

src/graphics/GraphicsLoader.cpp
src/graphics/GraphicsLoader.h
src/graphics/GraphicsParams.cpp
src/graphics/GraphicsParams.h

index ade29f1137d6396a84a556944cfce052a9070b3d..23ebb623948f9fee8bc9b6c27951fe92e28b1f33 100644 (file)
@@ -191,6 +191,15 @@ public:
        /// The connection of the signal StatusChanged  
        boost::signals::connection sc_;
 
+       double displayPixelRatio() const
+       {
+               return params_.pixel_ratio;
+       }
+       void setDisplayPixelRatio(double scale)
+       {
+               params_.pixel_ratio = scale;
+       }
+
 private:
        ///
        void statusChanged();
@@ -326,6 +335,18 @@ ImageStatus Loader::status() const
 }
 
 
+double Loader::displayPixelRatio() const
+{
+       return pimpl_->displayPixelRatio();
+}
+
+
+void Loader::setDisplayPixelRatio(double scale)
+{
+       pimpl_->setDisplayPixelRatio(scale);
+}
+
+
 boost::signals::connection Loader::connect(slot_type const & slot) const
 {
        return pimpl_->signal_.connect(slot);
@@ -433,6 +454,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) {
index 65218505b0254121794466ab036f6992530d4234..57328107085b7f86f9927fb93d0f84d83c372e16 100644 (file)
@@ -101,6 +101,9 @@ public:
         */
        Image const * image() const;
 
+       double displayPixelRatio() const;
+       void setDisplayPixelRatio(double scale);
+
 private:
        /// Use the Pimpl idiom to hide the internals.
        class Impl;
index a53d2c57b1ffb4f038c998cde7ceeea046f9b34c..c1c32a0aba2fe41d1a7d759d4427abbd076eac4b 100644 (file)
@@ -25,6 +25,7 @@ namespace graphics {
 Params::Params()
        : display(true),
          scale(100),
+         pixel_ratio(1.0),
          angle(0)
 {}
 
@@ -35,6 +36,7 @@ bool operator==(Params const & a, Params const & b)
                a.display == b.display &&
                a.bb == b.bb &&
                a.scale == b.scale &&
+               a.pixel_ratio == b.pixel_ratio &&
                a.angle == b.angle);
 }
 
index b1eb1a05c53d7c9d63ffe57c44b4b944cbdb9a6b..86cc9dc9b16daeb648fde7454c1bfc3c4fb6d5f2 100644 (file)
@@ -55,6 +55,7 @@ public:
 
        bool display;
        unsigned int scale;
+       double pixel_ratio;
 
        /// The image filename.
        support::FileName filename;