00001 /* 00002 * Copyright (C) 2008 The Android Open Source Project 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef SkImageRef_GlobalPool_DEFINED 00018 #define SkImageRef_GlobalPool_DEFINED 00019 00020 #include "SkImageRef.h" 00021 00022 class SkImageRef_GlobalPool : public SkImageRef { 00023 public: 00024 // if pool is null, use the global pool 00025 SkImageRef_GlobalPool(SkStream*, SkBitmap::Config, int sampleSize = 1); 00026 virtual ~SkImageRef_GlobalPool(); 00027 00028 // overrides 00029 virtual Factory getFactory() const { 00030 return Create; 00031 } 00032 static SkPixelRef* Create(SkFlattenableReadBuffer&); 00033 00034 // API to control the global pool 00035 00038 static size_t GetRAMBudget(); 00039 00042 static void SetRAMBudget(size_t); 00043 00046 static size_t GetRAMUsed(); 00047 00055 static void SetRAMUsed(size_t usageInBytes); 00056 00057 static void DumpPool(); 00058 00059 protected: 00060 virtual bool onDecode(SkImageDecoder* codec, SkStream* stream, 00061 SkBitmap* bitmap, SkBitmap::Config config, 00062 SkImageDecoder::Mode mode); 00063 00064 virtual void onUnlockPixels(); 00065 00066 SkImageRef_GlobalPool(SkFlattenableReadBuffer&); 00067 00068 private: 00069 typedef SkImageRef INHERITED; 00070 }; 00071 00072 #endif