/ CoreGraphics / CGSRegion.m
CGSRegion.m
1 /* 2 This file is part of Darling. 3 4 Copyright (C) 2020 Lubos Dolezel 5 6 Darling is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 Darling is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #include <CoreGraphics/CoreGraphicsPrivate.h> 20 #import <Foundation/NSObject.h> 21 22 @interface CGSRegion : NSObject { 23 CGRect _rect; 24 } 25 @property CGRect rect; 26 @end 27 28 @implementation CGSRegion 29 @synthesize rect = _rect; 30 @end 31 32 CGError CGSNewRegionWithRect(const CGRect *rect, CGSRegionRef *newRegion) { 33 CGSRegion *reg = [CGSRegion new]; 34 reg.rect = *rect; 35 *newRegion = (CGSRegionRef) reg; 36 return kCGSErrorSuccess; 37 } 38 39 void CGSRegionRelease(CGSRegionRef reg) { 40 CGSRegion *r = (CGSRegion *) reg; 41 [r release]; 42 } 43 44 void CGSRegionRetain(CGSRegionRef reg) { 45 CGSRegion *r = (CGSRegion *) reg; 46 [r retain]; 47 } 48 49 // This is non-standard. We should support non-rectangular regions instead 50 void CGSRegionToRect(CGSRegionRef reg, CGRect *rect) { 51 CGSRegion *r = (CGSRegion *) reg; 52 *rect = r.rect; 53 } 54 55 bool CGSRegionIsRectangular(CGSRegionRef reg) { 56 return TRUE; 57 }