| Index: ui/gfx/canvas.cc
|
| diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
|
| index 6ea067eb696ca04b86a44bf4ce2473a22a810bd5..7ce7c4725ecb39041d534c57fdb26ea3abca8f4b 100644
|
| --- a/ui/gfx/canvas.cc
|
| +++ b/ui/gfx/canvas.cc
|
| @@ -13,7 +13,9 @@
|
| #include "third_party/skia/include/effects/SkGradientShader.h"
|
| #include "ui/gfx/font_list.h"
|
| #include "ui/gfx/geometry/rect_conversions.h"
|
| +#include "ui/gfx/geometry/safe_integer_conversions.h"
|
| #include "ui/gfx/rect.h"
|
| +#include "ui/gfx/scoped_canvas.h"
|
| #include "ui/gfx/size_conversions.h"
|
| #include "ui/gfx/skia_util.h"
|
| #include "ui/gfx/transform.h"
|
| @@ -346,14 +348,13 @@ void Canvas::DrawImageInt(const ImageSkia& image,
|
| const SkBitmap& bitmap = image_rep.sk_bitmap();
|
| float bitmap_scale = image_rep.scale();
|
|
|
| - canvas_->save();
|
| + ScopedCanvas scoper(this);
|
| canvas_->scale(SkFloatToScalar(1.0f / bitmap_scale),
|
| SkFloatToScalar(1.0f / bitmap_scale));
|
| canvas_->drawBitmap(bitmap,
|
| SkFloatToScalar(x * bitmap_scale),
|
| SkFloatToScalar(y * bitmap_scale),
|
| &paint);
|
| - canvas_->restore();
|
| }
|
|
|
| void Canvas::DrawImageInt(const ImageSkia& image,
|
| @@ -415,13 +416,14 @@ void Canvas::DrawImageIntInPixel(const ImageSkia& image,
|
|
|
| // Ensure that the direction of the x and y scales is preserved. This is
|
| // important for RTL layouts.
|
| - matrix.getScaleX() > 0 ? matrix.setScaleX(1.0f) : matrix.setScaleX(-1.0f);
|
| - matrix.getScaleY() > 0 ? matrix.setScaleY(1.0f) : matrix.setScaleY(-1.0f);
|
| + matrix.setScaleX(matrix.getScaleX() > 0 ? 1.0f : -1.0f);
|
| + matrix.setScaleY(matrix.getScaleY() > 0 ? 1.0f : -1.0f);
|
|
|
| - matrix.setTranslateX(SkScalarRoundToInt(matrix.getTranslateX()));
|
| - matrix.setTranslateY(SkScalarRoundToInt(matrix.getTranslateY()));
|
| + // Floor so that we get consistent rounding.
|
| + matrix.setTranslateX(SkScalarFloorToScalar(matrix.getTranslateX()));
|
| + matrix.setTranslateY(SkScalarFloorToScalar(matrix.getTranslateY()));
|
|
|
| - Save();
|
| + ScopedCanvas scoper(this);
|
|
|
| canvas_->setMatrix(matrix);
|
|
|
| @@ -438,9 +440,6 @@ void Canvas::DrawImageIntInPixel(const ImageSkia& image,
|
| paint,
|
| image_scale_,
|
| true);
|
| -
|
| - // Restore the state of the canvas.
|
| - Restore();
|
| }
|
|
|
| void Canvas::DrawImageInPath(const ImageSkia& image,
|
|
|