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 SkMallocPixelRef_DEFINED 00018 #define SkMallocPixelRef_DEFINED 00019 00020 #include "SkPixelRef.h" 00021 00025 class SkMallocPixelRef : public SkPixelRef { 00026 public: 00030 SkMallocPixelRef(void* addr, size_t size, SkColorTable* ctable); 00031 virtual ~SkMallocPixelRef(); 00032 00034 size_t getSize() const { return fSize; } 00035 00036 // overrides from SkPixelRef 00037 virtual void flatten(SkFlattenableWriteBuffer&) const; 00038 virtual Factory getFactory() const { 00039 return Create; 00040 } 00041 static SkPixelRef* Create(SkFlattenableReadBuffer& buffer) { 00042 return SkNEW_ARGS(SkMallocPixelRef, (buffer)); 00043 } 00044 00045 protected: 00046 // overrides from SkPixelRef 00047 virtual void* onLockPixels(SkColorTable**); 00048 virtual void onUnlockPixels(); 00049 00050 SkMallocPixelRef(SkFlattenableReadBuffer& buffer); 00051 00052 private: 00053 void* fStorage; 00054 size_t fSize; 00055 SkColorTable* fCTable; 00056 00057 typedef SkPixelRef INHERITED; 00058 }; 00059 00060 #endif