Home | History | Annotate | Download | only in include
      1 /*
      2 // Copyright(c)2014 IntelCorporation
      3 //
      4 // LicensedundertheApacheLicense,Version2.0(the"License");
      5 // youmaynotusethisfileexceptincompliancewiththeLicense.
      6 // YoumayobtainacopyoftheLicenseat
      7 //
      8 // http://www.apache.org/licenses/LICENSE-2.0
      9 //
     10 // Unlessrequiredbyapplicablelaworagreedtoinwriting,software
     11 // distributedundertheLicenseisdistributedonan"ASIS"BASIS,
     12 // WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
     13 // SeetheLicenseforthespecificlanguagegoverningpermissionsand
     14 // limitationsundertheLicense.
     15 */
     16 #ifndef BUFFERMAPPER_H__
     17 #define BUFFERMAPPER_H__
     18 
     19 #include <DataBuffer.h>
     20 
     21 namespace android {
     22 namespace intel {
     23 
     24 class BufferMapper : public DataBuffer {
     25 public:
     26     BufferMapper(DataBuffer& buffer)
     27         : DataBuffer(buffer),
     28           mRefCount(0)
     29     {
     30     }
     31     virtual ~BufferMapper() {}
     32 public:
     33     int incRef()
     34     {
     35         mRefCount++;
     36         return mRefCount;
     37     }
     38     int decRef()
     39     {
     40         mRefCount--;
     41         return mRefCount;
     42     }
     43 
     44     int getRef() const
     45     {
     46         return mRefCount;
     47     }
     48 
     49     // map the given buffer into both DC & CPU MMU
     50     virtual bool map() = 0;
     51     // unmap the give buffer from both DC & CPU MMU
     52     virtual bool unmap() = 0;
     53 
     54     // return gtt page offset
     55     virtual uint32_t getGttOffsetInPage(int subIndex) const = 0;
     56     virtual void* getCpuAddress(int subIndex) const = 0;
     57     virtual uint32_t getSize(int subIndex) const = 0;
     58     virtual uint32_t getKHandle(int subIndex) = 0;
     59     virtual uint32_t getFbHandle(int subIndex) = 0;
     60     virtual void putFbHandle() = 0;
     61 private:
     62     int mRefCount;
     63 };
     64 
     65 } // namespace intel
     66 } // namespace android
     67 
     68 #endif /* BUFFERMAPPER_H__ */
     69