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/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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 | 368 |
369 // Scale proportionately. | 369 // Scale proportionately. |
370 float float_size = gfx::kFaviconSize; | 370 float float_size = gfx::kFaviconSize; |
371 float scale = std::min(float_size / scalable_w, | 371 float scale = std::min(float_size / scalable_w, |
372 float_size / scalable_h); | 372 float_size / scalable_h); |
373 int dest_w = static_cast<int>(float_src_w * scale); | 373 int dest_w = static_cast<int>(float_src_w * scale); |
374 int dest_h = static_cast<int>(float_src_h * scale); | 374 int dest_h = static_cast<int>(float_src_h * scale); |
375 | 375 |
376 GdkPixbuf* pixbuf; | 376 GdkPixbuf* pixbuf; |
377 if (dest_w == src_w && dest_h == src_h) { | 377 if (dest_w == src_w && dest_h == src_h) { |
378 pixbuf = gfx::GdkPixbufFromSkBitmap(&data_.favicon); | 378 pixbuf = gfx::GdkPixbufFromSkBitmap(data_.favicon); |
379 } else { | 379 } else { |
380 SkBitmap resized_icon = skia::ImageOperations::Resize( | 380 SkBitmap resized_icon = skia::ImageOperations::Resize( |
381 data_.favicon, | 381 data_.favicon, |
382 skia::ImageOperations::RESIZE_BETTER, | 382 skia::ImageOperations::RESIZE_BETTER, |
383 dest_w, dest_h); | 383 dest_w, dest_h); |
384 pixbuf = gfx::GdkPixbufFromSkBitmap(&resized_icon); | 384 pixbuf = gfx::GdkPixbufFromSkBitmap(resized_icon); |
385 } | 385 } |
386 | 386 |
387 data_.cairo_favicon.UsePixbuf(pixbuf); | 387 data_.cairo_favicon.UsePixbuf(pixbuf); |
388 g_object_unref(pixbuf); | 388 g_object_unref(pixbuf); |
389 } else { | 389 } else { |
390 data_.cairo_favicon.Reset(); | 390 data_.cairo_favicon.Reset(); |
391 } | 391 } |
392 | 392 |
393 // This is kind of a hacky way to determine whether our icon is the default | 393 // This is kind of a hacky way to determine whether our icon is the default |
394 // favicon. But the plumbing that would be necessary to do it right would | 394 // favicon. But the plumbing that would be necessary to do it right would |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); | 1123 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); |
1124 close_button_width_ = gdk_pixbuf_get_width(tab_close); | 1124 close_button_width_ = gdk_pixbuf_get_width(tab_close); |
1125 close_button_height_ = gdk_pixbuf_get_height(tab_close); | 1125 close_button_height_ = gdk_pixbuf_get_height(tab_close); |
1126 | 1126 |
1127 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); | 1127 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); |
1128 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1128 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
1129 title_font_height_ = title_font_->GetHeight(); | 1129 title_font_height_ = title_font_->GetHeight(); |
1130 | 1130 |
1131 initialized_ = true; | 1131 initialized_ = true; |
1132 } | 1132 } |
OLD | NEW |