Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1381)

Unified Diff: chrome/browser/android/vr_shell/ui_scene.cc

Issue 2624243002: VrShell: Allow native control of UI element opacity. (Closed)
Patch Set: for (auto nit : nits) nit.fix(); Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene.h ('k') | chrome/browser/android/vr_shell/ui_scene_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/ui_scene.cc
diff --git a/chrome/browser/android/vr_shell/ui_scene.cc b/chrome/browser/android/vr_shell/ui_scene.cc
index 2d4adb13181229d86665b66925900a5b649193b6..0035c1c66973e504b1150178c143e827a1f2da8d 100644
--- a/chrome/browser/android/vr_shell/ui_scene.cc
+++ b/chrome/browser/android/vr_shell/ui_scene.cc
@@ -96,6 +96,9 @@ void ParseEndpointToFloats(Animation::Property property,
case Animation::Property::TRANSLATION:
ParseFloats(dict, {"x", "y", "z"}, vec);
break;
+ case Animation::Property::OPACITY:
+ ParseFloats(dict, {"x"}, vec);
+ break;
}
}
@@ -324,7 +327,9 @@ void UiScene::UpdateTransforms(float screen_tilt, int64_t time_in_micro) {
for (auto& element : ui_elements_) {
element->transform.MakeIdentity();
element->transform.Scale(element->size.x, element->size.y, element->size.z);
- ApplyRecursiveTransforms(*element.get(), &element->transform);
+ element->computed_opacity = 1.0f;
+ ApplyRecursiveTransforms(*element.get(), &element->transform,
+ &element->computed_opacity);
element->transform.Rotate(1.0f, 0.0f, 0.0f, screen_tilt);
}
}
@@ -352,19 +357,21 @@ UiScene::UiScene() = default;
UiScene::~UiScene() = default;
void UiScene::ApplyRecursiveTransforms(const ContentRectangle& element,
- ReversibleTransform* transform) {
+ ReversibleTransform* transform,
+ float* opacity) {
transform->Scale(element.scale.x, element.scale.y, element.scale.z);
transform->Rotate(element.rotation.x, element.rotation.y,
element.rotation.z, element.rotation.angle);
transform->Translate(element.translation.x, element.translation.y,
element.translation.z);
+ *opacity *= element.opacity;
if (element.parent_id >= 0) {
const ContentRectangle* parent = GetUiElementById(element.parent_id);
CHECK(parent != nullptr);
ApplyAnchoring(*parent, element.x_anchoring, element.y_anchoring,
transform);
- ApplyRecursiveTransforms(*parent, transform);
+ ApplyRecursiveTransforms(*parent, transform, opacity);
}
}
@@ -385,6 +392,10 @@ void UiScene::ApplyDictToElement(const base::DictionaryValue& dict,
ParseVec3f(dict, "scale", &element->scale);
ParseRotationAxisAngle(dict, "rotation", &element->rotation);
ParseVec3f(dict, "translation", &element->translation);
+ double opacity;
+ if (dict.GetDouble("opacity", &opacity)) {
+ element->opacity = opacity;
+ }
if (dict.GetBoolean("contentQuad", &element->content_quad)) {
if (element->content_quad) {
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene.h ('k') | chrome/browser/android/vr_shell/ui_scene_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698