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

Side by Side Diff: ash/wm/frame_painter.cc

Issue 10192001: ash: Fix transparency glitches in window header (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/frame_painter.h ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/wm/frame_painter.h" 5 #include "ash/wm/frame_painter.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "base/logging.h" // DCHECK 10 #include "base/logging.h" // DCHECK
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 shader->unref(); 108 shader->unref();
109 // Adjust canvas to compensate for image sampling offset, draw, then adjust 109 // Adjust canvas to compensate for image sampling offset, draw, then adjust
110 // back. This is cheaper than pushing/popping the entire canvas state. 110 // back. This is cheaper than pushing/popping the entire canvas state.
111 canvas->sk_canvas()->translate(SkIntToScalar(-bitmap_offset_x), 0); 111 canvas->sk_canvas()->translate(SkIntToScalar(-bitmap_offset_x), 0);
112 canvas->DrawPath(path, *paint); 112 canvas->DrawPath(path, *paint);
113 canvas->sk_canvas()->translate(SkIntToScalar(bitmap_offset_x), 0); 113 canvas->sk_canvas()->translate(SkIntToScalar(bitmap_offset_x), 0);
114 } 114 }
115 115
116 // Returns true if |window| is a visible, normal window. 116 // Returns true if |window| is a visible, normal window.
117 bool IsVisibleNormalWindow(aura::Window* window) { 117 bool IsVisibleNormalWindow(aura::Window* window) {
118 // We must use TargetVisibility() because windows animate in and out and
119 // IsVisible() also tracks the layer visibility state.
118 return window && 120 return window &&
119 window->IsVisible() && 121 window->TargetVisibility() &&
120 window->type() == aura::client::WINDOW_TYPE_NORMAL; 122 window->type() == aura::client::WINDOW_TYPE_NORMAL;
121 } 123 }
122 124
123 } // namespace 125 } // namespace
124 126
125 namespace ash { 127 namespace ash {
126 128
127 // static 129 // static
128 int FramePainter::kActiveWindowOpacity = 230; // "Linus-approved" values 130 int FramePainter::kActiveWindowOpacity = 230; // "Linus-approved" values
129 int FramePainter::kInactiveWindowOpacity = 204; 131 int FramePainter::kInactiveWindowOpacity = 204;
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 if (ash::wm::IsWindowMaximized(window) || 509 if (ash::wm::IsWindowMaximized(window) ||
508 ash::wm::IsWindowFullscreen(window)) { 510 ash::wm::IsWindowFullscreen(window)) {
509 window->set_hit_test_bounds_override_inner(gfx::Insets()); 511 window->set_hit_test_bounds_override_inner(gfx::Insets());
510 } else { 512 } else {
511 window->set_hit_test_bounds_override_inner( 513 window->set_hit_test_bounds_override_inner(
512 gfx::Insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize, 514 gfx::Insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize,
513 kResizeInsideBoundsSize, kResizeInsideBoundsSize)); 515 kResizeInsideBoundsSize, kResizeInsideBoundsSize));
514 } 516 }
515 } 517 }
516 518
519 void FramePainter::OnWindowVisibilityChanged(aura::Window* window,
520 bool visible) {
521 // Hiding a window may trigger the solo window appearance in a different
522 // window.
523 if (!visible && UseSoloWindowHeader())
524 SchedulePaintForSoloWindow();
525 }
526
517 void FramePainter::OnWindowDestroying(aura::Window* destroying) { 527 void FramePainter::OnWindowDestroying(aura::Window* destroying) {
518 DCHECK_EQ(window_, destroying); 528 DCHECK_EQ(window_, destroying);
519 // Must be removed here and not in the destructor, as the aura::Window is 529 // Must be removed here and not in the destructor, as the aura::Window is
520 // already destroyed when our destructor runs. 530 // already destroyed when our destructor runs.
521 window_->RemoveObserver(this); 531 window_->RemoveObserver(this);
522 window_ = NULL; 532 window_ = NULL;
523 533
524 // For purposes of painting and solo window computation, we're done. 534 // For purposes of painting and solo window computation, we're done.
525 instances_->erase(this); 535 instances_->erase(this);
526 536
527 // If we have two or more windows open and we close this one, we might trigger 537 // If we have two or more windows open and we close this one, we might trigger
528 // the solo window appearance. If so, find the window that is becoming solo 538 // the solo window appearance for another window.
529 // and schedule it to paint. 539 if (UseSoloWindowHeader())
530 if (UseSoloWindowHeader()) { 540 SchedulePaintForSoloWindow();
531 for (std::set<FramePainter*>::const_iterator it = instances_->begin();
532 it != instances_->end();
533 ++it) {
534 FramePainter* painter = *it;
535 if (IsVisibleNormalWindow(painter->window_) && painter->frame_)
536 painter->frame_->non_client_view()->SchedulePaint();
537 }
538 }
539 } 541 }
540 542
541 /////////////////////////////////////////////////////////////////////////////// 543 ///////////////////////////////////////////////////////////////////////////////
542 // ui::AnimationDelegate overrides: 544 // ui::AnimationDelegate overrides:
543 545
544 void FramePainter::AnimationProgressed(const ui::Animation* animation) { 546 void FramePainter::AnimationProgressed(const ui::Animation* animation) {
545 frame_->SchedulePaintInRect(gfx::Rect(header_frame_bounds_)); 547 frame_->SchedulePaintInRect(gfx::Rect(header_frame_bounds_));
546 } 548 }
547 549
548 /////////////////////////////////////////////////////////////////////////////// 550 ///////////////////////////////////////////////////////////////////////////////
(...skipping 26 matching lines...) Expand all
575 ++it) { 577 ++it) {
576 if (IsVisibleNormalWindow((*it)->window_)) { 578 if (IsVisibleNormalWindow((*it)->window_)) {
577 window_count++; 579 window_count++;
578 if (window_count > 1) 580 if (window_count > 1)
579 return false; 581 return false;
580 } 582 }
581 } 583 }
582 return window_count == 1; 584 return window_count == 1;
583 } 585 }
584 586
587 // static
588 void FramePainter::SchedulePaintForSoloWindow() {
589 for (std::set<FramePainter*>::const_iterator it = instances_->begin();
590 it != instances_->end();
591 ++it) {
592 FramePainter* painter = *it;
593 if (IsVisibleNormalWindow(painter->window_))
594 painter->frame_->non_client_view()->SchedulePaint();
595 }
596 }
597
585 } // namespace ash 598 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/frame_painter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698