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

Side by Side Diff: tools/SkShaper_harfbuzz.cpp

Issue 2084533004: SkTextBlob: Begin implementing Extended TextBlob API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 3 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
« no previous file with comments | « tests/TextBlobTest.cpp ('k') | tools/using_skia_and_harfbuzz.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 2016 Google Inc. 2 * Copyright 2016 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 <hb-ot.h> 8 #include <hb-ot.h>
9 9
10 #include "SkShaper.h" 10 #include "SkShaper.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 hb_shape(fImpl->fHarfBuzzFont.get(), buffer, nullptr, 0); 98 hb_shape(fImpl->fHarfBuzzFont.get(), buffer, nullptr, 0);
99 unsigned len = hb_buffer_get_length(buffer); 99 unsigned len = hb_buffer_get_length(buffer);
100 if (len == 0) { 100 if (len == 0) {
101 hb_buffer_clear_contents(buffer); 101 hb_buffer_clear_contents(buffer);
102 return 0; 102 return 0;
103 } 103 }
104 104
105 hb_glyph_info_t* info = hb_buffer_get_glyph_infos(buffer, NULL); 105 hb_glyph_info_t* info = hb_buffer_get_glyph_infos(buffer, NULL);
106 hb_glyph_position_t* pos = 106 hb_glyph_position_t* pos =
107 hb_buffer_get_glyph_positions(buffer, NULL); 107 hb_buffer_get_glyph_positions(buffer, NULL);
108 auto runBuffer = builder->allocRunPos(paint, len); 108 auto runBuffer = builder->allocRunTextPos(
109 paint, SkToInt(len), SkToInt(textBytes), SkString());
110 memcpy(runBuffer.utf8text, utf8text, textBytes);
109 111
110 double x = point.x(); 112 double x = point.x();
111 double y = point.y(); 113 double y = point.y();
112 114
113 double textSizeY = paint.getTextSize() / (double)FONT_SIZE_SCALE; 115 double textSizeY = paint.getTextSize() / (double)FONT_SIZE_SCALE;
114 double textSizeX = textSizeY * paint.getTextScaleX(); 116 double textSizeX = textSizeY * paint.getTextScaleX();
115 117
116 for (unsigned i = 0; i < len; i++) { 118 for (unsigned i = 0; i < len; i++) {
117 runBuffer.glyphs[i] = info[i].codepoint; 119 runBuffer.glyphs[i] = info[i].codepoint;
120 runBuffer.clusters[i] = info[i].cluster;
118 reinterpret_cast<SkPoint*>(runBuffer.pos)[i] = 121 reinterpret_cast<SkPoint*>(runBuffer.pos)[i] =
119 SkPoint::Make(SkDoubleToScalar(x + pos[i].x_offset * textSizeX), 122 SkPoint::Make(SkDoubleToScalar(x + pos[i].x_offset * textSizeX),
120 SkDoubleToScalar(y - pos[i].y_offset * textSizeY)) ; 123 SkDoubleToScalar(y - pos[i].y_offset * textSizeY)) ;
121 x += pos[i].x_advance * textSizeX; 124 x += pos[i].x_advance * textSizeX;
122 y += pos[i].y_advance * textSizeY; 125 y += pos[i].y_advance * textSizeY;
123 } 126 }
127
124 hb_buffer_clear_contents(buffer); 128 hb_buffer_clear_contents(buffer);
125 return (SkScalar)x; 129 return (SkScalar)x;
126 } 130 }
OLDNEW
« no previous file with comments | « tests/TextBlobTest.cpp ('k') | tools/using_skia_and_harfbuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698