[vlc-commits] macosx: use vlc_safeDrawInBezierPath:angle:
Marvin Scholz
git at videolan.org
Wed Jun 3 16:51:20 CEST 2020
vlc/vlc-3.0 | branch: master | Marvin Scholz <epirat07 at gmail.com> | Wed Jun 3 15:45:48 2020 +0200| [77a6345fa1aa8f77b83be8207449d5a258e44492] | committer: Marvin Scholz
macosx: use vlc_safeDrawInBezierPath:angle:
(cherry picked from commit 6c1786b6e0ff677ec7bff9de47f506443d889765)
Signed-off-by: Marvin Scholz <epirat07 at gmail.com>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=77a6345fa1aa8f77b83be8207449d5a258e44492
---
modules/gui/macosx/VLCBottomBarView.m | 16 +++++++---------
modules/gui/macosx/VLCSliderCell.m | 5 ++---
modules/gui/macosx/VLCVolumeSliderCell.m | 19 +++++++------------
3 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/modules/gui/macosx/VLCBottomBarView.m b/modules/gui/macosx/VLCBottomBarView.m
index 912c355532..f0d97f7cfb 100644
--- a/modules/gui/macosx/VLCBottomBarView.m
+++ b/modules/gui/macosx/VLCBottomBarView.m
@@ -24,6 +24,7 @@
#import "VLCBottomBarView.h"
#import "CompatibilityFixes.h"
+#import "NSGradient+VLCAdditions.h"
@interface VLCBottomBarView () {
NSBezierPath *_rectanglePath;
@@ -129,15 +130,12 @@
[[NSColor clearColor] setFill];
NSRectFill(barRect);
- // Drawing a gradient into an empty bezier path will cause an exception, prevent that
- if (![_rectanglePath isEmpty]) {
- if (_isDark) {
- [_darkGradient drawInBezierPath:_rectanglePath angle:270.0];
- [_darkStroke setStroke];
- } else {
- [_lightGradient drawInBezierPath:_rectanglePath angle:270.0];
- [_lightStroke setStroke];
- }
+ if (_isDark) {
+ [_darkGradient vlc_safeDrawInBezierPath:_rectanglePath angle:270.0];
+ [_darkStroke setStroke];
+ } else {
+ [_lightGradient vlc_safeDrawInBezierPath:_rectanglePath angle:270.0];
+ [_lightStroke setStroke];
}
[_separatorPath stroke];
diff --git a/modules/gui/macosx/VLCSliderCell.m b/modules/gui/macosx/VLCSliderCell.m
index 09fc9e2e1a..6cd71de105 100644
--- a/modules/gui/macosx/VLCSliderCell.m
+++ b/modules/gui/macosx/VLCSliderCell.m
@@ -23,6 +23,7 @@
#import "VLCSliderCell.h"
#import "CompatibilityFixes.h"
+#import "NSGradient+VLCAdditions.h"
@interface VLCSliderCell () {
NSInteger _animationPosition;
@@ -228,9 +229,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
// Empty Track Drawing
NSBezierPath* emptyTrackPath = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:3 yRadius:3];
- // Drawing a gradient into an empty bezier path will cause an exception, prevent that
- if (![emptyTrackPath isEmpty])
- [_trackGradient drawInBezierPath:emptyTrackPath angle:-90];
+ [_trackGradient vlc_safeDrawInBezierPath:emptyTrackPath angle:-90];
if (_isKnobHidden) {
[_trackStrokeColor setStroke];
diff --git a/modules/gui/macosx/VLCVolumeSliderCell.m b/modules/gui/macosx/VLCVolumeSliderCell.m
index 489ac6dd76..e655ccb091 100644
--- a/modules/gui/macosx/VLCVolumeSliderCell.m
+++ b/modules/gui/macosx/VLCVolumeSliderCell.m
@@ -23,6 +23,7 @@
#import "VLCVolumeSliderCell.h"
#import "CompatibilityFixes.h"
+#import "NSGradient+VLCAdditions.h"
@interface VLCVolumeSliderCell () {
BOOL _isRTL;
@@ -145,16 +146,14 @@
// Draw knob
NSBezierPath* knobPath = [NSBezierPath bezierPathWithOvalInRect:NSInsetRect(knobRect, 1.0, 1.0)];
if (self.isHighlighted) {
- // Drawing a gradient into an empty bezier path will cause an exception, prevent that
- if (_knobGradient && ![knobPath isEmpty]) {
- [_knobGradient drawInBezierPath:knobPath angle:_knobGradientAngleHighlighted];
+ if (_knobGradient) {
+ [_knobGradient vlc_safeDrawInBezierPath:knobPath angle:_knobGradientAngleHighlighted];
} else {
[_activeKnobFillColor setFill];
}
} else {
- // Drawing a gradient into an empty bezier path will cause an exception, prevent that
- if (_knobGradient && ![knobPath isEmpty]) {
- [_knobGradient drawInBezierPath:knobPath angle:_knobGradientAngle];
+ if (_knobGradient) {
+ [_knobGradient vlc_safeDrawInBezierPath:knobPath angle:_knobGradientAngle];
} else {
[_knobFillColor setFill];
}
@@ -203,14 +202,10 @@
[emptyTrackPath fill];
// Filled part drawing
- // Drawing a gradient into an empty bezier path will cause an exception, prevent that
- if (![leadingTrackPath isEmpty])
- [_trackGradient drawInBezierPath:leadingTrackPath angle:-90];
+ [_trackGradient vlc_safeDrawInBezierPath:leadingTrackPath angle:-90];
} else {
// Empty part drawing
- // Drawing a gradient into an empty bezier path will cause an exception, prevent that
- if (![emptyTrackPath isEmpty])
- [_trackGradient drawInBezierPath:emptyTrackPath angle:-90];
+ [_trackGradient vlc_safeDrawInBezierPath:emptyTrackPath angle:-90];
// Filled part drawing
[_filledTrackColor setFill];
More information about the vlc-commits
mailing list