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

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

Issue 473633002: SkTextBlob (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Consolidated blob constructor + 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 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2214 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) 2215 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
2215 2216
2216 while (iter.next()) { 2217 while (iter.next()) {
2217 iter.fDevice->drawTextOnPath(iter, text, byteLength, path, 2218 iter.fDevice->drawTextOnPath(iter, text, byteLength, path,
2218 matrix, looper.paint()); 2219 matrix, looper.paint());
2219 } 2220 }
2220 2221
2221 LOOPER_END 2222 LOOPER_END
2222 } 2223 }
2223 2224
2225 void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, const SkPoint& offset,
2226 const SkPaint& paint) {
2227 SkASSERT(blob);
2228
2229 // FIXME: should we send the offset to the device?
2230 if (!offset.isZero()) {
2231 translate(offset.x(), offset.y());
2232 }
2233
2234 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
2235
2236 while (iter.next()) {
2237 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint());
2238 iter.fDevice->drawTextBlob(iter, blob, dfp.paint());
2239 // DrawTextDecorations?
2240 }
2241
2242 LOOPER_END
2243
2244 if (!offset.isZero()) {
2245 translate(-offset.x(), -offset.y());
2246 }
2247 }
2248
2224 // These will become non-virtual, so they always call the (virtual) onDraw... me thod 2249 // These will become non-virtual, so they always call the (virtual) onDraw... me thod
2225 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y, 2250 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y,
2226 const SkPaint& paint) { 2251 const SkPaint& paint) {
2227 this->onDrawText(text, byteLength, x, y, paint); 2252 this->onDrawText(text, byteLength, x, y, paint);
2228 } 2253 }
2229 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po s[], 2254 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po s[],
2230 const SkPaint& paint) { 2255 const SkPaint& paint) {
2231 this->onDrawPosText(text, byteLength, pos, paint); 2256 this->onDrawPosText(text, byteLength, pos, paint);
2232 } 2257 }
2233 void SkCanvas::drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], 2258 void SkCanvas::drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
2234 SkScalar constY, const SkPaint& paint) { 2259 SkScalar constY, const SkPaint& paint) {
2235 this->onDrawPosTextH(text, byteLength, xpos, constY, paint); 2260 this->onDrawPosTextH(text, byteLength, xpos, constY, paint);
2236 } 2261 }
2237 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 2262 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
2238 const SkMatrix* matrix, const SkPaint& paint) { 2263 const SkMatrix* matrix, const SkPaint& paint) {
2239 this->onDrawTextOnPath(text, byteLength, path, matrix, paint); 2264 this->onDrawTextOnPath(text, byteLength, path, matrix, paint);
2240 } 2265 }
2241 2266
2267 void SkCanvas::drawTextBlob(const SkTextBlob* blob, const SkPoint& offset,
2268 const SkPaint& paint) {
2269 if (NULL != blob) {
2270 this->onDrawTextBlob(blob, offset, paint);
2271 }
2272 }
2273
2242 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, 2274 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount,
2243 const SkPoint verts[], const SkPoint texs[], 2275 const SkPoint verts[], const SkPoint texs[],
2244 const SkColor colors[], SkXfermode* xmode, 2276 const SkColor colors[], SkXfermode* xmode,
2245 const uint16_t indices[], int indexCount, 2277 const uint16_t indices[], int indexCount,
2246 const SkPaint& paint) { 2278 const SkPaint& paint) {
2247 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL) 2279 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL)
2248 2280
2249 while (iter.next()) { 2281 while (iter.next()) {
2250 iter.fDevice->drawVertices(iter, vmode, vertexCount, verts, texs, 2282 iter.fDevice->drawVertices(iter, vmode, vertexCount, verts, texs,
2251 colors, xmode, indices, indexCount, 2283 colors, xmode, indices, indexCount,
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 } 2584 }
2553 2585
2554 if (NULL != matrix) { 2586 if (NULL != matrix) {
2555 canvas->concat(*matrix); 2587 canvas->concat(*matrix);
2556 } 2588 }
2557 } 2589 }
2558 2590
2559 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2591 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2560 fCanvas->restoreToCount(fSaveCount); 2592 fCanvas->restoreToCount(fSaveCount);
2561 } 2593 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698