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

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 304973003: [Aura] Translate web contents area to nearest physical pixel boundary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_aura.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 0607c92c0ec51533cc973ef7bf1656c8dc97a1d6..63f5b0e74c54fb500adecfdfae281786fe71bb74 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
+#include "cc/layers/layer.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
#include "cc/resources/texture_mailbox.h"
@@ -613,6 +614,7 @@ void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
}
}
+ SnapToPhysicalPixelBoundary();
InternalSetBounds(gfx::Rect(relative_origin, rect.size()));
}
@@ -962,6 +964,25 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceInitialized(int host_id,
int route_id) {
}
+void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() {
+ // The top left corner of our view in window coordinates might not land on a
+ // device pixel boundary if we have a non-integer device scale. In that case,
+ // to avoid the web contents area looking blurry we translate the web contents
+ // in the +x, +y direction to land on the nearest pixel boundary. This may
+ // cause the bottom and right edges to be clipped slightly, but that's ok.
+ gfx::Point view_offset_dips = window_->GetBoundsInRootWindow().origin();
+ gfx::PointF view_offset = view_offset_dips;
+ view_offset.Scale(current_device_scale_factor_);
+ gfx::PointF view_offset_snapped(std::ceil(view_offset.x()),
+ std::ceil(view_offset.y()));
+
+ gfx::Vector2dF fudge = view_offset_snapped - view_offset;
+ fudge.Scale(1.0 / current_device_scale_factor_);
+ gfx::Transform fudge_transform;
+ fudge_transform.Translate(fudge.x(), fudge.y());
+ GetLayer()->cc_layer()->SetTransform(fudge_transform);
+}
+
void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
if (HasDisplayPropertyChanged(window_))
host_->InvalidateScreenInfo();
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698