1/* 2 * Copyright 2020 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8#ifndef SkCGGeometry_DEFINED 9#define SkCGGeometry_DEFINED 10 11#include "include/core/SkTypes.h" 12#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) 13 14#ifdef SK_BUILD_FOR_MAC 15#import <ApplicationServices/ApplicationServices.h> 16#endif 17 18#ifdef SK_BUILD_FOR_IOS 19#include <CoreGraphics/CoreGraphics.h> 20#endif 21 22// Skia extensions for types in CGGeometry.h 23 24// Inline versions of these CGRect helpers. 25// The CG versions require making a call and a copy of the CGRect on the stack. 26 27static inline bool SkCGRectIsEmpty(const CGRect& rect) { 28 return rect.size.width <= 0 || rect.size.height <= 0; 29} 30 31static inline CGFloat SkCGRectGetMinX(const CGRect& rect) { 32 return rect.origin.x; 33} 34 35static inline CGFloat SkCGRectGetMaxX(const CGRect& rect) { 36 return rect.origin.x + rect.size.width; 37} 38 39static inline CGFloat SkCGRectGetMinY(const CGRect& rect) { 40 return rect.origin.y; 41} 42 43static inline CGFloat SkCGRectGetMaxY(const CGRect& rect) { 44 return rect.origin.y + rect.size.height; 45} 46 47static inline CGFloat SkCGRectGetWidth(const CGRect& rect) { 48 return rect.size.width; 49} 50 51#endif 52#endif //SkCGGeometry_DEFINED 53