コード例 #1
0
ファイル: llviewermedia.cpp プロジェクト: Kiera/Crow
/*LLViewerMediaTexture*/LLViewerTexture* LLViewerMediaImpl::updatePlaceholderImage()
{
	if(mTextureId.isNull())
	{
		// The code that created this instance will read from the plugin's bits.
		return NULL;
	}
	
	LLViewerMediaTexture* placeholder_image = (LLViewerMediaTexture*)LLViewerTextureManager::findTexture( mTextureId );
	
	if (mNeedsNewTexture 
		|| placeholder_image->getUseMipMaps()
		|| ! placeholder_image->mIsMediaTexture
		|| (placeholder_image->getWidth() != mMediaSource->getTextureWidth())
		|| (placeholder_image->getHeight() != mMediaSource->getTextureHeight())
		|| (mTextureUsedWidth != mMediaSource->getWidth())
		|| (mTextureUsedHeight != mMediaSource->getHeight())
		)
	{
		llinfos << "initializing media placeholder" << llendl;
		llinfos << "movie image id " << mTextureId << llendl;

		int texture_width = mMediaSource->getTextureWidth();
		int texture_height = mMediaSource->getTextureHeight();
		int texture_depth = mMediaSource->getTextureDepth();
		
		// MEDIAOPT: check to see if size actually changed before doing work
		placeholder_image->destroyGLTexture();
		// MEDIAOPT: apparently just calling setUseMipMaps(FALSE) doesn't work?
		placeholder_image->reinit(FALSE);	// probably not needed

		// MEDIAOPT: seems insane that we actually have to make an imageraw then
		// immediately discard it
		LLPointer<LLImageRaw> raw = new LLImageRaw(texture_width, texture_height, texture_depth);
		raw->clear(0x0f, 0x0f, 0x0f, 0xff);
		int discard_level = 0;

		// ask media source for correct GL image format constants
		placeholder_image->setExplicitFormat(mMediaSource->getTextureFormatInternal(),
											 mMediaSource->getTextureFormatPrimary(),
											 mMediaSource->getTextureFormatType(),
											 mMediaSource->getTextureFormatSwapBytes());

		placeholder_image->createGLTexture(discard_level, raw);

		// placeholder_image->setExplicitFormat()
		placeholder_image->setUseMipMaps(FALSE);

		// MEDIAOPT: set this dynamically on play/stop
		placeholder_image->mIsMediaTexture = true;
		mNeedsNewTexture = false;
				
		// If the amount of the texture being drawn by the media goes down in either width or height, 
		// recreate the texture to avoid leaving parts of the old image behind.
		mTextureUsedWidth = mMediaSource->getWidth();
		mTextureUsedHeight = mMediaSource->getHeight();
	}
	
	return placeholder_image;
}
コード例 #2
0
// Note: the caller SHOULD NOT keep the pointer that this function returns.  It may be updated as more data arrives.
LLImageGL* LLBumpImageList::getBrightnessDarknessImage(LLViewerImage* src_image, U8 bump_code )
{
	llassert( (bump_code == BE_BRIGHTNESS) || (bump_code == BE_DARKNESS) );

	LLImageGL* bump = NULL;
	const F32 BRIGHTNESS_DARKNESS_PIXEL_AREA_THRESHOLD = 1000;
	if( src_image->mMaxVirtualSize > BRIGHTNESS_DARKNESS_PIXEL_AREA_THRESHOLD )
	{
		bump_image_map_t* entries_list = NULL;
		void (*callback_func)( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) = NULL;

		switch( bump_code )
		{
		case BE_BRIGHTNESS:
			entries_list = &mBrightnessEntries;
			callback_func = LLBumpImageList::onSourceBrightnessLoaded;
			break;
		case BE_DARKNESS:
			entries_list = &mDarknessEntries;
			callback_func = LLBumpImageList::onSourceDarknessLoaded;
			break;
		default:
			llassert(0);
			return NULL;
		}

		bump_image_map_t::iterator iter = entries_list->find(src_image->getID());
		if (iter != entries_list->end())
		{
			bump = iter->second;
		}
		else
		{
			LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,1);
			raw->clear(0x77, 0x77, 0x77, 0xFF);

			//------------------------------
			bump = new LLImageGL( raw, TRUE);
			//immediately assign bump to a global smart pointer in case some local smart pointer
			//accidently releases it.
			(*entries_list)[src_image->getID()] = bump;
			//------------------------------

			bump->setExplicitFormat(GL_ALPHA8, GL_ALPHA);			

			// Note: this may create an LLImageGL immediately
			src_image->setLoadedCallback( callback_func, 0, TRUE, FALSE, new LLUUID(src_image->getID()) );
			bump = (*entries_list)[src_image->getID()]; // In case callback was called immediately and replaced the image

//			bump_total++;
//			llinfos << "*** Creating " << (void*)bump << " " << bump_total << llendl;
		}
	}
