OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "skia/ext/vector_platform_device_emf_win.h" | 5 #include "skia/ext/vector_platform_device_emf_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 } | 503 } |
504 | 504 |
505 static size_t size_glyphid(const char* text) { | 505 static size_t size_glyphid(const char* text) { |
506 return 2; | 506 return 2; |
507 } | 507 } |
508 | 508 |
509 void VectorPlatformDeviceEmf::drawPosText(const SkDraw& draw, | 509 void VectorPlatformDeviceEmf::drawPosText(const SkDraw& draw, |
510 const void* text, | 510 const void* text, |
511 size_t len, | 511 size_t len, |
512 const SkScalar pos[], | 512 const SkScalar pos[], |
513 SkScalar constY, | |
514 int scalarsPerPos, | 513 int scalarsPerPos, |
| 514 const SkPoint& offset, |
515 const SkPaint& paint) { | 515 const SkPaint& paint) { |
516 SkGDIFontSetup setup; | 516 SkGDIFontSetup setup; |
517 bool useDrawText = true; | 517 bool useDrawText = true; |
518 | 518 |
519 if (scalarsPerPos == 2 && len >= 2 && | 519 if (scalarsPerPos == 2 && len >= 2 && |
520 SkPaint::kUTF8_TextEncoding != paint.getTextEncoding() && | 520 SkPaint::kUTF8_TextEncoding != paint.getTextEncoding() && |
521 setup.useGDI(hdc_, paint)) { | 521 setup.useGDI(hdc_, paint)) { |
522 int startX = SkScalarRoundToInt(pos[0]); | 522 int startX = SkScalarRoundToInt(pos[0] + offset.x()); |
523 int startY = SkScalarRoundToInt(pos[1] + getAscent(paint)); | 523 int startY = SkScalarRoundToInt(pos[1] + offset.y() + getAscent(paint)); |
524 const int count = len >> 1; | 524 const int count = len >> 1; |
525 SkAutoSTMalloc<64, INT> storage(count); | 525 SkAutoSTMalloc<64, INT> storage(count); |
526 INT* advances = storage.get(); | 526 INT* advances = storage.get(); |
527 for (int i = 0; i < count - 1; ++i) { | 527 for (int i = 0; i < count - 1; ++i) { |
528 advances[i] = SkScalarRoundToInt(pos[2] - pos[0]); | 528 advances[i] = SkScalarRoundToInt(pos[2] - pos[0]); |
529 pos += 2; | 529 pos += 2; |
530 } | 530 } |
531 advances[count - 1] = 0; | 531 advances[count - 1] = 0; |
532 useDrawText = !EnsureExtTextOut(hdc_, startX, startY, | 532 useDrawText = !EnsureExtTextOut(hdc_, startX, startY, |
533 getTextOutOptions(paint), 0, reinterpret_cast<const wchar_t*>(text), | 533 getTextOutOptions(paint), 0, reinterpret_cast<const wchar_t*>(text), |
(...skipping 11 matching lines...) Expand all Loading... |
545 break; | 545 break; |
546 default: | 546 default: |
547 SkASSERT(SkPaint::kGlyphID_TextEncoding == paint.getTextEncoding()); | 547 SkASSERT(SkPaint::kGlyphID_TextEncoding == paint.getTextEncoding()); |
548 bytesPerCodePoint = size_glyphid; | 548 bytesPerCodePoint = size_glyphid; |
549 break; | 549 break; |
550 } | 550 } |
551 | 551 |
552 const char* curr = reinterpret_cast<const char*>(text); | 552 const char* curr = reinterpret_cast<const char*>(text); |
553 const char* stop = curr + len; | 553 const char* stop = curr + len; |
554 while (curr < stop) { | 554 while (curr < stop) { |
555 SkScalar y = (1 == scalarsPerPos) ? constY : pos[1]; | 555 SkScalar x = offset.x() + pos[0]; |
| 556 SkScalar y = offset.y() + (2 == scalarsPerPos ? pos[1] : 0); |
| 557 |
556 size_t bytes = bytesPerCodePoint(curr); | 558 size_t bytes = bytesPerCodePoint(curr); |
557 drawText(draw, curr, bytes, pos[0], y, paint); | 559 drawText(draw, curr, bytes, x, y, paint); |
558 curr += bytes; | 560 curr += bytes; |
559 pos += scalarsPerPos; | 561 pos += scalarsPerPos; |
560 } | 562 } |
561 } | 563 } |
562 } | 564 } |
563 | 565 |
564 void VectorPlatformDeviceEmf::drawTextOnPath(const SkDraw& draw, | 566 void VectorPlatformDeviceEmf::drawTextOnPath(const SkDraw& draw, |
565 const void* text, | 567 const void* text, |
566 size_t len, | 568 size_t len, |
567 const SkPath& path, | 569 const SkPath& path, |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 pixels, | 979 pixels, |
978 reinterpret_cast<const BITMAPINFO*>(&hdr), | 980 reinterpret_cast<const BITMAPINFO*>(&hdr), |
979 DIB_RGB_COLORS, | 981 DIB_RGB_COLORS, |
980 SRCCOPY); | 982 SRCCOPY); |
981 } | 983 } |
982 EndPlatformPaint(); | 984 EndPlatformPaint(); |
983 Cleanup(); | 985 Cleanup(); |
984 } | 986 } |
985 | 987 |
986 } // namespace skia | 988 } // namespace skia |
OLD | NEW |