summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-25 17:09:40 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-25 17:09:40 +0000
commitcf3645c5d322938c31e2797795ee234dae29daf2 (patch)
tree76362123904fa87b2411b433b2e9b5efeb00240e /ui/gfx
parent5d59e0a3f6d7e0c78d99069441aaeccbfc009b38 (diff)
downloadchromium_src-cf3645c5d322938c31e2797795ee234dae29daf2.zip
chromium_src-cf3645c5d322938c31e2797795ee234dae29daf2.tar.gz
chromium_src-cf3645c5d322938c31e2797795ee234dae29daf2.tar.bz2
cc: Fix anti-aliasing of axis-aligned quads.
Axis-aligned quads with edges not aligned to pixel boundaries are rendered incorrectly. These quads need anti-aliasing but current code that determines if anti-aliasing is needed thinks that no axis-aligned quads need it. This fixes the problem by adding alignment to pixel boundaries as an additional requirement to avoid anti-aliasing. BUG=169374 TEST=GLRendererPixelTest.AxisAligned,GLRendererShaderTest.DrawSolidColorShad Review URL: https://chromiumcodereview.appspot.com/12538005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196423 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/rect_conversions.cc18
-rw-r--r--ui/gfx/rect_conversions.h5
2 files changed, 23 insertions, 0 deletions
diff --git a/ui/gfx/rect_conversions.cc b/ui/gfx/rect_conversions.cc
index 251c0371..c548828 100644
--- a/ui/gfx/rect_conversions.cc
+++ b/ui/gfx/rect_conversions.cc
@@ -52,6 +52,24 @@ Rect ToNearestRect(const RectF& rect) {
return Rect(min_x, min_y, max_x - min_x, max_y - min_y);
}
+bool IsNearestRectWithinDistance(const gfx::RectF& rect, float distance) {
+ float float_min_x = rect.x();
+ float float_min_y = rect.y();
+ float float_max_x = rect.right();
+ float float_max_y = rect.bottom();
+
+ int min_x = ToRoundedInt(float_min_x);
+ int min_y = ToRoundedInt(float_min_y);
+ int max_x = ToRoundedInt(float_max_x);
+ int max_y = ToRoundedInt(float_max_y);
+
+ return
+ (std::abs(min_x - float_min_x) < distance) &&
+ (std::abs(min_y - float_min_y) < distance) &&
+ (std::abs(max_x - float_max_x) < distance) &&
+ (std::abs(max_y - float_max_y) < distance);
+}
+
Rect ToFlooredRectDeprecated(const RectF& rect) {
return Rect(ToFlooredInt(rect.x()),
ToFlooredInt(rect.y()),
diff --git a/ui/gfx/rect_conversions.h b/ui/gfx/rect_conversions.h
index 7c971b3..854fb6e 100644
--- a/ui/gfx/rect_conversions.h
+++ b/ui/gfx/rect_conversions.h
@@ -22,6 +22,11 @@ UI_EXPORT Rect ToEnclosedRect(const RectF& rect);
// you should use a different method.
UI_EXPORT Rect ToNearestRect(const RectF& rect);
+// Returns true if the Rect produced after snapping the corners of the RectF
+// to an integer grid is withing |distance|.
+UI_EXPORT bool IsNearestRectWithinDistance(
+ const gfx::RectF& rect, float distance);
+
// Returns a Rect obtained by flooring the values of the given RectF.
// Please prefer the previous two functions in new code.
UI_EXPORT Rect ToFlooredRectDeprecated(const RectF& rect);