小编Ric*_*ard的帖子

drawRect表现

我需要在iPad上绘制50万到100万的多边形.经过实验,我只能获得1 fps.这只是一个例子,我的真实代码有一些大小合适的多边形.

以下是一些问题:

  1. 为什么我不必将Quartz Framework添加到我的项目中?
  2. 如果许多多边形重复,我可以利用它与视图或它们太重等?
  3. 任何替代方案,QTPaint都可以处理这个问题,但是会进入gpu.有没有像QT或ios这样的东西?
  4. Opengl可以增加这种类型的2d性能吗?

示例drawrect:

//X Y Array of boxes

- (void)drawRect:(CGRect)rect
{
    int reset = [self pan].x;
    int markX = reset;
    int markY = [self pan].y;
    CGContextRef context = UIGraphicsGetCurrentContext();
    for(int i = 0; i < 1000; i++)//1,000,000
    {
        for(int j = 0; j < 1000; j++)
        {
            CGContextMoveToPoint(context, markX,  markY);
            CGContextAddLineToPoint(context, markX, markY + 10);
            CGContextAddLineToPoint(context, markX + 10, markY + 10);
            CGContextAddLineToPoint(context, markX + 10, markY);
            CGContextAddLineToPoint(context, markX, markY);
            CGContextStrokePath(context);
            markX+=12;
        }
        markY …
Run Code Online (Sandbox Code Playgroud)

performance drawrect ipad ios

5
推荐指数
1
解决办法
8257
查看次数

标签 统计

drawrect ×1

ios ×1

ipad ×1

performance ×1