Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,8 @@ private void enterVRVideo(@VideoProjectionMenuWidget.VideoProjectionFlags int aP
mediaHeight = mAttachedWindow.getWindowHeight();
}
final boolean resetBorder = aProjection == VideoProjectionMenuWidget.VIDEO_PROJECTION_360 ||
aProjection == VideoProjectionMenuWidget.VIDEO_PROJECTION_360_STEREO;
aProjection == VideoProjectionMenuWidget.VIDEO_PROJECTION_360_STEREO ||
aProjection == VideoProjectionMenuWidget.VIDEO_PROJECTION_360_STEREO_LEFT_RIGHT;
mAttachedWindow.enableVRVideoMode(mediaWidth, mediaHeight, resetBorder);
// Handle video resize while in VR video playback
if (mFullScreenMedia != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class VideoProjectionMenuWidget extends MenuWidget {
@IntDef(value = { VIDEO_PROJECTION_NONE, VIDEO_PROJECTION_3D_SIDE_BY_SIDE, VIDEO_PROJECTION_360,
VIDEO_PROJECTION_360_STEREO, VIDEO_PROJECTION_180,
VIDEO_PROJECTION_180_STEREO_LEFT_RIGHT, VIDEO_PROJECTION_180_STEREO_TOP_BOTTOM,
VIDEO_PROJECTION_3D_TOP_BOTTOM })
VIDEO_PROJECTION_3D_TOP_BOTTOM, VIDEO_PROJECTION_360_STEREO_LEFT_RIGHT })
public @interface VideoProjectionFlags {}

