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

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

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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
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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "chrome/browser/download/download_shelf.h" 7 #include "chrome/browser/download/download_shelf.h"
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/download/download_started_animation.h" 21 #include "chrome/browser/download/download_started_animation.h"
22 #include "chrome/browser/platform_util.h" 22 #include "chrome/browser/platform_util.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/themes/theme_properties.h" 24 #include "chrome/browser/themes/theme_properties.h"
25 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" 26 #include "chrome/browser/ui/tabs/tab_strip_model.h"
27 #include "content/public/browser/browser_context.h" 27 #include "content/public/browser/browser_context.h"
28 #include "content/public/browser/download_item.h" 28 #include "content/public/browser/download_item.h"
29 #include "content/public/browser/download_manager.h" 29 #include "content/public/browser/download_manager.h"
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "skia/ext/cdl_paint.h"
31 #include "third_party/skia/include/core/SkPaint.h" 32 #include "third_party/skia/include/core/SkPaint.h"
32 #include "third_party/skia/include/core/SkPath.h" 33 #include "third_party/skia/include/core/SkPath.h"
33 #include "ui/base/resource/resource_bundle.h" 34 #include "ui/base/resource/resource_bundle.h"
34 #include "ui/base/theme_provider.h" 35 #include "ui/base/theme_provider.h"
35 #include "ui/gfx/animation/animation.h" 36 #include "ui/gfx/animation/animation.h"
36 #include "ui/gfx/canvas.h" 37 #include "ui/gfx/canvas.h"
37 38
38 using content::DownloadItem; 39 using content::DownloadItem;
39 40
40 namespace { 41 namespace {
(...skipping 26 matching lines...) Expand all
67 68
68 // Download progress painting -------------------------------------------------- 69 // Download progress painting --------------------------------------------------
69 70
70 // static 71 // static
71 void DownloadShelf::PaintDownloadProgress( 72 void DownloadShelf::PaintDownloadProgress(
72 gfx::Canvas* canvas, 73 gfx::Canvas* canvas,
73 const ui::ThemeProvider& theme_provider, 74 const ui::ThemeProvider& theme_provider,
74 const base::TimeDelta& progress_time, 75 const base::TimeDelta& progress_time,
75 int percent_done) { 76 int percent_done) {
76 // Draw background (light blue circle). 77 // Draw background (light blue circle).
77 SkPaint bg_paint; 78 CdlPaint bg_paint;
78 bg_paint.setStyle(SkPaint::kFill_Style); 79 bg_paint.setStyle(CdlPaint::kFill_Style);
79 SkColor indicator_color = 80 SkColor indicator_color =
80 theme_provider.GetColor(ThemeProperties::COLOR_TAB_THROBBER_SPINNING); 81 theme_provider.GetColor(ThemeProperties::COLOR_TAB_THROBBER_SPINNING);
81 bg_paint.setColor(SkColorSetA(indicator_color, 0x33)); 82 bg_paint.setColor(SkColorSetA(indicator_color, 0x33));
82 bg_paint.setAntiAlias(true); 83 bg_paint.setAntiAlias(true);
83 const SkScalar kCenterPoint = kProgressIndicatorSize / 2.f; 84 const SkScalar kCenterPoint = kProgressIndicatorSize / 2.f;
84 SkPath bg; 85 SkPath bg;
85 bg.addCircle(kCenterPoint, kCenterPoint, kCenterPoint); 86 bg.addCircle(kCenterPoint, kCenterPoint, kCenterPoint);
86 canvas->DrawPath(bg, bg_paint); 87 canvas->DrawPath(bg, bg_paint);
87 88
88 // Calculate progress. 89 // Calculate progress.
89 SkScalar sweep_angle = 0.f; 90 SkScalar sweep_angle = 0.f;
90 // Start at 12 o'clock. 91 // Start at 12 o'clock.
91 SkScalar start_pos = SkIntToScalar(270); 92 SkScalar start_pos = SkIntToScalar(270);
92 if (percent_done < 0) { 93 if (percent_done < 0) {
93 // For unknown size downloads, draw a 50 degree sweep that moves at 94 // For unknown size downloads, draw a 50 degree sweep that moves at
94 // 0.08 degrees per millisecond. 95 // 0.08 degrees per millisecond.
95 sweep_angle = 50.f; 96 sweep_angle = 50.f;
96 start_pos += static_cast<SkScalar>(progress_time.InMilliseconds() * 0.08); 97 start_pos += static_cast<SkScalar>(progress_time.InMilliseconds() * 0.08);
97 } else if (percent_done > 0) { 98 } else if (percent_done > 0) {
98 sweep_angle = static_cast<SkScalar>(360 * percent_done / 100.0); 99 sweep_angle = static_cast<SkScalar>(360 * percent_done / 100.0);
99 } 100 }
100 101
101 // Draw progress. 102 // Draw progress.
102 SkPath progress; 103 SkPath progress;
103 progress.addArc( 104 progress.addArc(
104 SkRect::MakeLTRB(0, 0, kProgressIndicatorSize, kProgressIndicatorSize), 105 SkRect::MakeLTRB(0, 0, kProgressIndicatorSize, kProgressIndicatorSize),
105 start_pos, sweep_angle); 106 start_pos, sweep_angle);
106 SkPaint progress_paint; 107 CdlPaint progress_paint;
107 progress_paint.setColor(indicator_color); 108 progress_paint.setColor(indicator_color);
108 progress_paint.setStyle(SkPaint::kStroke_Style); 109 progress_paint.setStyle(CdlPaint::kStroke_Style);
109 progress_paint.setStrokeWidth(1.7f); 110 progress_paint.setStrokeWidth(1.7f);
110 progress_paint.setAntiAlias(true); 111 progress_paint.setAntiAlias(true);
111 canvas->DrawPath(progress, progress_paint); 112 canvas->DrawPath(progress, progress_paint);
112 } 113 }
113 114
114 // static 115 // static
115 void DownloadShelf::PaintDownloadComplete( 116 void DownloadShelf::PaintDownloadComplete(
116 gfx::Canvas* canvas, 117 gfx::Canvas* canvas,
117 const ui::ThemeProvider& theme_provider, 118 const ui::ThemeProvider& theme_provider,
118 double animation_progress) { 119 double animation_progress) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 content::DownloadManager* download_manager = GetDownloadManager(); 231 content::DownloadManager* download_manager = GetDownloadManager();
231 if (!download_manager) 232 if (!download_manager)
232 return; 233 return;
233 234
234 DownloadItem* download = download_manager->GetDownload(download_id); 235 DownloadItem* download = download_manager->GetDownload(download_id);
235 if (!download) 236 if (!download)
236 return; 237 return;
237 238
238 ShowDownload(download); 239 ShowDownload(download);
239 } 240 }
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_context.cc ('k') | chrome/browser/extensions/bookmark_app_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698