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

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

Issue 247983003: Revert of make drawText calls non-virtual, to ease SkFont and TextBlob (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::onDrawText(const void* text, size_t byteLength, SkScalar x, SkSca lar y, 2359 void SkCanvas::drawText(const void* text, size_t byteLength,
2360 const SkPaint& paint) { 2360 SkScalar x, SkScalar y, 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::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], 2375 void SkCanvas::drawPosText(const void* text, size_t byteLength,
2376 const SkPaint& paint) { 2376 const SkPoint pos[], 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::onDrawPosTextH(const void* text, size_t byteLength, const SkScala r xpos[], 2390 void SkCanvas::drawPosTextH(const void* text, size_t byteLength,
2391 SkScalar constY, const SkPaint& paint) { 2391 const SkScalar xpos[], SkScalar constY,
2392 const SkPaint& paint) {
2392 CHECK_SHADER_NOSETCONTEXT(paint); 2393 CHECK_SHADER_NOSETCONTEXT(paint);
2393 2394
2394 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) 2395 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
2395 2396
2396 while (iter.next()) { 2397 while (iter.next()) {
2397 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint()); 2398 SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint());
2398 iter.fDevice->drawPosText(iter, text, byteLength, xpos, constY, 1, 2399 iter.fDevice->drawPosText(iter, text, byteLength, xpos, constY, 1,
2399 dfp.paint()); 2400 dfp.paint());
2400 } 2401 }
2401 2402
2402 LOOPER_END 2403 LOOPER_END
2403 } 2404 }
2404 2405
2405 void SkCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPat h& path, 2406 void SkCanvas::drawTextOnPath(const void* text, size_t byteLength,
2406 const SkMatrix* matrix, const SkPaint& paint) { 2407 const SkPath& path, const SkMatrix* matrix,
2408 const SkPaint& paint) {
2407 CHECK_SHADER_NOSETCONTEXT(paint); 2409 CHECK_SHADER_NOSETCONTEXT(paint);
2408 2410
2409 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL) 2411 LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
2410 2412
2411 while (iter.next()) { 2413 while (iter.next()) {
2412 iter.fDevice->drawTextOnPath(iter, text, byteLength, path, 2414 iter.fDevice->drawTextOnPath(iter, text, byteLength, path,
2413 matrix, looper.paint()); 2415 matrix, looper.paint());
2414 } 2416 }
2415 2417
2416 LOOPER_END 2418 LOOPER_END
2417 } 2419 }
2418 2420
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);
2435 }
2436
2437 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, 2421 void SkCanvas::drawVertices(VertexMode vmode, int vertexCount,
2438 const SkPoint verts[], const SkPoint texs[], 2422 const SkPoint verts[], const SkPoint texs[],
2439 const SkColor colors[], SkXfermode* xmode, 2423 const SkColor colors[], SkXfermode* xmode,
2440 const uint16_t indices[], int indexCount, 2424 const uint16_t indices[], int indexCount,
2441 const SkPaint& paint) { 2425 const SkPaint& paint) {
2442 CHECK_SHADER_NOSETCONTEXT(paint); 2426 CHECK_SHADER_NOSETCONTEXT(paint);
2443 2427
2444 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL) 2428 LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, NULL)
2445 2429
2446 while (iter.next()) { 2430 while (iter.next()) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2683 if (!supported_for_raster_canvas(info)) { 2667 if (!supported_for_raster_canvas(info)) {
2684 return NULL; 2668 return NULL;
2685 } 2669 }
2686 2670
2687 SkBitmap bitmap; 2671 SkBitmap bitmap;
2688 if (!bitmap.installPixels(info, pixels, rowBytes)) { 2672 if (!bitmap.installPixels(info, pixels, rowBytes)) {
2689 return NULL; 2673 return NULL;
2690 } 2674 }
2691 return SkNEW_ARGS(SkCanvas, (bitmap)); 2675 return SkNEW_ARGS(SkCanvas, (bitmap));
2692 } 2676 }
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