aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkDraw.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-23 21:30:47 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-23 21:30:47 +0000
commitcb6ccdde5120ec45df208c0b958b263d8252a505 (patch)
tree5dcec7195df0e5298ceede61c2de8072c0543eea /src/core/SkDraw.cpp
parent1f221a70214fa1ab87b8a32dd66facf485f318ee (diff)
respect subpixel positioning
git-svn-id: http://skia.googlecode.com/svn/trunk@2165 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkDraw.cpp')
-rw-r--r--src/core/SkDraw.cpp35
1 files changed, 8 insertions, 27 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index 12c8288055..8d7f9b5f60 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1438,24 +1438,6 @@ SkDraw1Glyph::Proc SkDraw1Glyph::init(const SkDraw* draw, SkBlitter* blitter,
}
}
-enum RoundBaseline {
- kDont_Round_Baseline,
- kRound_X_Baseline,
- kRound_Y_Baseline
-};
-
-static RoundBaseline computeRoundBaseline(const SkMatrix& mat) {
- if (mat[1] == 0 && mat[3] == 0) {
- // we're 0 or 180 degrees, round the y coordinate of the baseline
- return kRound_Y_Baseline;
- } else if (mat[0] == 0 && mat[4] == 0) {
- // we're 90 or 270 degrees, round the x coordinate of the baseline
- return kRound_X_Baseline;
- } else {
- return kDont_Round_Baseline;
- }
-}
-
///////////////////////////////////////////////////////////////////////////////
void SkDraw::drawText(const char text[], size_t byteLength,
@@ -1523,11 +1505,10 @@ void SkDraw::drawText(const char text[], size_t byteLength,
SkFixed fxMask = ~0;
SkFixed fyMask = ~0;
if (paint.isSubpixelText()) {
- RoundBaseline roundBaseline = computeRoundBaseline(*matrix);
- if (kRound_Y_Baseline == roundBaseline) {
+ SkAxisAlignment baseline = SkComputeAxisAlignmentForHText(*matrix);
+ if (kX_SkAxisAlignment == baseline) {
fyMask = 0;
-// fy = (fy + 0x8000) & ~0xFFFF;
- } else if (kRound_X_Baseline == roundBaseline) {
+ } else if (kY_SkAxisAlignment == baseline) {
fxMask = 0;
}
}
@@ -1698,7 +1679,7 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
if (paint.isSubpixelText()) {
// maybe we should skip the rounding if linearText is set
- RoundBaseline roundBaseline = computeRoundBaseline(*matrix);
+ SkAxisAlignment roundBaseline = SkComputeAxisAlignmentForHText(*matrix);
if (SkPaint::kLeft_Align == paint.getTextAlign()) {
while (text < stop) {
@@ -1710,9 +1691,9 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
SkFixed fxMask = ~0;
SkFixed fyMask = ~0;
- if (kRound_Y_Baseline == roundBaseline) {
+ if (kX_SkAxisAlignment == roundBaseline) {
fyMask = 0;
- } else if (kRound_X_Baseline == roundBaseline) {
+ } else if (kY_SkAxisAlignment == roundBaseline) {
fxMask = 0;
}
@@ -1743,9 +1724,9 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
fx = fixedLoc.fX;
fy = fixedLoc.fY;
- if (kRound_Y_Baseline == roundBaseline) {
+ if (kX_SkAxisAlignment == roundBaseline) {
fyMask = 0;
- } else if (kRound_X_Baseline == roundBaseline) {
+ } else if (kY_SkAxisAlignment == roundBaseline) {
fxMask = 0;
}
}