Commit fe7e330f by hschlueter Committed by Ian Baker

Rename GlFrameProcessor updateProgramAndDraw to drawFrame.

What a minimal implementation should include is now explained in the
interface javadoc while the method name reflects what the method does.

PiperOrigin-RevId: 441432059
parent f4e0339e
...@@ -117,7 +117,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -117,7 +117,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
@Override @Override
public void updateProgramAndDraw(long presentationTimeUs) { public void drawFrame(long presentationTimeUs) {
checkStateNotNull(glProgram); checkStateNotNull(glProgram);
glProgram.use(); glProgram.use();
......
...@@ -105,7 +105,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -105,7 +105,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
@Override @Override
public void updateProgramAndDraw(long presentationTimeUs) { public void drawFrame(long presentationTimeUs) {
checkStateNotNull(glProgram).use(); checkStateNotNull(glProgram).use();
double theta = presentationTimeUs * 2 * Math.PI / DIMMING_PERIOD_US; double theta = presentationTimeUs * 2 * Math.PI / DIMMING_PERIOD_US;
float innerRadius = minInnerRadius + deltaInnerRadius * (0.5f - 0.5f * (float) Math.cos(theta)); float innerRadius = minInnerRadius + deltaInnerRadius * (0.5f - 0.5f * (float) Math.cos(theta));
......
...@@ -86,14 +86,14 @@ public final class AdvancedFrameProcessorPixelTest { ...@@ -86,14 +86,14 @@ public final class AdvancedFrameProcessorPixelTest {
} }
@Test @Test
public void updateProgramAndDraw_noEdits_producesExpectedOutput() throws Exception { public void drawFrame_noEdits_producesExpectedOutput() throws Exception {
String testId = "updateProgramAndDraw_noEdits"; String testId = "drawFrame_noEdits";
Matrix identityMatrix = new Matrix(); Matrix identityMatrix = new Matrix();
advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), identityMatrix); advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), identityMatrix);
advancedFrameProcessor.initialize(inputTexId, width, height); advancedFrameProcessor.initialize(inputTexId, width, height);
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(FIRST_FRAME_PNG_ASSET_STRING); Bitmap expectedBitmap = BitmapTestUtil.readBitmap(FIRST_FRAME_PNG_ASSET_STRING);
advancedFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0); advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height); BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
...@@ -107,8 +107,8 @@ public final class AdvancedFrameProcessorPixelTest { ...@@ -107,8 +107,8 @@ public final class AdvancedFrameProcessorPixelTest {
} }
@Test @Test
public void updateProgramAndDraw_translateRight_producesExpectedOutput() throws Exception { public void drawFrame_translateRight_producesExpectedOutput() throws Exception {
String testId = "updateProgramAndDraw_translateRight"; String testId = "drawFrame_translateRight";
Matrix translateRightMatrix = new Matrix(); Matrix translateRightMatrix = new Matrix();
translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0); translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0);
advancedFrameProcessor = advancedFrameProcessor =
...@@ -117,7 +117,7 @@ public final class AdvancedFrameProcessorPixelTest { ...@@ -117,7 +117,7 @@ public final class AdvancedFrameProcessorPixelTest {
Bitmap expectedBitmap = Bitmap expectedBitmap =
BitmapTestUtil.readBitmap(TRANSLATE_RIGHT_EXPECTED_OUTPUT_PNG_ASSET_STRING); BitmapTestUtil.readBitmap(TRANSLATE_RIGHT_EXPECTED_OUTPUT_PNG_ASSET_STRING);
advancedFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0); advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height); BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
...@@ -131,8 +131,8 @@ public final class AdvancedFrameProcessorPixelTest { ...@@ -131,8 +131,8 @@ public final class AdvancedFrameProcessorPixelTest {
} }
@Test @Test
public void updateProgramAndDraw_scaleNarrow_producesExpectedOutput() throws Exception { public void drawFrame_scaleNarrow_producesExpectedOutput() throws Exception {
String testId = "updateProgramAndDraw_scaleNarrow"; String testId = "drawFrame_scaleNarrow";
Matrix scaleNarrowMatrix = new Matrix(); Matrix scaleNarrowMatrix = new Matrix();
scaleNarrowMatrix.postScale(.5f, 1.2f); scaleNarrowMatrix.postScale(.5f, 1.2f);
advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), scaleNarrowMatrix); advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), scaleNarrowMatrix);
...@@ -140,7 +140,7 @@ public final class AdvancedFrameProcessorPixelTest { ...@@ -140,7 +140,7 @@ public final class AdvancedFrameProcessorPixelTest {
Bitmap expectedBitmap = Bitmap expectedBitmap =
BitmapTestUtil.readBitmap(SCALE_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING); BitmapTestUtil.readBitmap(SCALE_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
advancedFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0); advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height); BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
...@@ -154,15 +154,15 @@ public final class AdvancedFrameProcessorPixelTest { ...@@ -154,15 +154,15 @@ public final class AdvancedFrameProcessorPixelTest {
} }
@Test @Test
public void updateProgramAndDraw_rotate90_producesExpectedOutput() throws Exception { public void drawFrame_rotate90_producesExpectedOutput() throws Exception {
String testId = "updateProgramAndDraw_rotate90"; String testId = "drawFrame_rotate90";
Matrix rotate90Matrix = new Matrix(); Matrix rotate90Matrix = new Matrix();
rotate90Matrix.postRotate(/* degrees= */ 90); rotate90Matrix.postRotate(/* degrees= */ 90);
advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), rotate90Matrix); advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), rotate90Matrix);
advancedFrameProcessor.initialize(inputTexId, width, height); advancedFrameProcessor.initialize(inputTexId, width, height);
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_90_EXPECTED_OUTPUT_PNG_ASSET_STRING); Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_90_EXPECTED_OUTPUT_PNG_ASSET_STRING);
advancedFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0); advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap = Bitmap actualBitmap =
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height); BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
......
...@@ -146,7 +146,7 @@ public final class FrameProcessorChainTest { ...@@ -146,7 +146,7 @@ public final class FrameProcessorChainTest {
} }
@Override @Override
public void updateProgramAndDraw(long presentationTimeNs) {} public void drawFrame(long presentationTimeNs) {}
@Override @Override
public void release() {} public void release() {}
......
...@@ -185,7 +185,7 @@ public final class AdvancedFrameProcessor implements GlFrameProcessor { ...@@ -185,7 +185,7 @@ public final class AdvancedFrameProcessor implements GlFrameProcessor {
} }
@Override @Override
public void updateProgramAndDraw(long presentationTimeUs) { public void drawFrame(long presentationTimeUs) {
checkStateNotNull(glProgram).use(); checkStateNotNull(glProgram).use();
glProgram.setFloatsUniform( glProgram.setFloatsUniform(
"uTransformationMatrix", matrixProvider.getGlMatrixArray(presentationTimeUs)); "uTransformationMatrix", matrixProvider.getGlMatrixArray(presentationTimeUs));
......
...@@ -103,7 +103,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -103,7 +103,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
@Override @Override
public void updateProgramAndDraw(long presentationTimeUs) { public void drawFrame(long presentationTimeUs) {
checkStateNotNull(glProgram); checkStateNotNull(glProgram);
glProgram.use(); glProgram.use();
glProgram.bindAttributesAndUniforms(); glProgram.bindAttributesAndUniforms();
......
...@@ -446,12 +446,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -446,12 +446,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
intermediateSize.getWidth(), intermediateSize.getWidth(),
intermediateSize.getHeight()); intermediateSize.getHeight());
clearOutputFrame(); clearOutputFrame();
frameProcessors.get(i).updateProgramAndDraw(presentationTimeUs); frameProcessors.get(i).drawFrame(presentationTimeUs);
} }
GlUtil.focusEglSurface( GlUtil.focusEglSurface(
eglDisplay, eglContext, eglSurface, outputSize.getWidth(), outputSize.getHeight()); eglDisplay, eglContext, eglSurface, outputSize.getWidth(), outputSize.getHeight());
clearOutputFrame(); clearOutputFrame();
getLast(frameProcessors).updateProgramAndDraw(presentationTimeUs); getLast(frameProcessors).drawFrame(presentationTimeUs);
EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, presentationTimeNs); EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, presentationTimeNs);
EGL14.eglSwapBuffers(eglDisplay, eglSurface); EGL14.eglSwapBuffers(eglDisplay, eglSurface);
......
...@@ -26,7 +26,7 @@ import java.io.IOException; ...@@ -26,7 +26,7 @@ import java.io.IOException;
* <ol> * <ol>
* <li>The constructor, for implementation-specific arguments. * <li>The constructor, for implementation-specific arguments.
* <li>{@link #initialize(int,int,int)}, to set up graphics initialization. * <li>{@link #initialize(int,int,int)}, to set up graphics initialization.
* <li>{@link #updateProgramAndDraw(long)}, to process one frame. * <li>{@link #drawFrame(long)}, to process one frame.
* <li>{@link #release()}, upon conclusion of processing. * <li>{@link #release()}, upon conclusion of processing.
* </ol> * </ol>
*/ */
...@@ -45,8 +45,7 @@ public interface GlFrameProcessor { ...@@ -45,8 +45,7 @@ public interface GlFrameProcessor {
void initialize(int inputTexId, int inputWidth, int inputHeight) throws IOException; void initialize(int inputTexId, int inputWidth, int inputHeight) throws IOException;
/** /**
* Returns the output {@link Size} of frames processed through {@link * Returns the output {@link Size} of frames processed through {@link #drawFrame(long)}.
* #updateProgramAndDraw(long)}.
* *
* <p>This method may only be called after the frame processor has been {@link * <p>This method may only be called after the frame processor has been {@link
* #initialize(int,int,int) initialized}. * #initialize(int,int,int) initialized}.
...@@ -54,15 +53,18 @@ public interface GlFrameProcessor { ...@@ -54,15 +53,18 @@ public interface GlFrameProcessor {
Size getOutputSize(); Size getOutputSize();
/** /**
* Updates the shader program's vertex attributes and uniforms, binds them, and draws. * Draws one frame.
* *
* <p>This method may only be called after the frame processor has been {@link * <p>This method may only be called after the frame processor has been {@link
* #initialize(int,int,int) initialized}. The caller is responsible for focussing the correct * #initialize(int,int,int) initialized}. The caller is responsible for focussing the correct
* render target before calling this method. * render target before calling this method.
* *
* <p>A minimal implementation should tell OpenGL to use its shader program, bind the shader
* program's vertex attributes and uniforms, and issue a drawing command.
*
* @param presentationTimeUs The presentation timestamp of the current frame, in microseconds. * @param presentationTimeUs The presentation timestamp of the current frame, in microseconds.
*/ */
void updateProgramAndDraw(long presentationTimeUs); void drawFrame(long presentationTimeUs);
/** Releases all resources. */ /** Releases all resources. */
void release(); void release();
......
...@@ -266,8 +266,8 @@ public final class PresentationFrameProcessor implements GlFrameProcessor { ...@@ -266,8 +266,8 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
} }
@Override @Override
public void updateProgramAndDraw(long presentationTimeUs) { public void drawFrame(long presentationTimeUs) {
checkStateNotNull(advancedFrameProcessor).updateProgramAndDraw(presentationTimeUs); checkStateNotNull(advancedFrameProcessor).drawFrame(presentationTimeUs);
} }
@Override @Override
......
...@@ -132,8 +132,8 @@ public final class ScaleToFitFrameProcessor implements GlFrameProcessor { ...@@ -132,8 +132,8 @@ public final class ScaleToFitFrameProcessor implements GlFrameProcessor {
} }
@Override @Override
public void updateProgramAndDraw(long presentationTimeUs) { public void drawFrame(long presentationTimeUs) {
checkStateNotNull(advancedFrameProcessor).updateProgramAndDraw(presentationTimeUs); checkStateNotNull(advancedFrameProcessor).drawFrame(presentationTimeUs);
} }
@Override @Override
......
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 sign in to comment