aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkBitmap.cpp')
-rw-r--r--src/core/SkBitmap.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index f950e28cdc..6615b1c52b 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -333,6 +333,30 @@ bool SkBitmap::setAlphaType(SkAlphaType alphaType) {
return true;
}
+SkPixelRef* SkBitmap::installPixelRef(SkPixelRef* pr, const SkIRect* subset) {
+ if (NULL == pr) {
+ this->reset();
+ return NULL;
+ }
+
+ const SkImageInfo& info = pr->info();
+
+ fConfig = SkColorTypeToBitmapConfig(info.fColorType);
+ fAlphaType = info.fAlphaType;
+ fBytesPerPixel = info.bytesPerPixel();
+ // not known until we're locked
+ fRowBytes = 0;
+
+ SkIRect bounds = { 0, 0, info.fWidth, info.fHeight };
+ if (subset && !bounds.intersect(*subset)) {
+ bounds.setEmpty();
+ }
+
+ fWidth = bounds.width();
+ fHeight = bounds.height();
+ return this->setPixelRef(pr, bounds.left(), bounds.top());
+}
+
void SkBitmap::updatePixelsFromRef() const {
if (NULL != fPixelRef) {
if (fPixelLockCount > 0) {