reference different display objects

Adafruit_SharpMem derives from Adafruit_GFX.

GxGDEP015OC1 derives from GxEPD which derives from Adafruit_GFX.

So, you can define your function to take a reference to a Adafruit_GFX object, and make it function for either class, as long as you do not need to use the features that make a Adafruit_SharpMem different from a Adafruit_GFX or the features that make a GxGDEP015OC1 different from a Adafruit_GFX.