| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkDevice.h" | 8 #include "SkDevice.h" |
| 9 #include "SkDeviceProperties.h" | 9 #include "SkDeviceProperties.h" |
| 10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 SkPaint runPaint = paint; | 123 SkPaint runPaint = paint; |
| 124 | 124 |
| 125 SkTextBlob::RunIterator it(blob); | 125 SkTextBlob::RunIterator it(blob); |
| 126 while (!it.done()) { | 126 while (!it.done()) { |
| 127 size_t textLen = it.glyphCount() * sizeof(uint16_t); | 127 size_t textLen = it.glyphCount() * sizeof(uint16_t); |
| 128 const SkPoint& offset = it.offset(); | 128 const SkPoint& offset = it.offset(); |
| 129 // applyFontToPaint() always overwrites the exact same attributes, | 129 // applyFontToPaint() always overwrites the exact same attributes, |
| 130 // so it is safe to not re-seed the paint. | 130 // so it is safe to not re-seed the paint. |
| 131 it.applyFontToPaint(&runPaint); | 131 it.applyFontToPaint(&runPaint); |
| 132 runPaint.setFlags(this->filterTextFlags(runPaint)); |
| 132 | 133 |
| 133 switch (it.positioning()) { | 134 switch (it.positioning()) { |
| 134 case SkTextBlob::kDefault_Positioning: | 135 case SkTextBlob::kDefault_Positioning: |
| 135 this->drawText(draw, it.glyphs(), textLen, x + offset.x(), y + offse
t.y(), runPaint); | 136 this->drawText(draw, it.glyphs(), textLen, x + offset.x(), y + offse
t.y(), runPaint); |
| 136 break; | 137 break; |
| 137 case SkTextBlob::kHorizontal_Positioning: | 138 case SkTextBlob::kHorizontal_Positioning: |
| 138 this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 1, | 139 this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 1, |
| 139 SkPoint::Make(x, y + offset.y()), runPaint); | 140 SkPoint::Make(x, y + offset.y()), runPaint); |
| 140 break; | 141 break; |
| 141 case SkTextBlob::kFull_Positioning: | 142 case SkTextBlob::kFull_Positioning: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 205 } |
| 205 | 206 |
| 206 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S
kMatrix*, | 207 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S
kMatrix*, |
| 207 const SkPaint*) { | 208 const SkPaint*) { |
| 208 // The base class doesn't perform any accelerated picture rendering | 209 // The base class doesn't perform any accelerated picture rendering |
| 209 return false; | 210 return false; |
| 210 } | 211 } |
| 211 | 212 |
| 212 ////////////////////////////////////////////////////////////////////////////////
////////// | 213 ////////////////////////////////////////////////////////////////////////////////
////////// |
| 213 | 214 |
| 214 bool SkBaseDevice::shouldDisableLCD(const SkPaint& paint) const { | 215 uint32_t SkBaseDevice::filterTextFlags(const SkPaint& paint) const { |
| 216 uint32_t flags = paint.getFlags(); |
| 217 |
| 215 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { | 218 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { |
| 216 return false; | 219 return flags; |
| 217 } | 220 } |
| 218 | 221 |
| 219 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry()) { | 222 if (kUnknown_SkPixelGeometry == fLeakyProperties->pixelGeometry() |
| 220 return true; | 223 || this->onShouldDisableLCD(paint)) { |
| 224 |
| 225 flags &= ~SkPaint::kLCDRenderText_Flag; |
| 226 flags |= SkPaint::kGenA8FromLCD_Flag; |
| 221 } | 227 } |
| 222 | 228 |
| 223 return this->onShouldDisableLCD(paint); | 229 return flags; |
| 224 } | 230 } |
| 225 | 231 |
| OLD | NEW |