| OLD | NEW |
| 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 "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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <commctrl.h> | 8 #include <commctrl.h> |
| 9 #include <dwmapi.h> | 9 #include <dwmapi.h> |
| 10 #include <objidl.h> | 10 #include <objidl.h> |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 int model_index, | 375 int model_index, |
| 376 const gfx::Font& font, | 376 const gfx::Font& font, |
| 377 const gfx::Font& bold_font) { | 377 const gfx::Font& bold_font) { |
| 378 return new AutocompleteResultView(model, model_index, font, bold_font); | 378 return new AutocompleteResultView(model, model_index, font, bold_font); |
| 379 } | 379 } |
| 380 | 380 |
| 381 //////////////////////////////////////////////////////////////////////////////// | 381 //////////////////////////////////////////////////////////////////////////////// |
| 382 // AutocompletePopupContentsView, views::View overrides, protected: | 382 // AutocompletePopupContentsView, views::View overrides, protected: |
| 383 | 383 |
| 384 void AutocompletePopupContentsView::OnPaint(gfx::Canvas* canvas) { | 384 void AutocompletePopupContentsView::OnPaint(gfx::Canvas* canvas) { |
| 385 // We paint our children in an unconventional way. | 385 gfx::Path path; |
| 386 // | 386 MakeContentsPath(&path, GetContentsBounds()); |
| 387 // Because the border of this view creates an anti-aliased round-rect region | 387 canvas->Save(); |
| 388 // for the contents, we need to render our rectangular result child views into | 388 canvas->sk_canvas()->clipPath(path, |
| 389 // this round rect region. We can't use a simple clip because clipping is | 389 SkRegion::kIntersect_Op, |
| 390 // 1-bit and we get nasty jagged edges. | 390 true /* doAntialias */); |
| 391 // | 391 PaintResultViews(canvas); |
| 392 // Instead, we paint all our children into a second canvas and use that as a | |
| 393 // shader to fill a path representing the round-rect clipping region. This | |
| 394 // yields a nice anti-aliased edge. | |
| 395 gfx::Canvas contents_canvas(size(), true); | |
| 396 PaintResultViews(&contents_canvas); | |
| 397 | 392 |
| 398 // We want the contents background to be slightly transparent so we can see | 393 // We want the contents background to be slightly transparent so we can see |
| 399 // the blurry glass effect on DWM systems behind. We do this _after_ we paint | 394 // the blurry glass effect on DWM systems behind. We do this _after_ we paint |
| 400 // the children since they paint text, and GDI will reset this alpha data if | 395 // the children since they paint text, and GDI will reset this alpha data if |
| 401 // we paint text after this call. | 396 // we paint text after this call. |
| 402 MakeCanvasTransparent(&contents_canvas); | 397 MakeCanvasTransparent(canvas); |
| 403 | 398 canvas->Restore(); |
| 404 // Now paint the contents of the contents canvas into the actual canvas. | |
| 405 SkPaint paint; | |
| 406 paint.setAntiAlias(true); | |
| 407 | |
| 408 SkShader* shader = SkShader::CreateBitmapShader( | |
| 409 contents_canvas.sk_canvas()->getDevice()->accessBitmap(false), | |
| 410 SkShader::kClamp_TileMode, | |
| 411 SkShader::kClamp_TileMode); | |
| 412 paint.setShader(shader); | |
| 413 shader->unref(); | |
| 414 | |
| 415 gfx::Path path; | |
| 416 MakeContentsPath(&path, GetContentsBounds()); | |
| 417 canvas->DrawPath(path, paint); | |
| 418 | 399 |
| 419 // Now we paint the border, so it will be alpha-blended atop the contents. | 400 // Now we paint the border, so it will be alpha-blended atop the contents. |
| 420 // This looks slightly better in the corners than drawing the contents atop | 401 // This looks slightly better in the corners than drawing the contents atop |
| 421 // the border. | 402 // the border. |
| 422 OnPaintBorder(canvas); | 403 OnPaintBorder(canvas); |
| 423 } | 404 } |
| 424 | 405 |
| 425 void AutocompletePopupContentsView::PaintChildren(gfx::Canvas* canvas) { | 406 void AutocompletePopupContentsView::PaintChildren(gfx::Canvas* canvas) { |
| 426 // We paint our children inside OnPaint(). | 407 // We paint our children inside OnPaint(). |
| 427 } | 408 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 // bubble appear at the same height as the Star bubble. | 511 // bubble appear at the same height as the Star bubble. |
| 531 location_bar_bounds.Inset(LocationBarView::kNormalHorizontalEdgeThickness, | 512 location_bar_bounds.Inset(LocationBarView::kNormalHorizontalEdgeThickness, |
| 532 0); | 513 0); |
| 533 } | 514 } |
| 534 gfx::Point location_bar_origin(location_bar_bounds.origin()); | 515 gfx::Point location_bar_origin(location_bar_bounds.origin()); |
| 535 views::View::ConvertPointToScreen(location_bar_, &location_bar_origin); | 516 views::View::ConvertPointToScreen(location_bar_, &location_bar_origin); |
| 536 location_bar_bounds.set_origin(location_bar_origin); | 517 location_bar_bounds.set_origin(location_bar_origin); |
| 537 return bubble_border_->GetBounds( | 518 return bubble_border_->GetBounds( |
| 538 location_bar_bounds, gfx::Size(location_bar_bounds.width(), h)); | 519 location_bar_bounds, gfx::Size(location_bar_bounds.width(), h)); |
| 539 } | 520 } |
| OLD | NEW |