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

Side by Side Diff: ui/views/window/frame_background.cc

Issue 10447053: Converts remainder of ui and chrome/browser/ui/views/frame to use ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | « ui/views/window/frame_background.h ('k') | ui/views/window/window_resources.h » ('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/window/frame_background.h" 5 #include "ui/views/window/frame_background.h"
6 6
7 #include "grit/ui_resources.h" 7 #include "grit/ui_resources.h"
8 #include "third_party/skia/include/core/SkCanvas.h" 8 #include "third_party/skia/include/core/SkCanvas.h"
9 #include "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/base/theme_provider.h" 10 #include "ui/base/theme_provider.h"
11 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
12 #include "ui/views/view.h" 12 #include "ui/views/view.h"
13 13
14 namespace views { 14 namespace views {
15 15
16 FrameBackground::FrameBackground() 16 FrameBackground::FrameBackground()
17 : frame_color_(0), 17 : frame_color_(0),
18 theme_bitmap_(NULL), 18 theme_image_(NULL),
19 theme_overlay_bitmap_(NULL), 19 theme_overlay_image_(NULL),
20 top_area_height_(0), 20 top_area_height_(0),
21 left_edge_(NULL), 21 left_edge_(NULL),
22 top_edge_(NULL), 22 top_edge_(NULL),
23 right_edge_(NULL), 23 right_edge_(NULL),
24 bottom_edge_(NULL), 24 bottom_edge_(NULL),
25 top_left_corner_(NULL), 25 top_left_corner_(NULL),
26 top_right_corner_(NULL), 26 top_right_corner_(NULL),
27 bottom_left_corner_(NULL), 27 bottom_left_corner_(NULL),
28 bottom_right_corner_(NULL), 28 bottom_right_corner_(NULL),
29 maximized_top_left_(NULL), 29 maximized_top_left_(NULL),
30 maximized_top_right_(NULL), 30 maximized_top_right_(NULL),
31 maximized_top_offset_(0), 31 maximized_top_offset_(0),
32 theme_background_y_(0) { 32 theme_background_y_(0) {
33 } 33 }
34 34
35 FrameBackground::~FrameBackground() { 35 FrameBackground::~FrameBackground() {
36 } 36 }
37 37
38 void FrameBackground::SetSideImages(const SkBitmap* left, 38 void FrameBackground::SetSideImages(const gfx::ImageSkia* left,
39 const SkBitmap* top, 39 const gfx::ImageSkia* top,
40 const SkBitmap* right, 40 const gfx::ImageSkia* right,
41 const SkBitmap* bottom) { 41 const gfx::ImageSkia* bottom) {
42 left_edge_ = left; 42 left_edge_ = left;
43 top_edge_ = top; 43 top_edge_ = top;
44 right_edge_ = right; 44 right_edge_ = right;
45 bottom_edge_ = bottom; 45 bottom_edge_ = bottom;
46 } 46 }
47 47
48 void FrameBackground::SetCornerImages(const SkBitmap* top_left, 48 void FrameBackground::SetCornerImages(const gfx::ImageSkia* top_left,
49 const SkBitmap* top_right, 49 const gfx::ImageSkia* top_right,
50 const SkBitmap* bottom_left, 50 const gfx::ImageSkia* bottom_left,
51 const SkBitmap* bottom_right) { 51 const gfx::ImageSkia* bottom_right) {
52 top_left_corner_ = top_left; 52 top_left_corner_ = top_left;
53 top_right_corner_ = top_right; 53 top_right_corner_ = top_right;
54 bottom_left_corner_ = bottom_left; 54 bottom_left_corner_ = bottom_left;
55 bottom_right_corner_ = bottom_right; 55 bottom_right_corner_ = bottom_right;
56 } 56 }
57 57
58 void FrameBackground::PaintRestored(gfx::Canvas* canvas, View* view) const { 58 void FrameBackground::PaintRestored(gfx::Canvas* canvas, View* view) const {
59 // Fill with the frame color first so we have a constant background for 59 // Fill with the frame color first so we have a constant background for
60 // areas not covered by the theme image. 60 // areas not covered by the theme image.
61 PaintFrameColor(canvas, view); 61 PaintFrameColor(canvas, view);
62 62
63 // Draw the theme frame. 63 // Draw the theme frame.
64 canvas->TileImageInt(*theme_bitmap_, 64 canvas->TileImageInt(*theme_image_,
65 0, 0, view->width(), theme_bitmap_->height()); 65 0, 0, view->width(), theme_image_->height());
66 66
67 // Draw the theme frame overlay, if available. 67 // Draw the theme frame overlay, if available.
68 if (theme_overlay_bitmap_) 68 if (theme_overlay_image_)
69 canvas->DrawBitmapInt(*theme_overlay_bitmap_, 0, 0); 69 canvas->DrawBitmapInt(*theme_overlay_image_, 0, 0);
70 70
71 // Draw the top corners and edge, scaling the corner images down if they 71 // Draw the top corners and edge, scaling the corner images down if they
72 // are too big and relative to the vertical space available. 72 // are too big and relative to the vertical space available.
73 int top_left_height = 73 int top_left_height =
74 std::min(top_left_corner_->height(), 74 std::min(top_left_corner_->height(),
75 view->height() - bottom_left_corner_->height()); 75 view->height() - bottom_left_corner_->height());
76 canvas->DrawBitmapInt(*top_left_corner_, 76 canvas->DrawBitmapInt(*top_left_corner_,
77 0, 0, top_left_corner_->width(), top_left_height, 77 0, 0, top_left_corner_->width(), top_left_height,
78 0, 0, top_left_corner_->width(), top_left_height, 78 0, 0, top_left_corner_->width(), top_left_height,
79 false); 79 false);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 0, top_left_height, 122 0, top_left_height,
123 left_edge_->width(), left_edge_height); 123 left_edge_->width(), left_edge_height);
124 } 124 }
125 125
126 void FrameBackground::PaintMaximized(gfx::Canvas* canvas, View* view) const { 126 void FrameBackground::PaintMaximized(gfx::Canvas* canvas, View* view) const {
127 // We will be painting from top_offset to top_offset + theme_frame_height. If 127 // We will be painting from top_offset to top_offset + theme_frame_height. If
128 // this is less than top_area_height_, we need to paint the frame color 128 // this is less than top_area_height_, we need to paint the frame color
129 // to fill in the area beneath the image. 129 // to fill in the area beneath the image.
130 // TODO(jamescook): I'm not sure this is correct, as it doesn't seem to fully 130 // TODO(jamescook): I'm not sure this is correct, as it doesn't seem to fully
131 // account for the top_offset, but this is how it worked before. 131 // account for the top_offset, but this is how it worked before.
132 int theme_frame_bottom = maximized_top_offset_ + theme_bitmap_->height(); 132 int theme_frame_bottom = maximized_top_offset_ + theme_image_->height();
133 if (top_area_height_ > theme_frame_bottom) { 133 if (top_area_height_ > theme_frame_bottom) {
134 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_), 134 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_),
135 frame_color_); 135 frame_color_);
136 } 136 }
137 137
138 int left_offset = 0; 138 int left_offset = 0;
139 int right_offset = 0; 139 int right_offset = 0;
140 140
141 // Draw top-left and top-right corners to give maximized ChromeOS windows 141 // Draw top-left and top-right corners to give maximized ChromeOS windows
142 // a rounded appearance. 142 // a rounded appearance.
143 if (maximized_top_left_ || maximized_top_right_) { 143 if (maximized_top_left_ || maximized_top_right_) {
144 // If we have either a left or right we should have both. 144 // If we have either a left or right we should have both.
145 DCHECK(maximized_top_left_ && maximized_top_right_); 145 DCHECK(maximized_top_left_ && maximized_top_right_);
146 left_offset = maximized_top_left_->width(); 146 left_offset = maximized_top_left_->width();
147 right_offset = maximized_top_right_->width(); 147 right_offset = maximized_top_right_->width();
148 canvas->DrawBitmapInt(*maximized_top_left_, 0, 0); 148 canvas->DrawBitmapInt(*maximized_top_left_, 0, 0);
149 canvas->DrawBitmapInt(*maximized_top_right_, 149 canvas->DrawBitmapInt(*maximized_top_right_,
150 view->width() - right_offset, 0); 150 view->width() - right_offset, 0);
151 } 151 }
152 152
153 // Draw the theme frame. 153 // Draw the theme frame.
154 canvas->TileImageInt(*theme_bitmap_, 154 canvas->TileImageInt(*theme_image_,
155 left_offset, 155 left_offset,
156 maximized_top_offset_, 156 maximized_top_offset_,
157 view->width() - (left_offset + right_offset), 157 view->width() - (left_offset + right_offset),
158 theme_bitmap_->height()); 158 theme_image_->height());
159 // Draw the theme frame overlay, if available. 159 // Draw the theme frame overlay, if available.
160 if (theme_overlay_bitmap_) 160 if (theme_overlay_image_)
161 canvas->DrawBitmapInt(*theme_overlay_bitmap_, 0, theme_background_y_); 161 canvas->DrawBitmapInt(*theme_overlay_image_, 0, theme_background_y_);
162 } 162 }
163 163
164 void FrameBackground::PaintFrameColor(gfx::Canvas* canvas, View* view) const { 164 void FrameBackground::PaintFrameColor(gfx::Canvas* canvas, View* view) const {
165 // Fill the top area. 165 // Fill the top area.
166 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_), 166 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_),
167 frame_color_); 167 frame_color_);
168 168
169 // If the window is very short, we're done. 169 // If the window is very short, we're done.
170 int remaining_height = view->height() - top_area_height_; 170 int remaining_height = view->height() - top_area_height_;
171 if (remaining_height <= 0) 171 if (remaining_height <= 0)
(...skipping 13 matching lines...) Expand all
185 return; 185 return;
186 186
187 // Fill the bottom area. 187 // Fill the bottom area.
188 canvas->FillRect(gfx::Rect(left_edge_->width(), 188 canvas->FillRect(gfx::Rect(left_edge_->width(),
189 view->height() - bottom_edge_->height(), 189 view->height() - bottom_edge_->height(),
190 center_width, bottom_edge_->height()), 190 center_width, bottom_edge_->height()),
191 frame_color_); 191 frame_color_);
192 } 192 }
193 193
194 } // namespace views 194 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/window/frame_background.h ('k') | ui/views/window/window_resources.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698