summaryrefslogtreecommitdiff
path: root/indra/newview/llmediactrl.cpp
diff options
context:
space:
mode:
authorMonroe Linden <monroe@lindenlab.com>2010-01-11 17:54:05 -0800
committerMonroe Linden <monroe@lindenlab.com>2010-01-11 17:54:05 -0800
commit3b2697cb93e6b8a1f1281aeab0e960bc6704d8c4 (patch)
tree2088640dba30fc418976db037dc4d44b3b6bcf3d /indra/newview/llmediactrl.cpp
parent05cbb2b46b4afe24cd2c17967da2694ffa85fb69 (diff)
Fix for black/grey look at login screen and backspace going back in search/help windows. This should address EXT-4097.
Added a notion of "background color" to LLViewerMediaImpl and LLPluginClassMedia. Added background color parameters to the size_change message. Webkit plugin now sets the background color of the instance from the supplied background color, and navigates to a data: url with that background color instead of about:blank as its initial navigate. Webkit plugin now no longer waits for the first onPageChanged event LLViewerMediaImpl now clears the texture to the background color when initializing it. Made LLMediaCtrl fill with its opaque background color when the media impl isn't set up yet. Removed the initial data URL from the search and help floaters, since what it was doing is now handled internally by the new background color code. Reviewed by callum and rick.
Diffstat (limited to 'indra/newview/llmediactrl.cpp')
-rw-r--r--indra/newview/llmediactrl.cpp227
1 files changed, 121 insertions, 106 deletions
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index 93f926b5d0..6b0f9b709d 100644
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -632,6 +632,7 @@ bool LLMediaCtrl::ensureMediaSourceExists()
mMediaSource->setHomeURL(mHomePageUrl);
mMediaSource->setVisible( getVisible() );
mMediaSource->addObserver( this );
+ mMediaSource->setBackgroundColor( getBackgroundColor() );
if(mClearCache)
{
mMediaSource->clearCache();
@@ -671,34 +672,12 @@ LLPluginClassMedia* LLMediaCtrl::getMediaPlugin()
//
void LLMediaCtrl::draw()
{
- LLPluginClassMedia* media_plugin = NULL;
-
- if(mMediaSource && mMediaSource->hasMedia())
- {
- media_plugin = mMediaSource->getMediaPlugin();
- }
- else
- {
- return;
- }
-
- if(!media_plugin || (!media_plugin->textureValid()))
- {
- // Don't try to draw without a valid texture
- return;
- }
-
- LLViewerMediaTexture* media_texture = LLViewerTextureManager::findMediaTexture(mMediaTextureID);
-
- if (!media_texture )
- return;
-
if ( gRestoreGL == 1 )
{
LLRect r = getRect();
reshape( r.getWidth(), r.getHeight(), FALSE );
return;
- };
+ }
// NOTE: optimization needed here - probably only need to do this once
// unless tearoffs change the parent which they probably do.
@@ -712,125 +691,161 @@ void LLMediaCtrl::draw()
setFrequentUpdates( false );
};
+ bool draw_media = false;
+
+ LLPluginClassMedia* media_plugin = NULL;
+ LLViewerMediaTexture* media_texture = NULL;
+
+ if(mMediaSource && mMediaSource->hasMedia())
+ {
+ media_plugin = mMediaSource->getMediaPlugin();
+
+ if(media_plugin && (media_plugin->textureValid()))
+ {
+ media_texture = LLViewerTextureManager::findMediaTexture(mMediaTextureID);
+ if(media_texture)
+ {
+ draw_media = true;
+ }
+ }
+ }
+
if(mHidingInitialLoad)
{
// If we're hiding loading, don't draw at all.
- return;
+ draw_media = false;
}
- // alpha off for this
- LLGLSUIDefault gls_ui;
- LLGLDisable gls_alphaTest( GL_ALPHA_TEST );
-
- gGL.pushMatrix();
+ bool background_visible = isBackgroundVisible();
+ bool background_opaque = isBackgroundOpaque();
+
+ if(draw_media)
{
- if (mIgnoreUIScale)
+ // alpha off for this
+ LLGLSUIDefault gls_ui;
+ LLGLDisable gls_alphaTest( GL_ALPHA_TEST );
+
+ gGL.pushMatrix();
{
- glLoadIdentity();
- // font system stores true screen origin, need to scale this by UI scale factor
- // to get render origin for this view (with unit scale)
- gGL.translatef(floorf(LLFontGL::sCurOrigin.mX * LLUI::sGLScaleFactor.mV[VX]),
- floorf(LLFontGL::sCurOrigin.mY * LLUI::sGLScaleFactor.mV[VY]),
- LLFontGL::sCurOrigin.mZ);
- }
+ if (mIgnoreUIScale)
+ {
+ glLoadIdentity();
+ // font system stores true screen origin, need to scale this by UI scale factor
+ // to get render origin for this view (with unit scale)
+ gGL.translatef(floorf(LLFontGL::sCurOrigin.mX * LLUI::sGLScaleFactor.mV[VX]),
+ floorf(LLFontGL::sCurOrigin.mY * LLUI::sGLScaleFactor.mV[VY]),
+ LLFontGL::sCurOrigin.mZ);
+ }
- // scale texture to fit the space using texture coords
- gGL.getTexUnit(0)->bind(media_texture);
- gGL.color4fv( LLColor4::white.mV );
- F32 max_u = ( F32 )media_plugin->getWidth() / ( F32 )media_plugin->getTextureWidth();
- F32 max_v = ( F32 )media_plugin->getHeight() / ( F32 )media_plugin->getTextureHeight();
+ // scale texture to fit the space using texture coords
+ gGL.getTexUnit(0)->bind(media_texture);
+ gGL.color4fv( LLColor4::white.mV );
+ F32 max_u = ( F32 )media_plugin->getWidth() / ( F32 )media_plugin->getTextureWidth();
+ F32 max_v = ( F32 )media_plugin->getHeight() / ( F32 )media_plugin->getTextureHeight();
- LLRect r = getRect();
- S32 width, height;
- S32 x_offset = 0;
- S32 y_offset = 0;
-
- if(mStretchToFill)
- {
- if(mMaintainAspectRatio)
+ LLRect r = getRect();
+ S32 width, height;
+ S32 x_offset = 0;
+ S32 y_offset = 0;
+
+ if(mStretchToFill)
{
- F32 media_aspect = (F32)(media_plugin->getWidth()) / (F32)(media_plugin->getHeight());
- F32 view_aspect = (F32)(r.getWidth()) / (F32)(r.getHeight());
- if(media_aspect > view_aspect)
+ if(mMaintainAspectRatio)
{
- // max width, adjusted height
- width = r.getWidth();
- height = llmin(llmax(llround(width / media_aspect), 0), r.getHeight());
+ F32 media_aspect = (F32)(media_plugin->getWidth()) / (F32)(media_plugin->getHeight());
+ F32 view_aspect = (F32)(r.getWidth()) / (F32)(r.getHeight());
+ if(media_aspect > view_aspect)
+ {
+ // max width, adjusted height
+ width = r.getWidth();
+ height = llmin(llmax(llround(width / media_aspect), 0), r.getHeight());
+ }
+ else
+ {
+ // max height, adjusted width
+ height = r.getHeight();
+ width = llmin(llmax(llround(height * media_aspect), 0), r.getWidth());
+ }
}
else
{
- // max height, adjusted width
+ width = r.getWidth();
height = r.getHeight();
- width = llmin(llmax(llround(height * media_aspect), 0), r.getWidth());
}
}
else
{
- width = r.getWidth();
- height = r.getHeight();
+ width = llmin(media_plugin->getWidth(), r.getWidth());
+ height = llmin(media_plugin->getHeight(), r.getHeight());
}
- }
- else
- {
- width = llmin(media_plugin->getWidth(), r.getWidth());
- height = llmin(media_plugin->getHeight(), r.getHeight());
- }
-
- x_offset = (r.getWidth() - width) / 2;
- y_offset = (r.getHeight() - height) / 2;
+
+ x_offset = (r.getWidth() - width) / 2;
+ y_offset = (r.getHeight() - height) / 2;
- if(mIgnoreUIScale)
- {
- x_offset = llround((F32)x_offset * LLUI::sGLScaleFactor.mV[VX]);
- y_offset = llround((F32)y_offset * LLUI::sGLScaleFactor.mV[VY]);
- width = llround((F32)width * LLUI::sGLScaleFactor.mV[VX]);
- height = llround((F32)height * LLUI::sGLScaleFactor.mV[VY]);
- }
+ if(mIgnoreUIScale)
+ {
+ x_offset = llround((F32)x_offset * LLUI::sGLScaleFactor.mV[VX]);
+ y_offset = llround((F32)y_offset * LLUI::sGLScaleFactor.mV[VY]);
+ width = llround((F32)width * LLUI::sGLScaleFactor.mV[VX]);
+ height = llround((F32)height * LLUI::sGLScaleFactor.mV[VY]);
+ }
- // draw the browser
- gGL.setSceneBlendType(LLRender::BT_REPLACE);
- gGL.begin( LLRender::QUADS );
- if (! media_plugin->getTextureCoordsOpenGL())
- {
- // render using web browser reported width and height, instead of trying to invert GL scale
- gGL.texCoord2f( max_u, 0.f );
- gGL.vertex2i( x_offset + width, y_offset + height );
+ // draw the browser
+ gGL.setSceneBlendType(LLRender::BT_REPLACE);
+ gGL.begin( LLRender::QUADS );
+ if (! media_plugin->getTextureCoordsOpenGL())
+ {
+ // render using web browser reported width and height, instead of trying to invert GL scale
+ gGL.texCoord2f( max_u, 0.f );
+ gGL.vertex2i( x_offset + width, y_offset + height );
- gGL.texCoord2f( 0.f, 0.f );
- gGL.vertex2i( x_offset, y_offset + height );
+ gGL.texCoord2f( 0.f, 0.f );
+ gGL.vertex2i( x_offset, y_offset + height );
- gGL.texCoord2f( 0.f, max_v );
- gGL.vertex2i( x_offset, y_offset );
+ gGL.texCoord2f( 0.f, max_v );
+ gGL.vertex2i( x_offset, y_offset );
- gGL.texCoord2f( max_u, max_v );
- gGL.vertex2i( x_offset + width, y_offset );
- }
- else
- {
- // render using web browser reported width and height, instead of trying to invert GL scale
- gGL.texCoord2f( max_u, max_v );
- gGL.vertex2i( x_offset + width, y_offset + height );
+ gGL.texCoord2f( max_u, max_v );
+ gGL.vertex2i( x_offset + width, y_offset );
+ }
+ else
+ {
+ // render using web browser reported width and height, instead of trying to invert GL scale
+ gGL.texCoord2f( max_u, max_v );
+ gGL.vertex2i( x_offset + width, y_offset + height );
- gGL.texCoord2f( 0.f, max_v );
- gGL.vertex2i( x_offset, y_offset + height );
+ gGL.texCoord2f( 0.f, max_v );
+ gGL.vertex2i( x_offset, y_offset + height );
- gGL.texCoord2f( 0.f, 0.f );
- gGL.vertex2i( x_offset, y_offset );
+ gGL.texCoord2f( 0.f, 0.f );
+ gGL.vertex2i( x_offset, y_offset );
- gGL.texCoord2f( max_u, 0.f );
- gGL.vertex2i( x_offset + width, y_offset );
+ gGL.texCoord2f( max_u, 0.f );
+ gGL.vertex2i( x_offset + width, y_offset );
+ }
+ gGL.end();
+ gGL.setSceneBlendType(LLRender::BT_ALPHA);
}
- gGL.end();
- gGL.setSceneBlendType(LLRender::BT_ALPHA);
+ gGL.popMatrix();
+
}
- gGL.popMatrix();
-
+ else
+ {
+ // Setting these will make LLPanel::draw draw the opaque background color.
+ setBackgroundVisible(true);
+ setBackgroundOpaque(true);
+ }
+
// highlight if keyboard focus here. (TODO: this needs some work)
if ( mBorder && mBorder->getVisible() )
mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus( this ) );
LLPanel::draw();
+
+ // Restore the previous values
+ setBackgroundVisible(background_visible);
+ setBackgroundOpaque(background_opaque);
}
////////////////////////////////////////////////////////////////////////////////