Commit ab259835 authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[CRD iOS] Feed viewport transformation matrix when renderer context is recreated

The app no longer renders the first frame after we recreate the renderer
context when the app resumes. User has to move the cursor or viewport
to get the frame rendered. That's because we didn't set the transformation
matrix after the renderer context is recreated.

This CL makes GlRenderer cache the viewport matrix and set it on the
canvas when the canvas is recreated.

Bug: 836975
Change-Id: I3d4bb2575aa59f9148181104f320cf7a72770ad5
Reviewed-on: https://chromium-review.googlesource.com/1028848
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553841}
parent 9cc202d3
...@@ -52,9 +52,8 @@ void GlRenderer::RequestCanvasSize() { ...@@ -52,9 +52,8 @@ void GlRenderer::RequestCanvasSize() {
void GlRenderer::OnPixelTransformationChanged( void GlRenderer::OnPixelTransformationChanged(
const std::array<float, 9>& matrix) { const std::array<float, 9>& matrix) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
transformation_matrix_ = matrix;
if (!canvas_) { if (!canvas_) {
VLOG(1) << "Trying to set transformation matrix when the canvas is not "
<< "ready.";
return; return;
} }
canvas_->SetTransformationMatrix(matrix); canvas_->SetTransformationMatrix(matrix);
...@@ -109,6 +108,9 @@ void GlRenderer::OnSurfaceCreated(std::unique_ptr<Canvas> canvas) { ...@@ -109,6 +108,9 @@ void GlRenderer::OnSurfaceCreated(std::unique_ptr<Canvas> canvas) {
if (view_width_ > 0 && view_height_ > 0) { if (view_width_ > 0 && view_height_ > 0) {
canvas_->SetViewSize(view_width_, view_height_); canvas_->SetViewSize(view_width_, view_height_);
} }
if (transformation_matrix_) {
canvas_->SetTransformationMatrix(*transformation_matrix_);
}
for (auto& drawable : drawables_) { for (auto& drawable : drawables_) {
drawable->SetCanvas(canvas_->GetWeakPtr()); drawable->SetCanvas(canvas_->GetWeakPtr());
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/containers/queue.h" #include "base/containers/queue.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "remoting/client/display/gl_cursor.h" #include "remoting/client/display/gl_cursor.h"
#include "remoting/client/display/gl_cursor_feedback.h" #include "remoting/client/display/gl_cursor_feedback.h"
...@@ -51,6 +52,7 @@ class GlRenderer { ...@@ -51,6 +52,7 @@ class GlRenderer {
// recreated. // recreated.
void RequestCanvasSize(); void RequestCanvasSize();
// TODO(yuweih): Use ViewMatrix instead of the 3x3 array.
// Sets the pixel based transformation matrix related to the size of the // Sets the pixel based transformation matrix related to the size of the
// canvas. // canvas.
// 3 by 3 transformation matrix, [ m0, m1, m2, m3, m4, m5, m6, m7, m8 ]. // 3 by 3 transformation matrix, [ m0, m1, m2, m3, m4, m5, m6, m7, m8 ].
...@@ -133,6 +135,9 @@ class GlRenderer { ...@@ -133,6 +135,9 @@ class GlRenderer {
std::unique_ptr<Canvas> canvas_; std::unique_ptr<Canvas> canvas_;
// Used to recover the transformation matrix when the canvas is recreated.
base::Optional<std::array<float, 9>> transformation_matrix_;
GlCursor cursor_; GlCursor cursor_;
GlCursorFeedback cursor_feedback_; GlCursorFeedback cursor_feedback_;
GlDesktop desktop_; GlDesktop desktop_;
......
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