19 #ifndef PAGESPEED_KERNEL_IMAGE_SCANLINE_STATUS_H_
20 #define PAGESPEED_KERNEL_IMAGE_SCANLINE_STATUS_H_
29 namespace image_compression {
31 #if defined(PAGESPEED_SCANLINE_STATUS) || \
32 defined(PAGESPEED_SCANLINE_STATUS_SOURCE) || \
33 defined(PAGESPEED_SCANLINE_STATUS_ENUM_NAME) || \
34 defined(PAGESPEED_SCANLINE_STATUS_ENUM_STRING)
35 #error "Preprocessor macro collision."
38 #define PAGESPEED_SCANLINE_STATUS(_X) \
39 _X(SCANLINE_STATUS_UNINITIALIZED), \
40 _X(SCANLINE_STATUS_SUCCESS), \
41 _X(SCANLINE_STATUS_UNSUPPORTED_FORMAT), \
42 _X(SCANLINE_STATUS_UNSUPPORTED_FEATURE), \
43 _X(SCANLINE_STATUS_PARSE_ERROR), \
44 _X(SCANLINE_STATUS_MEMORY_ERROR), \
45 _X(SCANLINE_STATUS_INTERNAL_ERROR), \
46 _X(SCANLINE_STATUS_TIMEOUT_ERROR), \
47 _X(SCANLINE_STATUS_INVOCATION_ERROR), \
49 _X(NUM_SCANLINE_STATUS)
53 #define PAGESPEED_SCANLINE_STATUS_SOURCE(_X) \
54 _X(SCANLINE_UNKNOWN), \
55 _X(SCANLINE_PNGREADER), \
56 _X(SCANLINE_PNGREADERRAW), \
57 _X(SCANLINE_GIFREADER), \
58 _X(SCANLINE_GIFREADERRAW), \
59 _X(SCANLINE_JPEGREADER), \
60 _X(SCANLINE_WEBPREADER), \
61 _X(SCANLINE_RESIZER), \
62 _X(SCANLINE_PNGWRITER), \
63 _X(SCANLINE_JPEGWRITER), \
64 _X(SCANLINE_WEBPWRITER), \
66 _X(SCANLINE_PIXEL_FORMAT_OPTIMIZER), \
67 _X(FRAME_TO_SCANLINE_READER_ADAPTER), \
68 _X(FRAME_TO_SCANLINE_WRITER_ADAPTER), \
69 _X(SCANLINE_TO_FRAME_READER_ADAPTER), \
70 _X(SCANLINE_TO_FRAME_WRITER_ADAPTER), \
71 _X(FRAME_GIFREADER), \
72 _X(FRAME_WEBPWRITER), \
73 _X(FRAME_PADDING_READER), \
75 _X(NUM_SCANLINE_SOURCE)
77 #define PAGESPEED_SCANLINE_STATUS_ENUM_NAME(_Y) _Y
78 #define PAGESPEED_SCANLINE_STATUS_ENUM_STRING(_Y) #_Y
80 enum ScanlineStatusType {
81 PAGESPEED_SCANLINE_STATUS(PAGESPEED_SCANLINE_STATUS_ENUM_NAME)
84 enum ScanlineStatusSource {
96 source_(SCANLINE_UNKNOWN),
100 ScanlineStatusSource source,
108 source_(SCANLINE_UNKNOWN),
115 ScanlineStatusSource source,
123 StringAppendV(&detail_list, details, args);
128 bool Success()
const {
return (type_ == SCANLINE_STATUS_SUCCESS); }
129 ScanlineStatusType type()
const {
return type_; }
130 ScanlineStatusSource source()
const {
return source_; }
131 const GoogleString& details()
const {
return details_; }
133 const char* TypeStr()
const {
134 static const char*
const kScanlineStatusTypeNames[] = {
135 PAGESPEED_SCANLINE_STATUS(PAGESPEED_SCANLINE_STATUS_ENUM_STRING)
137 return kScanlineStatusTypeNames[type_];
140 const char* SourceStr()
const {
141 static const char*
const kScanlineStatusSourceNames[] = {
144 return kScanlineStatusSourceNames[source_];
148 return GoogleString(SourceStr()) +
"/" + TypeStr() +
" " + details();
155 case SCANLINE_PNGREADER:
156 case SCANLINE_PNGREADERRAW:
157 case SCANLINE_GIFREADER:
158 case SCANLINE_GIFREADERRAW:
159 case SCANLINE_JPEGREADER:
160 case SCANLINE_WEBPREADER:
161 case FRAME_TO_SCANLINE_READER_ADAPTER:
162 case SCANLINE_TO_FRAME_READER_ADAPTER:
163 case FRAME_GIFREADER:
164 case FRAME_PADDING_READER:
173 ScanlineStatusType type_;
174 ScanlineStatusSource source_;
181 #undef PAGESPEED_SCANLINE_STATUS_ENUM_STRING
182 #undef PAGESPEED_SCANLINE_STATUS_ENUM_NAME
183 #undef PAGESPEED_SCANLINE_STATUS_SOURCE
184 #undef PAGESPEED_SCANLINE_STATUS
189 #define PS_LOGGED_STATUS(_LOGGER, _HANDLER, _TYPE, _SOURCE, ...) \
190 (_LOGGER(_HANDLER, #_SOURCE "/" #_TYPE " " __VA_ARGS__), \
191 ScanlineStatus::New(_TYPE, _SOURCE, __VA_ARGS__))
Definition: scanline_status.h:93
bool ComesFromReader() const
Definition: scanline_status.h:153
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
static ScanlineStatus New(ScanlineStatusType type, ScanlineStatusSource source, const char *details,...) INSTAWEB_PRINTF_FORMAT(3
#define PAGESPEED_SCANLINE_STATUS_SOURCE(_X)
Definition: scanline_status.h:53