some clean up and reuse of member variables for more efficiency
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12415 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -17,8 +17,7 @@
|
|||||||
#include <agg_conv_segmentator.h>
|
#include <agg_conv_segmentator.h>
|
||||||
#include <agg_conv_transform.h>
|
#include <agg_conv_transform.h>
|
||||||
//#include <agg_rendering_buffer.h>
|
//#include <agg_rendering_buffer.h>
|
||||||
#include <agg_scanline_u.h>
|
//#include <agg_scanline_bin.h>
|
||||||
#include <agg_scanline_bin.h>
|
|
||||||
//#include <agg_renderer_mclip.h>
|
//#include <agg_renderer_mclip.h>
|
||||||
//#include <agg_renderer_scanline.h>
|
//#include <agg_renderer_scanline.h>
|
||||||
//#include <agg_renderer_primitives.h>
|
//#include <agg_renderer_primitives.h>
|
||||||
@@ -205,21 +204,13 @@ AGGTextRenderer::RenderString(const char* string,
|
|||||||
|
|
||||||
BRect bounds(0.0, 0.0, -1.0, -1.0);
|
BRect bounds(0.0, 0.0, -1.0, -1.0);
|
||||||
|
|
||||||
typedef agg::conv_curve<font_manager_type::path_adaptor_type> conv_font_curve_type;
|
fCurves.approximation_scale(transform.scale());
|
||||||
// typedef agg::conv_segmentator<conv_font_curve_type> conv_font_segm_type;
|
|
||||||
// typedef agg::conv_transform<conv_font_segm_type, agg::trans_affine> conv_font_trans_type;
|
// use a transformation behind the curves
|
||||||
|
// (only if glyph->data_type == agg::glyph_data_outline)
|
||||||
|
// in the pipeline for the rasterizer
|
||||||
typedef agg::conv_transform<conv_font_curve_type, agg::trans_affine> conv_font_trans_type;
|
typedef agg::conv_transform<conv_font_curve_type, agg::trans_affine> conv_font_trans_type;
|
||||||
|
conv_font_trans_type ftrans(fCurves, transform);
|
||||||
agg::scanline_u8 sl;
|
|
||||||
agg::rasterizer_scanline_aa<> ras;
|
|
||||||
|
|
||||||
|
|
||||||
conv_font_curve_type fcurves(fFontManager.path_adaptor());
|
|
||||||
fcurves.approximation_scale(transform.scale());
|
|
||||||
// conv_font_segm_type fsegm(fcurves);
|
|
||||||
// conv_font_trans_type ftrans(fsegm, transform);
|
|
||||||
conv_font_trans_type ftrans(fcurves, transform);
|
|
||||||
|
|
||||||
|
|
||||||
int32 srcLength = min_c(length, strlen(string));
|
int32 srcLength = min_c(length, strlen(string));
|
||||||
int32 dstLength = srcLength * 4;
|
int32 dstLength = srcLength * 4;
|
||||||
@@ -282,7 +273,6 @@ AGGTextRenderer::RenderString(const char* string,
|
|||||||
// we cannot use the transformation pipeline
|
// we cannot use the transformation pipeline
|
||||||
double transformedX = x + transformOffset.x;
|
double transformedX = x + transformOffset.x;
|
||||||
double transformedY = y + transformOffset.y;
|
double transformedY = y + transformOffset.y;
|
||||||
//printf("x: %f, y: %f\n", transformedX, transformedY);
|
|
||||||
fFontManager.init_embedded_adaptors(glyph,
|
fFontManager.init_embedded_adaptors(glyph,
|
||||||
transformedX,
|
transformedX,
|
||||||
transformedY);
|
transformedY);
|
||||||
@@ -308,7 +298,7 @@ AGGTextRenderer::RenderString(const char* string,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case agg::glyph_data_outline:
|
case agg::glyph_data_outline:
|
||||||
ras.reset();
|
fRasterizer.reset();
|
||||||
// NOTE: this function can be easily extended to handle
|
// NOTE: this function can be easily extended to handle
|
||||||
// conversion to contours, to that's why there is a lot of
|
// conversion to contours, to that's why there is a lot of
|
||||||
// commented out code, I leave here because I think it
|
// commented out code, I leave here because I think it
|
||||||
@@ -318,16 +308,16 @@ AGGTextRenderer::RenderString(const char* string,
|
|||||||
// For the sake of efficiency skip the
|
// For the sake of efficiency skip the
|
||||||
// contour converter if the weight is about zero.
|
// contour converter if the weight is about zero.
|
||||||
//-----------------------
|
//-----------------------
|
||||||
// ras.add_path(fCurves);
|
// fRasterizer.add_path(fCurves);
|
||||||
ras.add_path(ftrans);
|
fRasterizer.add_path(ftrans);
|
||||||
/* } else {
|
/* } else {
|
||||||
// ras.add_path(fContour);
|
// fRasterizer.add_path(fContour);
|
||||||
ras.add_path(ftrans);
|
fRasterizer.add_path(ftrans);
|
||||||
}*/
|
}*/
|
||||||
if (fAntialias) {
|
if (fAntialias) {
|
||||||
agg::render_scanlines(ras, sl, *solidRenderer);
|
agg::render_scanlines(fRasterizer, fScanline, *solidRenderer);
|
||||||
} else {
|
} else {
|
||||||
agg::render_scanlines(ras, sl, *binRenderer);
|
agg::render_scanlines(fRasterizer, fScanline, *binRenderer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -346,12 +336,8 @@ AGGTextRenderer::RenderString(const char* string,
|
|||||||
// put pen location behind rendered text
|
// put pen location behind rendered text
|
||||||
// (at the baseline of the virtual next glyph)
|
// (at the baseline of the virtual next glyph)
|
||||||
if (nextCharPos) {
|
if (nextCharPos) {
|
||||||
x += fAdvanceScale * advanceX;
|
nextCharPos->x = x + advanceX;
|
||||||
if (advanceX > 0.0 && fAdvanceScale > 1.0)
|
nextCharPos->y = y + advanceY;
|
||||||
x += (fAdvanceScale - 1.0) * fFontEngine.height();
|
|
||||||
y += advanceY;
|
|
||||||
nextCharPos->x = x;
|
|
||||||
nextCharPos->y = y;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "UTF8 -> Unicode conversion failed: %s\n", strerror(ret));
|
fprintf(stderr, "UTF8 -> Unicode conversion failed: %s\n", strerror(ret));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <agg_conv_curve.h>
|
#include <agg_conv_curve.h>
|
||||||
#include <agg_conv_contour.h>
|
#include <agg_conv_contour.h>
|
||||||
|
#include <agg_scanline_u.h>
|
||||||
|
|
||||||
#include "agg_font_freetype.h"
|
#include "agg_font_freetype.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
@@ -44,17 +45,19 @@ class AGGTextRenderer : public TextRenderer {
|
|||||||
|
|
||||||
typedef agg::font_engine_freetype_int32 font_engine_type;
|
typedef agg::font_engine_freetype_int32 font_engine_type;
|
||||||
typedef agg::font_cache_manager<font_engine_type> font_manager_type;
|
typedef agg::font_cache_manager<font_engine_type> font_manager_type;
|
||||||
|
typedef agg::conv_curve<font_manager_type::path_adaptor_type>
|
||||||
|
conv_font_curve_type;
|
||||||
|
typedef agg::conv_contour<conv_font_curve_type> conv_font_contour_type;
|
||||||
|
|
||||||
font_engine_type fFontEngine;
|
font_engine_type fFontEngine;
|
||||||
font_manager_type fFontManager;
|
font_manager_type fFontManager;
|
||||||
|
|
||||||
// Pipeline to process the vectors glyph paths (curves + contour)
|
// Pipeline to process the vectors glyph paths (curves + contour)
|
||||||
agg::conv_curve<font_manager_type::path_adaptor_type>
|
conv_font_curve_type fCurves;
|
||||||
fCurves;
|
conv_font_contour_type fContour;
|
||||||
agg::conv_contour<agg::conv_curve<font_manager_type::path_adaptor_type> >
|
|
||||||
fContour;
|
|
||||||
|
|
||||||
BRect fBounds;
|
agg::scanline_u8 fScanline;
|
||||||
|
agg::rasterizer_scanline_aa<> fRasterizer;;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AGG_TEXT_RENDERER_H
|
#endif // AGG_TEXT_RENDERER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user