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 "content/browser/android/system_ui_resource_manager_impl.h" | 5 #include "content/browser/android/system_ui_resource_manager_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 paint.setStyle(SkPaint::kFill_Style); | 33 paint.setStyle(SkPaint::kFill_Style); |
34 | 34 |
35 const float arc_width = | 35 const float arc_width = |
36 std::min(screen_size.width(), screen_size.height()) * 0.5f / kSin; | 36 std::min(screen_size.width(), screen_size.height()) * 0.5f / kSin; |
37 const float y = kCos * arc_width; | 37 const float y = kCos * arc_width; |
38 const float height = arc_width - y; | 38 const float height = arc_width - y; |
39 gfx::Size bounds(arc_width, height); | 39 gfx::Size bounds(arc_width, height); |
40 SkRect arc_rect = SkRect::MakeXYWH( | 40 SkRect arc_rect = SkRect::MakeXYWH( |
41 -arc_width / 2.f, -arc_width - y, arc_width * 2.f, arc_width * 2.f); | 41 -arc_width / 2.f, -arc_width - y, arc_width * 2.f, arc_width * 2.f); |
42 SkBitmap glow_bitmap; | 42 SkBitmap glow_bitmap; |
43 glow_bitmap.allocPixels(SkImageInfo::MakeA8(bounds.width(), bounds.height())); | 43 if (!glow_bitmap.allocPixels( |
| 44 SkImageInfo::MakeA8(bounds.width(), bounds.height()))) { |
| 45 LOG(FATAL) << " Failed to allocate bitmap of size " << bounds.width() << "x" |
| 46 << bounds.height(); |
| 47 } |
44 glow_bitmap.eraseColor(SK_ColorTRANSPARENT); | 48 glow_bitmap.eraseColor(SK_ColorTRANSPARENT); |
45 | 49 |
46 SkCanvas canvas(glow_bitmap); | 50 SkCanvas canvas(glow_bitmap); |
47 canvas.clipRect(SkRect::MakeXYWH(0, 0, bounds.width(), bounds.height())); | 51 canvas.clipRect(SkRect::MakeXYWH(0, 0, bounds.width(), bounds.height())); |
48 canvas.drawArc(arc_rect, 45, 90, true, paint); | 52 canvas.drawArc(arc_rect, 45, 90, true, paint); |
49 return glow_bitmap; | 53 return glow_bitmap; |
50 } | 54 } |
51 | 55 |
52 void LoadBitmap(ui::SystemUIResourceManager::ResourceType type, | 56 void LoadBitmap(ui::SystemUIResourceManager::ResourceType type, |
53 SkBitmap* bitmap_holder, | 57 SkBitmap* bitmap_holder, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 174 } |
171 | 175 |
172 void SystemUIResourceManagerImpl::OnFinishedLoadBitmap( | 176 void SystemUIResourceManagerImpl::OnFinishedLoadBitmap( |
173 ResourceType type, | 177 ResourceType type, |
174 SkBitmap* bitmap_holder) { | 178 SkBitmap* bitmap_holder) { |
175 DCHECK(bitmap_holder); | 179 DCHECK(bitmap_holder); |
176 GetEntry(type)->SetBitmap(*bitmap_holder); | 180 GetEntry(type)->SetBitmap(*bitmap_holder); |
177 } | 181 } |
178 | 182 |
179 } // namespace content | 183 } // namespace content |
OLD | NEW |