From: Matthew Leibowitz Date: Thu, 11 May 2017 01:33:18 +0000 (-0500) Subject: Updates required for building the new m59 X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9e6a490b29bab057971e4b6ff8c21069c5b19b3;p=platform%2Fupstream%2FlibSkiaSharp.git Updates required for building the new m59 --- diff --git a/gn/core.gni b/gn/core.gni index 83baba9..7de1f82 100644 --- a/gn/core.gni +++ b/gn/core.gni @@ -34,6 +34,7 @@ skia_core_sources = [ "$_include/c/sk_types.h", "$_include/c/sk_xml.h", "$_include/c/sk_svg.h", + "$_include/c/sk_vertices.h", "$_include/c/gr_context.h", "$_src/c/sk_bitmap.cpp", "$_src/c/sk_canvas.cpp", @@ -61,6 +62,7 @@ skia_core_sources = [ "$_src/c/sk_typeface.cpp", "$_src/c/sk_xml.cpp", "$_src/c/sk_svg.cpp", + "$_src/c/sk_vertices.cpp", "$_src/c/sk_types_priv.h", "$_src/c/gr_context.cpp", @@ -601,6 +603,6 @@ skia_core_sources += [ ] if (is_win) { skia_core_sources += [ "$_src/jumper/SkJumper_generated_win.S" ] -} else { +} else if (!is_tvos) { skia_core_sources += [ "$_src/jumper/SkJumper_generated.S" ] } diff --git a/include/c/sk_bitmap.h b/include/c/sk_bitmap.h index c0751cd..6016752 100644 --- a/include/c/sk_bitmap.h +++ b/include/c/sk_bitmap.h @@ -37,7 +37,6 @@ 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 bool sk_bitmap_copy_pixels_to(sk_bitmap_t* cbitmap, void* const dst, size_t dstSize, size_t dstRowBytes, bool preserveDstPad); SK_C_API bool sk_bitmap_copy(sk_bitmap_t* cbitmap, sk_bitmap_t* dst, sk_colortype_t ct); SK_C_API bool sk_bitmap_can_copy_to(sk_bitmap_t* cbitmap, sk_colortype_t ct); SK_C_API void sk_bitmap_lock_pixels(sk_bitmap_t* cbitmap); @@ -48,7 +47,7 @@ SK_C_API bool sk_bitmap_install_pixels(sk_bitmap_t* cbitmap, const sk_imageinfo_ SK_C_API bool sk_bitmap_install_pixels_with_pixmap(sk_bitmap_t* cbitmap, const sk_pixmap_t* cpixmap); SK_C_API bool sk_bitmap_install_mask_pixels(sk_bitmap_t* cbitmap, const sk_mask_t* cmask); SK_C_API bool sk_bitmap_try_alloc_pixels(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, size_t rowBytes); -SK_C_API bool sk_bitmap_try_alloc_pixels_with_color_table(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, sk_pixelref_factory_t* factory, sk_colortable_t* ctable); +SK_C_API bool sk_bitmap_try_alloc_pixels_with_color_table(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, sk_colortable_t* ctable, uint32_t flags); SK_C_API sk_colortable_t* sk_bitmap_get_colortable(sk_bitmap_t* cbitmap); SK_C_API void sk_bitmap_set_pixels(sk_bitmap_t* cbitmap, void* pixels, sk_colortable_t* ctable); SK_C_API bool sk_bitmap_peek_pixels(sk_bitmap_t* cbitmap, sk_pixmap_t* cpixmap); diff --git a/include/c/sk_canvas.h b/include/c/sk_canvas.h index 5948f8f..f8aec81 100644 --- a/include/c/sk_canvas.h +++ b/include/c/sk_canvas.h @@ -346,7 +346,7 @@ SK_C_API void sk_canvas_draw_link_destination_annotation(sk_canvas_t* t, const s SK_C_API void sk_canvas_draw_bitmap_lattice(sk_canvas_t* t, const sk_bitmap_t* bitmap, const sk_lattice_t* lattice, const sk_rect_t* dst, const sk_paint_t* paint); 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_vertices(sk_canvas_t* ccanvas, sk_vertex_mode_t vmode, int vertexCount, const sk_point_t* vertices, const sk_point_t* texs, const sk_color_t* colors, sk_blendmode_t mode, const uint16_t* indices, int indexCount, 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_PLUS_PLUS_END_GUARD diff --git a/include/c/sk_pixmap.h b/include/c/sk_pixmap.h index ed905ea..53603cb 100644 --- a/include/c/sk_pixmap.h +++ b/include/c/sk_pixmap.h @@ -35,6 +35,8 @@ SK_C_API void sk_color_get_bit_shift(int* a, int* r, int* g, int* b); SK_C_API bool sk_pixmap_encode_image(sk_wstream_t* dst, const sk_pixmap_t* src, sk_encoded_image_format_t encoder, int quality); +SK_C_API bool sk_pixmap_read_pixels(const sk_pixmap_t* cpixmap, const sk_imageinfo_t* dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY); + SK_C_PLUS_PLUS_END_GUARD #endif diff --git a/include/c/sk_types.h b/include/c/sk_types.h index a877aa1..3157ecb 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -775,6 +775,10 @@ typedef enum { DISALLOW_SK_IMAGE_CACHING_HINT, } sk_image_caching_hint_t; +typedef enum { + ZERO_PIXELS_SK_BITMAP_ALLOC_FLAGS = 1 << 0, +} sk_bitmap_allocflags_t; + typedef struct { int16_t fTimeZoneMinutes; uint16_t fYear; @@ -838,10 +842,12 @@ typedef struct sk_svgcanvas_t sk_svgcanvas_t; typedef struct sk_3dview_t sk_3dview_t; typedef enum { - TRIANGLES_SK_VERTEX_MODE, - TRIANGLE_STRIP_SK_VERTEX_MODE, - TRIANGLE_FAN_SK_VERTEX_MODE, -} sk_vertex_mode_t; + TRIANGLES_SK_VERTICES_VERTEX_MODE, + TRIANGLE_STRIP_SK_VERTICES_VERTEX_MODE, + TRIANGLE_FAN_SK_VERTICES_VERTEX_MODE, +} sk_vertices_vertex_mode_t; + +typedef struct sk_vertices_t sk_vertices_t; SK_C_PLUS_PLUS_END_GUARD diff --git a/include/c/sk_vertices.h b/include/c/sk_vertices.h new file mode 100644 index 0000000..ed21cf3 --- /dev/null +++ b/include/c/sk_vertices.h @@ -0,0 +1,23 @@ +/* + * Copyright 2016 Xamarin Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL +// DO NOT USE -- FOR INTERNAL TESTING ONLY + +#ifndef sk_vertices_DEFINED +#define sk_vertices_DEFINED + +#include "sk_types.h" + +SK_C_PLUS_PLUS_BEGIN_GUARD + +SK_C_API void sk_vertices_unref(sk_vertices_t* cvertices); +SK_C_API sk_vertices_t* sk_vertices_make_copy(sk_vertices_vertex_mode_t vmode, int vertexCount, const sk_point_t* positions, const sk_point_t* texs, const sk_color_t* colors, int indexCount, const uint16_t* indices); + +SK_C_PLUS_PLUS_END_GUARD + +#endif diff --git a/src/c/sk_bitmap.cpp b/src/c/sk_bitmap.cpp index 2ea5b56..0eb0ac4 100644 --- a/src/c/sk_bitmap.cpp +++ b/src/c/sk_bitmap.cpp @@ -234,11 +234,6 @@ bool sk_bitmap_ready_to_draw(sk_bitmap_t* cbitmap) return AsBitmap(cbitmap)->readyToDraw(); } -bool sk_bitmap_copy_pixels_to(sk_bitmap_t* cbitmap, void* const dst, size_t dstSize, size_t dstRowBytes, bool preserveDstPad) -{ - return AsBitmap(cbitmap)->copyPixelsTo(dst, dstSize, dstRowBytes, preserveDstPad); -} - bool sk_bitmap_copy(sk_bitmap_t* cbitmap, sk_bitmap_t* dst, sk_colortype_t ct) { return AsBitmap(cbitmap)->copyTo(AsBitmap(dst), (SkColorType)ct); @@ -352,14 +347,14 @@ bool sk_bitmap_try_alloc_pixels(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requ return bmp->tryAllocPixels(info, rowBytes); } -bool sk_bitmap_try_alloc_pixels_with_color_table(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, sk_pixelref_factory_t* factory, sk_colortable_t* ctable) +bool sk_bitmap_try_alloc_pixels_with_color_table(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, sk_colortable_t* ctable, uint32_t flags) { SkBitmap* bmp = AsBitmap(cbitmap); SkImageInfo info; from_c(*requestedInfo, &info); - return bmp->tryAllocPixels(info, AsPixelRefFactory(factory), AsColorTable(ctable)); + return bmp->tryAllocPixels(info, sk_ref_sp(AsColorTable(ctable)), flags); } sk_colortable_t* sk_bitmap_get_colortable(sk_bitmap_t* cbitmap) diff --git a/src/c/sk_canvas.cpp b/src/c/sk_canvas.cpp index 9e5335e..e22626f 100644 --- a/src/c/sk_canvas.cpp +++ b/src/c/sk_canvas.cpp @@ -278,6 +278,6 @@ void sk_canvas_draw_image_lattice(sk_canvas_t* ccanvas, AsCanvas(ccanvas)->drawImageLattice(AsImage(image), AsLattice(*lattice), AsRect(*dst), AsPaint(paint)); } -void sk_canvas_draw_vertices(sk_canvas_t* ccanvas, sk_vertex_mode_t vmode, int vertexCount, const sk_point_t* vertices, const sk_point_t* texs, const sk_color_t* colors, sk_blendmode_t mode, const uint16_t* indices, int indexCount, const sk_paint_t* paint) { - AsCanvas(ccanvas)->drawVertices((SkCanvas::VertexMode)vmode, vertexCount, AsPoint(vertices), AsPoint(texs), colors, (SkBlendMode)mode, indices, indexCount, AsPaint(*paint)); +void sk_canvas_draw_vertices(sk_canvas_t* ccanvas, sk_vertices_t* vertices, sk_blendmode_t mode, const sk_paint_t* paint) { + AsCanvas(ccanvas)->drawVertices(AsVertices(vertices), (SkBlendMode)mode, AsPaint(*paint)); } diff --git a/src/c/sk_enums.cpp b/src/c/sk_enums.cpp index 49a95fb..45ec96b 100644 --- a/src/c/sk_enums.cpp +++ b/src/c/sk_enums.cpp @@ -358,13 +358,16 @@ static_assert ((int)SkMatrix44::TypeMask::kScale_Mask == (int)SCALE_SK_M static_assert ((int)SkMatrix44::TypeMask::kAffine_Mask == (int)AFFINE_SK_MATRIX44_TYPE_MASK, ASSERT_MSG(SkMatrix44::TypeMask, sk_matrix44_type_mask_t)); static_assert ((int)SkMatrix44::TypeMask::kPerspective_Mask == (int)PERSPECTIVE_SK_MATRIX44_TYPE_MASK, ASSERT_MSG(SkMatrix44::TypeMask, sk_matrix44_type_mask_t)); -// sk_vertex_mode_t -static_assert ((int)SkCanvas::VertexMode::kTriangles_VertexMode == (int)TRIANGLES_SK_VERTEX_MODE, ASSERT_MSG(SkCanvas::VertexMode, sk_vertex_mode_t)); -static_assert ((int)SkCanvas::VertexMode::kTriangleStrip_VertexMode == (int)TRIANGLE_STRIP_SK_VERTEX_MODE, ASSERT_MSG(SkCanvas::VertexMode, sk_vertex_mode_t)); -static_assert ((int)SkCanvas::VertexMode::kTriangleFan_VertexMode == (int)TRIANGLE_FAN_SK_VERTEX_MODE, ASSERT_MSG(SkCanvas::VertexMode, sk_vertex_mode_t)); +// sk_vertices_vertex_mode_t +static_assert ((int)SkVertices::VertexMode::kTriangles_VertexMode == (int)TRIANGLES_SK_VERTICES_VERTEX_MODE, ASSERT_MSG(SkVertices::VertexMode, sk_vertices_vertex_mode_t)); +static_assert ((int)SkVertices::VertexMode::kTriangleStrip_VertexMode == (int)TRIANGLE_STRIP_SK_VERTICES_VERTEX_MODE, ASSERT_MSG(SkVertices::VertexMode, sk_vertices_vertex_mode_t)); +static_assert ((int)SkVertices::VertexMode::kTriangleFan_VertexMode == (int)TRIANGLE_FAN_SK_VERTICES_VERTEX_MODE, ASSERT_MSG(SkVertices::VertexMode, sk_vertices_vertex_mode_t)); // sk_image_caching_hint_t static_assert ((int)SkImage::CachingHint::kAllow_CachingHint == (int)ALLOW_SK_IMAGE_CACHING_HINT, ASSERT_MSG(SkImage::CachingHint, sk_image_caching_hint_t)); static_assert ((int)SkImage::CachingHint::kDisallow_CachingHint == (int)DISALLOW_SK_IMAGE_CACHING_HINT, ASSERT_MSG(SkImage::CachingHint, sk_image_caching_hint_t)); +// sk_bitmap_allocflags_t +static_assert ((int)SkBitmap::AllocFlags::kZeroPixels_AllocFlag == (int)ZERO_PIXELS_SK_BITMAP_ALLOC_FLAGS, ASSERT_MSG(SkBitmap::AllocFlags, sk_bitmap_allocflags_t)); + #endif diff --git a/src/c/sk_pixmap.cpp b/src/c/sk_pixmap.cpp index d7fe298..edd64d8 100644 --- a/src/c/sk_pixmap.cpp +++ b/src/c/sk_pixmap.cpp @@ -108,3 +108,11 @@ bool sk_pixmap_encode_image(sk_wstream_t* dst, const sk_pixmap_t* src, sk_encode { return SkEncodeImage(AsWStream(dst), AsPixmap(*src), (SkEncodedImageFormat)encoder, quality); } + +bool sk_pixmap_read_pixels(const sk_pixmap_t* cpixmap, const sk_imageinfo_t* dstInfo, void* dstPixels, size_t dstRowBytes, int srcX, int srcY) +{ + SkImageInfo info; + from_c(*dstInfo, &info); + + return AsPixmap(cpixmap)->readPixels(info, dstPixels, dstRowBytes, srcX, srcY); +} diff --git a/src/c/sk_stream.cpp b/src/c/sk_stream.cpp index c2a7d8d..c7953d4 100644 --- a/src/c/sk_stream.cpp +++ b/src/c/sk_stream.cpp @@ -157,7 +157,7 @@ sk_wstream_dynamicmemorystream_t* sk_dynamicmemorywstream_new() sk_stream_asset_t* sk_dynamicmemorywstream_detach_as_stream(sk_wstream_dynamicmemorystream_t* cstream) { - return ToStreamAsset(AsDynamicMemoryWStream(cstream)->detachAsStream()); + return ToStreamAsset(AsDynamicMemoryWStream(cstream)->detachAsStream().release()); } sk_data_t* sk_dynamicmemorywstream_detach_as_data(sk_wstream_dynamicmemorystream_t* cstream) diff --git a/src/c/sk_types_priv.h b/src/c/sk_types_priv.h index 43eb05e..d6a2068 100644 --- a/src/c/sk_types_priv.h +++ b/src/c/sk_types_priv.h @@ -530,22 +530,6 @@ static inline const sk_colortable_t* ToColorTable(const SkColorTable* p) { return reinterpret_cast(p); } -static inline const SkPixelRefFactory* AsPixelRefFactory(const sk_pixelref_factory_t* p) { - return reinterpret_cast(p); -} - -static inline SkPixelRefFactory* AsPixelRefFactory(sk_pixelref_factory_t* p) { - return reinterpret_cast(p); -} - -static inline sk_pixelref_factory_t* ToColorTable(SkPixelRefFactory* p) { - return reinterpret_cast(p); -} - -static inline const sk_pixelref_factory_t* ToColorTable(const SkPixelRefFactory* p) { - return reinterpret_cast(p); -} - static inline sk_surface_t* ToSurface(SkSurface* p) { return reinterpret_cast(p); } @@ -722,6 +706,22 @@ static inline const sk_matrix44_t* ToMatrix44(const SkMatrix44* p) { return reinterpret_cast(p); } +static inline const SkVertices* AsVertices(const sk_vertices_t* p) { + return reinterpret_cast(p); +} + +static inline SkVertices* AsVertices(sk_vertices_t* p) { + return reinterpret_cast(p); +} + +static inline sk_vertices_t* ToVertices(SkVertices* p) { + return reinterpret_cast(p); +} + +static inline const sk_vertices_t* ToVertices(const SkVertices* p) { + return reinterpret_cast(p); +} + static inline void from_c(const sk_matrix_t* cmatrix, SkMatrix* matrix) { matrix->setAll( cmatrix->mat[0], cmatrix->mat[1], cmatrix->mat[2], diff --git a/src/c/sk_vertices.cpp b/src/c/sk_vertices.cpp new file mode 100644 index 0000000..32852c6 --- /dev/null +++ b/src/c/sk_vertices.cpp @@ -0,0 +1,20 @@ +/* + * Copyright 2016 Xamarin Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkVertices.h" + +#include "sk_vertices.h" + +#include "sk_types_priv.h" + +void sk_vertices_unref(sk_vertices_t* cvertices) { + SkSafeUnref(AsVertices(cvertices)); +} + +sk_vertices_t* sk_vertices_make_copy(sk_vertices_vertex_mode_t vmode, int vertexCount, const sk_point_t* positions, const sk_point_t* texs, const sk_color_t* colors, int indexCount, const uint16_t* indices) { + return ToVertices(SkVertices::MakeCopy((SkVertices::VertexMode)vmode, vertexCount, AsPoint(positions), AsPoint(texs), colors, indexCount, indices).release()); +} diff --git a/src/jumper/SkJumper.cpp b/src/jumper/SkJumper.cpp index 0d4446c..5bd6e4b 100644 --- a/src/jumper/SkJumper.cpp +++ b/src/jumper/SkJumper.cpp @@ -144,7 +144,7 @@ using StageFn = void(void); extern "C" { -#if __has_feature(memory_sanitizer) +#if __has_feature(memory_sanitizer) || defined(SK_BUILD_FOR_TVOS) // We'll just run portable code. #elif defined(__aarch64__) @@ -196,7 +196,7 @@ extern "C" { // Translate SkRasterPipeline's StockStage enum to StageFn function pointers. -#if __has_feature(memory_sanitizer) +#if __has_feature(memory_sanitizer) || defined(SK_BUILD_FOR_TVOS) // We'll just run portable code. #elif defined(__aarch64__) @@ -316,7 +316,7 @@ bool SkRasterPipeline::run_with_jumper(size_t x, size_t n) const { }; // While possible, build and run at full vector stride. -#if __has_feature(memory_sanitizer) +#if __has_feature(memory_sanitizer) || defined(SK_BUILD_FOR_TVOS) // We'll just run portable code. #elif defined(__aarch64__)