/[gzz]/gzz/gfx/libimagecache/ImageCache.hxx
ViewVC logotype

Diff of /gzz/gfx/libimagecache/ImageCache.hxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by deetsay, Fri Sep 13 14:35:37 2002 UTC revision 1.3 by deetsay, Wed Sep 18 08:04:05 2002 UTC
# Line 12  Line 12 
12  #include <gdk-pixbuf/gdk-pixbuf.h>  #include <gdk-pixbuf/gdk-pixbuf.h>
13  #include <gdk-pixbuf/gdk-pixbuf-loader.h>  #include <gdk-pixbuf/gdk-pixbuf-loader.h>
14    
15    #define START_PIXBUF_BACKGROUND_LOADER  ((GdkPixbuf *)(-1))
16    
17  namespace ImageCache {  namespace ImageCache {
18    
19  using std::string;  using std::string;
# Line 30  using std::list; Line 32  using std::list;
32          CachedImage();          CachedImage();
33          ~CachedImage();          ~CachedImage();
34    
35          GdkPixbuf *getPixbuf(int lod);          /**
36             *      Returns the Pixbuf of this Image.  If the requested lod
37             *      is better (a smaller number) than what is available, the
38             *      call returns START_PIXBUF_BACKGROUND_LOADER. After that
39             *      it is safe to start calling write();... It is also safe to
40             *      call this method again - whatever Level of Detail is
41             *      available will be returned. The GdkPixbuf will have its
42             *      level of detail stored in its user_data field. Use
43             *      gtk_object_get_user_data() to get it.
44             */
45            GdkPixbuf *getPixbuf(int lod);
46            /**
47             *      Write data to this image's GdkPixbufLoader.
48             */
49          int write(char *data, int len);          int write(char *data, int len);
50            /**
51             *      Make this image's Level of Detail one step "larger".
52             *      A larger LOD means a smaller resolution. This is called
53             *      by ImageCache to make the cache smaller.
54             */
55          void dropLOD();          void dropLOD();
56            /**
57             *      loaderPrepared will be called when the GdkPixbufLoader
58             *      has completed loading enough of an image to be able to
59             *      say how large the image area is.
60             */
61          void loaderPrepared();          void loaderPrepared();
62            /**
63             *      loaderDone will be called when the GdkPixbufLoader
64             *      has completed loading an image.
65             */
66          void loaderDone();          void loaderDone();
67            /**
68             *      Calling closeLoader will close the GdkPixbufLoader and
69             *      set it to NULL.
70             */
71          void closeLoader();          void closeLoader();
72            /**
73             *      Returns the amount of change in this image's size since
74             *      the last time this was called. This is called by ImageCache
75             *      to keep track of the cache's size.
76             */
77          int getSizeChange();          int getSizeChange();
78            /**
79             *      Returns the current size of the image in bytes.
80             */
81          int getCurrentSize();          int getCurrentSize();
82      };      };
83    
84      class ImageCache {      class ImageCache {
85      private:      private:
86          GdkPixbuf *loading;          GdkPixbuf *loading;
87          map<string,CachedImage *> imageByUrx;          map<string,CachedImage *> imageByUri;
88          map<CachedImage *,string> urxByImage;          map<CachedImage *,string> uriByImage;
89          list<CachedImage *> recentlyUsedImages;          list<CachedImage *> recentlyUsedImages;
90          int size;          int size;
91      public:      public:
92          ImageCache();          ImageCache();
93          ~ImageCache();          ~ImageCache();
94    
95          GdkPixbuf *getPixbuf(string urx, int lod);          /**
96             *      Get an image from the given URI with preferably at least
97          int write(string urx, char *data, int n);           *      the given Level of Detail.
98             *
99          int cropToSize(int maxSize);           *      If the image is not yet available, you will either get
100             *      a loader-image, or a version of the image with a smaller
101             *      resolution. The image may also be incomplete.
102             *
103             *      If you get a smaller resolution than you asked for, or
104             *      the image is incomplete, or you got the loader-image, then
105             *      the cache will already be trying to load a better version.
106             *
107             *      The Level of Detail of an image can be found in the user_data
108             *      field of the GdkPixbuf. You can get it by using
109             *      gtk_object_get_used_data();
110             *
111             *      The Level of Detail for the loader-image will be -1.
112             */
113            GdkPixbuf *getPixbuf(string uri, int lod);
114    
115            /**
116             *      Trim cache to maxSize (if the cache is larger than that)
117             *      and return the size of the cache.
118             *
119             *      That means making the least recently used images smaller
120             *      (resizing them to the next level of detail)
121             *      (making their resolution poorer)
122             *      until the cache is smaller or equal to the requested size.
123             *
124             *      maxSize is in bytes.
125             *      The return value is also in bytes.
126             */
127            int trimToSize(int maxSize);
128    
129            /**
130             *      Write raw data to the GdkImageLoader of a given URI.
131             *
132             *      This will be called by the JNI interface when it receives
133             *      data from the Java BackgroundLoader.
134             */
135            int write(string uri, char *data, int n);
136      };      };
137  }  }
138    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26