images_renderer.h

Go to the documentation of this file.
00001 /*
00002  * File Name: images_renderer.h
00003  */
00004 
00005 /*
00006  * This file is part of uds-plugin-images.
00007  *
00008  * uds-plugin-images is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * uds-plugin-images is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
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 
Generated by  doxygen 1.6.2-20100208