OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |