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

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

Issue 9332006: ui/gfx: Make the first version of Canvas::TileImageInt take a gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
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"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 maximized_top_right_ = top_right; 62 maximized_top_right_ = top_right;
63 maximized_top_offset_ = top_offset; 63 maximized_top_offset_ = top_offset;
64 } 64 }
65 65
66 void FrameBackground::PaintRestored(gfx::Canvas* canvas, View* view) const { 66 void FrameBackground::PaintRestored(gfx::Canvas* canvas, View* view) const {
67 // Fill with the frame color first so we have a constant background for 67 // Fill with the frame color first so we have a constant background for
68 // areas not covered by the theme image. 68 // areas not covered by the theme image.
69 PaintFrameColor(canvas, view); 69 PaintFrameColor(canvas, view);
70 70
71 // Draw the theme frame. 71 // Draw the theme frame.
72 canvas->TileImageInt(*theme_bitmap_, 72 canvas->TileImage(*theme_bitmap_,
73 0, 0, view->width(), theme_bitmap_->height()); 73 gfx::Rect(0, 0, view->width(), theme_bitmap_->height()));
74 74
75 // Draw the theme frame overlay, if available. 75 // Draw the theme frame overlay, if available.
76 if (theme_overlay_bitmap_) 76 if (theme_overlay_bitmap_)
77 canvas->DrawBitmapInt(*theme_overlay_bitmap_, 0, 0); 77 canvas->DrawBitmapInt(*theme_overlay_bitmap_, 0, 0);
78 78
79 // Draw the top corners and edge, scaling the corner images down if they 79 // Draw the top corners and edge, scaling the corner images down if they
80 // are too big and relative to the vertical space available. 80 // are too big and relative to the vertical space available.
81 int top_left_height = 81 int top_left_height =
82 std::min(top_left_corner_->height(), 82 std::min(top_left_corner_->height(),
83 view->height() - bottom_left_corner_->height()); 83 view->height() - bottom_left_corner_->height());
84 canvas->DrawBitmapInt(*top_left_corner_, 84 canvas->DrawBitmapInt(*top_left_corner_,
85 0, 0, top_left_corner_->width(), top_left_height, 85 0, 0, top_left_corner_->width(), top_left_height,
86 0, 0, top_left_corner_->width(), top_left_height, 86 0, 0, top_left_corner_->width(), top_left_height,
87 false); 87 false);
88 canvas->TileImageInt(*top_edge_, 88 canvas->TileImage(*top_edge_, gfx::Rect(top_left_corner_->width(),
89 top_left_corner_->width(),
90 0, 89 0,
91 view->width() - top_left_corner_->width() - top_right_corner_->width(), 90 view->width() - top_left_corner_->width() - top_right_corner_->width(),
92 top_edge_->height()); 91 top_edge_->height()));
93 int top_right_height = 92 int top_right_height =
94 std::min(top_right_corner_->height(), 93 std::min(top_right_corner_->height(),
95 view->height() - bottom_right_corner_->height()); 94 view->height() - bottom_right_corner_->height());
96 canvas->DrawBitmapInt(*top_right_corner_, 95 canvas->DrawBitmapInt(*top_right_corner_,
97 0, 0, 96 0, 0,
98 top_right_corner_->width(), top_right_height, 97 top_right_corner_->width(), top_right_height,
99 view->width() - top_right_corner_->width(), 0, 98 view->width() - top_right_corner_->width(), 0,
100 top_right_corner_->width(), top_right_height, 99 top_right_corner_->width(), top_right_height,
101 false); 100 false);
102 101
103 // Right edge. 102 // Right edge.
104 int right_edge_height = 103 int right_edge_height =
105 view->height() - top_right_height - bottom_right_corner_->height(); 104 view->height() - top_right_height - bottom_right_corner_->height();
106 canvas->TileImageInt(*right_edge_, 105 canvas->TileImage(*right_edge_,
107 view->width() - right_edge_->width(), 106 gfx::Rect(view->width() - right_edge_->width(),
108 top_right_height, 107 top_right_height,
109 right_edge_->width(), 108 right_edge_->width(),
110 right_edge_height); 109 right_edge_height));
111 110
112 // Bottom corners and edge. 111 // Bottom corners and edge.
113 canvas->DrawBitmapInt(*bottom_right_corner_, 112 canvas->DrawBitmapInt(*bottom_right_corner_,
114 view->width() - bottom_right_corner_->width(), 113 view->width() - bottom_right_corner_->width(),
115 view->height() - bottom_right_corner_->height()); 114 view->height() - bottom_right_corner_->height());
116 canvas->TileImageInt( 115 canvas->TileImage(
117 *bottom_edge_, 116 *bottom_edge_,
118 bottom_left_corner_->width(), 117 gfx::Rect(bottom_left_corner_->width(),
119 view->height() - bottom_edge_->height(), 118 view->height() - bottom_edge_->height(),
120 view->width() - bottom_left_corner_->width() 119 view->width() - bottom_left_corner_->width()
121 - bottom_right_corner_->width(), 120 - bottom_right_corner_->width(),
Peter Kasting 2012/02/06 22:32:39 Nit: While here, '-' goes on end of prior line
tfarina 2012/02/06 23:12:16 Done.
122 bottom_edge_->height()); 121 bottom_edge_->height()));
123 canvas->DrawBitmapInt(*bottom_left_corner_, 0, 122 canvas->DrawBitmapInt(*bottom_left_corner_, 0,
124 view->height() - bottom_left_corner_->height()); 123 view->height() - bottom_left_corner_->height());
125 124
126 // Left edge. 125 // Left edge.
127 int left_edge_height = 126 int left_edge_height =
128 view->height() - top_left_height - bottom_left_corner_->height(); 127 view->height() - top_left_height - bottom_left_corner_->height();
129 canvas->TileImageInt(*left_edge_, 128 canvas->TileImage(*left_edge_, gfx::Rect(0, top_left_height,
130 0, top_left_height, 129 left_edge_->width(), left_edge_height));
131 left_edge_->width(), left_edge_height);
132 } 130 }
133 131
134 void FrameBackground::PaintMaximized(gfx::Canvas* canvas, View* view) const { 132 void FrameBackground::PaintMaximized(gfx::Canvas* canvas, View* view) const {
135 // We will be painting from top_offset to top_offset + theme_frame_height. If 133 // We will be painting from top_offset to top_offset + theme_frame_height. If
136 // this is less than top_area_height_, we need to paint the frame color 134 // this is less than top_area_height_, we need to paint the frame color
137 // to fill in the area beneath the image. 135 // to fill in the area beneath the image.
138 // TODO(jamescook): I'm not sure this is correct, as it doesn't seem to fully 136 // TODO(jamescook): I'm not sure this is correct, as it doesn't seem to fully
139 // account for the top_offset, but this is how it worked before. 137 // account for the top_offset, but this is how it worked before.
140 int theme_frame_bottom = maximized_top_offset_ + theme_bitmap_->height(); 138 int theme_frame_bottom = maximized_top_offset_ + theme_bitmap_->height();
141 if (top_area_height_ > theme_frame_bottom) { 139 if (top_area_height_ > theme_frame_bottom) {
(...skipping 10 matching lines...) Expand all
152 // If we have either a left or right we should have both. 150 // If we have either a left or right we should have both.
153 DCHECK(maximized_top_left_ && maximized_top_right_); 151 DCHECK(maximized_top_left_ && maximized_top_right_);
154 left_offset = maximized_top_left_->width(); 152 left_offset = maximized_top_left_->width();
155 right_offset = maximized_top_right_->width(); 153 right_offset = maximized_top_right_->width();
156 canvas->DrawBitmapInt(*maximized_top_left_, 0, 0); 154 canvas->DrawBitmapInt(*maximized_top_left_, 0, 0);
157 canvas->DrawBitmapInt(*maximized_top_right_, 155 canvas->DrawBitmapInt(*maximized_top_right_,
158 view->width() - right_offset, 0); 156 view->width() - right_offset, 0);
159 } 157 }
160 158
161 // Draw the theme frame. 159 // Draw the theme frame.
162 canvas->TileImageInt(*theme_bitmap_, 160 canvas->TileImage(*theme_bitmap_,
163 left_offset, 161 gfx::Rect(left_offset,
164 maximized_top_offset_, 162 maximized_top_offset_,
165 view->width() - (left_offset + right_offset), 163 view->width() - (left_offset + right_offset),
166 theme_bitmap_->height()); 164 theme_bitmap_->height()));
167 // Draw the theme frame overlay, if available. 165 // Draw the theme frame overlay, if available.
168 if (theme_overlay_bitmap_) 166 if (theme_overlay_bitmap_)
169 canvas->DrawBitmapInt(*theme_overlay_bitmap_, 0, theme_background_y_); 167 canvas->DrawBitmapInt(*theme_overlay_bitmap_, 0, theme_background_y_);
170 } 168 }
171 169
172 void FrameBackground::PaintFrameColor(gfx::Canvas* canvas, View* view) const { 170 void FrameBackground::PaintFrameColor(gfx::Canvas* canvas, View* view) const {
173 // Fill the top area. 171 // Fill the top area.
174 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_), 172 canvas->FillRect(gfx::Rect(0, 0, view->width(), top_area_height_),
175 frame_color_); 173 frame_color_);
176 174
(...skipping 16 matching lines...) Expand all
193 return; 191 return;
194 192
195 // Fill the bottom area. 193 // Fill the bottom area.
196 canvas->FillRect(gfx::Rect(left_edge_->width(), 194 canvas->FillRect(gfx::Rect(left_edge_->width(),
197 view->height() - bottom_edge_->height(), 195 view->height() - bottom_edge_->height(),
198 center_width, bottom_edge_->height()), 196 center_width, bottom_edge_->height()),
199 frame_color_); 197 frame_color_);
200 } 198 }
201 199
202 } // namespace views 200 } // namespace views
OLDNEW
« ui/views/controls/scrollbar/bitmap_scroll_bar.cc ('K') | « ui/views/window/custom_frame_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698