| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 #include "SkDiscardableMemory.h" | 73 #include "SkDiscardableMemory.h" |
| 74 | 74 |
| 75 class SkOneShotDiscardablePixelRef : public SkPixelRef { | 75 class SkOneShotDiscardablePixelRef : public SkPixelRef { |
| 76 public: | 76 public: |
| 77 SK_DECLARE_INST_COUNT(SkOneShotDiscardablePixelRef) | 77 SK_DECLARE_INST_COUNT(SkOneShotDiscardablePixelRef) |
| 78 // Ownership of the discardablememory is transfered to the pixelref | 78 // Ownership of the discardablememory is transfered to the pixelref |
| 79 SkOneShotDiscardablePixelRef(const SkImageInfo&, SkDiscardableMemory*, size_
t rowBytes); | 79 SkOneShotDiscardablePixelRef(const SkImageInfo&, SkDiscardableMemory*, size_
t rowBytes); |
| 80 ~SkOneShotDiscardablePixelRef(); | 80 ~SkOneShotDiscardablePixelRef(); |
| 81 | 81 |
| 82 protected: | 82 protected: |
| 83 bool onNewLockPixels(LockRec*) SK_OVERRIDE; | 83 bool onNewLockPixels(LockRec*) override; |
| 84 void onUnlockPixels() SK_OVERRIDE; | 84 void onUnlockPixels() override; |
| 85 size_t getAllocatedSizeInBytes() const SK_OVERRIDE; | 85 size_t getAllocatedSizeInBytes() const override; |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 SkDiscardableMemory* fDM; | 88 SkDiscardableMemory* fDM; |
| 89 size_t fRB; | 89 size_t fRB; |
| 90 bool fFirstTime; | 90 bool fFirstTime; |
| 91 | 91 |
| 92 typedef SkPixelRef INHERITED; | 92 typedef SkPixelRef INHERITED; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 SkOneShotDiscardablePixelRef::SkOneShotDiscardablePixelRef(const SkImageInfo& in
fo, | 95 SkOneShotDiscardablePixelRef::SkOneShotDiscardablePixelRef(const SkImageInfo& in
fo, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 return this->info().getSafeSize(fRB); | 143 return this->info().getSafeSize(fRB); |
| 144 } | 144 } |
| 145 | 145 |
| 146 class SkResourceCacheDiscardableAllocator : public SkBitmap::Allocator { | 146 class SkResourceCacheDiscardableAllocator : public SkBitmap::Allocator { |
| 147 public: | 147 public: |
| 148 SkResourceCacheDiscardableAllocator(SkResourceCache::DiscardableFactory fact
ory) { | 148 SkResourceCacheDiscardableAllocator(SkResourceCache::DiscardableFactory fact
ory) { |
| 149 SkASSERT(factory); | 149 SkASSERT(factory); |
| 150 fFactory = factory; | 150 fFactory = factory; |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool allocPixelRef(SkBitmap*, SkColorTable*) SK_OVERRIDE; | 153 bool allocPixelRef(SkBitmap*, SkColorTable*) override; |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 SkResourceCache::DiscardableFactory fFactory; | 156 SkResourceCache::DiscardableFactory fFactory; |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 bool SkResourceCacheDiscardableAllocator::allocPixelRef(SkBitmap* bitmap, SkColo
rTable* ctable) { | 159 bool SkResourceCacheDiscardableAllocator::allocPixelRef(SkBitmap* bitmap, SkColo
rTable* ctable) { |
| 160 size_t size = bitmap->getSize(); | 160 size_t size = bitmap->getSize(); |
| 161 uint64_t size64 = bitmap->computeSize64(); | 161 uint64_t size64 = bitmap->computeSize64(); |
| 162 if (0 == size || size64 > (uint64_t)size) { | 162 if (0 == size || size64 > (uint64_t)size) { |
| 163 return false; | 163 return false; |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 } | 636 } |
| 637 | 637 |
| 638 size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) { | 638 size_t SkGraphics::SetResourceCacheSingleAllocationByteLimit(size_t newLimit) { |
| 639 return SkResourceCache::SetSingleAllocationByteLimit(newLimit); | 639 return SkResourceCache::SetSingleAllocationByteLimit(newLimit); |
| 640 } | 640 } |
| 641 | 641 |
| 642 void SkGraphics::PurgeResourceCache() { | 642 void SkGraphics::PurgeResourceCache() { |
| 643 return SkResourceCache::PurgeAll(); | 643 return SkResourceCache::PurgeAll(); |
| 644 } | 644 } |
| 645 | 645 |
| OLD | NEW |