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;
}
@Override
public void updateProgramAndDraw(long presentationTimeUs) {
public void drawFrame(long presentationTimeUs) {
checkStateNotNull(glProgram);
glProgram.use();
......
......@@ -105,7 +105,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
@Override
public void updateProgramAndDraw(long presentationTimeUs) {
public void drawFrame(long presentationTimeUs) {
checkStateNotNull(glProgram).use();
double theta = presentationTimeUs * 2 * Math.PI / DIMMING_PERIOD_US;
float innerRadius = minInnerRadius + deltaInnerRadius * (0.5f - 0.5f * (float) Math.cos(theta));
......
......@@ -86,14 +86,14 @@ public final class AdvancedFrameProcessorPixelTest {
}
@Test
public void updateProgramAndDraw_noEdits_producesExpectedOutput() throws Exception {
String testId = "updateProgramAndDraw_noEdits";
public void drawFrame_noEdits_producesExpectedOutput() throws Exception {
String testId = "drawFrame_noEdits";
Matrix identityMatrix = new Matrix();
advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), identityMatrix);
advancedFrameProcessor.initialize(inputTexId, width, height);
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(FIRST_FRAME_PNG_ASSET_STRING);
advancedFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap =
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
......@@ -107,8 +107,8 @@ public final class AdvancedFrameProcessorPixelTest {
}
@Test
public void updateProgramAndDraw_translateRight_producesExpectedOutput() throws Exception {
String testId = "updateProgramAndDraw_translateRight";
public void drawFrame_translateRight_producesExpectedOutput() throws Exception {
String testId = "drawFrame_translateRight";
Matrix translateRightMatrix = new Matrix();
translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0);
advancedFrameProcessor =
......@@ -117,7 +117,7 @@ public final class AdvancedFrameProcessorPixelTest {
Bitmap expectedBitmap =
BitmapTestUtil.readBitmap(TRANSLATE_RIGHT_EXPECTED_OUTPUT_PNG_ASSET_STRING);
advancedFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap =
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
......@@ -131,8 +131,8 @@ public final class AdvancedFrameProcessorPixelTest {
}
@Test
public void updateProgramAndDraw_scaleNarrow_producesExpectedOutput() throws Exception {
String testId = "updateProgramAndDraw_scaleNarrow";
public void drawFrame_scaleNarrow_producesExpectedOutput() throws Exception {
String testId = "drawFrame_scaleNarrow";
Matrix scaleNarrowMatrix = new Matrix();
scaleNarrowMatrix.postScale(.5f, 1.2f);
advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), scaleNarrowMatrix);
......@@ -140,7 +140,7 @@ public final class AdvancedFrameProcessorPixelTest {
Bitmap expectedBitmap =
BitmapTestUtil.readBitmap(SCALE_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
advancedFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap =
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
......@@ -154,15 +154,15 @@ public final class AdvancedFrameProcessorPixelTest {
}
@Test
public void updateProgramAndDraw_rotate90_producesExpectedOutput() throws Exception {
String testId = "updateProgramAndDraw_rotate90";
public void drawFrame_rotate90_producesExpectedOutput() throws Exception {
String testId = "drawFrame_rotate90";
Matrix rotate90Matrix = new Matrix();
rotate90Matrix.postRotate(/* degrees= */ 90);
advancedFrameProcessor = new AdvancedFrameProcessor(getApplicationContext(), rotate90Matrix);
advancedFrameProcessor.initialize(inputTexId, width, height);
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(ROTATE_90_EXPECTED_OUTPUT_PNG_ASSET_STRING);
advancedFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
advancedFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
Bitmap actualBitmap =
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(width, height);
......
......@@ -146,7 +146,7 @@ public final class FrameProcessorChainTest {
}
@Override
public void updateProgramAndDraw(long presentationTimeNs) {}
public void drawFrame(long presentationTimeNs) {}
@Override
public void release() {}
......
......@@ -185,7 +185,7 @@ public final class AdvancedFrameProcessor implements GlFrameProcessor {
}
@Override
public void updateProgramAndDraw(long presentationTimeUs) {
public void drawFrame(long presentationTimeUs) {
checkStateNotNull(glProgram).use();
glProgram.setFloatsUniform(
"uTransformationMatrix", matrixProvider.getGlMatrixArray(presentationTimeUs));
......
......@@ -103,7 +103,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
@Override
public void updateProgramAndDraw(long presentationTimeUs) {
public void drawFrame(long presentationTimeUs) {
checkStateNotNull(glProgram);
glProgram.use();
glProgram.bindAttributesAndUniforms();
......
......@@ -446,12 +446,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
intermediateSize.getWidth(),
intermediateSize.getHeight());
clearOutputFrame();
frameProcessors.get(i).updateProgramAndDraw(presentationTimeUs);
frameProcessors.get(i).drawFrame(presentationTimeUs);
}
GlUtil.focusEglSurface(
eglDisplay, eglContext, eglSurface, outputSize.getWidth(), outputSize.getHeight());
clearOutputFrame();
getLast(frameProcessors).updateProgramAndDraw(presentationTimeUs);
getLast(frameProcessors).drawFrame(presentationTimeUs);
EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, presentationTimeNs);
EGL14.eglSwapBuffers(eglDisplay, eglSurface);
......
......@@ -26,7 +26,7 @@ import java.io.IOException;
* <ol>
* <li>The constructor, for implementation-specific arguments.
* <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.
* </ol>
*/
......@@ -45,8 +45,7 @@ public interface GlFrameProcessor {
void initialize(int inputTexId, int inputWidth, int inputHeight) throws IOException;
/**
* Returns the output {@link Size} of frames processed through {@link
* #updateProgramAndDraw(long)}.
* Returns the output {@link Size} of frames processed through {@link #drawFrame(long)}.
*
* <p>This method may only be called after the frame processor has been {@link
* #initialize(int,int,int) initialized}.
......@@ -54,15 +53,18 @@ public interface GlFrameProcessor {
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
* #initialize(int,int,int) initialized}. The caller is responsible for focussing the correct
* 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.
*/
void updateProgramAndDraw(long presentationTimeUs);
void drawFrame(long presentationTimeUs);
/** Releases all resources. */
void release();
......
......@@ -266,8 +266,8 @@ public final class PresentationFrameProcessor implements GlFrameProcessor {
}
@Override
public void updateProgramAndDraw(long presentationTimeUs) {
checkStateNotNull(advancedFrameProcessor).updateProgramAndDraw(presentationTimeUs);
public void drawFrame(long presentationTimeUs) {
checkStateNotNull(advancedFrameProcessor).drawFrame(presentationTimeUs);
}
@Override
......
......@@ -132,8 +132,8 @@ public final class ScaleToFitFrameProcessor implements GlFrameProcessor {
}
@Override
public void updateProgramAndDraw(long presentationTimeUs) {
checkStateNotNull(advancedFrameProcessor).updateProgramAndDraw(presentationTimeUs);
public void drawFrame(long presentationTimeUs) {
checkStateNotNull(advancedFrameProcessor).drawFrame(presentationTimeUs);
}
@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