• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2011 Google Inc.
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 #ifndef SkImageRef_ashmem_DEFINED
9 #define SkImageRef_ashmem_DEFINED
10 
11 #include "SkImageRef.h"
12 
13 struct SkAshmemRec {
14     int     fFD;
15     void*   fAddr;
16     size_t  fSize;
17     bool    fPinned;
18 };
19 
20 class SkImageRef_ashmem : public SkImageRef {
21 public:
22     SkImageRef_ashmem(SkStream*, SkBitmap::Config, int sampleSize = 1);
23     virtual ~SkImageRef_ashmem();
24 
25     // overrides
26     virtual void flatten(SkFlattenableWriteBuffer&) const;
getFactory()27     virtual Factory getFactory() const {
28         return Create;
29     }
30     static SkPixelRef* Create(SkFlattenableReadBuffer&);
31 
32     SK_DECLARE_PIXEL_REF_REGISTRAR()
33 protected:
34     virtual bool onDecode(SkImageDecoder* codec, SkStream* stream,
35                           SkBitmap* bitmap, SkBitmap::Config config,
36                           SkImageDecoder::Mode mode);
37 
38     virtual void* onLockPixels(SkColorTable**);
39     virtual void onUnlockPixels();
40 
41 private:
42     SkImageRef_ashmem(SkFlattenableReadBuffer&);
43     void closeFD();
44 
45     SkColorTable* fCT;
46     SkAshmemRec fRec;
47 
48     typedef SkImageRef INHERITED;
49 };
50 
51 #endif
52