bool
WebGLContext::ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
                                               uint8_t setterCols,
                                               uint8_t setterRows,
                                               GLenum setterType,
                                               size_t setterArraySize,
                                               bool setterTranspose,
                                               const char* funcName,
                                               GLuint* const out_rawLoc,
                                               GLsizei* const out_numElementsToUpload)
{
    uint8_t setterElemSize = setterCols * setterRows;

    if (IsContextLost())
        return false;

    if (!ValidateUniformLocation(loc, funcName))
        return false;

    if (!loc->ValidateSizeAndType(setterElemSize, setterType, this, funcName))
        return false;

    if (!loc->ValidateArrayLength(setterElemSize, setterArraySize, this, funcName))
        return false;

    if (!ValidateUniformMatrixTranspose(setterTranspose, funcName))
        return false;

    *out_rawLoc = loc->mLoc;
    *out_numElementsToUpload = std::min((size_t)loc->mActiveInfo->mElemCount,
                                        setterArraySize / setterElemSize);
    return true;
}
bool
WebGLContext::ValidateUniformArraySetter(WebGLUniformLocation* loc,
                                         uint8_t setterElemSize,
                                         GLenum setterType,
                                         size_t setterArraySize,
                                         const char* funcName,
                                         GLuint* const out_rawLoc,
                                         GLsizei* const out_numElementsToUpload)
{
    if (IsContextLost())
        return false;

    if (!ValidateUniformLocation(loc, funcName))
        return false;

    if (!loc->ValidateSizeAndType(setterElemSize, setterType, this, funcName))
        return false;

    if (!loc->ValidateArrayLength(setterElemSize, setterArraySize, this, funcName))
        return false;

    MOZ_ASSERT((size_t)loc->mActiveInfo->mElemCount > loc->mArrayIndex);
    size_t uniformElemCount = loc->mActiveInfo->mElemCount - loc->mArrayIndex;
    *out_rawLoc = loc->mLoc;
    *out_numElementsToUpload = std::min(uniformElemCount, setterArraySize / setterElemSize);
    return true;
}
bool
WebGLContext::ValidateUniformSetter(WebGLUniformLocation* loc,
                                    uint8_t setterElemSize, GLenum setterType,
                                    const char* funcName, GLuint* out_rawLoc)
{
    if (IsContextLost())
        return false;

    if (!ValidateUniformLocation(loc, funcName))
        return false;

    if (!loc->ValidateSizeAndType(setterElemSize, setterType, this, funcName))
        return false;

    *out_rawLoc = loc->mLoc;
    return true;
}