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

Side by Side Diff: chrome/browser/views/tabs/tab_renderer.cc

Issue 149727: Align custom background tab images correctly.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_renderer.h" 5 #include "chrome/browser/views/tabs/tab_renderer.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "app/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/gfx/font.h" 10 #include "app/gfx/font.h"
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 if (GetWidget() && 591 if (GetWidget() &&
592 GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) { 592 GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) {
593 tab_id = IDR_THEME_TAB_BACKGROUND_V; 593 tab_id = IDR_THEME_TAB_BACKGROUND_V;
594 } else { 594 } else {
595 tab_id = is_otr ? IDR_THEME_TAB_BACKGROUND_INCOGNITO : 595 tab_id = is_otr ? IDR_THEME_TAB_BACKGROUND_INCOGNITO :
596 IDR_THEME_TAB_BACKGROUND; 596 IDR_THEME_TAB_BACKGROUND;
597 } 597 }
598 598
599 SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(tab_id); 599 SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(tab_id);
600 600
601 // If the theme is providing a custom background image, then its top edge
602 // should be at the top of the tab. Otherwise, we assume that the background
603 // image is a composited foreground + frame image.
604 int bg_offset_y = GetThemeProvider()->HasCustomImage(tab_id) ?
605 0 : background_offset_.y();
606
601 // Draw left edge. Don't draw over the toolbar, as we're not the foreground 607 // Draw left edge. Don't draw over the toolbar, as we're not the foreground
602 // tab. 608 // tab.
603 SkBitmap tab_l = skia::ImageOperations::CreateTiledBitmap( 609 SkBitmap tab_l = skia::ImageOperations::CreateTiledBitmap(
604 *tab_bg, offset, background_offset_.y(), 610 *tab_bg, offset, bg_offset_y,
605 tab_active.l_width, height()); 611 tab_active.l_width, height());
606 SkBitmap theme_l = skia::ImageOperations::CreateMaskedBitmap( 612 SkBitmap theme_l = skia::ImageOperations::CreateMaskedBitmap(
607 tab_l, *tab_alpha.image_l); 613 tab_l, *tab_alpha.image_l);
608 canvas->DrawBitmapInt(theme_l, 614 canvas->DrawBitmapInt(theme_l,
609 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, 615 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
610 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, 616 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
611 false); 617 false);
612 618
613 // Draw right edge. Again, don't draw over the toolbar. 619 // Draw right edge. Again, don't draw over the toolbar.
614 SkBitmap tab_r = skia::ImageOperations::CreateTiledBitmap( 620 SkBitmap tab_r = skia::ImageOperations::CreateTiledBitmap(
615 *tab_bg, 621 *tab_bg,
616 offset + width() - tab_active.r_width, background_offset_.y(), 622 offset + width() - tab_active.r_width, bg_offset_y,
617 tab_active.r_width, height()); 623 tab_active.r_width, height());
618 SkBitmap theme_r = skia::ImageOperations::CreateMaskedBitmap( 624 SkBitmap theme_r = skia::ImageOperations::CreateMaskedBitmap(
619 tab_r, *tab_alpha.image_r); 625 tab_r, *tab_alpha.image_r);
620 canvas->DrawBitmapInt(theme_r, 626 canvas->DrawBitmapInt(theme_r,
621 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap, 627 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap,
622 width() - theme_r.width(), 0, theme_r.width(), 628 width() - theme_r.width(), 0, theme_r.width(),
623 theme_r.height() - kToolbarOverlap, false); 629 theme_r.height() - kToolbarOverlap, false);
624 630
625 // Draw center. Instead of masking out the top portion we simply skip over it 631 // Draw center. Instead of masking out the top portion we simply skip over it
626 // by incrementing by kDropShadowHeight, since it's a simple rectangle. And 632 // by incrementing by kDropShadowHeight, since it's a simple rectangle. And
627 // again, don't draw over the toolbar. 633 // again, don't draw over the toolbar.
628 canvas->TileImageInt(*tab_bg, 634 canvas->TileImageInt(*tab_bg,
629 offset + tab_active.l_width, background_offset_.y() + kDropShadowHeight, 635 offset + tab_active.l_width, bg_offset_y + kDropShadowHeight,
630 tab_active.l_width, kDropShadowHeight, 636 tab_active.l_width, kDropShadowHeight,
631 width() - tab_active.l_width - tab_active.r_width, 637 width() - tab_active.l_width - tab_active.r_width,
632 height() - kDropShadowHeight - kToolbarOverlap); 638 height() - kDropShadowHeight - kToolbarOverlap);
633 639
634 // Now draw the highlights/shadows around the tab edge. 640 // Now draw the highlights/shadows around the tab edge.
635 canvas->DrawBitmapInt(*tab_inactive.image_l, 0, 0); 641 canvas->DrawBitmapInt(*tab_inactive.image_l, 0, 0);
636 canvas->TileImageInt(*tab_inactive.image_c, 642 canvas->TileImageInt(*tab_inactive.image_c,
637 tab_inactive.l_width, 0, 643 tab_inactive.l_width, 0,
638 width() - tab_inactive.l_width - tab_inactive.r_width, 644 width() - tab_inactive.l_width - tab_inactive.r_width,
639 height()); 645 height());
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); 795 tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
790 tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); 796 tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
791 tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); 797 tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
792 798
793 tab_inactive.l_width = tab_inactive.image_l->width(); 799 tab_inactive.l_width = tab_inactive.image_l->width();
794 tab_inactive.r_width = tab_inactive.image_r->width(); 800 tab_inactive.r_width = tab_inactive.image_r->width();
795 801
796 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER); 802 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER);
797 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING); 803 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING);
798 } 804 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698