WPFGpuRaster.h (2117B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef MOZILLA_GFX_WPF_GPU_RASTER_H 8 #define MOZILLA_GFX_WPF_GPU_RASTER_H 9 10 #include <stddef.h> 11 #include <stdint.h> 12 13 namespace WGR { 14 15 enum class FillMode { EvenOdd, Winding }; 16 struct PathBuilder; 17 struct Point { 18 int32_t x; 19 int32_t y; 20 }; 21 constexpr uint8_t PathPointTypeStart = 0; 22 constexpr uint8_t PathPointTypeLine = 1; 23 constexpr uint8_t PathPointTypeBezier = 3; 24 constexpr uint8_t PathPointTypePathTypeMask = 0x07; 25 constexpr uint8_t PathPointTypeCloseSubpath = 0x80; 26 struct Path { 27 FillMode fill_mode; 28 const Point* points; 29 size_t num_points; 30 const uint8_t* types; 31 size_t num_types; 32 }; 33 struct OutputVertex { 34 float x; 35 float y; 36 float coverage; 37 }; 38 struct VertexBuffer { 39 OutputVertex* data; 40 size_t len; 41 }; 42 43 extern "C" { 44 PathBuilder* wgr_new_builder(); 45 void wgr_builder_reset(PathBuilder* pb); 46 void wgr_builder_move_to(PathBuilder* pb, float x, float y); 47 void wgr_builder_line_to(PathBuilder* pb, float x, float y); 48 void wgr_builder_curve_to(PathBuilder* pb, float c1x, float c1y, float c2x, 49 float c2y, float x, float y); 50 void wgr_builder_quad_to(PathBuilder* pb, float cx, float cy, float x, float y); 51 void wgr_builder_close(PathBuilder* pb); 52 void wgr_builder_set_fill_mode(PathBuilder* pb, FillMode fill_mode); 53 Path wgr_builder_get_path(PathBuilder* pb); 54 VertexBuffer wgr_path_rasterize_to_tri_list( 55 const Path* p, int32_t clip_x, int32_t clip_y, int32_t clip_width, 56 int32_t clip_height, bool need_inside = true, bool need_outside = false, 57 bool rasterization_truncates = false, OutputVertex* output_ptr = nullptr, 58 size_t output_capacity = 0); 59 void wgr_path_release(Path p); 60 void wgr_vertex_buffer_release(VertexBuffer vb); 61 void wgr_builder_release(PathBuilder* pb); 62 }; 63 64 } // namespace WGR 65 66 #endif // MOZILLA_GFX_WPF_GPU_RASTER_H