Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions indra/llplugin/llpluginclassmedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,13 @@ void LLPluginClassMedia::setJavascriptEnabled(const bool enabled)
sendMessage(message);
}

void LLPluginClassMedia::setTransparentBackground(const bool enabled)
{
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "transparent_background");
message.setValueBoolean("enable", enabled);
sendMessage(message);
}

void LLPluginClassMedia::setWebSecurityDisabled(const bool disabled)
{
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "web_security_disabled");
Expand Down
1 change: 1 addition & 0 deletions indra/llplugin/llpluginclassmedia.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class LLPluginClassMedia : public LLPluginProcessParentOwner
void setLanguageCode(const std::string &language_code);
void setPluginsEnabled(const bool enabled);
void setJavascriptEnabled(const bool enabled);
void setTransparentBackground(const bool enabled);
void setWebSecurityDisabled(const bool disabled);
void setFileAccessFromFileUrlsEnabled(const bool enabled);
void setTarget(const std::string &target);
Expand Down
33 changes: 31 additions & 2 deletions indra/llprimitive/llmediaentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
#define MEDIA_PERMS_INTERACT_KEY_STR "perms_interact"
#define MEDIA_PERMS_CONTROL_KEY_STR "perms_control"

// "display" fields
#define MEDIA_TRANSPARENT_BACKGROUND_KEY_STR "transparent_background"

// "general" fields
const char* LLMediaEntry::ALT_IMAGE_ENABLE_KEY = MEDIA_ALT_IMAGE_ENABLE_KEY_STR;
const char* LLMediaEntry::CONTROLS_KEY = MEDIA_CONTROLS_KEY_STR;
Expand All @@ -74,6 +77,9 @@ const char* LLMediaEntry::WHITELIST_KEY = MEDIA_WHITELIST_KEY_STR;
const char* LLMediaEntry::PERMS_INTERACT_KEY = MEDIA_PERMS_INTERACT_KEY_STR;
const char* LLMediaEntry::PERMS_CONTROL_KEY = MEDIA_PERMS_CONTROL_KEY_STR;

// "display" fields
const char* LLMediaEntry::TRANSPARENT_BACKGROUND_KEY = MEDIA_TRANSPARENT_BACKGROUND_KEY_STR;

#define DEFAULT_URL_PREFIX "https://"

// Constructor(s)
Expand All @@ -93,6 +99,7 @@ LLMediaEntry::LLMediaEntry() :
// mWhiteList
mPermsInteract(PERM_ALL),
mPermsControl(PERM_ALL),
mTransparentBackground(false),
mMediaIDp(NULL)
{
}
Expand Down Expand Up @@ -166,6 +173,9 @@ void LLMediaEntry::asLLSD(LLSD& sd) const
// "permissions" fields
sd[PERMS_INTERACT_KEY] = mPermsInteract;
sd[PERMS_CONTROL_KEY] = mPermsControl;

// "display" fields
sd[TRANSPARENT_BACKGROUND_KEY] = mTransparentBackground;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for if we stick with having an entry flag for this: you will want to extend unit tests to account for this. The existing tests are failing.

}

// static
Expand Down Expand Up @@ -263,6 +273,16 @@ bool LLMediaEntry::fromLLSDInternal(const LLSD& sd, bool overwrite)
status |= setPermsControl( 0xff & (LLSD::Integer)sd[PERMS_CONTROL_KEY] );
}

// "display" fields
// TODO: When the simulator adds "transparent_background" to ObjectMedia
// Change this block to match all other fields:
// if ( overwrite || sd.has(TRANSPARENT_BACKGROUND_KEY) )
// Until then leave it session based.
if ( sd.has(TRANSPARENT_BACKGROUND_KEY) )
{
status |= setTransparentBackground( sd[TRANSPARENT_BACKGROUND_KEY] );
}

return LSL_STATUS_OK == status;
}

Expand Down Expand Up @@ -290,6 +310,9 @@ LLMediaEntry& LLMediaEntry::operator=(const LLMediaEntry &rhs)
// "permissions" fields
mPermsInteract = rhs.mPermsInteract;
mPermsControl = rhs.mPermsControl;

// "display" fields
mTransparentBackground = rhs.mTransparentBackground;
}

return *this;
Expand Down Expand Up @@ -317,7 +340,10 @@ bool LLMediaEntry::operator==(const LLMediaEntry &rhs) const

