Ejemplo n.º 1
0
	void Framebuffer2D::AttachDepth(Texture2D* texture)
	{
		FL_ASSERT(m_Width == texture->GetWidth() && m_Height == texture->GetHeight());
		FL_ASSERT(texture->GetFormat() == TextureFormat::Depth);

		m_DepthAttachment = texture;

		Bind();
		GLCall(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texture->GetRendererID(), 0));
		Unbind();
	}
	String FileSystem::ReadTextFile(const String& path)
	{
		FILE* file = fopen(path.c_str(), "rb");
		FL_ASSERT(file);

		fseek(file, 0, SEEK_END);
		int length = ftell(file);
		FL_ASSERT(length < 100 * 1024 * 1024);
		String result(length, 0);
		fseek(file, 0, SEEK_SET);
		fread(&result[0], 1, length, file);
		fclose(file);

		// Strip carriage returns
		result.erase(std::remove(result.begin(), result.end(), '\r'), result.end());
		return result;
	}
	byte* FileSystem::ReadFile(const String& path, size_t* outSize)
	{
		FILE* file = fopen(path.c_str(), "rb");
		FL_ASSERT(file);
		// FL_ASSERT(file, "Could not open file '", filepath, "'!");

		fseek(file, 0, SEEK_END);
		size_t length = ftell(file);
		fseek(file, 0, SEEK_SET);
		FL_ASSERT(length < 100 * 1024 * 1024);
		if (outSize)
			*outSize = length;
		byte* result = new byte[length];
#ifdef FL_DEBUG
		memset(result, 0xCA, length);
#endif
		fread(result, 1, length, file);
		fclose(file);
		return result;
	}
Ejemplo n.º 4
0
	void Framebuffer2D::AttachColor(Texture2D* texture, uint index)
	{
		FL_ASSERT(m_Width == texture->GetWidth() && m_Height == texture->GetHeight());

		if (m_ColorAttachments.size() <= index)
			m_ColorAttachments.resize(index + 1);

		m_ColorAttachments[index] = texture;

		Bind();
		GLCall(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + index, GL_TEXTURE_2D, texture->GetRendererID(), 0));
		Unbind();
	}
