| 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 "SkPDFDevice.h" | 8 #include "SkPDFDevice.h" |
| 9 #include "SkAnnotationKeys.h" | 9 #include "SkAnnotationKeys.h" |
| 10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "SkRRect.h" | 30 #include "SkRRect.h" |
| 31 #include "SkString.h" | 31 #include "SkString.h" |
| 32 #include "SkSurface.h" | 32 #include "SkSurface.h" |
| 33 #include "SkTextFormatParams.h" | 33 #include "SkTextFormatParams.h" |
| 34 #include "SkTemplates.h" | 34 #include "SkTemplates.h" |
| 35 #include "SkTypefacePriv.h" | 35 #include "SkTypefacePriv.h" |
| 36 #include "SkXfermodeInterpretation.h" | 36 #include "SkXfermodeInterpretation.h" |
| 37 | 37 |
| 38 #define DPI_FOR_RASTER_SCALE_ONE 72 | 38 #define DPI_FOR_RASTER_SCALE_ONE 72 |
| 39 | 39 |
| 40 #if !defined(SK_PDF_NEVER_RELY_ON_ADVANCE) && defined(SK_BUILD_FOR_WIN) |
| 41 #define SK_PDF_NEVER_RELY_ON_ADVANCE |
| 42 #endif |
| 43 |
| 40 // Utility functions | 44 // Utility functions |
| 41 | 45 |
| 42 // If the paint will definitely draw opaquely, replace kSrc_Mode with | 46 // If the paint will definitely draw opaquely, replace kSrc_Mode with |
| 43 // kSrcOver_Mode. http://crbug.com/473572 | 47 // kSrcOver_Mode. http://crbug.com/473572 |
| 44 static void replace_srcmode_on_opaque_paint(SkPaint* paint) { | 48 static void replace_srcmode_on_opaque_paint(SkPaint* paint) { |
| 45 if (kSrcOver_SkXfermodeInterpretation | 49 if (kSrcOver_SkXfermodeInterpretation |
| 46 == SkInterpretXfermode(*paint, false)) { | 50 == SkInterpretXfermode(*paint, false)) { |
| 47 paint->setXfermode(nullptr); | 51 paint->setXfermode(nullptr); |
| 48 } | 52 } |
| 49 } | 53 } |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 fWideChars = wideChars; | 992 fWideChars = wideChars; |
| 989 } | 993 } |
| 990 } | 994 } |
| 991 void writeGlyph(SkScalar x, | 995 void writeGlyph(SkScalar x, |
| 992 SkScalar y, | 996 SkScalar y, |
| 993 SkScalar advanceWidth, | 997 SkScalar advanceWidth, |
| 994 uint16_t glyph) { | 998 uint16_t glyph) { |
| 995 if (!fDefaultPositioning) { | 999 if (!fDefaultPositioning) { |
| 996 SkScalar xPosition = x - fCurrentMatrixX; | 1000 SkScalar xPosition = x - fCurrentMatrixX; |
| 997 SkScalar yPosition = y - fCurrentMatrixY; | 1001 SkScalar yPosition = y - fCurrentMatrixY; |
| 998 if (xPosition != fXAdvance || yPosition != 0) { | 1002 bool alwaysPosition = false; |
| 1003 #ifdef SK_PDF_NEVER_RELY_ON_ADVANCE |
| 1004 alwaysPosition = true; |
| 1005 #endif |
| 1006 if (alwaysPosition || xPosition != fXAdvance || yPosition != 0) { |
| 999 this->flush(); | 1007 this->flush(); |
| 1000 SkPDFUtils::AppendScalar(xPosition, fContent); | 1008 SkPDFUtils::AppendScalar(xPosition, fContent); |
| 1001 fContent->writeText(" "); | 1009 fContent->writeText(" "); |
| 1002 SkPDFUtils::AppendScalar(-yPosition, fContent); | 1010 SkPDFUtils::AppendScalar(-yPosition, fContent); |
| 1003 fContent->writeText(" Td "); | 1011 fContent->writeText(" Td "); |
| 1004 fCurrentMatrixX = x; | 1012 fCurrentMatrixX = x; |
| 1005 fCurrentMatrixY = y; | 1013 fCurrentMatrixY = y; |
| 1006 fXAdvance = 0; | 1014 fXAdvance = 0; |
| 1007 } | 1015 } |
| 1008 fXAdvance += advanceWidth; | 1016 fXAdvance += advanceWidth; |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 } | 2159 } |
| 2152 | 2160 |
| 2153 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) { | 2161 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) { |
| 2154 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->
height()), | 2162 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->
height()), |
| 2155 image->makeNonTextureImage()); | 2163 image->makeNonTextureImage()); |
| 2156 } | 2164 } |
| 2157 | 2165 |
| 2158 sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { | 2166 sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { |
| 2159 return nullptr; | 2167 return nullptr; |
| 2160 } | 2168 } |
| OLD | NEW |