| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "platform/fonts/Font.h" | 32 #include "platform/fonts/Font.h" |
| 33 | 33 |
| 34 #include "platform/NotImplemented.h" | 34 #include "platform/RuntimeEnabledFeatures.h" |
| 35 #include "platform/fonts/FontPlatformFeatures.h" | 35 #include "platform/fonts/FontPlatformFeatures.h" |
| 36 #include "platform/fonts/SimpleFontData.h" | 36 #include "platform/fonts/SimpleFontData.h" |
| 37 #include "platform/fonts/harfbuzz/HarfBuzzShaper.h" | 37 #include "platform/fonts/harfbuzz/HarfBuzzShaper.h" |
| 38 #include "platform/fonts/GlyphBuffer.h" | 38 #include "platform/fonts/GlyphBuffer.h" |
| 39 #include "platform/geometry/FloatRect.h" | 39 #include "platform/geometry/FloatRect.h" |
| 40 #include "platform/graphics/GraphicsContext.h" | 40 #include "platform/graphics/GraphicsContext.h" |
| 41 | 41 |
| 42 #include "SkPaint.h" | 42 #include "SkPaint.h" |
| 43 #include "SkTemplates.h" | 43 #include "SkTemplates.h" |
| 44 | 44 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 x += SkFloatToScalar(adv[i].width()); | 194 x += SkFloatToScalar(adv[i].width()); |
| 195 y += SkFloatToScalar(adv[i].height()); | 195 y += SkFloatToScalar(adv[i].height()); |
| 196 } | 196 } |
| 197 | 197 |
| 198 const Glyph* glyphs = glyphBuffer.glyphs(from); | 198 const Glyph* glyphs = glyphBuffer.glyphs(from); |
| 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 ASSERT(RuntimeEnabledFeatures::textBlobEnabled()); |
| 205 |
| 204 // FIXME: It would be good to move this to Font.cpp, if we're sure that none | 206 // 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. | 207 // of the things in FontMac's setupPaint need to apply here. |
| 206 // See also paintGlyphs. | 208 // See also paintGlyphs. |
| 207 TextDrawingModeFlags textMode = gc->textDrawingMode(); | 209 TextDrawingModeFlags textMode = gc->textDrawingMode(); |
| 208 | 210 |
| 209 if (textMode & TextModeFill) | 211 if (textMode & TextModeFill) |
| 210 gc->drawTextBlob(blob, origin, gc->fillPaint()); | 212 gc->drawTextBlob(blob, origin, gc->fillPaint()); |
| 211 | 213 |
| 212 if ((textMode & TextModeStroke) && gc->hasStroke()) { | 214 if ((textMode & TextModeStroke) && gc->hasStroke()) { |
| 213 SkPaint paint = gc->strokePaint(); | 215 SkPaint paint = gc->strokePaint(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 { | 291 { |
| 290 HarfBuzzShaper shaper(this, run); | 292 HarfBuzzShaper shaper(this, run); |
| 291 if (!shaper.shape()) | 293 if (!shaper.shape()) |
| 292 return FloatRect(); | 294 return FloatRect(); |
| 293 return shaper.selectionRect(point, height, from, to); | 295 return shaper.selectionRect(point, height, from, to); |
| 294 } | 296 } |
| 295 | 297 |
| 296 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, float initia
lAdvance, | 298 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer, float initia
lAdvance, |
| 297 const FloatRect& bounds, float& advance, bool couldUseLCD) const | 299 const FloatRect& bounds, float& advance, bool couldUseLCD) const |
| 298 { | 300 { |
| 301 ASSERT(RuntimeEnabledFeatures::textBlobEnabled()); |
| 302 |
| 299 // FIXME: Except for setupPaint, this is not specific to FontHarfBuzz. | 303 // FIXME: Except for setupPaint, this is not specific to FontHarfBuzz. |
| 300 // FIXME: Also implement the more general full-positioning path. | 304 // FIXME: Also implement the more general full-positioning path. |
| 301 ASSERT(!glyphBuffer.hasVerticalAdvances()); | 305 ASSERT(!glyphBuffer.hasVerticalAdvances()); |
| 302 | 306 |
| 303 SkTextBlobBuilder builder; | 307 SkTextBlobBuilder builder; |
| 304 SkScalar x = SkFloatToScalar(initialAdvance); | 308 SkScalar x = SkFloatToScalar(initialAdvance); |
| 305 SkRect skBounds = bounds; | 309 SkRect skBounds = bounds; |
| 306 | 310 |
| 307 unsigned i = 0; | 311 unsigned i = 0; |
| 308 while (i < glyphBuffer.size()) { | 312 while (i < glyphBuffer.size()) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 buffer.pos[j] = x; | 345 buffer.pos[j] = x; |
| 342 x += SkFloatToScalar(advances[j].width()); | 346 x += SkFloatToScalar(advances[j].width()); |
| 343 } | 347 } |
| 344 } | 348 } |
| 345 | 349 |
| 346 advance = x; | 350 advance = x; |
| 347 return adoptRef(builder.build()); | 351 return adoptRef(builder.build()); |
| 348 } | 352 } |
| 349 | 353 |
| 350 } // namespace blink | 354 } // namespace blink |
| OLD | NEW |