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

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

Issue 473633002: SkTextBlob (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: SkRecord plumbing + partial blob bounds logic 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 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) 2216 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
2216 2217
2217 while (iter.next()) { 2218 while (iter.next()) {
2218 iter.fDevice->drawTextOnPath(iter, text, byteLength, path, 2219 iter.fDevice->drawTextOnPath(iter, text, byteLength, path,
2219 matrix, looper.paint()); 2220 matrix, looper.paint());
2220 } 2221 }
2221 2222
2222 LOOPER_END 2223 LOOPER_END
2223 } 2224 }
2224 2225
2226 void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
2227 const SkPaint& paint) {
2228 SkASSERT(blob);
2229
2230 // FIXME: dispatch to the device instead
2231
2232 if (x || y) {
2233 this->translate(x, y);
2234 }
2235
2236 for (unsigned i = 0; i < blob->runs(); ++i) {
2237 SkTextBlob::RunInfo runInfo = blob->runInfo(i);
2238 size_t textLen = runInfo.glyphCount * sizeof(uint16_t);
2239
2240 switch (runInfo.positioning) {
2241 case SkTextBlob::kDefault_Positioning:
2242 this->drawText(runInfo.glyphs, textLen, 0, 0, paint);
2243 break;
2244 case SkTextBlob::kHorizontal_Positioning:
2245 this->drawPosTextH(runInfo.glyphs, textLen, runInfo.pos, 0, paint);
2246 break;
2247 case SkTextBlob::kFull_Positioning:
2248 this->drawPosText(runInfo.glyphs, textLen, (const SkPoint*)runInfo.p os, paint);
2249 break;
2250 default:
2251 SkFAIL("unhandled positioning mode");
2252 }
2253 }
2254
2255 if (x || y) {
2256 this->translate(-x, -y);
2257 }
2258 }
2259
2225 // These will become non-virtual, so they always call the (virtual) onDraw... me thod 2260 // These will become non-virtual, so they always call the (virtual) onDraw... me thod
2226 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y, 2261 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y,
2227 const SkPaint& paint) { 2262 const SkPaint& paint) {
2228 this->onDrawText(text, byteLength, x, y, paint); 2263 this->onDrawText(text, byteLength, x, y, paint);
2229 } 2264 }
2230 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po s[], 2265 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po s[],
2231 const SkPaint& paint) { 2266 const SkPaint& paint) {
2232 this->onDrawPosText(text, byteLength, pos, paint); 2267 this->onDrawPosText(text, byteLength, pos, paint);
2233 } 2268 }
2234 void SkCanvas::drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], 2269 void SkCanvas::drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
2235 SkScalar constY, const SkPaint& paint) { 2270 SkScalar constY, const SkPaint& paint) {
2236 this->onDrawPosTextH(text, byteLength, xpos, constY, paint); 2271 this->onDrawPosTextH(text, byteLength, xpos, constY, paint);
2237 } 2272 }
2238 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 2273 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
2239 const SkMatrix* matrix, const SkPaint& paint) { 2274 const SkMatrix* matrix, const SkPaint& paint) {
2240 this->onDrawTextOnPath(text, byteLength, path, matrix, paint); 2275 this->onDrawTextOnPath(text, byteLength, path, matrix, paint);
2241 } 2276 }
2277 void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
2278 const SkPaint& paint) {
2279 if (NULL != blob) {
2280 this->onDrawTextBlob(blob, x, y, paint);
2281 }
2282 }
2242 2283
2243 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, 2284 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount,
2244 const SkPoint verts[], const SkPoint texs[], 2285 const SkPoint verts[], const SkPoint texs[],
2245 const SkColor colors[], SkXfermode* xmode, 2286 const SkColor colors[], SkXfermode* xmode,
2246 const uint16_t indices[], int indexCount, 2287 const uint16_t indices[], int indexCount,
2247 const SkPaint& paint) { 2288 const SkPaint& paint) {
2248 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL) 2289 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL)
2249 2290
2250 while (iter.next()) { 2291 while (iter.next()) {
2251 iter.fDevice->drawVertices(iter, vmode, vertexCount, verts, texs, 2292 iter.fDevice->drawVertices(iter, vmode, vertexCount, verts, texs,
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 } 2594 }
2554 2595
2555 if (NULL != matrix) { 2596 if (NULL != matrix) {
2556 canvas->concat(*matrix); 2597 canvas->concat(*matrix);
2557 } 2598 }
2558 } 2599 }
2559 2600
2560 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2601 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2561 fCanvas->restoreToCount(fSaveCount); 2602 fCanvas->restoreToCount(fSaveCount);
2562 } 2603 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698