Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file is here so other GLES2 related files can have a common set of | 5 // This file is here so other GLES2 related files can have a common set of |
| 6 // includes where appropriate. | 6 // includes where appropriate. |
| 7 | 7 |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
| 10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
| (...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1182 case GL_RG16UI: | 1182 case GL_RG16UI: |
| 1183 case GL_RG16I: | 1183 case GL_RG16I: |
| 1184 case GL_RG32UI: | 1184 case GL_RG32UI: |
| 1185 case GL_RG32I: | 1185 case GL_RG32I: |
| 1186 return kRed | kGreen; | 1186 return kRed | kGreen; |
| 1187 default: | 1187 default: |
| 1188 return 0x0000; | 1188 return 0x0000; |
| 1189 } | 1189 } |
| 1190 } | 1190 } |
| 1191 | 1191 |
| 1192 bool GLES2Util::IsSizedColorFormat(uint32_t internal_format) { | |
| 1193 switch (internal_format) { | |
| 1194 case GL_ALPHA16F_EXT: | |
| 1195 case GL_ALPHA32F_EXT: | |
| 1196 case GL_RGB8: | |
| 1197 case GL_RGB565: | |
| 1198 case GL_RGB16F: | |
| 1199 case GL_RGB32F: | |
| 1200 case GL_SRGB8: | |
| 1201 case GL_RGB8_SNORM: | |
| 1202 case GL_R11F_G11F_B10F: | |
| 1203 case GL_RGB9_E5: | |
| 1204 case GL_RGB8UI: | |
| 1205 case GL_RGB8I: | |
| 1206 case GL_RGB16UI: | |
| 1207 case GL_RGB16I: | |
| 1208 case GL_RGB32UI: | |
| 1209 case GL_RGB32I: | |
| 1210 case GL_BGRA8_EXT: | |
| 1211 case GL_RGBA16F: | |
| 1212 case GL_RGBA32F: | |
| 1213 case GL_RGBA8_OES: | |
| 1214 case GL_RGBA4: | |
| 1215 case GL_RGB5_A1: | |
| 1216 case GL_SRGB8_ALPHA8: | |
| 1217 case GL_RGBA8_SNORM: | |
| 1218 case GL_RGB10_A2: | |
| 1219 case GL_RGBA8UI: | |
| 1220 case GL_RGBA8I: | |
| 1221 case GL_RGB10_A2UI: | |
| 1222 case GL_RGBA16UI: | |
| 1223 case GL_RGBA16I: | |
| 1224 case GL_RGBA32UI: | |
| 1225 case GL_RGBA32I: | |
| 1226 case GL_R8: | |
| 1227 case GL_R8_SNORM: | |
| 1228 case GL_R16F: | |
| 1229 case GL_R32F: | |
| 1230 case GL_R8UI: | |
| 1231 case GL_R8I: | |
| 1232 case GL_R16UI: | |
| 1233 case GL_R16I: | |
| 1234 case GL_R32UI: | |
| 1235 case GL_R32I: | |
| 1236 case GL_RG8: | |
| 1237 case GL_RG8_SNORM: | |
| 1238 case GL_RG16F: | |
| 1239 case GL_RG32F: | |
| 1240 case GL_RG8UI: | |
| 1241 case GL_RG8I: | |
| 1242 case GL_RG16UI: | |
| 1243 case GL_RG16I: | |
| 1244 case GL_RG32UI: | |
| 1245 case GL_RG32I: | |
| 1246 return true; | |
| 1247 default: | |
| 1248 return false; | |
| 1249 } | |
| 1250 } | |
| 1251 | |
| 1252 void GLES2Util::GetColorFormatComponentSizes( | |
| 1253 uint32_t internal_format, uint32_t type, int* r, int* g, int* b, int* a) { | |
| 1254 DCHECK(r && g && b && a); | |
| 1255 switch (internal_format) { | |
| 1256 case GL_RGB: | |
| 1257 switch (type) { | |
| 1258 case GL_UNSIGNED_BYTE: | |
| 1259 internal_format = GL_RGB8; | |
| 1260 break; | |
| 1261 case GL_UNSIGNED_SHORT_5_6_5: | |
| 1262 internal_format = GL_RGB565; | |
| 1263 break; | |
| 1264 default: | |
|
Corentin Wallez
2016/06/02 21:29:40
All the default cases could be UNREACHABLE()
Zhenyao Mo
2016/06/03 18:29:48
Good idea. Done.
| |
| 1265 break; | |
| 1266 } | |
| 1267 break; | |
| 1268 case GL_SRGB_EXT: | |
| 1269 switch (type) { | |
| 1270 case GL_UNSIGNED_BYTE: | |
| 1271 internal_format = GL_SRGB8; | |
| 1272 break; | |
| 1273 default: | |
| 1274 break; | |
| 1275 } | |
| 1276 break; | |
| 1277 case GL_BGRA_EXT: | |
| 1278 switch (type) { | |
| 1279 case GL_UNSIGNED_BYTE: | |
| 1280 internal_format = GL_BGRA8_EXT; | |
| 1281 break; | |
| 1282 default: | |
| 1283 break; | |
| 1284 } | |
| 1285 break; | |
| 1286 case GL_RGBA: | |
| 1287 switch (type) { | |
| 1288 case GL_UNSIGNED_BYTE: | |
| 1289 internal_format = GL_RGBA8; | |
| 1290 break; | |
| 1291 default: | |
| 1292 break; | |
| 1293 } | |
| 1294 break; | |
| 1295 case GL_SRGB_ALPHA_EXT: | |
| 1296 switch (type) { | |
| 1297 case GL_UNSIGNED_BYTE: | |
| 1298 internal_format = GL_SRGB8_ALPHA8; | |
| 1299 break; | |
| 1300 default: | |
| 1301 break; | |
| 1302 } | |
| 1303 break; | |
| 1304 default: | |
| 1305 break; | |
| 1306 } | |
| 1307 | |
| 1308 *r = 0; | |
| 1309 *g = 0; | |
| 1310 *b = 0; | |
| 1311 *a = 0; | |
| 1312 switch (internal_format) { | |
| 1313 case GL_RGB8_OES: | |
| 1314 case GL_SRGB8: | |
| 1315 case GL_RGB8_SNORM: | |
| 1316 case GL_RGB8UI: | |
| 1317 case GL_RGB8I: | |
| 1318 *r = 8; | |
| 1319 *g = 8; | |
| 1320 *b = 8; | |
| 1321 break; | |
| 1322 case GL_RGB565: | |
| 1323 *r = 5; | |
| 1324 *g = 6; | |
| 1325 *b = 5; | |
| 1326 break; | |
| 1327 case GL_RGB16F: | |
| 1328 case GL_RGB16UI: | |
| 1329 case GL_RGB16I: | |
| 1330 *r = 16; | |
| 1331 *g = 16; | |
| 1332 *b = 16; | |
| 1333 break; | |
| 1334 case GL_RGB32F: | |
| 1335 case GL_RGB32UI: | |
| 1336 case GL_RGB32I: | |
| 1337 *r = 32; | |
| 1338 *g = 32; | |
| 1339 *b = 32; | |
| 1340 break; | |
| 1341 case GL_R11F_G11F_B10F: | |
| 1342 *r = 11; | |
| 1343 *g = 11; | |
| 1344 *b = 10; | |
| 1345 break; | |
| 1346 case GL_RGB9_E5: | |
| 1347 *r = 9; | |
| 1348 *g = 9; | |
| 1349 *b = 9; | |
| 1350 break; | |
| 1351 case GL_BGRA8_EXT: | |
| 1352 case GL_RGBA8: | |
| 1353 case GL_SRGB8_ALPHA8: | |
| 1354 case GL_RGBA8_SNORM: | |
| 1355 case GL_RGBA8UI: | |
| 1356 case GL_RGBA8I: | |
| 1357 *r = 8; | |
| 1358 *g = 8; | |
| 1359 *b = 8; | |
| 1360 *a = 8; | |
| 1361 break; | |
| 1362 case GL_RGBA16F_EXT: | |
| 1363 case GL_RGBA16UI: | |
| 1364 case GL_RGBA16I: | |
| 1365 *r = 16; | |
| 1366 *g = 16; | |
| 1367 *b = 16; | |
| 1368 *a = 16; | |
| 1369 break; | |
| 1370 case GL_RGBA32F_EXT: | |
| 1371 case GL_RGBA32UI: | |
| 1372 case GL_RGBA32I: | |
| 1373 *r = 32; | |
| 1374 *g = 32; | |
| 1375 *b = 32; | |
| 1376 *a = 32; | |
| 1377 break; | |
| 1378 case GL_RGBA4: | |
| 1379 *r = 4; | |
| 1380 *g = 4; | |
| 1381 *b = 4; | |
| 1382 *a = 4; | |
| 1383 break; | |
| 1384 case GL_RGB5_A1: | |
| 1385 *r = 5; | |
| 1386 *g = 5; | |
| 1387 *b = 5; | |
| 1388 *a = 1; | |
| 1389 break; | |
| 1390 case GL_RGB10_A2: | |
| 1391 case GL_RGB10_A2UI: | |
| 1392 *r = 10; | |
| 1393 *g = 10; | |
| 1394 *b = 10; | |
| 1395 *a = 2; | |
| 1396 break; | |
| 1397 case GL_R8: | |
| 1398 case GL_R8_SNORM: | |
| 1399 case GL_R8UI: | |
| 1400 case GL_R8I: | |
| 1401 *r = 8; | |
| 1402 break; | |
| 1403 case GL_R16F: | |
| 1404 case GL_R16UI: | |
| 1405 case GL_R16I: | |
| 1406 *r = 16; | |
| 1407 break; | |
| 1408 case GL_R32F: | |
| 1409 case GL_R32UI: | |
| 1410 case GL_R32I: | |
| 1411 *r = 32; | |
| 1412 break; | |
| 1413 case GL_RG8: | |
| 1414 case GL_RG8_SNORM: | |
| 1415 case GL_RG8UI: | |
| 1416 case GL_RG8I: | |
| 1417 *r = 8; | |
| 1418 *g = 8; | |
| 1419 break; | |
| 1420 case GL_RG16F: | |
| 1421 case GL_RG16UI: | |
| 1422 case GL_RG16I: | |
| 1423 *r = 16; | |
| 1424 *g = 16; | |
| 1425 break; | |
| 1426 case GL_RG32F: | |
| 1427 case GL_RG32UI: | |
| 1428 case GL_RG32I: | |
| 1429 *r = 32; | |
| 1430 *g = 32; | |
| 1431 break; | |
| 1432 default: | |
| 1433 break; | |
| 1434 } | |
| 1435 } | |
| 1436 | |
| 1192 uint32_t GLES2Util::GetChannelsNeededForAttachmentType( | 1437 uint32_t GLES2Util::GetChannelsNeededForAttachmentType( |
| 1193 int type, | 1438 int type, |
| 1194 uint32_t max_color_attachments) { | 1439 uint32_t max_color_attachments) { |
| 1195 switch (type) { | 1440 switch (type) { |
| 1196 case GL_DEPTH_ATTACHMENT: | 1441 case GL_DEPTH_ATTACHMENT: |
| 1197 return kDepth; | 1442 return kDepth; |
| 1198 case GL_STENCIL_ATTACHMENT: | 1443 case GL_STENCIL_ATTACHMENT: |
| 1199 return kStencil; | 1444 return kStencil; |
| 1200 case GL_DEPTH_STENCIL_ATTACHMENT: | 1445 case GL_DEPTH_STENCIL_ATTACHMENT: |
| 1201 return kDepth | kStencil; | 1446 return kDepth | kStencil; |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1519 } | 1764 } |
| 1520 | 1765 |
| 1521 return true; | 1766 return true; |
| 1522 } | 1767 } |
| 1523 | 1768 |
| 1524 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 1769 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
| 1525 | 1770 |
| 1526 } // namespace gles2 | 1771 } // namespace gles2 |
| 1527 } // namespace gpu | 1772 } // namespace gpu |
| 1528 | 1773 |
| OLD | NEW |