@@ -3,18 +3,18 @@ use crate::backend_interface::*;
3
3
use crate :: error:: InitError ;
4
4
use crate :: { Rect , SoftBufferError } ;
5
5
use objc2:: rc:: Retained ;
6
- use objc2:: runtime:: { AnyObject , Bool } ;
6
+ use objc2:: runtime:: { AnyObject , Bool , ProtocolObject } ;
7
7
use objc2:: { define_class, msg_send, AllocAnyThread , DefinedClass , MainThreadMarker , Message } ;
8
8
use objc2_core_foundation:: { CFRetained , CGPoint } ;
9
9
use objc2_core_graphics:: {
10
10
CGBitmapInfo , CGColorRenderingIntent , CGColorSpace , CGDataProvider , CGImage , CGImageAlphaInfo ,
11
11
} ;
12
12
use objc2_foundation:: {
13
13
ns_string, NSDictionary , NSKeyValueChangeKey , NSKeyValueChangeNewKey ,
14
- NSKeyValueObservingOptions , NSNumber , NSObject , NSObjectNSKeyValueObserverRegistration ,
14
+ NSKeyValueObservingOptions , NSNull , NSNumber , NSObject , NSObjectNSKeyValueObserverRegistration ,
15
15
NSString , NSValue ,
16
16
} ;
17
- use objc2_quartz_core:: { kCAGravityTopLeft, CALayer , CATransaction } ;
17
+ use objc2_quartz_core:: { kCAGravityTopLeft, CALayer } ;
18
18
use raw_window_handle:: { HasDisplayHandle , HasWindowHandle , RawWindowHandle } ;
19
19
20
20
use std:: ffi:: c_void;
@@ -222,6 +222,17 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for CGImpl<
222
222
// resized to something that doesn't fit, see #177.
223
223
layer. setContentsGravity ( unsafe { kCAGravityTopLeft } ) ;
224
224
225
+ // The CALayer has a default action associated with a change in the layer contents, causing
226
+ // a quarter second fade transition to happen every time a new buffer is applied.
227
+ //
228
+ // We avoid this by setting the action for the "contents" key to NULL.
229
+ //
230
+ // TODO(madsmtm): Do we want to do the same for bounds/contentsScale for smoother resizing?
231
+ layer. setActions ( Some ( & NSDictionary :: from_slices (
232
+ & [ ns_string ! ( "contents" ) ] ,
233
+ & [ ProtocolObject :: from_ref ( & * unsafe { NSNull :: null ( ) } ) ] ,
234
+ ) ) ) ;
235
+
225
236
// Initialize color space here, to reduce work later on.
226
237
let color_space = unsafe { CGColorSpace :: new_device_rgb ( ) } . unwrap ( ) ;
227
238
@@ -326,16 +337,9 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl<'_,
326
337
}
327
338
. unwrap ( ) ;
328
339
329
- // The CALayer has a default action associated with a change in the layer contents, causing
330
- // a quarter second fade transition to happen every time a new buffer is applied. This can
331
- // be avoided by wrapping the operation in a transaction and disabling all actions.
332
- CATransaction :: begin ( ) ;
333
- CATransaction :: setDisableActions ( true ) ;
334
-
335
340
// SAFETY: The contents is `CGImage`, which is a valid class for `contents`.
336
341
unsafe { self . imp . layer . setContents ( Some ( image. as_ref ( ) ) ) } ;
337
342
338
- CATransaction :: commit ( ) ;
339
343
Ok ( ( ) )
340
344
}
341
345
0 commit comments