From 8c30c138874d5b2ac43ccf2bf4141d879ef49495 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 27 Sep 2019 03:54:49 +0200 Subject: [PATCH 01/24] Adding the arm64_32 architecture to watchOS (#62) --- gn/BUILD.gn | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gn/BUILD.gn b/gn/BUILD.gn index 200caac1144..b19ffb11322 100644 --- a/gn/BUILD.gn +++ b/gn/BUILD.gn @@ -216,8 +216,12 @@ config("default") { } else if (target_cpu == "x64") { _target = "x86_64" } - if (is_watchos && _target == "armv7") { - _target = "armv7k" + if (is_watchos) { + if (_target == "armv7") { + _target = "armv7k" + } else if (_target == "arm64") { + _target = "arm64_32" + } } asmflags += [ "-isysroot", From bd7b9486d19c2856f8dce824c8da3442af4ff469 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 28 Sep 2019 02:23:25 +0200 Subject: [PATCH 02/24] Bitcode is just for device builds (#63) --- gn/BUILD.gn | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gn/BUILD.gn b/gn/BUILD.gn index b19ffb11322..b7112ae22b5 100644 --- a/gn/BUILD.gn +++ b/gn/BUILD.gn @@ -14,10 +14,9 @@ declare_args() { malloc = "" - enable_bitcode = false - if (is_tvos || is_watchos) { - enable_bitcode = true - } + enable_bitcode = + (is_tvos || is_watchos) && + (target_cpu == "arm" || target_cpu == "arm64") } if (is_ios) { @@ -217,9 +216,9 @@ config("default") { _target = "x86_64" } if (is_watchos) { - if (_target == "armv7") { + if (target_cpu == "arm") { _target = "armv7k" - } else if (_target == "arm64") { + } else if (target_cpu == "arm64") { _target = "arm64_32" } } From 281628fa2a21850f9adc88c3b5458df2d43b4b12 Mon Sep 17 00:00:00 2001 From: Benedikt Stebner Date: Thu, 17 Oct 2019 11:01:33 +0200 Subject: [PATCH 03/24] Update freetype to latest release (#65) --- .gitignore | 1 + DEPS | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3feb0a2ee93..6f32a854203 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ gl-out node_modules tools/lottiecap/filmstrip.png +/_ReSharper.Caches diff --git a/DEPS b/DEPS index b045771107e..fd0457d5174 100644 --- a/DEPS +++ b/DEPS @@ -6,7 +6,7 @@ deps = { "third_party/externals/angle2" : "https://chromium.googlesource.com/angle/angle.git@b001528ffa00e7c15a5002124f707570e59a5697", "third_party/externals/dng_sdk" : "https://android.googlesource.com/platform/external/dng_sdk.git@96443b262250c390b0caefbf3eed8463ba35ecae", "third_party/externals/expat" : "https://android.googlesource.com/platform/external/expat.git@android-6.0.1_r55", - "third_party/externals/freetype" : "https://skia.googlesource.com/third_party/freetype2.git@fa6da7bf6dcbcfa22d2464259ad1cccee3233189", + "third_party/externals/freetype" : "https://skia.googlesource.com/third_party/freetype2.git@VER-2-10-1", "third_party/externals/googletest" : "https://android.googlesource.com/platform/external/googletest@dd43b9998e9a44a579a7aba6c1309407d1a5ed95", "third_party/externals/harfbuzz" : "https://skia.googlesource.com/third_party/harfbuzz.git@1.4.2", "third_party/externals/icu" : "https://chromium.googlesource.com/chromium/deps/icu.git@ec9c1133693148470ffe2e5e53576998e3650c1d", From 77049b872966dc300ed233fc6e3930eb21bac5e3 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 18 Oct 2019 18:12:29 +0200 Subject: [PATCH 04/24] sk_region_contains should return bool (#66) --- include/c/sk_region.h | 4 ++-- src/c/sk_region.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/c/sk_region.h b/include/c/sk_region.h index f4a95a9393d..719a31ded62 100755 --- a/include/c/sk_region.h +++ b/include/c/sk_region.h @@ -18,8 +18,8 @@ SK_C_PLUS_PLUS_BEGIN_GUARD SK_C_API sk_region_t* sk_region_new(void); SK_C_API sk_region_t* sk_region_new2(const sk_region_t* region); SK_C_API void sk_region_delete(sk_region_t* cpath); -SK_C_API void sk_region_contains(sk_region_t* r, const sk_region_t* region); -SK_C_API void sk_region_contains2(sk_region_t* r, int x, int y); +SK_C_API bool sk_region_contains(sk_region_t* r, const sk_region_t* region); +SK_C_API bool sk_region_contains2(sk_region_t* r, int x, int y); SK_C_API bool sk_region_intersects_rect(sk_region_t* r, const sk_irect_t* rect); SK_C_API bool sk_region_intersects(sk_region_t* r, const sk_region_t* src); SK_C_API bool sk_region_set_path(sk_region_t* dst, const sk_path_t* t, const sk_region_t* clip); diff --git a/src/c/sk_region.cpp b/src/c/sk_region.cpp index ed6247d87cd..76ec11c8dcd 100644 --- a/src/c/sk_region.cpp +++ b/src/c/sk_region.cpp @@ -25,12 +25,12 @@ void sk_region_delete(sk_region_t *region) { delete AsRegion(region); } -void sk_region_contains(sk_region_t *r, const sk_region_t *region) { - AsRegion(r)->contains(*AsRegion(region)); +bool sk_region_contains(sk_region_t *r, const sk_region_t *region) { + return AsRegion(r)->contains(*AsRegion(region)); } -void sk_region_contains2(sk_region_t *r, int x, int y) { - AsRegion(r)->contains(x, y); +bool sk_region_contains2(sk_region_t *r, int x, int y) { + return AsRegion(r)->contains(x, y); } bool sk_region_intersects_rect(sk_region_t* r, const sk_irect_t* rect) { From caa8bd1b0570d1789d50c0b1b2f5810aeef07f4e Mon Sep 17 00:00:00 2001 From: Ngoc Dao Date: Tue, 5 Nov 2019 01:34:08 +1100 Subject: [PATCH 05/24] sk_ipoint_t and sk_isize_t should use integer members (#67) --- include/c/sk_types.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/c/sk_types.h b/include/c/sk_types.h index 1a36269a8a9..cd9ec804acb 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -175,7 +175,7 @@ typedef enum { TRANSLATE_SK_MATRIX44_TYPE_MASK = 0x01, SCALE_SK_MATRIX44_TYPE_MASK = 0x02, AFFINE_SK_MATRIX44_TYPE_MASK = 0x04, - PERSPECTIVE_SK_MATRIX44_TYPE_MASK = 0x08 + PERSPECTIVE_SK_MATRIX44_TYPE_MASK = 0x08 } sk_matrix44_type_mask_t; /** @@ -293,8 +293,8 @@ typedef struct { } sk_point3_t; typedef struct { - float x; - float y; + int32_t x; + int32_t y; } sk_ipoint_t; typedef struct { @@ -303,8 +303,8 @@ typedef struct { } sk_size_t; typedef struct { - float w; - float h; + int32_t w; + int32_t h; } sk_isize_t; typedef struct { @@ -570,7 +570,7 @@ typedef enum { INVERTED_SK_PATH_EFFECT_TRIM_MODE, } sk_path_effect_trim_mode_t; -typedef struct sk_path_effect_t sk_path_effect_t; +typedef struct sk_path_effect_t sk_path_effect_t; typedef enum { BUTT_SK_STROKE_CAP, @@ -891,8 +891,8 @@ typedef enum { 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 | + UP_SK_PNGENCODER_FILTER_FLAGS | + AVG_SK_PNGENCODER_FILTER_FLAGS | PAETH_SK_PNGENCODER_FILTER_FLAGS, } sk_pngencoder_filterflags_t; From 6c864a6c858f77d7e20b37cd468103ae8d7e054b Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 5 Nov 2019 22:57:29 +0200 Subject: [PATCH 06/24] Just a few fixes for the C API (#68) --- include/c/sk_types.h | 24 +++++++++--------------- src/c/sk_enums.cpp | 6 +++--- src/c/sk_types_priv.h | 16 ++++++++++++---- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/include/c/sk_types.h b/include/c/sk_types.h index cd9ec804acb..0a36ba55624 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -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; @@ -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; @@ -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 { @@ -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, @@ -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; @@ -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; @@ -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; diff --git a/src/c/sk_enums.cpp b/src/c/sk_enums.cpp index bc79a585d4e..9555c2c8b8e 100644 --- a/src/c/sk_enums.cpp +++ b/src/c/sk_enums.cpp @@ -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)); diff --git a/src/c/sk_types_priv.h b/src/c/sk_types_priv.h index a889331d878..df032534bae 100644 --- a/src/c/sk_types_priv.h +++ b/src/c/sk_types_priv.h @@ -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; } From c7bc33cec7df10707f9c13254e4a593ce18aa7ae Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sun, 17 Nov 2019 05:07:14 +0200 Subject: [PATCH 07/24] This feature is also missing on Nano Server --- src/xps/SkXPSDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp index a89cacdb6b6..97b48def1f0 100644 --- a/src/xps/SkXPSDevice.cpp +++ b/src/xps/SkXPSDevice.cpp @@ -334,7 +334,7 @@ bool SkXPSDevice::endSheet() { } static HRESULT subset_typeface(SkXPSDevice::TypefaceUse* current) { -#if SK_BUILD_FOR_WINRT +#if SK_BUILD_FOR_WINRT || SK_BUILD_FOR_NANOSERVER return E_UNEXPECTED; #else //CreateFontPackage wants unsigned short. From 10be3d7c52d173c9f8506492b2678aa9e1d9ba18 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 19 Nov 2019 05:49:24 +0200 Subject: [PATCH 08/24] Add isFixedPitch --- include/c/sk_typeface.h | 1 + src/c/sk_typeface.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/c/sk_typeface.h b/include/c/sk_typeface.h index 82a5a742f5c..2b56903926a 100644 --- a/include/c/sk_typeface.h +++ b/include/c/sk_typeface.h @@ -34,6 +34,7 @@ SK_C_API int sk_typeface_count_tables(sk_typeface_t* typeface); SK_C_API int sk_typeface_get_table_tags(sk_typeface_t* typeface, sk_font_table_tag_t tags[]); SK_C_API size_t sk_typeface_get_table_size(sk_typeface_t* typeface, sk_font_table_tag_t tag); SK_C_API size_t sk_typeface_get_table_data(sk_typeface_t* typeface, sk_font_table_tag_t tag, size_t offset, size_t length, void* data); +SK_C_API bool sk_typeface_is_fixed_pitch(sk_typeface_t* typeface); // font manager diff --git a/src/c/sk_typeface.cpp b/src/c/sk_typeface.cpp index a245a1b73c6..c3cde1f7d38 100644 --- a/src/c/sk_typeface.cpp +++ b/src/c/sk_typeface.cpp @@ -98,6 +98,10 @@ size_t sk_typeface_get_table_data(sk_typeface_t* typeface, sk_font_table_tag_t t return AsTypeface(typeface)->getTableData(tag, offset, length, data); } +bool sk_typeface_is_fixed_pitch(sk_typeface_t* typeface) { + return AsTypeface(typeface)->isFixedPitch(); +} + // font manager From 9048d001b8413c07ca105c8894a62196f2f15d6f Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 19 Nov 2019 17:01:12 +0200 Subject: [PATCH 09/24] Use IsMonospacedFont to detect fixed pitch --- src/ports/SkTypeface_win_dw.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ports/SkTypeface_win_dw.h b/src/ports/SkTypeface_win_dw.h index 75be040fd43..03deb4b6c6e 100644 --- a/src/ports/SkTypeface_win_dw.h +++ b/src/ports/SkTypeface_win_dw.h @@ -61,9 +61,15 @@ class DWriteFontTypeface : public SkTypeface { if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace2))) { SkASSERT_RELEASE(nullptr == fDWriteFontFace2.get()); } + if (!SUCCEEDED(fDWriteFont->QueryInterface(&fDWriteFont1))) { + SkASSERT_RELEASE(nullptr == fDWriteFont1.get()); + } if (!SUCCEEDED(fFactory->QueryInterface(&fFactory2))) { SkASSERT_RELEASE(nullptr == fFactory2.get()); } + + if (fDWriteFont1) + setIsFixedPitch(fDWriteFont1->IsMonospacedFont()); } public: @@ -73,6 +79,7 @@ class DWriteFontTypeface : public SkTypeface { SkTScopedComPtr fDWriteFontFileLoader; SkTScopedComPtr fDWriteFontFamily; SkTScopedComPtr fDWriteFont; + SkTScopedComPtr fDWriteFont1; SkTScopedComPtr fDWriteFontFace; SkTScopedComPtr fDWriteFontFace1; SkTScopedComPtr fDWriteFontFace2; From 0ad7a6b626d404c5b2d5c9d0537820c85cf156c8 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 19 Nov 2019 18:57:21 +0200 Subject: [PATCH 10/24] DW fixed pitch - use Google's code https://skia-review.googlesource.com/c/skia/+/255264 --- src/ports/SkTypeface_win_dw.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ports/SkTypeface_win_dw.h b/src/ports/SkTypeface_win_dw.h index 03deb4b6c6e..e543af5f7b0 100644 --- a/src/ports/SkTypeface_win_dw.h +++ b/src/ports/SkTypeface_win_dw.h @@ -61,15 +61,13 @@ class DWriteFontTypeface : public SkTypeface { if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace2))) { SkASSERT_RELEASE(nullptr == fDWriteFontFace2.get()); } - if (!SUCCEEDED(fDWriteFont->QueryInterface(&fDWriteFont1))) { - SkASSERT_RELEASE(nullptr == fDWriteFont1.get()); - } if (!SUCCEEDED(fFactory->QueryInterface(&fFactory2))) { SkASSERT_RELEASE(nullptr == fFactory2.get()); } - if (fDWriteFont1) - setIsFixedPitch(fDWriteFont1->IsMonospacedFont()); + if (fDWriteFontFace1 && fDWriteFontFace1->IsMonospacedFont()) { + this->setIsFixedPitch(true); + } } public: @@ -79,7 +77,6 @@ class DWriteFontTypeface : public SkTypeface { SkTScopedComPtr fDWriteFontFileLoader; SkTScopedComPtr fDWriteFontFamily; SkTScopedComPtr fDWriteFont; - SkTScopedComPtr fDWriteFont1; SkTScopedComPtr fDWriteFontFace; SkTScopedComPtr fDWriteFontFace1; SkTScopedComPtr fDWriteFontFace2; From 33ac8cff6082d3410497382b22c1e652bcd945de Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 22 Nov 2019 03:24:12 +0200 Subject: [PATCH 11/24] No implementation --- include/c/sk_bitmap.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/c/sk_bitmap.h b/include/c/sk_bitmap.h index c0bd7386611..40063495461 100644 --- a/include/c/sk_bitmap.h +++ b/include/c/sk_bitmap.h @@ -33,7 +33,6 @@ SK_C_API uint16_t sk_bitmap_get_addr_16(sk_bitmap_t* cbitmap, int x, int y); SK_C_API uint32_t sk_bitmap_get_addr_32(sk_bitmap_t* cbitmap, int x, int y); SK_C_API void* sk_bitmap_get_addr(sk_bitmap_t* cbitmap, int x, int y); SK_C_API sk_color_t sk_bitmap_get_pixel_color(sk_bitmap_t* cbitmap, int x, int y); -SK_C_API sk_pmcolor_t sk_bitmap_get_index8_color(sk_bitmap_t* cbitmap, int x, int y); SK_C_API void sk_bitmap_set_pixel_color(sk_bitmap_t* cbitmap, int x, int y, sk_color_t color); SK_C_API bool sk_bitmap_ready_to_draw(sk_bitmap_t* cbitmap); SK_C_API void sk_bitmap_get_pixel_colors(sk_bitmap_t* cbitmap, sk_color_t* colors); From 31af8bbc93dbdedf2bb796a44f6f20a0e32278b3 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Mon, 22 Oct 2018 13:16:37 -0400 Subject: [PATCH 12/24] Fix heap buffer overflow Bug: oss-fuzz:11040 Because we're sampling, the offset ends up the same as the width. Back up to the left enough to fit the bytes we will write. Change-Id: Ie476a0191b66c2322446b9c0922f630d6e971645 Reviewed-on: https://skia-review.googlesource.com/c/164262 Commit-Queue: Leon Scroggins Commit-Queue: Mike Klein Auto-Submit: Leon Scroggins Reviewed-by: Mike Klein --- src/codec/SkSwizzler.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp index 4b350c4ec4b..827e0537757 100644 --- a/src/codec/SkSwizzler.cpp +++ b/src/codec/SkSwizzler.cpp @@ -1211,6 +1211,15 @@ int SkSwizzler::onSetSampleX(int sampleX) { fSwizzleWidth = get_scaled_dimension(fSrcWidth, sampleX); fAllocatedWidth = get_scaled_dimension(fDstWidth, sampleX); + if (fDstOffsetBytes > 0) { + const size_t dstSwizzleBytes = fSwizzleWidth * fDstBPP; + const size_t dstAllocatedBytes = fAllocatedWidth * fDstBPP; + if (fDstOffsetBytes + dstSwizzleBytes > dstAllocatedBytes) { + SkASSERT(dstSwizzleBytes <= dstAllocatedBytes); + fDstOffsetBytes = dstAllocatedBytes - dstSwizzleBytes; + } + } + // The optimized swizzler functions do not support sampling. Sampled swizzles // are already fast because they skip pixels. We haven't seen a situation // where speeding up sampling has a significant impact on total decode time. From b4b86b6eb8e8e5d397e969ef8b8b7ab59cad333f Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Fri, 26 Oct 2018 14:15:02 -0400 Subject: [PATCH 13/24] Ensure fSrcOffsetUnits is in a valid range Bug: oss-fuzz:11114 fSrcOffsetUnits is where we start sampling from the image. It is computed as (sampleX / 2) * fSrcBPP (ignoring fSrcOffset, which is 0 for a GIF with a subset frame). sampleX will be no wider than the full image, and we divide it by two to sample points evenly spread through the image. But for a subset frame, we need to use a different sampling rate to ensure that the sampled points are within the width of the frame. Change-Id: I4a313db096fbaea7d869927a9da5df9beb9f6706 Reviewed-on: https://skia-review.googlesource.com/c/165500 Reviewed-by: Mike Klein Commit-Queue: Leon Scroggins --- src/codec/SkSwizzler.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp index 827e0537757..f5ba6426de5 100644 --- a/src/codec/SkSwizzler.cpp +++ b/src/codec/SkSwizzler.cpp @@ -1206,11 +1206,22 @@ int SkSwizzler::onSetSampleX(int sampleX) { SkASSERT(sampleX > 0); fSampleX = sampleX; - fSrcOffsetUnits = (get_start_coord(sampleX) + fSrcOffset) * fSrcBPP; fDstOffsetBytes = (fDstOffset / sampleX) * fDstBPP; fSwizzleWidth = get_scaled_dimension(fSrcWidth, sampleX); fAllocatedWidth = get_scaled_dimension(fDstWidth, sampleX); + int frameSampleX = sampleX; + if (fSrcWidth < fDstWidth) { + // Although SkSampledCodec adjusted sampleX so that it will never be + // larger than the width of the image (or subset, if applicable), it + // doesn't account for the width of a subset frame (i.e. gif). As a + // result, get_start_coord(sampleX) could result in fSrcOffsetUnits + // being wider than fSrcWidth. Compute a sampling rate based on the + // frame width to ensure that fSrcOffsetUnits is sensible. + frameSampleX = fSrcWidth / fSwizzleWidth; + } + fSrcOffsetUnits = (get_start_coord(frameSampleX) + fSrcOffset) * fSrcBPP; + if (fDstOffsetBytes > 0) { const size_t dstSwizzleBytes = fSwizzleWidth * fDstBPP; const size_t dstAllocatedBytes = fAllocatedWidth * fDstBPP; From 5029445713c6f0612eb30bace90b0cfce2307060 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 10 Dec 2019 23:05:45 +0200 Subject: [PATCH 14/24] Add SkPerlinNoiseShader::MakeImprovedNoise --- include/c/sk_shader.h | 5 +++++ src/c/sk_shader.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/include/c/sk_shader.h b/include/c/sk_shader.h index a0ee3342c9b..a0f292ad9bb 100644 --- a/include/c/sk_shader.h +++ b/include/c/sk_shader.h @@ -72,6 +72,11 @@ SK_C_API sk_shader_t* sk_shader_new_perlin_noise_turbulence( int numOctaves, float seed, const sk_isize_t* tileSize); +SK_C_API sk_shader_t* sk_shader_new_perlin_noise_improved_noise( + float baseFrequencyX, + float baseFrequencyY, + int numOctaves, + float z); SK_C_API sk_shader_t* sk_shader_new_compose( sk_shader_t* shaderA, sk_shader_t* shaderB); diff --git a/src/c/sk_shader.cpp b/src/c/sk_shader.cpp index e8efdaca010..3d4b95c3ef9 100644 --- a/src/c/sk_shader.cpp +++ b/src/c/sk_shader.cpp @@ -61,6 +61,11 @@ sk_shader_t* sk_shader_new_perlin_noise_turbulence(float baseFrequencyX, float b baseFrequencyX, baseFrequencyY, numOctaves, seed, AsISize(ctileSize)).release()); } +sk_shader_t* sk_shader_new_perlin_noise_improved_noise(float baseFrequencyX, float baseFrequencyY, int numOctaves, float z) { + return ToShader(SkPerlinNoiseShader::MakeImprovedNoise( + baseFrequencyX, baseFrequencyY, numOctaves, z).release()); +} + sk_shader_t* sk_shader_new_compose(sk_shader_t* shaderA, sk_shader_t* shaderB) { return ToShader(SkShader::MakeComposeShader( sk_ref_sp(AsShader(shaderA)), sk_ref_sp(AsShader(shaderB)), SkBlendMode::kSrcOver).release()); From 3a6e1449533362715139559c8006f731bc28472a Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 27 Dec 2019 15:12:35 +0200 Subject: [PATCH 15/24] Removed things --- src/c/sk_bitmap.cpp | 2 +- src/c/sk_imagefilter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c/sk_bitmap.cpp b/src/c/sk_bitmap.cpp index ece370f62c4..33ac1d12c65 100644 --- a/src/c/sk_bitmap.cpp +++ b/src/c/sk_bitmap.cpp @@ -254,7 +254,7 @@ bool sk_bitmap_install_pixels_with_pixmap(sk_bitmap_t* cbitmap, const sk_pixmap_ return AsBitmap(cbitmap)->installPixels(*AsPixmap(cpixmap)); } -SK_API bool sk_bitmap_install_mask_pixels(sk_bitmap_t* cbitmap, const sk_mask_t* cmask) { +bool sk_bitmap_install_mask_pixels(sk_bitmap_t* cbitmap, const sk_mask_t* cmask) { return AsBitmap(cbitmap)->installMaskPixels(*AsMask(cmask)); } diff --git a/src/c/sk_imagefilter.cpp b/src/c/sk_imagefilter.cpp index 92cc156eb91..ef52aad2237 100644 --- a/src/c/sk_imagefilter.cpp +++ b/src/c/sk_imagefilter.cpp @@ -369,7 +369,7 @@ sk_imagefilter_t* sk_imagefilter_new_xfermode( return ToImageFilter(filter.release()); } -SK_API sk_imagefilter_t* sk_imagefilter_new_arithmetic( +sk_imagefilter_t* sk_imagefilter_new_arithmetic( float k1, float k2, float k3, float k4, bool enforcePMColor, sk_imagefilter_t* background, From acad4805dfadf801d6ea62a93652c70a3fbbe10e Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Wed, 8 Jan 2020 02:22:47 +0200 Subject: [PATCH 16/24] Add a few more members for SkCanvas (#72) --- gm/cgm.c | 1 + include/c/sk_canvas.h | 8 +++++- include/c/sk_types.h | 60 +++++-------------------------------------- src/c/sk_canvas.cpp | 26 ++++++++++++++++++- src/c/sk_structs.cpp | 2 ++ src/c/sk_types_priv.h | 1 + tests/CTest.cpp | 43 ++++++++++++++++--------------- 7 files changed, 65 insertions(+), 76 deletions(-) diff --git a/gm/cgm.c b/gm/cgm.c index e3521c1b854..c8a73a6d737 100644 --- a/gm/cgm.c +++ b/gm/cgm.c @@ -10,6 +10,7 @@ #include "sk_canvas.h" #include "sk_data.h" +#include "sk_general.h" #include "sk_image.h" #include "sk_paint.h" #include "sk_shader.h" diff --git a/include/c/sk_canvas.h b/include/c/sk_canvas.h index 50392d2cfec..089b243c700 100644 --- a/include/c/sk_canvas.h +++ b/include/c/sk_canvas.h @@ -70,7 +70,13 @@ SK_C_API void sk_canvas_draw_bitmap_lattice(sk_canvas_t* t, const sk_bitmap_t* b SK_C_API void sk_canvas_draw_image_lattice(sk_canvas_t* t, const sk_image_t* image, const sk_lattice_t* lattice, const sk_rect_t* dst, const sk_paint_t* paint); SK_C_API void sk_canvas_draw_bitmap_nine(sk_canvas_t* t, const sk_bitmap_t* bitmap, const sk_irect_t* center, const sk_rect_t* dst, const sk_paint_t* paint); SK_C_API void sk_canvas_draw_image_nine(sk_canvas_t* t, const sk_image_t* image, const sk_irect_t* center, const sk_rect_t* dst, const sk_paint_t* paint); -SK_C_API void sk_canvas_draw_vertices(sk_canvas_t* ccanvas, sk_vertices_t* vertices, sk_blendmode_t mode, const sk_paint_t* paint); +SK_C_API void sk_canvas_draw_vertices(sk_canvas_t* ccanvas, const sk_vertices_t* vertices, sk_blendmode_t mode, const sk_paint_t* paint); +SK_C_API void sk_canvas_draw_arc(sk_canvas_t* ccanvas, const sk_rect_t* oval, float startAngle, float sweepAngle, bool useCenter, const sk_paint_t* paint); +SK_C_API void sk_canvas_draw_drrect(sk_canvas_t* ccanvas, const sk_rrect_t* outer, const sk_rrect_t* inner, const sk_paint_t* paint); +SK_C_API void sk_canvas_draw_atlas(sk_canvas_t* ccanvas, const sk_image_t* atlas, const sk_rsxform_t* xform, const sk_rect_t* tex, const sk_color_t* colors, int count, sk_blendmode_t mode, const sk_rect_t* cullRect, const sk_paint_t* paint); +SK_C_API void sk_canvas_draw_patch(sk_canvas_t* ccanvas, const sk_point_t* cubics, const sk_color_t* colors, const sk_point_t* texCoords, sk_blendmode_t mode, const sk_paint_t* paint); +SK_C_API bool sk_canvas_is_clip_empty(sk_canvas_t* ccanvas); +SK_C_API bool sk_canvas_is_clip_rect(sk_canvas_t* ccanvas); SK_C_API sk_nodraw_canvas_t* sk_nodraw_canvas_new(int width, int height); SK_C_API void sk_nodraw_canvas_destroy(sk_nodraw_canvas_t*); diff --git a/include/c/sk_types.h b/include/c/sk_types.h index 0a36ba55624..e97ce4430b8 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -112,59 +112,6 @@ typedef struct { float bottom; } sk_rect_t; -/** - The sk_matrix_t struct holds a 3x3 perspective matrix for - transforming coordinates: - - (X,Y) = T[M]((x,y)) - X = (M[0] * x + M[1] * y + M[2]) / (M[6] * x + M[7] * y + M[8]); - Y = (M[3] * x + M[4] * y + M[5]) / (M[6] * x + M[7] * y + M[8]); - - Therefore, the identity matrix is - - sk_matrix_t identity = {{1, 0, 0, - 0, 1, 0, - 0, 0, 1}}; - - A matrix that scales by sx and sy is: - - sk_matrix_t scale = {{sx, 0, 0, - 0, sy, 0, - 0, 0, 1}}; - - A matrix that translates by tx and ty is: - - sk_matrix_t translate = {{1, 0, tx, - 0, 1, ty, - 0, 0, 1}}; - - A matrix that rotates around the origin by A radians: - - sk_matrix_t rotate = {{cos(A), -sin(A), 0, - sin(A), cos(A), 0, - 0, 0, 1}}; - - Two matrixes can be concatinated by: - - void concat_matrices(sk_matrix_t* dst, - const sk_matrix_t* matrixU, - const sk_matrix_t* matrixV) { - const float* u = matrixU->mat; - const float* v = matrixV->mat; - sk_matrix_t result = {{ - u[0] * v[0] + u[1] * v[3] + u[2] * v[6], - u[0] * v[1] + u[1] * v[4] + u[2] * v[7], - u[0] * v[2] + u[1] * v[5] + u[2] * v[8], - u[3] * v[0] + u[4] * v[3] + u[5] * v[6], - u[3] * v[1] + u[4] * v[4] + u[5] * v[7], - u[3] * v[2] + u[4] * v[5] + u[5] * v[8], - u[6] * v[0] + u[7] * v[3] + u[8] * v[6], - u[6] * v[1] + u[7] * v[4] + u[8] * v[7], - u[6] * v[2] + u[7] * v[5] + u[8] * v[8] - }}; - *dst = result; - } -*/ typedef struct { float scaleX, skewX, transX; float skewY, scaleY, transY; @@ -953,6 +900,13 @@ typedef struct { void* clusters; } sk_textblob_builder_runbuffer_t; +typedef struct { + float fSCos; + float fSSin; + float fTX; + float fTY; +} sk_rsxform_t; + SK_C_PLUS_PLUS_END_GUARD #endif diff --git a/src/c/sk_canvas.cpp b/src/c/sk_canvas.cpp index f33f1799b66..f6871a1d9d7 100644 --- a/src/c/sk_canvas.cpp +++ b/src/c/sk_canvas.cpp @@ -258,10 +258,34 @@ void sk_canvas_draw_image_nine(sk_canvas_t* ccanvas, const sk_image_t* image, co AsCanvas(ccanvas)->drawImageNine(AsImage(image), *AsIRect(center), *AsRect(dst), AsPaint(paint)); } -void sk_canvas_draw_vertices(sk_canvas_t* ccanvas, sk_vertices_t* vertices, sk_blendmode_t mode, const sk_paint_t* paint) { +void sk_canvas_draw_vertices(sk_canvas_t* ccanvas, const sk_vertices_t* vertices, sk_blendmode_t mode, const sk_paint_t* paint) { AsCanvas(ccanvas)->drawVertices(AsVertices(vertices), (SkBlendMode)mode, *AsPaint(paint)); } +void sk_canvas_draw_arc(sk_canvas_t* ccanvas, const sk_rect_t* oval, float startAngle, float sweepAngle, bool useCenter, const sk_paint_t* paint) { + AsCanvas(ccanvas)->drawArc(*AsRect(oval), startAngle, sweepAngle, useCenter, *AsPaint(paint)); +} + +void sk_canvas_draw_drrect(sk_canvas_t* ccanvas, const sk_rrect_t* outer, const sk_rrect_t* inner, const sk_paint_t* paint) { + AsCanvas(ccanvas)->drawDRRect(*AsRRect(outer), *AsRRect(inner), *AsPaint(paint)); +} + +void sk_canvas_draw_atlas(sk_canvas_t* ccanvas, const sk_image_t* atlas, const sk_rsxform_t* xform, const sk_rect_t* tex, const sk_color_t* colors, int count, sk_blendmode_t mode, const sk_rect_t* cullRect, const sk_paint_t* paint) { + AsCanvas(ccanvas)->drawAtlas(AsImage(atlas), AsRSXform(xform), AsRect(tex), colors, count, (SkBlendMode)mode, AsRect(cullRect), AsPaint(paint)); +} + +void sk_canvas_draw_patch(sk_canvas_t* ccanvas, const sk_point_t* cubics, const sk_color_t* colors, const sk_point_t* texCoords, sk_blendmode_t mode, const sk_paint_t* paint) { + AsCanvas(ccanvas)->drawPatch(AsPoint(cubics), colors, AsPoint(texCoords), (SkBlendMode)mode, *AsPaint(paint)); +} + +bool sk_canvas_is_clip_empty(sk_canvas_t* ccanvas) { + return AsCanvas(ccanvas)->isClipEmpty(); +} + +bool sk_canvas_is_clip_rect(sk_canvas_t* ccanvas) { + return AsCanvas(ccanvas)->isClipRect(); +} + sk_nodraw_canvas_t* sk_nodraw_canvas_new(int width, int height) { return ToNoDrawCanvas(new SkNoDrawCanvas(width, height)); } diff --git a/src/c/sk_structs.cpp b/src/c/sk_structs.cpp index 2c52a544da8..bb4196a735e 100644 --- a/src/c/sk_structs.cpp +++ b/src/c/sk_structs.cpp @@ -23,6 +23,7 @@ #include "SkDocument.h" #include "SkHighContrastFilter.h" #include "SkTextBlob.h" +#include "SkRSXform.h" #if SK_SUPPORT_GPU #include "GrTypes.h" @@ -61,6 +62,7 @@ static_assert (sizeof (sk_pngencoder_options_t) == sizeof (SkPngEncoder::Options 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)); static_assert (sizeof (sk_textblob_builder_runbuffer_t) == sizeof (SkTextBlobBuilder::RunBuffer), ASSERT_MSG(SkTextBlobBuilder::RunBuffer, sk_textblob_builder_runbuffer_t)); +static_assert (sizeof (sk_rsxform_t) == sizeof (SkRSXform), ASSERT_MSG(SkRSXform, sk_rsxform_t)); #if SK_SUPPORT_GPU static_assert (sizeof (gr_gl_framebufferinfo_t) == sizeof (GrGLFramebufferInfo), ASSERT_MSG(GrGLFramebufferInfo, gr_gl_framebufferinfo_t)); diff --git a/src/c/sk_types_priv.h b/src/c/sk_types_priv.h index df032534bae..93e0314869d 100644 --- a/src/c/sk_types_priv.h +++ b/src/c/sk_types_priv.h @@ -120,6 +120,7 @@ DEF_STRUCT_MAP(SkMask, sk_mask_t, Mask) DEF_STRUCT_MAP(SkPoint, sk_point_t, Point) DEF_STRUCT_MAP(SkPoint3, sk_point3_t, Point3) DEF_STRUCT_MAP(SkRect, sk_rect_t, Rect) +DEF_STRUCT_MAP(SkRSXform, sk_rsxform_t, RSXform) DEF_STRUCT_MAP(SkSize, sk_size_t, Size) DEF_STRUCT_MAP(GrGLTextureInfo, gr_gl_textureinfo_t, GrGLTextureInfo) diff --git a/tests/CTest.cpp b/tests/CTest.cpp index 65d0b806983..eef524e8799 100644 --- a/tests/CTest.cpp +++ b/tests/CTest.cpp @@ -8,6 +8,7 @@ #include "Test.h" #include "sk_canvas.h" #include "sk_paint.h" +#include "sk_general.h" #include "sk_shader.h" #include "sk_surface.h" #include "sk_types.h" @@ -103,13 +104,13 @@ static void test_c(skiatest::Reporter* reporter) { static void null_imageinfo_test(skiatest::Reporter* reporter) { auto cppinfo = SkImageInfo::Make(0, 0, (SkColorType)0, (SkAlphaType)0, nullptr); - auto cinfo = ToImageInfo(&cppinfo); + auto cinfo = ToImageInfo(cppinfo); - REPORTER_ASSERT(reporter, cinfo->width == 0); - REPORTER_ASSERT(reporter, cinfo->height == 0); - REPORTER_ASSERT(reporter, cinfo->colorType == (sk_colortype_t)0); - REPORTER_ASSERT(reporter, cinfo->alphaType == (sk_alphatype_t)0); - REPORTER_ASSERT(reporter, cinfo->colorspace == nullptr); + REPORTER_ASSERT(reporter, cinfo.width == 0); + REPORTER_ASSERT(reporter, cinfo.height == 0); + REPORTER_ASSERT(reporter, cinfo.colorType == (sk_colortype_t)0); + REPORTER_ASSERT(reporter, cinfo.alphaType == (sk_alphatype_t)0); + REPORTER_ASSERT(reporter, cinfo.colorspace == nullptr); } static void nonnull_imageinfo_test(skiatest::Reporter* reporter) { @@ -117,14 +118,14 @@ static void nonnull_imageinfo_test(skiatest::Reporter* reporter) { sk_colorspace_t* csptr = ToColorSpace(cs.get()); SkImageInfo cppinfo = SkImageInfo::Make(1, 2, (SkColorType)3, (SkAlphaType)4, cs); - sk_imageinfo_t* cinfo = ToImageInfo(&cppinfo); + sk_imageinfo_t cinfo = ToImageInfo(cppinfo); - REPORTER_ASSERT(reporter, cinfo->width == 1); - REPORTER_ASSERT(reporter, cinfo->height == 2); - REPORTER_ASSERT(reporter, cinfo->colorType == (sk_colortype_t)3); - REPORTER_ASSERT(reporter, cinfo->alphaType == (sk_alphatype_t)4); - REPORTER_ASSERT(reporter, cinfo->colorspace != nullptr); - REPORTER_ASSERT(reporter, cinfo->colorspace == ToColorSpace(cs.get())); + REPORTER_ASSERT(reporter, cinfo.width == 1); + REPORTER_ASSERT(reporter, cinfo.height == 2); + REPORTER_ASSERT(reporter, cinfo.colorType == (sk_colortype_t)3); + REPORTER_ASSERT(reporter, cinfo.alphaType == (sk_alphatype_t)4); + REPORTER_ASSERT(reporter, cinfo.colorspace != nullptr); + REPORTER_ASSERT(reporter, cinfo.colorspace == ToColorSpace(cs.get())); sk_imageinfo_t newcinfo = { csptr, @@ -133,14 +134,14 @@ static void nonnull_imageinfo_test(skiatest::Reporter* reporter) { (sk_colortype_t)3, (sk_alphatype_t)4 }; - SkImageInfo* newcppinfo = AsImageInfo(&newcinfo); - - REPORTER_ASSERT(reporter, newcppinfo->width() == 1); - REPORTER_ASSERT(reporter, newcppinfo->height() == 2); - REPORTER_ASSERT(reporter, newcppinfo->colorType() == (SkColorType)3); - REPORTER_ASSERT(reporter, newcppinfo->alphaType() == (SkAlphaType)4); - REPORTER_ASSERT(reporter, newcppinfo->colorSpace() != nullptr); - REPORTER_ASSERT(reporter, newcppinfo->colorSpace() == AsColorSpace(csptr)); + SkImageInfo newcppinfo = AsImageInfo(&newcinfo); + + REPORTER_ASSERT(reporter, newcppinfo.width() == 1); + REPORTER_ASSERT(reporter, newcppinfo.height() == 2); + REPORTER_ASSERT(reporter, newcppinfo.colorType() == (SkColorType)3); + REPORTER_ASSERT(reporter, newcppinfo.alphaType() == (SkAlphaType)4); + REPORTER_ASSERT(reporter, newcppinfo.colorSpace() != nullptr); + REPORTER_ASSERT(reporter, newcppinfo.colorSpace() == AsColorSpace(csptr)); } DEF_TEST(C_API, reporter) { From 2186405bc20d47b28fd857ce0fd0c1ccf1bccc91 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Wed, 29 Jan 2020 22:08:16 +0200 Subject: [PATCH 17/24] Adding the SkColor4f (with SkColorSpace) overloads (#74) * Add SkColor4f for SkPixmap * Add the SkShader variants --- include/c/sk_colorspace.h | 8 +++ include/c/sk_pixmap.h | 1 + include/c/sk_shader.h | 98 ++++++++------------------ include/c/sk_types.h | 7 ++ src/c/sk_colorspace.cpp | 17 +++++ src/c/sk_pixmap.cpp | 6 +- src/c/sk_shader.cpp | 143 +++++++++++++++++++++----------------- src/c/sk_structs.cpp | 1 + src/c/sk_types_priv.h | 1 + 9 files changed, 151 insertions(+), 131 deletions(-) diff --git a/include/c/sk_colorspace.h b/include/c/sk_colorspace.h index 4682b4683ca..866d76f7bd0 100644 --- a/include/c/sk_colorspace.h +++ b/include/c/sk_colorspace.h @@ -14,6 +14,8 @@ SK_C_PLUS_PLUS_BEGIN_GUARD +// sk_colorspace_t + SK_C_API void sk_colorspace_unref(sk_colorspace_t* cColorSpace); SK_C_API sk_colorspace_t* sk_colorspace_new_srgb(void); SK_C_API sk_colorspace_t* sk_colorspace_new_srgb_linear(void); @@ -38,6 +40,12 @@ SK_C_API bool sk_colorspaceprimaries_to_xyzd50(const sk_colorspaceprimaries_t* p SK_C_API void sk_colorspace_transfer_fn_invert(const sk_colorspace_transfer_fn_t* transfer, sk_colorspace_transfer_fn_t* inverted); SK_C_API float sk_colorspace_transfer_fn_transform(const sk_colorspace_transfer_fn_t* transfer, float x); +// sk_color4f_t + +SK_C_API sk_color_t sk_color4f_to_color(const sk_color4f_t* color4f); +SK_C_API void sk_color4f_from_color(sk_color_t color, sk_color4f_t* color4f); +SK_C_API void sk_color4f_pin(const sk_color4f_t* color4f, sk_color4f_t* pinned); + SK_C_PLUS_PLUS_END_GUARD #endif diff --git a/include/c/sk_pixmap.h b/include/c/sk_pixmap.h index 46a2bd14f0a..cbcc15e1d86 100644 --- a/include/c/sk_pixmap.h +++ b/include/c/sk_pixmap.h @@ -29,6 +29,7 @@ SK_C_API bool sk_pixmap_read_pixels(const sk_pixmap_t* cpixmap, const sk_imagein SK_C_API bool sk_pixmap_scale_pixels(const sk_pixmap_t* cpixmap, const sk_pixmap_t* dst, sk_filter_quality_t quality); SK_C_API bool sk_pixmap_extract_subset(const sk_pixmap_t* cpixmap, sk_pixmap_t* result, const sk_irect_t* subset); SK_C_API bool sk_pixmap_erase_color(const sk_pixmap_t* cpixmap, sk_color_t color, const sk_irect_t* subset); +SK_C_API bool sk_pixmap_erase_color4f(const sk_pixmap_t* cpixmap, const sk_color4f_t* color, const sk_irect_t* subset); SK_C_API sk_color_t sk_color_unpremultiply(const sk_pmcolor_t pmcolor); SK_C_API sk_pmcolor_t sk_color_premultiply(const sk_color_t color); diff --git a/include/c/sk_shader.h b/include/c/sk_shader.h index a0f292ad9bb..74c4823781d 100644 --- a/include/c/sk_shader.h +++ b/include/c/sk_shader.h @@ -14,76 +14,38 @@ SK_C_PLUS_PLUS_BEGIN_GUARD -SK_C_API void sk_shader_ref(sk_shader_t*); -SK_C_API void sk_shader_unref(sk_shader_t*); -SK_C_API sk_shader_t* sk_shader_new_linear_gradient(const sk_point_t points[2], - const sk_color_t colors[], - const float colorPos[], - int colorCount, - sk_shader_tilemode_t tileMode, - const sk_matrix_t* localMatrix); -SK_C_API sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* center, - float radius, - const sk_color_t colors[], - const float colorPos[], - int colorCount, - sk_shader_tilemode_t tileMode, - const sk_matrix_t* localMatrix); -SK_C_API sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* center, - const sk_color_t colors[], - const float colorPos[], - int colorCount, - sk_shader_tilemode_t tileMode, - float startAngle, - float endAngle, - const sk_matrix_t* localMatrix); -SK_C_API sk_shader_t* sk_shader_new_two_point_conical_gradient( - const sk_point_t* start, - float startRadius, - const sk_point_t* end, - float endRadius, - const sk_color_t colors[], - const float colorPos[], - int colorCount, - sk_shader_tilemode_t tileMode, - const sk_matrix_t* localMatrix); +// SkShader + +SK_C_API void sk_shader_ref(sk_shader_t* shader); +SK_C_API void sk_shader_unref(sk_shader_t* shader); +SK_C_API sk_shader_t* sk_shader_with_local_matrix(const sk_shader_t* shader, const sk_matrix_t* localMatrix); +SK_C_API sk_shader_t* sk_shader_with_color_filter(const sk_shader_t* shader, const sk_colorfilter_t* filter); + +// SkShaders + SK_C_API sk_shader_t* sk_shader_new_empty(void); SK_C_API sk_shader_t* sk_shader_new_color(sk_color_t color); -SK_C_API sk_shader_t* sk_shader_new_bitmap(const sk_bitmap_t* src, - sk_shader_tilemode_t tmx, - sk_shader_tilemode_t tmy, - const sk_matrix_t* localMatrix); -SK_C_API sk_shader_t* sk_shader_new_picture(sk_picture_t* src, - sk_shader_tilemode_t tmx, - sk_shader_tilemode_t tmy, - const sk_matrix_t* localMatrix, - const sk_rect_t* tile); -SK_C_API sk_shader_t* sk_shader_new_local_matrix(sk_shader_t* proxy, const sk_matrix_t* localMatrix); -SK_C_API sk_shader_t* sk_shader_new_color_filter(sk_shader_t* proxy, sk_colorfilter_t* filter); -SK_C_API sk_shader_t* sk_shader_new_perlin_noise_fractal_noise( - float baseFrequencyX, - float baseFrequencyY, - int numOctaves, - float seed, - const sk_isize_t* tileSize); -SK_C_API sk_shader_t* sk_shader_new_perlin_noise_turbulence( - float baseFrequencyX, - float baseFrequencyY, - int numOctaves, - float seed, - const sk_isize_t* tileSize); -SK_C_API sk_shader_t* sk_shader_new_perlin_noise_improved_noise( - float baseFrequencyX, - float baseFrequencyY, - int numOctaves, - float z); -SK_C_API sk_shader_t* sk_shader_new_compose( - sk_shader_t* shaderA, - sk_shader_t* shaderB); -SK_C_API sk_shader_t* sk_shader_new_compose_with_mode( - sk_shader_t* shaderA, - sk_shader_t* shaderB, - sk_blendmode_t mode); +SK_C_API sk_shader_t* sk_shader_new_color4f(const sk_color4f_t* color, const sk_colorspace_t* colorspace); +SK_C_API sk_shader_t* sk_shader_new_compose(const sk_shader_t* shaderA, const sk_shader_t* shaderB, sk_blendmode_t mode); +SK_C_API sk_shader_t* sk_shader_new_bitmap(const sk_bitmap_t* src, sk_shader_tilemode_t tmx, sk_shader_tilemode_t tmy, const sk_matrix_t* localMatrix); +SK_C_API sk_shader_t* sk_shader_new_picture(sk_picture_t* src, sk_shader_tilemode_t tmx, sk_shader_tilemode_t tmy, const sk_matrix_t* localMatrix, const sk_rect_t* tile); + +// SkGradientShader + +SK_C_API sk_shader_t* sk_shader_new_linear_gradient(const sk_point_t points[2], const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); +SK_C_API sk_shader_t* sk_shader_new_linear_gradient_color4f(const sk_point_t points[2], const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); +SK_C_API sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* center, float radius, const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); +SK_C_API sk_shader_t* sk_shader_new_radial_gradient_color4f(const sk_point_t* center, float radius, const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); +SK_C_API sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* center, const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, float startAngle, float endAngle, const sk_matrix_t* localMatrix); +SK_C_API sk_shader_t* sk_shader_new_sweep_gradient_color4f(const sk_point_t* center, const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, float startAngle, float endAngle, const sk_matrix_t* localMatrix); +SK_C_API sk_shader_t* sk_shader_new_two_point_conical_gradient(const sk_point_t* start, float startRadius, const sk_point_t* end, float endRadius, const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); +SK_C_API sk_shader_t* sk_shader_new_two_point_conical_gradient_color4f(const sk_point_t* start, float startRadius, const sk_point_t* end, float endRadius, const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix); + +// SkPerlinNoiseShader + +SK_C_API sk_shader_t* sk_shader_new_perlin_noise_fractal_noise(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, const sk_isize_t* tileSize); +SK_C_API sk_shader_t* sk_shader_new_perlin_noise_turbulence(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, const sk_isize_t* tileSize); +SK_C_API sk_shader_t* sk_shader_new_perlin_noise_improved_noise(float baseFrequencyX, float baseFrequencyY, int numOctaves, float z); SK_C_PLUS_PLUS_END_GUARD diff --git a/include/c/sk_types.h b/include/c/sk_types.h index e97ce4430b8..ab138467b76 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -55,6 +55,13 @@ typedef uint32_t sk_pmcolor_t; #define sk_color_get_g(c) (((c) >> 8) & 0xFF) #define sk_color_get_b(c) (((c) >> 0) & 0xFF) +typedef struct sk_color4f_t { + float fR; + float fG; + float fB; + float fA; +} sk_color4f_t; + typedef enum { UNKNOWN_SK_COLORTYPE = 0, ALPHA_8_SK_COLORTYPE, diff --git a/src/c/sk_colorspace.cpp b/src/c/sk_colorspace.cpp index 8b4d7d4534d..5bed41a1cf1 100644 --- a/src/c/sk_colorspace.cpp +++ b/src/c/sk_colorspace.cpp @@ -13,6 +13,8 @@ #include "sk_types_priv.h" +// sk_colorspace_t + void sk_colorspace_unref(sk_colorspace_t* cColorSpace) { SkSafeUnref(AsColorSpace(cColorSpace)); } @@ -105,3 +107,18 @@ float sk_colorspace_transfer_fn_transform(const sk_colorspace_transfer_fn_t* tra SkColorSpaceTransferFn fn = *AsColorSpaceTransferFn(transfer); return fn(x); } + + +// sk_color4f_t + +sk_color_t sk_color4f_to_color(const sk_color4f_t* color4f) { + return AsColor4f(color4f)->toSkColor(); +} + +void sk_color4f_from_color(sk_color_t color, sk_color4f_t* color4f) { + *color4f = ToColor4f(SkColor4f::FromColor(color)); +} + +void sk_color4f_pin(const sk_color4f_t* color4f, sk_color4f_t* pinned) { + *pinned = ToColor4f(AsColor4f(color4f)->pin()); +} diff --git a/src/c/sk_pixmap.cpp b/src/c/sk_pixmap.cpp index a43f56e0d4d..846a6485ad1 100644 --- a/src/c/sk_pixmap.cpp +++ b/src/c/sk_pixmap.cpp @@ -64,10 +64,14 @@ bool sk_pixmap_extract_subset(const sk_pixmap_t* cpixmap, sk_pixmap_t* result, c return AsPixmap(cpixmap)->extractSubset(AsPixmap(result), *AsIRect(subset)); } -bool sk_pixmap_erase_color (const sk_pixmap_t* cpixmap, sk_color_t color, const sk_irect_t* subset) { +bool sk_pixmap_erase_color(const sk_pixmap_t* cpixmap, sk_color_t color, const sk_irect_t* subset) { return AsPixmap(cpixmap)->erase((SkColor)color, *AsIRect(subset)); } +bool sk_pixmap_erase_color4f(const sk_pixmap_t* cpixmap, const sk_color4f_t* color, const sk_irect_t* subset) { + return AsPixmap(cpixmap)->erase(*AsColor4f(color), AsIRect(subset)); +} + sk_color_t sk_color_unpremultiply(const sk_pmcolor_t pmcolor) { return SkUnPreMultiply::PMColorToColor(pmcolor); } diff --git a/src/c/sk_shader.cpp b/src/c/sk_shader.cpp index 3d4b95c3ef9..4bec829e1a9 100644 --- a/src/c/sk_shader.cpp +++ b/src/c/sk_shader.cpp @@ -17,7 +17,27 @@ #include "sk_types_priv.h" -sk_shader_t* sk_shader_new_empty() { +// SkShader + +void sk_shader_ref(sk_shader_t* shader){ + SkSafeRef(AsShader(shader)); +} + +void sk_shader_unref(sk_shader_t* shader){ + SkSafeUnref(AsShader(shader)); +} + +sk_shader_t* sk_shader_with_local_matrix(const sk_shader_t* shader, const sk_matrix_t* localMatrix) { + return ToShader(AsShader(shader)->makeWithLocalMatrix(AsMatrix(localMatrix)).release()); +} + +sk_shader_t* sk_shader_with_color_filter(const sk_shader_t* shader, const sk_colorfilter_t* filter) { + return ToShader(AsShader(shader)->makeWithColorFilter(sk_ref_sp(AsColorFilter(filter))).release()); +} + +// SkShaders + +sk_shader_t* sk_shader_new_empty(void) { return ToShader(SkShader::MakeEmptyShader().release()); } @@ -25,97 +45,96 @@ sk_shader_t* sk_shader_new_color(sk_color_t color) { return ToShader(SkShader::MakeColorShader(color).release()); } +sk_shader_t* sk_shader_new_color4f(const sk_color4f_t* color, const sk_colorspace_t* colorspace) { + return ToShader(SkShader::MakeColorShader(*AsColor4f(color), sk_ref_sp(AsColorSpace(colorspace))).release()); +} + +sk_shader_t* sk_shader_new_compose(const sk_shader_t* shaderA, const sk_shader_t* shaderB, sk_blendmode_t mode) { + return ToShader(SkShader::MakeComposeShader(sk_ref_sp(AsShader(shaderA)), sk_ref_sp(AsShader(shaderB)), (SkBlendMode)mode).release()); +} + sk_shader_t* sk_shader_new_bitmap(const sk_bitmap_t* src, sk_shader_tilemode_t tmx, sk_shader_tilemode_t tmy, const sk_matrix_t* localMatrix) { SkMatrix m; - if (localMatrix) { + if (localMatrix) m = AsMatrix(localMatrix); - } - return ToShader(SkShader::MakeBitmapShader( - *AsBitmap(src), (SkShader::TileMode)tmx, (SkShader::TileMode)tmy, localMatrix ? &m : nullptr).release()); + return ToShader(SkShader::MakeBitmapShader(*AsBitmap(src), (SkShader::TileMode)tmx, (SkShader::TileMode)tmy, localMatrix ? &m : nullptr).release()); } sk_shader_t* sk_shader_new_picture(sk_picture_t* src, sk_shader_tilemode_t tmx, sk_shader_tilemode_t tmy, const sk_matrix_t* localMatrix, const sk_rect_t* tile) { SkMatrix m; - if (localMatrix) { + if (localMatrix) m = AsMatrix(localMatrix); - } - return ToShader(SkShader::MakePictureShader( - sk_ref_sp(AsPicture(src)), (SkShader::TileMode)tmx, (SkShader::TileMode)tmy, localMatrix ? &m : nullptr, AsRect(tile)).release()); + return ToShader(SkShader::MakePictureShader(sk_ref_sp(AsPicture(src)), (SkShader::TileMode)tmx, (SkShader::TileMode)tmy, localMatrix ? &m : nullptr, AsRect(tile)).release()); } -sk_shader_t* sk_shader_new_color_filter(sk_shader_t* proxy, sk_colorfilter_t* filter) { - return ToShader(AsShader(proxy)->makeWithColorFilter(sk_ref_sp(AsColorFilter(filter))).release()); -} +// SkGradientShader -sk_shader_t* sk_shader_new_local_matrix(sk_shader_t* proxy, const sk_matrix_t* localMatrix) { - return ToShader(AsShader(proxy)->makeWithLocalMatrix(AsMatrix(localMatrix)).release()); -} - -sk_shader_t* sk_shader_new_perlin_noise_fractal_noise(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, const sk_isize_t* ctileSize) { - return ToShader(SkPerlinNoiseShader::MakeFractalNoise( - baseFrequencyX, baseFrequencyY, numOctaves, seed, AsISize(ctileSize)).release()); +sk_shader_t* sk_shader_new_linear_gradient(const sk_point_t points[2], const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix) { + SkMatrix m; + if (localMatrix) + m = AsMatrix(localMatrix); + return ToShader(SkGradientShader::MakeLinear(AsPoint(points), colors, colorPos, colorCount, (SkShader::TileMode)tileMode, 0, localMatrix ? &m : nullptr).release()); } -sk_shader_t* sk_shader_new_perlin_noise_turbulence(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, const sk_isize_t* ctileSize) { - return ToShader(SkPerlinNoiseShader::MakeTurbulence( - baseFrequencyX, baseFrequencyY, numOctaves, seed, AsISize(ctileSize)).release()); +sk_shader_t* sk_shader_new_linear_gradient_color4f(const sk_point_t points[2], const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix) { + SkMatrix m; + if (localMatrix) + m = AsMatrix(localMatrix); + return ToShader(SkGradientShader::MakeLinear(AsPoint(points), AsColor4f(colors), sk_ref_sp(AsColorSpace(colorspace)), colorPos, colorCount, (SkShader::TileMode)tileMode, 0, localMatrix ? &m : nullptr).release()); } -sk_shader_t* sk_shader_new_perlin_noise_improved_noise(float baseFrequencyX, float baseFrequencyY, int numOctaves, float z) { - return ToShader(SkPerlinNoiseShader::MakeImprovedNoise( - baseFrequencyX, baseFrequencyY, numOctaves, z).release()); +sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* center, float radius, const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix) { + SkMatrix m; + if (localMatrix) + m = AsMatrix(localMatrix); + return ToShader(SkGradientShader::MakeRadial(*AsPoint(center), (SkScalar)radius, colors, colorPos, colorCount, (SkShader::TileMode)tileMode, 0, localMatrix ? &m : nullptr).release()); } -sk_shader_t* sk_shader_new_compose(sk_shader_t* shaderA, sk_shader_t* shaderB) { - return ToShader(SkShader::MakeComposeShader( - sk_ref_sp(AsShader(shaderA)), sk_ref_sp(AsShader(shaderB)), SkBlendMode::kSrcOver).release()); +sk_shader_t* sk_shader_new_radial_gradient_color4f(const sk_point_t* center, float radius, const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix) { + SkMatrix m; + if (localMatrix) + m = AsMatrix(localMatrix); + return ToShader(SkGradientShader::MakeRadial(*AsPoint(center), (SkScalar)radius, AsColor4f(colors), sk_ref_sp(AsColorSpace(colorspace)), colorPos, colorCount, (SkShader::TileMode)tileMode, 0, localMatrix ? &m : nullptr).release()); } -sk_shader_t* sk_shader_new_compose_with_mode(sk_shader_t* shaderA, sk_shader_t* shaderB, sk_blendmode_t cmode) { - return ToShader(SkShader::MakeComposeShader( - sk_ref_sp(AsShader(shaderA)), sk_ref_sp(AsShader(shaderB)), (SkBlendMode)cmode).release()); +sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* center, const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, float startAngle, float endAngle, const sk_matrix_t* localMatrix) { + SkMatrix m; + if (localMatrix) + m = AsMatrix(localMatrix); + return ToShader(SkGradientShader::MakeSweep(center->x, center->y, colors, colorPos, colorCount, (SkShader::TileMode)tileMode, startAngle, endAngle, 0, localMatrix ? &m : nullptr).release()); } -void sk_shader_ref(sk_shader_t* cshader) { - SkSafeRef(AsShader(cshader)); +sk_shader_t* sk_shader_new_sweep_gradient_color4f(const sk_point_t* center, const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, float startAngle, float endAngle, const sk_matrix_t* localMatrix) { + SkMatrix m; + if (localMatrix) + m = AsMatrix(localMatrix); + return ToShader(SkGradientShader::MakeSweep(center->x, center->y, AsColor4f(colors), sk_ref_sp(AsColorSpace(colorspace)), colorPos, colorCount, (SkShader::TileMode)tileMode, startAngle, endAngle, 0, localMatrix ? &m : nullptr).release()); } -void sk_shader_unref(sk_shader_t* cshader) { - SkSafeUnref(AsShader(cshader)); +sk_shader_t* sk_shader_new_two_point_conical_gradient(const sk_point_t* start, float startRadius, const sk_point_t* end, float endRadius, const sk_color_t colors[], const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix) { + SkMatrix m; + if (localMatrix) + m = AsMatrix(localMatrix); + return ToShader(SkGradientShader::MakeTwoPointConical(*AsPoint(start), startRadius, *AsPoint(end), endRadius, colors, colorPos, colorCount, (SkShader::TileMode)tileMode, 0, localMatrix ? &m : nullptr).release()); } -sk_shader_t* sk_shader_new_linear_gradient(const sk_point_t pts[2], const sk_color_t* colors, const float* colorPos, int colorCount, sk_shader_tilemode_t cmode, const sk_matrix_t* cmatrix) { +sk_shader_t* sk_shader_new_two_point_conical_gradient_color4f(const sk_point_t* start, float startRadius, const sk_point_t* end, float endRadius, const sk_color4f_t* colors, const sk_colorspace_t* colorspace, const float colorPos[], int colorCount, sk_shader_tilemode_t tileMode, const sk_matrix_t* localMatrix) { SkMatrix m; - if (cmatrix) { - m = AsMatrix(cmatrix); - } - return ToShader(SkGradientShader::MakeLinear( - AsPoint(pts), colors, colorPos, colorCount, (SkShader::TileMode)cmode, 0, cmatrix ? &m : nullptr).release()); + if (localMatrix) + m = AsMatrix(localMatrix); + return ToShader(SkGradientShader::MakeTwoPointConical(*AsPoint(start), startRadius, *AsPoint(end), endRadius, AsColor4f(colors), sk_ref_sp(AsColorSpace(colorspace)), colorPos, colorCount, (SkShader::TileMode)tileMode, 0, localMatrix ? &m : nullptr).release()); } -sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* ccenter, float radius, const sk_color_t* colors, const float* colorPos, int colorCount, sk_shader_tilemode_t cmode, const sk_matrix_t* cmatrix) { - SkMatrix m; - if (cmatrix) { - m = AsMatrix(cmatrix); - } - return ToShader(SkGradientShader::MakeRadial( - *AsPoint(ccenter), (SkScalar)radius, colors, colorPos, colorCount, (SkShader::TileMode)cmode, 0, cmatrix ? &m : nullptr).release()); +// SkPerlinNoiseShader + +sk_shader_t* sk_shader_new_perlin_noise_fractal_noise(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, const sk_isize_t* tileSize) { + return ToShader(SkPerlinNoiseShader::MakeFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed, AsISize(tileSize)).release()); } -sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* ccenter, const sk_color_t* colors, const float* colorPos, int colorCount, sk_shader_tilemode_t cmode, float startAngle, float endAngle, const sk_matrix_t* cmatrix) { - SkMatrix m; - if (cmatrix) { - m = AsMatrix(cmatrix); - } - return ToShader(SkGradientShader::MakeSweep( - ccenter->x, ccenter->y, colors, colorPos, colorCount, (SkShader::TileMode)cmode, startAngle, endAngle, 0, cmatrix ? &m : nullptr).release()); +sk_shader_t* sk_shader_new_perlin_noise_turbulence(float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, const sk_isize_t* tileSize) { + return ToShader(SkPerlinNoiseShader::MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, AsISize(tileSize)).release()); } -sk_shader_t* sk_shader_new_two_point_conical_gradient(const sk_point_t* start, float startRadius, const sk_point_t* end, float endRadius, const sk_color_t* colors, const float* colorPos, int colorCount, sk_shader_tilemode_t cmode, const sk_matrix_t* cmatrix) { - SkMatrix m; - if (cmatrix) { - m = AsMatrix(cmatrix); - } - return ToShader(SkGradientShader::MakeTwoPointConical( - *AsPoint(start), startRadius, *AsPoint(end), endRadius, colors, colorPos, colorCount, (SkShader::TileMode)cmode, 0, cmatrix ? &m : nullptr).release()); +sk_shader_t* sk_shader_new_perlin_noise_improved_noise(float baseFrequencyX, float baseFrequencyY, int numOctaves, float z) { + return ToShader(SkPerlinNoiseShader::MakeImprovedNoise(baseFrequencyX, baseFrequencyY, numOctaves, z).release()); } diff --git a/src/c/sk_structs.cpp b/src/c/sk_structs.cpp index bb4196a735e..a035dd8a4cf 100644 --- a/src/c/sk_structs.cpp +++ b/src/c/sk_structs.cpp @@ -63,6 +63,7 @@ static_assert (sizeof (sk_jpegencoder_options_t) == sizeof (SkJpegEncoder::Optio static_assert (sizeof (sk_webpencoder_options_t) == sizeof (SkWebpEncoder::Options), ASSERT_MSG(SkWebpEncoder::Options, sk_webpencoder_options_t)); static_assert (sizeof (sk_textblob_builder_runbuffer_t) == sizeof (SkTextBlobBuilder::RunBuffer), ASSERT_MSG(SkTextBlobBuilder::RunBuffer, sk_textblob_builder_runbuffer_t)); static_assert (sizeof (sk_rsxform_t) == sizeof (SkRSXform), ASSERT_MSG(SkRSXform, sk_rsxform_t)); +static_assert (sizeof (sk_color4f_t) == sizeof (SkColor4f), ASSERT_MSG(SkColor4f, sk_color4f_t)); #if SK_SUPPORT_GPU static_assert (sizeof (gr_gl_framebufferinfo_t) == sizeof (GrGLFramebufferInfo), ASSERT_MSG(GrGLFramebufferInfo, gr_gl_framebufferinfo_t)); diff --git a/src/c/sk_types_priv.h b/src/c/sk_types_priv.h index 93e0314869d..9342ef8ce5d 100644 --- a/src/c/sk_types_priv.h +++ b/src/c/sk_types_priv.h @@ -110,6 +110,7 @@ DEF_CLASS_MAP(GrContext, gr_context_t, GrContext) DEF_CLASS_MAP(GrBackendTexture, gr_backendtexture_t, GrBackendTexture) DEF_CLASS_MAP(GrBackendRenderTarget, gr_backendrendertarget_t, GrBackendRenderTarget) +DEF_STRUCT_MAP(SkColor4f, sk_color4f_t, Color4f) DEF_STRUCT_MAP(SkColorSpacePrimaries, sk_colorspaceprimaries_t, ColorSpacePrimaries) DEF_STRUCT_MAP(SkColorSpaceTransferFn, sk_colorspace_transfer_fn_t, ColorSpaceTransferFn) DEF_STRUCT_MAP(SkHighContrastConfig, sk_highcontrastconfig_t, HighContrastConfig) From 676c0984e44e67726c214625266ed10cd5ff4b7e Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Wed, 5 Feb 2020 11:50:49 +0200 Subject: [PATCH 18/24] Added the rest of SkRegion members --- include/c/sk_region.h | 57 +++++++++++++--- include/c/sk_types.h | 3 + src/c/sk_region.cpp | 152 +++++++++++++++++++++++++++++++++++------- src/c/sk_types_priv.h | 5 ++ 4 files changed, 183 insertions(+), 34 deletions(-) diff --git a/include/c/sk_region.h b/include/c/sk_region.h index 719a31ded62..60abcd00d9d 100755 --- a/include/c/sk_region.h +++ b/include/c/sk_region.h @@ -15,19 +15,54 @@ SK_C_PLUS_PLUS_BEGIN_GUARD +// sk_region_t + SK_C_API sk_region_t* sk_region_new(void); -SK_C_API sk_region_t* sk_region_new2(const sk_region_t* region); -SK_C_API void sk_region_delete(sk_region_t* cpath); -SK_C_API bool sk_region_contains(sk_region_t* r, const sk_region_t* region); -SK_C_API bool sk_region_contains2(sk_region_t* r, int x, int y); -SK_C_API bool sk_region_intersects_rect(sk_region_t* r, const sk_irect_t* rect); -SK_C_API bool sk_region_intersects(sk_region_t* r, const sk_region_t* src); -SK_C_API bool sk_region_set_path(sk_region_t* dst, const sk_path_t* t, const sk_region_t* clip); -SK_C_API bool sk_region_set_rect(sk_region_t* dst, const sk_irect_t* rect); +SK_C_API void sk_region_delete(sk_region_t* r); +SK_C_API bool sk_region_is_empty(const sk_region_t* r); +SK_C_API bool sk_region_is_rect(const sk_region_t* r); +SK_C_API bool sk_region_is_complex(const sk_region_t* r); +SK_C_API void sk_region_get_bounds(const sk_region_t* r, sk_irect_t* rect); +SK_C_API bool sk_region_get_boundary_path(const sk_region_t* r, sk_path_t* path); +SK_C_API bool sk_region_set_empty(sk_region_t* r); +SK_C_API bool sk_region_set_rect(sk_region_t* r, const sk_irect_t* rect); +SK_C_API bool sk_region_set_rects(sk_region_t* r, const sk_irect_t* rects, int count); SK_C_API bool sk_region_set_region(sk_region_t* r, const sk_region_t* region); -SK_C_API bool sk_region_op(sk_region_t* dst, int left, int top, int right, int bottom, sk_region_op_t op); -SK_C_API bool sk_region_op2(sk_region_t* dst, sk_region_t* src, sk_region_op_t op); -SK_C_API void sk_region_get_bounds(sk_region_t* r, sk_irect_t* rect); +SK_C_API bool sk_region_set_path(sk_region_t* r, const sk_path_t* t, const sk_region_t* clip); +SK_C_API bool sk_region_intersects_rect(const sk_region_t* r, const sk_irect_t* rect); +SK_C_API bool sk_region_intersects(const sk_region_t* r, const sk_region_t* src); +SK_C_API bool sk_region_contains_point(const sk_region_t* r, int x, int y); +SK_C_API bool sk_region_contains_rect(const sk_region_t* r, const sk_irect_t* rect); +SK_C_API bool sk_region_contains(const sk_region_t* r, const sk_region_t* region); +SK_C_API bool sk_region_quick_contains(const sk_region_t* r, const sk_irect_t* rect); +SK_C_API bool sk_region_quick_reject_rect(const sk_region_t* r, const sk_irect_t* rect); +SK_C_API bool sk_region_quick_reject(const sk_region_t* r, const sk_region_t* region); +SK_C_API void sk_region_translate(sk_region_t* r, int x, int y); +SK_C_API bool sk_region_op_rect(sk_region_t* r, const sk_irect_t* rect, sk_region_op_t op); +SK_C_API bool sk_region_op(sk_region_t* r, const sk_region_t* region, sk_region_op_t op); + +// sk_region_iterator_t + +SK_C_API sk_region_iterator_t* sk_region_iterator_new(const sk_region_t* region); +SK_C_API void sk_region_iterator_delete(sk_region_iterator_t* iter); +SK_C_API bool sk_region_iterator_rewind(sk_region_iterator_t* iter); +SK_C_API bool sk_region_iterator_done(const sk_region_iterator_t* iter); +SK_C_API void sk_region_iterator_next(sk_region_iterator_t* iter); +SK_C_API void sk_region_iterator_rect(const sk_region_iterator_t* iter, sk_irect_t* rect); + +// sk_region_cliperator_t + +SK_C_API sk_region_cliperator_t* sk_region_cliperator_new(const sk_region_t* region, const sk_irect_t* clip); +SK_C_API void sk_region_cliperator_delete(sk_region_cliperator_t* iter); +SK_C_API bool sk_region_cliperator_done(sk_region_cliperator_t* iter); +SK_C_API void sk_region_cliperator_next(sk_region_cliperator_t* iter); +SK_C_API void sk_region_cliperator_rect(const sk_region_cliperator_t* iter, sk_irect_t* rect); + +// sk_region_spanerator_t + +SK_C_API sk_region_spanerator_t* sk_region_spanerator_new(const sk_region_t* region, int y, int left, int right); +SK_C_API void sk_region_spanerator_delete(sk_region_spanerator_t* iter); +SK_C_API bool sk_region_spanerator_next(sk_region_spanerator_t* iter, int* left, int* right); SK_C_PLUS_PLUS_END_GUARD diff --git a/include/c/sk_types.h b/include/c/sk_types.h index ab138467b76..e77228b67cf 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -208,6 +208,9 @@ typedef struct sk_surface_t sk_surface_t; clipping areas for drawing. */ typedef struct sk_region_t sk_region_t; +typedef struct sk_region_iterator_t sk_region_iterator_t; +typedef struct sk_region_cliperator_t sk_region_cliperator_t; +typedef struct sk_region_spanerator_t sk_region_spanerator_t; typedef enum { CLEAR_SK_BLENDMODE, diff --git a/src/c/sk_region.cpp b/src/c/sk_region.cpp index 76ec11c8dcd..b3993cd815b 100644 --- a/src/c/sk_region.cpp +++ b/src/c/sk_region.cpp @@ -12,55 +12,161 @@ #include "sk_region.h" #include "sk_types_priv.h" +// sk_region_t -sk_region_t *sk_region_new() { +sk_region_t* sk_region_new(void) { return ToRegion(new SkRegion()); } -sk_region_t *sk_region_new2(const sk_region_t *region) { - return ToRegion(new SkRegion(*AsRegion(region))); +void sk_region_delete(sk_region_t* r) { + delete AsRegion(r); } -void sk_region_delete(sk_region_t *region) { - delete AsRegion(region); +bool sk_region_is_empty(const sk_region_t* r) { + return AsRegion(r)->isEmpty(); } -bool sk_region_contains(sk_region_t *r, const sk_region_t *region) { - return AsRegion(r)->contains(*AsRegion(region)); +bool sk_region_is_rect(const sk_region_t* r) { + return AsRegion(r)->isRect(); } -bool sk_region_contains2(sk_region_t *r, int x, int y) { - return AsRegion(r)->contains(x, y); +bool sk_region_is_complex(const sk_region_t* r) { + return AsRegion(r)->isComplex(); +} + +void sk_region_get_bounds(const sk_region_t* r, sk_irect_t* rect) { + *rect = ToIRect(AsRegion(r)->getBounds()); +} + +bool sk_region_get_boundary_path(const sk_region_t* r, sk_path_t* path) { + return AsRegion(r)->getBoundaryPath(AsPath(path)); +} + +bool sk_region_set_empty(sk_region_t* r) { + return AsRegion(r)->setEmpty(); +} + +bool sk_region_set_rect(sk_region_t* r, const sk_irect_t* rect) { + return AsRegion(r)->setRect(*AsIRect(rect)); +} + +bool sk_region_set_rects(sk_region_t* r, const sk_irect_t* rects, int count) { + return AsRegion(r)->setRects(AsIRect(rects), count); +} + +bool sk_region_set_region(sk_region_t* r, const sk_region_t* region) { + return AsRegion(r)->setRegion(*AsRegion(region)); } -bool sk_region_intersects_rect(sk_region_t* r, const sk_irect_t* rect) { +bool sk_region_set_path(sk_region_t* r, const sk_path_t* t, const sk_region_t* clip) { + return AsRegion(r)->setPath(*AsPath(t), *AsRegion(clip)); +} + +bool sk_region_intersects_rect(const sk_region_t* r, const sk_irect_t* rect) { return AsRegion(r)->intersects(*AsIRect(rect)); } -bool sk_region_intersects(sk_region_t *r, const sk_region_t *src) { +bool sk_region_intersects(const sk_region_t* r, const sk_region_t* src) { return AsRegion(r)->intersects(*AsRegion(src)); } -bool sk_region_set_path(sk_region_t *dst, const sk_path_t *t, const sk_region_t* clip) { - return AsRegion(dst)->setPath(*AsPath(t), *AsRegion(clip)); +bool sk_region_contains_point(const sk_region_t* r, int x, int y) { + return AsRegion(r)->contains(x, y); +} + +bool sk_region_contains_rect(const sk_region_t* r, const sk_irect_t* rect) { + return AsRegion(r)->contains(*AsIRect(rect)); } -bool sk_region_set_rect(sk_region_t *dst, const sk_irect_t *rect) { - return AsRegion(dst)->setRect(*AsIRect(rect)); +bool sk_region_contains(const sk_region_t* r, const sk_region_t* region) { + return AsRegion(r)->contains(*AsRegion(region)); } -bool sk_region_set_region(sk_region_t* dst, const sk_region_t* region) { - return AsRegion(dst)->setRegion(*AsRegion(region)); +bool sk_region_quick_contains(const sk_region_t* r, const sk_irect_t* rect) { + return AsRegion(r)->quickContains(*AsIRect(rect)); } -bool sk_region_op(sk_region_t *dst, int left, int top, int right, int bottom, sk_region_op_t op) { - return AsRegion(dst)->op(left, top, right, bottom, (SkRegion::Op)op); +bool sk_region_quick_reject_rect(const sk_region_t* r, const sk_irect_t* rect) { + return AsRegion(r)->quickReject(*AsIRect(rect)); } -bool sk_region_op2(sk_region_t *dst, sk_region_t *src, sk_region_op_t op) { - return AsRegion(dst)->op(*AsRegion(src), (SkRegion::Op)op); +bool sk_region_quick_reject(const sk_region_t* r, const sk_region_t* region) { + return AsRegion(r)->quickReject(*AsRegion(region)); } -void sk_region_get_bounds(sk_region_t* r, sk_irect_t* rect) { - *rect = ToIRect(AsRegion(r)->getBounds()); +void sk_region_translate(sk_region_t* r, int x, int y) { + AsRegion(r)->translate(x, y); +} + +bool sk_region_op_rect(sk_region_t* r, const sk_irect_t* rect, sk_region_op_t op) { + return AsRegion(r)->op(*AsIRect(rect), (SkRegion::Op)op); +} + +bool sk_region_op(sk_region_t* r, const sk_region_t* region, sk_region_op_t op) { + return AsRegion(r)->op(*AsRegion(region), (SkRegion::Op)op); +} + + +// sk_region_iterator_t + +sk_region_iterator_t* sk_region_iterator_new(const sk_region_t* region) { + return ToRegionIterator(new SkRegion::Iterator(*AsRegion(region))); +} + +void sk_region_iterator_delete(sk_region_iterator_t* iter) { + delete AsRegionIterator(iter); +} + +bool sk_region_iterator_rewind(sk_region_iterator_t* iter) { + return AsRegionIterator(iter)->rewind(); +} + +bool sk_region_iterator_done(const sk_region_iterator_t* iter) { + return AsRegionIterator(iter)->done(); +} + +void sk_region_iterator_next(sk_region_iterator_t* iter) { + AsRegionIterator(iter)->next(); +} + +void sk_region_iterator_rect(const sk_region_iterator_t* iter, sk_irect_t* rect) { + *rect = ToIRect(AsRegionIterator(iter)->rect()); +} + + +// sk_region_cliperator_t + +sk_region_cliperator_t* sk_region_cliperator_new(const sk_region_t* region, const sk_irect_t* clip) { + return ToRegionCliperator(new SkRegion::Cliperator(*AsRegion(region), *AsIRect(clip))); +} + +void sk_region_cliperator_delete(sk_region_cliperator_t* iter) { + delete AsRegionCliperator(iter); +} + +bool sk_region_cliperator_done(sk_region_cliperator_t* iter) { + return AsRegionCliperator(iter)->done(); +} + +void sk_region_cliperator_next(sk_region_cliperator_t* iter) { + AsRegionCliperator(iter)->next(); +} + +void sk_region_cliperator_rect(const sk_region_cliperator_t* iter, sk_irect_t* rect) { + *rect = ToIRect(AsRegionCliperator(iter)->rect()); +} + + +// sk_region_spanerator_t + +sk_region_spanerator_t* sk_region_spanerator_new(const sk_region_t* region, int y, int left, int right) { + return ToRegionSpanerator(new SkRegion::Spanerator(*AsRegion(region), y, left, right)); +} + +void sk_region_spanerator_delete(sk_region_spanerator_t* iter) { + delete AsRegionSpanerator(iter); +} + +bool sk_region_spanerator_next(sk_region_spanerator_t* iter, int* left, int* right) { + return AsRegionSpanerator(iter)->next(left, right); } diff --git a/src/c/sk_types_priv.h b/src/c/sk_types_priv.h index 9342ef8ce5d..c103c7a3f15 100644 --- a/src/c/sk_types_priv.h +++ b/src/c/sk_types_priv.h @@ -151,6 +151,11 @@ DEF_MAP(SkPath::RawIter, sk_path_rawiterator_t, PathRawIter) #include "SkPngEncoder.h" DEF_MAP(SkPngEncoder::Options, sk_pngencoder_options_t, PngEncoderOptions) +#include "SkRegion.h" +DEF_MAP(SkRegion::Iterator, sk_region_iterator_t, RegionIterator) +DEF_MAP(SkRegion::Cliperator, sk_region_cliperator_t, RegionCliperator) +DEF_MAP(SkRegion::Spanerator, sk_region_spanerator_t, RegionSpanerator) + #include "SkTime.h" DEF_MAP(SkTime::DateTime, sk_time_datetime_t, TimeDateTime) From 2411fe768b0e3d16a1e59839f65b4d802b74499a Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Wed, 5 Feb 2020 21:50:48 +0200 Subject: [PATCH 19/24] Add a few more members to SkImage --- include/c/sk_image.h | 3 +++ src/c/sk_image.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/c/sk_image.h b/include/c/sk_image.h index 818c5f46bba..037061cd90e 100644 --- a/include/c/sk_image.h +++ b/include/c/sk_image.h @@ -25,7 +25,9 @@ SK_C_API sk_image_t* sk_image_new_from_adopted_texture(gr_context_t* context, co SK_C_API sk_image_t* sk_image_new_from_picture(sk_picture_t* picture, const sk_isize_t* dimensions, const sk_matrix_t* matrix, const sk_paint_t* paint); SK_C_API sk_image_t* sk_image_make_subset(const sk_image_t* cimage, const sk_irect_t* subset); +SK_C_API sk_image_t* sk_image_make_texture_image(const sk_image_t* cimage, gr_context_t* context, sk_colorspace_t* colorspace); SK_C_API sk_image_t* sk_image_make_non_texture_image(const sk_image_t* cimage); +SK_C_API sk_image_t* sk_image_make_raster_image(const sk_image_t* cimage); SK_C_API sk_image_t* sk_image_make_with_filter(const sk_image_t* cimage, const sk_imagefilter_t* filter, const sk_irect_t* subset, const sk_irect_t* clipBounds, sk_irect_t* outSubset, sk_ipoint_t* outOffset); SK_C_API void sk_image_ref(const sk_image_t*); @@ -41,6 +43,7 @@ SK_C_API sk_shader_t* sk_image_make_shader(const sk_image_t*, sk_shader_tilemode SK_C_API bool sk_image_peek_pixels(const sk_image_t* image, sk_pixmap_t* pixmap); SK_C_API bool sk_image_is_texture_backed(const sk_image_t* image); SK_C_API bool sk_image_is_lazy_generated(const sk_image_t* image); +SK_C_API bool sk_image_is_valid(const sk_image_t* image, gr_context_t* context); SK_C_API bool sk_image_read_pixels(const sk_image_t* image, const sk_imageinfo_t* dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY, sk_image_caching_hint_t cachingHint); SK_C_API bool sk_image_read_pixels_into_pixmap(const sk_image_t* image, const sk_pixmap_t* dst, int srcX, int srcY, sk_image_caching_hint_t cachingHint); SK_C_API bool sk_image_scale_pixels(const sk_image_t* image, const sk_pixmap_t* dst, sk_filter_quality_t quality, sk_image_caching_hint_t cachingHint); diff --git a/src/c/sk_image.cpp b/src/c/sk_image.cpp index 712f91e168c..3bd60e08e20 100644 --- a/src/c/sk_image.cpp +++ b/src/c/sk_image.cpp @@ -110,6 +110,10 @@ bool sk_image_is_lazy_generated(const sk_image_t* image) { return AsImage(image)->isLazyGenerated(); } +bool sk_image_is_valid(const sk_image_t* image, gr_context_t* context) { + return AsImage(image)->isValid(AsGrContext(context)); +} + bool sk_image_read_pixels(const sk_image_t* image, const sk_imageinfo_t* dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY, sk_image_caching_hint_t cachingHint) { return AsImage(image)->readPixels(AsImageInfo(dstInfo), dstPixels, dstRowBytes, srcX, srcY, (SkImage::CachingHint)cachingHint); } @@ -138,10 +142,18 @@ sk_image_t* sk_image_make_subset(const sk_image_t* cimage, const sk_irect_t* sub return ToImage(AsImage(cimage)->makeSubset(*AsIRect(subset)).release()); } +sk_image_t* sk_image_make_texture_image(const sk_image_t* cimage, gr_context_t* context, sk_colorspace_t* colorspace) { + return ToImage(AsImage(cimage)->makeTextureImage(AsGrContext(context), AsColorSpace(colorspace)).release()); +} + sk_image_t* sk_image_make_non_texture_image(const sk_image_t* cimage) { return ToImage(AsImage(cimage)->makeNonTextureImage().release()); } +sk_image_t* sk_image_make_raster_image(const sk_image_t* cimage) { + return ToImage(AsImage(cimage)->makeRasterImage().release()); +} + sk_image_t* sk_image_make_with_filter(const sk_image_t* cimage, const sk_imagefilter_t* filter, const sk_irect_t* subset, const sk_irect_t* clipBounds, sk_irect_t* outSubset, sk_ipoint_t* outOffset) { return ToImage(AsImage(cimage)->makeWithFilter(AsImageFilter(filter), *AsIRect(subset), *AsIRect(clipBounds), AsIRect(outSubset), AsIPoint(outOffset)).release()); } From d3d6d76dac77e9b6929036892177261157b291b5 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Thu, 27 Feb 2020 17:25:44 +0200 Subject: [PATCH 20/24] A few changes and fixes. (#75) --- include/c/sk_matrix.h | 1 + include/c/sk_path.h | 1 + include/c/sk_pixmap.h | 6 +++--- include/c/sk_svg.h | 3 ++- include/c/sk_typeface.h | 2 ++ src/c/sk_matrix.cpp | 4 ++++ src/c/sk_path.cpp | 6 +++++- src/c/sk_pixmap.cpp | 12 ++++++------ src/c/sk_svg.cpp | 6 +++++- src/c/sk_typeface.cpp | 8 ++++++++ src/xamarin/SkiaKeeper.c | 2 +- 11 files changed, 38 insertions(+), 13 deletions(-) diff --git a/include/c/sk_matrix.h b/include/c/sk_matrix.h index a361dd25273..3293e09fe65 100644 --- a/include/c/sk_matrix.h +++ b/include/c/sk_matrix.h @@ -59,6 +59,7 @@ SK_C_API void sk_matrix44_as_col_major (sk_matrix44_t* matrix, float* dst); SK_C_API void sk_matrix44_as_row_major (sk_matrix44_t* matrix, float* dst); SK_C_API void sk_matrix44_set_col_major (sk_matrix44_t* matrix, float* dst); SK_C_API void sk_matrix44_set_row_major (sk_matrix44_t* matrix, float* dst); +SK_C_API void sk_matrix44_set_3x3_row_major (sk_matrix44_t* matrix, float* dst); SK_C_API void sk_matrix44_set_translate (sk_matrix44_t* matrix, float dx, float dy, float dz); SK_C_API void sk_matrix44_pre_translate (sk_matrix44_t* matrix, float dx, float dy, float dz); SK_C_API void sk_matrix44_post_translate (sk_matrix44_t* matrix, float dx, float dy, float dz); diff --git a/include/c/sk_path.h b/include/c/sk_path.h index 6284fe50004..9c297fce2da 100644 --- a/include/c/sk_path.h +++ b/include/c/sk_path.h @@ -45,6 +45,7 @@ SK_C_API void sk_path_add_arc(sk_path_t* cpath, const sk_rect_t* crect, float st SK_C_API sk_path_filltype_t sk_path_get_filltype(sk_path_t*); SK_C_API void sk_path_set_filltype(sk_path_t*, sk_path_filltype_t); SK_C_API void sk_path_transform(sk_path_t* cpath, const sk_matrix_t* cmatrix); +SK_C_API void sk_path_transform_to_dest(sk_path_t* cpath, const sk_matrix_t* cmatrix, sk_path_t* destination); SK_C_API sk_path_t* sk_path_clone(const sk_path_t* cpath); SK_C_API void sk_path_add_path_offset (sk_path_t* cpath, sk_path_t* other, float dx, float dy, sk_path_add_mode_t add_mode); SK_C_API void sk_path_add_path_matrix (sk_path_t* cpath, sk_path_t* other, sk_matrix_t *matrix, sk_path_add_mode_t add_mode); diff --git a/include/c/sk_pixmap.h b/include/c/sk_pixmap.h index cbcc15e1d86..a910d3de65c 100644 --- a/include/c/sk_pixmap.h +++ b/include/c/sk_pixmap.h @@ -39,9 +39,9 @@ SK_C_API void sk_color_get_bit_shift(int* a, int* r, int* g, int* b); 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_API bool sk_webpencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, const sk_webpencoder_options_t* options); +SK_C_API bool sk_jpegencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, const sk_jpegencoder_options_t* options); +SK_C_API bool sk_pngencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, const sk_pngencoder_options_t* options); SK_C_PLUS_PLUS_END_GUARD diff --git a/include/c/sk_svg.h b/include/c/sk_svg.h index f0e384423e9..f67c4ff37c3 100644 --- a/include/c/sk_svg.h +++ b/include/c/sk_svg.h @@ -14,7 +14,8 @@ SK_C_PLUS_PLUS_BEGIN_GUARD -SK_C_API sk_canvas_t* sk_svgcanvas_create(const sk_rect_t* bounds, sk_xmlwriter_t* writer); +SK_C_API sk_canvas_t* sk_svgcanvas_create_with_stream(const sk_rect_t* bounds, sk_wstream_t* stream); +SK_C_API sk_canvas_t* sk_svgcanvas_create_with_writer(const sk_rect_t* bounds, sk_xmlwriter_t* writer); SK_C_PLUS_PLUS_END_GUARD diff --git a/include/c/sk_typeface.h b/include/c/sk_typeface.h index 2b56903926a..4aa408a5f88 100644 --- a/include/c/sk_typeface.h +++ b/include/c/sk_typeface.h @@ -30,11 +30,13 @@ SK_C_API sk_fontstyle_t* sk_typeface_get_fontstyle(sk_typeface_t* typeface); SK_C_API int sk_typeface_get_font_weight(sk_typeface_t* typeface); SK_C_API int sk_typeface_get_font_width(sk_typeface_t* typeface); SK_C_API sk_font_style_slant_t sk_typeface_get_font_slant(sk_typeface_t* typeface); +SK_C_API int sk_typeface_count_glyphs(sk_typeface_t* typeface); SK_C_API int sk_typeface_count_tables(sk_typeface_t* typeface); SK_C_API int sk_typeface_get_table_tags(sk_typeface_t* typeface, sk_font_table_tag_t tags[]); SK_C_API size_t sk_typeface_get_table_size(sk_typeface_t* typeface, sk_font_table_tag_t tag); SK_C_API size_t sk_typeface_get_table_data(sk_typeface_t* typeface, sk_font_table_tag_t tag, size_t offset, size_t length, void* data); SK_C_API bool sk_typeface_is_fixed_pitch(sk_typeface_t* typeface); +SK_C_API bool sk_typeface_get_kerning_pair_adjustments(sk_typeface_t* typeface, const uint16_t* glyphs, int count, int32_t* adjustments); // font manager diff --git a/src/c/sk_matrix.cpp b/src/c/sk_matrix.cpp index 3dd12523548..7bfd0da04f3 100644 --- a/src/c/sk_matrix.cpp +++ b/src/c/sk_matrix.cpp @@ -197,6 +197,10 @@ void sk_matrix44_set_row_major(sk_matrix44_t* matrix, float* dst) { AsMatrix44(matrix)->setRowMajorf(dst); } +void sk_matrix44_set_3x3_row_major(sk_matrix44_t* matrix, float* dst) { + AsMatrix44(matrix)->set3x3RowMajorf(dst); +} + void sk_matrix44_set_translate(sk_matrix44_t* matrix, float dx, float dy, float dz) { AsMatrix44(matrix)->setTranslate(dx, dy, dz); } diff --git a/src/c/sk_path.cpp b/src/c/sk_path.cpp index aea2cd7436e..d1288cfd5d7 100644 --- a/src/c/sk_path.cpp +++ b/src/c/sk_path.cpp @@ -53,7 +53,11 @@ sk_path_filltype_t sk_path_get_filltype(sk_path_t *cpath) { } void sk_path_transform(sk_path_t* cpath, const sk_matrix_t* cmatrix) { - return AsPath(cpath)->transform(AsMatrix(cmatrix)); + AsPath(cpath)->transform(AsMatrix(cmatrix)); +} + +void sk_path_transform_to_dest(sk_path_t* cpath, const sk_matrix_t* cmatrix, sk_path_t* destination) { + AsPath(cpath)->transform(AsMatrix(cmatrix), AsPath(destination)); } sk_path_t* sk_path_clone(const sk_path_t* cpath) { diff --git a/src/c/sk_pixmap.cpp b/src/c/sk_pixmap.cpp index 846a6485ad1..ec5f5f31772 100644 --- a/src/c/sk_pixmap.cpp +++ b/src/c/sk_pixmap.cpp @@ -115,14 +115,14 @@ void sk_swizzle_swap_rb(uint32_t* dest, const uint32_t* src, int count) { 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_webpencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, const 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_jpegencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, const 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)); +bool sk_pngencoder_encode(sk_wstream_t* dst, const sk_pixmap_t* src, const sk_pngencoder_options_t* options) { + return SkPngEncoder::Encode(AsWStream(dst), *AsPixmap(src), *AsPngEncoderOptions(options)); } diff --git a/src/c/sk_svg.cpp b/src/c/sk_svg.cpp index 01799b87990..929208eaa04 100644 --- a/src/c/sk_svg.cpp +++ b/src/c/sk_svg.cpp @@ -15,6 +15,10 @@ ////////////////////////////////////////////////////////////////////////////////////////////////// -sk_canvas_t* sk_svgcanvas_create(const sk_rect_t* bounds, sk_xmlwriter_t* writer) { +sk_canvas_t* sk_svgcanvas_create_with_stream(const sk_rect_t* bounds, sk_wstream_t* stream) { + return ToCanvas(SkSVGCanvas::Make(*AsRect(bounds), AsWStream(stream)).release()); +} + +sk_canvas_t* sk_svgcanvas_create_with_writer(const sk_rect_t* bounds, sk_xmlwriter_t* writer) { return ToCanvas(SkSVGCanvas::Make(*AsRect(bounds), AsXMLWriter(writer)).release()); } diff --git a/src/c/sk_typeface.cpp b/src/c/sk_typeface.cpp index c3cde1f7d38..918ddaac98c 100644 --- a/src/c/sk_typeface.cpp +++ b/src/c/sk_typeface.cpp @@ -82,6 +82,10 @@ sk_font_style_slant_t sk_typeface_get_font_slant(sk_typeface_t* typeface) { return (sk_font_style_slant_t)AsTypeface(typeface)->fontStyle().slant(); } +int sk_typeface_count_glyphs(sk_typeface_t* typeface) { + return AsTypeface(typeface)->countGlyphs(); +} + int sk_typeface_count_tables(sk_typeface_t* typeface) { return AsTypeface(typeface)->countTables(); } @@ -102,6 +106,10 @@ bool sk_typeface_is_fixed_pitch(sk_typeface_t* typeface) { return AsTypeface(typeface)->isFixedPitch(); } +bool sk_typeface_get_kerning_pair_adjustments(sk_typeface_t* typeface, const uint16_t* glyphs, int count, int32_t* adjustments) { + return AsTypeface(typeface)->getKerningPairAdjustments(glyphs, count, adjustments); +} + // font manager diff --git a/src/xamarin/SkiaKeeper.c b/src/xamarin/SkiaKeeper.c index f9bd4845411..348849bff30 100644 --- a/src/xamarin/SkiaKeeper.c +++ b/src/xamarin/SkiaKeeper.c @@ -80,7 +80,7 @@ void** KeepSkiaCSymbols (void) (void*)sk_stream_asset_destroy, (void*)sk_string_new_empty, (void*)sk_surface_new_null, - (void*)sk_svgcanvas_create, + (void*)sk_svgcanvas_create_with_stream, (void*)sk_typeface_unref, (void*)sk_textblob_ref, (void*)sk_xmlstreamwriter_new, From 37fbbc18a2e03d54c40305012aa43e597b2372a9 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 13 Mar 2020 13:09:30 +0200 Subject: [PATCH 21/24] Use wide console output --- tools/git-sync-deps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/git-sync-deps b/tools/git-sync-deps index 7599eacbcba..9bec0c365b8 100755 --- a/tools/git-sync-deps +++ b/tools/git-sync-deps @@ -102,7 +102,7 @@ def is_git_toplevel(git, directory): def status(directory, checkoutable): def truncate(s, length): return s if len(s) <= length else s[:(length - 3)] + '...' - dlen = 36 + dlen = 86 directory = truncate(directory, dlen) checkoutable = truncate(checkoutable, 40) sys.stdout.write('%-*s @ %s\n' % (dlen, directory, checkoutable)) From 22c042a5bc133e22f2c5fe5431f20ec7062ec0fd Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 13 Mar 2020 21:11:57 +0200 Subject: [PATCH 22/24] Update the Windows build tools --- gn/toolchain/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gn/toolchain/BUILD.gn b/gn/toolchain/BUILD.gn index cd1def114dd..76ae752f176 100644 --- a/gn/toolchain/BUILD.gn +++ b/gn/toolchain/BUILD.gn @@ -57,9 +57,9 @@ toolchain("msvc") { _target = "amd64_" + target_cpu } if (is_winrt) { - _target += " uwp 10.0.10240.0 -vcvars_ver=14.1" + _target += " uwp 10.0.10240.0 -vcvars_ver=14.2" } else { - _target += " 8.1 -vcvars_ver=14.1" + _target += " 10.0.10240.0 -vcvars_ver=14.2" } _vcvarsall = "$win_vc/Auxiliary/Build/vcvarsall.bat" From 2638bc7a8597a0002c40aa6e7a0ed58bf0ca4725 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 14 Mar 2020 00:19:46 +0200 Subject: [PATCH 23/24] Support building with VS2017 and VS2019 --- gn/BUILD.gn | 28 +++++++--------------- gn/BUILDCONFIG.gn | 52 ++++------------------------------------ gn/find_msvc.py | 26 ++++++++++++++++++++ gn/lowest_version_dir.py | 9 ++++++- gn/toolchain/BUILD.gn | 15 +++--------- 5 files changed, 50 insertions(+), 80 deletions(-) create mode 100644 gn/find_msvc.py diff --git a/gn/BUILD.gn b/gn/BUILD.gn index b7112ae22b5..25cc3eb58bf 100644 --- a/gn/BUILD.gn +++ b/gn/BUILD.gn @@ -59,12 +59,8 @@ config("default") { "NOMINMAX", ] - if (msvc == 2015) { - _include_dirs = [ "$win_vc/include" ] - } else { # 2017 - _include_dirs = [ "$win_vc/Tools/MSVC/$win_toolchain_version/include" ] - } - _include_dirs += [ + _include_dirs = [ + "$win_vc/Tools/MSVC/$win_toolchain_version/include", "$win_sdk/Include/$win_sdk_version/shared", "$win_sdk/Include/$win_sdk_version/ucrt", "$win_sdk/Include/$win_sdk_version/um", @@ -82,24 +78,16 @@ config("default") { include_dirs = _include_dirs } + _is_store = "" + if (is_winrt) { + _is_store = "/store" + } + lib_dirs = [ "$win_sdk/Lib/$win_sdk_version/ucrt/$target_cpu", "$win_sdk/Lib/$win_sdk_version/um/$target_cpu", + "$win_vc/Tools/MSVC/$win_toolchain_version/lib/$target_cpu$_is_store", ] - if (msvc == 2015) { - if (target_cpu == "x86") { - lib_dirs += [ "$win_vc/lib" ] - } else { - lib_dirs += [ "$win_vc/lib/amd64" ] - } - } else { # 2017 - _is_store = "" - if (is_winrt) { - _is_store = "/store" - } - lib_dirs += - [ "$win_vc/Tools/MSVC/$win_toolchain_version/lib/$target_cpu$_is_store" ] - } } else { cflags += [ "-fstrict-aliasing", diff --git a/gn/BUILDCONFIG.gn b/gn/BUILDCONFIG.gn index 8d099eeeb64..2f98e0b2aaa 100644 --- a/gn/BUILDCONFIG.gn +++ b/gn/BUILDCONFIG.gn @@ -28,6 +28,7 @@ declare_args() { cxx = "c++" win_sdk = "C:/Program Files (x86)/Windows Kits/10" + min_win_sdk_version = "10.0.10240.0" win_sdk_version = "" win_vc = "" @@ -140,62 +141,18 @@ if (is_android) { } } -msvc = "" if (is_win) { - # By default we look for 2017 (Pro & Community), then 2015. If MSVC is installed in a + # By default we look for 2017 (Enterprise, Pro, and Community), then 2015. If MSVC is installed in a # non-default location, you can set win_vc to inform us where it is. - vc_2017_ent_default = - "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC" - vc_2017_pro_default = - "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC" - vc_2017_com_default = - "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC" - vc_2017_bt_default = - "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC" - vc_2015_default = "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC" if (win_vc == "") { - if ("True" == exec_script("//gn/checkdir.py", - [ "$vc_2017_ent_default" ], - "trim string")) { - win_vc = vc_2017_ent_default - msvc = 2017 - } else if ("True" == exec_script("//gn/checkdir.py", - [ "$vc_2017_pro_default" ], - "trim string")) { - win_vc = vc_2017_pro_default - msvc = 2017 - } else if ("True" == exec_script("//gn/checkdir.py", - [ "$vc_2017_com_default" ], - "trim string")) { - win_vc = vc_2017_com_default - msvc = 2017 - } else if ("True" == exec_script("//gn/checkdir.py", - [ "$vc_2017_bt_default" ], - "trim string")) { - win_vc = vc_2017_bt_default - msvc = 2017 - } else if ("True" == exec_script("//gn/checkdir.py", - [ "$vc_2015_default" ], - "trim string")) { - win_vc = vc_2015_default - msvc = 2015 - } + win_vc = exec_script("//gn/find_msvc.py", [], "trim string") } assert(win_vc != "") # Could not find VC installation. Set win_vc to your VC directory. - - if (msvc == "") { - if ("True" == - exec_script("//gn/checkdir.py", [ "$win_vc/Tools" ], "trim string")) { - msvc = 2017 - } else { - msvc = 2015 - } - } } if (is_win) { - if (msvc == 2017 && win_toolchain_version == "") { + if (win_toolchain_version == "") { win_toolchain_version = exec_script("//gn/highest_version_dir.py", [ "$win_vc/Tools/MSVC", @@ -208,6 +165,7 @@ if (is_win) { [ "$win_sdk/Include", "[0-9]{2}\.[0-9]\.[0-9]{5}\.[0-9]", + min_win_sdk_version ], "trim string") } diff --git a/gn/find_msvc.py b/gn/find_msvc.py new file mode 100644 index 00000000000..864db094a3a --- /dev/null +++ b/gn/find_msvc.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# Copyright 2019 Google Inc. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os +import sys + +''' +Look for the first match in the format + C:\\Program Files (x86)\\Microsoft Visual Studio\\${RELEASE}\\${VERSION}\\VC +''' +def find_msvc(): + if sys.platform.startswith('win'): + default_dir = r'C:\Program Files (x86)\Microsoft Visual Studio' + for release in ['2019', '2017']: + for version in ['Enterprise', 'Professional', 'Community', 'BuildTools']: + path = os.path.join(default_dir, release, version, 'VC') + if os.path.isdir(path): + return path + return None + +if __name__ == '__main__': + result = find_msvc() + if result: + sys.stdout.write(result + '\n') diff --git a/gn/lowest_version_dir.py b/gn/lowest_version_dir.py index b493d7f1458..b835faa460a 100644 --- a/gn/lowest_version_dir.py +++ b/gn/lowest_version_dir.py @@ -11,5 +11,12 @@ dirpath = sys.argv[1] regex = re.compile(sys.argv[2]) +minimum = sys.argv[3] -print sorted(filter(regex.match, os.listdir(dirpath)))[0] +matches = sorted(filter(regex.match, os.listdir(dirpath))) +for match in matches: + if (match >= minimum): + path = os.path.join(dirpath, match) + if os.path.isdir(path): + print match + break diff --git a/gn/toolchain/BUILD.gn b/gn/toolchain/BUILD.gn index 76ae752f176..355d8f5a471 100644 --- a/gn/toolchain/BUILD.gn +++ b/gn/toolchain/BUILD.gn @@ -41,15 +41,7 @@ if (host_os == "win") { toolchain("msvc") { lib_dir_switch = "/LIBPATH:" - if (msvc == 2015) { - if (target_cpu == "x86") { - bin = "$win_vc/bin" - } else { - bin = "$win_vc/bin/amd64" - } - } else { - bin = "$win_vc/Tools/MSVC/$win_toolchain_version/bin/HostX64/$target_cpu" - } + bin = "$win_vc/Tools/MSVC/$win_toolchain_version/bin/HostX64/$target_cpu" if (target_cpu == "x64") { _target = "amd64" @@ -57,10 +49,9 @@ toolchain("msvc") { _target = "amd64_" + target_cpu } if (is_winrt) { - _target += " uwp 10.0.10240.0 -vcvars_ver=14.2" - } else { - _target += " 10.0.10240.0 -vcvars_ver=14.2" + _target += " uwp" } + _target += " " + win_sdk_version + " -vcvars_ver=14.2" _vcvarsall = "$win_vc/Auxiliary/Build/vcvarsall.bat" env_setup = "cmd /c set __VSCMD_ARG_NO_LOGO=1 && set VSCMD_START_DIR=%CD% && \"$_vcvarsall\" $_target && " From 6d51638657bdc907cc78458ad5164ed2da95b333 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Wed, 25 Mar 2020 17:22:14 +0200 Subject: [PATCH 24/24] lang is not used, so remove it. --- include/c/sk_textblob.h | 6 +++--- src/c/sk_textblob.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/c/sk_textblob.h b/include/c/sk_textblob.h index f583abe980b..7e86712363c 100644 --- a/include/c/sk_textblob.h +++ b/include/c/sk_textblob.h @@ -22,9 +22,9 @@ SK_C_API void sk_textblob_get_bounds(const sk_textblob_t* blob, sk_rect_t* bound SK_C_API sk_textblob_builder_t* sk_textblob_builder_new(); SK_C_API void sk_textblob_builder_delete(sk_textblob_builder_t* builder); SK_C_API sk_textblob_t* sk_textblob_builder_make(sk_textblob_builder_t* builder); -SK_C_API void sk_textblob_builder_alloc_run_text(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, float x, float y, int textByteCount, const sk_string_t* lang, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); -SK_C_API void sk_textblob_builder_alloc_run_text_pos_h(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, float y, int textByteCount, const sk_string_t* lang, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); -SK_C_API void sk_textblob_builder_alloc_run_text_pos(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, int textByteCount, const sk_string_t* lang, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); +SK_C_API void sk_textblob_builder_alloc_run_text(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, float x, float y, int textByteCount, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); +SK_C_API void sk_textblob_builder_alloc_run_text_pos_h(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, float y, int textByteCount, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); +SK_C_API void sk_textblob_builder_alloc_run_text_pos(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, int textByteCount, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer); SK_C_PLUS_PLUS_END_GUARD diff --git a/src/c/sk_textblob.cpp b/src/c/sk_textblob.cpp index c239e1c00a1..4b9bd097422 100644 --- a/src/c/sk_textblob.cpp +++ b/src/c/sk_textblob.cpp @@ -43,14 +43,14 @@ sk_textblob_t* sk_textblob_builder_make(sk_textblob_builder_t* builder) { return ToTextBlob(AsTextBlobBuilder(builder)->make().release()); } -void sk_textblob_builder_alloc_run_text(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, float x, float y, int textByteCount, const sk_string_t* lang, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer) { - *runbuffer = ToTextBlobBuilderRunBuffer(AsTextBlobBuilder(builder)->allocRunText(AsPaint(*font), count, x, y, textByteCount, *AsString(lang), AsRect(bounds))); +void sk_textblob_builder_alloc_run_text(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, float x, float y, int textByteCount, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer) { + *runbuffer = ToTextBlobBuilderRunBuffer(AsTextBlobBuilder(builder)->allocRunText(AsPaint(*font), count, x, y, textByteCount, SkString(), AsRect(bounds))); } -void sk_textblob_builder_alloc_run_text_pos_h(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, float y, int textByteCount, const sk_string_t* lang, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer) { - *runbuffer = ToTextBlobBuilderRunBuffer(AsTextBlobBuilder(builder)->allocRunTextPosH(AsPaint(*font), count, y, textByteCount, *AsString(lang), AsRect(bounds))); +void sk_textblob_builder_alloc_run_text_pos_h(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, float y, int textByteCount, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer) { + *runbuffer = ToTextBlobBuilderRunBuffer(AsTextBlobBuilder(builder)->allocRunTextPosH(AsPaint(*font), count, y, textByteCount, SkString(), AsRect(bounds))); } -void sk_textblob_builder_alloc_run_text_pos(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, int textByteCount, const sk_string_t* lang, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer) { - *runbuffer = ToTextBlobBuilderRunBuffer(AsTextBlobBuilder(builder)->allocRunTextPos(AsPaint(*font), count, textByteCount, *AsString(lang), AsRect(bounds))); +void sk_textblob_builder_alloc_run_text_pos(sk_textblob_builder_t* builder, const sk_paint_t* font, int count, int textByteCount, const sk_rect_t* bounds, sk_textblob_builder_runbuffer_t* runbuffer) { + *runbuffer = ToTextBlobBuilderRunBuffer(AsTextBlobBuilder(builder)->allocRunTextPos(AsPaint(*font), count, textByteCount, SkString(), AsRect(bounds))); }