Merge "hwc: Move resource checks to a common function."