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

Unified Diff: chrome/browser/android/vr_shell/ui_elements/textured_element.cc

Issue 2950173002: VR: System indicator rework. (Closed)
Patch Set: Address comments; increase size slightly for readability, now that position is dynamic. Created 3 years, 6 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
Index: chrome/browser/android/vr_shell/ui_elements/textured_element.cc
diff --git a/chrome/browser/android/vr_shell/ui_elements/textured_element.cc b/chrome/browser/android/vr_shell/ui_elements/textured_element.cc
index b4a065a5e9529e9a3db75a6cc6dd4ca6322e3812..e0a7a168f9546b1038c3694e415be72bc2e78a3c 100644
--- a/chrome/browser/android/vr_shell/ui_elements/textured_element.cc
+++ b/chrome/browser/android/vr_shell/ui_elements/textured_element.cc
@@ -26,9 +26,6 @@ void TexturedElement::Initialize() {
initialized_ = true;
UpdateTexture();
set_fill(Fill::SELF);
- gfx::SizeF drawn_size = GetTexture()->GetDrawnSize();
- float y = drawn_size.height() / drawn_size.width() * size().x();
- set_size({size().x(), y, 1});
}
void TexturedElement::UpdateTexture() {
@@ -38,6 +35,15 @@ void TexturedElement::UpdateTexture() {
texture_size_.width(), texture_size_.height());
GetTexture()->DrawAndLayout(surface->getCanvas(), texture_size_);
Flush(surface.get());
+ // Update the element size's aspect ratio to match the texture.
+ UpdateElementSize();
+}
+
+void TexturedElement::UpdateElementSize() {
+ // Updating the height according to width is a hack. This may be overridden.
+ gfx::SizeF drawn_size = GetTexture()->GetDrawnSize();
+ float y = drawn_size.height() / drawn_size.width() * size().x();
+ set_size({size().x(), y, 1});
}
void TexturedElement::Render(UiElementRenderer* renderer,

Powered by Google App Engine
This is Rietveld 408576698