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 "SkImagePriv.h" | 8 #include "SkImagePriv.h" |
| 9 #include "SkImage_Base.h" |
9 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
10 #include "SkPicture.h" | 11 #include "SkPicture.h" |
11 | 12 |
12 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { | 13 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef, |
| 14 const SkSurfaceProps* props) { |
13 const SkImageInfo info = bm.info(); | 15 const SkImageInfo info = bm.info(); |
14 if (kUnknown_SkColorType == info.colorType()) { | 16 if (kUnknown_SkColorType == info.colorType()) { |
15 return NULL; | 17 return NULL; |
16 } | 18 } |
17 | 19 |
18 SkImage* image = NULL; | 20 SkImage* image = NULL; |
19 if (canSharePixelRef || bm.isImmutable()) { | 21 if (canSharePixelRef || bm.isImmutable()) { |
20 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); | 22 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes(), props
); |
21 } else { | 23 } else { |
22 bm.lockPixels(); | 24 bm.lockPixels(); |
23 if (bm.getPixels()) { | 25 if (bm.getPixels()) { |
24 image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes()); | 26 image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes()); |
25 } | 27 } |
26 bm.unlockPixels(); | 28 bm.unlockPixels(); |
| 29 |
| 30 // we don't expose props to NewRasterCopy (need a private vers) so post-
init it here |
| 31 if (image && props) { |
| 32 as_IB(image)->initWithProps(*props); |
| 33 } |
27 } | 34 } |
28 return image; | 35 return image; |
29 } | 36 } |
OLD | NEW |