OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return gfx::Size(); | 125 return gfx::Size(); |
126 | 126 |
127 gfx::Size canvas_size = view->bounds().size(); | 127 gfx::Size canvas_size = view->bounds().size(); |
128 gfx::Canvas canvas(canvas_size, 1.0 /* image_scale */, | 128 gfx::Canvas canvas(canvas_size, 1.0 /* image_scale */, |
129 true /* is_opaque */); | 129 true /* is_opaque */); |
130 static_assert(kBitmapColor != SK_ColorBLACK, | 130 static_assert(kBitmapColor != SK_ColorBLACK, |
131 "The bitmap color must match the background color"); | 131 "The bitmap color must match the background color"); |
132 canvas.DrawColor(SK_ColorBLACK); | 132 canvas.DrawColor(SK_ColorBLACK); |
133 view->OnPaint(&canvas); | 133 view->OnPaint(&canvas); |
134 | 134 |
135 SkBitmap bitmap; | 135 SkBitmap bitmap = canvas.GetBitmap(); |
136 bitmap.allocN32Pixels(canvas_size.width(), canvas_size.height()); | |
137 canvas.sk_canvas()->readPixels(&bitmap, 0, 0); | |
138 | |
139 // Incrementally inset each edge at its midpoint to find the bounds of the | 136 // Incrementally inset each edge at its midpoint to find the bounds of the |
140 // rect containing the image's color. This assumes that the image is | 137 // rect containing the image's color. This assumes that the image is |
141 // centered in the canvas. | 138 // centered in the canvas. |
142 const int kHalfWidth = canvas_size.width() / 2; | 139 const int kHalfWidth = canvas_size.width() / 2; |
143 const int kHalfHeight = canvas_size.height() / 2; | 140 const int kHalfHeight = canvas_size.height() / 2; |
144 gfx::Rect rect(canvas_size); | 141 gfx::Rect rect(canvas_size); |
145 while (rect.width() > 0 && | 142 while (rect.width() > 0 && |
146 bitmap.getColor(rect.x(), kHalfHeight) != kBitmapColor) | 143 bitmap.getColor(rect.x(), kHalfHeight) != kBitmapColor) |
147 rect.Inset(1, 0, 0, 0); | 144 rect.Inset(1, 0, 0, 0); |
148 while (rect.height() > 0 && | 145 while (rect.height() > 0 && |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 TEST_F(NotificationViewTest, Pinned) { | 706 TEST_F(NotificationViewTest, Pinned) { |
710 notification()->set_pinned(true); | 707 notification()->set_pinned(true); |
711 | 708 |
712 UpdateNotificationViews(); | 709 UpdateNotificationViews(); |
713 EXPECT_EQ(NULL, GetCloseButton()); | 710 EXPECT_EQ(NULL, GetCloseButton()); |
714 } | 711 } |
715 | 712 |
716 #endif // defined(OS_CHROMEOS) | 713 #endif // defined(OS_CHROMEOS) |
717 | 714 |
718 } // namespace message_center | 715 } // namespace message_center |
OLD | NEW |