Auto merge of #23963 - asajeffrey:magicleap-grainier, r=Manishearth

Reduce magicleap servo screen resolution

<!-- Please describe your changes on the following line: -->

Reduce the magicleap resolution from 720p to 480p. (Videos at 720p seem to lag.)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because we don't test native UI

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23963)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-08-14 10:54:19 -04:00 committed by GitHub
commit c47575535c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 37 additions and 84 deletions

View file

@ -2,9 +2,9 @@
<mlproject:mlproject xmlns:mlproject="http://www.magicleap.com/uidesigner/mlproject" generated="true" srcGenVersion="1"> <mlproject:mlproject xmlns:mlproject="http://www.magicleap.com/uidesigner/mlproject" generated="true" srcGenVersion="1">
<designFile path="scenes/Servo2D.design"/> <designFile path="scenes/Servo2D.design"/>
<pipelineDirectory path="pipeline"/> <pipelineDirectory path="pipeline"/>
<preferences key="srcgen.directories.incgen" value="inc.gen"/>
<preferences key="srcgen.directories.src" value="src"/> <preferences key="srcgen.directories.src" value="src"/>
<preferences key="srcgen.directories.srcgen" value="src.gen"/>
<preferences key="srcgen.directories.basedir" value="code"/> <preferences key="srcgen.directories.basedir" value="code"/>
<preferences key="srcgen.directories.inc" value="inc"/> <preferences key="srcgen.directories.inc" value="inc"/>
<preferences key="srcgen.directories.incgen" value="inc.gen"/>
<preferences key="srcgen.directories.srcgen" value="src.gen"/>
</mlproject:mlproject> </mlproject:mlproject>

View file

