gfx/skia/trunk/include/images/SkImageRef_GlobalPool.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/images/SkImageRef_GlobalPool.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2008 The Android Open Source Project
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#ifndef SkImageRef_GlobalPool_DEFINED
    1.14 +#define SkImageRef_GlobalPool_DEFINED
    1.15 +
    1.16 +#include "SkImageRef.h"
    1.17 +
    1.18 +class SkImageRef_GlobalPool : public SkImageRef {
    1.19 +public:
    1.20 +    // if pool is null, use the global pool
    1.21 +    SkImageRef_GlobalPool(const SkImageInfo&, SkStreamRewindable*,
    1.22 +                          int sampleSize = 1);
    1.23 +    virtual ~SkImageRef_GlobalPool();
    1.24 +
    1.25 +    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageRef_GlobalPool)
    1.26 +
    1.27 +    // API to control the global pool
    1.28 +
    1.29 +    /** Return the amount specified as the budget for the cache (in bytes).
    1.30 +     */
    1.31 +    static size_t GetRAMBudget();
    1.32 +
    1.33 +    /** Set a new budget value for the cache.
    1.34 +     */
    1.35 +    static void SetRAMBudget(size_t);
    1.36 +
    1.37 +    /** Return how much ram is currently in use by the global cache.
    1.38 +     */
    1.39 +    static size_t GetRAMUsed();
    1.40 +
    1.41 +    /** Free up (approximately) enough such that the amount used by the cache
    1.42 +     is <= the specified amount. Since some images may be "in use", the
    1.43 +     amount actually freed may not always result in a ram usage value <=
    1.44 +     to the requested amount. In addition, because of the
    1.45 +     chunky nature of the cache, the resulting usage may be < the requested
    1.46 +     amount.
    1.47 +     */
    1.48 +    static void SetRAMUsed(size_t usageInBytes);
    1.49 +
    1.50 +    static void DumpPool();
    1.51 +
    1.52 +protected:
    1.53 +    virtual bool onDecode(SkImageDecoder* codec, SkStreamRewindable* stream,
    1.54 +                          SkBitmap* bitmap, SkBitmap::Config config,
    1.55 +                          SkImageDecoder::Mode mode);
    1.56 +
    1.57 +    virtual void onUnlockPixels();
    1.58 +
    1.59 +    SkImageRef_GlobalPool(SkReadBuffer&);
    1.60 +
    1.61 +private:
    1.62 +    typedef SkImageRef INHERITED;
    1.63 +};
    1.64 +
    1.65 +#endif

mercurial