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
This commit is contained in:
parent
d152fc2ac1
commit
f25c912c72
@ -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;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
|||||||
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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
|||||||
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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateProgramAndDraw(long presentationTimeNs) {}
|
public void drawFrame(long presentationTimeNs) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release() {}
|
public void release() {}
|
||||||
|
@ -90,8 +90,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateProgramAndDraw_noEdits_producesExpectedOutput() throws Exception {
|
public void drawFrame_noEdits_producesExpectedOutput() throws Exception {
|
||||||
String testId = "updateProgramAndDraw_noEdits";
|
String testId = "drawFrame_noEdits";
|
||||||
presentationFrameProcessor =
|
presentationFrameProcessor =
|
||||||
new PresentationFrameProcessor.Builder(getApplicationContext()).build();
|
new PresentationFrameProcessor.Builder(getApplicationContext()).build();
|
||||||
presentationFrameProcessor.initialize(inputTexId, inputWidth, inputHeight);
|
presentationFrameProcessor.initialize(inputTexId, inputWidth, inputHeight);
|
||||||
@ -99,7 +99,7 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||||
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(FIRST_FRAME_PNG_ASSET_STRING);
|
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(FIRST_FRAME_PNG_ASSET_STRING);
|
||||||
|
|
||||||
presentationFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
|
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||||
outputSize.getWidth(), outputSize.getHeight());
|
outputSize.getWidth(), outputSize.getHeight());
|
||||||
@ -114,8 +114,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateProgramAndDraw_cropSmaller_producesExpectedOutput() throws Exception {
|
public void drawFrame_cropSmaller_producesExpectedOutput() throws Exception {
|
||||||
String testId = "updateProgramAndDraw_cropSmaller";
|
String testId = "drawFrame_cropSmaller";
|
||||||
GlFrameProcessor presentationFrameProcessor =
|
GlFrameProcessor presentationFrameProcessor =
|
||||||
new PresentationFrameProcessor.Builder(getApplicationContext())
|
new PresentationFrameProcessor.Builder(getApplicationContext())
|
||||||
.setCrop(/* left= */ -.9f, /* right= */ .1f, /* bottom= */ -1f, /* top= */ .5f)
|
.setCrop(/* left= */ -.9f, /* right= */ .1f, /* bottom= */ -1f, /* top= */ .5f)
|
||||||
@ -126,7 +126,7 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap =
|
||||||
BitmapTestUtil.readBitmap(CROP_SMALLER_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
BitmapTestUtil.readBitmap(CROP_SMALLER_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
||||||
|
|
||||||
presentationFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
|
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||||
outputSize.getWidth(), outputSize.getHeight());
|
outputSize.getWidth(), outputSize.getHeight());
|
||||||
@ -141,8 +141,8 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateProgramAndDraw_cropLarger_producesExpectedOutput() throws Exception {
|
public void drawFrame_cropLarger_producesExpectedOutput() throws Exception {
|
||||||
String testId = "updateProgramAndDraw_cropSmaller";
|
String testId = "drawFrame_cropSmaller";
|
||||||
GlFrameProcessor presentationFrameProcessor =
|
GlFrameProcessor presentationFrameProcessor =
|
||||||
new PresentationFrameProcessor.Builder(getApplicationContext())
|
new PresentationFrameProcessor.Builder(getApplicationContext())
|
||||||
.setCrop(/* left= */ -2f, /* right= */ 2f, /* bottom= */ -1f, /* top= */ 2f)
|
.setCrop(/* left= */ -2f, /* right= */ 2f, /* bottom= */ -1f, /* top= */ 2f)
|
||||||
@ -152,7 +152,7 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
setupOutputTexture(outputSize.getWidth(), outputSize.getHeight());
|
||||||
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(CROP_LARGER_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
Bitmap expectedBitmap = BitmapTestUtil.readBitmap(CROP_LARGER_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
||||||
|
|
||||||
presentationFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
|
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||||
outputSize.getWidth(), outputSize.getHeight());
|
outputSize.getWidth(), outputSize.getHeight());
|
||||||
@ -167,9 +167,9 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateProgramAndDraw_changeAspectRatio_scaleToFit_narrow_producesExpectedOutput()
|
public void drawFrame_changeAspectRatio_scaleToFit_narrow_producesExpectedOutput()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
String testId = "updateProgramAndDraw_changeAspectRatio_scaleToFit_narrow";
|
String testId = "drawFrame_changeAspectRatio_scaleToFit_narrow";
|
||||||
presentationFrameProcessor =
|
presentationFrameProcessor =
|
||||||
new PresentationFrameProcessor.Builder(getApplicationContext())
|
new PresentationFrameProcessor.Builder(getApplicationContext())
|
||||||
.setAspectRatio(1f, PresentationFrameProcessor.SCALE_TO_FIT)
|
.setAspectRatio(1f, PresentationFrameProcessor.SCALE_TO_FIT)
|
||||||
@ -181,7 +181,7 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
BitmapTestUtil.readBitmap(
|
BitmapTestUtil.readBitmap(
|
||||||
ASPECT_RATIO_SCALE_TO_FIT_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
ASPECT_RATIO_SCALE_TO_FIT_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
||||||
|
|
||||||
presentationFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
|
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||||
outputSize.getWidth(), outputSize.getHeight());
|
outputSize.getWidth(), outputSize.getHeight());
|
||||||
@ -196,9 +196,9 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateProgramAndDraw_changeAspectRatio_scaleToFit_wide_producesExpectedOutput()
|
public void drawFrame_changeAspectRatio_scaleToFit_wide_producesExpectedOutput()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
String testId = "updateProgramAndDraw_changeAspectRatio_scaleToFit_wide";
|
String testId = "drawFrame_changeAspectRatio_scaleToFit_wide";
|
||||||
presentationFrameProcessor =
|
presentationFrameProcessor =
|
||||||
new PresentationFrameProcessor.Builder(getApplicationContext())
|
new PresentationFrameProcessor.Builder(getApplicationContext())
|
||||||
.setAspectRatio(2f, PresentationFrameProcessor.SCALE_TO_FIT)
|
.setAspectRatio(2f, PresentationFrameProcessor.SCALE_TO_FIT)
|
||||||
@ -209,7 +209,7 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
Bitmap expectedBitmap =
|
Bitmap expectedBitmap =
|
||||||
BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
BitmapTestUtil.readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
||||||
|
|
||||||
presentationFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
|
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||||
outputSize.getWidth(), outputSize.getHeight());
|
outputSize.getWidth(), outputSize.getHeight());
|
||||||
@ -224,10 +224,9 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void
|
public void drawFrame_changeAspectRatio_scaleToFitWithCrop_narrow_producesExpectedOutput()
|
||||||
updateProgramAndDraw_changeAspectRatio_scaleToFitWithCrop_narrow_producesExpectedOutput()
|
throws Exception {
|
||||||
throws Exception {
|
String testId = "drawFrame_changeAspectRatio_scaleToFitWithCrop_narrow";
|
||||||
String testId = "updateProgramAndDraw_changeAspectRatio_scaleToFitWithCrop_narrow";
|
|
||||||
presentationFrameProcessor =
|
presentationFrameProcessor =
|
||||||
new PresentationFrameProcessor.Builder(getApplicationContext())
|
new PresentationFrameProcessor.Builder(getApplicationContext())
|
||||||
.setAspectRatio(1f, PresentationFrameProcessor.SCALE_TO_FIT_WITH_CROP)
|
.setAspectRatio(1f, PresentationFrameProcessor.SCALE_TO_FIT_WITH_CROP)
|
||||||
@ -239,7 +238,7 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
BitmapTestUtil.readBitmap(
|
BitmapTestUtil.readBitmap(
|
||||||
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
||||||
|
|
||||||
presentationFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
|
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||||
outputSize.getWidth(), outputSize.getHeight());
|
outputSize.getWidth(), outputSize.getHeight());
|
||||||
@ -254,10 +253,9 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void
|
public void drawFrame_changeAspectRatio_scaleToFitWithCrop_wide_producesExpectedOutput()
|
||||||
updateProgramAndDraw_changeAspectRatio_scaleToFitWithCrop_wide_producesExpectedOutput()
|
throws Exception {
|
||||||
throws Exception {
|
String testId = "drawFrame_changeAspectRatio_scaleToFitWithCrop_wide";
|
||||||
String testId = "updateProgramAndDraw_changeAspectRatio_scaleToFitWithCrop_wide";
|
|
||||||
presentationFrameProcessor =
|
presentationFrameProcessor =
|
||||||
new PresentationFrameProcessor.Builder(getApplicationContext())
|
new PresentationFrameProcessor.Builder(getApplicationContext())
|
||||||
.setAspectRatio(2f, PresentationFrameProcessor.SCALE_TO_FIT_WITH_CROP)
|
.setAspectRatio(2f, PresentationFrameProcessor.SCALE_TO_FIT_WITH_CROP)
|
||||||
@ -269,7 +267,7 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
BitmapTestUtil.readBitmap(
|
BitmapTestUtil.readBitmap(
|
||||||
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
||||||
|
|
||||||
presentationFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
|
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||||
outputSize.getWidth(), outputSize.getHeight());
|
outputSize.getWidth(), outputSize.getHeight());
|
||||||
@ -284,9 +282,9 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateProgramAndDraw_changeAspectRatio_stretchToFit_narrow_producesExpectedOutput()
|
public void drawFrame_changeAspectRatio_stretchToFit_narrow_producesExpectedOutput()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
String testId = "updateProgramAndDraw_changeAspectRatio_stretchToFit_narrow";
|
String testId = "drawFrame_changeAspectRatio_stretchToFit_narrow";
|
||||||
presentationFrameProcessor =
|
presentationFrameProcessor =
|
||||||
new PresentationFrameProcessor.Builder(getApplicationContext())
|
new PresentationFrameProcessor.Builder(getApplicationContext())
|
||||||
.setAspectRatio(1f, PresentationFrameProcessor.STRETCH_TO_FIT)
|
.setAspectRatio(1f, PresentationFrameProcessor.STRETCH_TO_FIT)
|
||||||
@ -298,7 +296,7 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
BitmapTestUtil.readBitmap(
|
BitmapTestUtil.readBitmap(
|
||||||
ASPECT_RATIO_STRETCH_TO_FIT_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
ASPECT_RATIO_STRETCH_TO_FIT_NARROW_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
||||||
|
|
||||||
presentationFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
|
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||||
outputSize.getWidth(), outputSize.getHeight());
|
outputSize.getWidth(), outputSize.getHeight());
|
||||||
@ -313,9 +311,9 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateProgramAndDraw_changeAspectRatio_stretchToFit_wide_producesExpectedOutput()
|
public void drawFrame_changeAspectRatio_stretchToFit_wide_producesExpectedOutput()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
String testId = "updateProgramAndDraw_changeAspectRatio_stretchToFit_wide";
|
String testId = "drawFrame_changeAspectRatio_stretchToFit_wide";
|
||||||
presentationFrameProcessor =
|
presentationFrameProcessor =
|
||||||
new PresentationFrameProcessor.Builder(getApplicationContext())
|
new PresentationFrameProcessor.Builder(getApplicationContext())
|
||||||
.setAspectRatio(2f, PresentationFrameProcessor.STRETCH_TO_FIT)
|
.setAspectRatio(2f, PresentationFrameProcessor.STRETCH_TO_FIT)
|
||||||
@ -327,7 +325,7 @@ public final class PresentationFrameProcessorPixelTest {
|
|||||||
BitmapTestUtil.readBitmap(
|
BitmapTestUtil.readBitmap(
|
||||||
ASPECT_RATIO_STRETCH_TO_FIT_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
ASPECT_RATIO_STRETCH_TO_FIT_WIDE_EXPECTED_OUTPUT_PNG_ASSET_STRING);
|
||||||
|
|
||||||
presentationFrameProcessor.updateProgramAndDraw(/* presentationTimeUs= */ 0);
|
presentationFrameProcessor.drawFrame(/* presentationTimeUs= */ 0);
|
||||||
Bitmap actualBitmap =
|
Bitmap actualBitmap =
|
||||||
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
BitmapTestUtil.createArgb8888BitmapFromCurrentGlFramebuffer(
|
||||||
outputSize.getWidth(), outputSize.getHeight());
|
outputSize.getWidth(), outputSize.getHeight());
|
||||||
|
@ -187,7 +187,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;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
|||||||
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);
|
||||||
|
@ -27,7 +27,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>
|
||||||
*/
|
*/
|
||||||
@ -47,8 +47,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}.
|
||||||
@ -56,15 +55,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();
|
||||||
|
@ -268,8 +268,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
|
||||||
|
@ -134,8 +134,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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user