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

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

Issue 473633002: SkTextBlob (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Build warnings fix. 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
« no previous file with comments | « include/core/SkTextBlob.h ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2208 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) 2209 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
2209 2210
2210 while (iter.next()) { 2211 while (iter.next()) {
2211 iter.fDevice->drawTextOnPath(iter, text, byteLength, path, 2212 iter.fDevice->drawTextOnPath(iter, text, byteLength, path,
2212 matrix, looper.paint()); 2213 matrix, looper.paint());
2213 } 2214 }
2214 2215
2215 LOOPER_END 2216 LOOPER_END
2216 } 2217 }
2217 2218
2219 void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
2220 const SkPaint& paint) {
2221 SkASSERT(blob);
2222
2223 // FIXME: dispatch to the device instead
2224
2225 if (x || y) {
2226 this->translate(x, y);
2227 }
2228
2229 SkTextBlob::RunIterator it(blob);
2230 while (!it.done()) {
2231 size_t textLen = it.glyphCount() * sizeof(uint16_t);
2232 const SkPoint& offset = it.offset();
2233
2234 switch (it.positioning()) {
2235 case SkTextBlob::kDefault_Positioning:
2236 this->drawText(it.glyphs(), textLen, offset.x(), offset.y(), paint);
2237 break;
2238 case SkTextBlob::kHorizontal_Positioning:
2239 this->drawPosTextH(it.glyphs(), textLen, it.pos(), offset.y(), paint );
2240 break;
2241 case SkTextBlob::kFull_Positioning:
2242 this->drawPosText(it.glyphs(), textLen, (const SkPoint*)it.pos(), pa int);
2243 break;
2244 default:
2245 SkFAIL("unhandled positioning mode");
2246 }
2247
2248 it.next();
2249 }
2250
2251 if (x || y) {
2252 this->translate(-x, -y);
2253 }
2254 }
2255
2218 // These will become non-virtual, so they always call the (virtual) onDraw... me thod 2256 // These will become non-virtual, so they always call the (virtual) onDraw... me thod
2219 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y, 2257 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y,
2220 const SkPaint& paint) { 2258 const SkPaint& paint) {
2221 this->onDrawText(text, byteLength, x, y, paint); 2259 this->onDrawText(text, byteLength, x, y, paint);
2222 } 2260 }
2223 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po s[], 2261 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po s[],
2224 const SkPaint& paint) { 2262 const SkPaint& paint) {
2225 this->onDrawPosText(text, byteLength, pos, paint); 2263 this->onDrawPosText(text, byteLength, pos, paint);
2226 } 2264 }
2227 void SkCanvas::drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], 2265 void SkCanvas::drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
2228 SkScalar constY, const SkPaint& paint) { 2266 SkScalar constY, const SkPaint& paint) {
2229 this->onDrawPosTextH(text, byteLength, xpos, constY, paint); 2267 this->onDrawPosTextH(text, byteLength, xpos, constY, paint);
2230 } 2268 }
2231 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 2269 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
2232 const SkMatrix* matrix, const SkPaint& paint) { 2270 const SkMatrix* matrix, const SkPaint& paint) {
2233 this->onDrawTextOnPath(text, byteLength, path, matrix, paint); 2271 this->onDrawTextOnPath(text, byteLength, path, matrix, paint);
2234 } 2272 }
2273 void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
2274 const SkPaint& paint) {
2275 if (NULL != blob) {
2276 this->onDrawTextBlob(blob, x, y, paint);
2277 }
2278 }
2235 2279
2236 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, 2280 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount,
2237 const SkPoint verts[], const SkPoint texs[], 2281 const SkPoint verts[], const SkPoint texs[],
2238 const SkColor colors[], SkXfermode* xmode, 2282 const SkColor colors[], SkXfermode* xmode,
2239 const uint16_t indices[], int indexCount, 2283 const uint16_t indices[], int indexCount,
2240 const SkPaint& paint) { 2284 const SkPaint& paint) {
2241 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL) 2285 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL)
2242 2286
2243 while (iter.next()) { 2287 while (iter.next()) {
2244 iter.fDevice->drawVertices(iter, vmode, vertexCount, verts, texs, 2288 iter.fDevice->drawVertices(iter, vmode, vertexCount, verts, texs,
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 } 2590 }
2547 2591
2548 if (NULL != matrix) { 2592 if (NULL != matrix) {
2549 canvas->concat(*matrix); 2593 canvas->concat(*matrix);
2550 } 2594 }
2551 } 2595 }
2552 2596
2553 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2597 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2554 fCanvas->restoreToCount(fSaveCount); 2598 fCanvas->restoreToCount(fSaveCount);
2555 } 2599 }
OLDNEW
« no previous file with comments | « include/core/SkTextBlob.h ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698