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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 , fBitmap(bm) | 86 , fBitmap(bm) |
87 { | 87 { |
88 if (bm.pixelRef()->isPreLocked()) { | 88 if (bm.pixelRef()->isPreLocked()) { |
89 // we only preemptively lock if there is no chance of triggering som
ething expensive | 89 // we only preemptively lock if there is no chance of triggering som
ething expensive |
90 // like a lazy decode or imagegenerator. PreLocked means it is flat
pixels already. | 90 // like a lazy decode or imagegenerator. PreLocked means it is flat
pixels already. |
91 fBitmap.lockPixels(); | 91 fBitmap.lockPixels(); |
92 } | 92 } |
93 SkASSERT(fBitmap.isImmutable()); | 93 SkASSERT(fBitmap.isImmutable()); |
94 } | 94 } |
95 | 95 |
| 96 bool onIsLazyGenerated() const override { |
| 97 return fBitmap.pixelRef() && fBitmap.pixelRef()->isLazyGenerated(); |
| 98 } |
| 99 |
96 private: | 100 private: |
97 SkImage_Raster() : INHERITED(0, 0, kNeedNewImageUniqueID, NULL) { | 101 SkImage_Raster() : INHERITED(0, 0, kNeedNewImageUniqueID, NULL) { |
98 fBitmap.setImmutable(); | 102 fBitmap.setImmutable(); |
99 } | 103 } |
100 | 104 |
101 SkBitmap fBitmap; | 105 SkBitmap fBitmap; |
102 | 106 |
103 typedef SkImage_Base INHERITED; | 107 typedef SkImage_Base INHERITED; |
104 }; | 108 }; |
105 | 109 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 // pixelref since the caller might call setImmutable() themselves | 285 // pixelref since the caller might call setImmutable() themselves |
282 // (thus changing our state). | 286 // (thus changing our state). |
283 if (fBitmap.isImmutable()) { | 287 if (fBitmap.isImmutable()) { |
284 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); | 288 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); |
285 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); | 289 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); |
286 return true; | 290 return true; |
287 } | 291 } |
288 } | 292 } |
289 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); | 293 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); |
290 } | 294 } |
OLD | NEW |