示例#1
0
RoadMapPen roadmap_canvas_select_pen (RoadMapPen pen)
{
   if( !pen)
      return NULL;

   RoadMapPen old_pen = CurrentPen;
   dbg_time_start(DBG_TIME_SELECT_PEN);
   reno.profile(*pen->profile);
   reno.color(pen->color);
   CurrentPen = pen;

   dbg_time_end(DBG_TIME_SELECT_PEN);

   return old_pen;
}
void roadmap_canvas_refresh (void) {
   HDC hdc;
   
   if (RoadMapDrawingArea == NULL) return;
   
   dbg_time_start(DBG_TIME_FLIP);
   
   hdc = GetDC(RoadMapDrawingArea);
   BitBlt(hdc, ClientRect.left, ClientRect.top,
      ClientRect.right - ClientRect.left + 1,
      ClientRect.bottom - ClientRect.top + 1,
      RoadMapDrawingBuffer, 0, 0, SRCCOPY); 
   
   DeleteDC(hdc);
   dbg_time_end(DBG_TIME_FLIP);
}
示例#3
0
void roadmap_canvas_draw_formated_string_angle (const RoadMapGuiPoint *position,
                                                RoadMapGuiPoint *center,
                                                int angle, int size,
                                                int font_type,
                                                const char *text)
{

   font_manager_type *fman;
   font_manager_type *image_fman;
   font_engine_type  *feng;
   font_engine_type  *image_feng;

   if ((font_type & FONT_TYPE_NORMAL) && (!RoadMapCanvasNormalFontLoaded))
      font_type = FONT_TYPE_BOLD;


   if (font_type & FONT_TYPE_NORMAL){
      fman = &m_fman_nor;
      feng = &m_feng_nor;
      image_feng = &m_image_feng_nor;
      image_fman = &m_image_fman_nor;
   }
   else{
      fman = &m_fman;
      feng = &m_feng;
      image_feng = &m_image_feng;
      image_fman = &m_image_fman;
   }


   if ((font_type & FONT_TYPE_BOLD) && (RoadMapCanvasFontLoaded != 1)) return;


   dbg_time_start(DBG_TIME_TEXT_FULL);
   dbg_time_start(DBG_TIME_TEXT_CNV);

   wchar_t wstr[255];
   int length = roadmap_canvas_agg_to_wchar (text, wstr, 255);
   if (length <=0) return;

#ifdef USE_FRIBIDI
   wchar_t *bidi_text = bidi_string(wstr);
   const wchar_t* p = bidi_text;
#else
   const wchar_t* p = wstr;
#endif

   ren_solid.color(CurrentPen->color);
   dbg_time_end(DBG_TIME_TEXT_CNV);

   double x  = 0;
   double y  = 0;
   if (size < 0) size = 15;

   if ( roadmap_screen_is_hd_screen() )
   {
     size = (int)(size * CANVAS_HD_FONT_FACTOR);
   }
   else{
#ifdef _WIN32
      size = (int) (size * 0.9);
#endif
   }

   if (angle == 0) {

      /* Use faster drawing for text with no angle */
      x  = position->x;
      y  = position->y;

//      ren_solid.color(agg::rgba8(0, 0, 0));

      image_feng->height(size);
      image_feng->width(size);

      while(*p) {
         const agg::glyph_cache* glyph = image_fman->glyph(*p);

         if(glyph) {
            image_fman->init_embedded_adaptors(glyph, x, y);

            agg::render_scanlines(image_fman->gray8_adaptor(),
                  image_fman->gray8_scanline(),
                  ren_solid);

            // increment pen position
            x += glyph->advance_x;
            y += glyph->advance_y;
         }
         ++p;
      }
   }
   else{
      feng->height(size);
      feng->width(size);
   }

   while(*p) {
      dbg_time_start(DBG_TIME_TEXT_ONE_LETTER);
      dbg_time_start(DBG_TIME_TEXT_GET_GLYPH);
      const agg::glyph_cache* glyph = fman->glyph(*p);
      dbg_time_end(DBG_TIME_TEXT_GET_GLYPH);

      if(glyph) {
         fman->init_embedded_adaptors(glyph, x, y);

         //agg::conv_curve<font_manager_type::path_adaptor_type> stroke(fman->path_adaptor());

         agg::trans_affine mtx;
         if (abs(angle) > 0) {
            mtx *= agg::trans_affine_rotation(agg::deg2rad(angle));
         }
         mtx *= agg::trans_affine_translation(position->x, position->y);

         agg::conv_transform<font_manager_type::path_adaptor_type> tr(fman->path_adaptor(), mtx);

         agg::conv_curve<agg::conv_transform<font_manager_type::path_adaptor_type> > fill(tr);

         //agg::conv_stroke<
            //agg::conv_curve<agg::conv_transform<font_manager_type::path_adaptor_type> > >
         //stroke(fill);

         //agg::conv_contour<agg::conv_transform<font_manager_type::path_adaptor_type> >contour(tr);
         //contour.width(2);

         //agg::conv_stroke< agg::conv_contour<agg::conv_transform<font_manager_type::path_adaptor_type> > > stroke(contour);
         //agg::conv_stroke< agg::conv_transform<font_manager_type::path_adaptor_type> > stroke(tr);

         dbg_time_start(DBG_TIME_TEXT_ONE_RAS);

#ifdef WIN32_PROFILE
         ResumeCAPAll();
#endif
         ras.reset();
         ras.add_path(tr);
         agg::render_scanlines(ras, sl, ren_solid);
         //ras.add_path(fill);
         //ras.add_path(stroke);
         //ren_solid.color(agg::rgba8(255, 255, 255));
         //agg::render_scanlines(ras, sl, ren_solid);
         //ras.add_path(tr);
         //ren_solid.color(agg::rgba8(0, 0, 0));
         //agg::render_scanlines(ras, sl, ren_solid);

#ifdef WIN32_PROFILE
         SuspendCAPAll();
#endif

         dbg_time_end(DBG_TIME_TEXT_ONE_RAS);

         // increment pen position
         x += glyph->advance_x;
         y += glyph->advance_y;
         dbg_time_end(DBG_TIME_TEXT_ONE_LETTER);
      }
      ++p;
   }

#ifdef USE_FRIBIDI
   free(bidi_text);
#endif

   dbg_time_end(DBG_TIME_TEXT_FULL);
}
示例#4
0
void roadmap_canvas_draw_multiple_lines (int count, int *lines,
      RoadMapGuiPoint *points, int fast_draw) {

   int i;
   int count_of_points;


   dbg_time_start(DBG_TIME_DRAW_LINES);
#ifdef WIN32_PROFILE
   ResumeCAPAll();
#endif

#ifdef _WIN32_
   if (fast_draw) {
      roadmap_canvas_native_draw_multiple_lines (count, lines, points,
         CurrentPen->color.r, CurrentPen->color.g, CurrentPen->color.b,
         CurrentPen->thickness);
      return;
   }
#endif

   if (!fast_draw) {
      raso.round_cap(true);
      raso.line_join(agg::outline_miter_accurate_join);
   } else {
      raso.round_cap(false);
      raso.line_join(agg::outline_no_join);
   }

//   raso.accurate_join(true);

   static agg::path_storage path;

   for (i = 0; i < count; ++i) {

      int first = 1;

      count_of_points = *lines;

      if (count_of_points < 2) continue;

      dbg_time_start(DBG_TIME_CREATE_PATH);

      for (int j=0; j<count_of_points; j++) {

         if (first) {
            first = 0;
            path.move_to(points->x, points->y);
         } else {
            path.line_to(points->x, points->y);
         }

         points++;
      }

      dbg_time_end(DBG_TIME_CREATE_PATH);
      dbg_time_start(DBG_TIME_ADD_PATH);

#if 0
      if (fast_draw) {
         renderer_pr ren_pr(agg_renb);
         agg::rasterizer_outline<renderer_pr> ras_line(ren_pr);
         ren_pr.line_color(CurrentPen->color);
         ras_line.add_path(path);

      } else {
     #endif
         raso.add_path(path);
      //}

      path.remove_all ();
      dbg_time_end(DBG_TIME_ADD_PATH);

      lines += 1;
   }


#ifdef WIN32_PROFILE
   SuspendCAPAll();
#endif



	return;


   dbg_time_end(DBG_TIME_DRAW_LINES);
}

void roadmap_canvas_draw_multiple_polygons
         (int count, int *polygons, RoadMapGuiPoint *points, int filled,
          int fast_draw) {

   int i;
   int count_of_points;

   static agg::path_storage path;

   for (i = 0; i < count; ++i) {

      count_of_points = *polygons;

      int first = 1;

      for (int j=0; j<count_of_points; j++) {

         if (first) {
            first = 0;
            path.move_to(points->x, points->y);
         } else {
            path.line_to(points->x, points->y);
         }
         points++;
      }

      path.close_polygon();

      if (filled) {

         ras.reset();
         ras.add_path(path);
         ren_solid.color(CurrentPen->color);
         agg::render_scanlines( ras, sl, ren_solid);

      } else if (fast_draw) {
         renderer_pr ren_pr(agg_renb);
         agg::rasterizer_outline<renderer_pr> ras_line(ren_pr);
         ren_pr.line_color(CurrentPen->color);
         ras_line.add_path(path);

      } else {

         raso.add_path(path);
      }

      path.remove_all ();

      polygons += 1;
   }
}