forked from FelixKratz/JankyBorders
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
92 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "animation.h" | ||
|
||
void animation_init(struct animation* animation) { | ||
memset(animation, 0, sizeof(struct animation)); | ||
} | ||
|
||
void animation_start(struct animation* animation, void* proc, void* context) { | ||
assert(animation->link == NULL); | ||
assert(animation->context == NULL); | ||
CVDisplayLinkCreateWithActiveCGDisplays(&animation->link); | ||
CVTime refresh_period | ||
= CVDisplayLinkGetNominalOutputVideoRefreshPeriod(animation->link); | ||
animation->frame_time = 1e6 * (double)refresh_period.timeValue | ||
/ (double)refresh_period.timeScale; | ||
|
||
animation->context = context; | ||
CVDisplayLinkSetOutputCallback(animation->link, proc, animation); | ||
CVDisplayLinkStart(animation->link); | ||
} | ||
|
||
void animation_stop(struct animation* animation) { | ||
if (animation->link) { | ||
CVDisplayLinkStop(animation->link); | ||
CVDisplayLinkRelease(animation->link); | ||
animation->link = NULL; | ||
} | ||
if (animation->context) free(animation->context); | ||
animation->context = NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
#include <CoreVideo/CoreVideo.h> | ||
#include <pthread.h> | ||
|
||
struct animation { | ||
void* context; | ||
double frame_time; | ||
CVDisplayLinkRef link; | ||
}; | ||
|
||
void animation_init(struct animation* animation); | ||
void animation_start(struct animation* animation, void* proc, void* context); | ||
void animation_stop(struct animation* animation); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters