optimize get trim rect