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

Side by Side Diff: ui/views/bubble/bubble_border.cc

Issue 2680943002: ui: Clean up naming of paint-related identifiers (Closed)
Patch Set: Created 3 years, 10 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 | « ui/views/border.cc ('k') | ui/views/bubble/tray_bubble_view.cc » ('j') | 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 "ui/views/bubble/bubble_border.h" 5 #include "ui/views/bubble/bubble_border.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 SkDoubleToScalar(tip_y + multiplier * offset_to_next_vertex)); 503 SkDoubleToScalar(tip_y + multiplier * offset_to_next_vertex));
504 path->close(); 504 path->close();
505 } 505 }
506 506
507 void BubbleBorder::DrawArrow(gfx::Canvas* canvas, 507 void BubbleBorder::DrawArrow(gfx::Canvas* canvas,
508 const gfx::Rect& arrow_bounds) const { 508 const gfx::Rect& arrow_bounds) const {
509 DCHECK(!UseMd()); 509 DCHECK(!UseMd());
510 canvas->DrawImageInt(*GetArrowImage(), arrow_bounds.x(), arrow_bounds.y()); 510 canvas->DrawImageInt(*GetArrowImage(), arrow_bounds.x(), arrow_bounds.y());
511 SkPath path; 511 SkPath path;
512 GetArrowPathFromArrowBounds(arrow_bounds, &path); 512 GetArrowPathFromArrowBounds(arrow_bounds, &path);
513 cc::PaintFlags paint; 513 cc::PaintFlags flags;
514 paint.setStyle(cc::PaintFlags::kFill_Style); 514 flags.setStyle(cc::PaintFlags::kFill_Style);
515 paint.setColor(background_color_); 515 flags.setColor(background_color_);
516 516
517 canvas->DrawPath(path, paint); 517 canvas->DrawPath(path, flags);
518 } 518 }
519 519
520 SkRRect BubbleBorder::GetClientRect(const View& view) const { 520 SkRRect BubbleBorder::GetClientRect(const View& view) const {
521 gfx::RectF bounds(view.GetLocalBounds()); 521 gfx::RectF bounds(view.GetLocalBounds());
522 bounds.Inset(GetInsets()); 522 bounds.Inset(GetInsets());
523 return SkRRect::MakeRectXY(gfx::RectFToSkRect(bounds), 523 return SkRRect::MakeRectXY(gfx::RectFToSkRect(bounds),
524 GetBorderCornerRadius(), GetBorderCornerRadius()); 524 GetBorderCornerRadius(), GetBorderCornerRadius());
525 } 525 }
526 526
527 void BubbleBorder::PaintMd(const View& view, gfx::Canvas* canvas) { 527 void BubbleBorder::PaintMd(const View& view, gfx::Canvas* canvas) {
528 if (shadow_ == NO_ASSETS) 528 if (shadow_ == NO_ASSETS)
529 return PaintNoAssets(view, canvas); 529 return PaintNoAssets(view, canvas);
530 530
531 gfx::ScopedCanvas scoped(canvas); 531 gfx::ScopedCanvas scoped(canvas);
532 532
533 cc::PaintFlags paint; 533 cc::PaintFlags flags;
534 std::vector<gfx::ShadowValue> shadows; 534 std::vector<gfx::ShadowValue> shadows;
535 // gfx::ShadowValue counts blur pixels both inside and outside the shape, 535 // gfx::ShadowValue counts blur pixels both inside and outside the shape,
536 // whereas these blur values only describe the outside portion, hence they 536 // whereas these blur values only describe the outside portion, hence they
537 // must be doubled. 537 // must be doubled.
538 shadows.emplace_back(gfx::Vector2d(0, kSmallShadowVerticalOffset), 538 shadows.emplace_back(gfx::Vector2d(0, kSmallShadowVerticalOffset),
539 2 * kSmallShadowBlur, kSmallShadowColor); 539 2 * kSmallShadowBlur, kSmallShadowColor);
540 shadows.emplace_back(gfx::Vector2d(0, kLargeShadowVerticalOffset), 540 shadows.emplace_back(gfx::Vector2d(0, kLargeShadowVerticalOffset),
541 2 * kLargeShadowBlur, kLargeShadowColor); 541 2 * kLargeShadowBlur, kLargeShadowColor);
542 paint.setLooper(gfx::CreateShadowDrawLooperCorrectBlur(shadows)); 542 flags.setLooper(gfx::CreateShadowDrawLooperCorrectBlur(shadows));
543 paint.setColor(SkColorSetA(SK_ColorBLACK, 0x26)); 543 flags.setColor(SkColorSetA(SK_ColorBLACK, 0x26));
544 paint.setAntiAlias(true); 544 flags.setAntiAlias(true);
545 545
546 SkRRect r_rect = GetClientRect(view); 546 SkRRect r_rect = GetClientRect(view);
547 canvas->sk_canvas()->clipRRect(r_rect, SkClipOp::kDifference, 547 canvas->sk_canvas()->clipRRect(r_rect, SkClipOp::kDifference,
548 true /*doAntiAlias*/); 548 true /*doAntiAlias*/);
549 549
550 // The border is drawn outside the content area. 550 // The border is drawn outside the content area.
551 const SkScalar one_pixel = 551 const SkScalar one_pixel =
552 SkFloatToScalar(kBorderStrokeThicknessPx / canvas->image_scale()); 552 SkFloatToScalar(kBorderStrokeThicknessPx / canvas->image_scale());
553 r_rect.inset(-one_pixel, -one_pixel); 553 r_rect.inset(-one_pixel, -one_pixel);
554 canvas->sk_canvas()->drawRRect(r_rect, paint); 554 canvas->sk_canvas()->drawRRect(r_rect, flags);
555 } 555 }
556 556
557 void BubbleBorder::PaintNoAssets(const View& view, gfx::Canvas* canvas) { 557 void BubbleBorder::PaintNoAssets(const View& view, gfx::Canvas* canvas) {
558 gfx::ScopedCanvas scoped(canvas); 558 gfx::ScopedCanvas scoped(canvas);
559 canvas->sk_canvas()->clipRRect(GetClientRect(view), SkClipOp::kDifference, 559 canvas->sk_canvas()->clipRRect(GetClientRect(view), SkClipOp::kDifference,
560 true /*doAntiAlias*/); 560 true /*doAntiAlias*/);
561 canvas->sk_canvas()->drawColor(SK_ColorTRANSPARENT, SkBlendMode::kSrc); 561 canvas->sk_canvas()->drawColor(SK_ColorTRANSPARENT, SkBlendMode::kSrc);
562 } 562 }
563 563
564 internal::BorderImages* BubbleBorder::GetImagesForTest() const { 564 internal::BorderImages* BubbleBorder::GetImagesForTest() const {
565 return images_; 565 return images_;
566 } 566 }
567 567
568 void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const { 568 void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
569 if (border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER) 569 if (border_->shadow() == BubbleBorder::NO_SHADOW_OPAQUE_BORDER)
570 canvas->DrawColor(border_->background_color()); 570 canvas->DrawColor(border_->background_color());
571 571
572 // Fill the contents with a round-rect region to match the border images. 572 // Fill the contents with a round-rect region to match the border images.
573 cc::PaintFlags paint; 573 cc::PaintFlags flags;
574 paint.setAntiAlias(true); 574 flags.setAntiAlias(true);
575 paint.setStyle(cc::PaintFlags::kFill_Style); 575 flags.setStyle(cc::PaintFlags::kFill_Style);
576 paint.setColor(border_->background_color()); 576 flags.setColor(border_->background_color());
577 SkPath path; 577 SkPath path;
578 gfx::RectF bounds(view->GetLocalBounds()); 578 gfx::RectF bounds(view->GetLocalBounds());
579 bounds.Inset(gfx::InsetsF(border_->GetInsets())); 579 bounds.Inset(gfx::InsetsF(border_->GetInsets()));
580 580
581 canvas->DrawRoundRect(bounds, border_->GetBorderCornerRadius(), paint); 581 canvas->DrawRoundRect(bounds, border_->GetBorderCornerRadius(), flags);
582 } 582 }
583 583
584 } // namespace views 584 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/border.cc ('k') | ui/views/bubble/tray_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698