public static final int VIDEO_PROJECTION_NONE = -1;
Expand All @@ -33,6 +33,7 @@ public class VideoProjectionMenuWidget extends MenuWidget {
public static final int VIDEO_PROJECTION_180_STEREO_LEFT_RIGHT = 4;
public static final int VIDEO_PROJECTION_180_STEREO_TOP_BOTTOM = 5;
public static final int VIDEO_PROJECTION_3D_TOP_BOTTOM = 6;
public static final int VIDEO_PROJECTION_360_STEREO_LEFT_RIGHT = 7;

public interface Delegate {
void onVideoProjectionClick(@VideoProjectionFlags int aProjection);
Expand Down Expand Up @@ -108,6 +109,9 @@ private void createMenuItems() {
mItems.add(new ProjectionMenuItem(VIDEO_PROJECTION_360_STEREO, getContext().getString(R.string.video_mode_360_stereo),
R.drawable.ic_icon_videoplayback_360_stereo));

mItems.add(new ProjectionMenuItem(VIDEO_PROJECTION_360_STEREO_LEFT_RIGHT, getContext().getString(R.string.video_mode_360_stereo_leftright),
R.drawable.ic_icon_videoplayback_360_stereo_leftright));

mItems.add(new ProjectionMenuItem(VIDEO_PROJECTION_180, getContext().getString(R.string.video_mode_180),
R.drawable.ic_icon_videoplayback_180));

Expand Down Expand Up @@ -165,7 +169,10 @@ public void setSelectedProjection(@VideoProjectionFlags int aProjection) {

autoEnter.set(projection.endsWith("_auto"));

if (projection.startsWith("360s")) {
if (projection.startsWith("360lr")) {
return VIDEO_PROJECTION_360_STEREO_LEFT_RIGHT;
} else if (projection.startsWith("360tb") || projection.startsWith("360s")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can get rid of 360s, it adds nothing

// "360s" predates the tb/lr distinction and is kept as an alias.
return VIDEO_PROJECTION_360_STEREO;
} else if (projection.startsWith("360")) {
return VIDEO_PROJECTION_360;
Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/VRLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct VRLayer::State {
std::function<void()> pendingEvent;
std::string name;
bool composited;
// Clear for layers drawing per-eye content, or both eyes get the left one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please get rid of the comments, code is self explanatory and they get easily rotten.

bool useSameLayerForBothEyes;
State():
initialized(false),
Expand Down
40 changes: 40 additions & 0 deletions app/src/main/cpp/VRVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ struct VRVideo::State {
leftEye = createSphereProjection(false, device::EyeRect(0.0f, 0.5f, 1.0f, 0.5f));
rightEye = createSphereProjection(false, device::EyeRect(0.0f, 0.0f, 1.0f, 0.5f));
break;
case VRVideoProjection::VIDEO_PROJECTION_360_STEREO_LEFT_RIGHT:
leftEye = createSphereProjection(false, device::EyeRect(0.0f, 0.0f, 0.5f, 1.0f));
rightEye = createSphereProjection(false, device::EyeRect(0.5f, 0.0f, 0.5f, 1.0f));
break;
case VRVideoProjection::VIDEO_PROJECTION_180:
leftEye = createSphereProjection(true, device::EyeRect(0.0f, 0.0f, 1.0f, 1.0f));
break;
Expand Down Expand Up @@ -152,6 +156,9 @@ struct VRVideo::State {
case VRVideoProjection::VIDEO_PROJECTION_360_STEREO:
create360StereoProjectionLayer();
break;
case VRVideoProjection::VIDEO_PROJECTION_360_STEREO_LEFT_RIGHT:
create360LRProjectionLayer();
break;
case VRVideoProjection::VIDEO_PROJECTION_180:
create180ProjectionLayer();
break;
Expand Down Expand Up @@ -267,6 +274,32 @@ struct VRVideo::State {
rightTransform.ScaleInPlace(vrb::Vector(1.0f, 0.5f, 1.0f));
equirect->SetUVTransform(device::Eye::Right, rightTransform);

// Per-eye UV transforms need one layer per eye, else mono.
equirect->SetUseSameLayerForBothEyes(false);

leftEye = vrb::Toggle::Create(create);
leftEye->AddNode(VRLayerNode::Create(create, equirect));
rightEye = vrb::Toggle::Create(create);
rightEye->AddNode(VRLayerNode::Create(create, equirect));
}

void create360LRProjectionLayer() {
vrb::CreationContextPtr create = context.lock();
DeviceDelegatePtr device = deviceWeak.lock();
VRLayerEquirectPtr equirect = device->CreateLayerEquirect(window->GetLayer());
layer = equirect;

vrb::Matrix leftTransform = vrb::Matrix::Identity();
leftTransform.ScaleInPlace(vrb::Vector(0.5f, 1.0f, 1.0f));
equirect->SetUVTransform(device::Eye::Left, leftTransform);

vrb::Matrix rightTransform = vrb::Matrix::Position(vrb::Vector(0.5f, 0.0f, 0.0f));
rightTransform.ScaleInPlace(vrb::Vector(0.5f, 1.0f, 1.0f));
equirect->SetUVTransform(device::Eye::Right, rightTransform);

// Per-eye UV transforms need one layer per eye, else mono.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no need for this comment

equirect->SetUseSameLayerForBothEyes(false);

leftEye = vrb::Toggle::Create(create);
leftEye->AddNode(VRLayerNode::Create(create, equirect));
rightEye = vrb::Toggle::Create(create);
Expand All @@ -292,6 +325,8 @@ struct VRVideo::State {

vrb::Matrix uvTransform = vrb::Matrix::Identity();
uvTransform.ScaleInPlace(vrb::Vector(2.0f, 1.0f, 1.0f));
// centers the hemisphere in front of the viewer.
uvTransform.TranslateInPlace(vrb::Vector(-0.5f, 0.0f, 0.0f));

equirect->SetUVTransform(device::Eye::Left, uvTransform);
equirect->SetUVTransform(device::Eye::Right, uvTransform);
Expand Down Expand Up @@ -342,10 +377,15 @@ struct VRVideo::State {

vrb::Matrix uvTransform = vrb::Matrix::Identity();
uvTransform.ScaleInPlace(vrb::Vector(2.0f, 0.5f, 1.0f));
// centers the hemisphere in front of the viewer.
uvTransform.TranslateInPlace(vrb::Vector(-0.5f, 0.0f, 0.0f));
equirect->SetUVTransform(device::Eye::Left, uvTransform);
uvTransform.TranslateInPlace(vrb::Vector(0.0f, 0.5f, 0.0f));
equirect->SetUVTransform(device::Eye::Right, uvTransform);

// Per-eye UV transforms need one layer per eye, else mono.
equirect->SetUseSameLayerForBothEyes(false);

leftEye = create180LayerToggle(equirect);
rightEye = create180LayerToggle(equirect);
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/VRVideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class VRVideo {
VIDEO_PROJECTION_180_STEREO_LEFT_RIGHT = 4,
VIDEO_PROJECTION_180_STEREO_TOP_BOTTOM = 5,
VIDEO_PROJECTION_3D_TOP_BOTTOM = 6,
VIDEO_PROJECTION_360_STEREO_LEFT_RIGHT = 7,
};
static VRVideoPtr Create(vrb::CreationContextPtr aContext,
const WidgetPtr& aWindow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
<path
android:fillColor="@color/void_color"
android:pathData="M27.5 75.87a8 8 0 0 0 10.85-3.24 68.68 68.68 0 0 1 107.49-17.39l-5 4.26a6.82 6.82 0 0 0 2.19 11.61L169 80.2a6.82 6.82 0 0 0 9-7.7l-5.06-26.95a6.83 6.83 0 0 0-11.16-3.92L158 44.77A84.69 84.69 0 0 0 24.27 65a8 8 0 0 0 3.23 10.87zM172.5 124.13a8 8 0 0 0-10.85 3.24 68.68 68.68 0 0 1-107.49 17.39l5-4.26a6.82 6.82 0 0 0-2.19-11.61l-25.92-9.09a6.82 6.82 0 0 0-9 7.7l5.06 26.95a6.83 6.83 0 0 0 11.16 3.92l3.73-3.14a84.09 84.09 0 0 0 52.86 23.94q3.21.26 6.41.25A84.77 84.77 0 0 0 175.73 135a8 8 0 0 0-3.23-10.87z"/>
<path
android:fillColor="@color/void_color"
android:pathData="M26.5 108h147a8 8 0 0 0 0-16h-147a8 8 0 0 0 0 16z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="200"
android:viewportHeight="200">
<path
android:fillColor="@color/void_color"
android:pathData="M27.5 75.87a8 8 0 0 0 10.85-3.24 68.68 68.68 0 0 1 107.49-17.39l-5 4.26a6.82 6.82 0 0 0 2.19 11.61L169 80.2a6.82 6.82 0 0 0 9-7.7l-5.06-26.95a6.83 6.83 0 0 0-11.16-3.92L158 44.77A84.69 84.69 0 0 0 24.27 65a8 8 0 0 0 3.23 10.87zM172.5 124.13a8 8 0 0 0-10.85 3.24 68.68 68.68 0 0 1-107.49 17.39l5-4.26a6.82 6.82 0 0 0-2.19-11.61l-25.92-9.09a6.82 6.82 0 0 0-9 7.7l5.06 26.95a6.83 6.83 0 0 0 11.16 3.92l3.73-3.14a84.09 84.09 0 0 0 52.86 23.94q3.21.26 6.41.25A84.77 84.77 0 0 0 175.73 135a8 8 0 0 0-3.23-10.87z"/>
<path
android:fillColor="@color/void_color"
android:pathData="M108 26.5v147a8 8 0 0 0-16 0v-147a8 8 0 0 0 16 0z"/>
</vector>
5 changes: 4 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,10 @@
<string name="video_mode_360">360</string>

<!-- This string is displayed when selecting a video playback mode. -->
<string name="video_mode_360_stereo">360 Stereo</string>
<string name="video_mode_360_stereo">Stereo 360, oben nach unten</string>

<!-- This string is displayed when selecting a video playback mode. -->
<string name="video_mode_360_stereo_leftright">Stereo 360, links nach rechts</string>

<!-- This string is displayed when selecting a video playback mode. -->
<string name="video_mode_180">180</string>
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/values-en-rGB/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,10 @@
<string name="video_mode_360">360</string>

<!-- This string is displayed when selecting a video playback mode. -->
<string name="video_mode_360_stereo">360 Stereo</string>
<string name="video_mode_360_stereo">Stereo 360 Top to Bottom</string>

<!-- This string is displayed when selecting a video playback mode. -->
<string name="video_mode_360_stereo_leftright">Stereo 360 Left to Right</string>

<!-- This string is displayed when selecting a video playback mode. -->
<string name="video_mode_180">180</string>
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,10 @@
<string name="video_mode_360">360</string>

<!-- This string is displayed when selecting a video playback mode. -->
<string name="video_mode_360_stereo">360 Stereo</string>
<string name="video_mode_360_stereo">Stereo 360 Top to Bottom</string>

<!-- This string is displayed when selecting a video playback mode. -->
<string name="video_mode_360_stereo_leftright">Stereo 360 Left to Right</string>

<!-- This string is displayed when selecting a video playback mode. -->
<string name="video_mode_180">180</string>
Expand Down