| 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 "ui/message_center/views/notification_view.h" | 5 #include "ui/message_center/views/notification_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 scoped_ptr<views::Border> MakeSeparatorBorder(int top, | 75 scoped_ptr<views::Border> MakeSeparatorBorder(int top, |
| 76 int left, | 76 int left, |
| 77 SkColor color) { | 77 SkColor color) { |
| 78 return views::Border::CreateSolidSidedBorder(top, left, 0, 0, color); | 78 return views::Border::CreateSolidSidedBorder(top, left, 0, 0, color); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // static | 81 // static |
| 82 // Return true if and only if the image is null or has alpha. | 82 // Return true if and only if the image is null or has alpha. |
| 83 bool HasAlpha(gfx::ImageSkia& image, views::Widget* widget) { | 83 bool HasAlpha(gfx::ImageSkia& image, views::Widget* widget) { |
| 84 // Determine which bitmap to use. | 84 // Determine which bitmap to use. |
| 85 ui::ScaleFactor factor = ui::SCALE_FACTOR_100P; | 85 float factor = 1.0f; |
| 86 if (widget) { | 86 if (widget) |
| 87 factor = ui::GetScaleFactorForNativeView(widget->GetNativeView()); | 87 factor = ui::GetScaleFactorForNativeView(widget->GetNativeView()); |
| 88 if (factor == ui::SCALE_FACTOR_NONE) | |
| 89 factor = ui::SCALE_FACTOR_100P; | |
| 90 } | |
| 91 | 88 |
| 92 // Extract that bitmap's alpha and look for a non-opaque pixel there. | 89 // Extract that bitmap's alpha and look for a non-opaque pixel there. |
| 93 SkBitmap bitmap = | 90 SkBitmap bitmap = image.GetRepresentation(factor).sk_bitmap(); |
| 94 image.GetRepresentation(ui::GetImageScale(factor)).sk_bitmap(); | |
| 95 if (!bitmap.isNull()) { | 91 if (!bitmap.isNull()) { |
| 96 SkBitmap alpha; | 92 SkBitmap alpha; |
| 97 bitmap.extractAlpha(&alpha); | 93 bitmap.extractAlpha(&alpha); |
| 98 for (int y = 0; y < bitmap.height(); ++y) { | 94 for (int y = 0; y < bitmap.height(); ++y) { |
| 99 for (int x = 0; x < bitmap.width(); ++x) { | 95 for (int x = 0; x < bitmap.width(); ++x) { |
| 100 if (alpha.getColor(x, y) != SK_ColorBLACK) { | 96 if (alpha.getColor(x, y) != SK_ColorBLACK) { |
| 101 return true; | 97 return true; |
| 102 } | 98 } |
| 103 } | 99 } |
| 104 } | 100 } |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 | 759 |
| 764 return message_line_limit; | 760 return message_line_limit; |
| 765 } | 761 } |
| 766 | 762 |
| 767 int NotificationView::GetMessageHeight(int width, int limit) { | 763 int NotificationView::GetMessageHeight(int width, int limit) { |
| 768 return message_view_ ? | 764 return message_view_ ? |
| 769 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; | 765 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; |
| 770 } | 766 } |
| 771 | 767 |
| 772 } // namespace message_center | 768 } // namespace message_center |
| OLD | NEW |