Changeset 55

Show
Ignore:
Timestamp:
02/03/09 09:22:18 (3 years ago)
Author:
mirko
Message:

minor changes

Location:
branches/clutter-experiments
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/clutter-experiments/main.cc

    r54 r55  
    6666      ClutterColor stage_color; 
    6767      the_stage_m = clutter_stage_get_default(); 
     68      clutter_actor_set_size(the_stage_m, 1024, 768); 
    6869      clutter_color_parse("Black", &stage_color); 
    6970      clutter_stage_set_color(CLUTTER_STAGE(the_stage_m), &stage_color); 
     
    8081      if(active_document == NULL) 
    8182        { 
    82           g_print(_("PDF file %s cannot be opened, check it exists, permissions" 
     83          g_print(_("PDF file %s cannot be opened," 
     84                    " check that it exists, permissions" 
    8385                    " and that is \nnot encrypted.\n"), filename_m); 
    8486          return false; 
     
    99101        clutter_text_new_full("Mono 36", "0%", &label_color); 
    100102      guint screen_w, screen_h; 
    101       clutter_actor_get_size(CLUTTER_ACTOR(the_stage_m), &screen_w, &screen_h); 
    102       clutter_actor_set_position(progress_label_m, screen_w>>1, screen_h>>1); 
     103      clutter_actor_get_size(CLUTTER_ACTOR(the_stage_m),  
     104                             &screen_w, &screen_h); 
     105      clutter_actor_set_position(progress_label_m,  
     106                                 screen_w>>1, screen_h>>1); 
    103107      clutter_actor_set_anchor_point_from_gravity(progress_label_m,  
    104108                                                  CLUTTER_GRAVITY_CENTER); 
     
    107111      clutter_actor_show(the_stage_m); 
    108112      g_thread_create(render_thread, this, FALSE, NULL); 
    109  
     113       
    110114      clutter_threads_enter(); 
    111115      clutter_main(); 
     
    152156      GdkPixbuf* buffer = me->the_doc_m->page(0).pixbuf(pdfcube::page::HI_RES); 
    153157      me->current_page_m = clutter_texture_new(); 
     158      clutter_texture_set_filter_quality 
     159        (CLUTTER_TEXTURE(me->current_page_m),  
     160         CLUTTER_TEXTURE_QUALITY_HIGH); 
    154161      clutter_texture_set_from_rgb_data  
    155162        (CLUTTER_TEXTURE(me->current_page_m), 
     
    161168         4, (ClutterTextureFlags)0, 
    162169         &error); 
     170 
    163171      guint screen_w, screen_h; 
    164172      clutter_actor_get_size(CLUTTER_ACTOR(me->the_stage_m),  
    165173                             &screen_w, &screen_h); 
    166       clutter_actor_set_size(me->current_page_m, screen_w, screen_h); 
     174       
     175       
     176      // Check if our slot ratio is less or more than owr own 
     177      double aspect = me->the_doc_m->page(0).aspect_ratio(); 
     178       
     179      double w = 0.0, h = 0.0; 
     180      if(screen_h > screen_w/aspect) 
     181        { 
     182          w = screen_w; 
     183          h = w/aspect; 
     184        } 
     185      else  
     186        { 
     187          h = screen_h; 
     188          w = h*aspect; 
     189        } 
     190       
     191      clutter_actor_set_size(me->current_page_m, w, h); 
    167192      clutter_group_add_many(CLUTTER_GROUP(me->the_stage_m),  
    168193                             me->current_page_m, NULL); 
  • branches/clutter-experiments/page.hh

    r52 r55  
    11// TODO: move implementation in .cc file 
    22// TODO: refine api, it's somewhat ugly right now 
    3 // TODO: should render in a thread? 
     3// TODO: should we render in a thread? 
    44#ifndef __PDFCUBE__PAGE_HH__ 
    55#define __PDFCUBE__PAGE_HH__ 
     
    77#include <glib.h> 
    88#include <poppler.h> 
    9 //#include <clutter/clutter.h> 
    109#include <gdk-pixbuf/gdk-pixbuf.h> 
    1110 
     
    1817   * 
    1918   * This class is used to render low and hi res version of a 
    20    * PopplerPage as a ClutterActor. 
     19   * PopplerPage as GdkPixbufs 
    2120   * 
    22    * Usually on start all the pages will be rendered in a low res 
     21   * Usually, on start, all the pages will be rendered in a low res 
    2322   * version, while higher res versions will be rendered on demand by 
    2423   * the animations. We need to program the animations in advance so 
     
    6564     
    6665    /** 
    67      * @brief Renders the PopplerPage on the desired actor. 
     66     * @brief Renders the PopplerPage on the desired pixbuf. 
    6867     */ 
    6968    void 
     
    9190              } 
    9291 
    93             // GdkPixbuf* low_res_m = NULL; 
    9492            if(!low_res_m) 
    9593              low_res_m = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, w, h); 
     
    107105          { 
    108106            int w, h; 
    109             // we assume 4/3 aspect monitor can do better 
     107            // we assume 4/3 aspect monitor can be done better 
    110108            double box_w = 1600; 
    111109            double box_h = 1200; 
     
    132130                                          0,  
    133131                                          hi_res_m); 
    134             GError* error = 0; 
    135              
    136             /* 
    137             if(!hi_res_m) hi_res_m = clutter_texture_new(); 
    138             clutter_texture_set_from_rgb_data  
    139                (CLUTTER_TEXTURE(hi_res_m), 
    140                 gdk_pixbuf_get_pixels(buffer), 
    141                 gdk_pixbuf_get_has_alpha(buffer), 
    142                 gdk_pixbuf_get_width(buffer), 
    143                 gdk_pixbuf_get_height(buffer), 
    144                 gdk_pixbuf_get_rowstride(buffer), 
    145                 4, (ClutterTextureFlags)0, 
    146                 &error); 
    147             g_object_unref(buffer); 
    148             */ 
    149132            break; 
    150133          }