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

Side by Side Diff: chrome/browser/download/download_util.cc

Issue 11058003: No need to kClear_Mode a layer right after its created, as that will automatically (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 | « no previous file | chrome/browser/ui/views/download/download_item_view.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 // Download utility implementation 5 // Download utility implementation
6 6
7 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 7 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
8 8
9 #include "chrome/browser/download/download_util.h" 9 #include "chrome/browser/download/download_util.h"
10 10
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 gfx::Rect complete_bounds(origin_x, origin_y, 264 gfx::Rect complete_bounds(origin_x, origin_y,
265 complete->width(), complete->height()); 265 complete->width(), complete->height());
266 #if defined(TOOLKIT_VIEWS) 266 #if defined(TOOLKIT_VIEWS)
267 // Mirror the positions if necessary. 267 // Mirror the positions if necessary.
268 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds)); 268 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds));
269 #endif 269 #endif
270 270
271 // Start at full opacity, then loop back and forth five times before ending 271 // Start at full opacity, then loop back and forth five times before ending
272 // at zero opacity. 272 // at zero opacity.
273 canvas->SaveLayerAlpha(GetOpacity(animation_progress), complete_bounds); 273 canvas->DrawImageInt(*complete, complete_bounds.x(), complete_bounds.y(),
274 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); 274 GetOpacity(animation_progress));
275 canvas->DrawImageInt(*complete, complete_bounds.x(), complete_bounds.y());
276 canvas->Restore();
277 } 275 }
278 276
279 void PaintDownloadInterrupted(gfx::Canvas* canvas, 277 void PaintDownloadInterrupted(gfx::Canvas* canvas,
280 #if defined(TOOLKIT_VIEWS) 278 #if defined(TOOLKIT_VIEWS)
281 views::View* containing_view, 279 views::View* containing_view,
282 #endif 280 #endif
283 int origin_x, 281 int origin_x,
284 int origin_y, 282 int origin_y,
285 double animation_progress, 283 double animation_progress,
286 PaintDownloadProgressSize size) { 284 PaintDownloadProgressSize size) {
287 // Load up our common images. 285 // Load up our common images.
288 if (!g_foreground_16) { 286 if (!g_foreground_16) {
289 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 287 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
290 g_foreground_16 = rb.GetImageSkiaNamed(IDR_DOWNLOAD_PROGRESS_FOREGROUND_16); 288 g_foreground_16 = rb.GetImageSkiaNamed(IDR_DOWNLOAD_PROGRESS_FOREGROUND_16);
291 g_foreground_32 = rb.GetImageSkiaNamed(IDR_DOWNLOAD_PROGRESS_FOREGROUND_32); 289 g_foreground_32 = rb.GetImageSkiaNamed(IDR_DOWNLOAD_PROGRESS_FOREGROUND_32);
292 } 290 }
293 291
294 gfx::ImageSkia* complete = (size == BIG) ? g_foreground_32 : g_foreground_16; 292 gfx::ImageSkia* complete = (size == BIG) ? g_foreground_32 : g_foreground_16;
295 293
296 gfx::Rect complete_bounds(origin_x, origin_y, 294 gfx::Rect complete_bounds(origin_x, origin_y,
297 complete->width(), complete->height()); 295 complete->width(), complete->height());
298 #if defined(TOOLKIT_VIEWS) 296 #if defined(TOOLKIT_VIEWS)
299 // Mirror the positions if necessary. 297 // Mirror the positions if necessary.
300 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds)); 298 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds));
301 #endif 299 #endif
302 300
303 // Start at zero opacity, then loop back and forth five times before ending 301 // Start at zero opacity, then loop back and forth five times before ending
304 // at full opacity. 302 // at full opacity.
305 canvas->SaveLayerAlpha(GetOpacity(1.0 - animation_progress), complete_bounds); 303 canvas->DrawImageInt(*complete, complete_bounds.x(), complete_bounds.y(),
306 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); 304 GetOpacity(1.0 - animation_progress));
307 canvas->DrawImageInt(*complete, complete_bounds.x(), complete_bounds.y());
308 canvas->Restore();
309 } 305 }
310 306
311 // Load a language dependent height so that the dangerous download confirmation 307 // Load a language dependent height so that the dangerous download confirmation
312 // message doesn't overlap with the download link label. 308 // message doesn't overlap with the download link label.
313 int GetBigProgressIconSize() { 309 int GetBigProgressIconSize() {
314 static int big_progress_icon_size = 0; 310 static int big_progress_icon_size = 0;
315 if (big_progress_icon_size == 0) { 311 if (big_progress_icon_size == 0) {
316 string16 locale_size_str = 312 string16 locale_size_str =
317 l10n_util::GetStringUTF16(IDS_DOWNLOAD_BIG_PROGRESS_SIZE); 313 l10n_util::GetStringUTF16(IDS_DOWNLOAD_BIG_PROGRESS_SIZE);
318 bool rc = base::StringToInt(locale_size_str, &big_progress_icon_size); 314 bool rc = base::StringToInt(locale_size_str, &big_progress_icon_size);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 UMA_HISTOGRAM_ENUMERATION( 474 UMA_HISTOGRAM_ENUMERATION(
479 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY); 475 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY);
480 } 476 }
481 477
482 void RecordDownloadSource(ChromeDownloadSource source) { 478 void RecordDownloadSource(ChromeDownloadSource source) {
483 UMA_HISTOGRAM_ENUMERATION( 479 UMA_HISTOGRAM_ENUMERATION(
484 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY); 480 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY);
485 } 481 }
486 482
487 } // namespace download_util 483 } // namespace download_util
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698