| OLD | NEW |
| 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 #include "chrome/browser/ui/views/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/defaults.h" | 10 #include "chrome/browser/defaults.h" |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 canvas->Restore(); | 559 canvas->Restore(); |
| 560 } | 560 } |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 | 563 |
| 564 void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) { | 564 void Tab::PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas) { |
| 565 // Render the inactive tab background. We'll use this for clipping. | 565 // Render the inactive tab background. We'll use this for clipping. |
| 566 gfx::Canvas background_canvas(size(), canvas->scale_factor(), false); | 566 gfx::Canvas background_canvas(size(), canvas->scale_factor(), false); |
| 567 PaintInactiveTabBackground(&background_canvas); | 567 PaintInactiveTabBackground(&background_canvas); |
| 568 | 568 |
| 569 gfx::ImageSkia background_image(background_canvas.ExtractImageSkiaRep()); | 569 gfx::ImageSkia background_image(background_canvas.ExtractImageRep()); |
| 570 | 570 |
| 571 // Draw a radial gradient to hover_canvas. | 571 // Draw a radial gradient to hover_canvas. |
| 572 gfx::Canvas hover_canvas(size(), canvas->scale_factor(), false); | 572 gfx::Canvas hover_canvas(size(), canvas->scale_factor(), false); |
| 573 int radius = kMiniTitleChangeGradientRadius; | 573 int radius = kMiniTitleChangeGradientRadius; |
| 574 int x0 = width() + radius - kMiniTitleChangeInitialXOffset; | 574 int x0 = width() + radius - kMiniTitleChangeInitialXOffset; |
| 575 int x1 = radius; | 575 int x1 = radius; |
| 576 int x2 = -radius; | 576 int x2 = -radius; |
| 577 int x; | 577 int x; |
| 578 if (mini_title_animation_->current_part_index() == 0) { | 578 if (mini_title_animation_->current_part_index() == 0) { |
| 579 x = mini_title_animation_->CurrentValueBetween(x0, x1); | 579 x = mini_title_animation_->CurrentValueBetween(x0, x1); |
| 580 } else if (mini_title_animation_->current_part_index() == 1) { | 580 } else if (mini_title_animation_->current_part_index() == 1) { |
| 581 x = x1; | 581 x = x1; |
| 582 } else { | 582 } else { |
| 583 x = mini_title_animation_->CurrentValueBetween(x1, x2); | 583 x = mini_title_animation_->CurrentValueBetween(x1, x2); |
| 584 } | 584 } |
| 585 SkPoint center_point; | 585 SkPoint center_point; |
| 586 center_point.iset(x, 0); | 586 center_point.iset(x, 0); |
| 587 SkColor colors[2] = { kMiniTitleChangeGradientColor1, | 587 SkColor colors[2] = { kMiniTitleChangeGradientColor1, |
| 588 kMiniTitleChangeGradientColor2 }; | 588 kMiniTitleChangeGradientColor2 }; |
| 589 SkShader* shader = SkGradientShader::CreateRadial(center_point, | 589 SkShader* shader = SkGradientShader::CreateRadial(center_point, |
| 590 SkIntToScalar(radius), colors, NULL, 2, SkShader::kClamp_TileMode); | 590 SkIntToScalar(radius), colors, NULL, 2, SkShader::kClamp_TileMode); |
| 591 SkPaint paint; | 591 SkPaint paint; |
| 592 paint.setShader(shader); | 592 paint.setShader(shader); |
| 593 shader->unref(); | 593 shader->unref(); |
| 594 hover_canvas.DrawRect(gfx::Rect(x - radius, -radius, radius * 2, radius * 2), | 594 hover_canvas.DrawRect(gfx::Rect(x - radius, -radius, radius * 2, radius * 2), |
| 595 paint); | 595 paint); |
| 596 | 596 |
| 597 // Draw the radial gradient clipped to the background into hover_image. | 597 // Draw the radial gradient clipped to the background into hover_image. |
| 598 gfx::ImageSkia hover_image = gfx::ImageSkiaOperations::CreateMaskedImage( | 598 gfx::ImageSkia hover_image = gfx::ImageSkiaOperations::CreateMaskedImage( |
| 599 gfx::ImageSkia(hover_canvas.ExtractImageSkiaRep()), background_image); | 599 gfx::ImageSkia(hover_canvas.ExtractImageRep()), background_image); |
| 600 | 600 |
| 601 // Draw the tab background to the canvas. | 601 // Draw the tab background to the canvas. |
| 602 canvas->DrawImageInt(background_image, 0, 0); | 602 canvas->DrawImageInt(background_image, 0, 0); |
| 603 | 603 |
| 604 // And then the gradient on top of that. | 604 // And then the gradient on top of that. |
| 605 if (mini_title_animation_->current_part_index() == 2) { | 605 if (mini_title_animation_->current_part_index() == 2) { |
| 606 canvas->SaveLayerAlpha(mini_title_animation_->CurrentValueBetween(255, 0)); | 606 canvas->SaveLayerAlpha(mini_title_animation_->CurrentValueBetween(255, 0)); |
| 607 canvas->DrawImageInt(hover_image, 0, 0); | 607 canvas->DrawImageInt(hover_image, 0, 0); |
| 608 canvas->Restore(); | 608 canvas->Restore(); |
| 609 } else { | 609 } else { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 // rectangle. And again, don't draw over the toolbar. | 671 // rectangle. And again, don't draw over the toolbar. |
| 672 background_canvas.TileImageInt(*tab_bg, | 672 background_canvas.TileImageInt(*tab_bg, |
| 673 offset + tab_image->l_width, | 673 offset + tab_image->l_width, |
| 674 bg_offset_y + drop_shadow_height() + tab_image->y_offset, | 674 bg_offset_y + drop_shadow_height() + tab_image->y_offset, |
| 675 tab_image->l_width, | 675 tab_image->l_width, |
| 676 drop_shadow_height() + tab_image->y_offset, | 676 drop_shadow_height() + tab_image->y_offset, |
| 677 width() - tab_image->l_width - tab_image->r_width, | 677 width() - tab_image->l_width - tab_image->r_width, |
| 678 height() - drop_shadow_height() - kToolbarOverlap - tab_image->y_offset); | 678 height() - drop_shadow_height() - kToolbarOverlap - tab_image->y_offset); |
| 679 | 679 |
| 680 canvas->DrawImageInt( | 680 canvas->DrawImageInt( |
| 681 gfx::ImageSkia(background_canvas.ExtractImageSkiaRep()), 0, 0); | 681 gfx::ImageSkia(background_canvas.ExtractImageRep()), 0, 0); |
| 682 | 682 |
| 683 if (!GetThemeProvider()->HasCustomImage(tab_id) && | 683 if (!GetThemeProvider()->HasCustomImage(tab_id) && |
| 684 hover_controller().ShouldDraw()) { | 684 hover_controller().ShouldDraw()) { |
| 685 hover_controller().Draw(canvas, background_canvas.ExtractImageSkiaRep()); | 685 hover_controller().Draw(canvas, background_canvas.ExtractImageRep()); |
| 686 } | 686 } |
| 687 | 687 |
| 688 // Now draw the highlights/shadows around the tab edge. | 688 // Now draw the highlights/shadows around the tab edge. |
| 689 canvas->DrawImageInt(*tab_inactive_image->image_l, 0, 0); | 689 canvas->DrawImageInt(*tab_inactive_image->image_l, 0, 0); |
| 690 canvas->TileImageInt(*tab_inactive_image->image_c, | 690 canvas->TileImageInt(*tab_inactive_image->image_c, |
| 691 tab_inactive_image->l_width, 0, | 691 tab_inactive_image->l_width, 0, |
| 692 width() - tab_inactive_image->l_width - | 692 width() - tab_inactive_image->l_width - |
| 693 tab_inactive_image->r_width, | 693 tab_inactive_image->r_width, |
| 694 height()); | 694 height()); |
| 695 canvas->DrawImageInt(*tab_inactive_image->image_r, | 695 canvas->DrawImageInt(*tab_inactive_image->image_r, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 rb.GetImageSkiaNamed(IDR_TAB_ACTIVE_RIGHT_SEARCH); | 816 rb.GetImageSkiaNamed(IDR_TAB_ACTIVE_RIGHT_SEARCH); |
| 817 tab_active_search_.l_width = tab_active_search_.image_l->width(); | 817 tab_active_search_.l_width = tab_active_search_.image_l->width(); |
| 818 tab_active_search_.r_width = tab_active_search_.image_r->width(); | 818 tab_active_search_.r_width = tab_active_search_.image_r->width(); |
| 819 | 819 |
| 820 tab_inactive_.image_l = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_LEFT); | 820 tab_inactive_.image_l = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_LEFT); |
| 821 tab_inactive_.image_c = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_CENTER); | 821 tab_inactive_.image_c = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_CENTER); |
| 822 tab_inactive_.image_r = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_RIGHT); | 822 tab_inactive_.image_r = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_RIGHT); |
| 823 tab_inactive_.l_width = tab_inactive_.image_l->width(); | 823 tab_inactive_.l_width = tab_inactive_.image_l->width(); |
| 824 tab_inactive_.r_width = tab_inactive_.image_r->width(); | 824 tab_inactive_.r_width = tab_inactive_.image_r->width(); |
| 825 } | 825 } |
| OLD | NEW |