Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
4cae6fa2
Kaydet (Commit)
4cae6fa2
authored
Ara 19, 2013
tarafından
Tor Lillqvist
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add tiles per second counter (averaged over last five seconds)
Change-Id: I11e282c1a72dbc6b41a5a89229065983b41eb65b
üst
18397efd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
2 deletions
+80
-2
TiledView.m
...xperimental/TiledLibreOffice/TiledLibreOffice/TiledView.m
+61
-2
View.h
ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h
+2
-0
View.m
ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m
+17
-0
No files found.
ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m
Dosyayı görüntüle @
4cae6fa2
...
@@ -19,6 +19,60 @@
...
@@ -19,6 +19,60 @@
@implementation
TiledView
@implementation
TiledView
static
const
int
NTIMESTAMPS
=
100
;
static
const
CFTimeInterval
AVERAGINGTIME
=
5
;
static
CFTimeInterval
tileTimestamps
[
NTIMESTAMPS
];
static
int
curFirstTimestamp
=
0
;
static
int
curNextTimestamp
=
0
;
static
void
dropOldTimestamps
(
CFTimeInterval
now
)
{
// Drop too old timestamps
while
(
curFirstTimestamp
!=
curNextTimestamp
&&
now
-
tileTimestamps
[
curFirstTimestamp
]
>=
AVERAGINGTIME
)
curFirstTimestamp
=
(
curFirstTimestamp
+
1
)
%
NTIMESTAMPS
;
}
static
void
updateTilesPerSecond
(
UILabel
*
label
)
{
int
n
=
(
curNextTimestamp
<
curFirstTimestamp
)
?
(
NTIMESTAMPS
-
(
curFirstTimestamp
-
curNextTimestamp
))
:
((
curNextTimestamp
-
curFirstTimestamp
));
// NSLog(@"first:%d next:%d n:%d", curFirstTimestamp, curNextTimestamp, n);
double
tps
=
n
/
AVERAGINGTIME
;
[
label
setText
:[
NSString
stringWithFormat
:
@"%.0f tiles/second"
,
tps
]];
}
-
(
void
)
didRenderTile
{
CFTimeInterval
now
=
CACurrentMediaTime
();
@synchronized
(
self
)
{
dropOldTimestamps
(
now
);
// Add new timestamp
tileTimestamps
[
curNextTimestamp
]
=
now
;
// Let next added replace newest if array full
if
(
curFirstTimestamp
!=
(
curNextTimestamp
+
1
)
%
NTIMESTAMPS
)
curNextTimestamp
=
(
curNextTimestamp
+
1
)
%
NTIMESTAMPS
;
updateTilesPerSecond
(((
View
*
)
[
self
superview
]).
tpsLabel
);
}
}
-
(
void
)
updateTilesPerSecond
{
CFTimeInterval
now
=
CACurrentMediaTime
();
@synchronized
(
self
)
{
dropOldTimestamps
(
now
);
updateTilesPerSecond
(((
View
*
)
[
self
superview
]).
tpsLabel
);
}
}
-
(
id
)
initWithFrame
:
(
CGRect
)
frame
scale
:
(
CGFloat
)
scale
maxZoom
:
(
int
)
maxZoom
-
(
id
)
initWithFrame
:
(
CGRect
)
frame
scale
:
(
CGFloat
)
scale
maxZoom
:
(
int
)
maxZoom
{
{
self
=
[
super
initWithFrame
:
frame
];
self
=
[
super
initWithFrame
:
frame
];
...
@@ -28,6 +82,8 @@
...
@@ -28,6 +82,8 @@
catl
.
tileSize
=
CGSizeMake
(
512
,
512
);
catl
.
tileSize
=
CGSizeMake
(
512
,
512
);
catl
.
levelsOfDetail
=
log2
(
maxZoom
)
+
1
;
catl
.
levelsOfDetail
=
log2
(
maxZoom
)
+
1
;
catl
.
levelsOfDetailBias
=
catl
.
levelsOfDetail
-
1
;
catl
.
levelsOfDetailBias
=
catl
.
levelsOfDetail
-
1
;
[
NSTimer
scheduledTimerWithTimeInterval
:
1
target
:
self
selector
:
@selector
(
updateTilesPerSecond
)
userInfo
:
nil
repeats
:
YES
];
}
}
return
self
;
return
self
;
}
}
...
@@ -44,8 +100,9 @@
...
@@ -44,8 +100,9 @@
// expected it to be called with a bbox of 256x256.
// expected it to be called with a bbox of 256x256.
CGRect
bb
=
CGContextGetClipBoundingBox
(
ctx
);
CGRect
bb
=
CGContextGetClipBoundingBox
(
ctx
);
double
zoomScale
=
[(
View
*
)
[
self
superview
]
zoomScale
];
CATiledLayer
*
catl
=
(
CATiledLayer
*
)
[
self
layer
];
// double zoomScale = [(View *) [self superview] zoomScale];
// CATiledLayer *catl = (CATiledLayer*) [self layer];
CGContextSaveGState
(
ctx
);
CGContextSaveGState
(
ctx
);
...
@@ -70,6 +127,8 @@
...
@@ -70,6 +127,8 @@
CGPointMake
(
bb
.
origin
.
x
/
self
.
scale
,
bb
.
origin
.
y
/
self
.
scale
),
CGPointMake
(
bb
.
origin
.
x
/
self
.
scale
,
bb
.
origin
.
y
/
self
.
scale
),
CGSizeMake
(
bb
.
size
.
width
/
self
.
scale
,
bb
.
size
.
height
/
self
.
scale
));
CGSizeMake
(
bb
.
size
.
width
/
self
.
scale
,
bb
.
size
.
height
/
self
.
scale
));
[
self
didRenderTile
];
CGContextRestoreGState
(
ctx
);
CGContextRestoreGState
(
ctx
);
// I am a bit confused about what tiles exactly I am drawing, so
// I am a bit confused about what tiles exactly I am drawing, so
...
...
ios/experimental/TiledLibreOffice/TiledLibreOffice/View.h
Dosyayı görüntüle @
4cae6fa2
...
@@ -10,6 +10,8 @@
...
@@ -10,6 +10,8 @@
@interface
View
:
UIScrollView
<
UIScrollViewDelegate
>
@interface
View
:
UIScrollView
<
UIScrollViewDelegate
>
@property
UILabel
*
tpsLabel
;
@end
@end
// vim:set shiftwidth=4 softtabstop=4 expandtab:
// vim:set shiftwidth=4 softtabstop=4 expandtab:
ios/experimental/TiledLibreOffice/TiledLibreOffice/View.m
Dosyayı görüntüle @
4cae6fa2
...
@@ -37,6 +37,14 @@
...
@@ -37,6 +37,14 @@
self
.
subView
=
[[
TiledView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
frame
.
size
.
width
,
frame
.
size
.
width
*
docAspectRatio
)
scale
:
widthScale
maxZoom
:
MAXZOOM
];
self
.
subView
=
[[
TiledView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
frame
.
size
.
width
,
frame
.
size
.
width
*
docAspectRatio
)
scale
:
widthScale
maxZoom
:
MAXZOOM
];
[
self
addSubview
:
self
.
subView
];
[
self
addSubview
:
self
.
subView
];
UILabel
*
tpsLabel
=
[[
UILabel
alloc
]
initWithFrame
:
CGRectMake
(
20
,
20
,
300
,
40
)];
[
tpsLabel
setFont
:[
UIFont
systemFontOfSize
:
38
]];
[
tpsLabel
setBackgroundColor
:
[
UIColor
colorWithRed
:
0
green
:
0
blue
:
0
alpha
:
0
.
3
]];
[
tpsLabel
setTextColor
:
[
UIColor
colorWithRed
:
1
green
:
1
blue
:
0
alpha
:
1
]];
[
tpsLabel
setTextAlignment
:
NSTextAlignmentRight
];
[
self
addSubview
:
tpsLabel
];
self
.
tpsLabel
=
tpsLabel
;
}
}
return
self
;
return
self
;
}
}
...
@@ -46,6 +54,15 @@
...
@@ -46,6 +54,15 @@
return
self
.
subView
;
return
self
.
subView
;
}
}
-
(
void
)
scrollViewDidScroll
:(
UIScrollView
*
)
scrollView
{
CGRect
frame
=
((
View
*
)
scrollView
).
tpsLabel
.
frame
;
frame
.
origin
.
x
=
20
+
scrollView
.
contentOffset
.
x
;
frame
.
origin
.
y
=
20
+
scrollView
.
contentOffset
.
y
;
((
View
*
)
scrollView
).
tpsLabel
.
frame
=
frame
;
}
@end
@end
// vim:set shiftwidth=4 softtabstop=4 expandtab:
// vim:set shiftwidth=4 softtabstop=4 expandtab:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment