Home | History | Annotate | Download | only in merrifield_plus
      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 #include <common/utils/HwcTrace.h>
     17 #include <platforms/merrifield_plus/PlatfBufferManager.h>
     18 #include <ips/tangier/TngGrallocBuffer.h>
     19 #include <ips/tangier/TngGrallocBufferMapper.h>
     20 #include <sync/sync.h>
     21 
     22 namespace android {
     23 namespace intel {
     24 
     25 PlatfBufferManager::PlatfBufferManager()
     26     : BufferManager()
     27 {
     28 
     29 }
     30 
     31 PlatfBufferManager::~PlatfBufferManager()
     32 {
     33 
     34 }
     35 
     36 bool PlatfBufferManager::initialize()
     37 {
     38     return BufferManager::initialize();
     39 }
     40 
     41 void PlatfBufferManager::deinitialize()
     42 {
     43     BufferManager::deinitialize();
     44 }
     45 
     46 DataBuffer* PlatfBufferManager::createDataBuffer(uint32_t handle)
     47 {
     48     return new TngGrallocBuffer(handle);
     49 }
     50 
     51 BufferMapper* PlatfBufferManager::createBufferMapper(DataBuffer& buffer)
     52 {
     53     return new TngGrallocBufferMapper(*mGralloc, buffer);
     54 }
     55 
     56 bool PlatfBufferManager::blitGrallocBuffer(uint32_t srcHandle, uint32_t dstHandle,
     57                                   crop_t& srcCrop, uint32_t async)
     58 
     59 {
     60     int fenceFd;
     61 
     62     if (gralloc_blit_handle_to_handle_img(mGralloc,
     63                                 (buffer_handle_t)srcHandle,
     64                                 (buffer_handle_t)dstHandle,
     65                                 srcCrop.w, srcCrop.h, srcCrop.x,
     66                                 srcCrop.y, 0, -1, &fenceFd)) {
     67         ELOGTRACE("Blit failed");
     68         return false;
     69     }
     70 
     71     if (!async) {
     72         sync_wait(fenceFd, -1);
     73     }
     74     close(fenceFd);
     75     return true;
     76 }
     77 
     78 
     79 } // namespace intel
     80 } // namespace android
     81