images_renderer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _IMAGES_RENDERER_H_
00028 #define _IMAGES_RENDERER_H_
00029
00030 #include <string>
00031
00032 #include "images_pages_cache.h"
00033 #include "thread.h"
00034 #include "signal_slot.h"
00035
00036 #include "images_document.h"
00037 #include "image_page.h"
00038
00039
00040 namespace images
00041 {
00042
00043 typedef enum
00044 {
00045 IMG_RENDER_OK = 0,
00046 IMG_RENDER_FAIL,
00047 IMG_RENDER_INVALID,
00048 IMG_RENDER_OOM
00049 }ImageRenderStatus;
00050
00051 class ImagesRenderer
00052 {
00053 public:
00054 ImagesRenderer(ImagesDocument * document);
00055 ~ImagesRenderer(void);
00056
00057 public:
00058 ImageRenderStatus render(const std::string & anchor,
00059 const ImagePageAttrs & attrs,
00060 int ref_id,
00061 void * user_data);
00062
00063 void notify_page_ready(ImagePage * page,
00064 int ref_id,
00065 ImageRenderStatus status,
00066 void * user_data);
00067
00068 ImagePage * get_page(const std::string & anchor,
00069 const ImagePageAttrs & attrs);
00070
00071 void add_page(ImagePage * page);
00072
00073 ImageRenderStatus can_render(const std::string & anchor,
00074 const ImagePageAttrs & attrs);
00075
00076 bool set_memory_limit(const int bytes);
00077
00078 void stop(void);
00079
00080 private:
00081 void pre_render(int page_num,
00082 const ImagePageAttrs & attrs,
00083 bool page_down);
00084
00085 void render_prev_pages(int page_num,
00086 const ImagePageAttrs & attrs);
00087
00088 void render_next_pages(int page_num,
00089 const ImagePageAttrs & attrs);
00090
00091 void set_prerender_policy(int prev_range, int next_range);
00092
00093 public:
00094 utils::Signal <ImagePage *, const unsigned int, ImageRenderStatus, void *> sig_page_ready;
00095
00096 private:
00097 ImagesDocument * doc;
00098 common::Thread render_thread;
00099 PagesCache pages_cache;
00100
00101 int last_render_page;
00102 int prev_range_pages;
00103 int next_range_pages;
00104 };
00105 };
00106
00107 #endif //_IMAGES_RENDERER_H_
00108
00109