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

Side by Side Diff: ui/arc/notification/arc_custom_notification_view.cc

Issue 2640243005: Align layers for ARC notification surface to pixels (Closed)
Patch Set: . Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « ash/wm/window_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/arc/notification/arc_custom_notification_view.h" 5 #include "ui/arc/notification/arc_custom_notification_view.h"
6 6
7 #include "ash/wm/window_util.h"
7 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
8 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
9 #include "components/exo/notification_surface.h" 10 #include "components/exo/notification_surface.h"
10 #include "components/exo/surface.h" 11 #include "components/exo/surface.h"
11 #include "third_party/skia/include/core/SkColor.h" 12 #include "third_party/skia/include/core/SkColor.h"
12 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/compositor/layer_animation_observer.h" 15 #include "ui/compositor/layer_animation_observer.h"
15 #include "ui/display/screen.h" 16 #include "ui/display/screen.h"
16 #include "ui/events/event_handler.h" 17 #include "ui/events/event_handler.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 SchedulePaint(); 360 SchedulePaint();
360 } 361 }
361 362
362 void ArcCustomNotificationView::AttachSurface() { 363 void ArcCustomNotificationView::AttachSurface() {
363 if (!GetWidget()) 364 if (!GetWidget())
364 return; 365 return;
365 366
366 UpdatePreferredSize(); 367 UpdatePreferredSize();
367 Attach(surface_->window()); 368 Attach(surface_->window());
368 369
370 // The texture for this window can be placed at subpixel position
371 // with fractional scale factor. Force to align it at the pixel
372 // boundary here, and when layout is updated in Layout().
373 ash::wm::SnapWindowToPixelBoundary(surface_->window());
374
369 // Creates slide helper after this view is added to its parent. 375 // Creates slide helper after this view is added to its parent.
370 slide_helper_.reset(new SlideHelper(this)); 376 slide_helper_.reset(new SlideHelper(this));
371 377
372 // Invokes Update() in case surface is attached during a slide. 378 // Invokes Update() in case surface is attached during a slide.
373 slide_helper_->Update(); 379 slide_helper_->Update();
374 } 380 }
375 381
376 void ArcCustomNotificationView::ViewHierarchyChanged( 382 void ArcCustomNotificationView::ViewHierarchyChanged(
377 const views::View::ViewHierarchyChangedDetails& details) { 383 const views::View::ViewHierarchyChangedDetails& details) {
378 views::Widget* widget = GetWidget(); 384 views::Widget* widget = GetWidget();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 if (!floating_close_button_widget_) 431 if (!floating_close_button_widget_)
426 return; 432 return;
427 433
428 gfx::Rect close_button_bounds(floating_close_button_->GetPreferredSize()); 434 gfx::Rect close_button_bounds(floating_close_button_->GetPreferredSize());
429 close_button_bounds.set_x(contents_bounds.right() - 435 close_button_bounds.set_x(contents_bounds.right() -
430 close_button_bounds.width()); 436 close_button_bounds.width());
431 close_button_bounds.set_y(contents_bounds.y()); 437 close_button_bounds.set_y(contents_bounds.y());
432 floating_close_button_widget_->SetBounds(close_button_bounds); 438 floating_close_button_widget_->SetBounds(close_button_bounds);
433 439
434 UpdateCloseButtonVisiblity(); 440 UpdateCloseButtonVisiblity();
441
442 ash::wm::SnapWindowToPixelBoundary(surface_->window());
435 } 443 }
436 444
437 void ArcCustomNotificationView::OnPaint(gfx::Canvas* canvas) { 445 void ArcCustomNotificationView::OnPaint(gfx::Canvas* canvas) {
438 views::NativeViewHost::OnPaint(canvas); 446 views::NativeViewHost::OnPaint(canvas);
439 447
440 // Bail if there is a |surface_| or no item or no snapshot image. 448 // Bail if there is a |surface_| or no item or no snapshot image.
441 if (surface_ || !item_ || item_->snapshot().isNull()) 449 if (surface_ || !item_ || item_->snapshot().isNull())
442 return; 450 return;
443 const gfx::Rect contents_bounds = GetContentsBounds(); 451 const gfx::Rect contents_bounds = GetContentsBounds();
444 canvas->DrawImageInt(item_->snapshot(), 0, 0, item_->snapshot().width(), 452 canvas->DrawImageInt(item_->snapshot(), 0, 0, item_->snapshot().width(),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 542
535 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( 543 void ArcCustomNotificationView::OnNotificationSurfaceRemoved(
536 exo::NotificationSurface* surface) { 544 exo::NotificationSurface* surface) {
537 if (surface->notification_id() != notification_key_) 545 if (surface->notification_id() != notification_key_)
538 return; 546 return;
539 547
540 SetSurface(nullptr); 548 SetSurface(nullptr);
541 } 549 }
542 550
543 } // namespace arc 551 } // namespace arc
OLDNEW
« no previous file with comments | « ash/wm/window_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698