Example 2 (2002 National High School Competition Question) The range of negative values of $a$ for which the inequality $\sin ^{2} x+a \cos x+a^{2} \geqslant 1+\cos x$ holds for all $x \in \mathbf{R}$ is $\qquad$ .
Solve: Fill in $a \leqslant-2$. Reason: The original inequality can be transformed into $\left(\cos x-\frac{a-1}{2}\right)^{2} \leqslant a^{2}+\frac{(a-1)^{2}}{4}$. Since $-1 \leqslant \cos x \leqslant 1, a<0, \frac{a-1}{2}<0$, when $\cos x=1$, the function $y=\left(\cos x-\frac{a-1}{2}\right)^{2}$ has a maximum value $\left(1-\frac{a-1}{2}\right)^{2}$, so it should be that $\left(1-\frac{a-1}{2}\right)^{2} \leqslant a^{2}+\frac{(a-1)^{2}}{4}$, simplifying gives $a^{2}+a-2 \geqslant 0$, solving yields $a \geqslant 1$ or $a \leqslant-2$. Since $a<0$, therefore $a \leqslant-2$.