SK_C_API void sk_swizzle_swap_rb(uint32_t* dest, const uint32_t* src, int count);
+SK_C_API bool sk_webpencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, sk_webpencoder_options_t options);
+SK_C_API bool sk_jpegencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, sk_jpegencoder_options_t options);
+SK_C_API bool sk_pngencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, sk_pngencoder_options_t options);
+
SK_C_PLUS_PLUS_END_GUARD
#endif
float fContrast;
} sk_highcontrastconfig_t;
+typedef enum {
+ ZERO_SK_PNGENCODER_FILTER_FLAGS = 0x00,
+ NONE_SK_PNGENCODER_FILTER_FLAGS = 0x08,
+ SUB_SK_PNGENCODER_FILTER_FLAGS = 0x10,
+ UP_SK_PNGENCODER_FILTER_FLAGS = 0x20,
+ AVG_SK_PNGENCODER_FILTER_FLAGS = 0x40,
+ PAETH_SK_PNGENCODER_FILTER_FLAGS = 0x80,
+ ALL_SK_PNGENCODER_FILTER_FLAGS = NONE_SK_PNGENCODER_FILTER_FLAGS |
+ SUB_SK_PNGENCODER_FILTER_FLAGS |
+ UP_SK_PNGENCODER_FILTER_FLAGS |
+ AVG_SK_PNGENCODER_FILTER_FLAGS |
+ PAETH_SK_PNGENCODER_FILTER_FLAGS,
+} sk_pngencoder_filterflags_t;
+
+typedef struct {
+ sk_pngencoder_filterflags_t fFilterFlags;
+ int fZLibLevel;
+ sk_transfer_function_behavior_t fUnpremulBehavior;
+} sk_pngencoder_options_t;
+
+typedef enum {
+ DOWNSAMPLE_420_SK_JPEGENCODER_DOWNSAMPLE,
+ DOWNSAMPLE_422_SK_JPEGENCODER_DOWNSAMPLE,
+ DOWNSAMPLE_444_SK_JPEGENCODER_DOWNSAMPLE,
+} sk_jpegencoder_downsample_t;
+
+typedef enum {
+ IGNORE_SK_JPEGENCODER_ALPHA_OPTION,
+ BLEND_ON_BLACK_SK_JPEGENCODER_ALPHA_OPTION,
+} sk_jpegencoder_alphaoption_t;
+
+typedef struct {
+ int fQuality;
+ sk_jpegencoder_downsample_t fDownsample;
+ sk_jpegencoder_alphaoption_t fAlphaOption;
+ sk_transfer_function_behavior_t fBlendBehavior;
+} sk_jpegencoder_options_t;
+
+typedef enum {
+ LOSSY_SK_WEBPENCODER_COMPTRESSION,
+ LOSSLESS_SK_WEBPENCODER_COMPTRESSION,
+} sk_webpencoder_compression_t;
+
+typedef struct {
+ sk_webpencoder_compression_t fCompression;
+ float fQuality;
+ sk_transfer_function_behavior_t fUnpremulBehavior;
+} sk_webpencoder_options_t;
+
SK_C_PLUS_PLUS_END_GUARD
#endif
#include "SkMatrix44.h"
#include "SkBitmapScaler.h"
#include "SkBlurMaskFilter.h"
+#include "SkPngEncoder.h"
+#include "SkJpegEncoder.h"
+#include "SkWebpEncoder.h"
#if SK_SUPPORT_GPU
#include "GrTypes.h"
// sk_bitmap_allocflags_t
static_assert ((int)SkBitmap::AllocFlags::kZeroPixels_AllocFlag == (int)ZERO_PIXELS_SK_BITMAP_ALLOC_FLAGS, ASSERT_MSG(SkBitmap::AllocFlags, sk_bitmap_allocflags_t));
+// sk_pngencoder_filterflags_t
+static_assert ((int)SkPngEncoder::FilterFlag::kZero == (int)ZERO_SK_PNGENCODER_FILTER_FLAGS, ASSERT_MSG(SkPngEncoder::FilterFlag, sk_pngencoder_filterflags_t));
+static_assert ((int)SkPngEncoder::FilterFlag::kNone == (int)NONE_SK_PNGENCODER_FILTER_FLAGS, ASSERT_MSG(SkPngEncoder::FilterFlag, sk_pngencoder_filterflags_t));
+static_assert ((int)SkPngEncoder::FilterFlag::kSub == (int)SUB_SK_PNGENCODER_FILTER_FLAGS, ASSERT_MSG(SkPngEncoder::FilterFlag, sk_pngencoder_filterflags_t));
+static_assert ((int)SkPngEncoder::FilterFlag::kUp == (int)UP_SK_PNGENCODER_FILTER_FLAGS, ASSERT_MSG(SkPngEncoder::FilterFlag, sk_pngencoder_filterflags_t));
+static_assert ((int)SkPngEncoder::FilterFlag::kAvg == (int)AVG_SK_PNGENCODER_FILTER_FLAGS, ASSERT_MSG(SkPngEncoder::FilterFlag, sk_pngencoder_filterflags_t));
+static_assert ((int)SkPngEncoder::FilterFlag::kPaeth == (int)PAETH_SK_PNGENCODER_FILTER_FLAGS, ASSERT_MSG(SkPngEncoder::FilterFlag, sk_pngencoder_filterflags_t));
+static_assert ((int)SkPngEncoder::FilterFlag::kAll == (int)ALL_SK_PNGENCODER_FILTER_FLAGS, ASSERT_MSG(SkPngEncoder::FilterFlag, sk_pngencoder_filterflags_t));
+
+// sk_jpegencoder_downsample_t
+static_assert ((int)SkJpegEncoder::Downsample::k420 == (int)DOWNSAMPLE_420_SK_JPEGENCODER_DOWNSAMPLE, ASSERT_MSG(SkJpegEncoder::Downsample, sk_jpegencoder_downsample_t));
+static_assert ((int)SkJpegEncoder::Downsample::k422 == (int)DOWNSAMPLE_422_SK_JPEGENCODER_DOWNSAMPLE, ASSERT_MSG(SkJpegEncoder::Downsample, sk_jpegencoder_downsample_t));
+static_assert ((int)SkJpegEncoder::Downsample::k444 == (int)DOWNSAMPLE_444_SK_JPEGENCODER_DOWNSAMPLE, ASSERT_MSG(SkJpegEncoder::Downsample, sk_jpegencoder_downsample_t));
+
+// sk_jpegencoder_alphaoption_t
+static_assert ((int)SkJpegEncoder::AlphaOption::kIgnore == (int)IGNORE_SK_JPEGENCODER_ALPHA_OPTION, ASSERT_MSG(SkJpegEncoder::AlphaOption, sk_jpegencoder_alphaoption_t));
+static_assert ((int)SkJpegEncoder::AlphaOption::kBlendOnBlack == (int)BLEND_ON_BLACK_SK_JPEGENCODER_ALPHA_OPTION, ASSERT_MSG(SkJpegEncoder::AlphaOption, sk_jpegencoder_alphaoption_t));
+
+// sk_webpencoder_compression_t
+static_assert ((int)SkWebpEncoder::Compression::kLossy == (int)LOSSY_SK_WEBPENCODER_COMPTRESSION, ASSERT_MSG(SkWebpEncoder::Compression, sk_webpencoder_compression_t));
+static_assert ((int)SkWebpEncoder::Compression::kLossless == (int)LOSSLESS_SK_WEBPENCODER_COMPTRESSION, ASSERT_MSG(SkWebpEncoder::Compression, sk_webpencoder_compression_t));
+
#if SK_SUPPORT_GPU
// gr_surfaceorigin_t
{
SkSwapRB(dest, src, count);
}
+
+bool sk_webpencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, sk_webpencoder_options_t options) {
+ return SkWebpEncoder::Encode(AsWStream(dst), AsPixmap(*src), AsWebpEncoderOptions(options));
+}
+
+bool sk_jpegencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, sk_jpegencoder_options_t options) {
+ return SkJpegEncoder::Encode(AsWStream(dst), AsPixmap(*src), AsJpegEncoderOptions(options));
+}
+
+bool sk_pngencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, sk_pngencoder_options_t options) {
+ return SkPngEncoder::Encode(AsWStream(dst), AsPixmap(*src), AsPngEncoderOptions(options));
+}
static_assert (sizeof (sk_colorspace_transfer_fn_t) == sizeof (SkColorSpaceTransferFn), ASSERT_MSG(SkColorSpaceTransferFn, sk_colorspace_transfer_fn_t));
static_assert (sizeof (sk_colorspaceprimaries_t) == sizeof (SkColorSpacePrimaries), ASSERT_MSG(SkColorSpacePrimaries, sk_colorspaceprimaries_t));
static_assert (sizeof (sk_highcontrastconfig_t) == sizeof (SkHighContrastConfig), ASSERT_MSG(SkHighContrastConfig, sk_highcontrastconfig_t));
+static_assert (sizeof (sk_pngencoder_options_t) == sizeof (SkPngEncoder::Options), ASSERT_MSG(SkPngEncoder::Options, sk_pngencoder_options_t));
+static_assert (sizeof (sk_jpegencoder_options_t) == sizeof (SkJpegEncoder::Options), ASSERT_MSG(SkJpegEncoder::Options, sk_jpegencoder_options_t));
+static_assert (sizeof (sk_webpencoder_options_t) == sizeof (SkWebpEncoder::Options), ASSERT_MSG(SkWebpEncoder::Options, sk_webpencoder_options_t));
#if SK_SUPPORT_GPU
static_assert (sizeof (gr_backend_rendertarget_desc_t) == sizeof (GrBackendRenderTargetDesc), ASSERT_MSG(GrBackendRenderTargetDesc, gr_backend_rendertarget_desc_t));
#include "SkTime.h"
#include "SkCamera.h"
#include "SkHighContrastFilter.h"
+#include "SkPngEncoder.h"
+#include "SkJpegEncoder.h"
+#include "SkWebpEncoder.h"
#include "sk_path.h"
#include "sk_paint.h"
return reinterpret_cast<const sk_vertices_t*>(p);
}
+static inline const SkPngEncoder::Options& AsPngEncoderOptions(const sk_pngencoder_options_t& p) {
+ return reinterpret_cast<const SkPngEncoder::Options&>(p);
+}
+
+static inline const SkPngEncoder::Options* AsPngEncoderOptions(const sk_pngencoder_options_t* p) {
+ return reinterpret_cast<const SkPngEncoder::Options*>(p);
+}
+
+static inline const SkJpegEncoder::Options& AsJpegEncoderOptions(const sk_jpegencoder_options_t& p) {
+ return reinterpret_cast<const SkJpegEncoder::Options&>(p);
+}
+
+static inline const SkJpegEncoder::Options* AsJpegEncoderOptions(const sk_jpegencoder_options_t* p) {
+ return reinterpret_cast<const SkJpegEncoder::Options*>(p);
+}
+
+static inline const SkWebpEncoder::Options& AsWebpEncoderOptions(const sk_webpencoder_options_t& p) {
+ return reinterpret_cast<const SkWebpEncoder::Options&>(p);
+}
+
+static inline const SkWebpEncoder::Options* AsWebpEncoderOptions(const sk_webpencoder_options_t* p) {
+ return reinterpret_cast<const SkWebpEncoder::Options*>(p);
+}
+
static inline void from_c(const sk_matrix_t* cmatrix, SkMatrix* matrix) {
matrix->setAll(
cmatrix->mat[0], cmatrix->mat[1], cmatrix->mat[2],