Ejemplo n.º 5
0
void CMusicPlayerImgEngine::GetAlbumArtL(const CMetadata &aMetadata, CTheme &aTheme)
{
	if(aTheme.iAlbumArtSize.iHeight==0 || aMetadata.iFileDirEntry==NULL)return;
	//get the path & size out of the song
	LOG(ELogGeneral,1,"GetAlbumArtL++ (iFileDirEntry: %x)",aMetadata.iFileDirEntry);

	TFileName cover;
	CImageDecoder *dec;
	TInt err=GetAlbumArtFilename(aMetadata,aTheme.iAlbumArtSize,cover,&dec);
	if(err<0) {
		//no album art found, use generic based on the current theme color
		//first, compute the offset, based on size;
		const TInt KNrColors=5;
		TInt i,offset=0;
		if(aTheme.iAlbumArtSize==iGenericSize0)offset=0;
		else if(aTheme.iAlbumArtSize==iGenericSize1)offset=KNrColors;
		else {
			//we need to set the size and offset
			if(iGenericSize0.iHeight==0){
				iGenericSize0=aTheme.iAlbumArtSize;
				//offset=0; -> not needed, set above
				for(i=0;i<KNrColors;i++)
					iGenericImages.AppendL(NULL);			
			} 
			else if(iGenericSize1.iHeight==0){
				iGenericSize1=aTheme.iAlbumArtSize;
				offset=KNrColors;
				FL_ASSERT(iGenericImages.Count()==KNrColors);
				for(i=0;i<KNrColors;i++)
					iGenericImages.AppendL(NULL);
			}
			else FL_ASSERT_TXT(0,"Both sizes full, something is wrong.");
		}
		
		switch(iPreferences->iMusicPlayerThemeData&0xFFF0)
		{
		case CColoredTheme::EColorGreen:
			if(!iGenericImages[offset]){
				//we need to load the green image/icon
				iGenericImages[offset]=AknIconUtils::CreateIconL(KOwnIconFile,EMbmMlauncherMlauncheraif);
				AknIconUtils::SetSize(iGenericImages[offset],aTheme.iAlbumArtSize,EAspectRatioNotPreserved );
			}
			aTheme.iAlbumArt=iGenericImages[offset];
			aTheme.iAlbumArtDominantColor=0x00FF00;//green
			break;
		case CColoredTheme::EColorBlue:
			if(!iGenericImages[offset+1]){
				//we need to load the blue image/icon
				iGenericImages[offset+1]=AknIconUtils::CreateIconL(KOwnIconFile,EMbmMlauncherMlauncheraifblue);
				AknIconUtils::SetSize(iGenericImages[offset+1],aTheme.iAlbumArtSize,EAspectRatioNotPreserved );
			}
			aTheme.iAlbumArt=iGenericImages[offset+1];
			aTheme.iAlbumArtDominantColor=0x0080FF;//blue
			break;
		case CColoredTheme::EColorOrange:
			if(!iGenericImages[offset+2]){
				//we need to load the orange image/icon
				iGenericImages[offset+2]=AknIconUtils::CreateIconL(KOwnIconFile,EMbmMlauncherMlauncheraiforange);
				AknIconUtils::SetSize(iGenericImages[offset+2],aTheme.iAlbumArtSize,EAspectRatioNotPreserved );
			}
			aTheme.iAlbumArt=iGenericImages[offset+2];
			aTheme.iAlbumArtDominantColor=0xFBB416;//orange
			break;
		case CColoredTheme::EColorRed:
			if(!iGenericImages[offset+3]){
				//we need to load the red image/icon
				iGenericImages[offset+3]=AknIconUtils::CreateIconL(KOwnIconFile,EMbmMlauncherMlauncheraifred);
				AknIconUtils::SetSize(iGenericImages[offset+3],aTheme.iAlbumArtSize,EAspectRatioNotPreserved );
			}
			aTheme.iAlbumArt=iGenericImages[offset+3];
			aTheme.iAlbumArtDominantColor=0xFF0000;//red
			break;
		case CColoredTheme::EColorViolet:
			if(!iGenericImages[offset+4]){
				//we need to load the violet image/icon
				iGenericImages[offset+4]=AknIconUtils::CreateIconL(KOwnIconFile,EMbmMlauncherMlauncheraifviolet);
				AknIconUtils::SetSize(iGenericImages[offset+4],aTheme.iAlbumArtSize,EAspectRatioNotPreserved );
			}
			aTheme.iAlbumArt=iGenericImages[offset+4];
			aTheme.iAlbumArtDominantColor=0xF107E7;//violet
			break;
		}//switch
		LOG(ELogGeneral,-1,"GetAlbumArtL-- (generic album art used)");
		return;
	}
	if(err>0)
	{
		LOG(ELogGeneral,-1,"GetAlbumArtL-- (album art found in cache)");
		aTheme.iAlbumArt=iImages[0];
		aTheme.iAlbumArtDominantColor=iDominantColors[0];
		return;
	}

	LOG0("GetAlbumArtL: checking if we are already loading this request");

	//check if this request is already processing, or we need to enqueue it
	if(iState!=EIdle)
	{
		CheckAgainstCurrentAndEnqueued(ETrue,cover,dec,aTheme.iAlbumArtSize,&aTheme);
		LOG(ELogGeneral,-1,"GetAlbumArtL-- (either already processing or enqueued)");
		return;
	}

	//if we are here, we need to create the bitmap and transfer it
	LOG0("GetAlbumArtL: CACHE MISS, we have to load the album art from file");
	aTheme.iAlbumArt=NULL;
	err=DoProcessingL(cover,dec,aTheme.iAlbumArtSize,&aTheme);
	LOG(ELogGeneral,-1,"GetAlbumArtL-- (request processing)");
}