(image, options)
| 693 | } |
| 694 | |
| 695 | function parseImage (image, options) { |
| 696 | var data = null |
| 697 | if (isPixelData(options)) { |
| 698 | data = options |
| 699 | } else if (options) { |
| 700 | check.type(options, 'object', 'invalid pixel data type') |
| 701 | parseFlags(image, options) |
| 702 | if ('x' in options) { |
| 703 | image.xOffset = options.x | 0 |
| 704 | } |
| 705 | if ('y' in options) { |
| 706 | image.yOffset = options.y | 0 |
| 707 | } |
| 708 | if (isPixelData(options.data)) { |
| 709 | data = options.data |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | check( |
| 714 | !image.compressed || |
| 715 | data instanceof Uint8Array, |
| 716 | 'compressed texture data must be stored in a uint8array') |
| 717 | |
| 718 | if (options.copy) { |
| 719 | check(!data, 'can not specify copy and data field for the same texture') |
| 720 | var viewW = contextState.viewportWidth |
| 721 | var viewH = contextState.viewportHeight |
| 722 | image.width = image.width || (viewW - image.xOffset) |
| 723 | image.height = image.height || (viewH - image.yOffset) |
| 724 | image.needsCopy = true |
| 725 | check(image.xOffset >= 0 && image.xOffset < viewW && |
| 726 | image.yOffset >= 0 && image.yOffset < viewH && |
| 727 | image.width > 0 && image.width <= viewW && |
| 728 | image.height > 0 && image.height <= viewH, |
| 729 | 'copy texture read out of bounds') |
| 730 | } else if (!data) { |
| 731 | image.width = image.width || 1 |
| 732 | image.height = image.height || 1 |
| 733 | image.channels = image.channels || 4 |
| 734 | } else if (isTypedArray(data)) { |
| 735 | image.channels = image.channels || 4 |
| 736 | image.data = data |
| 737 | if (!('type' in options) && image.type === GL_UNSIGNED_BYTE) { |
| 738 | image.type = typedArrayCode(data) |
| 739 | } |
| 740 | } else if (isNumericArray(data)) { |
| 741 | image.channels = image.channels || 4 |
| 742 | convertData(image, data) |
| 743 | image.alignment = 1 |
| 744 | image.needsFree = true |
| 745 | } else if (isNDArrayLike(data)) { |
| 746 | var array = data.data |
| 747 | if (!Array.isArray(array) && image.type === GL_UNSIGNED_BYTE) { |
| 748 | image.type = typedArrayCode(array) |
| 749 | } |
| 750 | var shape = data.shape |
| 751 | var stride = data.stride |
| 752 | var shapeX, shapeY, shapeC, strideX, strideY, strideC |
no test coverage detected
searching dependent graphs…