Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few fixes #68

Merged
merged 2 commits into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions include/c/sk_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ typedef enum {
} sk_pixelgeometry_t;

typedef enum {
NONE_SK_SURFACE_PROPS_FLAGS = 0,
USE_DEVICE_INDEPENDENT_FONTS_SK_SURFACE_PROPS_FLAGS = 1 << 0,
} sk_surfaceprops_flags_t;

Expand Down Expand Up @@ -165,7 +166,9 @@ typedef struct {
}
*/
typedef struct {
float mat[9];
float scaleX, skewX, transX;
float skewY, scaleY, transY;
float persp0, persp1, persp2;
} sk_matrix_t;

typedef struct sk_matrix44_t sk_matrix44_t;
Expand Down Expand Up @@ -379,9 +382,9 @@ typedef struct sk_wstream_dynamicmemorystream_t sk_wstream_dynamicmemorystream_t
typedef struct sk_document_t sk_document_t;

typedef enum {
UTF8_ENCODING,
UTF16_ENCODING,
UTF32_ENCODING
UTF8_SK_ENCODING,
UTF16_SK_ENCODING,
UTF32_SK_ENCODING
} sk_encoding_t;

typedef enum {
Expand Down Expand Up @@ -424,6 +427,7 @@ typedef enum {
} sk_filter_quality_t;

typedef enum {
HAS_NONE_SK_CROP_RECT_FLAG = 0x00,
HAS_LEFT_SK_CROP_RECT_FLAG = 0x01,
HAS_TOP_SK_CROP_RECT_FLAG = 0x02,
HAS_WIDTH_SK_CROP_RECT_FLAG = 0x04,
Expand Down Expand Up @@ -662,11 +666,6 @@ typedef struct {
sk_mask_format_t fFormat;
} sk_mask_t;

typedef enum {
NONE_GR_CONTEXT_FLUSHBITS = 0,
DISCARD_GR_CONTEXT_FLUSHBITS = 0x2,
} gr_context_flushbits_t;

typedef intptr_t gr_backendobject_t;

typedef struct gr_backendrendertarget_t gr_backendrendertarget_t;
Expand Down Expand Up @@ -753,6 +752,7 @@ typedef enum {
} sk_image_caching_hint_t;

typedef enum {
NONE_SK_BITMAP_ALLOC_FLAGS = 0,
ZERO_PIXELS_SK_BITMAP_ALLOC_FLAGS = 1 << 0,
} sk_bitmap_allocflags_t;

Expand Down Expand Up @@ -781,12 +781,6 @@ typedef struct {
int fEncodingQuality;
} sk_document_pdf_metadata_t;

typedef enum {
SRGB_SK_COLORSPACE_NAMED,
ADOBE_RGB_SK_COLORSPACE_NAMED,
SRGB_LINEAR_SK_COLORSPACE_NAMED,
} sk_colorspace_named_t;

typedef struct {
sk_colorspace_t* colorspace;
int32_t width;
Expand Down
6 changes: 3 additions & 3 deletions src/c/sk_enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
#define ASSERT_MSG(SK, C) "ABI changed, you must write a enumeration mapper for " TOSTRING(#SK) " to " TOSTRING(#C) "."

// sk_encoding_t
static_assert ((int)SkTypeface::Encoding::kUTF8_Encoding == (int)UTF8_ENCODING, ASSERT_MSG(SkTypeface::Encoding, sk_encoding_t));
static_assert ((int)SkTypeface::Encoding::kUTF16_Encoding == (int)UTF16_ENCODING, ASSERT_MSG(SkTypeface::Encoding, sk_encoding_t));
static_assert ((int)SkTypeface::Encoding::kUTF32_Encoding == (int)UTF32_ENCODING, ASSERT_MSG(SkTypeface::Encoding, sk_encoding_t));
static_assert ((int)SkTypeface::Encoding::kUTF8_Encoding == (int)UTF8_SK_ENCODING, ASSERT_MSG(SkTypeface::Encoding, sk_encoding_t));
static_assert ((int)SkTypeface::Encoding::kUTF16_Encoding == (int)UTF16_SK_ENCODING, ASSERT_MSG(SkTypeface::Encoding, sk_encoding_t));
static_assert ((int)SkTypeface::Encoding::kUTF32_Encoding == (int)UTF32_SK_ENCODING, ASSERT_MSG(SkTypeface::Encoding, sk_encoding_t));

// sk_font_style_slant_t
static_assert ((int)SkFontStyle::Slant::kUpright_Slant == (int)UPRIGHT_SK_FONT_STYLE_SLANT, ASSERT_MSG(SkFontStyle::Slant, sk_font_style_slant_t));
Expand Down
16 changes: 12 additions & 4 deletions src/c/sk_types_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,21 @@ DEF_MAP(SkWebpEncoder::Options, sk_webpencoder_options_t, WebpEncoderOptions)
#include "SkMatrix.h"
static inline SkMatrix AsMatrix(const sk_matrix_t* matrix) {
return SkMatrix::MakeAll(
matrix->mat[0], matrix->mat[1], matrix->mat[2],
matrix->mat[3], matrix->mat[4], matrix->mat[5],
matrix->mat[6], matrix->mat[7], matrix->mat[8]);
matrix->scaleX, matrix->skewX, matrix->transX,
matrix->skewY, matrix->scaleY, matrix->transY,
matrix->persp0, matrix->persp1, matrix->persp2);
}
static inline sk_matrix_t ToMatrix(const SkMatrix* matrix) {
sk_matrix_t m;
matrix->get9(m.mat);
m.scaleX = matrix->get(SkMatrix::kMScaleX);
m.skewX = matrix->get(SkMatrix::kMSkewX);
m.transX = matrix->get(SkMatrix::kMTransX);
m.skewY = matrix->get(SkMatrix::kMSkewY);
m.scaleY = matrix->get(SkMatrix::kMScaleY);
m.transY = matrix->get(SkMatrix::kMTransY);
m.persp0 = matrix->get(SkMatrix::kMPersp0);
m.persp1 = matrix->get(SkMatrix::kMPersp1);
m.persp2 = matrix->get(SkMatrix::kMPersp2);
return m;
}

Expand Down