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

Side by Side Diff: ui/views/background.h

Issue 2637383003: Change Painter factory functions to unique_ptr (Closed)
Patch Set: msw review Created 3 years, 11 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 | « chrome/browser/ui/views/toolbar/browser_actions_container.cc ('k') | ui/views/background.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 #ifndef UI_VIEWS_BACKGROUND_H_ 5 #ifndef UI_VIEWS_BACKGROUND_H_
6 #define UI_VIEWS_BACKGROUND_H_ 6 #define UI_VIEWS_BACKGROUND_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "build/build_config.h" 13 #include "build/build_config.h"
12 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
13 #include "ui/views/views_export.h" 15 #include "ui/views/views_export.h"
14 16
15 #if defined(OS_WIN) 17 #if defined(OS_WIN)
16 #include <windows.h> 18 #include <windows.h>
17 #endif // defined(OS_WIN) 19 #endif // defined(OS_WIN)
18 20
19 namespace gfx { 21 namespace gfx {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // Creates a background that fills the canvas in the specified color. 55 // Creates a background that fills the canvas in the specified color.
54 static Background* CreateSolidBackground(int r, int g, int b, int a) { 56 static Background* CreateSolidBackground(int r, int g, int b, int a) {
55 return CreateSolidBackground(SkColorSetARGB(a, r, g, b)); 57 return CreateSolidBackground(SkColorSetARGB(a, r, g, b));
56 } 58 }
57 59
58 // Creates a background that contains a vertical gradient that varies 60 // Creates a background that contains a vertical gradient that varies
59 // from |color1| to |color2| 61 // from |color1| to |color2|
60 static Background* CreateVerticalGradientBackground(SkColor color1, 62 static Background* CreateVerticalGradientBackground(SkColor color1,
61 SkColor color2); 63 SkColor color2);
62 64
63 // Creates a background that contains a vertical gradient. The gradient can
64 // have multiple |colors|. The |pos| array contains the relative positions of
65 // each corresponding color. |colors| and |pos| must be the same size. The
66 // first element in |pos| must be 0.0 and the last element must be 1.0.
67 // |count| contains the number of elements in |colors| and |pos|.
68 static Background* CreateVerticalMultiColorGradientBackground(SkColor* colors,
69 SkScalar* pos,
70 size_t count);
71
72 // Creates Chrome's standard panel background 65 // Creates Chrome's standard panel background
73 static Background* CreateStandardPanelBackground(); 66 static Background* CreateStandardPanelBackground();
74 67
75 // Creates a Background from the specified Painter. If owns_painter is 68 // Creates a Background from the specified Painter.
76 // true, the Painter is deleted when the Border is deleted. 69 static Background* CreateBackgroundPainter(std::unique_ptr<Painter> painter);
77 static Background* CreateBackgroundPainter(bool owns_painter,
78 Painter* painter);
79 70
80 // Render the background for the provided view 71 // Render the background for the provided view
81 virtual void Paint(gfx::Canvas* canvas, View* view) const = 0; 72 virtual void Paint(gfx::Canvas* canvas, View* view) const = 0;
82 73
83 // Set a solid, opaque color to be used when drawing backgrounds of native 74 // Set a solid, opaque color to be used when drawing backgrounds of native
84 // controls. Unfortunately alpha=0 is not an option. 75 // controls. Unfortunately alpha=0 is not an option.
85 void SetNativeControlColor(SkColor color); 76 void SetNativeControlColor(SkColor color);
86 77
87 // Returns the "background color". This is equivalent to the color set in 78 // Returns the "background color". This is equivalent to the color set in
88 // SetNativeControlColor(). For solid backgrounds, this is the color; for 79 // SetNativeControlColor(). For solid backgrounds, this is the color; for
89 // gradient backgrounds, it's the midpoint of the gradient; for painter 80 // gradient backgrounds, it's the midpoint of the gradient; for painter
90 // backgrounds, this is not useful (returns a default color). 81 // backgrounds, this is not useful (returns a default color).
91 SkColor get_color() const { return color_; } 82 SkColor get_color() const { return color_; }
92 83
93 private: 84 private:
94 SkColor color_; 85 SkColor color_;
95 86
96 DISALLOW_COPY_AND_ASSIGN(Background); 87 DISALLOW_COPY_AND_ASSIGN(Background);
97 }; 88 };
98 89
99 } // namespace views 90 } // namespace views
100 91
101 #endif // UI_VIEWS_BACKGROUND_H_ 92 #endif // UI_VIEWS_BACKGROUND_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/browser_actions_container.cc ('k') | ui/views/background.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698