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

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

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: DrawingDisplayItem 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"
11 #include "cc/paint/paint_flags.h"
11 #include "third_party/skia/include/core/SkDrawLooper.h" 12 #include "third_party/skia/include/core/SkDrawLooper.h"
12 #include "third_party/skia/include/core/SkPaint.h"
13 #include "third_party/skia/include/core/SkPath.h" 13 #include "third_party/skia/include/core/SkPath.h"
14 #include "ui/base/material_design/material_design_controller.h" 14 #include "ui/base/material_design/material_design_controller.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/path.h" 18 #include "ui/gfx/path.h"
19 #include "ui/gfx/scoped_canvas.h" 19 #include "ui/gfx/scoped_canvas.h"
20 #include "ui/gfx/shadow_value.h" 20 #include "ui/gfx/shadow_value.h"
21 #include "ui/gfx/skia_paint_util.h" 21 #include "ui/gfx/skia_paint_util.h"
22 #include "ui/resources/grit/ui_resources.h" 22 #include "ui/resources/grit/ui_resources.h"
(...skipping 480 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 SkPaint paint; 513 cc::PaintFlags paint;
514 paint.setStyle(SkPaint::kFill_Style); 514 paint.setStyle(cc::PaintFlags::kFill_Style);
515 paint.setColor(background_color_); 515 paint.setColor(background_color_);
516 516
517 canvas->DrawPath(path, paint); 517 canvas->DrawPath(path, paint);
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 SkPaint paint; 533 cc::PaintFlags paint;
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 paint.setLooper(gfx::CreateShadowDrawLooperCorrectBlur(shadows));
543 paint.setColor(SkColorSetA(SK_ColorBLACK, 0x26)); 543 paint.setColor(SkColorSetA(SK_ColorBLACK, 0x26));
(...skipping 19 matching lines...) Expand all
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 SkPaint paint; 573 cc::PaintFlags paint;
574 paint.setAntiAlias(true); 574 paint.setAntiAlias(true);
575 paint.setStyle(SkPaint::kFill_Style); 575 paint.setStyle(cc::PaintFlags::kFill_Style);
576 paint.setColor(border_->background_color()); 576 paint.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(), paint);
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