Skip to content

Commit e2da568

Browse files
tadepall_adobecursoragent
andcommitted
Restore original comments and revert null-safety refactor in BitmapToHardwareBufferProcessor
Keep only the minimal HDR (RGBA_1010102) fast-path change while preserving the original inline comments and Bitmap.copy() call style. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 8da4800 commit e2da568

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

libraries/effect/src/main/java/androidx/media3/effect/BitmapToHardwareBufferProcessor.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,25 @@ public HardwareBufferFrame process(HardwareBufferFrame inputFrame) {
120120
buffer = copyCpuBitmapToHardwareBuffer(nextBitmap, hardwareBufferJniWrapper);
121121
} else if (SDK_INT >= 31) {
122122
if (nextBitmap.getConfig() == Config.HARDWARE) {
123+
// Input is HARDWARE and API >= 31: Direct access to HardwareBuffer is possible.
123124
buffer = nextBitmap.getHardwareBuffer();
124125
} else {
125-
Bitmap hwCopy = nextBitmap.copy(Config.HARDWARE, /* isMutable= */ false);
126-
if (hwCopy != null) {
127-
buffer = hwCopy.getHardwareBuffer();
128-
}
126+
// Input is not HARDWARE and API >= 31: We can create a HARDWARE Bitmap copy
127+
// and get its HardwareBuffer.
128+
buffer = nextBitmap.copy(Config.HARDWARE, /* isMutable= */ false).getHardwareBuffer();
129129
}
130130
}
131131
// Fallback to the native helper when the HardwareBuffer retrieved from the Bitmap was
132132
// null, or SDK_INT < 31.
133133
if (buffer == null) {
134134
if (nextBitmap.getConfig() == Config.HARDWARE) {
135+
// Input is HARDWARE but API < 31: HardwareBuffer is not directly accessible.
136+
// We must first copy to a software Bitmap (e.g. ARGB_8888)
137+
// and then copy that to a new HardwareBuffer via JNI.
135138
Bitmap softwareBitmap = nextBitmap.copy(Config.ARGB_8888, /* isMutable= */ false);
136139
buffer = copyCpuBitmapToHardwareBuffer(softwareBitmap, hardwareBufferJniWrapper);
137140
} else {
141+
// Input is not HARDWARE: Copy the software Bitmap to a new HardwareBuffer via JNI.
138142
buffer = copyCpuBitmapToHardwareBuffer(nextBitmap, hardwareBufferJniWrapper);
139143
}
140144
}

0 commit comments

Comments
 (0)