Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: ui/gfx/canvas.cc

Issue 1425163002: gfx: Rename canvas SaveAndUnscale to UnscaleTheDeviceScaleFactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ninepatchscale
Patch Set: scopedunscale: . Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 paint.setShader(shader.get()); 168 paint.setShader(shader.get());
169 169
170 DrawRect(Rect(rect.x(), rect.y(), rect.width(), 1), paint); 170 DrawRect(Rect(rect.x(), rect.y(), rect.width(), 1), paint);
171 DrawRect(Rect(rect.x(), rect.y() + rect.height() - 1, rect.width(), 1), 171 DrawRect(Rect(rect.x(), rect.y() + rect.height() - 1, rect.width(), 1),
172 paint); 172 paint);
173 DrawRect(Rect(rect.x(), rect.y(), 1, rect.height()), paint); 173 DrawRect(Rect(rect.x(), rect.y(), 1, rect.height()), paint);
174 DrawRect(Rect(rect.x() + rect.width() - 1, rect.y(), 1, rect.height()), 174 DrawRect(Rect(rect.x() + rect.width() - 1, rect.y(), 1, rect.height()),
175 paint); 175 paint);
176 } 176 }
177 177
178 float Canvas::UnscaleTheDeviceScaleFactor() {
179 SkScalar scale_factor = 1.0f / image_scale_;
180 canvas_->scale(scale_factor, scale_factor);
181 return image_scale_;
182 }
183
178 void Canvas::Save() { 184 void Canvas::Save() {
179 canvas_->save(); 185 canvas_->save();
180 } 186 }
181 187
182 float Canvas::SaveAndUnscale() {
183 Save();
184 SkScalar scale_factor = 1.0f / image_scale_;
185 canvas_->scale(scale_factor, scale_factor);
186 return image_scale_;
187 }
188
189 void Canvas::SaveLayerAlpha(uint8 alpha) { 188 void Canvas::SaveLayerAlpha(uint8 alpha) {
190 canvas_->saveLayerAlpha(NULL, alpha); 189 canvas_->saveLayerAlpha(NULL, alpha);
191 } 190 }
192 191
193 void Canvas::SaveLayerAlpha(uint8 alpha, const Rect& layer_bounds) { 192 void Canvas::SaveLayerAlpha(uint8 alpha, const Rect& layer_bounds) {
194 SkRect bounds(RectToSkRect(layer_bounds)); 193 SkRect bounds(RectToSkRect(layer_bounds));
195 canvas_->saveLayerAlpha(&bounds, alpha); 194 canvas_->saveLayerAlpha(&bounds, alpha);
196 } 195 }
197 196
198 void Canvas::Restore() { 197 void Canvas::Restore() {
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // by the paint). 576 // by the paint).
578 SkPaint p(paint); 577 SkPaint p(paint);
579 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); 578 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality);
580 p.setShader(shader.get()); 579 p.setShader(shader.get());
581 580
582 // The rect will be filled by the bitmap. 581 // The rect will be filled by the bitmap.
583 canvas_->drawRect(dest_rect, p); 582 canvas_->drawRect(dest_rect, p);
584 } 583 }
585 584
586 } // namespace gfx 585 } // namespace gfx
OLDNEW
« ui/gfx/canvas.h ('K') | « ui/gfx/canvas.h ('k') | ui/gfx/nine_image_painter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698