#include "lyxfont.h"
#include "version.h"
-#include "graphics/GraphicsCache.h"
-#include "graphics/GraphicsCacheItem.h"
+#include "graphics/GraphicsLoader.h"
#include "graphics/GraphicsImage.h"
-#include "graphics/GraphicsParams.h"
#include "support/filetools.h" // LibFileSearch
#include <boost/utility.hpp>
#include <boost/bind.hpp>
+#include <boost/signals/trackable.hpp>
using std::min;
using std::max;
namespace {
-class SplashScreen : boost::noncopyable {
+class SplashScreen : boost::noncopyable, boost::signals::trackable {
public:
/// This is a singleton class. Get the instance.
static SplashScreen const & get();
///
- grfx::GImage const * image() const { return image_.get(); }
+ grfx::GImage const * image() const { return loader_.image(); }
///
string const & text() const { return text_; }
///
LyXFont const & font() const { return font_; }
private:
- /** Make the c-tor, d-tor private so we can control how many objects
+ /** Make the c-tor private so we can control how many objects
* are instantiated.
*/
SplashScreen();
- ///
- ~SplashScreen();
- /** Connected to grfx::GCacheItem::statusChanged, so will generate the
- * pixmap as soon as the file is loaded into memory.
- */
- void createPixmap();
-
- /** Must store a copy of the cached item to ensure that it is not
- * erased unexpectedly by the cache itself.
- */
- grfx::GraphicPtr graphic_;
- /** We generate a pixmap from a copy of the grfx::GImage * stored in
- * the cache.
- */
- grfx::ImagePtr image_;
- /// The loading status of the image.
- grfx::ImageStatus status_;
+ ///
+ grfx::Loader loader_;
/// The text to be written on top of the pixmap
string const text_;
/// in this font...
SplashScreen::SplashScreen()
- : status_(grfx::WaitingToLoad),
- text_(lyx_version ? lyx_version : "unknown")
+ : text_(lyx_version ? lyx_version : "unknown")
{
string const file = LibFileSearch("images", "banner", "xpm");
if (file.empty())
font_.setColor(LColor::yellow);
// Load up the graphics file
- grfx::GCache & gc = grfx::GCache::get();
- if (!gc.inCache(file))
- gc.add(file);
- // We /must/ make a local copy of this.
- graphic_ = gc.graphic(file);
-
- if (graphic_->status() == grfx::Loaded) {
- createPixmap();
- } else {
- graphic_->statusChanged.connect(
- boost::bind(&SplashScreen::createPixmap, this));
- graphic_->startLoading();
- }
-}
-
-
-SplashScreen::~SplashScreen()
-{
- if (!graphic_.get())
- return;
-
- string const file = graphic_->filename();
- graphic_.reset();
-
- // If only the cache itself now references this item, then it will be
- // removed.
- grfx::GCache::get().remove(file);
-}
-
-
-void SplashScreen::createPixmap()
-{
- if (!graphic_.get() || image_.get())
- return;
-
- if (graphic_->status() != grfx::Loaded)
- return;
-
- if (status_ != grfx::WaitingToLoad)
- return;
-
- // Strictly speaking, we need to create a copy only if we're going to
- // modify the image (scale, etc).
- image_.reset(graphic_->image()->clone());
-
- bool const success = image_->setPixmap(grfx::GParams());
-
- if (success) {
- status_ = grfx::Loaded;
- } else {
- image_.reset();
- status_ = grfx::ErrorScalingEtc;
- }
+ loader_.reset(file);
+ // We aren't interested here in when the image is loaded.
+ // If it isn't ready when we want it, then we ignore it.
+// loader_->statusChanged.connect(
+// boost::bind(&SplashScreen::statusChanged, this));
+ if (loader_.status() == grfx::WaitingToLoad)
+ loader_.startLoading();
}
} // namespace anon