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

Unified Diff: chrome/browser/ui/views/status_bubble_views.cc

Issue 568343002: Removed a few manual roundrect path creations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change variable names Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/canvas.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/status_bubble_views.cc
diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc
index e0571a03e1d33609c7e99df97ad7b6cec5bbad4a..ff3bae7ab0d094f3b768277318a3b7b070806e34 100644
--- a/chrome/browser/ui/views/status_bubble_views.cc
+++ b/chrome/browser/ui/views/status_bubble_views.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/ui/elide_url.h"
#include "net/base/net_util.h"
#include "third_party/skia/include/core/SkPaint.h"
-#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkRect.h"
#include "ui/aura/window.h"
#include "ui/base/theme_provider.h"
@@ -360,81 +359,46 @@ void StatusBubbleViews::StatusView::OnPaint(gfx::Canvas* canvas) {
gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen();
// Figure out how to round the bubble's four corners.
- SkScalar rad[8];
+ int radTL = 0;
+ int radTR = 0;
+ int radBL = 0;
+ int radBR = 0;
// Top Edges - if the bubble is in its bottom position (sticking downwards),
// then we square the top edges. Otherwise, we square the edges based on the
// position of the bubble within the window (the bubble is positioned in the
// southeast corner in RTL and in the southwest corner in LTR).
- if (style_ == STYLE_BOTTOM) {
- // Top Left corner.
- rad[0] = 0;
- rad[1] = 0;
-
- // Top Right corner.
- rad[2] = 0;
- rad[3] = 0;
- } else {
+ if (style_ != STYLE_BOTTOM) {
if (base::i18n::IsRTL() != (style_ == STYLE_STANDARD_RIGHT)) {
// The text is RtL or the bubble is on the right side (but not both).
-
- // Top Left corner.
- rad[0] = SkIntToScalar(kBubbleCornerRadius);
- rad[1] = SkIntToScalar(kBubbleCornerRadius);
-
- // Top Right corner.
- rad[2] = 0;
- rad[3] = 0;
+ radTL = kBubbleCornerRadius;
} else {
- // Top Left corner.
- rad[0] = 0;
- rad[1] = 0;
-
- // Top Right corner.
- rad[2] = SkIntToScalar(kBubbleCornerRadius);
- rad[3] = SkIntToScalar(kBubbleCornerRadius);
+ radTR = kBubbleCornerRadius;
}
}
- // Bottom edges - square these off if the bubble is in its standard position
- // (sticking upward).
- if (style_ == STYLE_STANDARD || style_ == STYLE_STANDARD_RIGHT) {
- // Bottom Right Corner.
- rad[4] = 0;
- rad[5] = 0;
-
- // Bottom Left Corner.
- rad[6] = 0;
- rad[7] = 0;
- } else {
- // Bottom Right Corner.
- rad[4] = SkIntToScalar(kBubbleCornerRadius);
- rad[5] = SkIntToScalar(kBubbleCornerRadius);
-
- // Bottom Left Corner.
- rad[6] = SkIntToScalar(kBubbleCornerRadius);
- rad[7] = SkIntToScalar(kBubbleCornerRadius);
+ // Bottom edges - Keep these squared off if the bubble is in its standard
+ // position (sticking upward).
+ if (style_ != STYLE_STANDARD && style_ != STYLE_STANDARD_RIGHT) {
+ radBR = kBubbleCornerRadius;
+ radBL = kBubbleCornerRadius;
}
// Draw the bubble's shadow.
int width = popup_bounds.width();
int height = popup_bounds.height();
- SkRect rect(gfx::RectToSkRect(gfx::Rect(popup_bounds.size())));
- SkPath shadow_path;
- shadow_path.addRoundRect(rect, rad, SkPath::kCW_Direction);
+ gfx::Rect rect(gfx::Rect(popup_bounds.size()));
SkPaint shadow_paint;
shadow_paint.setAntiAlias(true);
shadow_paint.setColor(kShadowColor);
- canvas->DrawPath(shadow_path, shadow_paint);
+ canvas->DrawRoundRect(rect, radTL, radTR, radBL, radBR, shadow_paint);
sky 2014/09/15 19:11:17 This seems to be the only place using this variant
sky 2014/09/15 21:51:07 You should be able to use canvas->sk_canvas()->...
// Draw the bubble.
- rect.set(SkIntToScalar(kShadowThickness),
- SkIntToScalar(kShadowThickness),
- SkIntToScalar(width - kShadowThickness),
- SkIntToScalar(height - kShadowThickness));
- SkPath path;
- path.addRoundRect(rect, rad, SkPath::kCW_Direction);
- canvas->DrawPath(path, paint);
+ rect.SetRect(SkIntToScalar(kShadowThickness),
+ SkIntToScalar(kShadowThickness),
+ SkIntToScalar(width),
+ SkIntToScalar(height));
+ canvas->DrawRoundRect(rect, radTL, radTR, radBL, radBR, paint);
// Draw highlight text and then the text body. In order to make sure the text
// is aligned to the right on RTL UIs, we mirror the text bounds if the
« no previous file with comments | « no previous file | ui/gfx/canvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698