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 | |
348 SkIRect bounds = { 0, 0, info.fWidth, info.fHeight }; | |
349 if (subset && !bounds.intersect(*subset)) { | |
350 bounds.setEmpty(); | |
351 } | |
352 | |
353 fRowBytes = 0; // not known until we're locked | |
354 fPixelRefOrigin.set(bounds.left(), bounds.top()); | |
355 fWidth = bounds.width(); | |
356 fHeight = bounds.height(); | |
357 | |
358 return this->setPixelRef(pr); | |
scroggo
2014/01/09 00:02:11
This will overwrite fPixelRefOrigin. Instead, I th
reed1
2014/01/13 16:27:26
Done.
| |
359 } | |
360 | |
336 void SkBitmap::updatePixelsFromRef() const { | 361 void SkBitmap::updatePixelsFromRef() const { |
337 if (NULL != fPixelRef) { | 362 if (NULL != fPixelRef) { |
338 if (fPixelLockCount > 0) { | 363 if (fPixelLockCount > 0) { |
339 SkASSERT(fPixelRef->isLocked()); | 364 SkASSERT(fPixelRef->isLocked()); |
340 | 365 |
341 void* p = fPixelRef->pixels(); | 366 void* p = fPixelRef->pixels(); |
342 if (NULL != p) { | 367 if (NULL != p) { |
343 p = (char*)p | 368 p = (char*)p |
344 + fPixelRef->rowBytes() * fPixelRefOrigin.fY | 369 + fPixelRef->rowBytes() * fPixelRefOrigin.fY |
345 + fPixelRefOrigin.fX * fBytesPerPixel; | 370 + fPixelRefOrigin.fX * fBytesPerPixel; |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1636 if (NULL != uri) { | 1661 if (NULL != uri) { |
1637 str->appendf(" uri:\"%s\"", uri); | 1662 str->appendf(" uri:\"%s\"", uri); |
1638 } else { | 1663 } else { |
1639 str->appendf(" pixelref:%p", pr); | 1664 str->appendf(" pixelref:%p", pr); |
1640 } | 1665 } |
1641 } | 1666 } |
1642 | 1667 |
1643 str->append(")"); | 1668 str->append(")"); |
1644 } | 1669 } |
1645 #endif | 1670 #endif |
OLD | NEW |