| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 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 "SkImage_Base.h" | 8 #include "SkImage_Base.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 sk_sp<SkImage> SkMakeImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, | 247 sk_sp<SkImage> SkMakeImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, |
| 248 const SkIPoint& pixelRefOrigin, size_t ro
wBytes) { | 248 const SkIPoint& pixelRefOrigin, size_t ro
wBytes) { |
| 249 if (!SkImage_Raster::ValidArgs(info, rowBytes, false, nullptr)) { | 249 if (!SkImage_Raster::ValidArgs(info, rowBytes, false, nullptr)) { |
| 250 return nullptr; | 250 return nullptr; |
| 251 } | 251 } |
| 252 return sk_make_sp<SkImage_Raster>(info, pr, pixelRefOrigin, rowBytes); | 252 return sk_make_sp<SkImage_Raster>(info, pr, pixelRefOrigin, rowBytes); |
| 253 } | 253 } |
| 254 | 254 |
| 255 sk_sp<SkImage> SkMakeImageFromRasterBitmap(const SkBitmap& bm, ForceCopyMode for
ceCopy) { | 255 sk_sp<SkImage> SkMakeImageFromRasterBitmap(const SkBitmap& bm, ForceCopyMode for
ceCopy) { |
| 256 SkASSERT(nullptr == bm.getTexture()); | |
| 257 | |
| 258 bool hasColorTable = false; | 256 bool hasColorTable = false; |
| 259 if (kIndex_8_SkColorType == bm.colorType()) { | 257 if (kIndex_8_SkColorType == bm.colorType()) { |
| 260 SkAutoLockPixels autoLockPixels(bm); | 258 SkAutoLockPixels autoLockPixels(bm); |
| 261 hasColorTable = bm.getColorTable() != nullptr; | 259 hasColorTable = bm.getColorTable() != nullptr; |
| 262 } | 260 } |
| 263 | 261 |
| 264 if (!SkImage_Raster::ValidArgs(bm.info(), bm.rowBytes(), hasColorTable, null
ptr)) { | 262 if (!SkImage_Raster::ValidArgs(bm.info(), bm.rowBytes(), hasColorTable, null
ptr)) { |
| 265 return nullptr; | 263 return nullptr; |
| 266 } | 264 } |
| 267 | 265 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 294 // pixelref since the caller might call setImmutable() themselves | 292 // pixelref since the caller might call setImmutable() themselves |
| 295 // (thus changing our state). | 293 // (thus changing our state). |
| 296 if (fBitmap.isImmutable()) { | 294 if (fBitmap.isImmutable()) { |
| 297 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); | 295 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); |
| 298 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); | 296 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); |
| 299 return true; | 297 return true; |
| 300 } | 298 } |
| 301 } | 299 } |
| 302 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); | 300 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); |
| 303 } | 301 } |
| OLD | NEW |