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

Side by Side Diff: src/core/SkScalerContext.cpp

Issue 510423005: make allocPixels throw on failure (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkScalerContext.h" 10 #include "SkScalerContext.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 SkDEBUGFAIL("unexpected mask format"); 430 SkDEBUGFAIL("unexpected mask format");
431 } 431 }
432 432
433 SkRasterClip clip; 433 SkRasterClip clip;
434 clip.setRect(SkIRect::MakeWH(dstW, dstH)); 434 clip.setRect(SkIRect::MakeWH(dstW, dstH));
435 435
436 const SkImageInfo info = SkImageInfo::MakeA8(dstW, dstH); 436 const SkImageInfo info = SkImageInfo::MakeA8(dstW, dstH);
437 SkBitmap bm; 437 SkBitmap bm;
438 438
439 if (0 == dstRB) { 439 if (0 == dstRB) {
440 if (!bm.allocPixels(info)) { 440 if (!bm.tryAllocPixels(info)) {
441 // can't allocate offscreen, so empty the mask and return 441 // can't allocate offscreen, so empty the mask and return
442 sk_bzero(mask.fImage, mask.computeImageSize()); 442 sk_bzero(mask.fImage, mask.computeImageSize());
443 return; 443 return;
444 } 444 }
445 } else { 445 } else {
446 bm.installPixels(info, mask.fImage, dstRB); 446 bm.installPixels(info, mask.fImage, dstRB);
447 } 447 }
448 sk_bzero(bm.getPixels(), bm.getSafeSize()); 448 sk_bzero(bm.getPixels(), bm.getSafeSize());
449 449
450 SkDraw draw; 450 SkDraw draw;
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc, 792 SkScalerContext* SkTypeface::createScalerContext(const SkDescriptor* desc,
793 bool allowFailure) const { 793 bool allowFailure) const {
794 SkScalerContext* c = this->onCreateScalerContext(desc); 794 SkScalerContext* c = this->onCreateScalerContext(desc);
795 795
796 if (!c && !allowFailure) { 796 if (!c && !allowFailure) {
797 c = SkNEW_ARGS(SkScalerContext_Empty, 797 c = SkNEW_ARGS(SkScalerContext_Empty,
798 (const_cast<SkTypeface*>(this), desc)); 798 (const_cast<SkTypeface*>(this), desc));
799 } 799 }
800 return c; 800 return c;
801 } 801 }
OLDNEW
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698