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

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_background.cc

Issue 9588003: browser: Minor changes to use SkPoint::iset() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 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
« no previous file with comments | « chrome/browser/chromeos/frame/panel_controller.cc ('k') | chrome/browser/ui/views/tabs/tab.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 "chrome/browser/ui/views/infobars/infobar_background.h" 5 #include "chrome/browser/ui/views/infobars/infobar_background.h"
6 6
7 #include "chrome/browser/infobars/infobar.h" 7 #include "chrome/browser/infobars/infobar.h"
8 #include "chrome/browser/ui/views/infobars/infobar_view.h" 8 #include "chrome/browser/ui/views/infobars/infobar_view.h"
9 #include "third_party/skia/include/effects/SkGradientShader.h" 9 #include "third_party/skia/include/effects/SkGradientShader.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/canvas_skia_paint.h" 11 #include "ui/gfx/canvas_skia_paint.h"
12 #include "ui/gfx/color_utils.h" 12 #include "ui/gfx/color_utils.h"
13 #include "ui/views/view.h" 13 #include "ui/views/view.h"
14 14
15 InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type) 15 InfoBarBackground::InfoBarBackground(InfoBarDelegate::Type infobar_type)
16 : separator_color_(SK_ColorBLACK), 16 : separator_color_(SK_ColorBLACK),
17 top_color_(GetInfoBarTopColor(infobar_type)), 17 top_color_(GetInfoBarTopColor(infobar_type)),
18 bottom_color_(GetInfoBarBottomColor(infobar_type)) { 18 bottom_color_(GetInfoBarBottomColor(infobar_type)) {
19 SetNativeControlColor( 19 SetNativeControlColor(
20 color_utils::AlphaBlend(top_color_, bottom_color_, 128)); 20 color_utils::AlphaBlend(top_color_, bottom_color_, 128));
21 } 21 }
22 22
23 InfoBarBackground::~InfoBarBackground() { 23 InfoBarBackground::~InfoBarBackground() {
24 } 24 }
25 25
26 void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const { 26 void InfoBarBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
27 SkPoint gradient_points[2] = { 27 SkPoint gradient_points[2];
28 {SkIntToScalar(0), SkIntToScalar(0)}, 28 gradient_points[0].iset(0, 0);
29 {SkIntToScalar(0), SkIntToScalar(view->height())} 29 gradient_points[1].iset(0, view->height());
30 }; 30 SkColor gradient_colors[2] = { top_color_, bottom_color_ };
31 SkColor gradient_colors[2] = {
32 top_color_,
33 bottom_color_
34 };
35 SkShader* gradient_shader = SkGradientShader::CreateLinear( 31 SkShader* gradient_shader = SkGradientShader::CreateLinear(
36 gradient_points, gradient_colors, NULL, 2, SkShader::kClamp_TileMode); 32 gradient_points, gradient_colors, NULL, 2, SkShader::kClamp_TileMode);
37 SkPaint paint; 33 SkPaint paint;
38 paint.setStrokeWidth(SkIntToScalar(InfoBar::kSeparatorLineHeight)); 34 paint.setStrokeWidth(SkIntToScalar(InfoBar::kSeparatorLineHeight));
39 paint.setStyle(SkPaint::kFill_Style); 35 paint.setStyle(SkPaint::kFill_Style);
40 paint.setStrokeCap(SkPaint::kRound_Cap); 36 paint.setStrokeCap(SkPaint::kRound_Cap);
41 paint.setShader(gradient_shader); 37 paint.setShader(gradient_shader);
42 gradient_shader->unref(); 38 gradient_shader->unref();
43 39
44 InfoBarView* infobar = static_cast<InfoBarView*>(view); 40 InfoBarView* infobar = static_cast<InfoBarView*>(view);
45 SkCanvas* canvas_skia = canvas->GetSkCanvas(); 41 SkCanvas* canvas_skia = canvas->GetSkCanvas();
46 canvas_skia->drawPath(infobar->fill_path(), paint); 42 canvas_skia->drawPath(infobar->fill_path(), paint);
47 43
48 paint.setShader(NULL); 44 paint.setShader(NULL);
49 paint.setColor(SkColorSetA(separator_color_, 45 paint.setColor(SkColorSetA(separator_color_,
50 SkColorGetA(gradient_colors[0]))); 46 SkColorGetA(gradient_colors[0])));
51 paint.setStyle(SkPaint::kStroke_Style); 47 paint.setStyle(SkPaint::kStroke_Style);
52 // Anti-alias the path so it doesn't look goofy when the edges are not at 45 48 // Anti-alias the path so it doesn't look goofy when the edges are not at 45
53 // degree angles, but don't anti-alias anything else, especially not the fill, 49 // degree angles, but don't anti-alias anything else, especially not the fill,
54 // lest we get weird color bleeding problems. 50 // lest we get weird color bleeding problems.
55 paint.setAntiAlias(true); 51 paint.setAntiAlias(true);
56 canvas_skia->drawPath(infobar->stroke_path(), paint); 52 canvas_skia->drawPath(infobar->stroke_path(), paint);
57 paint.setAntiAlias(false); 53 paint.setAntiAlias(false);
58 54
59 // Now draw the separator at the bottom. 55 // Now draw the separator at the bottom.
60 canvas->FillRect(gfx::Rect(0, view->height() - InfoBar::kSeparatorLineHeight, 56 canvas->FillRect(gfx::Rect(0, view->height() - InfoBar::kSeparatorLineHeight,
61 view->width(), InfoBar::kSeparatorLineHeight), 57 view->width(), InfoBar::kSeparatorLineHeight),
62 separator_color_); 58 separator_color_);
63 } 59 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/frame/panel_controller.cc ('k') | chrome/browser/ui/views/tabs/tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698