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

Unified Diff: ui/gfx/rect.cc

Issue 10704198: Scale to DIPs in ppb_graphics2d_impl for proper invalidation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make generic ScaleBounds method, handle scroll properly Created 8 years, 5 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
Index: ui/gfx/rect.cc
diff --git a/ui/gfx/rect.cc b/ui/gfx/rect.cc
index 300b8adbf0f746d9caf6643e9c3032751a1232e3..9a254d41882d1545fde9145f9aee90702729bb94 100644
--- a/ui/gfx/rect.cc
+++ b/ui/gfx/rect.cc
@@ -4,6 +4,8 @@
#include "ui/gfx/rect.h"
+#include <math.h>
+
#if defined(OS_WIN)
#include <windows.h>
#elif defined(OS_MACOSX)
@@ -44,6 +46,14 @@ Rect::Rect(const gfx::Point& origin, const gfx::Size& size)
Rect::~Rect() {}
+void Rect::ScaleBounds(float scale) {
+ int left = static_cast<int>(floorf(x() * scale));
+ int top = static_cast<int>(floorf(y() * scale));
+ int right = static_cast<int>(ceilf((x() + width()) * scale));
+ int bottom = static_cast<int>(ceilf((y() + height()) * scale));
+ SetRect(left, top, right - left, bottom - top);
+}
+
#if defined(OS_WIN)
Rect::Rect(const RECT& r)
: RectBaseT(gfx::Point(r.left, r.top)) {

Powered by Google App Engine
This is Rietveld 408576698