OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. | 2 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 paintGlyphs(gc, font, glyphs, numGlyphs, pos, textRect); | 199 paintGlyphs(gc, font, glyphs, numGlyphs, pos, textRect); |
200 } | 200 } |
201 | 201 |
202 void Font::drawTextBlob(GraphicsContext* gc, const SkTextBlob* blob, const SkPoi nt& origin) const | 202 void Font::drawTextBlob(GraphicsContext* gc, const SkTextBlob* blob, const SkPoi nt& origin) const |
203 { | 203 { |
204 // FIXME: It would be good to move this to Font.cpp, if we're sure that none | 204 // FIXME: It would be good to move this to Font.cpp, if we're sure that none |
205 // of the things in FontMac's setupPaint need to apply here. | 205 // of the things in FontMac's setupPaint need to apply here. |
206 // See also paintGlyphs. | 206 // See also paintGlyphs. |
207 TextDrawingModeFlags textMode = gc->textDrawingMode(); | 207 TextDrawingModeFlags textMode = gc->textDrawingMode(); |
208 | 208 |
209 if (textMode & TextModeFill) { | 209 if (textMode & TextModeFill) |
210 SkPaint paint = gc->fillPaint(); | 210 gc->drawTextBlob(blob, origin, gc->fillPaint()); |
211 gc->adjustTextRenderMode(&paint); | |
212 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | |
213 gc->drawTextBlob(blob, origin, paint); | |
214 } | |
215 | 211 |
216 if ((textMode & TextModeStroke) && gc->hasStroke()) { | 212 if ((textMode & TextModeStroke) && gc->hasStroke()) { |
217 SkPaint paint = gc->strokePaint(); | 213 SkPaint paint = gc->strokePaint(); |
218 gc->adjustTextRenderMode(&paint); | |
219 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | |
220 if (textMode & TextModeFill) | 214 if (textMode & TextModeFill) |
221 paint.setLooper(0); | 215 paint.setLooper(0); |
222 gc->drawTextBlob(blob, origin, paint); | 216 gc->drawTextBlob(blob, origin, paint); |
223 } | 217 } |
224 } | 218 } |
225 | 219 |
226 float Font::drawComplexText(GraphicsContext* gc, const TextRunPaintInfo& runInfo , const FloatPoint& point) const | 220 float Font::drawComplexText(GraphicsContext* gc, const TextRunPaintInfo& runInfo , const FloatPoint& point) const |
227 { | 221 { |
228 if (!runInfo.run.length()) | 222 if (!runInfo.run.length()) |
229 return 0; | 223 return 0; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 FloatRect Font::selectionRectForComplexText(const TextRun& run, | 286 FloatRect Font::selectionRectForComplexText(const TextRun& run, |
293 const FloatPoint& point, int height, | 287 const FloatPoint& point, int height, |
294 int from, int to) const | 288 int from, int to) const |
295 { | 289 { |
296 HarfBuzzShaper shaper(this, run); | 290 HarfBuzzShaper shaper(this, run); |
297 if (!shaper.shape()) | 291 if (!shaper.shape()) |
298 return FloatRect(); | 292 return FloatRect(); |
299 return shaper.selectionRect(point, height, from, to); | 293 return shaper.selectionRect(point, height, from, to); |
300 } | 294 } |
301 | 295 |
302 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, float initia lAdvance, const FloatRect& bounds, float& advance) const | 296 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, const Graphi csContext& context, |
297 float initialAdvance, const FloatRect& bounds, float& advance) const | |
303 { | 298 { |
304 // FIXME: Except for setupPaint, this is not specific to FontHarfBuzz. | 299 // FIXME: Except for setupPaint, this is not specific to FontHarfBuzz. |
305 // FIXME: Also implement the more general full-positioning path. | 300 // FIXME: Also implement the more general full-positioning path. |
306 ASSERT(!glyphBuffer.hasVerticalAdvances()); | 301 ASSERT(!glyphBuffer.hasVerticalAdvances()); |
307 | 302 |
308 SkTextBlobBuilder builder; | 303 SkTextBlobBuilder builder; |
309 SkScalar x = SkFloatToScalar(initialAdvance); | 304 SkScalar x = SkFloatToScalar(initialAdvance); |
310 SkRect skBounds = bounds; | 305 SkRect skBounds = bounds; |
311 | 306 |
312 unsigned i = 0; | 307 unsigned i = 0; |
313 while (i < glyphBuffer.size()) { | 308 while (i < glyphBuffer.size()) { |
314 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i); | 309 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i); |
315 | 310 |
316 // FIXME: Handle vertical text. | 311 // FIXME: Handle vertical text. |
317 if (fontData->platformData().orientation() == Vertical) | 312 if (fontData->platformData().orientation() == Vertical) |
318 return nullptr; | 313 return nullptr; |
319 | 314 |
320 // FIXME: Handle SVG fonts. | 315 // FIXME: Handle SVG fonts. |
321 if (fontData->isSVGFont()) | 316 if (fontData->isSVGFont()) |
322 return nullptr; | 317 return nullptr; |
323 | 318 |
324 // FIXME: FontPlatformData makes some decisions on the device scale | 319 // FIXME: FontPlatformData makes some decisions on the device scale |
325 // factor, which is found via the GraphicsContext. This should be fixed | 320 // factor, which is found via the GraphicsContext. This should be fixed |
326 // to avoid correctness problems here. | 321 // to avoid correctness problems here. |
327 SkPaint paint; | 322 SkPaint paint; |
328 fontData->platformData().setupPaint(&paint); | 323 fontData->platformData().setupPaint(&paint); |
324 context.adjustTextRenderMode(&paint); | |
jbroman
2014/09/10 17:09:40
When can these properties of the GraphicsContext c
| |
329 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 325 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
330 | 326 |
331 unsigned start = i++; | 327 unsigned start = i++; |
332 while (i < glyphBuffer.size() && glyphBuffer.fontDataAt(i) == fontData) | 328 while (i < glyphBuffer.size() && glyphBuffer.fontDataAt(i) == fontData) |
333 i++; | 329 i++; |
334 unsigned count = i - start; | 330 unsigned count = i - start; |
335 | 331 |
336 const SkTextBlobBuilder::RunBuffer& buffer = builder.allocRunPosH(paint, count, 0, &skBounds); | 332 const SkTextBlobBuilder::RunBuffer& buffer = builder.allocRunPosH(paint, count, 0, &skBounds); |
337 | 333 |
338 const uint16_t* glyphs = glyphBuffer.glyphs(start); | 334 const uint16_t* glyphs = glyphBuffer.glyphs(start); |
339 std::copy(glyphs, glyphs + count, buffer.glyphs); | 335 std::copy(glyphs, glyphs + count, buffer.glyphs); |
340 | 336 |
341 const FloatSize* advances = glyphBuffer.advances(start); | 337 const FloatSize* advances = glyphBuffer.advances(start); |
342 for (unsigned j = 0; j < count; j++) { | 338 for (unsigned j = 0; j < count; j++) { |
343 buffer.pos[j] = x; | 339 buffer.pos[j] = x; |
344 x += SkFloatToScalar(advances[j].width()); | 340 x += SkFloatToScalar(advances[j].width()); |
345 } | 341 } |
346 } | 342 } |
347 | 343 |
348 advance = x; | 344 advance = x; |
349 return adoptRef(builder.build()); | 345 return adoptRef(builder.build()); |
350 } | 346 } |
351 | 347 |
352 } // namespace blink | 348 } // namespace blink |
OLD | NEW |