OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/canvas.h" | 5 #include "ui/gfx/canvas.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 paint); | 173 paint); |
174 DrawRect(Rect(rect.x(), rect.y(), 1, rect.height()), paint); | 174 DrawRect(Rect(rect.x(), rect.y(), 1, rect.height()), paint); |
175 DrawRect(Rect(rect.x() + rect.width() - 1, rect.y(), 1, rect.height()), | 175 DrawRect(Rect(rect.x() + rect.width() - 1, rect.y(), 1, rect.height()), |
176 paint); | 176 paint); |
177 } | 177 } |
178 | 178 |
179 void Canvas::Save() { | 179 void Canvas::Save() { |
180 canvas_->save(); | 180 canvas_->save(); |
181 } | 181 } |
182 | 182 |
183 float Canvas::SaveAndUnscale() { | |
sky
2015/10/13 22:23:11
How expensive is save? The common case is scale=1.
Peter Kasting
2015/10/13 22:34:42
Save() is very cheap. Also we can't get rid of it
| |
184 Save(); | |
185 SkScalar scale_factor = 1.0f / image_scale_; | |
sky
2015/10/13 22:23:11
I'm not familiar enough with what we want to happe
Peter Kasting
2015/10/13 22:34:42
I did, but I'm not convinced that's what we actual
| |
186 canvas_->scale(scale_factor, scale_factor); | |
187 return image_scale_; | |
188 } | |
189 | |
183 void Canvas::SaveLayerAlpha(uint8 alpha) { | 190 void Canvas::SaveLayerAlpha(uint8 alpha) { |
184 canvas_->saveLayerAlpha(NULL, alpha); | 191 canvas_->saveLayerAlpha(NULL, alpha); |
185 } | 192 } |
186 | 193 |
187 void Canvas::SaveLayerAlpha(uint8 alpha, const Rect& layer_bounds) { | 194 void Canvas::SaveLayerAlpha(uint8 alpha, const Rect& layer_bounds) { |
188 SkRect bounds(RectToSkRect(layer_bounds)); | 195 SkRect bounds(RectToSkRect(layer_bounds)); |
189 canvas_->saveLayerAlpha(&bounds, alpha); | 196 canvas_->saveLayerAlpha(&bounds, alpha); |
190 } | 197 } |
191 | 198 |
192 void Canvas::Restore() { | 199 void Canvas::Restore() { |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
621 // by the paint). | 628 // by the paint). |
622 SkPaint p(paint); | 629 SkPaint p(paint); |
623 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); | 630 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); |
624 p.setShader(shader.get()); | 631 p.setShader(shader.get()); |
625 | 632 |
626 // The rect will be filled by the bitmap. | 633 // The rect will be filled by the bitmap. |
627 canvas_->drawRect(dest_rect, p); | 634 canvas_->drawRect(dest_rect, p); |
628 } | 635 } |
629 | 636 |
630 } // namespace gfx | 637 } // namespace gfx |
OLD | NEW |