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

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

Issue 2130643004: drawTextRSXform (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update util canvases Created 4 years, 5 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 2011 Google Inc. 2 * Copyright 2011 Google Inc.
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 #include "SkColorFilter.h" 8 #include "SkColorFilter.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 m.postTranslate(xpos + hOffset, 0); 396 m.postTranslate(xpos + hOffset, 0);
397 if (matrix) { 397 if (matrix) {
398 m.postConcat(*matrix); 398 m.postConcat(*matrix);
399 } 399 }
400 morphpath(&tmp, *iterPath, meas, m); 400 morphpath(&tmp, *iterPath, meas, m);
401 this->drawPath(draw, tmp, iter.getPaint(), nullptr, true); 401 this->drawPath(draw, tmp, iter.getPaint(), nullptr, true);
402 } 402 }
403 } 403 }
404 } 404 }
405 405
406 #include "SkUtils.h"
407 typedef int (*CountTextProc)(const char* text);
408 static int count_utf16(const char* text) {
409 const uint16_t* prev = (uint16_t*)text;
410 (void)SkUTF16_NextUnichar(&prev);
411 return SkToInt((const char*)prev - text);
412 }
413 static int return_4(const char* text) { return 4; }
414 static int return_2(const char* text) { return 2; }
415
416 void SkBaseDevice::drawTextRSXform(const SkDraw& draw, const void* text, size_t len,
417 const SkRSXform xform[], const SkPaint& paint ) {
418 CountTextProc proc = nullptr;
419 switch (paint.getTextEncoding()) {
420 case SkPaint::kUTF8_TextEncoding:
421 proc = SkUTF8_CountUTF8Bytes;
422 break;
423 case SkPaint::kUTF16_TextEncoding:
424 proc = count_utf16;
425 break;
426 case SkPaint::kUTF32_TextEncoding:
427 proc = return_4;
428 break;
429 case SkPaint::kGlyphID_TextEncoding:
430 proc = return_2;
431 break;
432 }
433
434 SkDraw localD(draw);
435 SkMatrix localM, currM;
436 const void* stopText = (const char*)text + len;
437 while ((const char*)text < (const char*)stopText) {
438 localM.setRSXform(*xform++);
439 currM.setConcat(*draw.fMatrix, localM);
440 localD.fMatrix = &currM;
441 int subLen = proc((const char*)text);
442 this->drawText(localD, text, subLen, 0, 0, paint);
443 text = (const char*)text + subLen;
444 }
445 }
446
406 //////////////////////////////////////////////////////////////////////////////// ////////// 447 //////////////////////////////////////////////////////////////////////////////// //////////
407 448
408 void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitm ap, 449 void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitm ap,
409 int x, int y, 450 int x, int y,
410 const SkPaint& paint) { 451 const SkPaint& paint) {
411 SkImageFilter* filter = paint.getImageFilter(); 452 SkImageFilter* filter = paint.getImageFilter();
412 SkASSERT(filter); 453 SkASSERT(filter);
413 454
414 SkIPoint offset = SkIPoint::Make(0, 0); 455 SkIPoint offset = SkIPoint::Make(0, 0);
415 SkMatrix matrix = *draw.fMatrix; 456 SkMatrix matrix = *draw.fMatrix;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 544
504 // Also log filter quality independent scale factor. 545 // Also log filter quality independent scale factor.
505 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor, 546 SK_HISTOGRAM_ENUMERATION("DrawScaleFactor.AnyFilterQuality", scaleFactor,
506 kLast_ScaleFactor + 1); 547 kLast_ScaleFactor + 1);
507 548
508 // Also log an overall histogram of filter quality. 549 // Also log an overall histogram of filter quality.
509 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali ty + 1); 550 SK_HISTOGRAM_ENUMERATION("FilterQuality", filterQuality, kLast_SkFilterQuali ty + 1);
510 #endif 551 #endif
511 } 552 }
512 553
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698