images::ImageRenderTask Class Reference

#include <image_render_task.h>

Inheritance diagram for images::ImageRenderTask:
Inheritance graph
[legend]
Collaboration diagram for images::ImageRenderTask:
Collaboration graph
[legend]

Public Member Functions

 ImageRenderTask (const std::string &page_anchor, const ImagePageAttrs &attributes, int reference_id, ImagesRenderer *p_renderer, void *p_user_data)
virtual ~ImageRenderTask (void)
virtual void execute (void)
 Execute task with task context.

Detailed Description

Definition at line 35 of file image_render_task.h.


Constructor & Destructor Documentation

images::ImageRenderTask::ImageRenderTask ( const std::string &  page_anchor,
const ImagePageAttrs attributes,
int  reference_id,
ImagesRenderer p_renderer,
void *  p_user_data 
)

Definition at line 36 of file image_render_task.cpp.

References LOGPRINTF.

00041 : anchor(page_anchor)
00042 , ref_id(reference_id)
00043 , renderer(p_renderer)        
00044 , user_data(p_user_data)
00045 {
00046     LOGPRINTF("anchor[%s], ref_id[%d]", anchor.c_str(), ref_id);
00047 
00048     attrs = attributes;
00049 }

images::ImageRenderTask::~ImageRenderTask ( void   )  [virtual]

Definition at line 51 of file image_render_task.cpp.

References LOGPRINTF.

00052 {
00053     LOGPRINTF("entry");
00054 }


Member Function Documentation

void images::ImageRenderTask::execute ( void   )  [virtual]

Execute task with task context.

Implements common::Task.

Definition at line 56 of file image_render_task.cpp.

References images::ImagesRenderer::add_page(), images::ImagesRenderer::can_render(), images::ImagesRenderer::get_page(), images::IMG_RENDER_FAIL, images::IMG_RENDER_OK, LOGPRINTF, images::ImagesRenderer::notify_page_ready(), images::ImagePage::render(), images::ImagePageAttrs::rotation, WARNPRINTF, and images::ImagePageAttrs::zoom.

00057 { 
00058     LOGPRINTF("anchor[%s], zoom[%f], rotation[%d], reference_id[%d]",
00059                anchor.c_str(), attrs.zoom, attrs.rotation, ref_id );
00060 
00061     assert(renderer);
00062 
00063     // Check wether this page is already in pages_cache?
00064     ImagePage * ptr = renderer->get_page(anchor, attrs);
00065     if (ptr)
00066     {
00067         WARNPRINTF("Page %s already in pages cache!", anchor.c_str());
00068         
00069         // Notify renderer this page is ready now.
00070         renderer->notify_page_ready(ptr, ref_id, IMG_RENDER_OK, user_data);
00071         return;
00072     }
00073 
00074     // Check wether there's enough memory, then render this page.
00075     ImageRenderStatus ret = renderer->can_render(anchor, attrs);
00076     ImagePage * image = 0; 
00077     if (ret == IMG_RENDER_OK)
00078     {
00079         // Render the image
00080         image = new ImagePage(anchor, attrs); 
00081         assert(image);
00082         bool ok = image->render();
00083         if (!ok)
00084         {
00085             ret = IMG_RENDER_FAIL;
00086         }
00087     }
00088     if (ret != IMG_RENDER_OK)
00089     {
00090         WARNPRINTF("Can't render page %s. Error code: %d", anchor.c_str(), ret);
00091 
00092         // Notify renderer this page is not ready for some reason.
00093         renderer->notify_page_ready(0, ref_id, ret, user_data);
00094         delete image;
00095         return;
00096     }
00097     
00098     // Push the ImagePage into 'pages cache'
00099     renderer->add_page(image);
00100         
00101     // Notify renderer this page is ready.
00102     renderer->notify_page_ready(image, ref_id, ret, user_data);
00103 }

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.2-20100208