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

Unified Diff: ui/aura/mus/client_surface_embedder.cc

Issue 2873473002: Aura-Mus: Fix high-DPI gutter (Closed)
Patch Set: Addressed sadrul's comments Created 3 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 | « no previous file | ui/aura/mus/window_port_mus.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/client_surface_embedder.cc
diff --git a/ui/aura/mus/client_surface_embedder.cc b/ui/aura/mus/client_surface_embedder.cc
index 94ad333da35c65548becc266d33d6c1deaeb255f..4458206266e05b3322dc1170b2e4aed70fbab637 100644
--- a/ui/aura/mus/client_surface_embedder.cc
+++ b/ui/aura/mus/client_surface_embedder.cc
@@ -6,6 +6,7 @@
#include "cc/surfaces/surface_reference_factory.h"
#include "ui/aura/window.h"
+#include "ui/gfx/geometry/dip_util.h"
namespace aura {
namespace {
@@ -65,22 +66,26 @@ void ClientSurfaceEmbedder::SetFallbackSurfaceInfo(
void ClientSurfaceEmbedder::UpdateSizeAndGutters() {
surface_layer_->SetBounds(gfx::Rect(window_->bounds().size()));
- // TODO(fsamuel): Fix this for high DPI.
- gfx::Size fallback_surface_size(
- surface_layer_->GetFallbackSurfaceInfo()
- ? surface_layer_->GetFallbackSurfaceInfo()->size_in_pixels()
- : gfx::Size());
+ gfx::Size fallback_surface_size_in_dip;
+ const cc::SurfaceInfo* fallback_surface_info =
+ surface_layer_->GetFallbackSurfaceInfo();
+ if (fallback_surface_info) {
+ float fallback_device_scale_factor =
+ fallback_surface_info->device_scale_factor();
+ fallback_surface_size_in_dip = gfx::ConvertSizeToDIP(
+ fallback_device_scale_factor, fallback_surface_info->size_in_pixels());
+ }
gfx::Rect window_bounds(window_->bounds());
- if (fallback_surface_size.width() < window_bounds.width()) {
+ if (fallback_surface_size_in_dip.width() < window_bounds.width()) {
right_gutter_ = base::MakeUnique<ui::Layer>(ui::LAYER_SOLID_COLOR);
// TODO(fsamuel): Use the embedded client's background color.
right_gutter_->SetColor(SK_ColorWHITE);
- int width = window_bounds.width() - fallback_surface_size.width();
+ int width = window_bounds.width() - fallback_surface_size_in_dip.width();
// The right gutter also includes the bottom-right corner, if necessary.
int height = window_bounds.height() - client_area_insets_.height();
- right_gutter_->SetBounds(
- gfx::Rect(client_area_insets_.left() + fallback_surface_size.width(),
- client_area_insets_.top(), width, height));
+ right_gutter_->SetBounds(gfx::Rect(
+ client_area_insets_.left() + fallback_surface_size_in_dip.width(),
+ client_area_insets_.top(), width, height));
window_->layer()->Add(right_gutter_.get());
} else {
right_gutter_.reset();
@@ -88,15 +93,15 @@ void ClientSurfaceEmbedder::UpdateSizeAndGutters() {
// Only create a bottom gutter if a fallback surface is available. Otherwise,
// the right gutter will fill the whole window until a fallback is available.
- if (!fallback_surface_size.IsEmpty() &&
- fallback_surface_size.height() < window_bounds.height()) {
+ if (!fallback_surface_size_in_dip.IsEmpty() &&
+ fallback_surface_size_in_dip.height() < window_bounds.height()) {
bottom_gutter_ = base::MakeUnique<ui::Layer>(ui::LAYER_SOLID_COLOR);
// TODO(fsamuel): Use the embedded client's background color.
bottom_gutter_->SetColor(SK_ColorWHITE);
- int width = fallback_surface_size.width();
- int height = window_bounds.height() - fallback_surface_size.height();
+ int width = fallback_surface_size_in_dip.width();
+ int height = window_bounds.height() - fallback_surface_size_in_dip.height();
bottom_gutter_->SetBounds(
- gfx::Rect(0, fallback_surface_size.height(), width, height));
+ gfx::Rect(0, fallback_surface_size_in_dip.height(), width, height));
window_->layer()->Add(bottom_gutter_.get());
} else {
bottom_gutter_.reset();
« no previous file with comments | « no previous file | ui/aura/mus/window_port_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698