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 "SkChecksum.h" | 8 #include "SkChecksum.h" |
9 #include "SkMessageBus.h" | 9 #include "SkMessageBus.h" |
10 #include "SkMipMap.h" | 10 #include "SkMipMap.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if (0 == size || size64 > (uint64_t)size) { | 165 if (0 == size || size64 > (uint64_t)size) { |
166 return false; | 166 return false; |
167 } | 167 } |
168 | 168 |
169 SkDiscardableMemory* dm = fFactory(size); | 169 SkDiscardableMemory* dm = fFactory(size); |
170 if (nullptr == dm) { | 170 if (nullptr == dm) { |
171 return false; | 171 return false; |
172 } | 172 } |
173 | 173 |
174 // can we relax this? | 174 // can we relax this? |
175 if (kN32_SkColorType != bitmap->colorType()) { | 175 if (kN32_SkColorType != bitmap->colorType() && kRGB_565_SkColorType != bitma
p->colorType()) { |
176 return false; | 176 return false; |
177 } | 177 } |
178 | 178 |
179 SkImageInfo info = bitmap->info(); | 179 SkImageInfo info = bitmap->info(); |
180 bitmap->setPixelRef(new SkOneShotDiscardablePixelRef(info, dm, bitmap->rowBy
tes()))->unref(); | 180 bitmap->setPixelRef(new SkOneShotDiscardablePixelRef(info, dm, bitmap->rowBy
tes()))->unref(); |
181 bitmap->lockPixels(); | 181 bitmap->lockPixels(); |
182 return bitmap->readyToDraw(); | 182 return bitmap->readyToDraw(); |
183 } | 183 } |
184 | 184 |
185 SkResourceCache::SkResourceCache(DiscardableFactory factory) { | 185 SkResourceCache::SkResourceCache(DiscardableFactory factory) { |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed(
)); | 687 dump->dumpNumericValue(dumpName.c_str(), "size", "bytes", rec.bytesUsed(
)); |
688 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); | 688 dump->setMemoryBacking(dumpName.c_str(), "malloc", nullptr); |
689 } | 689 } |
690 } | 690 } |
691 | 691 |
692 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { | 692 void SkResourceCache::DumpMemoryStatistics(SkTraceMemoryDump* dump) { |
693 // Since resource could be backed by malloc or discardable, the cache always
dumps detailed | 693 // Since resource could be backed by malloc or discardable, the cache always
dumps detailed |
694 // stats to be accurate. | 694 // stats to be accurate. |
695 VisitAll(sk_trace_dump_visitor, dump); | 695 VisitAll(sk_trace_dump_visitor, dump); |
696 } | 696 } |
OLD | NEW |