| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "platform/graphics/gpu/WebGLImageConversion.h" | 6 #include "platform/graphics/gpu/WebGLImageConversion.h" |
| 7 | 7 |
| 8 #include "platform/CheckedInt.h" | 8 #include "platform/CheckedInt.h" |
| 9 #include "platform/graphics/ImageObserver.h" | 9 #include "platform/graphics/ImageObserver.h" |
| 10 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" | 10 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 break; | 205 break; |
| 206 case GL_UNSIGNED_SHORT_4_4_4_4: | 206 case GL_UNSIGNED_SHORT_4_4_4_4: |
| 207 dstFormat = WebGLImageConversion::DataFormatRGBA4444; | 207 dstFormat = WebGLImageConversion::DataFormatRGBA4444; |
| 208 break; | 208 break; |
| 209 case GL_UNSIGNED_SHORT_5_5_5_1: | 209 case GL_UNSIGNED_SHORT_5_5_5_1: |
| 210 dstFormat = WebGLImageConversion::DataFormatRGBA5551; | 210 dstFormat = WebGLImageConversion::DataFormatRGBA5551; |
| 211 break; | 211 break; |
| 212 case GL_UNSIGNED_SHORT_5_6_5: | 212 case GL_UNSIGNED_SHORT_5_6_5: |
| 213 dstFormat = WebGLImageConversion::DataFormatRGB565; | 213 dstFormat = WebGLImageConversion::DataFormatRGB565; |
| 214 break; | 214 break; |
| 215 case GL_UNSIGNED_INT_5_9_9_9_REV: |
| 216 dstFormat = WebGLImageConversion::DataFormatRGB5999; |
| 217 break; |
| 215 case GL_UNSIGNED_INT_24_8: | 218 case GL_UNSIGNED_INT_24_8: |
| 216 dstFormat = WebGLImageConversion::DataFormatDS24_8; | 219 dstFormat = WebGLImageConversion::DataFormatDS24_8; |
| 217 break; | 220 break; |
| 218 case GL_UNSIGNED_INT_10F_11F_11F_REV: | 221 case GL_UNSIGNED_INT_10F_11F_11F_REV: |
| 219 dstFormat = WebGLImageConversion::DataFormatRGB10F11F11F; | 222 dstFormat = WebGLImageConversion::DataFormatRGB10F11F11F; |
| 220 break; | 223 break; |
| 221 case GL_UNSIGNED_INT_2_10_10_10_REV: | 224 case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 222 dstFormat = WebGLImageConversion::DataFormatRGBA2_10_10_10; | 225 dstFormat = WebGLImageConversion::DataFormatRGBA2_10_10_10; |
| 223 break; | 226 break; |
| 224 default: | 227 default: |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 || format == WebGLImageConversion::DataFormatAR8 | 1133 || format == WebGLImageConversion::DataFormatAR8 |
| 1131 || format == WebGLImageConversion::DataFormatRA16F | 1134 || format == WebGLImageConversion::DataFormatRA16F |
| 1132 || format == WebGLImageConversion::DataFormatRA32F | 1135 || format == WebGLImageConversion::DataFormatRA32F |
| 1133 || format == WebGLImageConversion::DataFormatRGBA8 | 1136 || format == WebGLImageConversion::DataFormatRGBA8 |
| 1134 || format == WebGLImageConversion::DataFormatBGRA8 | 1137 || format == WebGLImageConversion::DataFormatBGRA8 |
| 1135 || format == WebGLImageConversion::DataFormatARGB8 | 1138 || format == WebGLImageConversion::DataFormatARGB8 |
| 1136 || format == WebGLImageConversion::DataFormatABGR8 | 1139 || format == WebGLImageConversion::DataFormatABGR8 |
| 1137 || format == WebGLImageConversion::DataFormatRGBA16F | 1140 || format == WebGLImageConversion::DataFormatRGBA16F |
| 1138 || format == WebGLImageConversion::DataFormatRGBA32F | 1141 || format == WebGLImageConversion::DataFormatRGBA32F |
| 1139 || format == WebGLImageConversion::DataFormatRGBA4444 | 1142 || format == WebGLImageConversion::DataFormatRGBA4444 |
| 1140 || format == WebGLImageConversion::DataFormatRGBA5551; | 1143 || format == WebGLImageConversion::DataFormatRGBA5551 |
| 1144 || format == WebGLImageConversion::DataFormatRGBA8_S |
| 1145 || format == WebGLImageConversion::DataFormatRGBA16 |
| 1146 || format == WebGLImageConversion::DataFormatRGBA16_S |
| 1147 || format == WebGLImageConversion::DataFormatRGBA32 |
| 1148 || format == WebGLImageConversion::DataFormatRGBA32_S |
| 1149 || format == WebGLImageConversion::DataFormatRGBA2_10_10_10; |
| 1141 } | 1150 } |
| 1142 | 1151 |
| 1143 bool HasColor(int format) | 1152 bool HasColor(int format) |
| 1144 { | 1153 { |
| 1145 return format == WebGLImageConversion::DataFormatRGBA8 | 1154 return format == WebGLImageConversion::DataFormatRGBA8 |
| 1146 || format == WebGLImageConversion::DataFormatRGBA16F | 1155 || format == WebGLImageConversion::DataFormatRGBA16F |
| 1147 || format == WebGLImageConversion::DataFormatRGBA32F | 1156 || format == WebGLImageConversion::DataFormatRGBA32F |
| 1148 || format == WebGLImageConversion::DataFormatRGB8 | 1157 || format == WebGLImageConversion::DataFormatRGB8 |
| 1149 || format == WebGLImageConversion::DataFormatRGB16F | 1158 || format == WebGLImageConversion::DataFormatRGB16F |
| 1150 || format == WebGLImageConversion::DataFormatRGB32F | 1159 || format == WebGLImageConversion::DataFormatRGB32F |
| 1151 || format == WebGLImageConversion::DataFormatBGR8 | 1160 || format == WebGLImageConversion::DataFormatBGR8 |
| 1152 || format == WebGLImageConversion::DataFormatBGRA8 | 1161 || format == WebGLImageConversion::DataFormatBGRA8 |
| 1153 || format == WebGLImageConversion::DataFormatARGB8 | 1162 || format == WebGLImageConversion::DataFormatARGB8 |
| 1154 || format == WebGLImageConversion::DataFormatABGR8 | 1163 || format == WebGLImageConversion::DataFormatABGR8 |
| 1155 || format == WebGLImageConversion::DataFormatRGBA5551 | 1164 || format == WebGLImageConversion::DataFormatRGBA5551 |
| 1156 || format == WebGLImageConversion::DataFormatRGBA4444 | 1165 || format == WebGLImageConversion::DataFormatRGBA4444 |
| 1157 || format == WebGLImageConversion::DataFormatRGB565 | 1166 || format == WebGLImageConversion::DataFormatRGB565 |
| 1158 || format == WebGLImageConversion::DataFormatR8 | 1167 || format == WebGLImageConversion::DataFormatR8 |
| 1159 || format == WebGLImageConversion::DataFormatR16F | 1168 || format == WebGLImageConversion::DataFormatR16F |
| 1160 || format == WebGLImageConversion::DataFormatR32F | 1169 || format == WebGLImageConversion::DataFormatR32F |
| 1161 || format == WebGLImageConversion::DataFormatRA8 | 1170 || format == WebGLImageConversion::DataFormatRA8 |
| 1162 || format == WebGLImageConversion::DataFormatRA16F | 1171 || format == WebGLImageConversion::DataFormatRA16F |
| 1163 || format == WebGLImageConversion::DataFormatRA32F | 1172 || format == WebGLImageConversion::DataFormatRA32F |
| 1164 || format == WebGLImageConversion::DataFormatAR8; | 1173 || format == WebGLImageConversion::DataFormatAR8 |
| 1174 || format == WebGLImageConversion::DataFormatRGBA8_S |
| 1175 || format == WebGLImageConversion::DataFormatRGBA16 |
| 1176 || format == WebGLImageConversion::DataFormatRGBA16_S |
| 1177 || format == WebGLImageConversion::DataFormatRGBA32 |
| 1178 || format == WebGLImageConversion::DataFormatRGBA32_S |
| 1179 || format == WebGLImageConversion::DataFormatRGBA2_10_10_10 |
| 1180 || format == WebGLImageConversion::DataFormatRGB8_S |
| 1181 || format == WebGLImageConversion::DataFormatRGB16 |
| 1182 || format == WebGLImageConversion::DataFormatRGB16_S |
| 1183 || format == WebGLImageConversion::DataFormatRGB32 |
| 1184 || format == WebGLImageConversion::DataFormatRGB32_S |
| 1185 || format == WebGLImageConversion::DataFormatRGB10F11F11F |
| 1186 || format == WebGLImageConversion::DataFormatRGB5999 |
| 1187 || format == WebGLImageConversion::DataFormatRG8 |
| 1188 || format == WebGLImageConversion::DataFormatRG8_S |
| 1189 || format == WebGLImageConversion::DataFormatRG16 |
| 1190 || format == WebGLImageConversion::DataFormatRG16_S |
| 1191 || format == WebGLImageConversion::DataFormatRG32 |
| 1192 || format == WebGLImageConversion::DataFormatRG32_S |
| 1193 || format == WebGLImageConversion::DataFormatRG16F |
| 1194 || format == WebGLImageConversion::DataFormatRG32F |
| 1195 || format == WebGLImageConversion::DataFormatR8_S |
| 1196 || format == WebGLImageConversion::DataFormatR16 |
| 1197 || format == WebGLImageConversion::DataFormatR16_S |
| 1198 || format == WebGLImageConversion::DataFormatR32 |
| 1199 || format == WebGLImageConversion::DataFormatR32_S; |
| 1165 } | 1200 } |
| 1166 | 1201 |
| 1167 template<int Format> | 1202 template<int Format> |
| 1203 struct IsInt8Format { |
| 1204 static const bool Value = |
| 1205 Format == WebGLImageConversion::DataFormatRGBA8_S |
| 1206 || Format == WebGLImageConversion::DataFormatRGB8_S |
| 1207 || Format == WebGLImageConversion::DataFormatRG8_S |
| 1208 || Format == WebGLImageConversion::DataFormatR8_S; |
| 1209 }; |
| 1210 |
| 1211 template<int Format> |
| 1212 struct IsInt16Format { |
| 1213 static const bool Value = |
| 1214 Format == WebGLImageConversion::DataFormatRGBA16_S |
| 1215 || Format == WebGLImageConversion::DataFormatRGB16_S |
| 1216 || Format == WebGLImageConversion::DataFormatRG16_S |
| 1217 || Format == WebGLImageConversion::DataFormatR16_S; |
| 1218 }; |
| 1219 |
| 1220 template<int Format> |
| 1221 struct IsInt32Format { |
| 1222 static const bool Value = |
| 1223 Format == WebGLImageConversion::DataFormatRGBA32_S |
| 1224 || Format == WebGLImageConversion::DataFormatRGB32_S |
| 1225 || Format == WebGLImageConversion::DataFormatRG32_S |
| 1226 || Format == WebGLImageConversion::DataFormatR32_S; |
| 1227 }; |
| 1228 |
| 1229 template<int Format> |
| 1230 struct IsUInt8Format { |
| 1231 static const bool Value = |
| 1232 Format == WebGLImageConversion::DataFormatRGBA8 |
| 1233 || Format == WebGLImageConversion::DataFormatRGB8 |
| 1234 || Format == WebGLImageConversion::DataFormatRG8 |
| 1235 || Format == WebGLImageConversion::DataFormatR8 |
| 1236 || Format == WebGLImageConversion::DataFormatBGRA8 |
| 1237 || Format == WebGLImageConversion::DataFormatBGR8 |
| 1238 || Format == WebGLImageConversion::DataFormatARGB8 |
| 1239 || Format == WebGLImageConversion::DataFormatABGR8 |
| 1240 || Format == WebGLImageConversion::DataFormatRA8 |
| 1241 || Format == WebGLImageConversion::DataFormatAR8 |
| 1242 || Format == WebGLImageConversion::DataFormatA8; |
| 1243 }; |
| 1244 |
| 1245 template<int Format> |
| 1246 struct IsUInt16Format { |
| 1247 static const bool Value = |
| 1248 Format == WebGLImageConversion::DataFormatRGBA16 |
| 1249 || Format == WebGLImageConversion::DataFormatRGB16 |
| 1250 || Format == WebGLImageConversion::DataFormatRG16 |
| 1251 || Format == WebGLImageConversion::DataFormatR16; |
| 1252 }; |
| 1253 |
| 1254 template<int Format> |
| 1255 struct IsUInt32Format { |
| 1256 static const bool Value = |
| 1257 Format == WebGLImageConversion::DataFormatRGBA32 |
| 1258 || Format == WebGLImageConversion::DataFormatRGB32 |
| 1259 || Format == WebGLImageConversion::DataFormatRG32 |
| 1260 || Format == WebGLImageConversion::DataFormatR32; |
| 1261 }; |
| 1262 |
| 1263 template<int Format> |
| 1168 struct IsFloatFormat { | 1264 struct IsFloatFormat { |
| 1169 static const bool Value = | 1265 static const bool Value = |
| 1170 Format == WebGLImageConversion::DataFormatRGBA32F | 1266 Format == WebGLImageConversion::DataFormatRGBA32F |
| 1171 || Format == WebGLImageConversion::DataFormatRGB32F | 1267 || Format == WebGLImageConversion::DataFormatRGB32F |
| 1172 || Format == WebGLImageConversion::DataFormatRA32F | 1268 || Format == WebGLImageConversion::DataFormatRA32F |
| 1173 || Format == WebGLImageConversion::DataFormatR32F | 1269 || Format == WebGLImageConversion::DataFormatR32F |
| 1174 || Format == WebGLImageConversion::DataFormatA32F; | 1270 || Format == WebGLImageConversion::DataFormatA32F |
| 1271 || Format == WebGLImageConversion::DataFormatRG32F; |
| 1175 }; | 1272 }; |
| 1176 | 1273 |
| 1177 template<int Format> | 1274 template<int Format> |
| 1178 struct IsHalfFloatFormat { | 1275 struct IsHalfFloatFormat { |
| 1179 static const bool Value = | 1276 static const bool Value = |
| 1180 Format == WebGLImageConversion::DataFormatRGBA16F | 1277 Format == WebGLImageConversion::DataFormatRGBA16F |
| 1181 || Format == WebGLImageConversion::DataFormatRGB16F | 1278 || Format == WebGLImageConversion::DataFormatRGB16F |
| 1182 || Format == WebGLImageConversion::DataFormatRA16F | 1279 || Format == WebGLImageConversion::DataFormatRA16F |
| 1183 || Format == WebGLImageConversion::DataFormatR16F | 1280 || Format == WebGLImageConversion::DataFormatR16F |
| 1184 || Format == WebGLImageConversion::DataFormatA16F; | 1281 || Format == WebGLImageConversion::DataFormatA16F |
| 1282 || Format == WebGLImageConversion::DataFormatRG16F; |
| 1185 }; | 1283 }; |
| 1186 | 1284 |
| 1187 template<int Format> | 1285 template<int Format> |
| 1286 struct Is32bppFormat { |
| 1287 static const bool Value = |
| 1288 Format == WebGLImageConversion::DataFormatRGBA2_10_10_10 |
| 1289 || Format == WebGLImageConversion::DataFormatRGB5999 |
| 1290 || Format == WebGLImageConversion::DataFormatRGB10F11F11F; |
| 1291 }; |
| 1292 |
| 1293 template<int Format> |
| 1188 struct Is16bppFormat { | 1294 struct Is16bppFormat { |
| 1189 static const bool Value = | 1295 static const bool Value = |
| 1190 Format == WebGLImageConversion::DataFormatRGBA5551 | 1296 Format == WebGLImageConversion::DataFormatRGBA5551 |
| 1191 || Format == WebGLImageConversion::DataFormatRGBA4444 | 1297 || Format == WebGLImageConversion::DataFormatRGBA4444 |
| 1192 || Format == WebGLImageConversion::DataFormatRGB565; | 1298 || Format == WebGLImageConversion::DataFormatRGB565; |
| 1193 }; | 1299 }; |
| 1194 | 1300 |
| 1195 template<int Format, bool IsFloat = IsFloatFormat<Format>::Value, bool IsHalfFlo
at = IsHalfFloatFormat<Format>::Value, bool Is16bpp = Is16bppFormat<Format>::Val
ue> | 1301 template<int Format, |
| 1302 bool IsInt8Format = IsInt8Format<Format>::Value, |
| 1303 bool IsUInt8Format = IsUInt8Format<Format>::Value, |
| 1304 bool IsInt16Format = IsInt16Format<Format>::Value, |
| 1305 bool IsUInt16Format = IsUInt16Format<Format>::Value, |
| 1306 bool IsInt32Format = IsInt32Format<Format>::Value, |
| 1307 bool IsUInt32Format = IsUInt32Format<Format>::Value, |
| 1308 bool IsFloat = IsFloatFormat<Format>::Value, |
| 1309 bool IsHalfFloat = IsHalfFloatFormat<Format>::Value, |
| 1310 bool Is16bpp = Is16bppFormat<Format>::Value, |
| 1311 bool Is32bpp = Is32bppFormat<Format>::Value> |
| 1196 struct DataTypeForFormat { | 1312 struct DataTypeForFormat { |
| 1313 typedef double Type; // Use a type that's not used in unpack/pack. |
| 1314 }; |
| 1315 |
| 1316 template<int Format> |
| 1317 struct DataTypeForFormat<Format, true, false, false, false, false, false, false,
false, false, false> { |
| 1318 typedef int8_t Type; |
| 1319 }; |
| 1320 |
| 1321 template<int Format> |
| 1322 struct DataTypeForFormat<Format, false, true, false, false, false, false, false,
false, false, false> { |
| 1197 typedef uint8_t Type; | 1323 typedef uint8_t Type; |
| 1198 }; | 1324 }; |
| 1199 | 1325 |
| 1200 template<int Format> | 1326 template<int Format> |
| 1201 struct DataTypeForFormat<Format, true, false, false> { | 1327 struct DataTypeForFormat<Format, false, false, true, false, false, false, false,
false, false, false> { |
| 1328 typedef int16_t Type; |
| 1329 }; |
| 1330 |
| 1331 template<int Format> |
| 1332 struct DataTypeForFormat<Format, false, false, false, true, false, false, false,
false, false, false> { |
| 1333 typedef uint16_t Type; |
| 1334 }; |
| 1335 |
| 1336 template<int Format> |
| 1337 struct DataTypeForFormat<Format, false, false, false, false, true, false, false,
false, false, false> { |
| 1338 typedef int32_t Type; |
| 1339 }; |
| 1340 |
| 1341 template<int Format> |
| 1342 struct DataTypeForFormat<Format, false, false, false, false, false, true, false,
false, false, false> { |
| 1343 typedef uint32_t Type; |
| 1344 }; |
| 1345 |
| 1346 template<int Format> |
| 1347 struct DataTypeForFormat<Format, false, false, false, false, false, false, true,
false, false, false> { |
| 1202 typedef float Type; | 1348 typedef float Type; |
| 1203 }; | 1349 }; |
| 1204 | 1350 |
| 1205 template<int Format> | 1351 template<int Format> |
| 1206 struct DataTypeForFormat<Format, false, true, false> { | 1352 struct DataTypeForFormat<Format, false, false, false, false, false, false, false
, true, false, false> { |
| 1207 typedef uint16_t Type; | 1353 typedef uint16_t Type; |
| 1208 }; | 1354 }; |
| 1209 | 1355 |
| 1210 template<int Format> | 1356 template<int Format> |
| 1211 struct DataTypeForFormat<Format, false, false, true> { | 1357 struct DataTypeForFormat<Format, false, false, false, false, false, false, false
, false, true, false> { |
| 1212 typedef uint16_t Type; | 1358 typedef uint16_t Type; |
| 1213 }; | 1359 }; |
| 1214 | 1360 |
| 1215 template<int Format> | 1361 template<int Format> |
| 1362 struct DataTypeForFormat<Format, false, false, false, false, false, false, false
, false, false, true> { |
| 1363 typedef uint32_t Type; |
| 1364 }; |
| 1365 |
| 1366 template<int Format> |
| 1367 struct UsesFloatIntermediateFormat { |
| 1368 static const bool Value = |
| 1369 IsFloatFormat<Format>::Value |
| 1370 || IsHalfFloatFormat<Format>::Value |
| 1371 || Format == WebGLImageConversion::DataFormatRGB10F11F11F |
| 1372 || Format == WebGLImageConversion::DataFormatRGB5999; |
| 1373 }; |
| 1374 |
| 1375 template<int Format> |
| 1216 struct IntermediateFormat { | 1376 struct IntermediateFormat { |
| 1217 static const int Value = (IsFloatFormat<Format>::Value || IsHalfFloatFormat<
Format>::Value) ? WebGLImageConversion::DataFormatRGBA32F : WebGLImageConversion
::DataFormatRGBA8; | 1377 static const int Value = |
| 1378 UsesFloatIntermediateFormat<Format>::Value ? WebGLImageConversion::DataF
ormatRGBA32F |
| 1379 : IsInt32Format<Format>::Value ? WebGLImageConversion::DataFormatRGBA32_
S |
| 1380 : IsUInt32Format<Format>::Value ? WebGLImageConversion::DataFormatRGBA32 |
| 1381 : IsInt16Format<Format>::Value ? WebGLImageConversion::DataFormatRGBA16_
S |
| 1382 : (IsUInt16Format<Format>::Value || Is32bppFormat<Format>::Value) ? WebG
LImageConversion::DataFormatRGBA16 |
| 1383 : IsInt8Format<Format>::Value ? WebGLImageConversion::DataFormatRGBA8_S
: WebGLImageConversion::DataFormatRGBA8; |
| 1218 }; | 1384 }; |
| 1219 | 1385 |
| 1220 unsigned TexelBytesForFormat(WebGLImageConversion::DataFormat format) | 1386 unsigned TexelBytesForFormat(WebGLImageConversion::DataFormat format) |
| 1221 { | 1387 { |
| 1222 switch (format) { | 1388 switch (format) { |
| 1223 case WebGLImageConversion::DataFormatR8: | 1389 case WebGLImageConversion::DataFormatR8: |
| 1224 case WebGLImageConversion::DataFormatR8_S: | 1390 case WebGLImageConversion::DataFormatR8_S: |
| 1225 case WebGLImageConversion::DataFormatA8: | 1391 case WebGLImageConversion::DataFormatA8: |
| 1226 return 1; | 1392 return 1; |
| 1227 case WebGLImageConversion::DataFormatRG8: | 1393 case WebGLImageConversion::DataFormatRG8: |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 ASSERT_NOT_REACHED(); | 1584 ASSERT_NOT_REACHED(); |
| 1419 return; | 1585 return; |
| 1420 } | 1586 } |
| 1421 if ((!HasAlpha(SrcFormat) || !HasColor(SrcFormat) || !HasColor(DstFormat)) &
& alphaOp != WebGLImageConversion::AlphaDoNothing) { | 1587 if ((!HasAlpha(SrcFormat) || !HasColor(SrcFormat) || !HasColor(DstFormat)) &
& alphaOp != WebGLImageConversion::AlphaDoNothing) { |
| 1422 ASSERT_NOT_REACHED(); | 1588 ASSERT_NOT_REACHED(); |
| 1423 return; | 1589 return; |
| 1424 } | 1590 } |
| 1425 | 1591 |
| 1426 typedef typename DataTypeForFormat<SrcFormat>::Type SrcType; | 1592 typedef typename DataTypeForFormat<SrcFormat>::Type SrcType; |
| 1427 typedef typename DataTypeForFormat<DstFormat>::Type DstType; | 1593 typedef typename DataTypeForFormat<DstFormat>::Type DstType; |
| 1428 const int IntermediateSrcFormat = IntermediateFormat<DstFormat>::Value; | 1594 const int IntermFormat = IntermediateFormat<DstFormat>::Value; |
| 1429 typedef typename DataTypeForFormat<IntermediateSrcFormat>::Type Intermediate
SrcType; | 1595 typedef typename DataTypeForFormat<IntermFormat>::Type IntermType; |
| 1430 const ptrdiff_t srcStrideInElements = m_srcStride / sizeof(SrcType); | 1596 const ptrdiff_t srcStrideInElements = m_srcStride / sizeof(SrcType); |
| 1431 const ptrdiff_t dstStrideInElements = m_dstStride / sizeof(DstType); | 1597 const ptrdiff_t dstStrideInElements = m_dstStride / sizeof(DstType); |
| 1432 const bool trivialUnpack = (SrcFormat == WebGLImageConversion::DataFormatRGB
A8 && !IsFloatFormat<DstFormat>::Value && !IsHalfFloatFormat<DstFormat>::Value)
|| SrcFormat == WebGLImageConversion::DataFormatRGBA32F; | 1598 const bool trivialUnpack = SrcFormat == IntermFormat; |
| 1433 const bool trivialPack = (DstFormat == WebGLImageConversion::DataFormatRGBA8
|| DstFormat == WebGLImageConversion::DataFormatRGBA32F) && alphaOp == WebGLIma
geConversion::AlphaDoNothing && m_dstStride > 0; | 1599 const bool trivialPack = DstFormat == IntermFormat && alphaOp == WebGLImageC
onversion::AlphaDoNothing && m_dstStride > 0; |
| 1434 ASSERT(!trivialUnpack || !trivialPack); | 1600 ASSERT(!trivialUnpack || !trivialPack); |
| 1435 | 1601 |
| 1436 const SrcType *srcRowStart = static_cast<const SrcType*>(m_srcStart); | 1602 const SrcType *srcRowStart = static_cast<const SrcType*>(m_srcStart); |
| 1437 DstType* dstRowStart = static_cast<DstType*>(m_dstStart); | 1603 DstType* dstRowStart = static_cast<DstType*>(m_dstStart); |
| 1438 if (trivialUnpack) { | 1604 if (trivialUnpack) { |
| 1439 for (size_t i = 0; i < m_height; ++i) { | 1605 for (size_t i = 0; i < m_height; ++i) { |
| 1440 pack<DstFormat, alphaOp>(srcRowStart, dstRowStart, m_width); | 1606 pack<DstFormat, alphaOp>(srcRowStart, dstRowStart, m_width); |
| 1441 srcRowStart += srcStrideInElements; | 1607 srcRowStart += srcStrideInElements; |
| 1442 dstRowStart += dstStrideInElements; | 1608 dstRowStart += dstStrideInElements; |
| 1443 } | 1609 } |
| 1444 } else if (trivialPack) { | 1610 } else if (trivialPack) { |
| 1445 for (size_t i = 0; i < m_height; ++i) { | 1611 for (size_t i = 0; i < m_height; ++i) { |
| 1446 unpack<SrcFormat>(srcRowStart, dstRowStart, m_width); | 1612 unpack<SrcFormat>(srcRowStart, dstRowStart, m_width); |
| 1447 srcRowStart += srcStrideInElements; | 1613 srcRowStart += srcStrideInElements; |
| 1448 dstRowStart += dstStrideInElements; | 1614 dstRowStart += dstStrideInElements; |
| 1449 } | 1615 } |
| 1450 } else { | 1616 } else { |
| 1451 for (size_t i = 0; i < m_height; ++i) { | 1617 for (size_t i = 0; i < m_height; ++i) { |
| 1452 unpack<SrcFormat>(srcRowStart, reinterpret_cast<IntermediateSrcType*
>(m_unpackedIntermediateSrcData.get()), m_width); | 1618 unpack<SrcFormat>(srcRowStart, reinterpret_cast<IntermType*>(m_unpac
kedIntermediateSrcData.get()), m_width); |
| 1453 pack<DstFormat, alphaOp>(reinterpret_cast<IntermediateSrcType*>(m_un
packedIntermediateSrcData.get()), dstRowStart, m_width); | 1619 pack<DstFormat, alphaOp>(reinterpret_cast<IntermType*>(m_unpackedInt
ermediateSrcData.get()), dstRowStart, m_width); |
| 1454 srcRowStart += srcStrideInElements; | 1620 srcRowStart += srcStrideInElements; |
| 1455 dstRowStart += dstStrideInElements; | 1621 dstRowStart += dstStrideInElements; |
| 1456 } | 1622 } |
| 1457 } | 1623 } |
| 1458 m_success = true; | 1624 m_success = true; |
| 1459 return; | 1625 return; |
| 1460 } | 1626 } |
| 1461 | 1627 |
| 1462 } // anonymous namespace | 1628 } // anonymous namespace |
| 1463 | 1629 |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 } | 2018 } |
| 1853 | 2019 |
| 1854 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); | 2020 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); |
| 1855 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); | 2021 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); |
| 1856 if (!converter.Success()) | 2022 if (!converter.Success()) |
| 1857 return false; | 2023 return false; |
| 1858 return true; | 2024 return true; |
| 1859 } | 2025 } |
| 1860 | 2026 |
| 1861 } // namespace blink | 2027 } // namespace blink |
| OLD | NEW |