diff --git a/graf2d/cocoa/inc/ROOTOpenGLView.h b/graf2d/cocoa/inc/ROOTOpenGLView.h
index 3d72fb3ee33bfaca79313c022eb6a3df8cbac7b3..21e055bbf5fea7d3ea1fa9a5384aa60cfc12e1d6 100644
--- a/graf2d/cocoa/inc/ROOTOpenGLView.h
+++ b/graf2d/cocoa/inc/ROOTOpenGLView.h
@@ -22,7 +22,11 @@
 //                                       //
 ///////////////////////////////////////////
 
-@interface ROOTOpenGLView : QuartzView
+@interface ROOTOpenGLView : QuartzView {
+@private
+   NSOpenGLPixelFormat *fPixelFormat;
+   BOOL fUpdateContext;
+}
 
 - (id) initWithFrame : (NSRect) frameRect pixelFormat : (NSOpenGLPixelFormat *) format;
 
diff --git a/graf2d/cocoa/src/ROOTOpenGLView.mm b/graf2d/cocoa/src/ROOTOpenGLView.mm
index b787534e88e1b6808f877660eaf17d688217e56c..63c4b1468f03c718ea8fb68f891965589e833d09 100644
--- a/graf2d/cocoa/src/ROOTOpenGLView.mm
+++ b/graf2d/cocoa/src/ROOTOpenGLView.mm
@@ -43,12 +43,7 @@ bool GLViewIsValidDrawable(ROOTOpenGLView *glView)
 }
 }
 
-@implementation ROOTOpenGLView {
-   BOOL            fIsOverlapped;
-
-   NSOpenGLPixelFormat *fPixelFormat;
-   BOOL fUpdateContext;
-}
+@implementation ROOTOpenGLView
 
 @synthesize fOpenGLContext;
 @synthesize fUpdateContext;
diff --git a/graf2d/quartz/src/QuartzFillArea.mm b/graf2d/quartz/src/QuartzFillArea.mm
index 73fe2f7d487e969e8144cf00711fdb6c7c6a4821..15b86cb271f20682fb0e25d596c45dab3b3d1d69 100644
--- a/graf2d/quartz/src/QuartzFillArea.mm
+++ b/graf2d/quartz/src/QuartzFillArea.mm
@@ -35,11 +35,50 @@ namespace {
 const CGSize shadowOffset = CGSizeMake(10., 10.);
 const CGFloat shadowBlur = 5.;
 
-
 //ROOT has TColorGradient, TLinearGradient and TRadialGradient -
 //they all specify parameters in NDC. But for rendering with
 //Quartz I need more specific parameters, I calculate them here.
 
+// GradientFactory deals with CGFloat being either float or double.
+template<class SRC, class DST>
+struct GradientFactory {
+   static CGGradientRef CreateGradient(CGColorSpaceRef colorSpace,
+                                       const TColorGradient *extendedColor)
+   {
+      assert(colorSpace != nullptr &&
+             "GradientHelper::CreateGradient, parameter 'colorSpace' is null");
+      assert(extendedColor != nullptr &&
+             "GradientHelper::CreateGradient, parameter 'extendedColor' is null");
+      SRC compStart = extendedColor->GetColors();
+      SRC compEnd = compStart + extendedColor->GetNumberOfSteps() * 4;//TODO: this assumes RGBA.
+      const std::vector<DST> convertedComponents(compStart, compEnd);
+      SRC posStart = extendedColor->GetColorPositions();
+      SRC posEnd = posStart + extendedColor->GetNumberOfSteps();
+      const std::vector<DST> convertedPositions(posStart, posEnd);
+
+      return CGGradientCreateWithColorComponents(colorSpace,
+                                                 &convertedComponents[0],
+                                                 &convertedPositions[0],
+                                                 extendedColor->GetNumberOfSteps());
+   }
+};
+
+template<class DST>
+struct GradientFactory<DST, DST> {
+   static CGGradientRef CreateGradient(CGColorSpaceRef colorSpace,
+                                       const TColorGradient *extendedColor)
+   {
+      assert(colorSpace != nullptr &&
+             "GradientHelper::CreateGradient, parameter 'colorSpace' is null");
+      assert(extendedColor != nullptr &&
+             "GradientHelper::CreateGradient, parameter 'extendedColor' is null");
+      return CGGradientCreateWithColorComponents(colorSpace,
+                                                 extendedColor->GetColors(),
+                                                 extendedColor->GetColorPositions(),
+                                                 extendedColor->GetNumberOfSteps());
+   }
+};
+
 struct GradientParameters {
    //
    CGPoint fStartPoint;
@@ -468,11 +507,8 @@ void DrawPolygonWithGradientFill(CGContextRef ctx, const TColorGradient *extende
       return;
    }
 
-   const CFScopeGuard<CGGradientRef> gradient(CGGradientCreateWithColorComponents(baseSpace.Get(),
-                                              extendedColor->GetColors(),
-                                              extendedColor->GetColorPositions(),
-                                              extendedColor->GetNumberOfSteps()));
-
+   typedef GradientFactory<Double_t, CGFloat> Factory;
+   const CFScopeGuard<CGGradientRef> gradient(Factory::CreateGradient(baseSpace.Get(), extendedColor));
    if (!gradient.Get()) {
       ::Error("DrawPolygonWithGradientFill", "CGGradientCreateWithColorComponents failed");
       return;