コード例 #3
0
ファイル: lldrawpoolbump.cpp プロジェクト: Belxjander/Kirito
// Note: the caller SHOULD NOT keep the pointer that this function returns.  It may be updated as more data arrives.
LLViewerTexture* LLBumpImageList::getBrightnessDarknessImage(LLViewerFetchedTexture* src_image, U8 bump_code )
{
	llassert( (bump_code == BE_BRIGHTNESS) || (bump_code == BE_DARKNESS) );

	LLViewerTexture* bump = NULL;
	
	bump_image_map_t* entries_list = NULL;
	void (*callback_func)( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata ) = NULL;

	switch( bump_code )
	{
	case BE_BRIGHTNESS:
		entries_list = &mBrightnessEntries;
		callback_func = LLBumpImageList::onSourceBrightnessLoaded;
		break;
	case BE_DARKNESS:
		entries_list = &mDarknessEntries;
		callback_func = LLBumpImageList::onSourceDarknessLoaded;
		break;
	default:
		llassert(0);
		return NULL;
	}

	bump_image_map_t::iterator iter = entries_list->find(src_image->getID());
	if (iter != entries_list->end() && iter->second.notNull())
	{
		bump = iter->second;
	}
	else
	{
		LLPointer<LLImageRaw> raw = new LLImageRaw(1,1,1);
		raw->clear(0x77, 0x77, 0xFF, 0xFF);

		(*entries_list)[src_image->getID()] = LLViewerTextureManager::getLocalTexture( raw.get(), TRUE);
		bump = (*entries_list)[src_image->getID()]; // In case callback was called immediately and replaced the image
	}

	if (!src_image->hasCallbacks())
	{ //if image has no callbacks but resolutions don't match, trigger raw image loaded callback again
		if (src_image->getWidth() != bump->getWidth() ||
			src_image->getHeight() != bump->getHeight())// ||
			//(LLPipeline::sRenderDeferred && bump->getComponents() != 4))
		{
			src_image->setBoostLevel(LLGLTexture::BOOST_BUMP) ;
			src_image->setLoadedCallback( callback_func, 0, TRUE, FALSE, new LLUUID(src_image->getID()), NULL );
			src_image->forceToSaveRawImage(0) ;
		}
	}

	return bump;
}
コード例 #4
0
ファイル: llviewermedia.cpp プロジェクト: Xara/Meerkat-Viewer
void LLViewerMediaImpl::initializePlaceholderImage(LLViewerImage *placeholder_image, LLMediaBase *media_source)
{
	int media_width = media_source->getMediaWidth();
	int media_height = media_source->getMediaHeight();
	//int media_rowspan = media_source->getMediaRowSpan();

	// if width & height are invalid, don't bother doing anything
	if ( media_width < 1 || media_height < 1 )
		return;

	llinfos << "initializing media placeholder" << llendl;
	llinfos << "movie image id " << mMovieImageID << llendl;

	int texture_width = LLMediaManager::textureWidthFromMediaWidth( media_width );
	int texture_height = LLMediaManager::textureHeightFromMediaHeight( media_height );
	int texture_depth = media_source->getMediaDepth();

	// MEDIAOPT: check to see if size actually changed before doing work
	placeholder_image->destroyGLTexture();
	// MEDIAOPT: apparently just calling setUseMipMaps(FALSE) doesn't work?
	placeholder_image->reinit(FALSE);	// probably not needed

	// MEDIAOPT: seems insane that we actually have to make an imageraw then
	// immediately discard it
	LLPointer<LLImageRaw> raw = new LLImageRaw(texture_width, texture_height, texture_depth);
	raw->clear(0x0f, 0x0f, 0x0f, 0xff);
	int discard_level = 0;

	// ask media source for correct GL image format constants
	placeholder_image->setExplicitFormat(media_source->getTextureFormatInternal(),
										 media_source->getTextureFormatPrimary(),
										 media_source->getTextureFormatType());

	placeholder_image->createGLTexture(discard_level, raw);

	// placeholder_image->setExplicitFormat()
	placeholder_image->setUseMipMaps(FALSE);

	// MEDIAOPT: set this dynamically on play/stop
	placeholder_image->mIsMediaTexture = true;
}