That was going to be a mercy killing, basically, to save him from what the invading forces would do to him--a pretty far cry from killing Joffrey so she could hold onto her influence. God knows, though, she likes being queen.
After the pie was sliced there was an extended shot of the open pie. Even before I got to the end and saw how it shook out, I rewound that weird, meaningful pie shot three times. I never did see anything, but it was a very peculiar shot.
I can't imagine it was Margaery--she looked too disgusted during various points of the celebration. If she knew he was going to die she would have been better able to maintain a pleasant expression, knowing he was going to get his ASAP.