Questions tagged [cadisplaylink]

A CADisplayLink object is a timer object that allows your application to synchronize its drawing to the refresh rate of the display.

137 questions
42
votes
2 answers

How to create the effect of a circular object entering and separating from a thick substance

Based on the image below (I used different colours for circle and flat surface so they can be seen, but in the end the colours will be the same), using Swift and Spritekit, I am trying to create the effect of a circular object entering a thick…
NSologistic
  • 745
  • 4
  • 14
34
votes
2 answers

Cocoa drawing on different screens loses performance

I have a document-based app, where each document has one window with an NSScrollView that does some (fairly continuous) drawing using only Cocoa. To call the drawing, I am using a CVDisplayLink, outlined in the code below: -…
spudwaffle
  • 2,905
  • 1
  • 22
  • 29
23
votes
2 answers

Best way to mirror a UIWebView

I need to mirror a UIWebView's CALayers to a smaller CALayer. The smaller CALayer is essentially a pip of the larger UIWebView. I'm having difficulty in doing this. The only thing that comes close is CAReplicatorLayer, but given the original and the…
Luke
  • 13,678
  • 7
  • 45
  • 79
21
votes
3 answers

Correct handling / cleanup / etc of CADisplayLink in Swift custom animation?

Consider this trivial sync animation using CADisplayLink, var link:CADisplayLink? var startTime:Double = 0.0 let animTime:Double = 0.2 let animMaxVal:CGFloat = 0.4 private func yourAnim() { if ( link != nil ) { link!.paused…
Fattie
  • 27,874
  • 70
  • 431
  • 719
17
votes
1 answer

Animating a circular UIBezierPath

I've got a project where I'm animating a UIBezierPath based on a set progress. The BezierPath is in the shape of a circle and lies in a UIView and animation is done in drawRect using CADisplayLink right now. Simply put, based on a set progress x the…
hav
  • 373
  • 5
  • 10
16
votes
6 answers

How to correctly stop and resume a CADisplayLink?

I figured out a big problem with CADisplayLink. I have the most basic EAGLLayer with OpenGL ES 1.1 drawing a rotating triangle for testing. This needs a run loop method to be called at screen refresh rate, so I start the runloop like this: -…
dontWatchMyProfile
  • 45,440
  • 50
  • 177
  • 260
16
votes
1 answer

Why does UIScrollView pause my CADisplayLink?

I have a view backed by a CAEAGLLayer, which is inside a UIScrollView. When I begin scrolling, the CADisplayLink that calls the -draw method of openGL view stops getting called. I verified that my runloop start / stop methods don't get called when…
Proud Member
  • 40,078
  • 47
  • 146
  • 231
11
votes
2 answers

How many ways to calculate the FPS (Frames per second) of an iOS App programmatically?

Since we are talking about programmatically, Instruments are not under my consideration. Some reference listed in advance: Calculate fps (frames per second) for iphone app Display FPS on iOS onscreen (without Instruments) At what framerate does the…
Jason Lee
  • 3,200
  • 1
  • 34
  • 71
10
votes
2 answers

What is the android relevant of CADisplayLink(iOS) or CompositionTarget(WP)

I need to update my animations per frame, on iOS I have CADisplayLink, on WinPhone I have CompositionTarget, but how do I do that on Android? Currently I'm using a Timer alongside a Handler, but I believe there is a way to sync the callback with the…
horeaper
  • 361
  • 1
  • 16
9
votes
2 answers

CADisplayLink target selector being triggered after it is invalidated

I have a CADisplayLink that triggers a draw method in a Director object. I want to invalidate the CADisplayLink and then deallocate some singleton Cache objects that are used by the Director object. The singleton Cache objects are not retained by…
Ricardo Sanchez-Saez
  • 9,466
  • 8
  • 53
  • 92
8
votes
2 answers

Definitively, do you have to invalidate() a CADisplayLink when the controller disappears?

Say you have an everyday CADisplayLink class Test: UIViewController { private var _ca : CADisplayLink? @IBAction func frames() { _ca?.invalidate() _ca = nil _ca = CADisplayLink( target: self, …
Fattie
  • 27,874
  • 70
  • 431
  • 719
8
votes
0 answers

CADisplayLink and drawRect

I need help to better understand how CADisplayLink and drawRect behave, so that I can figure out how to keep my app's framerate at a smooth 60fps. My (presumably incorrect) understanding so far is the following: 1) CADisplayLink calls a specified…
deltacrux
  • 1,186
  • 11
  • 18
6
votes
2 answers

Memory usage keeps rising on older devices using Metal

I use Metal and CADisplayLink to live filter a CIImage and render it into a MTKView. // Starting display link displayLink = CADisplayLink(target: self, selector: #selector(applyAnimatedFilter)) displayLink.preferredFramesPerSecond =…
SmartTree
  • 1,381
  • 3
  • 21
  • 40
6
votes
2 answers

Format realtime stopwatch timer to the hundredth using Swift

I have an app using an NSTimer at centisecond (0.01 second) update intervals to display a running stopwatch in String Format as 00:00.00 (mm:ss.SS). (Basically cloning the iOS built-in stopwatch to integrate into realtime sports timing math…
mothy
  • 147
  • 2
  • 8
6
votes
0 answers

Multiple CADisplayLink's or as few as possible?

Example I have a UIView which simply draws a custom spinner using CoreGraphics. It is updating itself using CADisplayLink so it can draw each frame. Another UIView subclass draws a progress-bar also using CoreGraphics. It is also updating itself…
hfossli
  • 22,616
  • 10
  • 116
  • 130
1
2 3
9 10