cursor ai garbage tuning
This commit is contained in:
parent
07296e74cb
commit
b88f0b7151
|
@ -1,4 +1,6 @@
|
||||||
#import "FrameUpdater.h"
|
#import "FrameUpdater.h"
|
||||||
|
#import <CoreGraphics/CoreGraphics.h>
|
||||||
|
#import <QuartzCore/QuartzCore.h>
|
||||||
|
|
||||||
@implementation FrameUpdater {
|
@implementation FrameUpdater {
|
||||||
|
|
||||||
|
@ -7,6 +9,7 @@
|
||||||
BOOL _updatingFrames;
|
BOOL _updatingFrames;
|
||||||
uint32_t _lastUpdatedSeed;
|
uint32_t _lastUpdatedSeed;
|
||||||
NSTimer* _updateFrameTimer;
|
NSTimer* _updateFrameTimer;
|
||||||
|
CADisplayLink *_displayLink;
|
||||||
|
|
||||||
// Shared from ScreenDumpVNC
|
// Shared from ScreenDumpVNC
|
||||||
IOSurfaceRef _screenSurface;
|
IOSurfaceRef _screenSurface;
|
||||||
|
@ -36,41 +39,49 @@
|
||||||
|
|
||||||
|
|
||||||
-(void)_updateFrame {
|
-(void)_updateFrame {
|
||||||
|
[_q addOperationWithBlock: ^{
|
||||||
if (!_updatingFrames) {
|
if (!_updatingFrames) {
|
||||||
[self stopFrameLoop];
|
[self stopFrameLoop];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Check if screen changed
|
||||||
// check if screen changed
|
|
||||||
uint32_t currentFrameSeed = IOSurfaceGetSeed(_screenSurface);
|
uint32_t currentFrameSeed = IOSurfaceGetSeed(_screenSurface);
|
||||||
|
|
||||||
|
// Only proceed if the screen has changed and the VNC is active
|
||||||
if (_lastUpdatedSeed != currentFrameSeed && rfbIsActive(_rfbScreenInfo)) {
|
if (_lastUpdatedSeed != currentFrameSeed && rfbIsActive(_rfbScreenInfo)) {
|
||||||
_lastUpdatedSeed = currentFrameSeed;
|
_lastUpdatedSeed = currentFrameSeed;
|
||||||
[_q addOperationWithBlock: ^{
|
|
||||||
|
// Optimize the transfer by checking if the accelerator is available
|
||||||
|
if (_accelerator) {
|
||||||
IOSurfaceAcceleratorTransferSurface(_accelerator, _screenSurface, _staticBuffer, NULL, NULL, NULL, NULL);
|
IOSurfaceAcceleratorTransferSurface(_accelerator, _screenSurface, _staticBuffer, NULL, NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark the entire screen as modified only if necessary
|
||||||
|
if (_width > 0 && _height > 0) {
|
||||||
rfbMarkRectAsModified(_rfbScreenInfo, 0, 0, _width, _height);
|
rfbMarkRectAsModified(_rfbScreenInfo, 0, 0, _width, _height);
|
||||||
|
}
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
-(void)stopFrameLoop {
|
|
||||||
if (_updateFrameTimer == nil || ![_updateFrameTimer isValid]) return;
|
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^(void){
|
|
||||||
[_updateFrameTimer invalidate];
|
|
||||||
_updatingFrames = NO;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)startFrameLoop {
|
-(void)startFrameLoop {
|
||||||
// if (size_image == 0) VNCSetup();
|
|
||||||
[self stopFrameLoop];
|
[self stopFrameLoop];
|
||||||
_updatingFrames = YES;
|
_updatingFrames = YES;
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^(void){
|
dispatch_async(dispatch_get_main_queue(), ^(void){
|
||||||
_updateFrameTimer = [NSTimer scheduledTimerWithTimeInterval:1/400 target:self selector:@selector(_updateFrame) userInfo:nil repeats:YES];
|
_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_updateFrame)];
|
||||||
|
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)stopFrameLoop {
|
||||||
|
if (_displayLink) {
|
||||||
|
[_displayLink invalidate];
|
||||||
|
_displayLink = nil;
|
||||||
|
}
|
||||||
|
_updatingFrames = NO;
|
||||||
|
}
|
||||||
|
|
||||||
-(void)dealloc {
|
-(void)dealloc {
|
||||||
[self stopFrameLoop];
|
[self stopFrameLoop];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue