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

Unified Diff: Source/platform/fonts/skia/SimpleFontDataSkia.cpp

Issue 240003002: Add unit test for GlyphPageTreeNode. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: more tests Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/fonts/skia/GlyphPageTreeNodeSkia.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/skia/SimpleFontDataSkia.cpp
diff --git a/Source/platform/fonts/skia/SimpleFontDataSkia.cpp b/Source/platform/fonts/skia/SimpleFontDataSkia.cpp
index e312531f4b8e091857fc5851d74779f086d8e51c..f5a9f95e9832cea118e4a4b9e4965c7bf56a36aa 100644
--- a/Source/platform/fonts/skia/SimpleFontDataSkia.cpp
+++ b/Source/platform/fonts/skia/SimpleFontDataSkia.cpp
@@ -36,7 +36,9 @@
#include "SkPath.h"
#include "SkTypeface.h"
#include "SkTypes.h"
+#include "SkUtils.h"
#include "platform/fonts/FontDescription.h"
+#include "platform/fonts/GlyphPage.h"
#include "platform/fonts/VDMXParser.h"
#include "platform/geometry/FloatRect.h"
#include "wtf/unicode/Unicode.h"
@@ -278,4 +280,26 @@ bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters
}
#endif
+bool SimpleFontData::fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength) const
+{
+ if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) {
+ SkDebugf("%s last char is high-surrogate", __FUNCTION__);
+ return false;
+ }
+
+ SkAutoSTMalloc<GlyphPage::size, uint16_t> glyphStorage(length);
+
+ uint16_t* glyphs = glyphStorage.get();
+ SkTypeface* typeface = platformData().typeface();
+ typeface->charsToGlyphs(buffer, SkTypeface::kUTF16_Encoding, glyphs, length);
+
+ unsigned allGlyphs = 0; // track if any of the glyphIDs are non-zero
+ for (unsigned i = 0; i < length; i++) {
+ pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], glyphs[i] ? this : 0);
+ allGlyphs |= glyphs[i];
+ }
+
+ return allGlyphs;
+}
+
} // namespace WebCore
« no previous file with comments | « Source/platform/fonts/skia/GlyphPageTreeNodeSkia.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698