-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement SkTextBlob::Iter in Skiko (#512)
- Loading branch information
1 parent
8fccb7e
commit bd7e73c
Showing
5 changed files
with
209 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "SkTextBlob.h" | ||
|
||
class TextBlobIter { | ||
public: | ||
TextBlobIter(SkTextBlob* blob): _blob(sk_ref_sp(blob)), _iter(*blob), _buffer(), _hasNext() { | ||
fetch(); | ||
} | ||
|
||
bool fetch() { | ||
_hasNext = _iter.next(&_buffer); | ||
return _hasNext; | ||
} | ||
|
||
bool hasNext() const { | ||
return _hasNext; | ||
} | ||
|
||
sk_sp<SkTypeface> getTypeface() const { | ||
return sk_ref_sp(_buffer.fTypeface); | ||
} | ||
|
||
int getGlyphCount() const { | ||
return _buffer.fGlyphCount; | ||
} | ||
|
||
int writeGlyphs(uint16_t* dst, int max) const { | ||
int count = std::min(max, _buffer.fGlyphCount); | ||
std::memcpy(dst, _buffer.fGlyphIndices, count * sizeof(uint16_t)); | ||
return _buffer.fGlyphCount; | ||
} | ||
|
||
private: | ||
SkTextBlob::Iter::Run _buffer; | ||
SkTextBlob::Iter _iter; | ||
bool _hasNext; | ||
sk_sp<SkTextBlob> _blob; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters