void TestStrokeAAPerformance()
成都創(chuàng)新互聯(lián)是一家專注于做網(wǎng)站、成都網(wǎng)站制作與策劃設(shè)計,富蘊網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十載,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:富蘊等地區(qū)。富蘊做網(wǎng)站價格咨詢:18980820575
{
agg::rendering_buffer &rbuf = rbuf_window();
agg::pixfmt_bgr24 pixf(rbuf);
typedef agg::renderer_base<agg::pixfmt_bgr24> renderer_base_type;
renderer_base_type renb(pixf);
typedef agg::renderer_scanline_aa_solid<renderer_base_type>renderder_scanline_type;
renderder_scanline_type rensl(renb);
agg::rasterizer_scanline_aa<> ras;
agg::scanline_u8 sl;
ras.reset();
renb.clear(agg::rgba8(255,255,255));
int nPointX[5]={20,80,20,80,20};
int nPointY[5]={20,20,80,80,20};
agg::path_storage ps;
ps.move_to(nPointX[0],nPointY[0]);
for (int i =1; i<= 4; i++)
{
ps.line_to(nPointX[i],nPointY[i]);
ps.move_to(nPointX[i],nPointY[i]);
}
stroke(trans);
agg::conv_stroke<agg::path_storage> stroke(ps);
stroke.width(nLineWidth);
int start = ::GetTickCount();
ras.gamma(agg::gamma_threshold(0.5));//取消抗鋸齒;注釋使用抗鋸齒功能
for (int x=0;x<1000;x++)
{
ras.add_path(stroke);
}
agg::render_scanlines_aa_solid(ras,sl,renb,agg::rgba8(255,0,0));
int end = ::GetTickCount();
int costTime = 0;
costTime = end -start;
}
void TestOutLineAAPerformance()
{
agg::rendering_buffer &rbuf = rbuf_window();
agg::pixfmt_bgr24 pixf(rbuf);
typedef agg::renderer_outline_aa<agg::pixfmt_bgr24> renderer_type;
agg::line_profile_aa profile;
profile.gamma(agg::gamma_threshold(0.5));
profile.width(nLineWidth);//強制性要求設(shè)置線寬
renderer_type ren(pixf,profile);
typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;
rasterizer_type ras(ren);
ren.color(agg::rgba8(255,0,0));//可選
int nPointX[5]={20,80,20,80,20};
int nPointY[5]={20,20,80,80,20};
agg::path_storage ps;
ps.move_to(nPointX[0],nPointY[0]);
for (int i =1; i<= 4; i++)
{
ps.line_to(nPointX[i],nPointY[i]);
ps.move_to(nPointX[i],nPointY[i]);
}
//agg::conv_transform<agg::path_storage,roundoff>trans(ps,roundoff());
int start = ::GetTickCount();
for (int x=0;x<1000;x++)
{
ras.add_path(ps);
}
int end = ::GetTickCount();
int costTime = 0;
costTime = end -start;
}
簡單說明:agg::gamma_threshold(0.5)主要應(yīng)用于關(guān)閉抗鋸齒功能,注釋掉所在的代碼行就可以啟用抗鋸齒功能。
1)是否設(shè)置抗鋸齒,對于渲染的速度沒有多大的幫助,不引入抗鋸齒,耗時稍微多了一點。
2)在渲染細微的線的時候,采用outline_aa更快,如果是厚線,采用stroke_aa更好??!
如下是作者的觀點:
1)亞像素精度和速度沒有多大的關(guān)系
2)一般情況下,rasterizer_outline_aa渲染的速度是conv_stroke和rasterizer_scanline_aa的兩倍。但是有非常明顯的限制,只支持miter連接,生成一些工件(artifacts),在渲染厚線的時候更加明顯。
3)實際上渲染鋸齒的厚線遠比抗鋸齒的厚線更加的復(fù)雜,看起來可能非常奇怪。所以是否抗鋸齒不會加快渲染速度。
4)渲染厚線(是否抗鋸齒)是一項非常復(fù)雜的操作,目前只能夠通過stroker和scanline rasterizer配合工作使用。如果你需要一個非常非常快的渲染厚線的方法,AGG恐怕無法勝任,可能需要硬件加速,但是可能會有更多的限制??!
Having subpixel accuracy doesn't reallymatter for speed.
In general, rasterizer_outline_aa worksabout twice faster than conv_stroke
plus rasterizer_scanline_aa. But it hascertain restrictions (only miter joins)
and produces some artifacts, especiallywith thick lines.
It may seem strange, but it's moredifficult to draw aliased thick polyline
than anti-aliased one. You anyway have toconsider line joins at least. To turn
off anti-aliasing you can use thefollowing:
agg::line_profile_aa profile(10.0,agg::gamma_threshold(0.5));
But it won't speed up rendering.
Fully correct thick outline (aliased oranti-aliased) is a very complex task
and can be solved only with the strokerplus scanline rasterizer.
If you really need to draw thick lines veryvery fast, I'm afraid that AGG is
not what you need. You can try somethingelse, with hardware acceleration,
But this method is even more restrictivethan the general stroker.
分享名稱:AGG第三十四課stroke_aa和outline_aa渲染線段效率對比
網(wǎng)站路徑:http://chinadenli.net/article36/iegcpg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、App開發(fā)、做網(wǎng)站、定制網(wǎng)站、手機網(wǎng)站建設(shè)、網(wǎng)站維護
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)