Flutter Engine
The Flutter Engine
third_party
skia
src
codec
SkJpegPriv.h
Go to the documentation of this file.
1
/*
2
* Copyright 2017 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
9
#ifndef SkJpegPriv_DEFINED
10
#define SkJpegPriv_DEFINED
11
12
#include "
include/codec/SkEncodedOrigin.h
"
13
#include "
include/core/SkStream.h
"
14
#include "
include/private/base/SkTArray.h
"
15
16
#include <setjmp.h>
17
// stdio is needed for jpeglib
18
#include <
stdio.h
>
19
20
extern
"C"
{
21
#include "jpeglib.h"
// NO_G3_REWRITE
22
#include "jerror.h"
// NO_G3_REWRITE
23
}
24
25
/*
26
* Error handling struct
27
*/
28
struct
skjpeg_error_mgr
:
public
jpeg_error_mgr {
29
class
AutoPushJmpBuf
{
30
public
:
31
AutoPushJmpBuf
(
skjpeg_error_mgr
* mgr) : fMgr(mgr) { fMgr->
push
(&fJmpBuf); }
32
~AutoPushJmpBuf
() { fMgr->
pop
(&fJmpBuf); }
33
operator
jmp_buf&() {
return
fJmpBuf; }
34
35
private
:
36
skjpeg_error_mgr
*
const
fMgr;
37
jmp_buf fJmpBuf;
38
};
39
40
// When libjpeg initializes the fields of a `jpeg_error_mgr` (in `jpeg_std_error`), it
41
// leaves the msg_parm fields uninitialized. This is safe, but confuses MSAN, so we
42
// explicitly zero out the structure when constructing it. (crbug.com/oss-fuzz/68691)
43
skjpeg_error_mgr
() : jpeg_error_mgr({}) {}
44
45
void
push
(jmp_buf* j) {
46
SkASSERT
(
fStack
[3] ==
nullptr
);
// if we assert here, the stack has overflowed
47
fStack
[3] =
fStack
[2];
48
fStack
[2] =
fStack
[1];
49
fStack
[1] =
fStack
[0];
50
fStack
[0] = j;
51
}
52
53
void
pop
(jmp_buf* j) {
54
SkASSERT
(
fStack
[0] == j);
// if we assert here, the pushes and pops were unbalanced
55
fStack
[0] =
fStack
[1];
56
fStack
[1] =
fStack
[2];
57
fStack
[2] =
fStack
[3];
58
fStack
[3] =
nullptr
;
59
}
60
61
jmp_buf*
fStack
[4] = {};
62
};
63
64
#endif
SkASSERT
#define SkASSERT(cond)
Definition:
SkAssert.h:116
SkEncodedOrigin.h
SkStream.h
SkTArray.h
skjpeg_error_mgr::AutoPushJmpBuf
Definition:
SkJpegPriv.h:29
skjpeg_error_mgr::AutoPushJmpBuf::AutoPushJmpBuf
AutoPushJmpBuf(skjpeg_error_mgr *mgr)
Definition:
SkJpegPriv.h:31
skjpeg_error_mgr::AutoPushJmpBuf::~AutoPushJmpBuf
~AutoPushJmpBuf()
Definition:
SkJpegPriv.h:32
stdio.h
skjpeg_error_mgr
Definition:
SkJpegPriv.h:28
skjpeg_error_mgr::skjpeg_error_mgr
skjpeg_error_mgr()
Definition:
SkJpegPriv.h:43
skjpeg_error_mgr::push
void push(jmp_buf *j)
Definition:
SkJpegPriv.h:45
skjpeg_error_mgr::pop
void pop(jmp_buf *j)
Definition:
SkJpegPriv.h:53
skjpeg_error_mgr::fStack
jmp_buf * fStack[4]
Definition:
SkJpegPriv.h:61
Generated on Sun Jun 23 2024 21:56:09 for Flutter Engine by
1.9.4