// "permissions" fields
mPermsInteract == rhs.mPermsInteract &&
mPermsControl == rhs.mPermsControl
mPermsControl == rhs.mPermsControl &&

// "display" fields
mTransparentBackground == rhs.mTransparentBackground

);
}
Expand All @@ -344,7 +370,10 @@ bool LLMediaEntry::operator!=(const LLMediaEntry &rhs) const

// "permissions" fields
mPermsInteract != rhs.mPermsInteract ||
mPermsControl != rhs.mPermsControl
mPermsControl != rhs.mPermsControl ||

// "display" fields
mTransparentBackground != rhs.mTransparentBackground

);
}
Expand Down
7 changes: 6 additions & 1 deletion indra/llprimitive/llmediaentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class LLMediaEntry
bool getFirstClickInteract() const { return mFirstClickInteract; }
U16 getWidthPixels() const { return mWidthPixels; }
U16 getHeightPixels() const { return mHeightPixels; }
bool getTransparentBackground() const { return mTransparentBackground; }

// "security" fields
bool getWhiteListEnable() const { return mWhiteListEnable; }
Expand All @@ -100,6 +101,7 @@ class LLMediaEntry
U32 setAutoScale(bool auto_scale) { mAutoScale = auto_scale; return LSL_STATUS_OK; }
U32 setAutoZoom(bool auto_zoom) { mAutoZoom = auto_zoom; return LSL_STATUS_OK; }
U32 setFirstClickInteract(bool first_click) { mFirstClickInteract = first_click; return LSL_STATUS_OK; }
U32 setTransparentBackground(bool transparent) { mTransparentBackground = transparent; return LSL_STATUS_OK; }
U32 setWidthPixels(U16 width);
U32 setHeightPixels(U16 height);

Expand Down Expand Up @@ -138,6 +140,7 @@ class LLMediaEntry
static const char* FIRST_CLICK_INTERACT_KEY;
static const char* WIDTH_PIXELS_KEY;
static const char* HEIGHT_PIXELS_KEY;
static const char* TRANSPARENT_BACKGROUND_KEY;

// "security" fields
static const char* WHITELIST_ENABLE_KEY;
Expand Down Expand Up @@ -168,7 +171,8 @@ class LLMediaEntry
WHITELIST_ID = 12,
PERMS_INTERACT_ID = 13,
PERMS_CONTROL_ID = 14,
PARAM_MAX_ID = PERMS_CONTROL_ID
TRANSPARENT_BACKGROUND_ID = 15,
PARAM_MAX_ID = TRANSPARENT_BACKGROUND_ID
};

// "permissions" values
Expand Down Expand Up @@ -204,6 +208,7 @@ class LLMediaEntry
bool mAutoScale;
bool mAutoZoom;
bool mFirstClickInteract;
bool mTransparentBackground;
U16 mWidthPixels;
U16 mHeightPixels;

Expand Down
2 changes: 1 addition & 1 deletion indra/llrender/llgltexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class LLGLTexture : public LLTexture
LLGLenum getPrimaryFormat() const;
bool getIsAlphaMask() const ;
LLTexUnit::eTextureType getTarget(void) const ;
bool getMask(const LLVector2 &tc);
virtual bool getMask(const LLVector2 &tc);
F32 getTimePassedSinceLastBound();
bool getMissed() const ;
bool isJustBound()const ;
Expand Down
10 changes: 8 additions & 2 deletions indra/media_plugins/cef/media_plugin_cef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class MediaPluginCEF :
std::string mProxyHost;
int mProxyPort;
bool mDisableGPU;
bool mTransparentBackground;
bool mDisableNetworkService;
bool mUseMockKeyChain;
bool mDisableWebSecurity;
Expand Down Expand Up @@ -140,6 +141,7 @@ MediaPluginBase(host_send_func, host_user_data)
mProxyHost = "";
mProxyPort = 0;
mDisableGPU = false;
mTransparentBackground = false;
mDisableNetworkService = true;
mUseMockKeyChain = true;
mDisableWebSecurity = false;
Expand Down Expand Up @@ -652,7 +654,7 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
// SL-15560: Product team overruled my change to set the default
// embedded background color to match the floater background
// and set it to white
settings.background_color = 0xffffffff; // white
settings.background_color = mTransparentBackground ? 0x00ffffff : 0xffffffff;

