OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. |
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. | 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "platform/fonts/Character.h" | 32 #include "platform/fonts/Character.h" |
33 #include "platform/fonts/FontCache.h" | 33 #include "platform/fonts/FontCache.h" |
34 #include "platform/fonts/FontFallbackList.h" | 34 #include "platform/fonts/FontFallbackList.h" |
35 #include "platform/fonts/GlyphBuffer.h" | 35 #include "platform/fonts/GlyphBuffer.h" |
36 #include "platform/fonts/GlyphPageTreeNode.h" | 36 #include "platform/fonts/GlyphPageTreeNode.h" |
37 #include "platform/fonts/SimpleFontData.h" | 37 #include "platform/fonts/SimpleFontData.h" |
38 #include "platform/fonts/shaping/HarfBuzzShaper.h" | 38 #include "platform/fonts/shaping/HarfBuzzShaper.h" |
39 #include "platform/fonts/shaping/SimpleShaper.h" | 39 #include "platform/fonts/shaping/SimpleShaper.h" |
40 #include "platform/geometry/FloatRect.h" | 40 #include "platform/geometry/FloatRect.h" |
41 #include "platform/graphics/GraphicsContext.h" | 41 #include "platform/graphics/GraphicsContext.h" |
| 42 #include "platform/graphics/GraphicsContextStateSaver.h" |
42 #include "platform/text/TextRun.h" | 43 #include "platform/text/TextRun.h" |
43 #include "wtf/MainThread.h" | 44 #include "wtf/MainThread.h" |
44 #include "wtf/StdLibExtras.h" | 45 #include "wtf/StdLibExtras.h" |
45 #include "wtf/unicode/CharacterNames.h" | 46 #include "wtf/unicode/CharacterNames.h" |
46 #include "wtf/unicode/Unicode.h" | 47 #include "wtf/unicode/Unicode.h" |
47 | 48 |
48 using namespace WTF; | 49 using namespace WTF; |
49 using namespace Unicode; | 50 using namespace Unicode; |
50 | 51 |
51 namespace blink { | 52 namespace blink { |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 { | 795 { |
795 const OpenTypeVerticalData* verticalData = font->verticalData(); | 796 const OpenTypeVerticalData* verticalData = font->verticalData(); |
796 | 797 |
797 SkAutoSTMalloc<32, SkPoint> storage(numGlyphs); | 798 SkAutoSTMalloc<32, SkPoint> storage(numGlyphs); |
798 SkPoint* pos = storage.get(); | 799 SkPoint* pos = storage.get(); |
799 | 800 |
800 // Bend over backwards to preserve legacy rounding. | 801 // Bend over backwards to preserve legacy rounding. |
801 float initialAdvance = glyphBuffer.xOffsetAt(from); | 802 float initialAdvance = glyphBuffer.xOffsetAt(from); |
802 FloatPoint adjustedPoint(point.x() + initialAdvance, point.y()); | 803 FloatPoint adjustedPoint(point.x() + initialAdvance, point.y()); |
803 | 804 |
804 AffineTransform savedMatrix = gc->getCTM(); | 805 GraphicsContextStateSaver stateSaver(*gc); |
805 gc->concatCTM(AffineTransform(0, -1, 1, 0, adjustedPoint.x(), adjustedPoint.
y())); | 806 gc->concatCTM(AffineTransform(0, -1, 1, 0, adjustedPoint.x(), adjustedPoint.
y())); |
806 gc->concatCTM(AffineTransform(1, 0, 0, 1, -adjustedPoint.x(), -adjustedPoint
.y())); | 807 gc->concatCTM(AffineTransform(1, 0, 0, 1, -adjustedPoint.x(), -adjustedPoint
.y())); |
807 | 808 |
808 const unsigned kMaxBufferLength = 256; | 809 const unsigned kMaxBufferLength = 256; |
809 Vector<FloatPoint, kMaxBufferLength> translations; | 810 Vector<FloatPoint, kMaxBufferLength> translations; |
810 | 811 |
811 const FontMetrics& metrics = font->fontMetrics(); | 812 const FontMetrics& metrics = font->fontMetrics(); |
812 float verticalOriginX = adjustedPoint.x() + metrics.floatAscent() - metrics.
floatAscent(IdeographicBaseline); | 813 float verticalOriginX = adjustedPoint.x() + metrics.floatAscent() - metrics.
floatAscent(IdeographicBaseline); |
813 | 814 |
814 unsigned glyphIndex = 0; | 815 unsigned glyphIndex = 0; |
815 while (glyphIndex < numGlyphs) { | 816 while (glyphIndex < numGlyphs) { |
816 unsigned chunkLength = std::min(kMaxBufferLength, numGlyphs - glyphIndex
); | 817 unsigned chunkLength = std::min(kMaxBufferLength, numGlyphs - glyphIndex
); |
817 | 818 |
818 const Glyph* glyphs = glyphBuffer.glyphs(from + glyphIndex); | 819 const Glyph* glyphs = glyphBuffer.glyphs(from + glyphIndex); |
819 | 820 |
820 translations.resize(chunkLength); | 821 translations.resize(chunkLength); |
821 verticalData->getVerticalTranslationsForGlyphs(font, glyphs, chunkLength
, | 822 verticalData->getVerticalTranslationsForGlyphs(font, glyphs, chunkLength
, |
822 reinterpret_cast<float*>(&translations[0])); | 823 reinterpret_cast<float*>(&translations[0])); |
823 | 824 |
824 for (unsigned i = 0; i < chunkLength; ++i, ++glyphIndex) { | 825 for (unsigned i = 0; i < chunkLength; ++i, ++glyphIndex) { |
825 SkScalar x = verticalOriginX + lroundf(translations[i].x()); | 826 SkScalar x = verticalOriginX + lroundf(translations[i].x()); |
826 SkScalar y = adjustedPoint.y() - SkIntToScalar( | 827 SkScalar y = adjustedPoint.y() - SkIntToScalar( |
827 -lroundf(glyphBuffer.xOffsetAt(from + glyphIndex) - initialAdvan
ce - translations[i].y())); | 828 -lroundf(glyphBuffer.xOffsetAt(from + glyphIndex) - initialAdvan
ce - translations[i].y())); |
828 pos[i].set(x, y); | 829 pos[i].set(x, y); |
829 } | 830 } |
830 paintGlyphs(gc, font, glyphs, chunkLength, pos, textRect); | 831 paintGlyphs(gc, font, glyphs, chunkLength, pos, textRect); |
831 } | 832 } |
832 | |
833 gc->setCTM(savedMatrix); | |
834 } | 833 } |
835 | 834 |
836 void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, | 835 void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, |
837 const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, | 836 const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, |
838 const FloatPoint& point, const FloatRect& textRect) const | 837 const FloatPoint& point, const FloatRect& textRect) const |
839 { | 838 { |
840 ASSERT(glyphBuffer.size() >= from + numGlyphs); | 839 ASSERT(glyphBuffer.size() >= from + numGlyphs); |
841 | 840 |
842 if (font->platformData().orientation() == Vertical && font->verticalData())
{ | 841 if (font->platformData().orientation() == Vertical && font->verticalData())
{ |
843 paintGlyphsVertical(gc, font, glyphBuffer, from, numGlyphs, point, textR
ect); | 842 paintGlyphsVertical(gc, font, glyphBuffer, from, numGlyphs, point, textR
ect); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 if (delta <= 0) | 1058 if (delta <= 0) |
1060 break; | 1059 break; |
1061 } | 1060 } |
1062 } | 1061 } |
1063 } | 1062 } |
1064 | 1063 |
1065 return offset; | 1064 return offset; |
1066 } | 1065 } |
1067 | 1066 |
1068 } // namespace blink | 1067 } // namespace blink |
OLD | NEW |