Merge pull request #59 from thedjinn/disable-calayer-actions
Disable CALayer fade action when setting buffers
This commit is contained in:
commit
c0142e9faf
2 changed files with 110 additions and 1 deletions
11
src/cg.rs
11
src/cg.rs
|
|
@ -9,7 +9,7 @@ use raw_window_handle::AppKitWindowHandle;
|
|||
|
||||
use cocoa::appkit::{NSView, NSViewHeightSizable, NSViewWidthSizable, NSWindow};
|
||||
use cocoa::base::{id, nil};
|
||||
use cocoa::quartzcore::{CALayer, ContentsGravity};
|
||||
use cocoa::quartzcore::{transaction, CALayer, ContentsGravity};
|
||||
use foreign_types::ForeignType;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
|
@ -55,6 +55,15 @@ impl CGImpl {
|
|||
false,
|
||||
kCGRenderingIntentDefault,
|
||||
);
|
||||
|
||||
// The CALayer has a default action associated with a change in the layer contents, causing
|
||||
// a quarter second fade transition to happen every time a new buffer is applied. This can
|
||||
// be mitigated by wrapping the operation in a transaction and disabling all actions.
|
||||
transaction::begin();
|
||||
transaction::set_disable_actions(true);
|
||||
|
||||
unsafe { self.layer.set_contents(image.as_ptr() as id) };
|
||||
|
||||
transaction::commit();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue