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

Unified Diff: Source/platform/graphics/RegionTracker.cpp

Issue 666253003: When tracking regions, treat sub-pixel areas as belonging to the region. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adjusting to comments Created 6 years, 2 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/RegionTracker.cpp
diff --git a/Source/platform/graphics/RegionTracker.cpp b/Source/platform/graphics/RegionTracker.cpp
index 759a134483cd10a9cfbe26ebe2a0a3d30261d704..6c8fef7d4684033d7412a44c41134c7d98971377 100644
--- a/Source/platform/graphics/RegionTracker.cpp
+++ b/Source/platform/graphics/RegionTracker.cpp
@@ -53,13 +53,15 @@ void RegionTracker::reset()
IntRect RegionTracker::asRect() const
{
// Returns the largest enclosed rect.
- // TODO: actually, this logic looks like its returning the smallest.
- // to return largest, shouldn't we take floor of left/top
- // and the ceil of right/bottom?
- int left = SkScalarCeilToInt(m_opaqueRect.fLeft);
- int top = SkScalarCeilToInt(m_opaqueRect.fTop);
- int right = SkScalarFloorToInt(m_opaqueRect.fRight);
- int bottom = SkScalarFloorToInt(m_opaqueRect.fBottom);
+
+ // epsilon is large enough to accommodate machine precision issues and
+ // small enough to have a negligible effect on rendered results.
+ const SkScalar epsilon = 1.0f / 512.0f;
+
+ int left = SkScalarCeilToInt(m_opaqueRect.fLeft - epsilon);
+ int top = SkScalarCeilToInt(m_opaqueRect.fTop - epsilon);
+ int right = SkScalarFloorToInt(m_opaqueRect.fRight + epsilon);
+ int bottom = SkScalarFloorToInt(m_opaqueRect.fBottom + epsilon);
return IntRect(left, top, right-left, bottom-top);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698