Chromium Code Reviews| Index: ui/gfx/image/image_skia_operations.cc |
| diff --git a/ui/gfx/image/image_skia_operations.cc b/ui/gfx/image/image_skia_operations.cc |
| index 4b5612ea063bc1376556b58dee5e03e80b9ffe23..07784f06687ad4073d9934fa896d461f053c5dcb 100644 |
| --- a/ui/gfx/image/image_skia_operations.cc |
| +++ b/ui/gfx/image/image_skia_operations.cc |
| @@ -14,6 +14,8 @@ |
| #include "ui/gfx/image/image_skia_rep.h" |
| #include "ui/gfx/image/image_skia_source.h" |
| #include "ui/gfx/insets.h" |
| +#include "ui/gfx/point.h" |
| +#include "ui/gfx/point_conversions.h" |
| #include "ui/gfx/rect.h" |
| #include "ui/gfx/rect_conversions.h" |
| #include "ui/gfx/size.h" |
| @@ -54,7 +56,12 @@ class BinaryImageSource : public gfx::ImageSkiaSource { |
| virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { |
| ImageSkiaRep first_rep = first_.GetRepresentation(scale_factor); |
| ImageSkiaRep second_rep = second_.GetRepresentation(scale_factor); |
| - if (first_rep.pixel_size() != second_rep.pixel_size()) { |
| + gfx::Size first_size = first_rep.pixel_size(); |
| + gfx::Size second_size = second_rep.pixel_size(); |
| + // Allow for maximum of 1 pixel mismatch due to rounding errors. |
| + int dw = first_size.width() - second_size.width(); |
| + int dh = first_size.height() - second_size.height(); |
| + if (abs(dw) > 1 || abs(dh) > 1) { |
| DCHECK_NE(first_rep.scale_factor(), second_rep.scale_factor()); |
| if (first_rep.scale_factor() == second_rep.scale_factor()) { |
| LOG(ERROR) << "ImageSkiaRep size mismatch in " << source_name_; |
| @@ -63,9 +70,9 @@ class BinaryImageSource : public gfx::ImageSkiaSource { |
| } |
| first_rep = first_.GetRepresentation(ui::SCALE_FACTOR_100P); |
| second_rep = second_.GetRepresentation(ui::SCALE_FACTOR_100P); |
| - DCHECK_EQ(first_rep.pixel_width(), second_rep.pixel_width()); |
| - DCHECK_EQ(first_rep.pixel_height(), second_rep.pixel_height()); |
| - if (first_rep.pixel_size() != second_rep.pixel_size()) { |
| + DCHECK_LE(abs(dw), 1); |
| + DCHECK_LE(abs(dh), 1); |
| + if (abs(dw) > 1 || abs(dh) > 1) { |
| LOG(ERROR) << "ImageSkiaRep size mismatch in " << source_name_; |
| return GetErrorImageRep(first_rep.scale_factor(), |
| first_rep.pixel_size()); |
| @@ -216,10 +223,14 @@ class TiledImageSource : public gfx::ImageSkiaSource { |
| virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { |
| ImageSkiaRep source_rep = source_.GetRepresentation(scale_factor); |
| float scale = ui::GetScaleFactorScale(source_rep.scale_factor()); |
| + gfx::Point point = gfx::ToFlooredPoint(gfx::ScalePoint( |
|
pkotwicz
2013/03/12 15:54:37
You should create a generic method which does this
kevers
2013/03/12 22:02:25
Done.
|
| + gfx::Point(src_x_, src_y_), scale)); |
| + gfx::Size size = gfx::ToCeiledSize(gfx::ScaleSize( |
| + gfx::Size(dst_w_, dst_h_), scale)); |
| return ImageSkiaRep( |
| SkBitmapOperations::CreateTiledBitmap( |
| source_rep.sk_bitmap(), |
| - src_x_ * scale, src_y_ * scale, dst_w_ * scale, dst_h_ * scale), |
| + point.x(), point.y(), size.width(), size.height()), |
| source_rep.scale_factor()); |
| } |