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

Side by Side Diff: chrome/browser/ui/views/tabs/tab.cc

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

Powered by Google App Engine
This is Rietveld 408576698