QtBase  v6.3.1
hb-cff1-interp-cs.hh
Go to the documentation of this file.
1 /*
2  * Copyright © 2018 Adobe Inc.
3  *
4  * This is part of HarfBuzz, a text shaping library.
5  *
6  * Permission is hereby granted, without written agreement and without
7  * license or royalty fees, to use, copy, modify, and distribute this
8  * software and its documentation for any purpose, provided that the
9  * above copyright notice and the following two paragraphs appear in
10  * all copies of this software.
11  *
12  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16  * DAMAGE.
17  *
18  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23  *
24  * Adobe Author(s): Michiharu Ariza
25  */
26 #ifndef HB_CFF1_INTERP_CS_HH
27 #define HB_CFF1_INTERP_CS_HH
28 
29 #include "hb.hh"
31 
32 namespace CFF {
33 
34 using namespace OT;
35 
37 
38 struct cff1_cs_interp_env_t : cs_interp_env_t<number_t, CFF1Subrs>
39 {
40  template <typename ACC>
41  void init (const byte_str_t &str, ACC &acc, unsigned int fd)
42  {
43  SUPER::init (str, acc.globalSubrs, acc.privateDicts[fd].localSubrs);
44  processed_width = false;
45  has_width = false;
46  arg_start = 0;
47  in_seac = false;
48  }
49 
50  void fini () { SUPER::fini (); }
51 
52  void set_width (bool has_width_)
53  {
54  if (likely (!processed_width && (SUPER::argStack.get_count () > 0)))
55  {
56  if (has_width_)
57  {
58  width = SUPER::argStack[0];
59  has_width = true;
60  arg_start = 1;
61  }
62  }
63  processed_width = true;
64  }
65 
66  void clear_args ()
67  {
68  arg_start = 0;
69  SUPER::clear_args ();
70  }
71 
72  void set_in_seac (bool _in_seac) { in_seac = _in_seac; }
73 
75  bool has_width;
76  unsigned int arg_start;
78  bool in_seac;
79 
80  private:
82 };
83 
84 template <typename OPSET, typename PARAM, typename PATH=path_procs_null_t<cff1_cs_interp_env_t, PARAM>>
85 struct cff1_cs_opset_t : cs_opset_t<number_t, OPSET, cff1_cs_interp_env_t, PARAM, PATH>
86 {
87  /* PostScript-originated legacy opcodes (OpCode_add etc) are unsupported */
88  /* Type 1-originated deprecated opcodes, seac behavior of endchar and dotsection are supported */
89 
90  static void process_op (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
91  {
92  switch (op) {
93  case OpCode_dotsection:
94  SUPER::flush_args_and_op (op, env, param);
95  break;
96 
97  case OpCode_endchar:
98  OPSET::check_width (op, env, param);
99  if (env.argStack.get_count () >= 4)
100  {
101  OPSET::process_seac (env, param);
102  }
103  OPSET::flush_args_and_op (op, env, param);
104  env.set_endchar (true);
105  break;
106 
107  default:
108  SUPER::process_op (op, env, param);
109  }
110  }
111 
112  static void check_width (op_code_t op, cff1_cs_interp_env_t &env, PARAM& param)
113  {
114  if (!env.processed_width)
115  {
116  bool has_width = false;
117  switch (op)
118  {
119  case OpCode_endchar:
120  case OpCode_hstem:
121  case OpCode_hstemhm:
122  case OpCode_vstem:
123  case OpCode_vstemhm:
124  case OpCode_hintmask:
125  case OpCode_cntrmask:
126  has_width = ((env.argStack.get_count () & 1) != 0);
127  break;
128  case OpCode_hmoveto:
129  case OpCode_vmoveto:
130  has_width = (env.argStack.get_count () > 1);
131  break;
132  case OpCode_rmoveto:
133  has_width = (env.argStack.get_count () > 2);
134  break;
135  default:
136  return;
137  }
138  env.set_width (has_width);
139  }
140  }
141 
142  static void process_seac (cff1_cs_interp_env_t &env, PARAM& param)
143  {
144  }
145 
146  static void flush_args (cff1_cs_interp_env_t &env, PARAM& param)
147  {
148  SUPER::flush_args (env, param);
149  env.clear_args (); /* pop off width */
150  }
151 
152  private:
154 };
155 
156 template <typename OPSET, typename PARAM>
157 struct cff1_cs_interpreter_t : cs_interpreter_t<cff1_cs_interp_env_t, OPSET, PARAM> {};
158 
159 } /* namespace CFF */
160 
161 #endif /* HB_CFF1_INTERP_CS_HH */
QString str
[2]
#define OpCode_hintmask
#define OpCode_rmoveto
#define OpCode_vmoveto
#define OpCode_vstem
#define OpCode_hstemhm
#define OpCode_dotsection
#define OpCode_cntrmask
#define OpCode_endchar
#define OpCode_hmoveto
#define OpCode_vstemhm
#define OpCode_hstem
#define likely(expr)
Definition: hb.hh:250
biased_subrs_t< CFF1Subrs > cff1_biased_subrs_t
unsigned int op_code_t
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld init[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld SRC pixld MASK if DST_R else pixld DST_R endif if src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head if pixblock_size cache_preload_simple endif process_pixblock_tail pixinterleave dst_w_basereg irp if pixblock_size chunk_size tst beq if DST_W else pixst DST_W else mov ORIG_W endif add lsl if lsl endif if lsl endif lsl endif lsl endif lsl endif subs mov DST_W if regs_shortage str endif bge start_of_loop_label endm macro generate_composite_function
set set set set set set set macro pixldst1 op
GLint GLsizei width
GLenum const GLint * param
GLuint64 GLenum GLint fd
void set_in_seac(bool _in_seac)
void set_width(bool has_width_)
void init(const byte_str_t &str, ACC &acc, unsigned int fd)
static void flush_args(cff1_cs_interp_env_t &env, PARAM &param)
static void process_op(op_code_t op, cff1_cs_interp_env_t &env, PARAM &param)
static void check_width(op_code_t op, cff1_cs_interp_env_t &env, PARAM &param)
static void process_seac(cff1_cs_interp_env_t &env, PARAM &param)
void set_endchar(bool endchar_flag_)
arg_stack_t< ARG > argStack
#define ACC