CoreGraphicsがiPhone4よ3G/3GS
-
25-09-2019 - |
質問
している図表されCoreGraphics.
この図表できる水平スクロールで描かれたスクロールします。
問題は、3G/3GSの高速化と高機能のスクロールは良いのですがiPhone4はより遅くなる。
ねこの問題に関する高解像度のiPhone4.A:はい、そうなります。
たいのですがパフォーマンスが向上しますiPhone4?の枠組みの自動変換にiPhone4分解能のようなものがありますか?
ありがとうございます。
解決
のiPhone4ができ 多く 遅くなりまCoreGraphics処となります。
することを可能と考えです。時にユーザがスクロールな描く完全分解能を描くCoreGraphics関連のものを半分解能コンテキストその後そのコンテキストとしてビットマップおよび規模までとなってフル解像度こfor iPhone4のみというのも高品質だけですが、ユーザがスクロールします。
こちらは一部のコードを書いための試験とは異なる。
私た場合の結果を表示するビューでフル画面になります。
- 3G 9FPS
- 3GS, 16FPS
- i4, 5FPS (bummer)
CoreGraphicsTestView.h
#import <UIKit/UIKit.h>
@interface CoreGraphicsTestView : UIView
{
int displayCounter;
float displayInterval;
char fps[50];
}
@end
CoreGraphicsTestView.m
#import "CoreGraphicsTestView.h"
#define RNDN(s, e) ((((CGFloat)rand() / (CGFloat)INT_MAX) * ((e)-(s)) + (s)))
#define RNDX(s, e, r) (RNDN((s), (e)) * (r).size.width)
#define RNDY(s, e, r) (RNDN((s), (e)) * (r).size.height)
#define RNDR(r) (CGRectMake(RNDX(0,0.50,(r)),RNDY(0,0.50,(r)),RNDX(0.50,1.0,(r)),RNDY(0.50,1.0,(r))))
@implementation CoreGraphicsTestView
- (id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame]))
{
self.backgroundColor = [UIColor blackColor];
srand(time(NULL));
fps[0] = '\0';
}
return self;
}
- (void)updateDisplayCounter:(CGContextRef)c rect:(CGRect)rect
{
displayCounter++;
float now = (float)clock() / (float)CLOCKS_PER_SEC;
if (now - displayInterval > 1)
{
sprintf(fps, "%0.0f", displayCounter / (now - displayInterval));
printf("%s\n", fps);
displayInterval = now;
displayCounter = 0;
}
CGContextTranslateCTM(c, 5, 40);
CGContextScaleCTM(c, 1.0, -1.0);
CGContextSetFillColorWithColor(c, [UIColor whiteColor].CGColor);
CGContextSelectFont(c, "Arial", 18, kCGEncodingMacRoman);
CGContextShowTextAtPoint(c, 0, 0, fps, strlen(fps));
}
- (void)setRandomColor:(CGContextRef)c
{
CGFloat components[4] = {1,RNDN(0, 1),RNDN(0, 1),RNDN(0, 1)};
CGContextSetFillColor(c, components);
}
- (void)drawRect:(CGRect)rect
{
CGContextRef c = UIGraphicsGetCurrentContext();
for (int i=0;i<5;i++)
{
[self setRandomColor:c];
CGContextFillRect(c, RNDR(rect));
[self setRandomColor:c];
CGContextFillEllipseInRect(c, RNDR(rect));
}
[self updateDisplayCounter:c rect:rect];
[self performSelector:@selector(setNeedsDisplay) withObject:nil afterDelay:0.0];
}
@end
他のヒント
の体験"では遅い"のについて説明していただけまでより正確に?私はこのようなフレームレートをスクロールが低くなった場所でどんな滑らかなもstutters.
その場合、まるでこの決議の原因であること、二つの方法が一般的です。
- 更新例えば半分の間隔で、レンダリング半の広さでスライス.ばココアタッチになると、トリガーでのコールバックでの時間間隔のレンダリング手法の提案います。
- 描画されていなかったが、事前に"このグラフ隠さらに社外の視聴可能地域を描きのスクロールが見えてきます。
っといいを見て"Drawing"の性質は、不透明などで、それこそが真のグローバルには影響します。
所属していません StackOverflow