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

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

Issue 2683953007: Support rendering Android Native Pages in VR Shell. (Closed)
Patch Set: rebase Created 3 years, 10 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_interface.cc ('k') | chrome/browser/android/vr_shell/vr_shell.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_compositor.cc
diff --git a/chrome/browser/android/vr_shell/vr_compositor.cc b/chrome/browser/android/vr_shell/vr_compositor.cc
index f22271aed3c87278a9b9c727aab1ea0233536996..de60da7dd488b5c21f27909756e3460720ebed81 100644
--- a/chrome/browser/android/vr_shell/vr_compositor.cc
+++ b/chrome/browser/android/vr_shell/vr_compositor.cc
@@ -4,7 +4,10 @@
#include "chrome/browser/android/vr_shell/vr_compositor.h"
+#include <utility>
+
#include "cc/layers/layer.h"
+#include "cc/layers/solid_color_layer.h"
#include "content/public/browser/android/compositor.h"
#include "content/public/browser/web_contents.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -20,8 +23,7 @@ VrCompositor::VrCompositor(ui::WindowAndroid* window, bool transparent)
}
VrCompositor::~VrCompositor() {
- if (layer_)
- RestoreLayer();
+ RestoreLayer();
}
void VrCompositor::UpdateLayerTreeHost() {}
@@ -29,8 +31,13 @@ void VrCompositor::UpdateLayerTreeHost() {}
void VrCompositor::OnSwapBuffersCompleted(int pending_swap_buffers) {}
void VrCompositor::SetLayer(content::WebContents* web_contents) {
- if (layer_)
- RestoreLayer();
+ RestoreLayer();
+ if (!web_contents) {
+ scoped_refptr<cc::SolidColorLayer> layer = cc::SolidColorLayer::Create();
+ layer->SetBackgroundColor(SK_ColorTRANSPARENT);
+ compositor_->SetRootLayer(std::move(layer));
+ return;
+ }
ui::ViewAndroid* view_android = web_contents->GetNativeView();
// When we pass the layer for the ContentViewCore to the compositor it may be
@@ -48,10 +55,13 @@ void VrCompositor::SetLayer(content::WebContents* web_contents) {
}
void VrCompositor::RestoreLayer() {
+ if (!layer_)
+ return;
layer_->SetBackgroundColor(background_color_);
if (layer_parent_) {
layer_parent_->AddChild(layer_);
}
+ layer_ = nullptr;
}
void VrCompositor::SurfaceDestroyed() {
@@ -63,7 +73,6 @@ void VrCompositor::SetWindowBounds(gfx::Size size) {
}
void VrCompositor::SurfaceChanged(jobject surface) {
- DCHECK(surface);
compositor_->SetSurface(surface);
}
« no previous file with comments | « chrome/browser/android/vr_shell/ui_interface.cc ('k') | chrome/browser/android/vr_shell/vr_shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698