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

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

Issue 12389084: Fix Aura backing store to work with non-integer scale factors. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge with trunk Created 7 years, 9 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/backing_store_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/backing_store_aura.cc
diff --git a/content/browser/renderer_host/backing_store_aura.cc b/content/browser/renderer_host/backing_store_aura.cc
index fccc19284a89a213f1d19ed0e631f2a184c0637f..5f976c45ea3b488ca32cd04c1e92430cfbc05fcc 100644
--- a/content/browser/renderer_host/backing_store_aura.cc
+++ b/content/browser/renderer_host/backing_store_aura.cc
@@ -16,6 +16,15 @@
#include "ui/gfx/size_conversions.h"
#include "ui/gfx/vector2d_conversions.h"
+namespace {
+
+gfx::Size ToPixelSize(gfx::Size dipSize, float scale) {
+ return gfx::ToCeiledSize(gfx::ScaleSize(dipSize, scale));
+}
+
+} // namespace
+
+
namespace content {
// Assume that somewhere along the line, someone will do width * height * 4
@@ -30,8 +39,7 @@ BackingStoreAura::BackingStoreAura(RenderWidgetHost* widget,
: BackingStore(widget, size) {
device_scale_factor_ =
ui::GetScaleFactorScale(GetScaleFactorForView(widget->GetView()));
- gfx::Size pixel_size = gfx::ToFlooredSize(
- gfx::ScaleSize(size, device_scale_factor_));
+ gfx::Size pixel_size = ToPixelSize(size, device_scale_factor_);
bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
pixel_size.width(), pixel_size.height());
bitmap_.allocPixels();
@@ -52,12 +60,10 @@ void BackingStoreAura::ScaleFactorChanged(float device_scale_factor) {
if (device_scale_factor == device_scale_factor_)
return;
- gfx::Size old_pixel_size = gfx::ToFlooredSize(
- gfx::ScaleSize(size(), device_scale_factor_));
+ gfx::Size old_pixel_size = ToPixelSize(size(), device_scale_factor_);
device_scale_factor_ = device_scale_factor;
- gfx::Size pixel_size = gfx::ToFlooredSize(
- gfx::ScaleSize(size(), device_scale_factor_));
+ gfx::Size pixel_size = ToPixelSize(size(), device_scale_factor_);
SkBitmap new_bitmap;
new_bitmap.setConfig(SkBitmap::kARGB_8888_Config,
pixel_size.width(), pixel_size.height());
@@ -79,8 +85,7 @@ void BackingStoreAura::ScaleFactorChanged(float device_scale_factor) {
size_t BackingStoreAura::MemorySize() {
// NOTE: The computation may be different when the canvas is a subrectangle of
// a larger bitmap.
- return gfx::ToFlooredSize(
- gfx::ScaleSize(size(), device_scale_factor_)).GetArea() * 4;
+ return ToPixelSize(size(), device_scale_factor_).GetArea() * 4;
}
void BackingStoreAura::PaintToBackingStore(
@@ -95,7 +100,7 @@ void BackingStoreAura::PaintToBackingStore(
if (bitmap_rect.IsEmpty())
return;
- gfx::Rect pixel_bitmap_rect = gfx::ToEnclosedRect(
+ gfx::Rect pixel_bitmap_rect = gfx::ToEnclosingRect(
gfx::ScaleRect(bitmap_rect, scale_factor));
const int width = pixel_bitmap_rect.width();
« no previous file with comments | « content/browser/renderer_host/backing_store_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698