Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58a7ac4c authored by Jan Sebechlebsky's avatar Jan Sebechlebsky
Browse files

Use timestamp instead of frame number when generating test pattern.

Frame number is reset upon reconfiguration and causes test pattern
to be generated from point 0 as well.

Bug: 301023410
Test: manually with OpenCamera
Change-Id: Ib037293117b8ce4f143af2d36fa6aa94845c5efb
parent 66ef83f3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ void TestPatternRenderer::renderThreadLoop(
    }

    // Render the test pattern and update timestamp.
    testPatternProgram.draw(frameNumber++);
    testPatternProgram.draw(ts);
    eglDisplayContext.swapBuffers();
    lastFrameTs = getCurrentTimestamp();
  }
+2 −3
Original line number Diff line number Diff line
@@ -229,13 +229,12 @@ EglTestPatternProgram::EglTestPatternProgram() {
                        kTextureCoords.size(), kTextureCoords.data());
}

bool EglTestPatternProgram::draw(int frameNumber) {
bool EglTestPatternProgram::draw(const std::chrono::nanoseconds timestamp) {
  // Load compiled shader.
  glUseProgram(mProgram);
  checkEglError("glUseProgram");

  // Compute point in complex plane corresponding to fractal for this frame number.
  float time = float(frameNumber) / 120.0f;
  float time = float(timestamp.count() / 1e9) / 10;
  const std::complex<float> c(std::sin(time) * 0.78f, std::cos(time) * 0.78f);

  // Pass "C" constant value determining the Julia set to the shader.
+2 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define ANDROID_COMPANION_VIRTUALCAMERA_EGLPROGRAM_H

#include <array>
#include <chrono>

#include "GLES/gl.h"

@@ -46,7 +47,7 @@ class EglTestPatternProgram : public EglProgram {
 public:
  EglTestPatternProgram();

  bool draw(int frameNumber);
  bool draw(std::chrono::nanoseconds timestamp);

 private:
  int mPositionHandle = -1;