Account for text alignment in Op bounds calculation

bug:8243821

Previously this wasn't done for deferred clipping + reordering, so
non-left-aligned text would be clipped at defer time, when it wouldn't
have been at draw time (in OpenGLRenderer::quickReject())

Change-Id: Ic96949c2dca4378f284606b37d9411ed42f8d203
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h
index 9db8fe8..9ecfb5a 100644
--- a/libs/hwui/DisplayListOp.h
+++ b/libs/hwui/DisplayListOp.h
@@ -1140,9 +1140,20 @@
             const float* positions, SkPaint* paint, float length)
             : DrawBoundedOp(paint), mText(text), mBytesCount(bytesCount), mCount(count),
             mX(x), mY(y), mPositions(positions), mLength(length) {
+        // duplicates bounds calculation from OpenGLRenderer::drawText, but doesn't alter mX
         SkPaint::FontMetrics metrics;
         paint->getFontMetrics(&metrics, 0.0f);
-        mLocalBounds.set(mX, mY + metrics.fTop, mX + length, mY + metrics.fBottom);
+        switch (paint->getTextAlign()) {
+        case SkPaint::kCenter_Align:
+            x -= length / 2.0f;
+            break;
+        case SkPaint::kRight_Align:
+            x -= length;
+            break;
+        default:
+            break;
+        }
+        mLocalBounds.set(x, mY + metrics.fTop, x + length, mY + metrics.fBottom);
     }
 
     virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,