mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-21 15:01:01 +01:00
begin_path_command()/end_path_command() (and the path-sink begin_command()/end_command()) took a `before` out-parameter that captured the output buffer length so end could charge the emitted bytes to the work budget. That byte charge is gone -- output is bounded by the document-size cap now -- so the parameter and its per-call-site local were dead plumbing. Remove them; begin is now a plain guard and end a plain finalize. Internal helpers only; no API change. Tests: meson test -C build (275/275 passed). Assisted-by: Claude <noreply@anthropic.com>
75 lines
2.3 KiB
C++
75 lines
2.3 KiB
C++
/*
|
|
* Copyright © 2026 Behdad Esfahbod
|
|
*
|
|
* This is part of HarfBuzz, a text shaping library.
|
|
*
|
|
* Permission is hereby granted, without written agreement and without
|
|
* license or royalty fees, to use, copy, modify, and distribute this
|
|
* software and its documentation for any purpose, provided that the
|
|
* above copyright notice and the following two paragraphs appear in
|
|
* all copies of this software.
|
|
*
|
|
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
* DAMAGE.
|
|
*
|
|
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
*
|
|
* Author(s): Behdad Esfahbod
|
|
*/
|
|
|
|
#ifndef HB_VECTOR_PATH_HH
|
|
#define HB_VECTOR_PATH_HH
|
|
|
|
#include "hb.hh"
|
|
#include "hb-vector.hh"
|
|
#include "hb-vector.h"
|
|
#include "hb-draw.h"
|
|
#include "hb-vector-buf.hh"
|
|
|
|
/* Lightweight path sink: serializes hb_draw_* calls into an
|
|
* external char buffer as either SVG path-data or PDF path
|
|
* operators, depending on format. Used by the vector paint
|
|
* backends to accumulate arbitrary clip paths (and by the
|
|
* SVG backend to emit glyph outlines into defs). */
|
|
struct hb_vector_path_sink_t
|
|
{
|
|
hb_vector_buf_t *path;
|
|
unsigned precision;
|
|
float x_scale;
|
|
float y_scale;
|
|
int64_t *budget;
|
|
|
|
bool begin_command ()
|
|
{
|
|
return likely (!path->in_error () && !(budget && *budget < 0));
|
|
}
|
|
|
|
void end_command ()
|
|
{
|
|
/* Serialized bytes are bounded by the output buffer's document-size
|
|
* cap (in_error), not the outline work budget; stop outline traversal
|
|
* once that cap or an allocation error trips. */
|
|
if (!budget) return;
|
|
if (unlikely (path->in_error ()))
|
|
*budget = 0;
|
|
}
|
|
};
|
|
|
|
HB_INTERNAL hb_draw_funcs_t *
|
|
hb_vector_svg_path_draw_funcs_get ();
|
|
|
|
HB_INTERNAL hb_draw_funcs_t *
|
|
hb_vector_pdf_path_draw_funcs_get ();
|
|
|
|
HB_INTERNAL hb_draw_funcs_t *
|
|
hb_vector_path_draw_funcs_get (hb_vector_format_t format);
|
|
|
|
#endif /* HB_VECTOR_PATH_HH */
|