Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: content/browser/android/system_ui_resource_manager_impl.cc

Issue 545513002: tryAllocPixels returns bool, allocPixels requires success (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (!glow_bitmap.allocPixels( 43 glow_bitmap.allocPixels(SkImageInfo::MakeA8(bounds.width(), bounds.height()));
44 SkImageInfo::MakeA8(bounds.width(), bounds.height()))) {
45 LOG(FATAL) << " Failed to allocate bitmap of size " << bounds.width() << "x"
46 << bounds.height();
47 }
48 glow_bitmap.eraseColor(SK_ColorTRANSPARENT); 44 glow_bitmap.eraseColor(SK_ColorTRANSPARENT);
49 45
50 SkCanvas canvas(glow_bitmap); 46 SkCanvas canvas(glow_bitmap);
51 canvas.clipRect(SkRect::MakeXYWH(0, 0, bounds.width(), bounds.height())); 47 canvas.clipRect(SkRect::MakeXYWH(0, 0, bounds.width(), bounds.height()));
52 canvas.drawArc(arc_rect, 45, 90, true, paint); 48 canvas.drawArc(arc_rect, 45, 90, true, paint);
53 return glow_bitmap; 49 return glow_bitmap;
54 } 50 }
55 51
56 void LoadBitmap(ui::SystemUIResourceManager::ResourceType type, 52 void LoadBitmap(ui::SystemUIResourceManager::ResourceType type,
57 SkBitmap* bitmap_holder, 53 SkBitmap* bitmap_holder,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 170 }
175 171
176 void SystemUIResourceManagerImpl::OnFinishedLoadBitmap( 172 void SystemUIResourceManagerImpl::OnFinishedLoadBitmap(
177 ResourceType type, 173 ResourceType type,
178 SkBitmap* bitmap_holder) { 174 SkBitmap* bitmap_holder) {
179 DCHECK(bitmap_holder); 175 DCHECK(bitmap_holder);
180 GetEntry(type)->SetBitmap(*bitmap_holder); 176 GetEntry(type)->SetBitmap(*bitmap_holder);
181 } 177 }
182 178
183 } // namespace content 179 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/table_row_nsimage_cache_unittest.mm ('k') | content/browser/compositor/delegated_frame_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698