I can't make out 'ap' there, but I'm not very familiar with Welsh records so might not have recognised it.
What I think I can see for the middle name is Joan[ni]s, which would be Latin for 'of John'. It's quite a stylised signature, so the last part is tricky, but I think it could well be Gllm (for Gwillym etc).
Whether this is the same David John Gwillym who was vicar in 1614 can't be determined from this document alone, though the use of Latin would suggest someone educated. And a vicar would be the sort of person who might witness a document, but note that John Lewes called himself Clerke, and this one didn't.
Otherwise, do you have any idea when the vicar chap was born - in other words, was he of an age to be likely to be witnessing a document in 1585? And do you know when he became vicar there? If it was after 1585, might he nevertheless have been in the area some time earlier?