Comment on lines 654 to 658
settings.root_cache_path = mRootCachePath;
settings.cookies_enabled = mCookiesEnabled;
Expand Down Expand Up @@ -734,7 +736,7 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
message.setValueS32("default_width", 1024);
message.setValueS32("default_height", 1024);
message.setValueS32("depth", mDepth);
message.setValueU32("internalformat", GL_RGB);
message.setValueU32("internalformat", GL_RGBA);
message.setValueU32("format", GL_BGRA);
message.setValueU32("type", GL_UNSIGNED_BYTE);
message.setValueBoolean("coords_opengl", true);
Expand Down Expand Up @@ -1033,6 +1035,10 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
{
mJavascriptEnabled = message_in.getValueBoolean("enable");
}
else if (message_name == "transparent_background")
{
mTransparentBackground = message_in.getValueBoolean("enable");
}
else if (message_name == "gpu_disabled")
{
mDisableGPU = message_in.getValueBoolean("disable");
Expand Down
6 changes: 6 additions & 0 deletions indra/newview/llpanelmediasettingsgeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ LLPanelMediaSettingsGeneral::LLPanelMediaSettingsGeneral() :
mAutoZoom( NULL ),
mAutoPlay( NULL ),
mAutoScale( NULL ),
mTransparentBackground( NULL ),
mWidthPixels( NULL ),
mHeightPixels( NULL ),
mHomeURL( NULL ),
Expand All @@ -87,6 +88,7 @@ bool LLPanelMediaSettingsGeneral::postBuild()
mAutoPlay = getChild< LLCheckBoxCtrl >( LLMediaEntry::AUTO_PLAY_KEY );
mAutoScale = getChild< LLCheckBoxCtrl >( LLMediaEntry::AUTO_SCALE_KEY );
mAutoZoom = getChild< LLCheckBoxCtrl >( LLMediaEntry::AUTO_ZOOM_KEY );
mTransparentBackground = getChild< LLCheckBoxCtrl >( LLMediaEntry::TRANSPARENT_BACKGROUND_KEY );
mCurrentURL = getChild< LLTextBox >( LLMediaEntry::CURRENT_URL_KEY );
mFirstClick = getChild< LLCheckBoxCtrl >( LLMediaEntry::FIRST_CLICK_INTERACT_KEY );
mHeightPixels = getChild< LLSpinCtrl >( LLMediaEntry::HEIGHT_PIXELS_KEY );
Expand Down Expand Up @@ -204,6 +206,7 @@ void LLPanelMediaSettingsGeneral::clearValues( void* userdata, bool editable, bo
self->mHeightPixels->clear();
self->mHomeURL->clear();
self->mWidthPixels->clear();
self->mTransparentBackground->clear();
self->mAutoLoop ->setEnabled(editable);
self->mAutoPlay ->setEnabled(editable);
self->mAutoScale ->setEnabled(editable);
Expand All @@ -213,6 +216,7 @@ void LLPanelMediaSettingsGeneral::clearValues( void* userdata, bool editable, bo
self->mHeightPixels ->setEnabled(editable);
self->mHomeURL ->setEnabled(editable);
self->mWidthPixels ->setEnabled(editable);
self->mTransparentBackground ->setEnabled(editable);
if (update_preview)
{
self->updateMediaPreview();
Expand Down Expand Up @@ -277,6 +281,7 @@ void LLPanelMediaSettingsGeneral::initValues( void* userdata, const LLSD& _media
{ LLMediaEntry::HOME_URL_KEY, self->mHomeURL, "LLLineEditor" },
{ LLMediaEntry::FIRST_CLICK_INTERACT_KEY, self->mFirstClick, "LLCheckBoxCtrl" },
{ LLMediaEntry::WIDTH_PIXELS_KEY, self->mWidthPixels, "LLSpinCtrl" },
{ LLMediaEntry::TRANSPARENT_BACKGROUND_KEY, self->mTransparentBackground, "LLCheckBoxCtrl" },
{ "", NULL , "" }
};

Expand Down Expand Up @@ -414,6 +419,7 @@ void LLPanelMediaSettingsGeneral::getValues( LLSD &fill_me_in, bool include_tent
fill_me_in[LLMediaEntry::HOME_URL_KEY] = (LLSD::String)mHomeURL->getValue();
if (include_tentative || !mFirstClick->getTentative()) fill_me_in[LLMediaEntry::FIRST_CLICK_INTERACT_KEY] = (LLSD::Boolean)mFirstClick->getValue();
if (include_tentative || !mWidthPixels->getTentative()) fill_me_in[LLMediaEntry::WIDTH_PIXELS_KEY] = (LLSD::Integer)mWidthPixels->getValue();
if (include_tentative || !mTransparentBackground->getTentative()) fill_me_in[LLMediaEntry::TRANSPARENT_BACKGROUND_KEY] = (LLSD::Boolean)mTransparentBackground->getValue();
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions indra/newview/llpanelmediasettingsgeneral.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class LLPanelMediaSettingsGeneral : public LLPanel
LLCheckBoxCtrl* mAutoZoom;
LLCheckBoxCtrl* mAutoPlay;
LLCheckBoxCtrl* mAutoScale;
LLCheckBoxCtrl* mTransparentBackground;
LLSpinCtrl* mWidthPixels;
LLSpinCtrl* mHeightPixels;
LLLineEditor* mHomeURL;
Expand Down
51 changes: 50 additions & 1 deletion indra/newview/lltoolpie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ bool LLToolPie::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType cli
return result;
}

// True if the pick landed on a media face at a fully transparent media
// pixel, so the pick should defer to whatever is visible behind it.
static bool is_transparent_media_pick(const LLPickInfo& pick)
{
LLViewerObject* objectp = pick.getObject();
if (!objectp || pick.mObjectFace < 0 || pick.mObjectFace >= objectp->getNumTEs())
{
return false;
}
const LLTextureEntry* tep = objectp->getTE(pick.mObjectFace);
LLMediaEntry* mep = (tep && tep->hasMedia()) ? tep->getMediaData() : NULL;
if (!mep)
{
return false;
}
viewer_media_t media_impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID());
return media_impl.notNull() && media_impl->isTransparentAt(pick.mUVCoords);
}

bool LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask)
{
if (mDoubleClickTimer.getStarted())
Expand All @@ -129,7 +148,13 @@ bool LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask)
// left mouse down always picks transparent (but see handleMouseUp).
// Also see LLToolPie::handleHover() - priorities are a bit different there.
// Todo: we need a more consistent set of rules to work with
if (transp_object == visible_object || !visible_object ||
if (transp_object != visible_object && is_transparent_media_pick(transparent_pick))
{
// The transparent pick went through a fully transparent media pixel,
// act on whatever is visible behind it (object, land, or nothing).
mPick = visible_pick;
}
else if (transp_object == visible_object || !visible_object ||
!transp_object) // avoid potential for null dereference below, don't make assumptions about behavior of pickImmediate
{
mPick = transparent_pick;
Expand Down Expand Up @@ -1666,6 +1691,14 @@ bool LLToolPie::handleMediaClick(const LLPickInfo& pick)

viewer_media_t media_impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID());

if (media_impl.notNull() && media_impl->isTransparentAt(pick.mUVCoords))
{
// The click landed on a fully transparent part of the media, let it
// pass through to the world.
LLViewerMediaFocus::getInstance()->clearFocus();
return false;
}

if (gSavedSettings.getBOOL("MediaOnAPrimUI"))
{
if (!LLViewerMediaFocus::getInstance()->isFocusedOnFace(pick.getObject(), pick.mObjectFace) || media_impl.isNull())
Expand Down Expand Up @@ -1730,6 +1763,14 @@ bool LLToolPie::handleMediaDblClick(const LLPickInfo& pick)

viewer_media_t media_impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID());

if (media_impl.notNull() && media_impl->isTransparentAt(pick.mUVCoords))
{
// The click landed on a fully transparent part of the media, let it
// pass through to the world.
LLViewerMediaFocus::getInstance()->clearFocus();
return false;
}

if (gSavedSettings.getBOOL("MediaOnAPrimUI"))
{
if (!LLViewerMediaFocus::getInstance()->isFocusedOnFace(pick.getObject(), pick.mObjectFace) || media_impl.isNull())
Expand Down Expand Up @@ -1785,6 +1826,14 @@ bool LLToolPie::handleMediaHover(const LLPickInfo& pick)
{
viewer_media_t media_impl = LLViewerMedia::getInstance()->getMediaImplFromTextureID(mep->getMediaID());

if (media_impl.notNull() && media_impl->isTransparentAt(pick.mUVCoords))
{
// Hovering over a fully transparent part of the media, treat it
// as normal in-world hover.
LLViewerMediaFocus::getInstance()->clearHover();
return false;
}

if(media_impl.notNull())
{
// Update media hover object
Expand Down
Loading
Loading