Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2008 The Android Open Source Project |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #ifndef SkImageRef_GlobalPool_DEFINED |
michael@0 | 11 | #define SkImageRef_GlobalPool_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkImageRef.h" |
michael@0 | 14 | |
michael@0 | 15 | class SkImageRef_GlobalPool : public SkImageRef { |
michael@0 | 16 | public: |
michael@0 | 17 | // if pool is null, use the global pool |
michael@0 | 18 | SkImageRef_GlobalPool(const SkImageInfo&, SkStreamRewindable*, |
michael@0 | 19 | int sampleSize = 1); |
michael@0 | 20 | virtual ~SkImageRef_GlobalPool(); |
michael@0 | 21 | |
michael@0 | 22 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageRef_GlobalPool) |
michael@0 | 23 | |
michael@0 | 24 | // API to control the global pool |
michael@0 | 25 | |
michael@0 | 26 | /** Return the amount specified as the budget for the cache (in bytes). |
michael@0 | 27 | */ |
michael@0 | 28 | static size_t GetRAMBudget(); |
michael@0 | 29 | |
michael@0 | 30 | /** Set a new budget value for the cache. |
michael@0 | 31 | */ |
michael@0 | 32 | static void SetRAMBudget(size_t); |
michael@0 | 33 | |
michael@0 | 34 | /** Return how much ram is currently in use by the global cache. |
michael@0 | 35 | */ |
michael@0 | 36 | static size_t GetRAMUsed(); |
michael@0 | 37 | |
michael@0 | 38 | /** Free up (approximately) enough such that the amount used by the cache |
michael@0 | 39 | is <= the specified amount. Since some images may be "in use", the |
michael@0 | 40 | amount actually freed may not always result in a ram usage value <= |
michael@0 | 41 | to the requested amount. In addition, because of the |
michael@0 | 42 | chunky nature of the cache, the resulting usage may be < the requested |
michael@0 | 43 | amount. |
michael@0 | 44 | */ |
michael@0 | 45 | static void SetRAMUsed(size_t usageInBytes); |
michael@0 | 46 | |
michael@0 | 47 | static void DumpPool(); |
michael@0 | 48 | |
michael@0 | 49 | protected: |
michael@0 | 50 | virtual bool onDecode(SkImageDecoder* codec, SkStreamRewindable* stream, |
michael@0 | 51 | SkBitmap* bitmap, SkBitmap::Config config, |
michael@0 | 52 | SkImageDecoder::Mode mode); |
michael@0 | 53 | |
michael@0 | 54 | virtual void onUnlockPixels(); |
michael@0 | 55 | |
michael@0 | 56 | SkImageRef_GlobalPool(SkReadBuffer&); |
michael@0 | 57 | |
michael@0 | 58 | private: |
michael@0 | 59 | typedef SkImageRef INHERITED; |
michael@0 | 60 | }; |
michael@0 | 61 | |
michael@0 | 62 | #endif |