| 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 uint32 bytes_per_group = ComputeImageGroupSize(format, type); | 535 uint32 bytes_per_group = ComputeImageGroupSize(format, type); |
| 536 return ComputeImageRowSizeHelper( | 536 return ComputeImageRowSizeHelper( |
| 537 width, bytes_per_group, alignment, nullptr, padded_row_size); | 537 width, bytes_per_group, alignment, nullptr, padded_row_size); |
| 538 } | 538 } |
| 539 | 539 |
| 540 // Returns the amount of data glTexImage*D or glTexSubImage*D will access. | 540 // Returns the amount of data glTexImage*D or glTexSubImage*D will access. |
| 541 bool GLES2Util::ComputeImageDataSizes( | 541 bool GLES2Util::ComputeImageDataSizes( |
| 542 int width, int height, int depth, int format, int type, | 542 int width, int height, int depth, int format, int type, |
| 543 int alignment, uint32* size, uint32* opt_unpadded_row_size, | 543 int alignment, uint32* size, uint32* opt_unpadded_row_size, |
| 544 uint32* opt_padded_row_size) { | 544 uint32* opt_padded_row_size) { |
| 545 DCHECK(width >= 0 && height >= 0 && depth >= 0); | 545 PixelStoreParams params; |
| 546 | 546 params.alignment = alignment; |
| 547 uint32 bytes_per_group = ComputeImageGroupSize(format, type); | 547 return ComputeImageDataSizesES3( |
| 548 | 548 width, height, depth, format, type, params, |
| 549 uint32 unpadded_row_size; | 549 size, opt_unpadded_row_size, opt_padded_row_size, nullptr); |
| 550 uint32 padded_row_size; | |
| 551 if (!ComputeImageRowSizeHelper(width, bytes_per_group, alignment, | |
| 552 &unpadded_row_size, &padded_row_size)) { | |
| 553 return false; | |
| 554 } | |
| 555 uint32 num_of_rows; | |
| 556 if (!SafeMultiplyUint32(height, depth, &num_of_rows)) { | |
| 557 return false; | |
| 558 } | |
| 559 if (num_of_rows > 0) { | |
| 560 uint32 size_of_all_but_last_row; | |
| 561 if (!SafeMultiplyUint32((num_of_rows - 1), padded_row_size, | |
| 562 &size_of_all_but_last_row)) { | |
| 563 return false; | |
| 564 } | |
| 565 if (!SafeAddUint32(size_of_all_but_last_row, unpadded_row_size, size)) { | |
| 566 return false; | |
| 567 } | |
| 568 } else { | |
| 569 *size = 0; | |
| 570 } | |
| 571 if (opt_padded_row_size) { | |
| 572 *opt_padded_row_size = padded_row_size; | |
| 573 } | |
| 574 if (opt_unpadded_row_size) { | |
| 575 *opt_unpadded_row_size = unpadded_row_size; | |
| 576 } | |
| 577 | |
| 578 return true; | |
| 579 } | 550 } |
| 580 | 551 |
| 581 bool GLES2Util::ComputeImageDataSizesES3( | 552 bool GLES2Util::ComputeImageDataSizesES3( |
| 582 int width, int height, int depth, int format, int type, | 553 int width, int height, int depth, int format, int type, |
| 583 const PixelStoreParams& params, | 554 const PixelStoreParams& params, |
| 584 uint32_t* size, uint32_t* opt_unpadded_row_size, | 555 uint32_t* size, uint32_t* opt_unpadded_row_size, |
| 585 uint32_t* opt_padded_row_size, uint32_t* opt_skip_size) { | 556 uint32_t* opt_padded_row_size, uint32_t* opt_skip_size) { |
| 586 DCHECK(width >= 0 && height >= 0 && depth >= 0); | 557 DCHECK(width >= 0 && height >= 0 && depth >= 0); |
| 587 | 558 |
| 588 uint32 bytes_per_group = ComputeImageGroupSize(format, type); | 559 uint32 bytes_per_group = ComputeImageGroupSize(format, type); |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 } | 1488 } |
| 1518 | 1489 |
| 1519 return true; | 1490 return true; |
| 1520 } | 1491 } |
| 1521 | 1492 |
| 1522 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" | 1493 #include "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h" |
| 1523 | 1494 |
| 1524 } // namespace gles2 | 1495 } // namespace gles2 |
| 1525 } // namespace gpu | 1496 } // namespace gpu |
| 1526 | 1497 |
| OLD | NEW |