Skip to content
Snippets Groups Projects
Commit d8a9d8cc authored by Timur Pocheptsov's avatar Timur Pocheptsov
Browse files

QuartzFillArea/ROOTOpenGLView - fix for 32-bit build

CGGradientCreateWithColorComponents accepts CGFloat as parameter,
which can be either double or float. TGColorGradient works with Double_t.
Make it work with CGFloat == float.
parent 597da14a
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,11 @@
// //
///////////////////////////////////////////
@interface ROOTOpenGLView : QuartzView
@interface ROOTOpenGLView : QuartzView {
@private
NSOpenGLPixelFormat *fPixelFormat;
BOOL fUpdateContext;
}
- (id) initWithFrame : (NSRect) frameRect pixelFormat : (NSOpenGLPixelFormat *) format;
......
......@@ -43,12 +43,7 @@ bool GLViewIsValidDrawable(ROOTOpenGLView *glView)
}
}
@implementation ROOTOpenGLView {
BOOL fIsOverlapped;
NSOpenGLPixelFormat *fPixelFormat;
BOOL fUpdateContext;
}
@implementation ROOTOpenGLView
@synthesize fOpenGLContext;
@synthesize fUpdateContext;
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment