X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fimage_proxy.h;h=01cb79552d26de566d6ea3ad667c8a819c5618f8;hb=e068f8b19ed0892fed8da44b873e2d309d7ba137;hp=f6212e54f59bc11a5c679b4551bfc8d8d57cd72f;hpb=4e411ea97b4dab8a5fa282d1d4cf7971ef1e24ad;p=dcpomatic.git diff --git a/src/lib/image_proxy.h b/src/lib/image_proxy.h index f6212e54f..01cb79552 100644 --- a/src/lib/image_proxy.h +++ b/src/lib/image_proxy.h @@ -1,34 +1,44 @@ /* Copyright (C) 2014 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ +#ifndef DCPOMATIC_IMAGE_PROXY_H +#define DCPOMATIC_IMAGE_PROXY_H + /** @file src/lib/image_proxy.h * @brief ImageProxy and subclasses. */ +extern "C" { +#include +} +#include #include -#include -#include -#include +#include +#include class Image; class Socket; -class Log; + +namespace xmlpp { + class Node; +} namespace cxml { class Node; @@ -42,50 +52,36 @@ namespace cxml { * of happening in a single-threaded decoder. * * For example, large TIFFs are slow to decode, so this class will keep - * the TIFF data TIFF until such a time that the actual image is needed. + * the TIFF data compressed until the decompressed image is needed. * At this point, the class decodes the TIFF to an Image. */ class ImageProxy : public boost::noncopyable { public: - ImageProxy (boost::shared_ptr log); + virtual ~ImageProxy () {} + + /** @param note Handler for any notes that occur. + * @param size Size that the returned image will be scaled to, in case this + * can be used as an optimisation. + * @return Image (which must be aligned) + */ + virtual boost::shared_ptr image ( + boost::optional note = boost::optional (), + boost::optional size = boost::optional () + ) const = 0; - /** @return Image (which must be aligned) */ - virtual boost::shared_ptr image () const = 0; virtual void add_metadata (xmlpp::Node *) const = 0; virtual void send_binary (boost::shared_ptr) const = 0; - -protected: - boost::shared_ptr _log; -}; - -class RawImageProxy : public ImageProxy -{ -public: - RawImageProxy (boost::shared_ptr, boost::shared_ptr log); - RawImageProxy (boost::shared_ptr xml, boost::shared_ptr socket, boost::shared_ptr log); - - boost::shared_ptr image () const; - void add_metadata (xmlpp::Node *) const; - void send_binary (boost::shared_ptr) const; - -private: - boost::shared_ptr _image; + /** @return true if our image is definitely the same as another, false if it is probably not */ + virtual bool same (boost::shared_ptr) const = 0; + /** Do any useful work that would speed up a subsequent call to ::image(). + * This method may be called in a different thread to image(). + */ + virtual void prepare (boost::optional = boost::optional()) const {} + virtual AVPixelFormat pixel_format () const = 0; + virtual size_t memory_used () const = 0; }; -class MagickImageProxy : public ImageProxy -{ -public: - MagickImageProxy (boost::filesystem::path, boost::shared_ptr log); - MagickImageProxy (boost::shared_ptr xml, boost::shared_ptr socket, boost::shared_ptr log); - - boost::shared_ptr image () const; - void add_metadata (xmlpp::Node *) const; - void send_binary (boost::shared_ptr) const; - -private: - Magick::Blob _blob; - mutable boost::shared_ptr _image; -}; +boost::shared_ptr image_proxy_factory (boost::shared_ptr xml, boost::shared_ptr socket); -boost::shared_ptr image_proxy_factory (boost::shared_ptr xml, boost::shared_ptr socket, boost::shared_ptr log); +#endif