michael@0: michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: #ifndef SkImageRef_ashmem_DEFINED michael@0: #define SkImageRef_ashmem_DEFINED michael@0: michael@0: #include "SkImageRef.h" michael@0: michael@0: struct SkAshmemRec { michael@0: int fFD; michael@0: void* fAddr; michael@0: size_t fSize; michael@0: bool fPinned; michael@0: }; michael@0: michael@0: class SkImageRef_ashmem : public SkImageRef { michael@0: public: michael@0: SkImageRef_ashmem(const SkImageInfo&, SkStreamRewindable*, int sampleSize = 1); michael@0: virtual ~SkImageRef_ashmem(); michael@0: michael@0: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageRef_ashmem) michael@0: michael@0: protected: michael@0: SkImageRef_ashmem(SkReadBuffer&); michael@0: virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; michael@0: michael@0: virtual bool onDecode(SkImageDecoder* codec, SkStreamRewindable* stream, michael@0: SkBitmap* bitmap, SkBitmap::Config config, michael@0: SkImageDecoder::Mode mode); michael@0: michael@0: virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE; michael@0: virtual void onUnlockPixels() SK_OVERRIDE; michael@0: michael@0: private: michael@0: void closeFD(); michael@0: michael@0: SkColorTable* fCT; michael@0: SkAshmemRec fRec; michael@0: michael@0: typedef SkImageRef INHERITED; michael@0: }; michael@0: michael@0: #endif