@@ -623,10 +623,9 @@ - (void)display {
623623 CGContextTranslateCTM (drawContext, 0 , float (target->Backing ()->Height ()));
624624 }
625625 if (priv->contentsScale != 1 .0f ) {
626- CGContextScaleCTM (drawContext, priv->contentsScale , priv->contentsScale );
627-
628626 // TODO 1077:: Remove once D2D render target is implemented
629627 _CGContextSetScaleFactor (drawContext, priv->contentsScale );
628+ CGContextScaleCTM (drawContext, priv->contentsScale , priv->contentsScale );
630629 }
631630
632631 CGContextScaleCTM (drawContext, 1 .0f , -1 .0f );
@@ -2133,11 +2132,11 @@ - (BOOL)containsPoint:(CGPoint)point {
21332132- (void )dealloc {
21342133 if (DEBUG_VERBOSE) {
21352134 TraceVerbose (TAG,
2136- L" CALayer dealloc: (%hs - 0x%p, %hs - 0x%p)." ,
2137- object_getClassName (self),
2138- self,
2139- priv->delegate ? object_getClassName (priv->delegate ) : " nil" ,
2140- priv->delegate );
2135+ L" CALayer dealloc: (%hs - 0x%p, %hs - 0x%p)." ,
2136+ object_getClassName (self),
2137+ self,
2138+ priv->delegate ? object_getClassName (priv->delegate ) : " nil" ,
2139+ priv->delegate );
21412140 }
21422141
21432142 [self removeAllAnimations ];
@@ -2400,63 +2399,58 @@ - (void)_displayChanged {
24002399 // ////////////////////////////////////////////////////////////////////////////////////////////
24012400 // TODO: Switch to ARC
24022401 // We don't want to do display updates on an object that's currently deallocating.
2403- // In order to ensure that we're not mid-deallocation during the display update,
2402+ // In order to ensure that we're not mid-deallocation during the display update,
24042403 // we create a weak reference here, and then *immediately* acquire a strong reference to it.
24052404 // If that succeeds, we're guaranteed to not dealloc until after the block executes.
2406-
2405+
24072406 // Store a weak reference - this will fail if we're already deallocating
24082407 id weakSuperLayer = nil ;
24092408 objc_storeWeak (&weakSuperLayer, superLayer);
2410-
2409+
24112410 // Grab a strong reference that we can pass into the block - this will fail if we're already deallocating
24122411 auto strongSuperLayer = reinterpret_cast <CALayer *>(objc_loadWeakRetained (&weakSuperLayer));
2413-
2412+
24142413 // We need to make sure the retain we just performed above is released *after* we construct the block
2415- auto releaseSuperLayer = wil::ScopeExit ([&strongSuperLayer]() {
2416- objc_release (strongSuperLayer);
2417- });
2414+ auto releaseSuperLayer = wil::ScopeExit ([&strongSuperLayer]() { objc_release (strongSuperLayer); });
24182415
24192416 // The weak reference is no longer needed, so clean up after ourselves
24202417 objc_destroyWeak (&weakSuperLayer);
24212418
24222419 // Grab a raw pointer (so it's not block-retained) - for logging purposes (if needed)
24232420 void * rawSuperLayerForLog = reinterpret_cast <void *>(superLayer);
24242421
2425- dispatch_async (
2426- dispatch_get_main_queue (),
2427- ^{
2428- // If we have a valid non-dealloc'd object, run its display update pass
2429- if (strongSuperLayer) {
2430- // Only run the update pass for this superLayer if it's a 'root layer' - aka a UIWindow layer,
2431- // or if we're running as a framework - aka for middleware scenarios - where the layer won't have
2432- // a 'root' superlayer.
2433- if (strongSuperLayer->priv ->isRootLayer || GetCACompositor ()->IsRunningAsFramework ()) {
2434- strongSuperLayer->priv ->_displayPending = false ;
2435-
2436- if (DEBUG_VERBOSE) {
2437- TraceVerbose (
2438- TAG,
2439- L" Performing _displayChanged work for superlayer (%hs - 0x%p, %hs - 0x%p)." ,
2440- object_getClassName (strongSuperLayer),
2441- strongSuperLayer,
2442- strongSuperLayer->priv ->delegate ? object_getClassName (strongSuperLayer->priv ->delegate ) : " nil" ,
2443- strongSuperLayer->priv ->delegate );
2444- }
2445-
2446- // Recalculate layouts
2447- DoLayerLayouts (strongSuperLayer, true );
2448-
2449- // Redisplay anything necessary
2450- DoDisplayList (strongSuperLayer);
2422+ dispatch_async (dispatch_get_main_queue (), ^{
2423+ // If we have a valid non-dealloc'd object, run its display update pass
2424+ if (strongSuperLayer) {
2425+ // Only run the update pass for this superLayer if it's a 'root layer' - aka a UIWindow layer,
2426+ // or if we're running as a framework - aka for middleware scenarios - where the layer won't have
2427+ // a 'root' superlayer.
2428+ if (strongSuperLayer->priv ->isRootLayer || GetCACompositor ()->IsRunningAsFramework ()) {
2429+ strongSuperLayer->priv ->_displayPending = false ;
2430+
2431+ if (DEBUG_VERBOSE) {
2432+ TraceVerbose (TAG,
2433+ L" Performing _displayChanged work for superlayer (%hs - 0x%p, %hs - 0x%p)." ,
2434+ object_getClassName (strongSuperLayer),
2435+ strongSuperLayer,
2436+ strongSuperLayer->priv ->delegate ? object_getClassName (strongSuperLayer->priv ->delegate ) : " nil" ,
2437+ strongSuperLayer->priv ->delegate );
24512438 }
2452- } else if (DEBUG_VERBOSE) {
2453- TraceVerbose (TAG, L" Skipping _displayChanged work for currently-dealloc'd object (0x%p)." , rawSuperLayerForLog);
2439+
2440+ // Recalculate layouts
2441+ DoLayerLayouts (strongSuperLayer, true );
2442+
2443+ // Redisplay anything necessary
2444+ DoDisplayList (strongSuperLayer);
24542445 }
2446+ } else if (DEBUG_VERBOSE) {
2447+ TraceVerbose (TAG, L" Skipping _displayChanged work for currently-dealloc'd object (0x%p)." , rawSuperLayerForLog);
2448+ }
24552449
2456- // Always commit and process all queued CATransactions
2457- [CATransaction _commitRootQueue ];
2458- GetCACompositor ()->ProcessTransactions ();
2459- });
2450+ // Always commit and process all queued CATransactions
2451+ [CATransaction _commitRootQueue ];
2452+ GetCACompositor ()->ProcessTransactions ();
2453+ });
24602454 }
24612455}
24622456
@@ -2592,7 +2586,7 @@ + (CGPoint)convertPoint:(CGPoint)point fromLayer:(CALayer*)fromLayer toLayer:(CA
25922586 }
25932587
25942588 if (DEBUG_VERBOSE) {
2595- TraceVerbose (TAG, L" convertPoint: {%f, %f} to {%f, %f}" , point.x , point.y , ret.x , ret.y );
2589+ TraceVerbose (TAG, L" convertPoint: {%f, %f} to {%f, %f}" , point.x , point.y , ret.x , ret.y );
25962590 }
25972591
25982592 return ret;
0 commit comments