The police officer who arrested ex-LA Lakers star Matt Barnes waited in an alley for 2 hours ... waited for Barnes to exit a restaurant, and then charged the b-baller with felony resisting arrest -- even though Barnes never got physically violent ... law enforcement sources tell TMZ.

Barnes had a warrant out for his arrest for failing to appear on a ticket for driving on a suspended license. Sources say Barnes had gone to the DMV, gotten his license reinstated, and mistakenly believed he no longer had to go to court to clear the ticket.

Now here's where it gets strange. Our law enforcement sources say the arresting officer KNEW Barnes had an outstanding warrant as he watched the NBA forward and his baby mama park their car in a lot Monday night -- and walk a block-and-a-half to MB Post, a popular restaurant in Manhattan Beach, CA -- yet the cop did not approach the hoopster. Instead the officer waited in an alley near the car.

The TMZ report goes on to mention that the officer declined to arrest Barnes 15 minutes after he entered the restaurant, when Barnes passed by the officer on his way to retrieve something from his car. And that the police officer waited a full two hours before pouncing on Barnes a few minutes after he left the restaurant, and a few minutes into an autograph session with fans.

TMZ's "law enforcement sources" also note that Barnes wasn't told why he was being arrested, and though he lobbed a few curse words at the officer, that those words weren't the reason he was cited for allegedly resisting arrest.

Though verbal threats can be used as a reason to site someone for resisting arrest, the police report mentioned something physical as being the basis for the resisting arrest charge. According to TMZ that physical bit was merely Barnes handing his car keys to his girlfriend (a person that TMZ, always classy, refers to as a "chick," "baby mama," and "gf" in their report) so she could get home without Matt.

This report is entirely plausible, and we're clearly leaning toward believing this alleged behavior over the police's report of Barnes' alleged behavior. We've seen both sides act boorish, though, before.

The bottom line? Ask those DMV helpers as many questions as you can, we suppose. They're there to help, people. At reasonable hours, too.