Core.Graphics: Convert DeviceLock into template class