19 #ifndef PAGESPEED_KERNEL_IMAGE_IMAGE_UTIL_H_
20 #define PAGESPEED_KERNEL_IMAGE_IMAGE_UTIL_H_
28 #include "pagespeed/kernel/http/image_types.pb.h"
30 namespace net_instaweb {
37 namespace image_compression {
73 enum PreferredLibwebpLevel {
80 const uint8_t kAlphaOpaque = 255;
81 const uint8_t kAlphaTransparent = 0;
82 typedef uint8_t PixelRgbaChannels[RGBA_NUM_CHANNELS];
86 inline uint32_t PackHiToLo(uint8_t i3,
91 (static_cast<uint32_t>(i3) << 24) |
98 inline uint32_t PackAsArgb(uint8_t alpha,
102 return PackHiToLo(alpha, red, green, blue);
107 inline uint32_t RgbaToPackedArgb(
const PixelRgbaChannels rgba) {
108 return PackAsArgb(rgba[RGBA_ALPHA],
116 inline uint32_t RgbToPackedArgb(
const PixelRgbaChannels rgba) {
117 return PackAsArgb(kAlphaOpaque,
125 inline uint32_t GrayscaleToPackedArgb(
const uint8_t luminance) {
126 return PackAsArgb(kAlphaOpaque,
135 typedef uint32 size_px;
138 const char* ImageFormatToMimeTypeString(ImageFormat image_type);
141 const char* ImageFormatToString(ImageFormat image_type);
144 const char* GetPixelFormatString(PixelFormat pixel_format);
148 size_t GetBytesPerPixel(PixelFormat pixel_format);
155 net_instaweb::ImageType ComputeImageType(
const StringPiece& buf);
163 countdown_timer_(timer, NULL, time_allowed_ms),
164 time_allowed_ms_(time_allowed_ms),
166 was_timed_out_(
false),
175 static bool Continue(
int percent,
void* user_data);
179 countdown_timer_.Reset(time_allowed_ms_);
183 time_elapsed_ms_ = countdown_timer_.TimeElapsedMs();
186 bool was_timed_out()
const {
return was_timed_out_; }
187 int64 time_elapsed_ms()
const {
return time_elapsed_ms_; }
191 const int64 time_allowed_ms_;
192 int64 time_elapsed_ms_;
static bool Continue(int percent, void *user_data)
Definition: countdown_timer.h:33
Class for managing image conversion timeouts.
Definition: image_util.h:158
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Definition: image_util.h:198
Definition: message_handler.h:39
Timer interface, made virtual so it can be mocked for tests.
Definition: timer.h:27