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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapeResultBloberizer.h

Issue 2835103002: Move blobalizer implementation to ShapeResultBloberizer (Closed)
Patch Set: Fix canvas tests Created 3 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #ifndef ShapeResultBloberizer_h 5 #ifndef ShapeResultBloberizer_h
6 #define ShapeResultBloberizer_h 6 #define ShapeResultBloberizer_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/fonts/Glyph.h" 9 #include "platform/fonts/Glyph.h"
10 #include "platform/fonts/SimpleFontData.h" 10 #include "platform/fonts/SimpleFontData.h"
11 #include "platform/fonts/shaping/ShapeResultBuffer.h"
11 #include "platform/geometry/FloatPoint.h" 12 #include "platform/geometry/FloatPoint.h"
12 #include "platform/wtf/Allocator.h" 13 #include "platform/wtf/Allocator.h"
13 #include "platform/wtf/Vector.h" 14 #include "platform/wtf/Vector.h"
14 #include "third_party/skia/include/core/SkTextBlob.h" 15 #include "third_party/skia/include/core/SkTextBlob.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
18 class Font; 19 class Font;
19 20
20 class PLATFORM_EXPORT ShapeResultBloberizer { 21 class PLATFORM_EXPORT ShapeResultBloberizer {
21 WTF_MAKE_NONCOPYABLE(ShapeResultBloberizer); 22 WTF_MAKE_NONCOPYABLE(ShapeResultBloberizer);
22 STACK_ALLOCATED(); 23 STACK_ALLOCATED();
23 24
24 public: 25 public:
25 enum class Type { kNormal, kTextIntercepts }; 26 enum class Type { kNormal, kTextIntercepts };
26 27
27 ShapeResultBloberizer(const Font&, 28 ShapeResultBloberizer(const Font&,
28 float device_scale_factor, 29 float device_scale_factor,
29 Type = Type::kNormal); 30 Type = Type::kNormal);
30 31
31 Type GetType() const { return type_; } 32 Type GetType() const { return type_; }
32 33
34 float FillGlyphs(const TextRunPaintInfo&, const ShapeResultBuffer&);
35 void FillTextEmphasisGlyphs(const TextRunPaintInfo&,
36 const GlyphData& emphasis_data,
37 const ShapeResultBuffer&);
38
33 void Add(Glyph glyph, const SimpleFontData* font_data, float h_offset) { 39 void Add(Glyph glyph, const SimpleFontData* font_data, float h_offset) {
34 // cannot mix x-only/xy offsets 40 // cannot mix x-only/xy offsets
35 DCHECK(!HasPendingVerticalOffsets()); 41 DCHECK(!HasPendingVerticalOffsets());
36 42
37 if (UNLIKELY(font_data != pending_font_data_)) { 43 if (UNLIKELY(font_data != pending_font_data_)) {
38 CommitPendingRun(); 44 CommitPendingRun();
39 pending_font_data_ = font_data; 45 pending_font_data_ = font_data;
40 DCHECK_EQ(GetBlobRotation(font_data), BlobRotation::kNoRotation); 46 DCHECK_EQ(GetBlobRotation(font_data), BlobRotation::kNoRotation);
41 } 47 }
42 48
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 sk_sp<SkTextBlob> blob; 80 sk_sp<SkTextBlob> blob;
75 BlobRotation rotation; 81 BlobRotation rotation;
76 }; 82 };
77 83
78 using BlobBuffer = Vector<BlobInfo, 16>; 84 using BlobBuffer = Vector<BlobInfo, 16>;
79 const BlobBuffer& Blobs(); 85 const BlobBuffer& Blobs();
80 86
81 private: 87 private:
82 friend class ShapeResultBloberizerTestInfo; 88 friend class ShapeResultBloberizerTestInfo;
83 89
90 float FillGlyphsForResult(const ShapeResult&,
91 const TextRunPaintInfo&,
92 float initial_advance,
93 unsigned run_offset);
94 float FillFastHorizontalGlyphs(const ShapeResultBuffer&, const TextRun&);
95 float FillTextEmphasisGlyphsForRun(const ShapeResult::RunInfo*,
96 const TextRunPaintInfo&,
97 const GlyphData& emphasis_data,
98 float initial_advance,
99 unsigned run_offset);
100
84 void CommitPendingRun(); 101 void CommitPendingRun();
85 void CommitPendingBlob(); 102 void CommitPendingBlob();
86 103
87 bool HasPendingVerticalOffsets() const; 104 bool HasPendingVerticalOffsets() const;
88 static BlobRotation GetBlobRotation(const SimpleFontData*); 105 static BlobRotation GetBlobRotation(const SimpleFontData*);
89 106
90 const Font& font_; 107 const Font& font_;
91 const float device_scale_factor_; 108 const float device_scale_factor_;
92 const Type type_; 109 const Type type_;
93 110
94 // Current text blob state. 111 // Current text blob state.
95 SkTextBlobBuilder builder_; 112 SkTextBlobBuilder builder_;
96 BlobRotation builder_rotation_ = BlobRotation::kNoRotation; 113 BlobRotation builder_rotation_ = BlobRotation::kNoRotation;
97 size_t builder_run_count_ = 0; 114 size_t builder_run_count_ = 0;
98 115
99 // Current run state. 116 // Current run state.
100 const SimpleFontData* pending_font_data_ = nullptr; 117 const SimpleFontData* pending_font_data_ = nullptr;
101 Vector<Glyph, 1024> pending_glyphs_; 118 Vector<Glyph, 1024> pending_glyphs_;
102 Vector<float, 1024> pending_offsets_; 119 Vector<float, 1024> pending_offsets_;
103 float pending_vertical_baseline_x_offset_ = 0; 120 float pending_vertical_baseline_x_offset_ = 0;
104 121
105 // Constructed blobs. 122 // Constructed blobs.
106 BlobBuffer blobs_; 123 BlobBuffer blobs_;
107 }; 124 };
108 125
109 } // namespace blink 126 } // namespace blink
110 127
111 #endif // ShapeResultBloberizer_h 128 #endif // ShapeResultBloberizer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698