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

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

Issue 248083002: Make drawText calls non-virtual, to ease SkFont and TextBlob (https://codereview.chromium.org/24385… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkBBoxRecord.cpp ('k') | src/core/SkPictureRecord.h » ('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 /* 2 /*
3 * Copyright 2008 The Android Open Source Project 3 * Copyright 2008 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 if (flags & SkPaint::kStrikeThruText_Flag) { 2349 if (flags & SkPaint::kStrikeThruText_Flag) {
2350 SkScalar offset = SkScalarMulAdd(textSize, kStdStrikeThru_Offset, 2350 SkScalar offset = SkScalarMulAdd(textSize, kStdStrikeThru_Offset,
2351 start.fY); 2351 start.fY);
2352 r.fTop = offset; 2352 r.fTop = offset;
2353 r.fBottom = offset + height; 2353 r.fBottom = offset + height;
2354 DrawRect(draw, paint, r, textSize); 2354 DrawRect(draw, paint, r, textSize);
2355 } 2355 }
2356 } 2356 }
2357 } 2357 }
2358 2358
2359 void SkCanvas::drawText(const void* text, size_t byteLength, 2359 void SkCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkSca lar y,
2360 SkScalar x, SkScalar y, const SkPaint& paint) { 2360 const SkPaint& paint) {
2361 CHECK_SHADER_NOSETCONTEXT(paint); 2361 CHECK_SHADER_NOSETCONTEXT(paint);
2362 2362
2363 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) 2363 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
2364 2364
2365 while (iter.next()) { 2365 while (iter.next()) {
2366 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint()); 2366 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint());
2367 iter.fDevice->drawText(iter, text, byteLength, x, y, dfp.paint()); 2367 iter.fDevice->drawText(iter, text, byteLength, x, y, dfp.paint());
2368 DrawTextDecorations(iter, dfp.paint(), 2368 DrawTextDecorations(iter, dfp.paint(),
2369 static_cast<const char*>(text), byteLength, x, y); 2369 static_cast<const char*>(text), byteLength, x, y);
2370 } 2370 }
2371 2371
2372 LOOPER_END 2372 LOOPER_END
2373 } 2373 }
2374 2374
2375 void SkCanvas::drawPosText(const void* text, size_t byteLength, 2375 void SkCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
2376 const SkPoint pos[], const SkPaint& paint) { 2376 const SkPaint& paint) {
2377 CHECK_SHADER_NOSETCONTEXT(paint); 2377 CHECK_SHADER_NOSETCONTEXT(paint);
2378 2378
2379 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) 2379 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
2380 2380
2381 while (iter.next()) { 2381 while (iter.next()) {
2382 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint()); 2382 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint());
2383 iter.fDevice->drawPosText(iter, text, byteLength, &pos->fX, 0, 2, 2383 iter.fDevice->drawPosText(iter, text, byteLength, &pos->fX, 0, 2,
2384 dfp.paint()); 2384 dfp.paint());
2385 } 2385 }
2386 2386
2387 LOOPER_END 2387 LOOPER_END
2388 } 2388 }
2389 2389
2390 void SkCanvas::drawPosTextH(const void* text, size_t byteLength, 2390 void SkCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScala r xpos[],
2391 const SkScalar xpos[], SkScalar constY, 2391 SkScalar constY, const SkPaint& paint) {
2392 const SkPaint& paint) {
2393 CHECK_SHADER_NOSETCONTEXT(paint); 2392 CHECK_SHADER_NOSETCONTEXT(paint);
2394 2393
2395 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) 2394 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
2396 2395
2397 while (iter.next()) { 2396 while (iter.next()) {
2398 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint()); 2397 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint());
2399 iter.fDevice->drawPosText(iter, text, byteLength, xpos, constY, 1, 2398 iter.fDevice->drawPosText(iter, text, byteLength, xpos, constY, 1,
2400 dfp.paint()); 2399 dfp.paint());
2401 } 2400 }
2402 2401
2403 LOOPER_END 2402 LOOPER_END
2404 } 2403 }
2405 2404
2406 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, 2405 void SkCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPat h& path,
2407 const SkPath& path, const SkMatrix* matrix, 2406 const SkMatrix* matrix, const SkPaint& paint) {
2408 const SkPaint& paint) {
2409 CHECK_SHADER_NOSETCONTEXT(paint); 2407 CHECK_SHADER_NOSETCONTEXT(paint);
2410 2408
2411 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) 2409 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
2412 2410
2413 while (iter.next()) { 2411 while (iter.next()) {
2414 iter.fDevice->drawTextOnPath(iter, text, byteLength, path, 2412 iter.fDevice->drawTextOnPath(iter, text, byteLength, path,
2415 matrix, looper.paint()); 2413 matrix, looper.paint());
2416 } 2414 }
2415
2416 LOOPER_END
2417 }
2417 2418
2418 LOOPER_END 2419 // These will become non-virtual, so they always call the (virtual) onDraw... me thod
2420 void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScala r y,
2421 const SkPaint& paint) {
2422 this->onDrawText(text, byteLength, x, y, paint);
2423 }
2424 void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint po s[],
2425 const SkPaint& paint) {
2426 this->onDrawPosText(text, byteLength, pos, paint);
2427 }
2428 void SkCanvas::drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
2429 SkScalar constY, const SkPaint& paint) {
2430 this->onDrawPosTextH(text, byteLength, xpos, constY, paint);
2431 }
2432 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
2433 const SkMatrix* matrix, const SkPaint& paint) {
2434 this->onDrawTextOnPath(text, byteLength, path, matrix, paint);
2419 } 2435 }
2420 2436
2421 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, 2437 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount,
2422 const SkPoint verts[], const SkPoint texs[], 2438 const SkPoint verts[], const SkPoint texs[],
2423 const SkColor colors[], SkXfermode* xmode, 2439 const SkColor colors[], SkXfermode* xmode,
2424 const uint16_t indices[], int indexCount, 2440 const uint16_t indices[], int indexCount,
2425 const SkPaint& paint) { 2441 const SkPaint& paint) {
2426 CHECK_SHADER_NOSETCONTEXT(paint); 2442 CHECK_SHADER_NOSETCONTEXT(paint);
2427 2443
2428 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL) 2444 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL)
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2667 if (!supported_for_raster_canvas(info)) { 2683 if (!supported_for_raster_canvas(info)) {
2668 return NULL; 2684 return NULL;
2669 } 2685 }
2670 2686
2671 SkBitmap bitmap; 2687 SkBitmap bitmap;
2672 if (!bitmap.installPixels(info, pixels, rowBytes)) { 2688 if (!bitmap.installPixels(info, pixels, rowBytes)) {
2673 return NULL; 2689 return NULL;
2674 } 2690 }
2675 return SkNEW_ARGS(SkCanvas, (bitmap)); 2691 return SkNEW_ARGS(SkCanvas, (bitmap));
2676 } 2692 }
OLDNEW
« no previous file with comments | « src/core/SkBBoxRecord.cpp ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698