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

Side by Side Diff: chrome/browser/themes/browser_theme_pack.cc

Issue 556463002: Revert of 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 (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 "chrome/browser/themes/browser_theme_pack.h" 5 #include "chrome/browser/themes/browser_theme_pack.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 // Computes a bitmap at one scale from a bitmap at a different scale. 470 // Computes a bitmap at one scale from a bitmap at a different scale.
471 SkBitmap CreateLowQualityResizedBitmap(const SkBitmap& source_bitmap, 471 SkBitmap CreateLowQualityResizedBitmap(const SkBitmap& source_bitmap,
472 ui::ScaleFactor source_scale_factor, 472 ui::ScaleFactor source_scale_factor,
473 ui::ScaleFactor desired_scale_factor) { 473 ui::ScaleFactor desired_scale_factor) {
474 gfx::Size scaled_size = gfx::ToCeiledSize( 474 gfx::Size scaled_size = gfx::ToCeiledSize(
475 gfx::ScaleSize(gfx::Size(source_bitmap.width(), 475 gfx::ScaleSize(gfx::Size(source_bitmap.width(),
476 source_bitmap.height()), 476 source_bitmap.height()),
477 ui::GetScaleForScaleFactor(desired_scale_factor) / 477 ui::GetScaleForScaleFactor(desired_scale_factor) /
478 ui::GetScaleForScaleFactor(source_scale_factor))); 478 ui::GetScaleForScaleFactor(source_scale_factor)));
479 SkBitmap scaled_bitmap; 479 SkBitmap scaled_bitmap;
480 scaled_bitmap.allocN32Pixels(scaled_size.width(), scaled_size.height()); 480 if (!scaled_bitmap.allocN32Pixels(scaled_size.width(), scaled_size.height()))
481 SK_CRASH();
481 scaled_bitmap.eraseARGB(0, 0, 0, 0); 482 scaled_bitmap.eraseARGB(0, 0, 0, 0);
482 SkCanvas canvas(scaled_bitmap); 483 SkCanvas canvas(scaled_bitmap);
483 SkRect scaled_bounds = RectToSkRect(gfx::Rect(scaled_size)); 484 SkRect scaled_bounds = RectToSkRect(gfx::Rect(scaled_size));
484 // Note(oshima): The following scaling code doesn't work with 485 // Note(oshima): The following scaling code doesn't work with
485 // a mask image. 486 // a mask image.
486 canvas.drawBitmapRect(source_bitmap, NULL, scaled_bounds); 487 canvas.drawBitmapRect(source_bitmap, NULL, scaled_bounds);
487 return scaled_bitmap; 488 return scaled_bitmap;
488 } 489 }
489 490
490 // A ImageSkiaSource that scales 100P image to the target scale factor 491 // A ImageSkiaSource that scales 100P image to the target scale factor
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 false, 1630 false,
1630 &bitmap_data)) { 1631 &bitmap_data)) {
1631 NOTREACHED() << "Unable to encode theme image for prs_id=" 1632 NOTREACHED() << "Unable to encode theme image for prs_id="
1632 << prs_id << " for scale_factor=" << scale_factors_[i]; 1633 << prs_id << " for scale_factor=" << scale_factors_[i];
1633 break; 1634 break;
1634 } 1635 }
1635 image_memory_[scaled_raw_id] = 1636 image_memory_[scaled_raw_id] =
1636 base::RefCountedBytes::TakeVector(&bitmap_data); 1637 base::RefCountedBytes::TakeVector(&bitmap_data);
1637 } 1638 }
1638 } 1639 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/notification_conversion_helper.cc ('k') | chrome/browser/ui/app_list/fast_show_pickler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698