#include "support/bind.h"
-#include <set>
#include <queue>
+#include <memory>
+#include <set>
using namespace std;
using namespace lyx::support;
};
-//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;
+
LoaderQueue & LoaderQueue::get()
{
LYXERR(Debug::GRAPHICS, "LoaderQueue: "
<< cache_queue_.size() << " items in the queue");
int counter = s_numimages_;
- while (cache_queue_.size() && counter--) {
+ while (!cache_queue_.empty() && counter--) {
Cache::ItemPtr ptr = cache_queue_.front();
cache_set_.erase(ptr);
cache_queue_.pop_front();
if (ptr->status() == WaitingToLoad)
ptr->startLoading();
}
- if (!cache_queue_.empty()) {
+ if (!cache_queue_.empty())
startLoader();
- } else {
+ else
stopLoader();
- }
}
//
/////////////////////////////////////////////////////////////////////
-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();
/// 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:
///
}
-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);
}
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) {