| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 bool HasAlpha(gfx::ImageSkia& image, views::Widget* widget) { | 97 bool HasAlpha(gfx::ImageSkia& image, views::Widget* widget) { |
| 98 // Determine which bitmap to use. | 98 // Determine which bitmap to use. |
| 99 ui::ScaleFactor factor = ui::SCALE_FACTOR_100P; | 99 ui::ScaleFactor factor = ui::SCALE_FACTOR_100P; |
| 100 if (widget) { | 100 if (widget) { |
| 101 factor = ui::GetScaleFactorForNativeView(widget->GetNativeView()); | 101 factor = ui::GetScaleFactorForNativeView(widget->GetNativeView()); |
| 102 if (factor == ui::SCALE_FACTOR_NONE) | 102 if (factor == ui::SCALE_FACTOR_NONE) |
| 103 factor = ui::SCALE_FACTOR_100P; | 103 factor = ui::SCALE_FACTOR_100P; |
| 104 } | 104 } |
| 105 | 105 |
| 106 // Extract that bitmap's alpha and look for a non-opaque pixel there. | 106 // Extract that bitmap's alpha and look for a non-opaque pixel there. |
| 107 SkBitmap bitmap = image.GetRepresentation(factor).sk_bitmap(); | 107 SkBitmap bitmap = |
| 108 image.GetRepresentation(ui::GetScaleFactorScale(factor)).sk_bitmap(); |
| 108 if (!bitmap.isNull()) { | 109 if (!bitmap.isNull()) { |
| 109 SkBitmap alpha; | 110 SkBitmap alpha; |
| 110 alpha.setConfig(SkBitmap::kA1_Config, bitmap.width(), bitmap.height(), 0); | 111 alpha.setConfig(SkBitmap::kA1_Config, bitmap.width(), bitmap.height(), 0); |
| 111 bitmap.extractAlpha(&alpha); | 112 bitmap.extractAlpha(&alpha); |
| 112 for (int y = 0; y < bitmap.height(); ++y) { | 113 for (int y = 0; y < bitmap.height(); ++y) { |
| 113 for (int x = 0; x < bitmap.width(); ++x) { | 114 for (int x = 0; x < bitmap.width(); ++x) { |
| 114 if (alpha.getColor(x, y) != SK_ColorBLACK) { | 115 if (alpha.getColor(x, y) != SK_ColorBLACK) { |
| 115 return true; | 116 return true; |
| 116 } | 117 } |
| 117 } | 118 } |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 return message_view_ ? | 784 return message_view_ ? |
| 784 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; | 785 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; |
| 785 } | 786 } |
| 786 | 787 |
| 787 int NotificationView::GetMessageHeight(int width, int limit) { | 788 int NotificationView::GetMessageHeight(int width, int limit) { |
| 788 return message_view_ ? | 789 return message_view_ ? |
| 789 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; | 790 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; |
| 790 } | 791 } |
| 791 | 792 |
| 792 } // namespace message_center | 793 } // namespace message_center |
| OLD | NEW |