Updates required for building the new m59
authorMatthew Leibowitz <mattleibow@live.com>
Thu, 11 May 2017 01:33:18 +0000 (20:33 -0500)
committerMatthew Leibowitz <mattleibow@live.com>
Thu, 11 May 2017 01:33:18 +0000 (20:33 -0500)
14 files changed:
gn/core.gni
include/c/sk_bitmap.h
include/c/sk_canvas.h
include/c/sk_pixmap.h
include/c/sk_types.h
include/c/sk_vertices.h [new file with mode: 0644]
src/c/sk_bitmap.cpp
src/c/sk_canvas.cpp
src/c/sk_enums.cpp
src/c/sk_pixmap.cpp
src/c/sk_stream.cpp
src/c/sk_types_priv.h
src/c/sk_vertices.cpp [new file with mode: 0644]
src/jumper/SkJumper.cpp

index 83baba9..7de1f82 100644 (file)
@@ -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" ]
 }
index c0751cd..6016752 100644 (file)
@@ -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);
index 5948f8f..f8aec81 100644 (file)
@@ -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
 
index ed905ea..53603cb 100644 (file)
@@ -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
index a877aa1..3157ecb 100644 (file)
@@ -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 (file)
index 0000000..ed21cf3
--- /dev/null
@@ -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
index 2ea5b56..0eb0ac4 100644 (file)
@@ -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)
index 9e5335e..e22626f 100644 (file)
@@ -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));
 }
index 49a95fb..45ec96b 100644 (file)
@@ -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
index d7fe298..edd64d8 100644 (file)
@@ -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);
+}
index c2a7d8d..c7953d4 100644 (file)
@@ -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)
index 43eb05e..d6a2068 100644 (file)
@@ -530,22 +530,6 @@ static inline const sk_colortable_t* ToColorTable(const SkColorTable* p) {
     return reinterpret_cast<const sk_colortable_t*>(p);
 }
 
-static inline const SkPixelRefFactory* AsPixelRefFactory(const sk_pixelref_factory_t* p) {
-    return reinterpret_cast<const SkPixelRefFactory*>(p);
-}
-
-static inline SkPixelRefFactory* AsPixelRefFactory(sk_pixelref_factory_t* p) {
-    return reinterpret_cast<SkPixelRefFactory*>(p);
-}
-
-static inline sk_pixelref_factory_t* ToColorTable(SkPixelRefFactory* p) {
-    return reinterpret_cast<sk_pixelref_factory_t*>(p);
-}
-
-static inline const sk_pixelref_factory_t* ToColorTable(const SkPixelRefFactory* p) {
-    return reinterpret_cast<const sk_pixelref_factory_t*>(p);
-}
-
 static inline sk_surface_t* ToSurface(SkSurface* p) {
     return reinterpret_cast<sk_surface_t*>(p);
 }
@@ -722,6 +706,22 @@ static inline const sk_matrix44_t* ToMatrix44(const SkMatrix44* p) {
     return reinterpret_cast<const sk_matrix44_t*>(p);
 }
 
+static inline const SkVertices* AsVertices(const sk_vertices_t* p) {
+    return reinterpret_cast<const SkVertices*>(p);
+}
+
+static inline SkVertices* AsVertices(sk_vertices_t* p) {
+    return reinterpret_cast<SkVertices*>(p);
+}
+
+static inline sk_vertices_t* ToVertices(SkVertices* p) {
+    return reinterpret_cast<sk_vertices_t*>(p);
+}
+
+static inline const sk_vertices_t* ToVertices(const SkVertices* p) {
+    return reinterpret_cast<const sk_vertices_t*>(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 (file)
index 0000000..32852c6
--- /dev/null
@@ -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());
+}
index 0d4446c..5bd6e4b 100644 (file)
@@ -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__)