Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
| 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 "SkAtomics.h" | 8 #include "SkAtomics.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 srcRect.set(0, 0, this->width(), this->height()); | 740 srcRect.set(0, 0, this->width(), this->height()); |
| 741 if (!r.intersect(srcRect, subset)) { | 741 if (!r.intersect(srcRect, subset)) { |
| 742 return false; // r is empty (i.e. no intersection) | 742 return false; // r is empty (i.e. no intersection) |
| 743 } | 743 } |
| 744 | 744 |
| 745 if (fPixelRef->getTexture() != nullptr) { | 745 if (fPixelRef->getTexture() != nullptr) { |
| 746 // Do a deep copy | 746 // Do a deep copy |
| 747 SkPixelRef* pixelRef = fPixelRef->deepCopy(this->colorType(), this->prof ileType(), &subset); | 747 SkPixelRef* pixelRef = fPixelRef->deepCopy(this->colorType(), this->prof ileType(), &subset); |
| 748 if (pixelRef != nullptr) { | 748 if (pixelRef != nullptr) { |
| 749 SkBitmap dst; | 749 SkBitmap dst; |
| 750 dst.setInfo(SkImageInfo::Make(subset.width(), subset.height(), | 750 dst.setInfo(SkImageInfo::Make(subset.width(), subset.height(), |
|
mtklein
2016/04/14 19:36:33
This is probably a good place to be using SkImageI
reed1
2016/04/14 19:59:17
+1
herb_g
2016/04/14 20:28:06
Done.
herb_g
2016/04/14 20:28:06
Done.
| |
| 751 this->colorType(), this->alphaType())) ; | 751 this->colorType(), this->alphaType(), |
| 752 this->profileType())); | |
| 752 dst.setIsVolatile(this->isVolatile()); | 753 dst.setIsVolatile(this->isVolatile()); |
| 753 dst.setPixelRef(pixelRef)->unref(); | 754 dst.setPixelRef(pixelRef)->unref(); |
| 754 SkDEBUGCODE(dst.validate()); | 755 SkDEBUGCODE(dst.validate()); |
| 755 result->swap(dst); | 756 result->swap(dst); |
| 756 return true; | 757 return true; |
| 757 } | 758 } |
| 758 } | 759 } |
| 759 | 760 |
| 760 // If the upper left of the rectangle was outside the bounds of this SkBitma p, we should have | 761 // If the upper left of the rectangle was outside the bounds of this SkBitma p, we should have |
| 761 // exited above. | 762 // exited above. |
| 762 SkASSERT(static_cast<unsigned>(r.fLeft) < static_cast<unsigned>(this->width( ))); | 763 SkASSERT(static_cast<unsigned>(r.fLeft) < static_cast<unsigned>(this->width( ))); |
| 763 SkASSERT(static_cast<unsigned>(r.fTop) < static_cast<unsigned>(this->height( ))); | 764 SkASSERT(static_cast<unsigned>(r.fTop) < static_cast<unsigned>(this->height( ))); |
| 764 | 765 |
| 765 SkBitmap dst; | 766 SkBitmap dst; |
| 766 dst.setInfo(SkImageInfo::Make(r.width(), r.height(), this->colorType(), this ->alphaType()), | 767 dst.setInfo(SkImageInfo::Make(r.width(), r.height(), this->colorType(), |
|
mtklein
2016/04/14 19:36:33
Ditto.
herb_g
2016/04/14 20:28:06
Done.
| |
| 768 this->alphaType(), this->profileType()), | |
| 767 this->rowBytes()); | 769 this->rowBytes()); |
| 768 dst.setIsVolatile(this->isVolatile()); | 770 dst.setIsVolatile(this->isVolatile()); |
| 769 | 771 |
| 770 if (fPixelRef) { | 772 if (fPixelRef) { |
| 771 SkIPoint origin = fPixelRefOrigin; | 773 SkIPoint origin = fPixelRefOrigin; |
| 772 origin.fX += r.fLeft; | 774 origin.fX += r.fLeft; |
| 773 origin.fY += r.fTop; | 775 origin.fY += r.fTop; |
| 774 // share the pixelref with a custom offset | 776 // share the pixelref with a custom offset |
| 775 dst.setPixelRef(fPixelRef, origin); | 777 dst.setPixelRef(fPixelRef, origin); |
| 776 } | 778 } |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1351 /////////////////////////////////////////////////////////////////////////////// | 1353 /////////////////////////////////////////////////////////////////////////////// |
| 1352 | 1354 |
| 1353 #ifdef SK_DEBUG | 1355 #ifdef SK_DEBUG |
| 1354 void SkImageInfo::validate() const { | 1356 void SkImageInfo::validate() const { |
| 1355 SkASSERT(fWidth >= 0); | 1357 SkASSERT(fWidth >= 0); |
| 1356 SkASSERT(fHeight >= 0); | 1358 SkASSERT(fHeight >= 0); |
| 1357 SkASSERT(SkColorTypeIsValid(fColorType)); | 1359 SkASSERT(SkColorTypeIsValid(fColorType)); |
| 1358 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1360 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
| 1359 } | 1361 } |
| 1360 #endif | 1362 #endif |
| OLD | NEW |