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

Side by Side Diff: chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc

Issue 8122013: Allow CanvasSkia to bind to an existing SkCanvas. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 1 more fix Created 9 years, 2 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) 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 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 x() + favicon_bounds_.x(), offset_y + favicon_bounds_.y(), 412 x() + favicon_bounds_.x(), offset_y + favicon_bounds_.y(),
413 favicon_bounds_.x(), favicon_bounds_.y(), 413 favicon_bounds_.x(), favicon_bounds_.y(),
414 favicon_bounds_.width(), favicon_bounds_.height()); 414 favicon_bounds_.width(), favicon_bounds_.height());
415 415
416 if (!IsActive()) { 416 if (!IsActive()) {
417 double throb_value = GetThrobValue(); 417 double throb_value = GetThrobValue();
418 if (throb_value > 0) { 418 if (throb_value > 0) {
419 SkRect bounds; 419 SkRect bounds;
420 bounds.set(favicon_bounds_.x(), favicon_bounds_.y(), 420 bounds.set(favicon_bounds_.x(), favicon_bounds_.y(),
421 favicon_bounds_.right(), favicon_bounds_.bottom()); 421 favicon_bounds_.right(), favicon_bounds_.bottom());
422 canvas.saveLayerAlpha(&bounds, static_cast<int>(throb_value * 0xff), 422 canvas.sk_canvas()->saveLayerAlpha(
423 SkCanvas::kARGB_ClipLayer_SaveFlag); 423 &bounds, static_cast<int>(throb_value * 0xff),
424 canvas.drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); 424 SkCanvas::kARGB_ClipLayer_SaveFlag);
425 canvas.sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
425 SkBitmap* active_bg = theme_service_->GetBitmapNamed(IDR_THEME_TOOLBAR); 426 SkBitmap* active_bg = theme_service_->GetBitmapNamed(IDR_THEME_TOOLBAR);
426 canvas.TileImageInt(*active_bg, 427 canvas.TileImageInt(*active_bg,
427 x() + favicon_bounds_.x(), favicon_bounds_.y(), 428 x() + favicon_bounds_.x(), favicon_bounds_.y(),
428 favicon_bounds_.x(), favicon_bounds_.y(), 429 favicon_bounds_.x(), favicon_bounds_.y(),
429 favicon_bounds_.width(), favicon_bounds_.height()); 430 favicon_bounds_.width(), favicon_bounds_.height());
430 canvas.restore(); 431 canvas.sk_canvas()->restore();
431 } 432 }
432 } 433 }
433 434
434 // Now paint the icon. 435 // Now paint the icon.
435 PaintIcon(&canvas); 436 PaintIcon(&canvas);
436 } 437 }
437 438
438 bool TabRendererGtk::ShouldShowIcon() const { 439 bool TabRendererGtk::ShouldShowIcon() const {
439 if (mini() && height() >= GetMinimumUnselectedSize().height()) { 440 if (mini() && height() >= GetMinimumUnselectedSize().height()) {
440 return true; 441 return true;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 PaintTitle(canvas); 649 PaintTitle(canvas);
649 650
650 if (show_icon) 651 if (show_icon)
651 PaintIcon(canvas); 652 PaintIcon(canvas);
652 } 653 }
653 654
654 cairo_surface_t* TabRendererGtk::PaintToSurface() { 655 cairo_surface_t* TabRendererGtk::PaintToSurface() {
655 gfx::CanvasSkia canvas(width(), height(), false); 656 gfx::CanvasSkia canvas(width(), height(), false);
656 Paint(&canvas); 657 Paint(&canvas);
657 return cairo_surface_reference(cairo_get_target( 658 return cairo_surface_reference(cairo_get_target(
658 skia::BeginPlatformPaint(&canvas))); 659 skia::BeginPlatformPaint(canvas.sk_canvas())));
659 } 660 }
660 661
661 void TabRendererGtk::SchedulePaint() { 662 void TabRendererGtk::SchedulePaint() {
662 gtk_widget_queue_draw(tab_.get()); 663 gtk_widget_queue_draw(tab_.get());
663 } 664 }
664 665
665 gfx::Rect TabRendererGtk::GetLocalBounds() { 666 gfx::Rect TabRendererGtk::GetLocalBounds() {
666 return gfx::Rect(0, 0, bounds_.width(), bounds_.height()); 667 return gfx::Rect(0, 0, bounds_.width(), bounds_.height());
667 } 668 }
668 669
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 void TabRendererGtk::PaintTabBackground(gfx::Canvas* canvas) { 881 void TabRendererGtk::PaintTabBackground(gfx::Canvas* canvas) {
881 if (IsActive()) { 882 if (IsActive()) {
882 PaintActiveTabBackground(canvas); 883 PaintActiveTabBackground(canvas);
883 } else { 884 } else {
884 PaintInactiveTabBackground(canvas); 885 PaintInactiveTabBackground(canvas);
885 886
886 double throb_value = GetThrobValue(); 887 double throb_value = GetThrobValue();
887 if (throb_value > 0) { 888 if (throb_value > 0) {
888 canvas->SaveLayerAlpha(static_cast<int>(throb_value * 0xff), 889 canvas->SaveLayerAlpha(static_cast<int>(throb_value * 0xff),
889 gfx::Rect(width(), height())); 890 gfx::Rect(width(), height()));
890 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, 891 canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255,
891 SkXfermode::kClear_Mode); 892 SkXfermode::kClear_Mode);
892 PaintActiveTabBackground(canvas); 893 PaintActiveTabBackground(canvas);
893 canvas->Restore(); 894 canvas->Restore();
894 } 895 }
895 } 896 }
896 } 897 }
897 898
898 void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) { 899 void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) {
899 900
900 // The tab image needs to be lined up with the background image 901 // The tab image needs to be lined up with the background image
901 // so that it feels partially transparent. 902 // so that it feels partially transparent.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 1090
1090 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 1091 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1091 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); 1092 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
1092 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); 1093 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize);
1093 title_font_height_ = title_font_->GetHeight(); 1094 title_font_height_ = title_font_->GetHeight();
1094 1095
1095 crashed_favicon = rb.GetBitmapNamed(IDR_SAD_FAVICON); 1096 crashed_favicon = rb.GetBitmapNamed(IDR_SAD_FAVICON);
1096 1097
1097 initialized_ = true; 1098 initialized_ = true;
1098 } 1099 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698