I'm working with cocos2d-x 2.0.4. I illustrate what I am trying to do through these two images.

[![convex_poly](https://i.stack.imgur.com/bdjOu.png)](https://i.stack.imgur.com/bdjOu.png)
[![convex_poly_with_border](https://i.stack.imgur.com/PRGzI.png)](https://i.stack.imgur.com/PRGzI.png)

What i want to do is to create a blurred border or a border with a gradient on it programmatically. I have two ideas to do that but I'm not sure if it is the correct way to do. First solution would be to triangulate the polygon containing only the blurred color (concave polygon with a hole in this case) and rendering color on it with a gradient, vertices on the outside of the polygon would be full-alpha and vertices on the inside zero-alpha. The interpolation would do the job of gradient then.
Second solution would be to do it inside the shader itself. All I need is to calculate the distance from a pixel and the closest edge of the polygon to it. Then under a certain threshold I affect pixel white color with a certain alpha value depending on that distance (the shortest the distance is, the biggest alpha is).

Anyway I am very new to openGL stuff and I am afraid that the second solution will end up with big processing time as I have to calculate the distance for every pixel of the polygon. What do you think about this guys? Any ideas the tend to confirm my guesses or am I completely wrong on this?

EDIT:
The solution I finally chose was to use the bisector of every angle (easy to calculate with 3 consecutive vertices) in the polygon and take a point on that bisector that would become a vertex for the inner polygon. Then i take either a outer polygon vertex or a inner polygon vertex to build an array of vertices that can fit the GL\_TRIANGLE\_STRIP parameter. I put the image below to understand better.

[![expl](https://i.stack.imgur.com/DwOfV.png)](https://i.stack.imgur.com/DwOfV.png)