| 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 | 8 |
| 9 #include "SkData.h" | 9 #include "SkData.h" |
| 10 #include "SkGeometry.h" | 10 #include "SkGeometry.h" |
| 11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
| 12 #include "SkPath.h" | 12 #include "SkPath.h" |
| 13 #include "SkPDFResourceDict.h" | 13 #include "SkPDFResourceDict.h" |
| 14 #include "SkPDFUtils.h" | 14 #include "SkPDFUtils.h" |
| 15 #include "SkStream.h" | 15 #include "SkStream.h" |
| 16 #include "SkString.h" | 16 #include "SkString.h" |
| 17 #include "SkPDFTypes.h" | 17 #include "SkPDFTypes.h" |
| 18 | 18 |
| 19 #include <cmath> | 19 #include <cmath> |
| 20 | 20 |
| 21 //static | 21 sk_sp<SkPDFArray> SkPDFUtils::RectToArray(const SkRect& rect) { |
| 22 SkPDFArray* SkPDFUtils::RectToArray(const SkRect& rect) { | 22 auto result = sk_make_sp<SkPDFArray>(); |
| 23 SkPDFArray* result = new SkPDFArray(); | |
| 24 result->reserve(4); | 23 result->reserve(4); |
| 25 result->appendScalar(rect.fLeft); | 24 result->appendScalar(rect.fLeft); |
| 26 result->appendScalar(rect.fTop); | 25 result->appendScalar(rect.fTop); |
| 27 result->appendScalar(rect.fRight); | 26 result->appendScalar(rect.fRight); |
| 28 result->appendScalar(rect.fBottom); | 27 result->appendScalar(rect.fBottom); |
| 29 return result; | 28 return result; |
| 30 } | 29 } |
| 31 | 30 |
| 32 // static | 31 sk_sp<SkPDFArray> SkPDFUtils::MatrixToArray(const SkMatrix& matrix) { |
| 33 SkPDFArray* SkPDFUtils::MatrixToArray(const SkMatrix& matrix) { | |
| 34 SkScalar values[6]; | 32 SkScalar values[6]; |
| 35 if (!matrix.asAffine(values)) { | 33 if (!matrix.asAffine(values)) { |
| 36 SkMatrix::SetAffineIdentity(values); | 34 SkMatrix::SetAffineIdentity(values); |
| 37 } | 35 } |
| 38 | 36 |
| 39 SkPDFArray* result = new SkPDFArray; | 37 auto result = sk_make_sp<SkPDFArray>(); |
| 40 result->reserve(6); | 38 result->reserve(6); |
| 41 for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) { | 39 for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) { |
| 42 result->appendScalar(values[i]); | 40 result->appendScalar(values[i]); |
| 43 } | 41 } |
| 44 return result; | 42 return result; |
| 45 } | 43 } |
| 46 | 44 |
| 47 // static | 45 // static |
| 48 void SkPDFUtils::AppendTransform(const SkMatrix& matrix, SkWStream* content) { | 46 void SkPDFUtils::AppendTransform(const SkMatrix& matrix, SkWStream* content) { |
| 49 SkScalar values[6]; | 47 SkScalar values[6]; |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 for (size_t i = 0; i < len; i++) { | 406 for (size_t i = 0; i < len; i++) { |
| 409 uint8_t c = static_cast<uint8_t>(cin[i]); | 407 uint8_t c = static_cast<uint8_t>(cin[i]); |
| 410 static const char gHex[] = "0123456789ABCDEF"; | 408 static const char gHex[] = "0123456789ABCDEF"; |
| 411 *str++ = gHex[(c >> 4) & 0xF]; | 409 *str++ = gHex[(c >> 4) & 0xF]; |
| 412 *str++ = gHex[(c ) & 0xF]; | 410 *str++ = gHex[(c ) & 0xF]; |
| 413 } | 411 } |
| 414 *str++ = '>'; | 412 *str++ = '>'; |
| 415 } | 413 } |
| 416 return result; | 414 return result; |
| 417 } | 415 } |
| OLD | NEW |