| 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/ntp_background_util.h" | 5 #include "chrome/browser/ntp_background_util.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/themes/theme_service.h" | 10 #include "chrome/browser/themes/theme_service.h" |
| 11 #include "grit/theme_resources.h" | 11 #include "grit/theme_resources.h" |
| 12 #include "third_party/skia/include/core/SkBitmap.h" | |
| 13 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
| 13 #include "ui/gfx/image/image_skia.h" |
| 14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 15 #include "ui/gfx/skia_util.h" | 15 #include "ui/gfx/skia_util.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 void PaintThemeBackground( | 19 void PaintThemeBackground( |
| 20 gfx::Canvas* canvas, SkBitmap* ntp_background, int tiling, int alignment, | 20 gfx::Canvas* canvas, gfx::ImageSkia* ntp_background, int tiling, |
| 21 const gfx::Rect& area, int tab_contents_height) { | 21 int alignment, const gfx::Rect& area, int tab_contents_height) { |
| 22 int x_pos = 0; | 22 int x_pos = 0; |
| 23 int y_pos = 0; | 23 int y_pos = 0; |
| 24 int width = area.width() + ntp_background->width(); | 24 int width = area.width() + ntp_background->width(); |
| 25 int height = area.height() + ntp_background->height(); | 25 int height = area.height() + ntp_background->height(); |
| 26 | 26 |
| 27 if (alignment & ThemeService::ALIGN_BOTTOM) { | 27 if (alignment & ThemeService::ALIGN_BOTTOM) { |
| 28 y_pos += area.height() + tab_contents_height - ntp_background->height(); | 28 y_pos += area.height() + tab_contents_height - ntp_background->height(); |
| 29 } else if (alignment & ThemeService::ALIGN_TOP) { | 29 } else if (alignment & ThemeService::ALIGN_TOP) { |
| 30 // no op | 30 // no op |
| 31 } else { // ALIGN_CENTER | 31 } else { // ALIGN_CENTER |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 int tab_contents_height) { | 71 int tab_contents_height) { |
| 72 // Draw the background to match the new tab page. | 72 // Draw the background to match the new tab page. |
| 73 canvas->FillRect(area, tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND)); | 73 canvas->FillRect(area, tp->GetColor(ThemeService::COLOR_NTP_BACKGROUND)); |
| 74 | 74 |
| 75 if (tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { | 75 if (tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { |
| 76 int tiling = ThemeService::NO_REPEAT; | 76 int tiling = ThemeService::NO_REPEAT; |
| 77 tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_TILING, &tiling); | 77 tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_TILING, &tiling); |
| 78 int alignment; | 78 int alignment; |
| 79 if (tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, | 79 if (tp->GetDisplayProperty(ThemeService::NTP_BACKGROUND_ALIGNMENT, |
| 80 &alignment)) { | 80 &alignment)) { |
| 81 SkBitmap* ntp_background = tp->GetBitmapNamed(IDR_THEME_NTP_BACKGROUND); | 81 gfx::ImageSkia* ntp_background = |
| 82 tp->GetImageSkiaNamed(IDR_THEME_NTP_BACKGROUND); |
| 82 | 83 |
| 83 PaintThemeBackground( | 84 PaintThemeBackground( |
| 84 canvas, ntp_background, tiling, alignment, area, tab_contents_height); | 85 canvas, ntp_background, tiling, alignment, area, tab_contents_height); |
| 85 } | 86 } |
| 86 } | 87 } |
| 87 } | 88 } |
| OLD | NEW |