| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkPDFDeviceFlattener.h" | 8 #include "SkPDFDeviceFlattener.h" |
| 9 | 9 |
| 10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
| 11 | 11 |
| 12 static SkISize SkSizeToISize(const SkSize& size) { | 12 static SkISize SkSizeToISize(const SkSize& size) { |
| 13 return SkISize::Make(SkScalarRoundToInt(size.width()), SkScalarRoundToInt(si
ze.height())); | 13 return SkISize::Make(SkScalarRoundToInt(size.width()), SkScalarRoundToInt(si
ze.height())); |
| 14 } | 14 } |
| 15 | 15 |
| 16 SkPDFDeviceFlattener::SkPDFDeviceFlattener(const SkSize& pageSize, const SkRect*
trimBox) | 16 SkPDFDeviceFlattener::SkPDFDeviceFlattener(const SkSize& pageSize, const SkRect*
trimBox) |
| 17 : SkPDFDevice(SkSizeToISize(pageSize), | 17 : SkPDFDevice(SkSizeToISize(pageSize), |
| 18 SkSizeToISize(pageSize), | 18 SkSizeToISize(pageSize), |
| 19 SkMatrix::I()) { | 19 SkMatrix::I()) { |
| 20 // TODO(edisonn): store the trimbox on emit. | 20 // TODO(edisonn): store the trimbox on emit. |
| 21 } | 21 } |
| 22 | 22 |
| 23 SkPDFDeviceFlattener::~SkPDFDeviceFlattener() { | 23 SkPDFDeviceFlattener::~SkPDFDeviceFlattener() { |
| 24 } | 24 } |
| 25 | 25 |
| 26 static void flattenPaint(const SkDraw& d, SkPaint* paint) { | 26 static void flattenPaint(const SkDraw& d, SkPaint* paint) { |
| 27 if (paint->getShader()) { | 27 if (paint->getShader()) { |
| 28 SkMatrix local = paint->getShader()->getLocalMatrix(); | 28 SkMatrix local = paint->getShader()->getLocalMatrix(); |
| 29 local.preConcat(*d.fMatrix); | 29 local.preConcat(*d.fMatrix); |
| 30 // TODO(dominikg): The shader has been created else where. Need a wrappe
r? |
| 30 paint->getShader()->setLocalMatrix(local); | 31 paint->getShader()->setLocalMatrix(local); |
| 31 } | 32 } |
| 32 } | 33 } |
| 33 | 34 |
| 34 void SkPDFDeviceFlattener::drawPoints(const SkDraw& d, SkCanvas::PointMode mode, | 35 void SkPDFDeviceFlattener::drawPoints(const SkDraw& d, SkCanvas::PointMode mode, |
| 35 size_t count, const SkPoint points[], | 36 size_t count, const SkPoint points[], |
| 36 const SkPaint& paint) { | 37 const SkPaint& paint) { |
| 37 if (!mustFlatten(d)) { | 38 if (!mustFlatten(d)) { |
| 38 INHERITED::drawPoints(d, mode, count, points, paint); | 39 INHERITED::drawPoints(d, mode, count, points, paint); |
| 39 return; | 40 return; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 bool SkPDFDeviceFlattener::mustFlatten(const SkDraw& d) const { | 147 bool SkPDFDeviceFlattener::mustFlatten(const SkDraw& d) const { |
| 147 // TODO(edisonn): testability, add flag to force return true. | 148 // TODO(edisonn): testability, add flag to force return true. |
| 148 return d.fMatrix->hasPerspective(); | 149 return d.fMatrix->hasPerspective(); |
| 149 } | 150 } |
| 150 | 151 |
| 151 bool SkPDFDeviceFlattener::mustPathText(const SkDraw& d, const SkPaint&) { | 152 bool SkPDFDeviceFlattener::mustPathText(const SkDraw& d, const SkPaint&) { |
| 152 // TODO(edisonn): testability, add flag to force return true. | 153 // TODO(edisonn): testability, add flag to force return true. |
| 153 // TODO(edisonn): TBD: How to flatten MaskFilter. | 154 // TODO(edisonn): TBD: How to flatten MaskFilter. |
| 154 return d.fMatrix->hasPerspective(); | 155 return d.fMatrix->hasPerspective(); |
| 155 } | 156 } |
| OLD | NEW |