There is a fundamental machlokes Rabbeinu Tam and Rivam quoted by tosafos regarding the exemption from ma'aser on produce that Reuven sold to Shimon.
Rabbeinu Tam holds that if Revuen processed the produce prior to selling and it became obligated in ma'aser and assumes a status of tevel, by selling it to Shimon the tevel status goes away and it is exempt once again. But if Reuven never processed it, when shimon does the processing he will be obligated in ma'aser m'doraysa becasue it is considered his own produce.
Rivam says exactly the opposite. If Reuven processed the produce prior to selling it, since it has become obligated in ma'aser and assumes a status of tevel, this status can not be removed. Therefore, when he sells it to Shimon, Shimon will have a Torah obligation to take ma'aser. But if reuven sold it to shimon prior to processing it and it was processed in the home of shimon, then it is patur from ma'aser.
When the produce was grown by a goy (assuming his kinyan in EY won't remove the chiyuv), the gemara says in bechoros 11b that if the goy processed them and then sold them to a jew, they are exempt from ma'aser, but if the jew processed them they are chayev. Rabbeinu Tam holds that if the produce was processed by the original farmer, it makes no difference if he were a jew or goy, the buyer (shimon) would be patur. But, if they weren't processed by the original farmer, the buyer would be chayev. The Rivam holds that when the original farmer was a goy, the halacha is exactly the opposite from when the original farmer would be a jew. A goy farmer who processes and sells would be patur since it was processed by the goy and remain patur even after it is sold. But if the goy farmer didn't process it, it is not considered his at all so that when he sells it to the jew and the jew processes it, it is chayev.
The greates difficulty with Rabbeinu Tam is that produce that is tevel can be sold and revert back to being exempt from ma'aser (and then if sold back to reuven would revert back to being chayev in ma'aser!). The greatest difficulty in the Rivam is that produce of a goy is not considered to be his unless he processed it, so that if sold to a jew, it is as if the jew grew it himself and is chayev in ma'aser.
Another hybrid approach (i think it is R' Chaim's approach in shitas ha'rambam) is that it is not dependent on who processed it, but rather what the intent was when it was processed. If Reuven processed it for personal use and it becomes chayev, nothing can remove that status of tevel (like Rivam). If Reuven did not process it rather he sold it to shimon who processed it then it is also chayev (like Rabbeinu Tam). Only if Reueven processed it with the intent of selling it to shimon, it will be patur.