  Searching for the signal of primordial gravitational waves in the B-modes
(BB) power spectrum is one of the key scientific aims of the cosmic microwave
background (CMB) polarization experiments. However, this could be easily
contaminated by several foreground issues, such as the thermal dust emission.
In this paper we study another mechanism, the cosmic birefringence, which can
be introduced by a CPT-violating interaction between CMB photons and an
external scalar field. Such kind of interaction could give rise to the rotation
of the linear polarization state of CMB photons, and consequently induce the
CMB BB power spectrum, which could mimic the signal of primordial gravitational
waves at large scales. With the recent polarization data of BICEP2 and the
joint analysis data of BICEP2/Keck Array and Planck, we perform a global
fitting analysis on constraining the tensor-to-scalar ratio $r$ by considering
the polarization rotation angle which can be separated into a background
isotropic part and a small anisotropic part. Since the data of BICEP2 and Keck
Array experiments have already been corrected by using the "self-calibration"
method, here we mainly focus on the effects from the anisotropies of CMB
polarization rotation angle. We find that including the anisotropies in the
analysis could slightly weaken the constraints on $r$, when using current CMB
polarization measurements. We also simulate the mock CMB data with the
BICEP3-like sensitivity. Very interestingly, we find that if the effects of the
anisotropic polarization rotation angle can not be taken into account properly
in the analysis, the constraints on $r$ will be dramatically biased. This
implies that we need to break the degeneracy between the anisotropies of the
CMB polarization rotation angle and the CMB primordial tensor perturbations, in
order to measure the signal of primordial gravitational waves accurately.
