OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/views/tabs/tab.h" | 5 #include "chrome/browser/views/tabs/tab.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "app/multi_animation.h" | 9 #include "app/multi_animation.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "app/slide_animation.h" | 11 #include "app/slide_animation.h" |
12 #include "app/throb_animation.h" | 12 #include "app/throb_animation.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/browser_theme_provider.h" | 14 #include "chrome/browser/browser_theme_provider.h" |
15 #include "chrome/browser/defaults.h" | 15 #include "chrome/browser/defaults.h" |
16 #include "gfx/canvas.h" | |
17 #include "gfx/canvas_skia.h" | 16 #include "gfx/canvas_skia.h" |
18 #include "gfx/favicon_size.h" | 17 #include "gfx/favicon_size.h" |
19 #include "gfx/font.h" | 18 #include "gfx/font.h" |
20 #include "gfx/path.h" | 19 #include "gfx/path.h" |
21 #include "gfx/skbitmap_operations.h" | 20 #include "gfx/skbitmap_operations.h" |
22 #include "grit/app_resources.h" | 21 #include "grit/app_resources.h" |
23 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
24 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
25 #include "third_party/skia/include/effects/SkGradientShader.h" | 24 #include "third_party/skia/include/effects/SkGradientShader.h" |
26 #include "views/controls/button/image_button.h" | 25 #include "views/controls/button/image_button.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } else { | 374 } else { |
376 if (mini_title_animation_.get() && mini_title_animation_->is_animating()) | 375 if (mini_title_animation_.get() && mini_title_animation_->is_animating()) |
377 PaintInactiveTabBackgroundWithTitleChange(canvas); | 376 PaintInactiveTabBackgroundWithTitleChange(canvas); |
378 else | 377 else |
379 PaintInactiveTabBackground(canvas); | 378 PaintInactiveTabBackground(canvas); |
380 | 379 |
381 double throb_value = GetThrobValue(); | 380 double throb_value = GetThrobValue(); |
382 if (throb_value > 0) { | 381 if (throb_value > 0) { |
383 SkRect bounds; | 382 SkRect bounds; |
384 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height())); | 383 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height())); |
385 canvas->saveLayerAlpha(&bounds, static_cast<int>(throb_value * 0xff), | 384 canvas->AsCanvasSkia()->saveLayerAlpha( |
386 SkCanvas::kARGB_ClipLayer_SaveFlag); | 385 &bounds, static_cast<int>(throb_value * 0xff), |
387 canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 386 SkCanvas::kARGB_ClipLayer_SaveFlag); |
| 387 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, |
| 388 SkXfermode::kClear_Mode); |
388 PaintActiveTabBackground(canvas); | 389 PaintActiveTabBackground(canvas); |
389 canvas->restore(); | 390 canvas->AsCanvasSkia()->restore(); |
390 } | 391 } |
391 } | 392 } |
392 } | 393 } |
393 | 394 |
394 void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) { | 395 void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) { |
395 // Render the inactive tab background. We'll use this for clipping. | 396 // Render the inactive tab background. We'll use this for clipping. |
396 gfx::Canvas background_canvas(width(), height(), false); | 397 gfx::CanvasSkia background_canvas(width(), height(), false); |
397 PaintInactiveTabBackground(&background_canvas); | 398 PaintInactiveTabBackground(&background_canvas); |
398 | 399 |
399 SkBitmap background_image = background_canvas.ExtractBitmap(); | 400 SkBitmap background_image = background_canvas.ExtractBitmap(); |
400 | 401 |
401 // Draw a radial gradient to hover_canvas. | 402 // Draw a radial gradient to hover_canvas. |
402 gfx::CanvasSkia hover_canvas(width(), height(), false); | 403 gfx::CanvasSkia hover_canvas(width(), height(), false); |
403 int radius = kMiniTitleChangeGradientRadius; | 404 int radius = kMiniTitleChangeGradientRadius; |
404 int x0 = width() + radius - kMiniTitleChangeInitialXOffset; | 405 int x0 = width() + radius - kMiniTitleChangeInitialXOffset; |
405 int x1 = radius; | 406 int x1 = radius; |
406 int x2 = -radius; | 407 int x2 = -radius; |
(...skipping 23 matching lines...) Expand all Loading... |
430 | 431 |
431 // Draw the radial gradient clipped to the background into hover_image. | 432 // Draw the radial gradient clipped to the background into hover_image. |
432 SkBitmap hover_image = SkBitmapOperations::CreateMaskedBitmap( | 433 SkBitmap hover_image = SkBitmapOperations::CreateMaskedBitmap( |
433 hover_canvas.ExtractBitmap(), background_image); | 434 hover_canvas.ExtractBitmap(), background_image); |
434 | 435 |
435 // Draw the tab background to the canvas. | 436 // Draw the tab background to the canvas. |
436 canvas->DrawBitmapInt(background_image, 0, 0); | 437 canvas->DrawBitmapInt(background_image, 0, 0); |
437 | 438 |
438 // And then the gradient on top of that. | 439 // And then the gradient on top of that. |
439 if (mini_title_animation_->current_part_index() == 2) { | 440 if (mini_title_animation_->current_part_index() == 2) { |
440 canvas->saveLayerAlpha(NULL, | 441 canvas->AsCanvasSkia()->saveLayerAlpha( |
441 mini_title_animation_->CurrentValueBetween(255, 0)); | 442 NULL, mini_title_animation_->CurrentValueBetween(255, 0)); |
442 canvas->DrawBitmapInt(hover_image, 0, 0); | 443 canvas->DrawBitmapInt(hover_image, 0, 0); |
443 canvas->restore(); | 444 canvas->AsCanvasSkia()->restore(); |
444 } else { | 445 } else { |
445 canvas->DrawBitmapInt(hover_image, 0, 0); | 446 canvas->DrawBitmapInt(hover_image, 0, 0); |
446 } | 447 } |
447 } | 448 } |
448 | 449 |
449 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { | 450 void Tab::PaintInactiveTabBackground(gfx::Canvas* canvas) { |
450 bool is_otr = data().off_the_record; | 451 bool is_otr = data().off_the_record; |
451 | 452 |
452 // The tab image needs to be lined up with the background image | 453 // The tab image needs to be lined up with the background image |
453 // so that it feels partially transparent. These offsets represent the tab | 454 // so that it feels partially transparent. These offsets represent the tab |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 tab_inactive.l_width = tab_inactive.image_l->width(); | 637 tab_inactive.l_width = tab_inactive.image_l->width(); |
637 tab_inactive.r_width = tab_inactive.image_r->width(); | 638 tab_inactive.r_width = tab_inactive.image_r->width(); |
638 | 639 |
639 tab_inactive_nano.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_LEFT); | 640 tab_inactive_nano.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_LEFT); |
640 tab_inactive_nano.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_CENTER); | 641 tab_inactive_nano.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_CENTER); |
641 tab_inactive_nano.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_RIGHT); | 642 tab_inactive_nano.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_RIGHT); |
642 tab_inactive_nano.l_width = tab_inactive_nano.image_l->width(); | 643 tab_inactive_nano.l_width = tab_inactive_nano.image_l->width(); |
643 tab_inactive_nano.r_width = tab_inactive_nano.image_r->width(); | 644 tab_inactive_nano.r_width = tab_inactive_nano.image_r->width(); |
644 tab_inactive_nano.y_offset = kNanoTabDiffHeight; | 645 tab_inactive_nano.y_offset = kNanoTabDiffHeight; |
645 } | 646 } |
OLD | NEW |