<commit_before>// @(#)root/graf2d:$Id$
// Author: <NAME>   16/02/2012

/*************************************************************************
 * Copyright (C) 1995-2012, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/


#ifndef ROOT_QuartzPixmap
#define ROOT_QuartzPixmap

#include <Cocoa/Cocoa.h>

#ifndef ROOT_CocoaGuiTypes
#include "CocoaGuiTypes.h"
#endif
#ifndef ROOT_X11Drawable
#include "X11Drawable.h"
#endif
#ifndef ROOT_GuiTypes
#include "GuiTypes.h"
#endif

///////////////////////////////////////////////////////
//                                                   //
// "Pixmap". Graphical context to draw into image.   //
//                                                   //
///////////////////////////////////////////////////////

@interface QuartzPixmap : NSObject<X11Drawable> {
@private
   unsigned       fWidth;
   unsigned       fHeight;
   // TODO: std::vector can be an i-var in Objective-C++,
   // this will simplify and clear the error handling and
   // memory management.
   unsigned char *fData;
   CGContextRef   fContext;

   unsigned       fScaleFactor;
}

- (id) initWithW : (unsigned) width H : (unsigned) height scaleFactor : (CGFloat) scaleFactor;
- (BOOL) resizeW : (unsigned) width H : (unsigned) height scaleFactor : (CGFloat) scaleFactor;

- (CGImageRef) createImageFromPixmap;
- (CGImageRef) createImageFromPixmap : (ROOT::MacOSX::X11::Rectangle) cropArea;

//X11Drawable protocol.

@property (nonatomic, assign) unsigned fID;

- (BOOL) fIsPixmap;
- (BOOL) fIsOpenGLWidget;

@property (nonatomic, readonly) CGContextRef fContext;

- (unsigned) fWidth;
- (unsigned) fHeight;

- (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *) mask
         clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;

- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;

//
- (unsigned char *) fData;

//XPutPixel.
- (void) putPixel : (const unsigned char *) data X : (unsigned) x Y : (unsigned) y;
//XAddPixel.
- (void) addPixel : (const unsigned char *) rgb;

@end

/////////////////////////////////////////////////////////
//                                                     //
// CGImageRef, created from external data source (raw  //
// data)                                               //
//                                                     //
/////////////////////////////////////////////////////////

//TODO: split image and mask image?

@interface QuartzImage : NSObject<X11Drawable> {
   unsigned       fWidth;
   unsigned       fHeight;
   CGImageRef     fImage;
   // TODO: replace with std::vector i-var.
   unsigned char *fImageData;
}

- (id) initWithW : (unsigned) width H : (unsigned) height data : (unsigned char *) data;
- (id) initMaskWithW : (unsigned) width H : (unsigned) height bitmapMask : (unsigned char *) mask;
- (id) initMaskWithW : (unsigned) width H : (unsigned) height;
- (id) initFromPixmap : (QuartzPixmap *) pixmap;
- (id) initFromImage : (QuartzImage *) image;
- (id) initFromImageFlipped : (QuartzImage *) image;

- (void) dealloc;
@property (nonatomic, readonly) BOOL fIsStippleMask;
- (CGImageRef) fImage;

//X11Drawable protocol.
@property (nonatomic, assign) unsigned fID;

- (BOOL) fIsPixmap;
- (BOOL) fIsOpenGLWidget;

- (unsigned) fWidth;
- (unsigned) fHeight;

- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;

@end


namespace ROOT {
namespace MacOSX {
namespace X11 {

CGImageRef CreateSubImage(QuartzImage *image, const Rectangle &area);
//
bool AdjustCropArea(const Rectangle &srcRect, Rectangle &cropArea);
bool AdjustCropArea(QuartzImage *srcImage, Rectangle &cropArea);
bool AdjustCropArea(QuartzImage *srcImage, NSRect &cropArea);
bool AdjustCropArea(QuartzPixmap *srcImage, Rectangle &cropArea);

//Aux. function for TGCocoa.
void FillPixmapBuffer(const unsigned char *bitmap, unsigned width, unsigned height, ULong_t foregroundPixel,
                      ULong_t backgroundPixel, unsigned depth, unsigned char *imageData);

}
}
}

#endif
<commit_msg>32-bit obj-C requires explicit i-var for a synthesized property.<commit_after>// @(#)root/graf2d:$Id$
// Author: <NAME>   16/02/2012

/*************************************************************************
 * Copyright (C) 1995-2012, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/


#ifndef ROOT_QuartzPixmap
#define ROOT_QuartzPixmap

#include <Cocoa/Cocoa.h>

#ifndef ROOT_CocoaGuiTypes
#include "CocoaGuiTypes.h"
#endif
#ifndef ROOT_X11Drawable
#include "X11Drawable.h"
#endif
#ifndef ROOT_GuiTypes
#include "GuiTypes.h"
#endif

///////////////////////////////////////////////////////
//                                                   //
// "Pixmap". Graphical context to draw into image.   //
//                                                   //
///////////////////////////////////////////////////////

@interface QuartzPixmap : NSObject<X11Drawable> {
@private
   //32-bit Obj-C requires i-var to be declared (for a synthesized prop.).
   unsigned       fID;
   //

   unsigned       fWidth;
   unsigned       fHeight;
   // TODO: std::vector can be an i-var in Objective-C++,
   // this will simplify and clear the error handling and
   // memory management.
   unsigned char *fData;
   CGContextRef   fContext;

   unsigned       fScaleFactor;
}

- (id) initWithW : (unsigned) width H : (unsigned) height scaleFactor : (CGFloat) scaleFactor;
- (BOOL) resizeW : (unsigned) width H : (unsigned) height scaleFactor : (CGFloat) scaleFactor;

- (CGImageRef) createImageFromPixmap;
- (CGImageRef) createImageFromPixmap : (ROOT::MacOSX::X11::Rectangle) cropArea;

//X11Drawable protocol.

@property (nonatomic, assign) unsigned fID;

- (BOOL) fIsPixmap;
- (BOOL) fIsOpenGLWidget;

@property (nonatomic, readonly) CGContextRef fContext;

- (unsigned) fWidth;
- (unsigned) fHeight;

- (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *) mask
         clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;

- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;

//
- (unsigned char *) fData;

//XPutPixel.
- (void) putPixel : (const unsigned char *) data X : (unsigned) x Y : (unsigned) y;
//XAddPixel.
- (void) addPixel : (const unsigned char *) rgb;

@end

/////////////////////////////////////////////////////////
//                                                     //
// CGImageRef, created from external data source (raw  //
// data)                                               //
//                                                     //
/////////////////////////////////////////////////////////

//TODO: split image and mask image?

@interface QuartzImage : NSObject<X11Drawable> {
@private
   //32-bit Obj-C requires i-var to be declared (for a synthesized prop.).
   BOOL fIsStippleMask;
   unsigned fID;
   //

   unsigned       fWidth;
   unsigned       fHeight;
   CGImageRef     fImage;
   // TODO: replace with std::vector i-var.
   unsigned char *fImageData;
}

- (id) initWithW : (unsigned) width H : (unsigned) height data : (unsigned char *) data;
- (id) initMaskWithW : (unsigned) width H : (unsigned) height bitmapMask : (unsigned char *) mask;
- (id) initMaskWithW : (unsigned) width H : (unsigned) height;
- (id) initFromPixmap : (QuartzPixmap *) pixmap;
- (id) initFromImage : (QuartzImage *) image;
- (id) initFromImageFlipped : (QuartzImage *) image;

- (void) dealloc;
@property (nonatomic, readonly) BOOL fIsStippleMask;
- (CGImageRef) fImage;

//X11Drawable protocol.
@property (nonatomic, assign) unsigned fID;

- (BOOL) fIsPixmap;
- (BOOL) fIsOpenGLWidget;

- (unsigned) fWidth;
- (unsigned) fHeight;

- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;

@end


namespace ROOT {
namespace MacOSX {
namespace X11 {

CGImageRef CreateSubImage(QuartzImage *image, const Rectangle &area);
//
bool AdjustCropArea(const Rectangle &srcRect, Rectangle &cropArea);
bool AdjustCropArea(QuartzImage *srcImage, Rectangle &cropArea);
bool AdjustCropArea(QuartzImage *srcImage, NSRect &cropArea);
bool AdjustCropArea(QuartzPixmap *srcImage, Rectangle &cropArea);

//Aux. function for TGCocoa.
void FillPixmapBuffer(const unsigned char *bitmap, unsigned width, unsigned height, ULong_t foregroundPixel,
                      ULong_t backgroundPixel, unsigned depth, unsigned char *imageData);

}
}
}

#endif

{'fraction_non_alphanumeric': 0.1903829416884247, 'fraction_numerical': 0.010443864229765013, 'mean_word_length': 2.263400780972666, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6321215', 'n_tokens_mistral': 2769, 'n_tokens_neox': 2619, 'n_words': 713}