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

Unified Diff: ui/gfx/canvas.cc

Issue 605893002: Revert of Changes NineImagePainter to snap to (enclosed) pixel boundaries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/nine_image_painter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/canvas.cc
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index 7ce7c4725ecb39041d534c57fdb26ea3abca8f4b..6ea067eb696ca04b86a44bf4ce2473a22a810bd5 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -13,9 +13,7 @@
#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"
@@ -348,13 +346,14 @@
const SkBitmap& bitmap = image_rep.sk_bitmap();
float bitmap_scale = image_rep.scale();
- ScopedCanvas scoper(this);
+ canvas_->save();
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,
@@ -416,14 +415,13 @@
// Ensure that the direction of the x and y scales is preserved. This is
// important for RTL layouts.
- matrix.setScaleX(matrix.getScaleX() > 0 ? 1.0f : -1.0f);
- matrix.setScaleY(matrix.getScaleY() > 0 ? 1.0f : -1.0f);
-
- // Floor so that we get consistent rounding.
- matrix.setTranslateX(SkScalarFloorToScalar(matrix.getTranslateX()));
- matrix.setTranslateY(SkScalarFloorToScalar(matrix.getTranslateY()));
-
- ScopedCanvas scoper(this);
+ matrix.getScaleX() > 0 ? matrix.setScaleX(1.0f) : matrix.setScaleX(-1.0f);
+ matrix.getScaleY() > 0 ? matrix.setScaleY(1.0f) : matrix.setScaleY(-1.0f);
+
+ matrix.setTranslateX(SkScalarRoundToInt(matrix.getTranslateX()));
+ matrix.setTranslateY(SkScalarRoundToInt(matrix.getTranslateY()));
+
+ Save();
canvas_->setMatrix(matrix);
@@ -440,6 +438,9 @@
paint,
image_scale_,
true);
+
+ // Restore the state of the canvas.
+ Restore();
}
void Canvas::DrawImageInPath(const ImageSkia& image,
« no previous file with comments | « no previous file | ui/gfx/nine_image_painter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698