@ -24,7 +24,6 @@
#include <SpawnedSceneBase.h> #include <SpawnedSceneBase.h>
#include <SpawnedSceneHandlers.h> #include <SpawnedSceneHandlers.h>
#include <lumin/node/LineNode.h>
#include <lumin/node/QuadNode.h> #include <lumin/node/QuadNode.h>
#include <lumin/ui/node/UiButton.h> #include <lumin/ui/node/UiButton.h>
#include <lumin/ui/node/UiPanel.h> #include <lumin/ui/node/UiPanel.h>
@ -40,7 +39,6 @@ namespace scenes {
extern const std::string backButton; extern const std::string backButton;
extern const std::string fwdButton; extern const std::string fwdButton;
extern const std::string urlBar; extern const std::string urlBar;
extern const std::string laser;
} }
struct SpawnedScene : public SpawnedSceneBase { struct SpawnedScene : public SpawnedSceneBase {
@ -51,7 +49,6 @@ namespace scenes {
lumin::ui::UiButton* backButton; lumin::ui::UiButton* backButton;
lumin::ui::UiButton* fwdButton; lumin::ui::UiButton* fwdButton;
lumin::ui::UiTextEdit* urlBar; lumin::ui::UiTextEdit* urlBar;
lumin::LineNode* laser;
}; };
SpawnedSceneBase* createSpawnedScene(const SceneDescriptor& sceneDescriptor, lumin::Node* root); SpawnedSceneBase* createSpawnedScene(const SceneDescriptor& sceneDescriptor, lumin::Node* root);

View file

@ -124,9 +124,10 @@ protected:
bool pointInsideViewport(glm::vec2 pt); bool pointInsideViewport(glm::vec2 pt);
/** /**
* Redraw the laser. Returns the laser endpoint, in viewport coordinates. * Returns the intersection of the laser and the viewport, in viewport coordinates.
* Returns (-1, -1) if the laser does not intersect the viewport.
*/ */
glm::vec2 redrawLaser(); glm::vec2 laserPosition();
private: private:
lumin::Prism* prism_ = nullptr; // represents the bounded space where the App renders. lumin::Prism* prism_ = nullptr; // represents the bounded space where the App renders.

View file

@ -34,7 +34,6 @@ namespace scenes {
backButton = lumin::ui::UiButton::CastFrom(root->findChild(externalNodes::backButton)); backButton = lumin::ui::UiButton::CastFrom(root->findChild(externalNodes::backButton));
fwdButton = lumin::ui::UiButton::CastFrom(root->findChild(externalNodes::fwdButton)); fwdButton = lumin::ui::UiButton::CastFrom(root->findChild(externalNodes::fwdButton));
urlBar = lumin::ui::UiTextEdit::CastFrom(root->findChild(externalNodes::urlBar)); urlBar = lumin::ui::UiTextEdit::CastFrom(root->findChild(externalNodes::urlBar));
laser = lumin::LineNode::CastFrom(root->findChild(externalNodes::laser));
} }
SpawnedScene::~SpawnedScene() { SpawnedScene::~SpawnedScene() {
@ -73,10 +72,6 @@ namespace scenes {
urlBarHandlers(SpawnedScene& ss); urlBarHandlers(SpawnedScene& ss);
}; };
urlBarHandlers urlBarHandlers_; urlBarHandlers urlBarHandlers_;
struct laserHandlers {
laserHandlers(SpawnedScene& ss);
};
laserHandlers laserHandlers_;
}; };
Handlers::contentPanelHandlers::contentPanelHandlers(SpawnedScene& ss) Handlers::contentPanelHandlers::contentPanelHandlers(SpawnedScene& ss)
@ -94,9 +89,6 @@ namespace scenes {
Handlers::urlBarHandlers::urlBarHandlers(SpawnedScene& ss) Handlers::urlBarHandlers::urlBarHandlers(SpawnedScene& ss)
{ {
} }
Handlers::laserHandlers::laserHandlers(SpawnedScene& ss)
{
}
Handlers::Handlers(SpawnedScene& ss) Handlers::Handlers(SpawnedScene& ss)
: SpawnedSceneHandlers(ss), : SpawnedSceneHandlers(ss),
@ -104,8 +96,7 @@ namespace scenes {
contentHandlers_(ss), contentHandlers_(ss),
backButtonHandlers_(ss), backButtonHandlers_(ss),
fwdButtonHandlers_(ss), fwdButtonHandlers_(ss),
urlBarHandlers_(ss), urlBarHandlers_(ss)
laserHandlers_(ss)
{ {
} }

View file

@ -33,7 +33,6 @@ namespace scenes {
extern const std::string backButton = "backButton"; extern const std::string backButton = "backButton";
extern const std::string fwdButton = "fwdButton"; extern const std::string fwdButton = "fwdButton";
extern const std::string urlBar = "urlBar"; extern const std::string urlBar = "urlBar";
extern const std::string laser = "laser";
} }
const SceneDescriptor::ExternalNodeReferences externalNodesMap = { const SceneDescriptor::ExternalNodeReferences externalNodesMap = {
@ -41,8 +40,7 @@ namespace scenes {
{"content", externalNodes::content}, {"content", externalNodes::content},
{"backButton", externalNodes::backButton}, {"backButton", externalNodes::backButton},
{"fwdButton", externalNodes::fwdButton}, {"fwdButton", externalNodes::fwdButton},
{"urlBar", externalNodes::urlBar}, {"urlBar", externalNodes::urlBar}
{"laser", externalNodes::laser}
}; };
const SceneDescriptor descriptor( const SceneDescriptor descriptor(

View file

@ -18,22 +18,22 @@
#include <string.h> #include <string.h>
// The viewport dimensions (in px). // The viewport dimensions (in px).
const int VIEWPORT_W = 500; const int VIEWPORT_W = 852;
const int VIEWPORT_H = 500; const int VIEWPORT_H = 480;
// The hidpi factor. // The hidpi factor.
const float HIDPI = 1.0; const float HIDPI = 1.0;
// The prism dimensions (in m). // The prism dimensions (in m).
const float PRISM_W = 2.0; const float PRISM_W = 1.50;
const float PRISM_H = 0.75; const float PRISM_H = 1;
const float PRISM_D = 2.0; const float PRISM_D = 0.05;
// The length of the laser pointer (in m). // The length of the laser pointer (in m).
const float LASER_LENGTH = 10.0; const float LASER_LENGTH = 10.0;
// The width of the keyboard // The width of the keyboard
const float KEYBOARD_W = 0.666; const float KEYBOARD_W = 1.333;
// The home page // The home page
const char* HOME_PAGE = "https://servo.org/ml-home"; const char* HOME_PAGE = "https://servo.org/ml-home";
@ -152,7 +152,7 @@ int Servo2D::init() {
} }
lumin::ui::UiPanel::RequestFocus(content_panel_); lumin::ui::UiPanel::RequestFocus(content_panel_);
lumin::ResourceIDType plane_id = prism_->createPlanarEGLResourceId(); lumin::ResourceIDType plane_id = prism_->createPlanarEGLResourceId(VIEWPORT_W, VIEWPORT_H);
if (!plane_id) { if (!plane_id) {
ML_LOG(Error, "Servo2D Failed to create EGL resource"); ML_LOG(Error, "Servo2D Failed to create EGL resource");
abort(); abort();
@ -226,14 +226,6 @@ int Servo2D::init() {
url_bar_->setKeyboardProperties(keyboard_properties); url_bar_->setKeyboardProperties(keyboard_properties);
url_bar_->onFocusLostSub(std::bind(&Servo2D::urlBarEventListener, this)); url_bar_->onFocusLostSub(std::bind(&Servo2D::urlBarEventListener, this));
// Add the laser pointer
laser_ = lumin::LineNode::CastFrom(prism_->findNode(scenes::Servo2D::externalNodes::laser, root_node));
if (!laser_) {
ML_LOG(Error, "Servo2D Failed to get laser");
abort();
return 1;
}
return 0; return 0;
} }
@ -264,7 +256,7 @@ void Servo2D::spawnInitialScenes() {
} }
bool Servo2D::updateLoop(float fDelta) { bool Servo2D::updateLoop(float fDelta) {
glm::vec2 pos = redrawLaser(); glm::vec2 pos = laserPosition();
move_servo(servo_, pos.x, pos.y); move_servo(servo_, pos.x, pos.y);
heartbeat_servo(servo_); heartbeat_servo(servo_);
return true; return true;
@ -311,7 +303,7 @@ bool Servo2D::pose6DofEventListener(lumin::ControlPose6DofInputEventData* event)
return false; return false;
} }
glm::vec2 Servo2D::redrawLaser() { glm::vec2 Servo2D::laserPosition() {
// Return (-1, -1) if the laser doesn't intersect z=0 // Return (-1, -1) if the laser doesn't intersect z=0
glm::vec2 result = glm::vec2(-1.0, -1.0); glm::vec2 result = glm::vec2(-1.0, -1.0);
@ -333,18 +325,9 @@ glm::vec2 Servo2D::redrawLaser() {
float ratio = 1.0 / (1.0 - (endpoint.z / position.z)); float ratio = 1.0 / (1.0 - (endpoint.z / position.z));
// The intersection point // The intersection point
glm::vec3 intersection = ((1 - ratio) * position) + (ratio * endpoint); glm::vec3 intersection = ((1 - ratio) * position) + (ratio * endpoint);
// Is the intersection inside the viewport?
result = viewportPosition(intersection); result = viewportPosition(intersection);
if (pointInsideViewport(result)) {
color = glm::vec4(0.0, 1.0, 0.0, 1.0);
endpoint = intersection;
}
} }
laser_->clearPoints();
laser_->addPoints(position);
laser_->addPoints(endpoint);
laser_->setColor(color);
return result; return result;
} }
@ -356,7 +339,7 @@ bool Servo2D::gestureEventListener(lumin::GestureInputEventData* event) {
} }
// Only respond to trigger down if the laser is currently in the viewport // Only respond to trigger down if the laser is currently in the viewport
glm::vec2 pos = redrawLaser(); glm::vec2 pos = laserPosition();
if ((typ == lumin::input::GestureType::TriggerDown) && !pointInsideViewport(pos)) { if ((typ == lumin::input::GestureType::TriggerDown) && !pointInsideViewport(pos)) {
return false; return false;
} }

View file

@ -22,7 +22,7 @@
"lap/types/file/png" "lap/types/file/png"
] ]
}, },
"checkpoint-hash": "b1a5b4c3dfe7a6c0a3068dd837adfa07364f5016ddef9e6698090ba3544ccf921abba715182f372e25d65a9b6b13fdf11f12e436482cc3bace76f56876bd2251", "checkpoint-hash": "ac0d99c246211709c735b6ff2a02e2f4a2450bdb04c0db28409c4990e45211b922511c68c5874869ee26898c1a95c40a812b85d4c3fa397703606f436fd84b51",
"templates": [ "templates": [
"lap/template/passthru_material_from_kmat", "lap/template/passthru_material_from_kmat",
"lap/template/passthru_model_from_fbx", "lap/template/passthru_model_from_fbx",

View file

@ -4,6 +4,7 @@
<property id="sceneName" value="Servo2D"/> <property id="sceneName" value="Servo2D"/>
<node name="contentPanel" nodeTypeId="lumin.ui.panel"> <node name="contentPanel" nodeTypeId="lumin.ui.panel">
<property id="cursorInitialPosition"/> <property id="cursorInitialPosition"/>
<property id="cursorVisible" value="false"/>
<property id="edgeConstraint"/> <property id="edgeConstraint"/>
<property id="external" value="true"/> <property id="external" value="true"/>
<property id="gravityWellProperties"> <property id="gravityWellProperties">
@ -15,8 +16,8 @@
<property id="name" value="contentPanel"/> <property id="name" value="contentPanel"/>
<property id="panelShape"> <property id="panelShape">
<property id="size"> <property id="size">
<property id="x" value="0.5"/> <property id="x" value="1.28"/>
<property id="y" value="0.44"/> <property id="y" value="0.72"/>
</property> </property>
<property id="offset"/> <property id="offset"/>
</property> </property>
@ -29,15 +30,15 @@
<property id="external" value="true"/> <property id="external" value="true"/>
<property id="name" value="content"/> <property id="name" value="content"/>
<property id="position"> <property id="position">
<property id="x" value="-0.25"/> <property id="x" value="-0.64"/>
<property id="y" value="-0.22"/> <property id="y" value="-0.36"/>
<property id="z" value="-0.0"/> <property id="z" value="-0.0"/>
</property> </property>
<property id="rotation"/> <property id="rotation"/>
<property id="scale"/> <property id="scale"/>
<property id="size"> <property id="size">
<property id="x" value="0.5"/> <property id="x" value="1.28"/>
<property id="y" value="0.5"/> <property id="y" value="0.72"/>
</property> </property>
<property id="texCoords"> <property id="texCoords">
<property id="x"> <property id="x">
@ -76,12 +77,12 @@
<property id="name" value="uiLinearLayout1"/> <property id="name" value="uiLinearLayout1"/>
<property id="orientation" value="Horizontal"/> <property id="orientation" value="Horizontal"/>
<property id="position"> <property id="position">
<property id="y" value="-0.2"/> <property id="y" value="-0.32"/>
</property> </property>
<property id="rotation"/> <property id="rotation"/>
<property id="scale"/> <property id="scale"/>
<property id="size"> <property id="size">
<property id="x" value="0.5"/> <property id="x" value="1.28"/>
<property id="y" value="0.05"/> <property id="y" value="0.05"/>
</property> </property>
<node name="backButton" nodeTypeId="lumin.ui.button"> <node name="backButton" nodeTypeId="lumin.ui.button">
@ -149,39 +150,22 @@
<property id="left" value="0.003"/> <property id="left" value="0.003"/>
</property> </property>
<property id="textSize" value="0.05"/> <property id="textSize" value="0.05"/>
<property id="width" value="0.6"/> <property id="width" value="1.8"/>
</node> </node>
</node> </node>
<node name="laser" nodeTypeId="lumin.line">
<property id="color" value="0 0 0 0"/>
<property id="external" value="true"/>
<property id="name" value="laser"/>
<property id="opaque" value="false"/>
<property id="points">
<property id="0"/>
<property id="1">
<property id="x" value="1.0"/>
<property id="y" value="1.0"/>
<property id="z" value="1.0"/>
</property>
</property>
<property id="position"/>
<property id="rotation"/>
<property id="scale"/>
</node>
<node name="bevel" nodeTypeId="lumin.quad"> <node name="bevel" nodeTypeId="lumin.quad">
<property id="color" value="0.4 0.302 0.702 1"/> <property id="color" value="0.4 0.302 0.702 1"/>
<property id="name" value="bevel"/> <property id="name" value="bevel"/>
<property id="position"> <property id="position">
<property id="x" value="-0.26"/> <property id="x" value="-0.65"/>
<property id="y" value="-0.17"/> <property id="y" value="-0.31"/>
<property id="z" value="-0.01"/> <property id="z" value="-0.01"/>
</property> </property>
<property id="rotation"/> <property id="rotation"/>
<property id="scale"/> <property id="scale"/>
<property id="size"> <property id="size">
<property id="x" value="0.52"/> <property id="x" value="1.3"/>
<property id="y" value="0.52"/> <property id="y" value="0.74"/>
</property> </property>
<property id="texCoords"> <property id="texCoords">
<property id="x"> <property id="x">

View file

@ -1,9 +1,9 @@
<ObjectModel name="Servo2D" version="1"> <ObjectModel name="Servo2D" version="1">
<TransformNode/> <TransformNode/>
<UiPanel bottomEdgeConstraint="0.000000" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" leftEdgeConstraint="0.000000" name="contentPanel" pos="0,0.06,0" rightEdgeConstraint="0.000000" shape="[size:[0.5,0.44], roundness: 0, offset:[0,0,0]]" topEdgeConstraint="0.000000"> <UiPanel bottomEdgeConstraint="0.000000" cursorVisible="false" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" leftEdgeConstraint="0.000000" name="contentPanel" pos="0,0.06,0" rightEdgeConstraint="0.000000" shape="[size:[1.28,0.72], roundness: 0, offset:[0,0,0]]" topEdgeConstraint="0.000000">
<QuadNode castShadow="false" name="content" pos="-0.25,-0.22,-0" receiveShadow="false" shader="MAX" size="0.500000, 0.500000"/> <QuadNode castShadow="false" name="content" pos="-0.64,-0.36,-0" receiveShadow="false" shader="MAX" size="1.280000, 0.720000"/>
</UiPanel> </UiPanel>
<UiLinearLayout alignment="Top, Center" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" itemAlignment="Center, Left" itemPadding="0.000000, 0.010000, 0.000000, 0.010000" name="uiLinearLayout1" orientation="Horizontal" pos="0,-0.2,0" size="0.500000, 0.050000"> <UiLinearLayout alignment="Top, Center" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" itemAlignment="Center, Left" itemPadding="0.000000, 0.010000, 0.000000, 0.010000" name="uiLinearLayout1" orientation="Horizontal" pos="0,-0.32,0" size="1.280000, 0.050000">
<Content> <Content>
<UiButton gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="backButton" pos="0,-0.6,0" size="0.100000, 0.100000" text="Back" textSize="0.050000"/> <UiButton gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="backButton" pos="0,-0.6,0" size="0.100000, 0.100000" text="Back" textSize="0.050000"/>
</Content> </Content>
@ -11,9 +11,8 @@
<UiButton gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="fwdButton" size="0.100000, 0.100000" text="Fwd" textSize="0.050000"/> <UiButton gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="fwdButton" size="0.100000, 0.100000" text="Fwd" textSize="0.050000"/>
</Content> </Content>
<Content> <Content>
<UiTextEdit alignment="Center, Left" font="DefaultRes_Font_LominoUI_Rg" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="urlBar" scrollSpeed="0.500000" size="0.600000, 0.050000" textSize="0.050000"/> <UiTextEdit alignment="Center, Left" font="DefaultRes_Font_LominoUI_Rg" gravityWellRoundness="0.000000" gravityWellSize="0.000000, 0.000000" gravityWellSnap="ClosestEdge" name="urlBar" scrollSpeed="0.500000" size="1.800000, 0.050000" textSize="0.050000"/>
</Content> </Content>
</UiLinearLayout> </UiLinearLayout>
<LineNode castShadow="false" color="0,0,0,0" name="laser" opaque="false" points="0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000" receiveShadow="false" shader="Line"/> <QuadNode castShadow="false" color="0.1572062,0.09219654,0.4817875,1" name="bevel" pos="-0.65,-0.31,-0.01" receiveShadow="false" shader="MAX" size="1.300000, 0.740000"/>
<QuadNode castShadow="false" color="0.1572062,0.09219654,0.4817875,1" name="bevel" pos="-0.26,-0.17,-0.01" receiveShadow="false" shader="MAX" size="0.520000, 0.520000"/>
</ObjectModel> </ObjectModel>