OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkDiscardablePixelRef.h" | 8 #include "SkDiscardablePixelRef.h" |
9 #include "SkDiscardableMemory.h" | 9 #include "SkDiscardableMemory.h" |
10 #include "SkImageGenerator.h" | 10 #include "SkImageGenerator.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return false; | 130 return false; |
131 } | 131 } |
132 | 132 |
133 // Since dst->setInfo() may have changed/fixed-up info, we check from the bi
tmap | 133 // Since dst->setInfo() may have changed/fixed-up info, we check from the bi
tmap |
134 SkASSERT(dst->info().colorType() != kUnknown_SkColorType); | 134 SkASSERT(dst->info().colorType() != kUnknown_SkColorType); |
135 | 135 |
136 if (dst->empty()) { // Use a normal pixelref. | 136 if (dst->empty()) { // Use a normal pixelref. |
137 return dst->tryAllocPixels(); | 137 return dst->tryAllocPixels(); |
138 } | 138 } |
139 SkAutoTUnref<SkDiscardablePixelRef> ref( | 139 SkAutoTUnref<SkDiscardablePixelRef> ref( |
140 new SkDiscardablePixelRef(prInfo, autoGenerator.detach(), dst->rowBy
tes(), factory)); | 140 new SkDiscardablePixelRef(prInfo, autoGenerator.release(), dst->rowB
ytes(), factory)); |
141 dst->setPixelRef(ref, origin.x(), origin.y()); | 141 dst->setPixelRef(ref, origin.x(), origin.y()); |
142 return true; | 142 return true; |
143 } | 143 } |
144 | 144 |
145 // These are the public API | 145 // These are the public API |
146 | 146 |
147 bool SkDEPRECATED_InstallDiscardablePixelRef(SkImageGenerator* generator, SkBitm
ap* dst) { | 147 bool SkDEPRECATED_InstallDiscardablePixelRef(SkImageGenerator* generator, SkBitm
ap* dst) { |
148 return SkDEPRECATED_InstallDiscardablePixelRef(generator, nullptr, dst, null
ptr); | 148 return SkDEPRECATED_InstallDiscardablePixelRef(generator, nullptr, dst, null
ptr); |
149 } | 149 } |
150 | 150 |
151 bool SkDEPRECATED_InstallDiscardablePixelRef(SkData* encoded, SkBitmap* dst) { | 151 bool SkDEPRECATED_InstallDiscardablePixelRef(SkData* encoded, SkBitmap* dst) { |
152 SkImageGenerator* generator = SkImageGenerator::NewFromEncoded(encoded); | 152 SkImageGenerator* generator = SkImageGenerator::NewFromEncoded(encoded); |
153 return generator ? | 153 return generator ? |
154 SkDEPRECATED_InstallDiscardablePixelRef(generator, nullptr, dst, nul
lptr) : false; | 154 SkDEPRECATED_InstallDiscardablePixelRef(generator, nullptr, dst, nul
lptr) : false; |
155 } | 155 } |
OLD | NEW |