Stop using skjpeg_error_mgr in YuvToJpegEncoder

Bug: None
Test: compile

skjpeg_error_mgr is only different from the standard one in that it
includes a jmp_buf. A recent change to skjpeg_error_mgr stores a stack
of jmp_bufs (see https://skia-review.googlesource.com/c/skia/+/79241).
This complexity is unnecessary for YuvToJpegEncoder, which only contains
a single method with libjpeg calls (which might call longjmp). Simplify
this code by placing the jmp_buf on the stack. This fixes the Skia to
Android roll, which includes the above Skia change.

Change-Id: If9a33ed10ea60131906a632a7030e0b69a21f4ea
This commit is contained in:
Leon Scroggins III
2017-12-04 11:37:30 -05:00
parent c51777b9b8
commit 471ef097cc

View File

@@ -26,12 +26,13 @@ YuvToJpegEncoder::YuvToJpegEncoder(int* strides) : fStrides(strides) {
bool YuvToJpegEncoder::encode(SkWStream* stream, void* inYuv, int width,
int height, int* offsets, int jpegQuality) {
jpeg_compress_struct cinfo;
skjpeg_error_mgr sk_err;
jpeg_error_mgr err;
skjpeg_destination_mgr sk_wstream(stream);
cinfo.err = jpeg_std_error(&sk_err);
sk_err.error_exit = skjpeg_error_exit;
if (setjmp(sk_err.fJmpBuf)) {
cinfo.err = jpeg_std_error(&err);
err.error_exit = skjpeg_error_exit;
jmp_buf jmp;
if (setjmp(jmp)) {
return false;
}
jpeg_create_compress(&cinfo);