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

Side by Side Diff: src/image/SkImage_Raster.cpp

Issue 869743002: more reinforcement that images never have zero width or height (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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/image/SkImage_Gpu.cpp ('k') | no next file » | 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 2012 Google Inc. 2 * Copyright 2012 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 "SkImage_Base.h" 8 #include "SkImage_Base.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 179 }
180 180
181 return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes, NULL)); 181 return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes, NULL));
182 } 182 }
183 183
184 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator) { 184 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator) {
185 SkBitmap bitmap; 185 SkBitmap bitmap;
186 if (!SkInstallDiscardablePixelRef(generator, &bitmap)) { 186 if (!SkInstallDiscardablePixelRef(generator, &bitmap)) {
187 return NULL; 187 return NULL;
188 } 188 }
189 if (0 == bitmap.width() || 0 == bitmap.height()) {
190 return NULL;
191 }
192
189 return SkNEW_ARGS(SkImage_Raster, (bitmap, NULL)); 193 return SkNEW_ARGS(SkImage_Raster, (bitmap, NULL));
190 } 194 }
191 195
192 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, size_t rowBytes, 196 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, size_t rowBytes,
193 const SkSurfaceProps* props) { 197 const SkSurfaceProps* props) {
198 if (!SkImage_Raster::ValidArgs(info, rowBytes)) {
199 return NULL;
200 }
194 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes, props)); 201 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes, props));
195 } 202 }
196 203
197 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) { 204 const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* image) {
198 return ((const SkImage_Raster*)image)->getPixelRef(); 205 return ((const SkImage_Raster*)image)->getPixelRef();
199 } 206 }
200 207
201 bool SkImage_Raster::isOpaque() const { 208 bool SkImage_Raster::isOpaque() const {
202 return fBitmap.isOpaque(); 209 return fBitmap.isOpaque();
203 } 210 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698