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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPicture.h" | 10 #include "SkPicture.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 | 68 |
69 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { | 69 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { |
70 SkImageInfo info; | 70 SkImageInfo info; |
71 if (!bm.asImageInfo(&info)) { | 71 if (!bm.asImageInfo(&info)) { |
72 return NULL; | 72 return NULL; |
73 } | 73 } |
74 | 74 |
75 SkImage* image = NULL; | 75 SkImage* image = NULL; |
76 if (canSharePixelRef || bm.isImmutable()) { | 76 if (canSharePixelRef || bm.isImmutable()) { |
77 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); | 77 image = SkNewImageFromPixelRef(bm.pixelRef()); |
78 } else { | 78 } else { |
79 bm.lockPixels(); | 79 bm.lockPixels(); |
80 if (bm.getPixels()) { | 80 if (bm.getPixels()) { |
81 image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes()); | 81 image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes()); |
82 } | 82 } |
83 bm.unlockPixels(); | 83 bm.unlockPixels(); |
84 } | 84 } |
85 return image; | 85 return image; |
86 } | 86 } |
87 | 87 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 canvas->save(); | 134 canvas->save(); |
135 } | 135 } |
136 canvas->concat(matrix); | 136 canvas->concat(matrix); |
137 if (!paint || !needs_layer(*paint)) { | 137 if (!paint || !needs_layer(*paint)) { |
138 canvas->clipRect(tmpSrc); | 138 canvas->clipRect(tmpSrc); |
139 } | 139 } |
140 | 140 |
141 canvas->drawPicture(*picture); | 141 canvas->drawPicture(*picture); |
142 canvas->restoreToCount(saveCount); | 142 canvas->restoreToCount(saveCount); |
143 } | 143 } |
OLD | NEW |