Mercurial > dwindows
comparison mac/dw.m @ 747:a4f99795ff26
Abort drawing functions if we fail to lock focus on a render control.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 16 Mar 2011 15:10:16 +0000 |
parents | d29fb0d5b291 |
children | f39745844175 |
comparison
equal
deleted
inserted
replaced
746:0a364e76a7aa | 747:a4f99795ff26 |
---|---|
388 { | 388 { |
389 [bltdest lockFocus]; | 389 [bltdest lockFocus]; |
390 } | 390 } |
391 else | 391 else |
392 { | 392 { |
393 [bltdest lockFocusIfCanDraw]; | 393 if([bltdest lockFocusIfCanDraw] == NO) |
394 { | |
395 return; | |
396 } | |
394 _DWLastDrawable = bltinfo->dest; | 397 _DWLastDrawable = bltinfo->dest; |
395 } | 398 } |
396 if([bltsrc isMemberOfClass:[NSImage class]]) | 399 if([bltsrc isMemberOfClass:[NSImage class]]) |
397 { | 400 { |
398 NSImage *image = bltsrc; | 401 NSImage *image = bltsrc; |
3751 image = (id)pixmap->image; | 3754 image = (id)pixmap->image; |
3752 [image lockFocus]; | 3755 [image lockFocus]; |
3753 } | 3756 } |
3754 else | 3757 else |
3755 { | 3758 { |
3756 [image lockFocusIfCanDraw]; | 3759 if([image lockFocusIfCanDraw] == NO) |
3760 { | |
3761 DW_MUTEX_UNLOCK; | |
3762 return; | |
3763 } | |
3757 _DWLastDrawable = handle; | 3764 _DWLastDrawable = handle; |
3758 } | 3765 } |
3759 NSBezierPath* aPath = [NSBezierPath bezierPath]; | 3766 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
3760 [aPath setLineWidth: 0.5]; | 3767 [aPath setLineWidth: 0.5]; |
3761 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; | 3768 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
3786 image = (id)pixmap->image; | 3793 image = (id)pixmap->image; |
3787 [image lockFocus]; | 3794 [image lockFocus]; |
3788 } | 3795 } |
3789 else | 3796 else |
3790 { | 3797 { |
3791 [image lockFocusIfCanDraw]; | 3798 if([image lockFocusIfCanDraw] == NO) |
3799 { | |
3800 DW_MUTEX_UNLOCK; | |
3801 return; | |
3802 } | |
3792 _DWLastDrawable = handle; | 3803 _DWLastDrawable = handle; |
3793 } | 3804 } |
3794 NSBezierPath* aPath = [NSBezierPath bezierPath]; | 3805 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
3795 [aPath setLineWidth: 0.5]; | 3806 [aPath setLineWidth: 0.5]; |
3796 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; | 3807 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
3822 { | 3833 { |
3823 if([image isMemberOfClass:[DWRender class]]) | 3834 if([image isMemberOfClass:[DWRender class]]) |
3824 { | 3835 { |
3825 DWRender *render = handle; | 3836 DWRender *render = handle; |
3826 NSFont *font = [render font]; | 3837 NSFont *font = [render font]; |
3827 [image lockFocusIfCanDraw]; | 3838 if([image lockFocusIfCanDraw] == NO) |
3839 { | |
3840 DW_MUTEX_UNLOCK; | |
3841 return; | |
3842 } | |
3828 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; | 3843 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
3829 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:color, NSForegroundColorAttributeName, nil]; | 3844 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:color, NSForegroundColorAttributeName, nil]; |
3830 if(font) | 3845 if(font) |
3831 { | 3846 { |
3832 [dict setValue:font forKey:NSFontAttributeName]; | 3847 [dict setValue:font forKey:NSFontAttributeName]; |
3919 image = (id)pixmap->image; | 3934 image = (id)pixmap->image; |
3920 [image lockFocus]; | 3935 [image lockFocus]; |
3921 } | 3936 } |
3922 else | 3937 else |
3923 { | 3938 { |
3924 [image lockFocusIfCanDraw]; | 3939 if([image lockFocusIfCanDraw] == NO) |
3940 { | |
3941 DW_MUTEX_UNLOCK; | |
3942 return; | |
3943 } | |
3925 _DWLastDrawable = handle; | 3944 _DWLastDrawable = handle; |
3926 } | 3945 } |
3927 NSBezierPath* aPath = [NSBezierPath bezierPath]; | 3946 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
3928 [aPath setLineWidth: 0.5]; | 3947 [aPath setLineWidth: 0.5]; |
3929 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; | 3948 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
3964 image = (id)pixmap->image; | 3983 image = (id)pixmap->image; |
3965 [image lockFocus]; | 3984 [image lockFocus]; |
3966 } | 3985 } |
3967 else | 3986 else |
3968 { | 3987 { |
3969 [image lockFocusIfCanDraw]; | 3988 if([image lockFocusIfCanDraw] == NO) |
3989 { | |
3990 DW_MUTEX_UNLOCK; | |
3991 return; | |
3992 } | |
3970 _DWLastDrawable = handle; | 3993 _DWLastDrawable = handle; |
3971 } | 3994 } |
3972 NSBezierPath* aPath = [NSBezierPath bezierPath]; | 3995 NSBezierPath* aPath = [NSBezierPath bezierPath]; |
3973 [aPath setLineWidth: 0.5]; | 3996 [aPath setLineWidth: 0.5]; |
3974 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; | 3997 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |