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

Side by Side Diff: src/lazy/SkDiscardablePixelRef.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/lazy/SkCachingPixelRef.cpp ('k') | src/pdf/SkPDFDevice.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 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDiscardablePixelRef.h" 8 #include "SkDiscardablePixelRef.h"
9 #include "SkDiscardableMemory.h" 9 #include "SkDiscardableMemory.h"
10 #include "SkImageGenerator.h" 10 #include "SkImageGenerator.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 if ((NULL == autoGenerator.get()) 103 if ((NULL == autoGenerator.get())
104 || (!autoGenerator->getInfo(&info)) 104 || (!autoGenerator->getInfo(&info))
105 || (!dst->setInfo(info))) { 105 || (!dst->setInfo(info))) {
106 return false; 106 return false;
107 } 107 }
108 // Since dst->setInfo() may have changed/fixed-up info, we copy it back from that bitmap 108 // Since dst->setInfo() may have changed/fixed-up info, we copy it back from that bitmap
109 info = dst->info(); 109 info = dst->info();
110 110
111 SkASSERT(info.colorType() != kUnknown_SkColorType); 111 SkASSERT(info.colorType() != kUnknown_SkColorType);
112 if (dst->empty()) { // Use a normal pixelref. 112 if (dst->empty()) { // Use a normal pixelref.
113 return dst->allocPixels(); 113 return dst->tryAllocPixels();
114 } 114 }
115 SkAutoTUnref<SkDiscardablePixelRef> ref( 115 SkAutoTUnref<SkDiscardablePixelRef> ref(
116 SkNEW_ARGS(SkDiscardablePixelRef, 116 SkNEW_ARGS(SkDiscardablePixelRef,
117 (info, autoGenerator.detach(), dst->rowBytes(), factory))); 117 (info, autoGenerator.detach(), dst->rowBytes(), factory)));
118 dst->setPixelRef(ref); 118 dst->setPixelRef(ref);
119 return true; 119 return true;
120 } 120 }
121 121
122 // This is the public API 122 // This is the public API
123 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst) { 123 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst) {
124 return SkInstallDiscardablePixelRef(generator, dst, NULL); 124 return SkInstallDiscardablePixelRef(generator, dst, NULL);
125 } 125 }
OLDNEW
« no previous file with comments | « src/lazy/SkCachingPixelRef.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698