@@ -1043,6 +1043,48 @@ pub enum UpdateTextureError {
10431043 SdlError ( String ) ,
10441044}
10451045
1046+ impl fmt:: Display for UpdateTextureError {
1047+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1048+ use self :: UpdateTextureError :: * ;
1049+
1050+ match * self {
1051+ PitchOverflows ( value) => write ! ( f, "Pitch overflows ({})" , value) ,
1052+ PitchMustBeMultipleOfTwoForFormat ( value, format) => write ! ( f,
1053+ "Pitch must be multiple of two for pixel format '{:?}' ({})" ,
1054+ format, value) ,
1055+ XMustBeMultipleOfTwoForFormat ( value, format) => write ! ( f,
1056+ "X must be multiple of two for pixel format '{:?}' ({})" ,
1057+ format, value) ,
1058+ YMustBeMultipleOfTwoForFormat ( value, format) => write ! ( f,
1059+ "Y must be multiple of two for pixel format '{:?}' ({})" ,
1060+ format, value) ,
1061+ WidthMustBeMultipleOfTwoForFormat ( value, format) => write ! ( f,
1062+ "Width must be multiple of two for pixel format '{:?}' ({})" ,
1063+ format, value) ,
1064+ HeightMustBeMultipleOfTwoForFormat ( value, format) => write ! ( f,
1065+ "Height must be multiple of two for pixel format '{:?}' ({})" ,
1066+ format, value) ,
1067+ SdlError ( ref e) => write ! ( f, "SDL error: {}" , e)
1068+ }
1069+ }
1070+ }
1071+
1072+ impl Error for UpdateTextureError {
1073+ fn description ( & self ) -> & str {
1074+ use self :: UpdateTextureError :: * ;
1075+
1076+ match * self {
1077+ PitchOverflows ( _) => "pitch overflow" ,
1078+ PitchMustBeMultipleOfTwoForFormat ( ..) => "pitch must be multiple of two" ,
1079+ XMustBeMultipleOfTwoForFormat ( ..) => "x must be multiple of two" ,
1080+ YMustBeMultipleOfTwoForFormat ( ..) => "y must be multiple of two" ,
1081+ WidthMustBeMultipleOfTwoForFormat ( ..) => "width must be multiple of two" ,
1082+ HeightMustBeMultipleOfTwoForFormat ( ..) => "height must be multiple of two" ,
1083+ SdlError ( ref e) => e,
1084+ }
1085+ }
1086+ }
1087+
10461088#[ derive( Debug ) ]
10471089pub enum UpdateTextureYUVError {
10481090 PitchOverflows { plane : & ' static str , value : usize } ,
@@ -1055,6 +1097,47 @@ pub enum UpdateTextureYUVError {
10551097 SdlError ( String ) ,
10561098}
10571099
1100+ impl fmt:: Display for UpdateTextureYUVError {
1101+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1102+ use self :: UpdateTextureYUVError :: * ;
1103+
1104+ match * self {
1105+ PitchOverflows { plane, value } => write ! ( f,
1106+ "Pitch overflows on {} plane ({})" , plane, value) ,
1107+ InvalidPlaneLength { plane, length, pitch, height } => write ! ( f,
1108+ "The {} plane is wrong length ({}, should be {} * {})" ,
1109+ plane, length, pitch, height) ,
1110+ XMustBeMultipleOfTwoForFormat ( value) => write ! ( f,
1111+ "X must be multiple of two ({})" , value) ,
1112+ YMustBeMultipleOfTwoForFormat ( value) => write ! ( f,
1113+ "Y must be multiple of two ({})" , value) ,
1114+ WidthMustBeMultipleOfTwoForFormat ( value) => write ! ( f,
1115+ "Width must be multiple of two ({})" , value) ,
1116+ HeightMustBeMultipleOfTwoForFormat ( value) => write ! ( f,
1117+ "Height must be multiple of two ({})" , value) ,
1118+ RectNotInsideTexture ( _) => write ! ( f, "Rect must be inside texture" ) ,
1119+ SdlError ( ref e) => write ! ( f, "SDL error: {}" , e)
1120+ }
1121+ }
1122+ }
1123+
1124+ impl Error for UpdateTextureYUVError {
1125+ fn description ( & self ) -> & str {
1126+ use self :: UpdateTextureYUVError :: * ;
1127+
1128+ match * self {
1129+ PitchOverflows { ..} => "pitch overflow" ,
1130+ InvalidPlaneLength { ..} => "invalid plane length" ,
1131+ XMustBeMultipleOfTwoForFormat ( _) => "x must be multiple of two" ,
1132+ YMustBeMultipleOfTwoForFormat ( _) => "y must be multiple of two" ,
1133+ WidthMustBeMultipleOfTwoForFormat ( _) => "width must be multiple of two" ,
1134+ HeightMustBeMultipleOfTwoForFormat ( _) => "height must be multiple of two" ,
1135+ RectNotInsideTexture ( _) => "rect must be inside texture" ,
1136+ SdlError ( ref e) => e,
1137+ }
1138+ }
1139+ }
1140+
10581141impl Texture {
10591142 #[ inline]
10601143 fn check_renderer ( & self ) {
0 commit comments