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

Side by Side Diff: chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc

Issue 8122013: Allow CanvasSkia to bind to an existing SkCanvas. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 1 more fix Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h" 5 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
10 #include "chrome/browser/instant/instant_confirm_dialog.h" 10 #include "chrome/browser/instant/instant_confirm_dialog.h"
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 513
514 void AutocompletePopupContentsView::OnMouseExited( 514 void AutocompletePopupContentsView::OnMouseExited(
515 const views::MouseEvent& event) { 515 const views::MouseEvent& event) {
516 model_->SetHoveredLine(AutocompletePopupModel::kNoMatch); 516 model_->SetHoveredLine(AutocompletePopupModel::kNoMatch);
517 } 517 }
518 518
519 //////////////////////////////////////////////////////////////////////////////// 519 ////////////////////////////////////////////////////////////////////////////////
520 // AutocompletePopupContentsView, protected: 520 // AutocompletePopupContentsView, protected:
521 521
522 void AutocompletePopupContentsView::PaintResultViews(gfx::CanvasSkia* canvas) { 522 void AutocompletePopupContentsView::PaintResultViews(gfx::CanvasSkia* canvas) {
523 canvas->drawColor(AutocompleteResultView::GetColor( 523 canvas->sk_canvas()->drawColor(AutocompleteResultView::GetColor(
524 AutocompleteResultView::NORMAL, AutocompleteResultView::BACKGROUND)); 524 AutocompleteResultView::NORMAL, AutocompleteResultView::BACKGROUND));
525 View::PaintChildren(canvas); 525 View::PaintChildren(canvas);
526 } 526 }
527 527
528 int AutocompletePopupContentsView::CalculatePopupHeight() { 528 int AutocompletePopupContentsView::CalculatePopupHeight() {
529 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); 529 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size());
530 int popup_height = 0; 530 int popup_height = 0;
531 for (size_t i = 0; i < model_->result().size(); ++i) 531 for (size_t i = 0; i < model_->result().size(); ++i)
532 popup_height += child_at(i)->GetPreferredSize().height(); 532 popup_height += child_at(i)->GetPreferredSize().height();
533 return popup_height + 533 return popup_height +
(...skipping 29 matching lines...) Expand all
563 // the blurry glass effect on DWM systems behind. We do this _after_ we paint 563 // the blurry glass effect on DWM systems behind. We do this _after_ we paint
564 // the children since they paint text, and GDI will reset this alpha data if 564 // the children since they paint text, and GDI will reset this alpha data if
565 // we paint text after this call. 565 // we paint text after this call.
566 MakeCanvasTransparent(&contents_canvas); 566 MakeCanvasTransparent(&contents_canvas);
567 567
568 // Now paint the contents of the contents canvas into the actual canvas. 568 // Now paint the contents of the contents canvas into the actual canvas.
569 SkPaint paint; 569 SkPaint paint;
570 paint.setAntiAlias(true); 570 paint.setAntiAlias(true);
571 571
572 SkShader* shader = SkShader::CreateBitmapShader( 572 SkShader* shader = SkShader::CreateBitmapShader(
573 contents_canvas.getDevice()->accessBitmap(false), 573 contents_canvas.sk_canvas()->getDevice()->accessBitmap(false),
574 SkShader::kClamp_TileMode, 574 SkShader::kClamp_TileMode,
575 SkShader::kClamp_TileMode); 575 SkShader::kClamp_TileMode);
576 paint.setShader(shader); 576 paint.setShader(shader);
577 shader->unref(); 577 shader->unref();
578 578
579 gfx::Path path; 579 gfx::Path path;
580 MakeContentsPath(&path, GetContentsBounds()); 580 MakeContentsPath(&path, GetContentsBounds());
581 canvas->AsCanvasSkia()->drawPath(path, paint); 581 canvas->GetSkCanvas()->drawPath(path, paint);
582 582
583 // Now we paint the border, so it will be alpha-blended atop the contents. 583 // Now we paint the border, so it will be alpha-blended atop the contents.
584 // This looks slightly better in the corners than drawing the contents atop 584 // This looks slightly better in the corners than drawing the contents atop
585 // the border. 585 // the border.
586 OnPaintBorder(canvas); 586 OnPaintBorder(canvas);
587 } 587 }
588 588
589 void AutocompletePopupContentsView::PaintChildren(gfx::Canvas* canvas) { 589 void AutocompletePopupContentsView::PaintChildren(gfx::Canvas* canvas) {
590 // We paint our children inside OnPaint(). 590 // We paint our children inside OnPaint().
591 } 591 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 bb.hRgnBlur = popup_region.Get(); 637 bb.hRgnBlur = popup_region.Get();
638 DwmEnableBlurBehindWindow(GetWidget()->GetNativeView(), &bb); 638 DwmEnableBlurBehindWindow(GetWidget()->GetNativeView(), &bb);
639 #endif 639 #endif
640 } 640 }
641 641
642 void AutocompletePopupContentsView::MakeCanvasTransparent( 642 void AutocompletePopupContentsView::MakeCanvasTransparent(
643 gfx::Canvas* canvas) { 643 gfx::Canvas* canvas) {
644 // Allow the window blur effect to show through the popup background. 644 // Allow the window blur effect to show through the popup background.
645 SkAlpha alpha = GetThemeProvider()->ShouldUseNativeFrame() ? 645 SkAlpha alpha = GetThemeProvider()->ShouldUseNativeFrame() ?
646 kGlassPopupAlpha : kOpaquePopupAlpha; 646 kGlassPopupAlpha : kOpaquePopupAlpha;
647 canvas->AsCanvasSkia()->drawColor(SkColorSetA( 647 canvas->GetSkCanvas()->drawColor(SkColorSetA(
648 AutocompleteResultView::GetColor(AutocompleteResultView::NORMAL, 648 AutocompleteResultView::GetColor(AutocompleteResultView::NORMAL,
649 AutocompleteResultView::BACKGROUND), alpha), SkXfermode::kDstIn_Mode); 649 AutocompleteResultView::BACKGROUND), alpha), SkXfermode::kDstIn_Mode);
650 } 650 }
651 651
652 void AutocompletePopupContentsView::OpenIndex( 652 void AutocompletePopupContentsView::OpenIndex(
653 size_t index, 653 size_t index,
654 WindowOpenDisposition disposition) { 654 WindowOpenDisposition disposition) {
655 if (!HasMatchAt(index)) 655 if (!HasMatchAt(index))
656 return; 656 return;
657 657
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 opt_in_view_ = NULL; 710 opt_in_view_ = NULL;
711 PromoCounter* counter = profile_->GetInstantPromoCounter(); 711 PromoCounter* counter = profile_->GetInstantPromoCounter();
712 DCHECK(counter); 712 DCHECK(counter);
713 counter->Hide(); 713 counter->Hide();
714 if (opt_in) { 714 if (opt_in) {
715 browser::ShowInstantConfirmDialogIfNecessary( 715 browser::ShowInstantConfirmDialogIfNecessary(
716 location_bar_->GetWidget()->GetNativeWindow(), profile_); 716 location_bar_->GetWidget()->GetNativeWindow(), profile_);
717 } 717 }
718 UpdatePopupAppearance(); 718 UpdatePopupAppearance();
719 } 719 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698