Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: src/core/SkCanvas.cpp

Issue 473633002: SkTextBlob (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Alloc API + review comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
25 #include "SkTextFormatParams.h" 26 #include "SkTextFormatParams.h"
26 #include "SkTLazy.h" 27 #include "SkTLazy.h"
27 #include "SkUtils.h" 28 #include "SkUtils.h"
28 29
29 #if SK_SUPPORT_GPU 30 #if SK_SUPPORT_GPU
30 #include "GrRenderTarget.h" 31 #include "GrRenderTarget.h"
31 #endif 32 #endif
32 33
33 // experimental for faster tiled drawing... 34 // experimental for faster tiled drawing...
34 //#define SK_ENABLE_CLIP_QUICKREJECT 35 //#define SK_ENABLE_CLIP_QUICKREJECT
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) 2221 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
2221 2222
2222 while (iter.next()) { 2223 while (iter.next()) {
2223 iter.fDevice->drawTextOnPath(iter, text, byteLength, path, 2224 iter.fDevice->drawTextOnPath(iter, text, byteLength, path,
2224 matrix, looper.paint()); 2225 matrix, looper.paint());
2225 } 2226 }
2226 2227
2227 LOOPER_END 2228 LOOPER_END
2228 } 2229 }
2229 2230
2231 void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
2232 const SkPaint& paint) {
2233 SkASSERT(blob);
2234
2235 // FIXME: dispatch to the device instead
2236
2237 if (x || y) {
2238 this->translate(x, y);
2239 }
2240
2241 SkTextBlob::RunIterator it(blob);
2242 while (!it.done()) {
2243 size_t textLen = it.glyphCount() * sizeof(uint16_t);
2244 switch (it.positioning()) {
2245 case SkTextBlob::kDefault_Positioning:
2246 this->drawText(it.glyphs(), textLen, 0, 0, paint);
2247 break;
2248 case SkTextBlob::kHorizontal_Positioning:
2249 this->drawPosTextH(it.glyphs(), textLen, it.pos(), 0, paint);
2250 break;
2251 case SkTextBlob::kFull_Positioning:
2252 this->drawPosText(it.glyphs(), textLen, (const SkPoint*)it.pos(), pa int);
2253 break;
2254 default:
2255 SkFAIL("unhandled positioning mode");
2256 }
2257
2258 it.next();
2259 }
2260
2261 if (x || y) {
2262 this->translate(-x, -y);
2263 }
2264 }
2265
2230 // These will become non-virtual, so they always call the (virtual) onDraw... me thod 2266 // These will become non-virtual, so they always call the (virtual) onDraw... me thod
2231 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y, 2267 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y,
2232 const SkPaint& paint) { 2268 const SkPaint& paint) {
2233 this->onDrawText(text, byteLength, x, y, paint); 2269 this->onDrawText(text, byteLength, x, y, paint);
2234 } 2270 }
2235 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po s[], 2271 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po s[],
2236 const SkPaint& paint) { 2272 const SkPaint& paint) {
2237 this->onDrawPosText(text, byteLength, pos, paint); 2273 this->onDrawPosText(text, byteLength, pos, paint);
2238 } 2274 }
2239 void SkCanvas::drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], 2275 void SkCanvas::drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
2240 SkScalar constY, const SkPaint& paint) { 2276 SkScalar constY, const SkPaint& paint) {
2241 this->onDrawPosTextH(text, byteLength, xpos, constY, paint); 2277 this->onDrawPosTextH(text, byteLength, xpos, constY, paint);
2242 } 2278 }
2243 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 2279 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
2244 const SkMatrix* matrix, const SkPaint& paint) { 2280 const SkMatrix* matrix, const SkPaint& paint) {
2245 this->onDrawTextOnPath(text, byteLength, path, matrix, paint); 2281 this->onDrawTextOnPath(text, byteLength, path, matrix, paint);
2246 } 2282 }
2283 void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
2284 const SkPaint& paint) {
2285 if (NULL != blob) {
2286 this->onDrawTextBlob(blob, x, y, paint);
2287 }
2288 }
2247 2289
2248 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, 2290 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount,
2249 const SkPoint verts[], const SkPoint texs[], 2291 const SkPoint verts[], const SkPoint texs[],
2250 const SkColor colors[], SkXfermode* xmode, 2292 const SkColor colors[], SkXfermode* xmode,
2251 const uint16_t indices[], int indexCount, 2293 const uint16_t indices[], int indexCount,
2252 const SkPaint& paint) { 2294 const SkPaint& paint) {
2253 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL) 2295 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL)
2254 2296
2255 while (iter.next()) { 2297 while (iter.next()) {
2256 iter.fDevice->drawVertices(iter, vmode, vertexCount, verts, texs, 2298 iter.fDevice->drawVertices(iter, vmode, vertexCount, verts, texs,
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 } 2600 }
2559 2601
2560 if (NULL != matrix) { 2602 if (NULL != matrix) {
2561 canvas->concat(*matrix); 2603 canvas->concat(*matrix);
2562 } 2604 }
2563 } 2605 }
2564 2606
2565 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2607 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2566 fCanvas->restoreToCount(fSaveCount); 2608 fCanvas->restoreToCount(fSaveCount);
2567 } 2609 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698