| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 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 "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 HeapAllocator stdalloc; | 272 HeapAllocator stdalloc; |
| 273 | 273 |
| 274 if (NULL == allocator) { | 274 if (NULL == allocator) { |
| 275 allocator = &stdalloc; | 275 allocator = &stdalloc; |
| 276 } | 276 } |
| 277 return allocator->allocPixelRef(this, ctable); | 277 return allocator->allocPixelRef(this, ctable); |
| 278 } | 278 } |
| 279 | 279 |
| 280 /////////////////////////////////////////////////////////////////////////////// | 280 /////////////////////////////////////////////////////////////////////////////// |
| 281 | 281 |
| 282 bool SkBitmap::allocPixels(const SkImageInfo& requestedInfo, size_t rowBytes) { | 282 bool SkBitmap::allocPixelsCheck(const SkImageInfo& requestedInfo, size_t rowByte
s) { |
| 283 if (kIndex_8_SkColorType == requestedInfo.colorType()) { | 283 if (kIndex_8_SkColorType == requestedInfo.colorType()) { |
| 284 return reset_return_false(this); | 284 return reset_return_false(this); |
| 285 } | 285 } |
| 286 if (!this->setInfo(requestedInfo, rowBytes)) { | 286 if (!this->setInfo(requestedInfo, rowBytes)) { |
| 287 return reset_return_false(this); | 287 return reset_return_false(this); |
| 288 } | 288 } |
| 289 | 289 |
| 290 // setInfo may have corrected info (e.g. 565 is always opaque). | 290 // setInfo may have corrected info (e.g. 565 is always opaque). |
| 291 const SkImageInfo& correctedInfo = this->info(); | 291 const SkImageInfo& correctedInfo = this->info(); |
| 292 // setInfo may have computed a valid rowbytes if 0 were passed in | 292 // setInfo may have computed a valid rowbytes if 0 were passed in |
| 293 rowBytes = this->rowBytes(); | 293 rowBytes = this->rowBytes(); |
| 294 | 294 |
| 295 SkMallocPixelRef::PRFactory defaultFactory; | 295 SkMallocPixelRef::PRFactory defaultFactory; |
| 296 | 296 |
| 297 SkPixelRef* pr = defaultFactory.create(correctedInfo, rowBytes, NULL); | 297 SkPixelRef* pr = defaultFactory.create(correctedInfo, rowBytes, NULL); |
| 298 if (NULL == pr) { | 298 if (NULL == pr) { |
| 299 return reset_return_false(this); | 299 return reset_return_false(this); |
| 300 } | 300 } |
| 301 this->setPixelRef(pr)->unref(); | 301 this->setPixelRef(pr)->unref(); |
| 302 | 302 |
| 303 // TODO: lockPixels could/should return bool or void*/NULL | 303 // TODO: lockPixels could/should return bool or void*/NULL |
| 304 this->lockPixels(); | 304 this->lockPixels(); |
| 305 if (NULL == this->getPixels()) { | 305 if (NULL == this->getPixels()) { |
| 306 return reset_return_false(this); | 306 return reset_return_false(this); |
| 307 } | 307 } |
| 308 return true; | 308 return true; |
| 309 } | 309 } |
| 310 | 310 |
| 311 bool SkBitmap::allocPixels(const SkImageInfo& requestedInfo, SkPixelRefFactory*
factory, | 311 bool SkBitmap::allocPixelsCheck(const SkImageInfo& requestedInfo, SkPixelRefFact
ory* factory, |
| 312 SkColorTable* ctable) { | 312 SkColorTable* ctable) { |
| 313 if (kIndex_8_SkColorType == requestedInfo.fColorType && NULL == ctable) { | 313 if (kIndex_8_SkColorType == requestedInfo.fColorType && NULL == ctable) { |
| 314 return reset_return_false(this); | 314 return reset_return_false(this); |
| 315 } | 315 } |
| 316 if (!this->setInfo(requestedInfo)) { | 316 if (!this->setInfo(requestedInfo)) { |
| 317 return reset_return_false(this); | 317 return reset_return_false(this); |
| 318 } | 318 } |
| 319 | 319 |
| 320 // setInfo may have corrected info (e.g. 565 is always opaque). | 320 // setInfo may have corrected info (e.g. 565 is always opaque). |
| 321 const SkImageInfo& correctedInfo = this->info(); | 321 const SkImageInfo& correctedInfo = this->info(); |
| 322 | 322 |
| (...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 /////////////////////////////////////////////////////////////////////////////// | 1389 /////////////////////////////////////////////////////////////////////////////// |
| 1390 | 1390 |
| 1391 #ifdef SK_DEBUG | 1391 #ifdef SK_DEBUG |
| 1392 void SkImageInfo::validate() const { | 1392 void SkImageInfo::validate() const { |
| 1393 SkASSERT(fWidth >= 0); | 1393 SkASSERT(fWidth >= 0); |
| 1394 SkASSERT(fHeight >= 0); | 1394 SkASSERT(fHeight >= 0); |
| 1395 SkASSERT(SkColorTypeIsValid(fColorType)); | 1395 SkASSERT(SkColorTypeIsValid(fColorType)); |
| 1396 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1396 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
| 1397 } | 1397 } |
| 1398 #endif | 1398 #endif |
| OLD | NEW |