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

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

Issue 1447403003: SkTextBlob should store per-run text alignment (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | tests/TextBlobTest.cpp » ('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 * 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 , fHinting(paint.getHinting()) 25 , fHinting(paint.getHinting())
25 , fFlags(paint.getFlags() & kFlagsMask) { } 26 , fFlags(paint.getFlags() & kFlagsMask) { }
26 27
27 void applyToPaint(SkPaint* paint) const { 28 void applyToPaint(SkPaint* paint) const {
28 paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding); 29 paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding);
29 paint->setTypeface(fTypeface.get()); 30 paint->setTypeface(fTypeface.get());
30 paint->setTextSize(fSize); 31 paint->setTextSize(fSize);
31 paint->setTextScaleX(fScaleX); 32 paint->setTextScaleX(fScaleX);
32 paint->setTextSkewX(fSkewX); 33 paint->setTextSkewX(fSkewX);
34 paint->setTextAlign(static_cast<SkPaint::Align>(fAlign));
33 paint->setHinting(static_cast<SkPaint::Hinting>(fHinting)); 35 paint->setHinting(static_cast<SkPaint::Hinting>(fHinting));
34 36
35 paint->setFlags((paint->getFlags() & ~kFlagsMask) | fFlags); 37 paint->setFlags((paint->getFlags() & ~kFlagsMask) | fFlags);
36 } 38 }
37 39
38 bool operator==(const RunFont& other) const { 40 bool operator==(const RunFont& other) const {
39 return fTypeface == other.fTypeface 41 return fTypeface == other.fTypeface
40 && fSize == other.fSize 42 && fSize == other.fSize
41 && fScaleX == other.fScaleX 43 && fScaleX == other.fScaleX
42 && fSkewX == other.fSkewX 44 && fSkewX == other.fSkewX
45 && fAlign == other.fAlign
43 && fHinting == other.fHinting 46 && fHinting == other.fHinting
44 && fFlags == other.fFlags; 47 && fFlags == other.fFlags;
45 } 48 }
46 49
47 bool operator!=(const RunFont& other) const { 50 bool operator!=(const RunFont& other) const {
48 return !(*this == other); 51 return !(*this == other);
49 } 52 }
50 53
51 uint32_t flags() const { return fFlags; } 54 uint32_t flags() const { return fFlags; }
52 55
(...skipping 13 matching lines...) Expand all
66 SkPaint::kGenA8FromLCD_Flag; 69 SkPaint::kGenA8FromLCD_Flag;
67 70
68 SkScalar fSize; 71 SkScalar fSize;
69 SkScalar fScaleX; 72 SkScalar fScaleX;
70 73
71 // 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
72 // 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).
73 SkAutoTUnref<SkTypeface> fTypeface; 76 SkAutoTUnref<SkTypeface> fTypeface;
74 SkScalar fSkewX; 77 SkScalar fSkewX;
75 78
79 static_assert(SkPaint::kAlignCount < 4, "insufficient_align_bits");
80 uint32_t fAlign : 2;
76 static_assert(SkPaint::kFull_Hinting < 4, "insufficient_hinting_bits"); 81 static_assert(SkPaint::kFull_Hinting < 4, "insufficient_hinting_bits");
77 uint32_t fHinting : 2; 82 uint32_t fHinting : 2;
78 static_assert((kFlagsMask & 0xffff) == kFlagsMask, "insufficient_flags_bits" ); 83 static_assert((kFlagsMask & 0xffff) == kFlagsMask, "insufficient_flags_bits" );
79 uint32_t fFlags : 16; 84 uint32_t fFlags : 16;
80 85
81 typedef SkNoncopyable INHERITED; 86 typedef SkNoncopyable INHERITED;
82 }; 87 };
83 88
84 struct RunFontStorageEquivalent { 89 struct RunFontStorageEquivalent {
85 SkScalar fSize, fScaleX; 90 SkScalar fSize, fScaleX;
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 640
636 fStorageUsed = 0; 641 fStorageUsed = 0;
637 fStorageSize = 0; 642 fStorageSize = 0;
638 fRunCount = 0; 643 fRunCount = 0;
639 fLastRun = 0; 644 fLastRun = 0;
640 fBounds.setEmpty(); 645 fBounds.setEmpty();
641 646
642 return blob; 647 return blob;
643 } 648 }
644 649
OLDNEW
« no previous file with comments | « no previous file | tests/TextBlobTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698