FliPer: A global measure of power density to estimate surface gravities of main-sequence solar-like stars and red giants