OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkDrawCommand.h" | 10 #include "SkDrawCommand.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.width()), | 91 canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.width()), |
92 SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.width()) ); | 92 SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.width()) ); |
93 } else { | 93 } else { |
94 canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.height()) , | 94 canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.height()) , |
95 SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.height() )); | 95 SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.height() )); |
96 } | 96 } |
97 canvas->translate(-bounds.centerX(), -bounds.centerY()); | 97 canvas->translate(-bounds.centerX(), -bounds.centerY()); |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 void render_path(SkCanvas* canvas, const SkPath& path) { | 101 void render_path(SkCanvas* canvas, const SkPath& path) { |
robertphillips
2015/10/06 14:12:55
Maybe put this after the clear so we get a blank s
f(malita)
2015/10/06 14:17:21
Done.
| |
102 const SkRect& bounds = path.getBounds(); | |
103 if (bounds.isEmpty()) { | |
104 return; | |
105 } | |
106 | |
107 SkAutoCanvasRestore acr(canvas, true); | |
102 canvas->clear(0xFFFFFFFF); | 108 canvas->clear(0xFFFFFFFF); |
103 canvas->save(); | |
104 | |
105 const SkRect& bounds = path.getBounds(); | |
106 | 109 |
107 xlate_and_scale_to_bounds(canvas, bounds); | 110 xlate_and_scale_to_bounds(canvas, bounds); |
108 | 111 |
109 SkPaint p; | 112 SkPaint p; |
110 p.setColor(SK_ColorBLACK); | 113 p.setColor(SK_ColorBLACK); |
111 p.setStyle(SkPaint::kStroke_Style); | 114 p.setStyle(SkPaint::kStroke_Style); |
112 | 115 |
113 canvas->drawPath(path, p); | 116 canvas->drawPath(path, p); |
114 canvas->restore(); | |
115 } | 117 } |
116 | 118 |
117 void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRec t = nullptr) { | 119 void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRec t = nullptr) { |
118 const SkISize& size = canvas->getDeviceSize(); | 120 const SkISize& size = canvas->getDeviceSize(); |
119 | 121 |
120 SkScalar xScale = SkIntToScalar(size.fWidth-2) / input.width(); | 122 SkScalar xScale = SkIntToScalar(size.fWidth-2) / input.width(); |
121 SkScalar yScale = SkIntToScalar(size.fHeight-2) / input.height(); | 123 SkScalar yScale = SkIntToScalar(size.fHeight-2) / input.height(); |
122 | 124 |
123 if (input.width() > input.height()) { | 125 if (input.width() > input.height()) { |
124 yScale *= input.height() / (float) input.width(); | 126 yScale *= input.height() / (float) input.width(); |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
975 | 977 |
976 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { | 978 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { |
977 fUserMatrix = userMatrix; | 979 fUserMatrix = userMatrix; |
978 } | 980 } |
979 | 981 |
980 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { | 982 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { |
981 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); | 983 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); |
982 canvas->setMatrix(temp); | 984 canvas->setMatrix(temp); |
983 } | 985 } |
984 | 986 |
OLD | NEW |