| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 | 9 |
| 10 #ifndef UNICODE | 10 #ifndef UNICODE |
| (...skipping 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2050 /** [in] Advance width and offsets for glyphs measured in | 2050 /** [in] Advance width and offsets for glyphs measured in |
| 2051 hundredths of the font em size (XPS Spec 5.1.3). */ | 2051 hundredths of the font em size (XPS Spec 5.1.3). */ |
| 2052 FLOAT centemPerUnit; | 2052 FLOAT centemPerUnit; |
| 2053 /** [in,out] The accumulated glyphs used in the current typeface. */ | 2053 /** [in,out] The accumulated glyphs used in the current typeface. */ |
| 2054 SkBitSet* glyphUse; | 2054 SkBitSet* glyphUse; |
| 2055 /** [out] The glyphs to draw. */ | 2055 /** [out] The glyphs to draw. */ |
| 2056 SkTDArray<XPS_GLYPH_INDEX> xpsGlyphs; | 2056 SkTDArray<XPS_GLYPH_INDEX> xpsGlyphs; |
| 2057 }; | 2057 }; |
| 2058 | 2058 |
| 2059 static void xps_draw_1_glyph(const SkDraw1Glyph& state, | 2059 static void xps_draw_1_glyph(const SkDraw1Glyph& state, |
| 2060 SkFixed x, SkFixed y, | 2060 Sk48Dot16 fx, Sk48Dot16 fy, |
| 2061 const SkGlyph& skGlyph) { | 2061 const SkGlyph& skGlyph) { |
| 2062 SkASSERT(skGlyph.fWidth > 0 && skGlyph.fHeight > 0); | 2062 SkASSERT(skGlyph.fWidth > 0 && skGlyph.fHeight > 0); |
| 2063 | 2063 |
| 2064 SkXPSDrawProcs* procs = static_cast<SkXPSDrawProcs*>(state.fDraw->fProcs); | 2064 SkXPSDrawProcs* procs = static_cast<SkXPSDrawProcs*>(state.fDraw->fProcs); |
| 2065 | 2065 |
| 2066 //Draw pre-adds half the sampling frequency for floor rounding. | 2066 //Draw pre-adds half the sampling frequency for floor rounding. |
| 2067 x -= state.fHalfSampleX; | 2067 SkScalar x = Sk48Dot16ToScalar(fx) - state.fHalfSampleX; |
| 2068 y -= state.fHalfSampleY; | 2068 SkScalar y = Sk48Dot16ToScalar(fy) - state.fHalfSampleY; |
| 2069 | 2069 |
| 2070 XPS_GLYPH_INDEX* xpsGlyph = procs->xpsGlyphs.append(); | 2070 XPS_GLYPH_INDEX* xpsGlyph = procs->xpsGlyphs.append(); |
| 2071 uint16_t glyphID = skGlyph.getGlyphID(); | 2071 uint16_t glyphID = skGlyph.getGlyphID(); |
| 2072 procs->glyphUse->setBit(glyphID, true); | 2072 procs->glyphUse->setBit(glyphID, true); |
| 2073 xpsGlyph->index = glyphID; | 2073 xpsGlyph->index = glyphID; |
| 2074 if (1 == procs->xpsGlyphs.count()) { | 2074 if (1 == procs->xpsGlyphs.count()) { |
| 2075 xpsGlyph->advanceWidth = 0.0f; | 2075 xpsGlyph->advanceWidth = 0.0f; |
| 2076 xpsGlyph->horizontalOffset = SkFixedToFloat(x) * procs->centemPerUnit; | 2076 xpsGlyph->horizontalOffset = SkScalarToFloat(x) * procs->centemPerUnit; |
| 2077 xpsGlyph->verticalOffset = SkFixedToFloat(y) * -procs->centemPerUnit; | 2077 xpsGlyph->verticalOffset = SkScalarToFloat(y) * -procs->centemPerUnit; |
| 2078 } else { | 2078 } else { |
| 2079 const XPS_GLYPH_INDEX& first = procs->xpsGlyphs[0]; | 2079 const XPS_GLYPH_INDEX& first = procs->xpsGlyphs[0]; |
| 2080 xpsGlyph->advanceWidth = 0.0f; | 2080 xpsGlyph->advanceWidth = 0.0f; |
| 2081 xpsGlyph->horizontalOffset = (SkFixedToFloat(x) * procs->centemPerUnit) | 2081 xpsGlyph->horizontalOffset = (SkScalarToFloat(x) * procs->centemPerUnit) |
| 2082 - first.horizontalOffset; | 2082 - first.horizontalOffset; |
| 2083 xpsGlyph->verticalOffset = (SkFixedToFloat(y) * -procs->centemPerUnit) | 2083 xpsGlyph->verticalOffset = (SkScalarToFloat(y) * -procs->centemPerUnit) |
| 2084 - first.verticalOffset; | 2084 - first.verticalOffset; |
| 2085 } | 2085 } |
| 2086 } | 2086 } |
| 2087 | 2087 |
| 2088 static void text_draw_init(const SkPaint& paint, | 2088 static void text_draw_init(const SkPaint& paint, |
| 2089 const void* text, size_t byteLength, | 2089 const void* text, size_t byteLength, |
| 2090 SkBitSet& glyphsUsed, | 2090 SkBitSet& glyphsUsed, |
| 2091 SkDraw& myDraw, SkXPSDrawProcs& procs) { | 2091 SkDraw& myDraw, SkXPSDrawProcs& procs) { |
| 2092 procs.fD1GProc = xps_draw_1_glyph; | 2092 procs.fD1GProc = xps_draw_1_glyph; |
| 2093 int numGlyphGuess; | 2093 int numGlyphGuess; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 IID_PPV_ARGS(&this->fXpsFactory)), | 2278 IID_PPV_ARGS(&this->fXpsFactory)), |
| 2279 "Could not create factory for layer."); | 2279 "Could not create factory for layer."); |
| 2280 | 2280 |
| 2281 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas), | 2281 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas), |
| 2282 "Could not create canvas for layer."); | 2282 "Could not create canvas for layer."); |
| 2283 } | 2283 } |
| 2284 | 2284 |
| 2285 bool SkXPSDevice::allowImageFilter(const SkImageFilter*) { | 2285 bool SkXPSDevice::allowImageFilter(const SkImageFilter*) { |
| 2286 return false; | 2286 return false; |
| 2287 } | 2287 } |
| OLD | NEW |