Commit 486117c9 authored by Christopher Grant's avatar Christopher Grant Committed by Commit Bot

VR: Add a dummy content quad to the testapp

BUG=
R=tiborg

Change-Id: Id4180e06908fdb4e07bc73cec25d15204d119bdf
Reviewed-on: https://chromium-review.googlesource.com/693222Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Christopher Grant <cjgrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505781}
parent 8e469acd
......@@ -256,7 +256,8 @@ void VrShellGl::InitializeGl(gfx::AcceleratedWidget window) {
InitializeRenderer();
ui_->OnGlInitialized(content_texture_id);
ui_->OnGlInitialized(content_texture_id,
vr::UiElementRenderer::kTextureLocationExternal);
webvr_vsync_align_ = base::FeatureList::IsEnabled(features::kWebVrVsyncAlign);
......
......@@ -24,8 +24,7 @@ void ContentElement::Render(
if (!texture_id_)
return;
gfx::RectF copy_rect(0, 0, 1, 1);
renderer->DrawTexturedQuad(texture_id_,
UiElementRenderer::kTextureLocationExternal,
renderer->DrawTexturedQuad(texture_id_, texture_location_,
model_view_proj_matrix, copy_rect,
computed_opacity(), size(), corner_radius());
}
......@@ -76,4 +75,10 @@ void ContentElement::OnScrollEnd(
delegate_->OnContentScrollEnd(std::move(gesture), position);
}
void ContentElement::SetTexture(unsigned int texture_id,
UiElementRenderer::TextureLocation location) {
texture_id_ = texture_id;
texture_location_ = location;
}
} // namespace vr
......@@ -8,6 +8,7 @@
#include "base/macros.h"
#include "chrome/browser/vr/content_input_delegate.h"
#include "chrome/browser/vr/elements/ui_element.h"
#include "chrome/browser/vr/ui_element_renderer.h"
namespace vr {
......@@ -37,11 +38,14 @@ class ContentElement : public UiElement {
void Render(UiElementRenderer* renderer,
const gfx::Transform& model_view_proj_matrix) const final;
void set_texture_id(unsigned int texture_id) { texture_id_ = texture_id; }
void SetTexture(unsigned int texture_id,
UiElementRenderer::TextureLocation location);
private:
ContentInputDelegate* delegate_ = nullptr;
unsigned int texture_id_ = 0;
UiElementRenderer::TextureLocation texture_location_ =
UiElementRenderer::kTextureLocationExternal;
};
} // namespace vr
......
......@@ -54,7 +54,8 @@ void UiPixelTest::MakeUi(const UiInitialState& ui_initial_state,
const ToolbarState& toolbar_state) {
ui_ = base::MakeUnique<Ui>(browser_.get(), content_input_delegate_.get(),
ui_initial_state);
ui_->OnGlInitialized(content_texture_);
ui_->OnGlInitialized(content_texture_,
vr::UiElementRenderer::kTextureLocationLocal);
ui_->GetBrowserUiWeakPtr()->SetToolbarState(toolbar_state);
}
......
......@@ -20,6 +20,8 @@
#include "components/security_state/core/security_state.h"
#include "components/toolbar/vector_icons.h"
#include "third_party/WebKit/public/platform/WebGestureEvent.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/dom/dom_code.h"
......@@ -180,8 +182,32 @@ void VrTestContext::HandleInput(ui::Event* event) {
}
void VrTestContext::OnGlInitialized(const gfx::Size& window_size) {
unsigned int content_texture_id = CreateFakeContentTexture();
window_size_ = window_size;
ui_->OnGlInitialized(0);
ui_->OnGlInitialized(content_texture_id,
UiElementRenderer::kTextureLocationLocal);
}
unsigned int VrTestContext::CreateFakeContentTexture() {
sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(1, 1);
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0xFF000080);
SkPixmap pixmap;
CHECK(surface->peekPixels(&pixmap));
SkColorType type = pixmap.colorType();
DCHECK(type == kRGBA_8888_SkColorType || type == kBGRA_8888_SkColorType);
GLint format = (type == kRGBA_8888_SkColorType ? GL_RGBA : GL_BGRA);
unsigned int texture_id;
glGenTextures(1, &texture_id);
glBindTexture(GL_TEXTURE_2D, texture_id);
glTexImage2D(GL_TEXTURE_2D, 0, format, pixmap.width(), pixmap.height(), 0,
format, GL_UNSIGNED_BYTE, pixmap.addr());
return texture_id;
}
void VrTestContext::OnContentEnter(const gfx::PointF& normalized_hit_point) {}
......
......@@ -62,6 +62,8 @@ class VrTestContext : public vr::ContentInputDelegate,
void OnContentScreenBoundsChanged(const gfx::SizeF& bounds) override;
private:
unsigned int CreateFakeContentTexture();
std::unique_ptr<Ui> ui_;
gfx::Size window_size_;
......
......@@ -100,11 +100,12 @@ bool Ui::ShouldRenderWebVr() {
return scene_manager_->ShouldRenderWebVr();
}
void Ui::OnGlInitialized(unsigned int content_texture_id) {
void Ui::OnGlInitialized(unsigned int content_texture_id,
UiElementRenderer::TextureLocation content_location) {
vr_shell_renderer_ = base::MakeUnique<vr::VrShellRenderer>();
ui_renderer_ =
base::MakeUnique<vr::UiRenderer>(scene_.get(), vr_shell_renderer_.get());
scene_manager_->OnGlInitialized(content_texture_id);
scene_manager_->OnGlInitialized(content_texture_id, content_location);
}
void Ui::OnAppButtonClicked() {
......
......@@ -68,7 +68,9 @@ class Ui : public BrowserUiInterface, public UiInterface {
// UiInterface
bool ShouldRenderWebVr() override;
void OnGlInitialized(unsigned int content_texture_id) override;
void OnGlInitialized(
unsigned int content_texture_id,
UiElementRenderer::TextureLocation content_location) override;
void OnAppButtonClicked() override;
void OnAppButtonGesturePerformed(UiInterface::Direction direction) override;
void OnProjMatrixChanged(const gfx::Transform& proj_matrix) override;
......
......@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_VR_UI_INTERFACE_H_
#define CHROME_BROWSER_VR_UI_INTERFACE_H_
#include "ui_element_renderer.h"
namespace gfx {
class Transform;
}
......@@ -26,7 +28,9 @@ class UiInterface {
virtual bool ShouldRenderWebVr() = 0;
virtual void OnGlInitialized(unsigned int content_texture_id) = 0;
virtual void OnGlInitialized(
unsigned int content_texture_id,
UiElementRenderer::TextureLocation content_location) = 0;
virtual void OnAppButtonClicked() = 0;
virtual void OnAppButtonGesturePerformed(
UiInterface::Direction direction) = 0;
......
......@@ -812,8 +812,10 @@ bool UiSceneManager::ShouldRenderWebVr() {
return scene_->web_vr_rendering_enabled();
}
void UiSceneManager::OnGlInitialized(unsigned int content_texture_id) {
main_content_->set_texture_id(content_texture_id);
void UiSceneManager::OnGlInitialized(
unsigned int content_texture_id,
UiElementRenderer::TextureLocation content_location) {
main_content_->SetTexture(content_texture_id, content_location);
scene_->OnGlInitialized();
ConfigureScene();
......
......@@ -114,7 +114,9 @@ class UiSceneManager : public UiInterface, public BrowserUiInterface {
// UiInterface.
bool ShouldRenderWebVr() override;
void OnGlInitialized(unsigned int content_texture_id) override;
void OnGlInitialized(
unsigned int content_texture_id,
UiElementRenderer::TextureLocation content_location) override;
void OnAppButtonClicked() override;
void OnAppButtonGesturePerformed(UiInterface::Direction direction) override;
void OnProjMatrixChanged(const gfx::Transform& proj_matrix) override;
......
......@@ -638,7 +638,7 @@ TEST_F(UiSceneManagerTest, RendererUsesCorrectOpacity) {
ContentElement* content_element =
static_cast<ContentElement*>(scene_->GetUiElementByName(kContentQuad));
content_element->set_texture_id(1);
content_element->SetTexture(0, vr::UiElementRenderer::kTextureLocationLocal);
TexturedElement::SetInitializedForTesting();
CheckRendererOpacityRecursive(&scene_->root_element());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment