| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 326 } |
| 327 | 327 |
| 328 bool SkBitmap::setAlphaType(SkAlphaType alphaType) { | 328 bool SkBitmap::setAlphaType(SkAlphaType alphaType) { |
| 329 if (!validate_alphaType(this->config(), alphaType, &alphaType)) { | 329 if (!validate_alphaType(this->config(), alphaType, &alphaType)) { |
| 330 return false; | 330 return false; |
| 331 } | 331 } |
| 332 fAlphaType = SkToU8(alphaType); | 332 fAlphaType = SkToU8(alphaType); |
| 333 return true; | 333 return true; |
| 334 } | 334 } |
| 335 | 335 |
| 336 SkPixelRef* SkBitmap::installPixelRef(SkPixelRef* pr, const SkIRect* subset) { | |
| 337 if (NULL == pr) { | |
| 338 this->reset(); | |
| 339 return NULL; | |
| 340 } | |
| 341 | |
| 342 const SkImageInfo& info = pr->info(); | |
| 343 | |
| 344 fConfig = SkColorTypeToBitmapConfig(info.fColorType); | |
| 345 fAlphaType = info.fAlphaType; | |
| 346 fBytesPerPixel = info.bytesPerPixel(); | |
| 347 // not known until we're locked | |
| 348 fRowBytes = 0; | |
| 349 | |
| 350 SkIRect bounds = { 0, 0, info.fWidth, info.fHeight }; | |
| 351 if (subset && !bounds.intersect(*subset)) { | |
| 352 bounds.setEmpty(); | |
| 353 } | |
| 354 | |
| 355 fWidth = bounds.width(); | |
| 356 fHeight = bounds.height(); | |
| 357 return this->setPixelRef(pr, bounds.left(), bounds.top()); | |
| 358 } | |
| 359 | |
| 360 void SkBitmap::updatePixelsFromRef() const { | 336 void SkBitmap::updatePixelsFromRef() const { |
| 361 if (NULL != fPixelRef) { | 337 if (NULL != fPixelRef) { |
| 362 if (fPixelLockCount > 0) { | 338 if (fPixelLockCount > 0) { |
| 363 SkASSERT(fPixelRef->isLocked()); | 339 SkASSERT(fPixelRef->isLocked()); |
| 364 | 340 |
| 365 void* p = fPixelRef->pixels(); | 341 void* p = fPixelRef->pixels(); |
| 366 if (NULL != p) { | 342 if (NULL != p) { |
| 367 p = (char*)p | 343 p = (char*)p |
| 368 + fPixelRefOrigin.fY * fRowBytes | 344 + fPixelRefOrigin.fY * fRowBytes |
| 369 + fPixelRefOrigin.fX * fBytesPerPixel; | 345 + fPixelRefOrigin.fX * fBytesPerPixel; |
| (...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 if (NULL != uri) { | 1636 if (NULL != uri) { |
| 1661 str->appendf(" uri:\"%s\"", uri); | 1637 str->appendf(" uri:\"%s\"", uri); |
| 1662 } else { | 1638 } else { |
| 1663 str->appendf(" pixelref:%p", pr); | 1639 str->appendf(" pixelref:%p", pr); |
| 1664 } | 1640 } |
| 1665 } | 1641 } |
| 1666 | 1642 |
| 1667 str->append(")"); | 1643 str->append(")"); |
| 1668 } | 1644 } |
| 1669 #endif | 1645 #endif |
| OLD | NEW |