Bug 821304 - Unbreak plugins that use subclasses of CALayer in CoreAnimation mode. r=bgirard a=akeybl
authorSteven Michaud <smichaud@pobox.com>
Fri, 21 Dec 2012 12:47:43 -0600
changeset 117780 b65e7e4f1aa4cacba02edf7880c6772adc50c35d
parent 117779 d169db669f311fbabe8cc3bc9aad4f9a4ace1052
child 117781 931590387ec90a1fa4e5a92ad31986504b267fd9
push id75
push userdbaron@mozilla.com
push dateSat, 22 Dec 2012 00:41:31 +0000
reviewersbgirard, akeybl
bugs821304
milestone18.0
Bug 821304 - Unbreak plugins that use subclasses of CALayer in CoreAnimation mode. r=bgirard a=akeybl
gfx/2d/QuartzSupport.mm
--- a/gfx/2d/QuartzSupport.mm
+++ b/gfx/2d/QuartzSupport.mm
@@ -726,38 +726,49 @@ void nsCARenderer::SetBounds(int aWidth,
   if (mContentsScaleFactor != 1.0) {
     CGAffineTransform affineTransform = [layer affineTransform];
     affineTransform.a = mContentsScaleFactor;
     affineTransform.d = mContentsScaleFactor;
     affineTransform.tx = ((double)aWidth)/mContentsScaleFactor;
     affineTransform.ty = ((double)aHeight)/mContentsScaleFactor;
     [layer setAffineTransform:affineTransform];
     if ([layer respondsToSelector:@selector(setContentsScale:)]) {
-      // For reasons that aren't clear (perhaps one or more OS bugs), OOP
-      // Core Graphics plugins (ones that use CGBridgeLayer) can only use
-      // HiDPI mode if the tree is built with the 10.7 SDK or up.
+      // For reasons that aren't clear (perhaps one or more OS bugs), if layer
+      // belongs to a subclass of CALayer we can only use full HiDPI resolution
+      // here if the tree is built with the 10.7 SDK or up:  If we change
+      // layer.contentsScale (even to the same value), layer simply stops
+      // working (goes blank).  And even if we're building with the 10.7 SDK,
+      // we can't use full HiDPI resolution if layer belongs to CAOpenGLLayer
+      // or a subclass:  Changing layer.contentsScale to values higher than
+      // 1.0 makes it display only in the lower left part of its "box".
+      // We use CGBridgeLayer (a subclass of CALayer) to implement CoreGraphics
+      // mode for OOP plugins.  Shockwave uses a subclass of CAOpenGLLayer
+      // (SWRenderer) to implement CoreAnimation mode.  The SlingPlayer plugin
+      // uses another subclass of CAOpenGLLayer (CoreAnimationLayer).
 #if !defined(MAC_OS_X_VERSION_10_7) || \
     MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
-      Class CGBridgeLayerClass = ::NSClassFromString(@"CGBridgeLayer");
-      if (!CGBridgeLayerClass || ![layer isKindOfClass:CGBridgeLayerClass])
+      if ([layer isMemberOfClass:[CALayer class]])
+#else
+      if (![layer isKindOfClass:[CAOpenGLLayer class]])
 #endif
       {
         layer.contentsScale = mContentsScaleFactor;
       }
     }
   } else {
     // These settings are the default values.  But they might have been
     // changed as above if we were previously running in a HiDPI mode
     // (i.e. if we just switched from that to a non-HiDPI mode).
     [layer setAffineTransform:CGAffineTransformIdentity];
     if ([layer respondsToSelector:@selector(setContentsScale:)]) {
 #if !defined(MAC_OS_X_VERSION_10_7) || \
     MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
-      Class CGBridgeLayerClass = ::NSClassFromString(@"CGBridgeLayer");
-      if (!CGBridgeLayerClass || ![layer isKindOfClass:CGBridgeLayerClass])
+      if ([layer isMemberOfClass:[CALayer class]])
+#else
+      if (![layer isKindOfClass:[CAOpenGLLayer class]])
 #endif
       {
         layer.contentsScale = 1.0;
       }
     }
   }
   [CATransaction commit];