OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkTextBlobRunIterator.h" | 8 #include "SkTextBlobRunIterator.h" |
9 | 9 |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
11 #include "SkTypeface.h" | 11 #include "SkTypeface.h" |
12 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 // TODO(fmalita): replace with SkFont. | 16 // TODO(fmalita): replace with SkFont. |
17 class RunFont : SkNoncopyable { | 17 class RunFont : SkNoncopyable { |
18 public: | 18 public: |
19 RunFont(const SkPaint& paint) | 19 RunFont(const SkPaint& paint) |
20 : fSize(paint.getTextSize()) | 20 : fSize(paint.getTextSize()) |
21 , fScaleX(paint.getTextScaleX()) | 21 , fScaleX(paint.getTextScaleX()) |
22 , fTypeface(SkSafeRef(paint.getTypeface())) | 22 , fTypeface(SkSafeRef(paint.getTypeface())) |
23 , fSkewX(paint.getTextSkewX()) | 23 , fSkewX(paint.getTextSkewX()) |
24 , fAlign(paint.getTextAlign()) | 24 , fAlign(paint.getTextAlign()) |
25 , fHinting(paint.getHinting()) | 25 , fHinting(paint.getHinting()) |
26 , fFlags(paint.getFlags() & kFlagsMask) { } | 26 , fFlags(paint.getFlags() & kFlagsMask) { } |
27 | 27 |
28 void applyToPaint(SkPaint* paint) const { | 28 void applyToPaint(SkPaint* paint) const { |
29 paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 29 paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
30 paint->setTypeface(fTypeface); | 30 paint->setTypeface(fTypeface.get()); |
31 paint->setTextSize(fSize); | 31 paint->setTextSize(fSize); |
32 paint->setTextScaleX(fScaleX); | 32 paint->setTextScaleX(fScaleX); |
33 paint->setTextSkewX(fSkewX); | 33 paint->setTextSkewX(fSkewX); |
34 paint->setTextAlign(static_cast<SkPaint::Align>(fAlign)); | 34 paint->setTextAlign(static_cast<SkPaint::Align>(fAlign)); |
35 paint->setHinting(static_cast<SkPaint::Hinting>(fHinting)); | 35 paint->setHinting(static_cast<SkPaint::Hinting>(fHinting)); |
36 | 36 |
37 paint->setFlags((paint->getFlags() & ~kFlagsMask) | fFlags); | 37 paint->setFlags((paint->getFlags() & ~kFlagsMask) | fFlags); |
38 } | 38 } |
39 | 39 |
40 bool operator==(const RunFont& other) const { | 40 bool operator==(const RunFont& other) const { |
(...skipping 25 matching lines...) Expand all Loading... |
66 SkPaint::kEmbeddedBitmapText_Flag | | 66 SkPaint::kEmbeddedBitmapText_Flag | |
67 SkPaint::kAutoHinting_Flag | | 67 SkPaint::kAutoHinting_Flag | |
68 SkPaint::kVerticalText_Flag | | 68 SkPaint::kVerticalText_Flag | |
69 SkPaint::kGenA8FromLCD_Flag; | 69 SkPaint::kGenA8FromLCD_Flag; |
70 | 70 |
71 SkScalar fSize; | 71 SkScalar fSize; |
72 SkScalar fScaleX; | 72 SkScalar fScaleX; |
73 | 73 |
74 // Keep this SkAutoTUnref off the first position, to avoid interfering with
SkNoncopyable | 74 // Keep this SkAutoTUnref off the first position, to avoid interfering with
SkNoncopyable |
75 // empty baseclass optimization (http://code.google.com/p/skia/issues/detail
?id=3694). | 75 // empty baseclass optimization (http://code.google.com/p/skia/issues/detail
?id=3694). |
76 sk_sp<SkTypeface> fTypeface; | 76 SkAutoTUnref<SkTypeface> fTypeface; |
77 SkScalar fSkewX; | 77 SkScalar fSkewX; |
78 | 78 |
79 static_assert(SkPaint::kAlignCount < 4, "insufficient_align_bits"); | 79 static_assert(SkPaint::kAlignCount < 4, "insufficient_align_bits"); |
80 uint32_t fAlign : 2; | 80 uint32_t fAlign : 2; |
81 static_assert(SkPaint::kFull_Hinting < 4, "insufficient_hinting_bits"); | 81 static_assert(SkPaint::kFull_Hinting < 4, "insufficient_hinting_bits"); |
82 uint32_t fHinting : 2; | 82 uint32_t fHinting : 2; |
83 static_assert((kFlagsMask & 0xffff) == kFlagsMask, "insufficient_flags_bits"
); | 83 static_assert((kFlagsMask & 0xffff) == kFlagsMask, "insufficient_flags_bits"
); |
84 uint32_t fFlags : 16; | 84 uint32_t fFlags : 16; |
85 | 85 |
86 typedef SkNoncopyable INHERITED; | 86 typedef SkNoncopyable INHERITED; |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 ) | 639 ) |
640 | 640 |
641 fStorageUsed = 0; | 641 fStorageUsed = 0; |
642 fStorageSize = 0; | 642 fStorageSize = 0; |
643 fRunCount = 0; | 643 fRunCount = 0; |
644 fLastRun = 0; | 644 fLastRun = 0; |
645 fBounds.setEmpty(); | 645 fBounds.setEmpty(); |
646 | 646 |
647 return blob; | 647 return blob; |
648 } | 648 } |
OLD | NEW |