| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/download/download_util.h" | 7 #include "chrome/browser/download/download_util.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <shobjidl.h> | 10 #include <shobjidl.h> |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 SkShader::CreateBitmapShader(*foreground, | 254 SkShader::CreateBitmapShader(*foreground, |
| 255 SkShader::kClamp_TileMode, | 255 SkShader::kClamp_TileMode, |
| 256 SkShader::kClamp_TileMode); | 256 SkShader::kClamp_TileMode); |
| 257 SkMatrix shader_scale; | 257 SkMatrix shader_scale; |
| 258 shader_scale.setTranslate(SkIntToScalar(foreground_bounds.x()), | 258 shader_scale.setTranslate(SkIntToScalar(foreground_bounds.x()), |
| 259 SkIntToScalar(foreground_bounds.y())); | 259 SkIntToScalar(foreground_bounds.y())); |
| 260 shader->setLocalMatrix(shader_scale); | 260 shader->setLocalMatrix(shader_scale); |
| 261 foreground_paint.setShader(shader); | 261 foreground_paint.setShader(shader); |
| 262 foreground_paint.setAntiAlias(true); | 262 foreground_paint.setAntiAlias(true); |
| 263 shader->unref(); | 263 shader->unref(); |
| 264 canvas->AsCanvasSkia()->drawPath(path, foreground_paint); | 264 canvas->GetSkCanvas()->drawPath(path, foreground_paint); |
| 265 return; | 265 return; |
| 266 } | 266 } |
| 267 | 267 |
| 268 canvas->DrawBitmapInt(*foreground, | 268 canvas->DrawBitmapInt(*foreground, |
| 269 foreground_bounds.x(), | 269 foreground_bounds.x(), |
| 270 foreground_bounds.y(), | 270 foreground_bounds.y(), |
| 271 foreground_paint); | 271 foreground_paint); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void PaintDownloadComplete(gfx::Canvas* canvas, | 274 void PaintDownloadComplete(gfx::Canvas* canvas, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 294 // Mirror the positions if necessary. | 294 // Mirror the positions if necessary. |
| 295 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds)); | 295 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds)); |
| 296 #endif | 296 #endif |
| 297 | 297 |
| 298 // Start at full opacity, then loop back and forth five times before ending | 298 // Start at full opacity, then loop back and forth five times before ending |
| 299 // at zero opacity. | 299 // at zero opacity. |
| 300 double opacity = sin(animation_progress * PI * kCompleteAnimationCycles + | 300 double opacity = sin(animation_progress * PI * kCompleteAnimationCycles + |
| 301 PI/2) / 2 + 0.5; | 301 PI/2) / 2 + 0.5; |
| 302 | 302 |
| 303 canvas->SaveLayerAlpha(static_cast<int>(255.0 * opacity), complete_bounds); | 303 canvas->SaveLayerAlpha(static_cast<int>(255.0 * opacity), complete_bounds); |
| 304 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 304 canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
| 305 canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y()); | 305 canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y()); |
| 306 canvas->Restore(); | 306 canvas->Restore(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void PaintDownloadInterrupted(gfx::Canvas* canvas, | 309 void PaintDownloadInterrupted(gfx::Canvas* canvas, |
| 310 #if defined(TOOLKIT_VIEWS) | 310 #if defined(TOOLKIT_VIEWS) |
| 311 views::View* containing_view, | 311 views::View* containing_view, |
| 312 #endif | 312 #endif |
| 313 int origin_x, | 313 int origin_x, |
| 314 int origin_y, | 314 int origin_y, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 330 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds)); | 330 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds)); |
| 331 #endif | 331 #endif |
| 332 | 332 |
| 333 // Start at zero opacity, then loop back and forth five times before ending | 333 // Start at zero opacity, then loop back and forth five times before ending |
| 334 // at full opacity. | 334 // at full opacity. |
| 335 double opacity = sin( | 335 double opacity = sin( |
| 336 (1.0 - animation_progress) * PI * kCompleteAnimationCycles + PI/2) / 2 + | 336 (1.0 - animation_progress) * PI * kCompleteAnimationCycles + PI/2) / 2 + |
| 337 0.5; | 337 0.5; |
| 338 | 338 |
| 339 canvas->SaveLayerAlpha(static_cast<int>(255.0 * opacity), complete_bounds); | 339 canvas->SaveLayerAlpha(static_cast<int>(255.0 * opacity), complete_bounds); |
| 340 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 340 canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
| 341 canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y()); | 341 canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y()); |
| 342 canvas->Restore(); | 342 canvas->Restore(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 // Load a language dependent height so that the dangerous download confirmation | 345 // Load a language dependent height so that the dangerous download confirmation |
| 346 // message doesn't overlap with the download link label. | 346 // message doesn't overlap with the download link label. |
| 347 int GetBigProgressIconSize() { | 347 int GetBigProgressIconSize() { |
| 348 static int big_progress_icon_size = 0; | 348 static int big_progress_icon_size = 0; |
| 349 if (big_progress_icon_size == 0) { | 349 if (big_progress_icon_size == 0) { |
| 350 string16 locale_size_str = | 350 string16 locale_size_str = |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 return DownloadFile::GetUniquePathNumberWithSuffix( | 590 return DownloadFile::GetUniquePathNumberWithSuffix( |
| 591 path, FILE_PATH_LITERAL(".crdownload")); | 591 path, FILE_PATH_LITERAL(".crdownload")); |
| 592 } | 592 } |
| 593 | 593 |
| 594 FilePath GetCrDownloadPath(const FilePath& suggested_path) { | 594 FilePath GetCrDownloadPath(const FilePath& suggested_path) { |
| 595 return DownloadFile::AppendSuffixToPath( | 595 return DownloadFile::AppendSuffixToPath( |
| 596 suggested_path, FILE_PATH_LITERAL(".crdownload")); | 596 suggested_path, FILE_PATH_LITERAL(".crdownload")); |
| 597 } | 597 } |
| 598 | 598 |
| 599 } // namespace download_util | 599 } // namespace download_util |
| OLD | NEW |