当前位置: 首页>>代码示例>>C++>>正文


C++ MemoryBase::getMemory方法代码示例

本文整理汇总了C++中MemoryBase::getMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBase::getMemory方法的具体用法?C++ MemoryBase::getMemory怎么用?C++ MemoryBase::getMemory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MemoryBase的用法示例。


在下文中一共展示了MemoryBase::getMemory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Open


//.........这里部分代码省略.........
		{
			case MAKEFOURCC('Y','V','1','2'):
#ifndef RENESAS_ANDROID
	#if ANDROID_VER==23
				m_dpFormat =HAL_PIXEL_FORMAT_YV12;
	#else
				m_dpFormat =HAL_PIXEL_FORMAT_YCbCr_420_P;
	#endif
#else
 				m_dpFormat = OVERLAY_FORMAT_YCbCr_420_P;
 #endif
				m_bytesPerPixel = 1.5f;
				break;

			case MAKEFOURCC('N','V','1','2'):
#ifndef RENESAS_ANDROID
				m_dpFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP;
#else
				m_dpFormat = OVERLAY_FORMAT_YCbCr_420_SP;
#endif
				m_bytesPerPixel = 1.5f;
				break;

			default:
				break;
		}
		if(m_dpFormat != 0)
			break;
	}
	DP("Open :%x ,w,h:%d,%d\n", m_dwFourCC, m_dwWidth, m_dwHeight);
	if(m_dpFormat  == 0)
	{
		DP("[CGfxAndroidISurfOverlay::Open] m_dpFormat == 0 \n");
		return E_FAIL;
	}

/* 
    m_heap =   new MemoryHeapBase(m_dwWidth*m_dwHeight*m_bytesPerPixel* ISURFACEOVL_BACKBUFF_NUM);
    if(!m_heap)
    {
      LOGE("ERROR !!! null heap \n");
    }
*/

#if defined(RENESAS_ANDROID)
	int ret;
	unsigned long phys_start;
	unsigned long phys_size = 6*1024*1024;
	int test_count;
	m_renesas_fd = open("/dev/siz", O_RDWR | O_NONBLOCK | O_NOCTTY);
	if(m_renesas_fd < 0)
	     return E_FAIL;

	DP("========= mmap dynamic ========== \n");
	ioctl(m_renesas_fd, EMXX_CIDANA_PHYSTART, &m_renesas_phymemory_addr);
	ioctl(m_renesas_fd, EMXX_CIDANA_PHYSIZE, &m_renesas_memory_size);
	m_renesas_memory_addr = (unsigned char *)mmap(0, m_renesas_memory_size, 
	    PROT_READ | PROT_WRITE, MAP_SHARED,     m_renesas_fd, m_renesas_phymemory_addr);
	DP("mmap virtual addr: %p, phys_start:%p, phys_size=%x \n", m_renesas_memory_addr, 
    	m_renesas_phymemory_addr, m_renesas_memory_size);
#endif

    for(int i=0;i<ISURFACEOVL_BACKBUFF_NUM;i++)
    {
#ifdef INFOMAX
        m_heap = new MemoryHeapBase("/dev/pmem_adsp", m_dwWidth*m_dwHeight*m_bytesPerPixel);
    if(m_heap->heapID() >= 0) {
        m_PBuffer = new MemoryBase(m_heap, 0, m_dwWidth*m_dwHeight*m_bytesPerPixel);
      m_pBuff[i] = (unsigned char*)(m_PBuffer->getMemory(NULL, NULL)->base());
      DP("malloc m_pBuff[%d]:%p \n",i,m_pBuff[i]);
    }
    else
    {
      DP("failed to new pmem_adsp");
      return E_FAIL;
    }
#elif defined(RENESAS_ANDROID)
        if(i* m_dwWidth*m_dwHeight*m_bytesPerPixel > m_renesas_memory_size)
        {
            DP("physical memory isn't enough i:%d eachBuf:%d \n",i,m_dwWidth*m_dwHeight*m_bytesPerPixel);
            return E_FAIL;
        }
    	m_pBuff[i] = m_renesas_memory_addr + (LONG)(i* m_dwWidth*m_dwHeight*m_bytesPerPixel);
#else
        m_pBuff[i] = (unsigned char*)malloc(m_dwWidth*m_dwHeight*m_bytesPerPixel);
#endif      
        LOGE("m_pBuff[%d] :%p",i,m_pBuff[i]);
        memset(m_pBuff[i],0, i*m_dwWidth*m_dwHeight*m_bytesPerPixel);
      if(!m_pBuff[i])  
      {
        	DP("[<<<<<<<<<<<<<<CGfxAndroidISurfOverlay]malloc bufer %d failed \n",i);
          return E_FAIL;
      }
    }
	
	DP("[<<<<<<<<<<<<<<CGfxAndroidISurfOverlay]Open w:%d h:%d \n",m_dwWidth, m_dwHeight);

	m_bOpen = TRUE;
	return S_OK;
}
开发者ID:xuweiqiang,项目名称:LibVRPresent,代码行数:101,代码来源:GfxAndroid_ISurfaceOverlay.cpp


注:本文中的MemoryBase::getMemory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。