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

Side by Side Diff: chrome/common/extensions/extension_action.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: put back the Peter's nits 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) 2011 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/common/extensions/extension_action.h" 5 #include "chrome/common/extensions/extension_action.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/common/badge_util.h" 10 #include "chrome/common/badge_util.h"
11 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Overlay the gradient. It is stretchy, so we do this in three parts. 165 // Overlay the gradient. It is stretchy, so we do this in three parts.
166 ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance(); 166 ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance();
167 SkBitmap* gradient_left = resource_bundle.GetBitmapNamed( 167 SkBitmap* gradient_left = resource_bundle.GetBitmapNamed(
168 IDR_BROWSER_ACTION_BADGE_LEFT); 168 IDR_BROWSER_ACTION_BADGE_LEFT);
169 SkBitmap* gradient_right = resource_bundle.GetBitmapNamed( 169 SkBitmap* gradient_right = resource_bundle.GetBitmapNamed(
170 IDR_BROWSER_ACTION_BADGE_RIGHT); 170 IDR_BROWSER_ACTION_BADGE_RIGHT);
171 SkBitmap* gradient_center = resource_bundle.GetBitmapNamed( 171 SkBitmap* gradient_center = resource_bundle.GetBitmapNamed(
172 IDR_BROWSER_ACTION_BADGE_CENTER); 172 IDR_BROWSER_ACTION_BADGE_CENTER);
173 173
174 canvas->GetSkCanvas()->drawBitmap(*gradient_left, rect.fLeft, rect.fTop); 174 canvas->GetSkCanvas()->drawBitmap(*gradient_left, rect.fLeft, rect.fTop);
175 canvas->TileImageInt(*gradient_center, 175 canvas->TileImage(*gradient_center,
176 SkScalarFloor(rect.fLeft) + gradient_left->width(), 176 gfx::Rect(SkScalarFloor(rect.fLeft) + gradient_left->width(),
177 SkScalarFloor(rect.fTop), 177 SkScalarFloor(rect.fTop),
178 SkScalarFloor(rect.width()) - gradient_left->width() - 178 SkScalarFloor(rect.width()) - gradient_left->width() -
179 gradient_right->width(), 179 gradient_right->width(),
180 SkScalarFloor(rect.height())); 180 SkScalarFloor(rect.height())));
181 canvas->GetSkCanvas()->drawBitmap(*gradient_right, 181 canvas->GetSkCanvas()->drawBitmap(*gradient_right,
182 rect.fRight - SkIntToScalar(gradient_right->width()), rect.fTop); 182 rect.fRight - SkIntToScalar(gradient_right->width()), rect.fTop);
183 183
184 // Finally, draw the text centered within the badge. We set a clip in case the 184 // Finally, draw the text centered within the badge. We set a clip in case the
185 // text was too large. 185 // text was too large.
186 rect.fLeft += kPadding; 186 rect.fLeft += kPadding;
187 rect.fRight -= kPadding; 187 rect.fRight -= kPadding;
188 canvas->GetSkCanvas()->clipRect(rect); 188 canvas->GetSkCanvas()->clipRect(rect);
189 canvas->GetSkCanvas()->drawText(text.c_str(), text.size(), 189 canvas->GetSkCanvas()->drawText(text.c_str(), text.size(),
190 rect.fLeft + (rect.width() - text_width) / 2, 190 rect.fLeft + (rect.width() - text_width) / 2,
191 rect.fTop + kTextSize + kTopTextPadding, 191 rect.fTop + kTextSize + kTopTextPadding,
192 *text_paint); 192 *text_paint);
193 canvas->Restore(); 193 canvas->Restore();
194 } 194 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab.cc ('k') | content/browser/renderer_host/render_widget_host_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698