| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
| 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 | 8 |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
| 11 #include "SkBitmapDevice.h" | 11 #include "SkBitmapDevice.h" |
| 12 #include "SkDeviceImageFilterProxy.h" | 12 #include "SkDeviceImageFilterProxy.h" |
| 13 #include "SkDraw.h" | 13 #include "SkDraw.h" |
| 14 #include "SkDrawFilter.h" | 14 #include "SkDrawFilter.h" |
| 15 #include "SkDrawLooper.h" | 15 #include "SkDrawLooper.h" |
| 16 #include "SkMetaData.h" | 16 #include "SkMetaData.h" |
| 17 #include "SkPathOps.h" | 17 #include "SkPathOps.h" |
| 18 #include "SkPatchUtils.h" | 18 #include "SkPatchUtils.h" |
| 19 #include "SkPicture.h" | 19 #include "SkPicture.h" |
| 20 #include "SkRasterClip.h" | 20 #include "SkRasterClip.h" |
| 21 #include "SkRRect.h" | 21 #include "SkRRect.h" |
| 22 #include "SkSmallAllocator.h" | 22 #include "SkSmallAllocator.h" |
| 23 #include "SkSurface_Base.h" | 23 #include "SkSurface_Base.h" |
| 24 #include "SkTemplates.h" | 24 #include "SkTemplates.h" |
| 25 #include "SkTextBlob.h" | |
| 26 #include "SkTextFormatParams.h" | 25 #include "SkTextFormatParams.h" |
| 27 #include "SkTLazy.h" | 26 #include "SkTLazy.h" |
| 28 #include "SkUtils.h" | 27 #include "SkUtils.h" |
| 29 | 28 |
| 30 #if SK_SUPPORT_GPU | 29 #if SK_SUPPORT_GPU |
| 31 #include "GrRenderTarget.h" | 30 #include "GrRenderTarget.h" |
| 32 #endif | 31 #endif |
| 33 | 32 |
| 34 // experimental for faster tiled drawing... | 33 // experimental for faster tiled drawing... |
| 35 //#define SK_ENABLE_CLIP_QUICKREJECT | 34 //#define SK_ENABLE_CLIP_QUICKREJECT |
| (...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2211 while (iter.next()) { | 2210 while (iter.next()) { |
| 2212 iter.fDevice->drawTextOnPath(iter, text, byteLength, path, | 2211 iter.fDevice->drawTextOnPath(iter, text, byteLength, path, |
| 2213 matrix, looper.paint()); | 2212 matrix, looper.paint()); |
| 2214 } | 2213 } |
| 2215 | 2214 |
| 2216 LOOPER_END | 2215 LOOPER_END |
| 2217 } | 2216 } |
| 2218 | 2217 |
| 2219 void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, | 2218 void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
| 2220 const SkPaint& paint) { | 2219 const SkPaint& paint) { |
| 2221 SkASSERT(blob); | 2220 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) |
| 2222 | 2221 |
| 2223 // FIXME: dispatch to the device instead | 2222 while (iter.next()) { |
| 2224 | 2223 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint()); |
| 2225 if (x || y) { | 2224 iter.fDevice->drawTextBlob(iter, blob, x, y, dfp.paint()); |
| 2226 this->translate(x, y); | |
| 2227 } | 2225 } |
| 2228 | 2226 |
| 2229 SkPaint runPaint = paint; | 2227 LOOPER_END |
| 2230 SkTextBlob::RunIterator it(blob); | |
| 2231 while (!it.done()) { | |
| 2232 size_t textLen = it.glyphCount() * sizeof(uint16_t); | |
| 2233 const SkPoint& offset = it.offset(); | |
| 2234 // applyFontToPaint() always overwrites the exact same attributes, | |
| 2235 // so it is safe to not re-seed the paint. | |
| 2236 it.applyFontToPaint(&runPaint); | |
| 2237 | |
| 2238 switch (it.positioning()) { | |
| 2239 case SkTextBlob::kDefault_Positioning: | |
| 2240 this->drawText(it.glyphs(), textLen, offset.x(), offset.y(), runPain
t); | |
| 2241 break; | |
| 2242 case SkTextBlob::kHorizontal_Positioning: | |
| 2243 this->drawPosTextH(it.glyphs(), textLen, it.pos(), offset.y(), runPa
int); | |
| 2244 break; | |
| 2245 case SkTextBlob::kFull_Positioning: | |
| 2246 this->drawPosText(it.glyphs(), textLen, (const SkPoint*)it.pos(), ru
nPaint); | |
| 2247 break; | |
| 2248 default: | |
| 2249 SkFAIL("unhandled positioning mode"); | |
| 2250 } | |
| 2251 | |
| 2252 it.next(); | |
| 2253 } | |
| 2254 | |
| 2255 if (x || y) { | |
| 2256 this->translate(-x, -y); | |
| 2257 } | |
| 2258 } | 2228 } |
| 2259 | 2229 |
| 2260 // These will become non-virtual, so they always call the (virtual) onDraw... me
thod | 2230 // These will become non-virtual, so they always call the (virtual) onDraw... me
thod |
| 2261 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala
r y, | 2231 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala
r y, |
| 2262 const SkPaint& paint) { | 2232 const SkPaint& paint) { |
| 2263 this->onDrawText(text, byteLength, x, y, paint); | 2233 this->onDrawText(text, byteLength, x, y, paint); |
| 2264 } | 2234 } |
| 2265 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po
s[], | 2235 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po
s[], |
| 2266 const SkPaint& paint) { | 2236 const SkPaint& paint) { |
| 2267 this->onDrawPosText(text, byteLength, pos, paint); | 2237 this->onDrawPosText(text, byteLength, pos, paint); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2594 } | 2564 } |
| 2595 | 2565 |
| 2596 if (NULL != matrix) { | 2566 if (NULL != matrix) { |
| 2597 canvas->concat(*matrix); | 2567 canvas->concat(*matrix); |
| 2598 } | 2568 } |
| 2599 } | 2569 } |
| 2600 | 2570 |
| 2601 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2571 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
| 2602 fCanvas->restoreToCount(fSaveCount); | 2572 fCanvas->restoreToCount(fSaveCount); |
| 2603 } | 2573 } |
| OLD | NEW |