diff options
| author | Dave Parks <davep@lindenlab.com> | 2011-02-01 15:35:56 -0600 | 
|---|---|---|
| committer | Dave Parks <davep@lindenlab.com> | 2011-02-01 15:35:56 -0600 | 
| commit | 105872b94e09502220a2ec0d5e9a2f54929ba232 (patch) | |
| tree | 8c12d7fce9bcdceddf3e13be8d239ad99a4a1e95 /indra/newview | |
| parent | f0074f1002f36ad680ae04daf3f5e026dca31d54 (diff) | |
| parent | 2d04379bea7d0e5556faf4605230c9d2bd9808c5 (diff) | |
merge
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llfloatersnapshot.cpp | 37 | ||||
| -rw-r--r-- | indra/newview/llviewerdisplay.cpp | 32 | ||||
| -rw-r--r-- | indra/newview/llviewerwindow.cpp | 80 | ||||
| -rw-r--r-- | indra/newview/pipeline.cpp | 27 | 
4 files changed, 103 insertions, 73 deletions
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 0931f77281..add591895b 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -1363,6 +1363,36 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)  	floater->getChildView("auto_snapshot_check")->setVisible(		is_advance);  	floater->getChildView("image_quality_slider")->setVisible(	is_advance && show_slider); +	if (gSavedSettings.getBOOL("RenderUIInSnapshot") || gSavedSettings.getBOOL("RenderHUDInSnapshot")) +	{ //clamp snapshot resolution to window size when showing UI or HUD in snapshot + +		LLSpinCtrl* width_ctrl = floater->getChild<LLSpinCtrl>("snapshot_width"); +		LLSpinCtrl* height_ctrl = floater->getChild<LLSpinCtrl>("snapshot_height"); + +		S32 width = gViewerWindow->getWindowWidthRaw(); +		S32 height = gViewerWindow->getWindowHeightRaw(); + +		width_ctrl->setMaxValue(width); +		 +		height_ctrl->setMaxValue(height); + +		if (width_ctrl->getValue().asInteger() > width) +		{ +			width_ctrl->forceSetValue(width); +		} +		if (height_ctrl->getValue().asInteger() > height) +		{ +			height_ctrl->forceSetValue(height); +		} +	} +	else +	{  +		LLSpinCtrl* width = floater->getChild<LLSpinCtrl>("snapshot_width"); +		width->setMaxValue(6016); +		LLSpinCtrl* height = floater->getChild<LLSpinCtrl>("snapshot_height"); +		height->setMaxValue(6016); +	} +		  	LLSnapshotLivePreview* previewp = getPreviewView(floater);  	BOOL got_bytes = previewp && previewp->getDataSize() > 0;  	BOOL got_snap = previewp && previewp->getSnapshotUpToDate(); @@ -1810,6 +1840,13 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL  		previewp->getSize(width, height); +		if (gSavedSettings.getBOOL("RenderUIInSnapshot") || gSavedSettings.getBOOL("RenderHUDInSnapshot")) +		{ //clamp snapshot resolution to window size when showing UI or HUD in snapshot +			width = llmin(width, gViewerWindow->getWindowWidthRaw()); +			height = llmin(height, gViewerWindow->getWindowHeightRaw()); +		} + +		  		if(checkImageSize(previewp, width, height, TRUE, previewp->getMaxImageSize()))  		{  			resetSnapshotSizeOnUI(view, width, height) ; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index ddb11829df..41b7c13826 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -647,8 +647,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)  		LLGLState::checkTextureChannels();  		LLGLState::checkClientArrays(); -		BOOL to_texture = !for_snapshot && -						gPipeline.canUseVertexShaders() && +		BOOL to_texture = gPipeline.canUseVertexShaders() &&  						LLPipeline::sRenderGlow;  		LLAppViewer::instance()->pingMainloopTimeout("Display:Swap"); @@ -709,7 +708,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)  			glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);  		} -		if (!for_snapshot) +		//if (!for_snapshot)  		{  			LLMemType mt_gw(LLMemType::MTYPE_DISPLAY_GEN_REFLECTION);  			LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery"); @@ -1043,8 +1042,7 @@ LLRect get_whole_screen_region()  		S32 tile_height = llround((F32)gViewerWindow->getWorldViewHeightScaled() / zoom_factor);  		int tile_y = sub_region / num_horizontal_tiles;  		int tile_x = sub_region - (tile_y * num_horizontal_tiles); -		glh::matrix4f mat; -		 +			  		whole_screen.setLeftTopAndSize(tile_x * tile_width, gViewerWindow->getWorldViewHeightScaled() - (tile_y * tile_height), tile_width, tile_height);  	}  	return whole_screen; @@ -1124,10 +1122,14 @@ void render_ui(F32 zoom_factor, int subfield)  	LLMemType mt_ru(LLMemType::MTYPE_DISPLAY_RENDER_UI);  	LLGLState::checkStates(); -	glPushMatrix(); -	glLoadMatrixd(gGLLastModelView);  	glh::matrix4f saved_view = glh_get_current_modelview(); -	glh_set_current_modelview(glh_copy_matrix(gGLLastModelView)); + +	if (!gSnapshot) +	{ +		glPushMatrix(); +		glLoadMatrixd(gGLLastModelView); +		glh_set_current_modelview(glh_copy_matrix(gGLLastModelView)); +	}  	{  		BOOL to_texture = gPipeline.canUseVertexShaders() && @@ -1178,8 +1180,11 @@ void render_ui(F32 zoom_factor, int subfield)  		LLVertexBuffer::unbind();  	} -	glh_set_current_modelview(saved_view); -	glPopMatrix(); +	if (!gSnapshot) +	{ +		glh_set_current_modelview(saved_view); +		glPopMatrix(); +	}  	if (gDisplaySwapBuffers)  	{ @@ -1321,7 +1326,7 @@ void render_ui_2d()  	// render outline for HUD  	if (isAgentAvatarValid() && gAgentCamera.mHUDCurZoom < 0.98f)  	{ -		glPushMatrix(); +		gGL.pushMatrix();  		S32 half_width = (gViewerWindow->getWorldViewWidthScaled() / 2);  		S32 half_height = (gViewerWindow->getWorldViewHeightScaled() / 2);  		glScalef(LLUI::sGLScaleFactor.mV[0], LLUI::sGLScaleFactor.mV[1], 1.f); @@ -1330,7 +1335,7 @@ void render_ui_2d()  		glScalef(zoom,zoom,1.f);  		gGL.color4fv(LLColor4::white.mV);  		gl_rect_2d(-half_width, half_height, half_width, -half_height, FALSE); -		glPopMatrix(); +		gGL.popMatrix();  		stop_glerror();  	} @@ -1378,8 +1383,7 @@ void render_ui_2d()  			gGL.setColorMask(true, false);  			LLUI::sDirtyRect = t_rect; -			 -	} +		}  		LLGLDisable cull(GL_CULL_FACE);  		LLGLDisable blend(GL_BLEND); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index ca0478ee0c..274dbe2cc8 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4001,18 +4001,26 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei  		LLPipeline::sShowHUDAttachments = FALSE;  	} +	// if not showing ui, use full window to render world view +	updateWorldViewRect(!show_ui); +  	// Copy screen to a buffer  	// crop sides or top and bottom, if taking a snapshot of different aspect ratio  	// from window -	S32 snapshot_width = mWindowRectRaw.getWidth(); -	S32 snapshot_height =  mWindowRectRaw.getHeight(); +	LLRect window_rect = show_ui ? getWindowRectRaw() : getWorldViewRectRaw();  + +	S32 snapshot_width = window_rect.getWidth(); +	S32 snapshot_height = window_rect.getHeight();  	// SNAPSHOT -	S32 window_width = mWindowRectRaw.getWidth(); -	S32 window_height = mWindowRectRaw.getHeight();	 -	LLRect window_rect = mWindowRectRaw; -	BOOL use_fbo = FALSE; +	S32 window_width = snapshot_width; +	S32 window_height = snapshot_height; +	 +	if (show_ui) +	{ +		image_width = llmin(image_width, window_width); +		image_height = llmin(image_height, window_height); +	} -	LLRenderTarget target;  	F32 scale_factor = 1.0f ;  	if(!keep_window_aspect) //image cropping  	{		 @@ -4025,45 +4033,24 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei  	{  		if(image_width > window_width || image_height > window_height) //need to enlarge the scene  		{ -			if (!LLPipeline::sRenderDeferred && gGLManager.mHasFramebufferObject && !show_ui) -			{ -				GLint max_size = 0; -				glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &max_size); -		 -				if (image_width <= max_size && image_height <= max_size) //re-project the scene -				{ -					use_fbo = TRUE; -					 -					snapshot_width = image_width; -					snapshot_height = image_height; -					target.allocate(snapshot_width, snapshot_height, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, TRUE); -					window_width = snapshot_width; -					window_height = snapshot_height; -					scale_factor = 1.f; -					mWindowRectRaw.set(0, snapshot_height, snapshot_width, 0); -					target.bindTarget();			 -				} -			} - -			if(!use_fbo) //no re-projection, so tiling the scene -			{ -				F32 ratio = llmin( (F32)window_width / image_width , (F32)window_height / image_height) ; -				snapshot_width = (S32)(ratio * image_width) ; -				snapshot_height = (S32)(ratio * image_height) ; -				scale_factor = llmax(1.0f, 1.0f / ratio) ;	 -			} +			F32 ratio = llmin( (F32)window_width / image_width , (F32)window_height / image_height) ; +			snapshot_width = (S32)(ratio * image_width) ; +			snapshot_height = (S32)(ratio * image_height) ; +			scale_factor = llmax(1.0f, 1.0f / ratio) ;	  		} -		//else: keep the current scene scale, re-scale it if necessary after reading out.  	} -	// if not showing ui, use full window to render world view -	updateWorldViewRect(!show_ui); +	if (show_ui && scale_factor > 1.f) +	{ +		llwarns << "over scaling UI not supported." << llendl; +	}  	S32 buffer_x_offset = llfloor(((window_width - snapshot_width) * scale_factor) / 2.f);  	S32 buffer_y_offset = llfloor(((window_height - snapshot_height) * scale_factor) / 2.f);  	S32 image_buffer_x = llfloor(snapshot_width*scale_factor) ;  	S32 image_buffer_y = llfloor(snapshot_height *scale_factor) ; +  	if(image_buffer_x > max_size || image_buffer_y > max_size) //boundary check to avoid memory overflow  	{  		scale_factor *= llmin((F32)max_size / image_buffer_x, (F32)max_size / image_buffer_y) ; @@ -4072,7 +4059,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei  	}  	if(image_buffer_x > 0 && image_buffer_y > 0)  	{ -	raw->resize(image_buffer_x, image_buffer_y, 3); +		raw->resize(image_buffer_x, image_buffer_y, 3);  	}  	else  	{ @@ -4084,12 +4071,13 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei  	}  	BOOL high_res = scale_factor >= 2.f; // Font scaling is slow, only do so if rez is much higher -	if (high_res) +	if (high_res && show_ui)  	{ -		send_agent_pause(); +		llwarns << "High res UI snapshot not supported. " << llendl; +		/*send_agent_pause();  		//rescale fonts  		initFonts(scale_factor); -		LLHUDObject::reshapeAll(); +		LLHUDObject::reshapeAll();*/  	}  	S32 output_buffer_offset_y = 0; @@ -4185,12 +4173,6 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei  		output_buffer_offset_y += subimage_y_offset;  	} -	if (use_fbo) -	{ -		mWindowRectRaw = window_rect; -		target.flush(); -		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -	}  	gDisplaySwapBuffers = FALSE;  	gDepthDirty = TRUE; @@ -4205,11 +4187,11 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei  		LLPipeline::sShowHUDAttachments = TRUE;  	} -	if (high_res) +	/*if (high_res)  	{  		initFonts(1.f);  		LLHUDObject::reshapeAll(); -	} +	}*/  	// Pre-pad image to number of pixels such that the line length is a multiple of 4 bytes (for BMP encoding)  	// Note: this formula depends on the number of components being 3.  Not obvious, but it's correct.	 diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 59b526059b..39bc354250 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -5432,7 +5432,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)  	gGL.setColorMask(true, true);  	glClearColor(0,0,0,0); -	if (for_snapshot) +	/*if (for_snapshot)  	{  		gGL.getTexUnit(0)->bind(&mGlow[1]);  		{ @@ -5443,14 +5443,21 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)  			// If the snapshot is constructed from tiles, calculate which  			// tile we're in. -			const S32 num_horizontal_tiles = llceil(zoom_factor); -			const LLVector2 tile(subfield % num_horizontal_tiles, -								 (S32)(subfield / num_horizontal_tiles)); -			llassert(zoom_factor > 0.0); // Non-zero, non-negative. -			const F32 tile_size = 1.0/zoom_factor; -			 -			tc1 = tile*tile_size; // Top left texture coordinates -			tc2 = (tile+LLVector2(1,1))*tile_size; // Bottom right texture coordinates + +			//from LLViewerCamera::setPerpsective +			if (zoom_factor > 1.f) +			{ +				int pos_y = subfield / llceil(zoom_factor); +				int pos_x = subfield - (pos_y*llceil(zoom_factor)); +				F32 size = 1.f/zoom_factor; + +				tc1.set(pos_x*size, pos_y*size); +				tc2 = tc1 + LLVector2(size,size); +			} +			else +			{ +				tc2.set(1,1); +			}  			LLGLEnable blend(GL_BLEND);  			gGL.setSceneBlendType(LLRender::BT_ADD); @@ -5483,7 +5490,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)  		glPopMatrix();  		return; -	} +	}*/  	{  		{  | 
