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

Unified Diff: chrome/browser/ui/views/download/download_item_view.cc

Issue 1236463002: Vectorize download shelf progress indicators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/download/download_item_view.cc
diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc
index 77e704c7d965ead84a6b1a5c51abba7445384272..37d83ae1d56361855925d16ca3769985803b03c2 100644
--- a/chrome/browser/ui/views/download/download_item_view.cc
+++ b/chrome/browser/ui/views/download/download_item_view.cc
@@ -96,16 +96,6 @@ static const int kDisabledOnOpenDuration = 3000;
// light-on-dark themes.
static const double kDownloadItemLuminanceMod = 0.8;
-namespace {
-
-// Callback for DownloadShelf paint functions to mirror the progress animation
-// in RTL locales.
-void RTLMirrorXForView(views::View* containing_view, gfx::Rect* bounds) {
- bounds->set_x(containing_view->GetMirroredXForRect(*bounds));
-}
-
-} // namespace
-
DownloadItemView::DownloadItemView(DownloadItem* download_item,
DownloadShelfView* parent)
: warning_icon_(NULL),
@@ -114,7 +104,6 @@ DownloadItemView::DownloadItemView(DownloadItem* download_item,
body_state_(NORMAL),
drop_down_state_(NORMAL),
mode_(NORMAL_MODE),
- progress_angle_(DownloadShelf::kStartAngleDegrees),
drop_down_pressed_(false),
dragging_(false),
starting_drag_(false),
@@ -244,19 +233,13 @@ DownloadItemView::~DownloadItemView() {
// Progress animation handlers.
-void DownloadItemView::UpdateDownloadProgress() {
- progress_angle_ =
- (progress_angle_ + DownloadShelf::kUnknownIncrementDegrees) %
- DownloadShelf::kMaxDegrees;
- SchedulePaint();
-}
-
void DownloadItemView::StartDownloadProgress() {
if (progress_timer_.IsRunning())
return;
- progress_timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(DownloadShelf::kProgressRateMs), this,
- &DownloadItemView::UpdateDownloadProgress);
+ progress_start_time_ = base::TimeTicks::Now();
+ progress_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(
+ DownloadShelf::kProgressRateMs),
+ this, &DownloadItemView::SchedulePaint);
}
void DownloadItemView::StopDownloadProgress() {
@@ -870,23 +853,29 @@ void DownloadItemView::OnPaintBackground(gfx::Canvas* canvas) {
if (icon) {
if (!IsShowingWarningDialog()) {
DownloadItem::DownloadState state = download()->GetState();
- DownloadShelf::BoundsAdjusterCallback rtl_mirror =
- base::Bind(&RTLMirrorXForView, base::Unretained(this));
+ canvas->Save();
+ if (base::i18n::IsRTL())
+ canvas->Translate(
+ gfx::Vector2d(width() - DownloadShelf::kSmallProgressIconSize, 0));
+
if (state == DownloadItem::IN_PROGRESS) {
- DownloadShelf::PaintDownloadProgress(canvas, rtl_mirror, 0, 0,
- progress_angle_,
+ DownloadShelf::PaintDownloadProgress(canvas, *GetThemeProvider(),
+ progress_start_time_,
model_.PercentComplete());
} else if (complete_animation_.get() &&
complete_animation_->is_animating()) {
if (state == DownloadItem::INTERRUPTED) {
DownloadShelf::PaintDownloadInterrupted(
- canvas, rtl_mirror, 0, 0, complete_animation_->GetCurrentValue());
+ canvas, *GetThemeProvider(),
+ complete_animation_->GetCurrentValue());
} else {
DCHECK_EQ(DownloadItem::COMPLETE, state);
DownloadShelf::PaintDownloadComplete(
- canvas, rtl_mirror, 0, 0, complete_animation_->GetCurrentValue());
+ canvas, *GetThemeProvider(),
+ complete_animation_->GetCurrentValue());
}
}
+ canvas->Restore();
}
// Draw the icon image.

Powered by Google App Engine
This is Rietveld 408576698