| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 float Canvas::UndoDeviceScaleFactor() { | 179 float Canvas::UndoDeviceScaleFactor() { |
| 180 SkScalar scale_factor = 1.0f / image_scale_; | 180 SkScalar scale_factor = 1.0f / image_scale_; |
| 181 canvas_->scale(scale_factor, scale_factor); | 181 canvas_->scale(scale_factor, scale_factor); |
| 182 return image_scale_; | 182 return image_scale_; |
| 183 } | 183 } |
| 184 | 184 |
| 185 void Canvas::Save() { | 185 void Canvas::Save() { |
| 186 canvas_->save(); | 186 canvas_->save(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void Canvas::SaveLayerAlpha(uint8 alpha) { | 189 void Canvas::SaveLayerAlpha(uint8_t alpha) { |
| 190 canvas_->saveLayerAlpha(NULL, alpha); | 190 canvas_->saveLayerAlpha(NULL, alpha); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void Canvas::SaveLayerAlpha(uint8 alpha, const Rect& layer_bounds) { | 193 void Canvas::SaveLayerAlpha(uint8_t alpha, const Rect& layer_bounds) { |
| 194 SkRect bounds(RectToSkRect(layer_bounds)); | 194 SkRect bounds(RectToSkRect(layer_bounds)); |
| 195 canvas_->saveLayerAlpha(&bounds, alpha); | 195 canvas_->saveLayerAlpha(&bounds, alpha); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void Canvas::Restore() { | 198 void Canvas::Restore() { |
| 199 canvas_->restore(); | 199 canvas_->restore(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void Canvas::ClipRect(const Rect& rect) { | 202 void Canvas::ClipRect(const Rect& rect) { |
| 203 canvas_->clipRect(RectToSkRect(rect)); | 203 canvas_->clipRect(RectToSkRect(rect)); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 DrawLine(Point(x1, y2), Point(x2, y2), paint); | 333 DrawLine(Point(x1, y2), Point(x2, y2), paint); |
| 334 DrawLine(Point(x1, y1), Point(x1, y2), paint); | 334 DrawLine(Point(x1, y1), Point(x1, y2), paint); |
| 335 DrawLine(Point(x2, y1), Point(x2, y2 + 1), paint); | 335 DrawLine(Point(x2, y1), Point(x2, y2 + 1), paint); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y) { | 338 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y) { |
| 339 SkPaint paint; | 339 SkPaint paint; |
| 340 DrawImageInt(image, x, y, paint); | 340 DrawImageInt(image, x, y, paint); |
| 341 } | 341 } |
| 342 | 342 |
| 343 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y, uint8 a) { | 343 void Canvas::DrawImageInt(const ImageSkia& image, int x, int y, uint8_t a) { |
| 344 SkPaint paint; | 344 SkPaint paint; |
| 345 paint.setAlpha(a); | 345 paint.setAlpha(a); |
| 346 DrawImageInt(image, x, y, paint); | 346 DrawImageInt(image, x, y, paint); |
| 347 } | 347 } |
| 348 | 348 |
| 349 void Canvas::DrawImageInt(const ImageSkia& image, | 349 void Canvas::DrawImageInt(const ImageSkia& image, |
| 350 int x, | 350 int x, |
| 351 int y, | 351 int y, |
| 352 const SkPaint& paint) { | 352 const SkPaint& paint) { |
| 353 const ImageSkiaRep& image_rep = image.GetRepresentation(image_scale_); | 353 const ImageSkiaRep& image_rep = image.GetRepresentation(image_scale_); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 // by the paint). | 584 // by the paint). |
| 585 SkPaint p(paint); | 585 SkPaint p(paint); |
| 586 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); | 586 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); |
| 587 p.setShader(shader.get()); | 587 p.setShader(shader.get()); |
| 588 | 588 |
| 589 // The rect will be filled by the bitmap. | 589 // The rect will be filled by the bitmap. |
| 590 canvas_->drawRect(dest_rect, p); | 590 canvas_->drawRect(dest_rect, p); |
| 591 } | 591 } |
| 592 | 592 |
| 593 } // namespace gfx | 593 } // namespace gfx |
| OLD | NEW |