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

Side by Side Diff: chrome/browser/themes/browser_theme_pack.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 (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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // Computes a bitmap at one scale from a bitmap at a different scale. 452 // Computes a bitmap at one scale from a bitmap at a different scale.
453 SkBitmap CreateLowQualityResizedBitmap(const SkBitmap& source_bitmap, 453 SkBitmap CreateLowQualityResizedBitmap(const SkBitmap& source_bitmap,
454 ui::ScaleFactor source_scale_factor, 454 ui::ScaleFactor source_scale_factor,
455 ui::ScaleFactor desired_scale_factor) { 455 ui::ScaleFactor desired_scale_factor) {
456 gfx::Size scaled_size = gfx::ToCeiledSize( 456 gfx::Size scaled_size = gfx::ToCeiledSize(
457 gfx::ScaleSize(gfx::Size(source_bitmap.width(), 457 gfx::ScaleSize(gfx::Size(source_bitmap.width(),
458 source_bitmap.height()), 458 source_bitmap.height()),
459 ui::GetScaleForScaleFactor(desired_scale_factor) / 459 ui::GetScaleForScaleFactor(desired_scale_factor) /
460 ui::GetScaleForScaleFactor(source_scale_factor))); 460 ui::GetScaleForScaleFactor(source_scale_factor)));
461 SkBitmap scaled_bitmap; 461 SkBitmap scaled_bitmap;
462 if (!scaled_bitmap.allocN32Pixels(scaled_size.width(), scaled_size.height())) 462 scaled_bitmap.allocN32Pixels(scaled_size.width(), scaled_size.height());
463 SK_CRASH();
464 scaled_bitmap.eraseARGB(0, 0, 0, 0); 463 scaled_bitmap.eraseARGB(0, 0, 0, 0);
465 SkCanvas canvas(scaled_bitmap); 464 SkCanvas canvas(scaled_bitmap);
466 SkRect scaled_bounds = RectToSkRect(gfx::Rect(scaled_size)); 465 SkRect scaled_bounds = RectToSkRect(gfx::Rect(scaled_size));
467 // Note(oshima): The following scaling code doesn't work with 466 // Note(oshima): The following scaling code doesn't work with
468 // a mask image. 467 // a mask image.
469 canvas.drawBitmapRect(source_bitmap, NULL, scaled_bounds); 468 canvas.drawBitmapRect(source_bitmap, NULL, scaled_bounds);
470 return scaled_bitmap; 469 return scaled_bitmap;
471 } 470 }
472 471
473 // A ImageSkiaSource that scales 100P image to the target scale factor 472 // A ImageSkiaSource that scales 100P image to the target scale factor
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 false, 1611 false,
1613 &bitmap_data)) { 1612 &bitmap_data)) {
1614 NOTREACHED() << "Unable to encode theme image for prs_id=" 1613 NOTREACHED() << "Unable to encode theme image for prs_id="
1615 << prs_id << " for scale_factor=" << scale_factors_[i]; 1614 << prs_id << " for scale_factor=" << scale_factors_[i];
1616 break; 1615 break;
1617 } 1616 }
1618 image_memory_[scaled_raw_id] = 1617 image_memory_[scaled_raw_id] =
1619 base::RefCountedBytes::TakeVector(&bitmap_data); 1618 base::RefCountedBytes::TakeVector(&bitmap_data);
1620 } 1619 }
1621 } 1620 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698