apwfreetypelib

Check-in [5f647f2006]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixes new code and refactoring.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:5f647f2006633434ca375cc56724dd579a9cad15
User & Date: arnulf 2015-01-25 18:02:26
Context
2015-01-25
18:58
fixes and new code. check-in: c443e0dd64 user: arnulf tags: trunk
18:02
fixes new code and refactoring. check-in: 5f647f2006 user: arnulf tags: trunk
16:24
fixes and renaming check-in: 37d8d05b7b user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to aftraster/FTGrayOutlineFuncsClass.java.

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
...
178
179
180
181
182
183
184
185
186
187
188
189

190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
...
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
...
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
...
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
...
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
...
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
...
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
...
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
...
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
...
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
...
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
...
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870


871
872
873

874

875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911

      /* record current cell, if any */
    gray_record_cell(worker);
      /* start to a new position */
    x = RasterUtil.UPSCALE(to.x);
    y = RasterUtil.UPSCALE(to.y);
    gray_start_cell(worker, RasterUtil.TRUNC(x), RasterUtil.TRUNC(y));
    worker.x = x;
    worker.y = y;
    return error;
  }

  /* =====================================================================
   *    gray_line_to
   *
   * =====================================================================
................................................................................

  /* =====================================================================
   *    gray_find_cell
   *
   * =====================================================================
   */
  private TCellRec gray_find_cell(grayTWorkerRec worker) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_find_cell: ras.ex: %d, ras.ey: %d, ras.count_ex: %d, ras.num_cells: %d", worker.ex, worker.ey, worker.count_ex, worker.num_cells));
    int pcellIdx;
    int cellIdx;
    TCellRec cell = null;
    TCellRec pcell = null;
    int x = worker.ex;
    boolean useYcells = true;
    boolean isYcell = true;

    if (x > worker.count_ex) {
      x = worker.count_ex;
    }
    for(int j = 0; j < worker.ycount; j++) {
      int a = worker.ycells[j] == null ? -1 : worker.ycells[j].area;
      int c = worker.ycells[j] == null ? -1 : worker.ycells[j].cover;
      StringBuffer str = new StringBuffer("");
      str.append(String.format("ycells j: %2d, idx: %2d, x: %4d, a: %6x, c: %6x", j,
          worker.ycells[j] == null ? -1 : worker.ycells[j].self_idx,
          worker.ycells[j] == null ? -1 : worker.ycells[j].x,
          a & 0xFFFFFF, c & 0xFFFFFF));
      cell = worker.ycells[j];
      while( cell != null) {
        cell = cell.next;
        if (cell != null) {
          str.append(String.format("\n              idx: %2d, x: %4d, a: %6x, c: %6x",
              cell.self_idx, cell.x, cell.area & 0xFFFFFF, cell.cover & 0xFFFFFF));
        }
      }
Debug(0, DebugTag.DBG_RENDER, TAG, str.toString());
    }

    pcellIdx = (int)worker.ey;
    cellIdx = -1;
    for (;;) {
      if (cellIdx == -1) {
        cell = worker.ycells[pcellIdx];
      } else {
        cell = cell.next;
      }
      if (cell == null || cell.x > x) {
        break;
      }
      if (cell.x == x) {
................................................................................
      }
      if (!useYcells) {
        isYcell = false;
      }
      useYcells = false;
      cellIdx = cell.self_idx;
    }
    if (worker.num_cells >= worker.max_cells) {
//FIXME!!        ft_longjmp( worker.jump_buffer, 1 );
      Log.e(TAG, "out of worker.cells: " + worker.num_cells + "!" + worker.max_cells);
    }
    cell = worker.cells[worker.num_cells++];

    cell.self_idx = worker.num_cells - 1;
    cell.x = x;
    cell.area = 0;
    cell.cover = 0;
    if (useYcells) {
      cell.next = worker.ycells[pcellIdx];
//System.out.println(String.format("pcellIdx: %d",  pcellIdx));
      worker.ycells[pcellIdx] = cell;
    } else {
      if (isYcell) {
        cell.next = worker.ycells[pcellIdx].next;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cellIdx. %d pcellIdx: %d",  cellIdx, pcellIdx));
        worker.ycells[pcellIdx].next = cell;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("isYcell: cell idx: %d cell next idx: %d ", cell.self_idx, cell.next == null ? -1 : cell.next.self_idx));
      } else {
        cell.next = worker.cells[cellIdx].next;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cellIdx. %d pcellIdx: %d",  cellIdx, pcellIdx));
        worker.cells[cellIdx].next = cell;
      }
    }
    return cell;
  }

  /* =====================================================================
   *    gray_record_cell
   *
   * =====================================================================
   */
  public void gray_record_cell(grayTWorkerRec worker) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_record_cell: ras.invalid: %b, ras.area: %x, ras.cover: %x\n", worker.invalid, worker.area, worker.cover));

    if (!worker.invalid && (worker.area | worker.cover) != 0) {
      TCellRec cell = gray_find_cell(worker);

      cell.area  += worker.area;
      cell.cover += worker.cover;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_record_cell2: cell.area: %x, cell.cover: %x worker.area: %x, worker.cover: %x\n", cell.area, cell.cover, worker.area, worker.cover));
    }
  }

  /* =====================================================================
   *    gray_set_cell
   *
   * Move the cell pointer to a new position.  We set the `invalid'
................................................................................
   *
   * Note that if a cell is to the left of the clipping region, it is
   * actually set to the (min_ex-1) horizontal position.
   *
   * =====================================================================
   */
  private void gray_set_cell(grayTWorkerRec worker, int ex, int ey) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_set_cell: ex: %d, ey: %d, invalid: %b, ras.ex: %d, ras.ey: %d", ex, ey, worker.invalid, worker.ex, worker.ey));
      /* All cells that are on the left of the clipping region go to the */
      /* min_ex - 1 horizontal position.                                 */
    ey -= worker.min_ey;
    if (ex > worker.max_ex) {
      ex = worker.max_ex;
    }
    ex -= worker.min_ex;
    if (ex < 0) {
      ex = -1;
    }
      /* are we moving to a different cell ? */
    if (ex != worker.ex || ey != worker.ey) {
        /* record the current one if it is valid */
      if (!worker.invalid) {
        gray_record_cell(worker);
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_set_cell after call gray_record_cell"));
      }
      worker.area  = 0;
      worker.cover = 0;
    }
    worker.ex = ex;
    worker.ey = ey;
    worker.invalid = (ey >= worker.count_ey || ex >= worker.count_ex);
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_set_cell end"));
  }

  /* =====================================================================
   *    gray_start_cell
   *
   * =====================================================================
   */
  private void gray_start_cell(grayTWorkerRec worker, int ex, int ey) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_start_cell: ex: %d, ey: %d", ex, ey));

    if (ex > worker.max_ex) {
      ex = worker.max_ex;
    }
    if (ex < worker.min_ex) {
      ex = worker.min_ex - 1;
    }
    worker.area = 0;
    worker.cover = 0;
    worker.ex = ex - worker.min_ex;
    worker.ey = ey - worker.min_ey;
    worker.last_ey = RasterUtil.SUBPIXELS(ey);
    worker.invalid = false;
    gray_set_cell(worker, ex, ey);
  }


  /* =====================================================================
   *    gray_render_scanline
   *
................................................................................
      gray_set_cell(worker, ex2, ey);
      return;
    }
      /* everything is located in a single cell.  That is easy! */
      /*                                                        */
    if (ex1 == ex2) {
      delta = y2 - y1;
      worker.area  += ((fx1 + fx2) * delta);
      worker.cover += delta;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("return ex1 == ex2: %d", ex2));
      return;
    }
      /* ok, we'll have to render a run of adjacent cells on the same */
      /* scanline...                                                  */
      /*                                                              */
    p = (RasterUtil.ONE_PIXEL() - fx1) * (y2 - y1);
................................................................................
    }
    delta = (p / dx);
    mod   = (p % dx);
    if (mod < 0) {
      delta--;
      mod += dx;
    }
    worker.area += ((fx1 + first) * delta);
    worker.cover += delta;
    ex1 += incr;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("call gray_set_cell2 ex1: %d, ey: %d", ex1, ey));
    gray_set_cell(worker, ex1, ey);
    y1  += delta;
    if (ex1 != ex2) {
      int lift;
      int rem;
................................................................................
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("ex1: %d ex2: %d incr: %d", ex1, ex2, incr));
        delta = lift;
        mod  += rem;
        if (mod >= 0) {
          mod -= dx;
          delta++;
        }
        worker.area += (RasterUtil.ONE_PIXEL() * delta);
        worker.cover += delta;
        y1 += delta;
        ex1 += incr;
        gray_set_cell(worker, ex1, ey);
      }
    }
    delta = y2 - y1;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("return end delta: %d", delta));
    worker.area  += ((fx2 + RasterUtil.ONE_PIXEL() - first) * delta);
    worker.cover += delta;
  }

  /* =====================================================================
   *    gray_render_line
   *
   * =====================================================================
   */
................................................................................
    int first;
    int delta;
    int rem;
    int lift;
    int incr;

Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_render_line: to_x: %d, to_y: %d", to_x, to_y));
    ey1 = RasterUtil.TRUNC(worker.last_ey);
    ey2 = RasterUtil.TRUNC(to_y);     /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
    fy1 = (worker.y - worker.last_ey);
    fy2 = (to_y - RasterUtil.SUBPIXELS(ey2));
    dx = to_x - worker.x;
    dy = to_y - worker.y;
      /* XXX: we should do something about the trivial case where dx == 0, */
      /*      as it happens very often!                                    */

      /* perform vertical clipping */
    {
      int min;
      int max;
................................................................................

      min = ey1;
      max = ey2;
      if (ey1 > ey2) {
        min = ey2;
        max = ey1;
      }
      if (min >= worker.max_ey || max < worker.min_ey) {
        worker.x = to_x;
        worker.y = to_y;
        worker.last_ey = RasterUtil.SUBPIXELS(ey2);
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line return 1");
        return;
      }
    }
      /* everything is on a single scanline */
    if (ey1 == ey2) {
      gray_render_scanline(worker, ey1, worker.x, fy1, to_x, fy2);
      worker.x = to_x;
      worker.y = to_y;
      worker.last_ey = RasterUtil.SUBPIXELS(ey2);
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line return 2");
      return;
    }
      /* vertical line - avoid calling gray_render_scanline */
    incr = 1;
    if (dx == 0) {
      int ex = RasterUtil.TRUNC(worker.x);
      int two_fx = ((worker.x - RasterUtil.SUBPIXELS(ex)) << 1);
      int area;

      first = RasterUtil.ONE_PIXEL();
      if (dy < 0) {
        first = 0;
        incr  = -1;
      }
      delta = (int)(first - fy1);
      worker.area  += two_fx * delta;
      worker.cover += delta;
      ey1 += incr;
      gray_set_cell(worker, ex, ey1);
      delta = (first + first - RasterUtil.ONE_PIXEL());
      area = two_fx * delta;
      while (ey1 != ey2) {
        worker.area += area;
        worker.cover += delta;
        ey1 += incr;
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line call gray_set_cell while");
        gray_set_cell(worker, ex, ey1);
      }
      delta = (fy2 - RasterUtil.ONE_PIXEL() + first);
      worker.area += two_fx * delta;
      worker.cover += delta;
      worker.x = to_x;
      worker.y = to_y;
      worker.last_ey = RasterUtil.SUBPIXELS(ey2);
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line return 3");
      return;
    }
      /* ok, we have to render several scanlines */
    p = (RasterUtil.ONE_PIXEL() - fy1) * dx;
    first = RasterUtil.ONE_PIXEL();
    incr = 1;
................................................................................
    }
    delta = (int)(p / dy);
    mod = (int)(p % dy);
    if (mod < 0) {
      delta--;
      mod += dy;
    }
    x = worker.x + delta;
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line call gray_render_scanline 1");
    gray_render_scanline(worker, ey1, worker.x, fy1, x, first);
    ey1 += incr;
    gray_set_cell(worker, RasterUtil.TRUNC(x), ey1);
    if (ey1 != ey2) {
      p = RasterUtil.ONE_PIXEL() * dx;
      lift  = (int)(p / dy);
      rem   = (int)(p % dy);
      if (rem < 0) {
        lift--;
        rem += (int)dy;
      }
      mod -= (int)dy;
      while (ey1 != ey2) {
        delta = lift;
        mod += rem;
        if (mod >= 0) {
          mod -= (int)dy;
          delta++;
        }
        x2 = x + delta;
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line call gray_render_scanline 2");
        gray_render_scanline(worker, ey1, x, RasterUtil.ONE_PIXEL() - first, x2, first);
        x = x2;
        ey1 += incr;
        gray_set_cell(worker, RasterUtil.TRUNC(x), ey1);
      }
    }
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line call gray_render_scanline 3");
    gray_render_scanline(worker, ey1, x, RasterUtil.ONE_PIXEL() - first, to_x, fy2);
    worker.x = to_x;
    worker.y = to_y;
    worker.last_ey = RasterUtil.SUBPIXELS(ey2);
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line end");
  }

  /* =====================================================================
   *    gray_split_conic
   *
   * =====================================================================
................................................................................
    int[] levels;
    FTVectorRec[] arc;
    FTReference<FTVectorRec[]> arc_ref = new FTReference<FTVectorRec[]>();
    int arcIdx = 0;
    boolean doDraw = false;

Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_conic");
    levels = worker.lev_stack;
    arc = worker.bez_stack;
    arc[arcIdx + 0].x = RasterUtil.UPSCALE(to.x);
    arc[arcIdx + 0].y = RasterUtil.UPSCALE(to.y);
    arc[arcIdx + 1].x = RasterUtil.UPSCALE(control.x);
    arc[arcIdx + 1].y = RasterUtil.UPSCALE(control.y);
    arc[arcIdx + 2].x = worker.x;
    arc[arcIdx + 2].y = worker.y;
    top = 0;
    dx = FTCalc.FT_ABS(arc[arcIdx + 2].x + arc[arcIdx + 0].x - 2 * arc[arcIdx + 1].x);
    dy = FTCalc.FT_ABS(arc[arcIdx + 2].y + arc[arcIdx + 0].y - 2 * arc[arcIdx + 1].y);
    if (dx < dy) {
      dx = dy;
    }
    if (dx < RasterUtil.ONE_PIXEL() / 4) {
................................................................................
      y = arc[arcIdx + 2].y;
      if (y < min) {
        min = y;
      }
      if (y > max) {
        max = y;
      }
      if (RasterUtil.TRUNC(min) >= worker.max_ey || RasterUtil.TRUNC(max) < worker.min_ey) {
        doDraw = true;
      }
    }
    if (!doDraw) {
      level = 0;
      do {
        dx >>= 2;
................................................................................
    int arcIdx = 0;
    int min;
    int max;
    int y;
    boolean noSplit = false;

Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_cubic");
    arc = worker.bez_stack;
    arc[arcIdx + 0].x = RasterUtil.UPSCALE(to.x);
    arc[arcIdx + 0].y = RasterUtil.UPSCALE(to.y);
    arc[arcIdx + 1].x = RasterUtil.UPSCALE(control2.x);
    arc[arcIdx + 1].y = RasterUtil.UPSCALE(control2.y);
    arc[arcIdx + 2].x = RasterUtil.UPSCALE(control1.x);
    arc[arcIdx + 2].y = RasterUtil.UPSCALE(control1.y);
    arc[arcIdx + 3].x = worker.x;
    arc[arcIdx + 3].y = worker.y;
      /* Short-cut the arc that crosses the current band. */
    min = max = arc[arcIdx + 0].y;
    y = arc[arcIdx + 1].y;
    if (y < min) {
      min = y;
    }
    if (y > max) {
................................................................................
    y = arc[arcIdx + 3].y;
    if (y < min) {
      min = y;
    }
    if (y > max) {
      max = y;
    }
    if (RasterUtil.TRUNC(min) >= worker.max_ey || RasterUtil.TRUNC(max) < worker.min_ey) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_render_cubic call gray_render_line"));
      gray_render_line(worker, arc[arcIdx + 0].x, arc[arcIdx + 0].y);
      if (arc == worker.bez_stack) {
        return;
      }
      arcIdx -= 3;
    }
    for (;;) {
        /* Decide whether to split or draw. See `Rapid Termination          */
        /* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */
................................................................................
        gray_split_cubic(arc_ref, arcIdx);
        arc = arc_ref.Get();
        arcIdx += 3;
        continue;
      }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_render_cubic 2 call gray_render_line"));
      gray_render_line(worker, arc[arcIdx + 0].x, arc[arcIdx + 0].y);
      if (arc == worker.bez_stack) {
        return;
      }
      arcIdx -= 3;
      worker.bez_stack = arc;
    }
  }

  /* =====================================================================
   *    gray_compute_cbox
   *
   * =====================================================================
   */
  public void gray_compute_cbox(grayTWorkerRec worker) {
    FTOutlineRec outline = worker.outline;
    FTVectorRec vec;
    int vecIdx = 0;
    int limit = outline.getN_points();

Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_compute_cbox"));
    if (outline.getN_points() <= 0) {
      worker.min_ex = worker.max_ex = 0;
      worker.min_ey = worker.max_ey = 0;


      return;
    }
    worker.min_ex = worker.max_ex = outline.getPoints()[vecIdx].x;

    worker.min_ey = worker.max_ey = outline.getPoints()[vecIdx].y;

Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cbox01: %d %d %d %d", worker.min_ex, worker.min_ey, worker.max_ex, worker.max_ey));
    vecIdx++;
    for ( ; vecIdx < limit; vecIdx++) {
      vec = outline.getPoints()[vecIdx];
      int x = vec.x;
      int y = vec.y;

      if (x < worker.min_ex) {
        worker.min_ex = x;
      }
      if (x > worker.max_ex) {
        worker.max_ex = x;
      }
      if (y < worker.min_ey) {
        worker.min_ey = y;
      }
      if (y > worker.max_ey) {
        worker.max_ey = y;
      }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cbox11: %d %d", x, y));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cbox12: %d %d %d %d", worker.min_ex, worker.min_ey, worker.max_ex, worker.max_ey));
    }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cbox2: %d %d %d %d", worker.min_ex, worker.min_ey, worker.max_ex, worker.max_ey));
      /* truncate the bounding box to integer pixels */
    worker.min_ex = worker.min_ex >> 6;
    worker.min_ey = worker.min_ey >> 6;
    worker.max_ex = (worker.max_ex + 63) >> 6;
    worker.max_ey = (worker.max_ey + 63) >> 6;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_comput_cbox end: %d %d %d %d", worker.min_ex, worker.min_ey, worker.max_ex, worker.max_ey));
    worker.outline = outline;
  }


  /* ==================== moveTo ===================================== */
  @Override
  public FTError.ErrorTag moveTo(FTVectorRec point, Object user) {
    return gray_move_to(point, (grayTWorkerRec)user);







|
|







 







|




|



|
|

|
|
|


|
|

|










|



|







 







|

|

|
>
|




|

|


|

|


|

|











|

|


|
|
|







 







|


|
|
|

|




|

|



|
|

|
|
|











|
|

|
|

|
|
|
|
|
|







 







|
|







 







|
|







 







|
|







|
|







 







|

|

|
|







 







|
|
|
|






|
|
|
|






|
|








|
|





|
|





|
|
|
|
|







 







|

|




|
|


|

|




|












|
|
|







 







|
|




|
|







 







|







 







|






|
|







 







|


|







 







|



|









|






|
|
>
>


|
>
|
>
|






|
|

|
|

|
|

|
|


|

|

|
|
|
|
|
|







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
...
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
...
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
...
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
...
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
...
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
...
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
...
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
...
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
...
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
...
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
...
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
...
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916

      /* record current cell, if any */
    gray_record_cell(worker);
      /* start to a new position */
    x = RasterUtil.UPSCALE(to.x);
    y = RasterUtil.UPSCALE(to.y);
    gray_start_cell(worker, RasterUtil.TRUNC(x), RasterUtil.TRUNC(y));
    worker.setX(x);
    worker.setY(y);
    return error;
  }

  /* =====================================================================
   *    gray_line_to
   *
   * =====================================================================
................................................................................

  /* =====================================================================
   *    gray_find_cell
   *
   * =====================================================================
   */
  private TCellRec gray_find_cell(grayTWorkerRec worker) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_find_cell: ras.ex: %d, ras.ey: %d, ras.count_ex: %d, ras.num_cells: %d", worker.getEx(), worker.getEy(), worker.getCount_ex(), worker.getNum_cells()));
    int pcellIdx;
    int cellIdx;
    TCellRec cell = null;
    TCellRec pcell = null;
    int x = worker.getEx();
    boolean useYcells = true;
    boolean isYcell = true;

    if (x > worker.getCount_ex()) {
      x = worker.getCount_ex();
    }
    for(int j = 0; j < worker.getYcount(); j++) {
      int a = worker.getYcell(j) == null ? -1 : worker.getYcell(j).area;
      int c = worker.getYcell(j) == null ? -1 : worker.getYcell(j).cover;
      StringBuffer str = new StringBuffer("");
      str.append(String.format("ycells j: %2d, idx: %2d, x: %4d, a: %6x, c: %6x", j,
          worker.getYcell(j) == null ? -1 : worker.getYcell(j).self_idx,
          worker.getYcell(j) == null ? -1 : worker.getYcell(j).x,
          a & 0xFFFFFF, c & 0xFFFFFF));
      cell = worker.getYcell(j);
      while( cell != null) {
        cell = cell.next;
        if (cell != null) {
          str.append(String.format("\n              idx: %2d, x: %4d, a: %6x, c: %6x",
              cell.self_idx, cell.x, cell.area & 0xFFFFFF, cell.cover & 0xFFFFFF));
        }
      }
Debug(0, DebugTag.DBG_RENDER, TAG, str.toString());
    }

    pcellIdx = worker.getEy();
    cellIdx = -1;
    for (;;) {
      if (cellIdx == -1) {
        cell = worker.getYcell(pcellIdx);
      } else {
        cell = cell.next;
      }
      if (cell == null || cell.x > x) {
        break;
      }
      if (cell.x == x) {
................................................................................
      }
      if (!useYcells) {
        isYcell = false;
      }
      useYcells = false;
      cellIdx = cell.self_idx;
    }
    if (worker.getNum_cells() >= worker.getMax_cells()) {
//FIXME!!        ft_longjmp( worker.jump_buffer, 1 );
      Log.e(TAG, "out of worker.cells: " + worker.getNum_cells() + "!" + worker.getMax_cells());
    }
    cell = worker.getCell(worker.getNum_cells());
    worker.setNum_cells(worker.getNum_cells() + 1);
    cell.self_idx = worker.getNum_cells() - 1;
    cell.x = x;
    cell.area = 0;
    cell.cover = 0;
    if (useYcells) {
      cell.next = worker.getYcell(pcellIdx);
//System.out.println(String.format("pcellIdx: %d",  pcellIdx));
      worker.setYcell(pcellIdx, cell);
    } else {
      if (isYcell) {
        cell.next = worker.getYcell(pcellIdx).next;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cellIdx. %d pcellIdx: %d",  cellIdx, pcellIdx));
        worker.getYcell(pcellIdx).next = cell;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("isYcell: cell idx: %d cell next idx: %d ", cell.self_idx, cell.next == null ? -1 : cell.next.self_idx));
      } else {
        cell.next = worker.getCell(cellIdx).next;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cellIdx. %d pcellIdx: %d",  cellIdx, pcellIdx));
        worker.getCell(cellIdx).next = cell;
      }
    }
    return cell;
  }

  /* =====================================================================
   *    gray_record_cell
   *
   * =====================================================================
   */
  public void gray_record_cell(grayTWorkerRec worker) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_record_cell: ras.invalid: %b, ras.area: %x, ras.cover: %x\n", worker.isInvalid(), worker.getArea(), worker.getCover()));

    if (!worker.isInvalid() && (worker.getArea() | worker.getCover()) != 0) {
      TCellRec cell = gray_find_cell(worker);

      cell.area  += worker.getArea();
      cell.cover += worker.getCover();
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_record_cell2: cell.area: %x, cell.cover: %x worker.area: %x, worker.cover: %x\n", cell.area, cell.cover, worker.getArea(), worker.getCover()));
    }
  }

  /* =====================================================================
   *    gray_set_cell
   *
   * Move the cell pointer to a new position.  We set the `invalid'
................................................................................
   *
   * Note that if a cell is to the left of the clipping region, it is
   * actually set to the (min_ex-1) horizontal position.
   *
   * =====================================================================
   */
  private void gray_set_cell(grayTWorkerRec worker, int ex, int ey) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_set_cell: ex: %d, ey: %d, invalid: %b, ras.ex: %d, ras.ey: %d", ex, ey, worker.isInvalid(), worker.getEx(), worker.getEy()));
      /* All cells that are on the left of the clipping region go to the */
      /* min_ex - 1 horizontal position.                                 */
    ey -= worker.getMin_ey();
    if (ex > worker.getMax_ex()) {
      ex = worker.getMax_ex();
    }
    ex -= worker.getMin_ex();
    if (ex < 0) {
      ex = -1;
    }
      /* are we moving to a different cell ? */
    if (ex != worker.getEx() || ey != worker.getEy()) {
        /* record the current one if it is valid */
      if (!worker.isInvalid()) {
        gray_record_cell(worker);
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_set_cell after call gray_record_cell"));
      }
      worker.setArea(0);
      worker.setCover(0);
    }
    worker.setEx(ex);
    worker.setEy(ey);
    worker.setInvalid((ey >= worker.getCount_ey()) || ex >= worker.getCount_ex());
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_set_cell end"));
  }

  /* =====================================================================
   *    gray_start_cell
   *
   * =====================================================================
   */
  private void gray_start_cell(grayTWorkerRec worker, int ex, int ey) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_start_cell: ex: %d, ey: %d", ex, ey));

    if (ex > worker.getMax_ex()) {
      ex = worker.getMax_ex();
    }
    if (ex < worker.getMin_ex()) {
      ex = worker.getMin_ex() - 1;
    }
    worker.setArea(0);
    worker.setCover(0);
    worker.setEx(ex - worker.getMin_ex());
    worker.setEy(ey - worker.getMin_ey());
    worker.setLast_ey(RasterUtil.SUBPIXELS(ey));
    worker.setInvalid(false);
    gray_set_cell(worker, ex, ey);
  }


  /* =====================================================================
   *    gray_render_scanline
   *
................................................................................
      gray_set_cell(worker, ex2, ey);
      return;
    }
      /* everything is located in a single cell.  That is easy! */
      /*                                                        */
    if (ex1 == ex2) {
      delta = y2 - y1;
      worker.setArea(worker.getArea() + ((fx1 + fx2) * delta));
      worker.setCover(worker.getCover() + delta);
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("return ex1 == ex2: %d", ex2));
      return;
    }
      /* ok, we'll have to render a run of adjacent cells on the same */
      /* scanline...                                                  */
      /*                                                              */
    p = (RasterUtil.ONE_PIXEL() - fx1) * (y2 - y1);
................................................................................
    }
    delta = (p / dx);
    mod   = (p % dx);
    if (mod < 0) {
      delta--;
      mod += dx;
    }
    worker.setArea(worker.getArea() + ((fx1 + first) * delta));
    worker.setCover(worker.getCover() + delta);
    ex1 += incr;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("call gray_set_cell2 ex1: %d, ey: %d", ex1, ey));
    gray_set_cell(worker, ex1, ey);
    y1  += delta;
    if (ex1 != ex2) {
      int lift;
      int rem;
................................................................................
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("ex1: %d ex2: %d incr: %d", ex1, ex2, incr));
        delta = lift;
        mod  += rem;
        if (mod >= 0) {
          mod -= dx;
          delta++;
        }
        worker.setArea(worker.getArea() + (RasterUtil.ONE_PIXEL() * delta));
        worker.setCover(worker.getCover() + delta);
        y1 += delta;
        ex1 += incr;
        gray_set_cell(worker, ex1, ey);
      }
    }
    delta = y2 - y1;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("return end delta: %d", delta));
    worker.setArea(worker.getArea()  + ((fx2 + RasterUtil.ONE_PIXEL() - first) * delta));
    worker.setCover(worker.getCover() + delta);
  }

  /* =====================================================================
   *    gray_render_line
   *
   * =====================================================================
   */
................................................................................
    int first;
    int delta;
    int rem;
    int lift;
    int incr;

Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_render_line: to_x: %d, to_y: %d", to_x, to_y));
    ey1 = RasterUtil.TRUNC(worker.getLast_ey());
    ey2 = RasterUtil.TRUNC(to_y);     /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
    fy1 = (worker.getY() - worker.getLast_ey());
    fy2 = (to_y - RasterUtil.SUBPIXELS(ey2));
    dx = to_x - worker.getX();
    dy = to_y - worker.getY();
      /* XXX: we should do something about the trivial case where dx == 0, */
      /*      as it happens very often!                                    */

      /* perform vertical clipping */
    {
      int min;
      int max;
................................................................................

      min = ey1;
      max = ey2;
      if (ey1 > ey2) {
        min = ey2;
        max = ey1;
      }
      if (min >= worker.getMax_ey() || max < worker.getMin_ey()) {
        worker.setX(to_x);
        worker.setY(to_y);
        worker.setLast_ey(RasterUtil.SUBPIXELS(ey2));
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line return 1");
        return;
      }
    }
      /* everything is on a single scanline */
    if (ey1 == ey2) {
      gray_render_scanline(worker, ey1, worker.getX(), fy1, to_x, fy2);
      worker.setX(to_x);
      worker.setY(to_y);
      worker.setLast_ey(RasterUtil.SUBPIXELS(ey2));
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line return 2");
      return;
    }
      /* vertical line - avoid calling gray_render_scanline */
    incr = 1;
    if (dx == 0) {
      int ex = RasterUtil.TRUNC(worker.getX());
      int two_fx = ((worker.getX() - RasterUtil.SUBPIXELS(ex)) << 1);
      int area;

      first = RasterUtil.ONE_PIXEL();
      if (dy < 0) {
        first = 0;
        incr  = -1;
      }
      delta = (int)(first - fy1);
      worker.setArea(worker.getArea()  + two_fx * delta);
      worker.setCover(worker.getCover() + delta);
      ey1 += incr;
      gray_set_cell(worker, ex, ey1);
      delta = (first + first - RasterUtil.ONE_PIXEL());
      area = two_fx * delta;
      while (ey1 != ey2) {
        worker.setArea(worker.getArea() + area);
        worker.setCover(worker.getCover() + delta);
        ey1 += incr;
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line call gray_set_cell while");
        gray_set_cell(worker, ex, ey1);
      }
      delta = (fy2 - RasterUtil.ONE_PIXEL() + first);
      worker.setArea(worker.getArea() + two_fx * delta);
      worker.setCover(worker.getCover() + delta);
      worker.setX(to_x);
      worker.setY(to_y);
      worker.setLast_ey(RasterUtil.SUBPIXELS(ey2));
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line return 3");
      return;
    }
      /* ok, we have to render several scanlines */
    p = (RasterUtil.ONE_PIXEL() - fy1) * dx;
    first = RasterUtil.ONE_PIXEL();
    incr = 1;
................................................................................
    }
    delta = (int)(p / dy);
    mod = (int)(p % dy);
    if (mod < 0) {
      delta--;
      mod += dy;
    }
    x = worker.getX() + delta;
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line call gray_render_scanline 1");
    gray_render_scanline(worker, ey1, worker.getX(), fy1, x, first);
    ey1 += incr;
    gray_set_cell(worker, RasterUtil.TRUNC(x), ey1);
    if (ey1 != ey2) {
      p = RasterUtil.ONE_PIXEL() * dx;
      lift  = (p / dy);
      rem   = (p % dy);
      if (rem < 0) {
        lift--;
        rem += dy;
      }
      mod -= dy;
      while (ey1 != ey2) {
        delta = lift;
        mod += rem;
        if (mod >= 0) {
          mod -= dy;
          delta++;
        }
        x2 = x + delta;
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line call gray_render_scanline 2");
        gray_render_scanline(worker, ey1, x, RasterUtil.ONE_PIXEL() - first, x2, first);
        x = x2;
        ey1 += incr;
        gray_set_cell(worker, RasterUtil.TRUNC(x), ey1);
      }
    }
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line call gray_render_scanline 3");
    gray_render_scanline(worker, ey1, x, RasterUtil.ONE_PIXEL() - first, to_x, fy2);
    worker.setX(to_x);
    worker.setY(to_y);
    worker.setLast_ey(RasterUtil.SUBPIXELS(ey2));
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_line end");
  }

  /* =====================================================================
   *    gray_split_conic
   *
   * =====================================================================
................................................................................
    int[] levels;
    FTVectorRec[] arc;
    FTReference<FTVectorRec[]> arc_ref = new FTReference<FTVectorRec[]>();
    int arcIdx = 0;
    boolean doDraw = false;

Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_conic");
    levels = worker.getLev_stack();
    arc = worker.getBez_stack();
    arc[arcIdx + 0].x = RasterUtil.UPSCALE(to.x);
    arc[arcIdx + 0].y = RasterUtil.UPSCALE(to.y);
    arc[arcIdx + 1].x = RasterUtil.UPSCALE(control.x);
    arc[arcIdx + 1].y = RasterUtil.UPSCALE(control.y);
    arc[arcIdx + 2].x = worker.getX();
    arc[arcIdx + 2].y = worker.getY();
    top = 0;
    dx = FTCalc.FT_ABS(arc[arcIdx + 2].x + arc[arcIdx + 0].x - 2 * arc[arcIdx + 1].x);
    dy = FTCalc.FT_ABS(arc[arcIdx + 2].y + arc[arcIdx + 0].y - 2 * arc[arcIdx + 1].y);
    if (dx < dy) {
      dx = dy;
    }
    if (dx < RasterUtil.ONE_PIXEL() / 4) {
................................................................................
      y = arc[arcIdx + 2].y;
      if (y < min) {
        min = y;
      }
      if (y > max) {
        max = y;
      }
      if (RasterUtil.TRUNC(min) >= worker.getMax_ey() || RasterUtil.TRUNC(max) < worker.getMin_ey()) {
        doDraw = true;
      }
    }
    if (!doDraw) {
      level = 0;
      do {
        dx >>= 2;
................................................................................
    int arcIdx = 0;
    int min;
    int max;
    int y;
    boolean noSplit = false;

Debug(0, DebugTag.DBG_RENDER, TAG, "gray_render_cubic");
    arc = worker.getBez_stack();
    arc[arcIdx + 0].x = RasterUtil.UPSCALE(to.x);
    arc[arcIdx + 0].y = RasterUtil.UPSCALE(to.y);
    arc[arcIdx + 1].x = RasterUtil.UPSCALE(control2.x);
    arc[arcIdx + 1].y = RasterUtil.UPSCALE(control2.y);
    arc[arcIdx + 2].x = RasterUtil.UPSCALE(control1.x);
    arc[arcIdx + 2].y = RasterUtil.UPSCALE(control1.y);
    arc[arcIdx + 3].x = worker.getX();
    arc[arcIdx + 3].y = worker.getY();
      /* Short-cut the arc that crosses the current band. */
    min = max = arc[arcIdx + 0].y;
    y = arc[arcIdx + 1].y;
    if (y < min) {
      min = y;
    }
    if (y > max) {
................................................................................
    y = arc[arcIdx + 3].y;
    if (y < min) {
      min = y;
    }
    if (y > max) {
      max = y;
    }
    if (RasterUtil.TRUNC(min) >= worker.getMax_ey() || RasterUtil.TRUNC(max) < worker.getMin_ey()) {
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_render_cubic call gray_render_line"));
      gray_render_line(worker, arc[arcIdx + 0].x, arc[arcIdx + 0].y);
      if (arc == worker.getBez_stack()) {
        return;
      }
      arcIdx -= 3;
    }
    for (;;) {
        /* Decide whether to split or draw. See `Rapid Termination          */
        /* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */
................................................................................
        gray_split_cubic(arc_ref, arcIdx);
        arc = arc_ref.Get();
        arcIdx += 3;
        continue;
      }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_render_cubic 2 call gray_render_line"));
      gray_render_line(worker, arc[arcIdx + 0].x, arc[arcIdx + 0].y);
      if (arc == worker.getBez_stack()) {
        return;
      }
      arcIdx -= 3;
      worker.setBez_stack(arc);
    }
  }

  /* =====================================================================
   *    gray_compute_cbox
   *
   * =====================================================================
   */
  public void gray_compute_cbox(grayTWorkerRec worker) {
    FTOutlineRec outline = worker.getOutline();
    FTVectorRec vec;
    int vecIdx = 0;
    int limit = outline.getN_points();

Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_compute_cbox"));
    if (outline.getN_points() <= 0) {
      worker.setMin_ex(0);
      worker.setMax_ex(0);
      worker.setMin_ey(0);
      worker.setMax_ey(0);
      return;
    }
    worker.setMin_ex(outline.getPoints()[vecIdx].x);
    worker.setMax_ex(outline.getPoints()[vecIdx].x);
    worker.setMin_ey(outline.getPoints()[vecIdx].y);
    worker.setMax_ey(outline.getPoints()[vecIdx].y);
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cbox01: %d %d %d %d", worker.getMin_ex(), worker.getMin_ey(), worker.getMax_ex(), worker.getMax_ey()));
    vecIdx++;
    for ( ; vecIdx < limit; vecIdx++) {
      vec = outline.getPoints()[vecIdx];
      int x = vec.x;
      int y = vec.y;

      if (x < worker.getMin_ex()) {
        worker.setMin_ex(x);
      }
      if (x > worker.getMax_ex()) {
        worker.setMax_ex(x);
      }
      if (y < worker.getMin_ey()) {
        worker.setMin_ey(y);
      }
      if (y > worker.getMax_ey()) {
        worker.setMax_ey(y);
      }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cbox11: %d %d", x, y));
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cbox12: %d %d %d %d", worker.getMin_ex(), worker.getMin_ey(), worker.getMax_ex(), worker.getMax_ey()));
    }
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("cbox2: %d %d %d %d", worker.getMin_ex(), worker.getMin_ey(), worker.getMax_ex(), worker.getMax_ey()));
      /* truncate the bounding box to integer pixels */
    worker.setMin_ex(worker.getMin_ex() >> 6);
    worker.setMin_ey(worker.getMin_ey() >> 6);
    worker.setMax_ex((worker.getMax_ex() + 63) >> 6);
    worker.setMax_ey((worker.getMax_ey() + 63) >> 6);
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_comput_cbox end: %d %d %d %d", worker.getMin_ex(), worker.getMin_ey(), worker.getMax_ex(), worker.getMax_ey()));
    worker.setOutline(outline);
  }


  /* ==================== moveTo ===================================== */
  @Override
  public FTError.ErrorTag moveTo(FTVectorRec point, Object user) {
    return gray_move_to(point, (grayTWorkerRec)user);

Changes to aftraster/FTRasterParamsRec.java.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    FTRasterParams                                                          */
  /*                                                                       */
  /* <Description>                                                         */
  /*    A structure to hold the arguments used by a raster's render        */
  /*    function.                                                          */
  /*                                                                       */
  /* <Fields>                                                              */
  /*    target      :: The target bitmap.                                  */
................................................................................
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;

public class FTRasterParamsRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "FTRasterParams";

  public final static int FT_RASTER_FLAG_DEFAULT = 0x0;
  public final static int FT_RASTER_FLAG_AA      =  0x1;
  public final static int FT_RASTER_FLAG_DIRECT  =  0x2;
  public final static int FT_RASTER_FLAG_CLIP    =  0x4;

  private FTBitmapRec target = null;
  private Object source = null;
  private int flags;
  private Object user_data = null;
  private FTBBoxRec clip_box = null;

  /* ==================== FTRasterParams ================================== */
  public FTRasterParamsRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {







|







 







|












|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    FTRasterParamsRec                                                  */
  /*                                                                       */
  /* <Description>                                                         */
  /*    A structure to hold the arguments used by a raster's render        */
  /*    function.                                                          */
  /*                                                                       */
  /* <Fields>                                                              */
  /*    target      :: The target bitmap.                                  */
................................................................................
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;

public class FTRasterParamsRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "FTRasterParamsRec";

  public final static int FT_RASTER_FLAG_DEFAULT = 0x0;
  public final static int FT_RASTER_FLAG_AA      =  0x1;
  public final static int FT_RASTER_FLAG_DIRECT  =  0x2;
  public final static int FT_RASTER_FLAG_CLIP    =  0x4;

  private FTBitmapRec target = null;
  private Object source = null;
  private int flags;
  private Object user_data = null;
  private FTBBoxRec clip_box = null;

  /* ==================== FTRasterParamsRec ================================== */
  public FTRasterParamsRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {

Changes to aftraster/FTSmoothRendererClass.java.

324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
...
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
...
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415

416
417
418
419
420

421
422
423
424
425
426
427
428
...
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
...
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
...
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
...
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
...
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
...
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
...
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
...
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_raster_reset");
    if (raster != null) {
      if (pool_base != null) {
        grayTWorkerRec worker =  new grayTWorkerRec();
        raster.buffer = pool_base;
        raster.buffer_size = pool_size;
//          raster.band_size = (int)raster.buffer_size / sizeof(TCell) * 8;
        raster.band_size = (int)raster.buffer_size / 20;  // FIXME!!!
        raster.worker = worker;
      } else {
        raster.buffer = null;
        raster.buffer_size = 0;
        raster.worker = null;
      }
    }
    return error;
  }

  /* =====================================================================
   *    gray_raster_render
................................................................................
    }
    if (outline.getContours() == null || outline.getPoints()== null) {
      return FTError.ErrorTag.RENDER_INVALID_OUTLINE;
    }
    if (outline.getN_points() != outline.getContours()[outline.getN_contours() - 1] + 1) {
      return FTError.ErrorTag.RENDER_INVALID_OUTLINE;
    }
    worker = raster.worker;
      /* if direct mode is not set, we must have a target bitmap */
    if ((params.getFlags() & FTRasterParamsRec.FT_RASTER_FLAG_DIRECT) == 0) {
      if (target_map == null) {
        return FTError.ErrorTag.RENDER_INVALID_ARGUMENT;
      }
        /* nothing to do */
      if (target_map.getWidth() == 0|| target_map.getRows() == 0) {
................................................................................
      /* this version does not support monochrome rendering */
    if ((params.getFlags() & FTRasterParamsRec.FT_RASTER_FLAG_AA) == 0) {
      return FTError.ErrorTag.RENDER_INVALID_MODE;
    }
      /* compute clipping box */
    if ((params.getFlags() & FTRasterParamsRec.FT_RASTER_FLAG_DIRECT) == 0) {
        /* compute clip box from target pixmap */
      worker.clip_box.setxMin(0);
      worker.clip_box.setyMin(0);
      worker.clip_box.setxMax(target_map.getWidth());
      worker.clip_box.setyMax(target_map.getRows());
    } else {
      if ((params.getFlags() & FTRasterParamsRec.FT_RASTER_FLAG_CLIP) != 0) {
        worker.clip_box = params.getClip_box();
      } else {
        worker.clip_box.setxMin(-32768);
        worker.clip_box.setyMin(-32768);
        worker.clip_box.setxMax(32767);
        worker.clip_box.setyMax(32767);
      }
    }
    gray_init_cells(worker, raster.buffer, raster.buffer_size);
    worker.outline = outline;
    worker.num_cells = 0;
    worker.invalid = true;
    worker.band_size = raster.band_size;
    worker.num_gray_spans = 0;
    if ((params.getFlags() & FTRasterParamsRec.FT_RASTER_FLAG_DIRECT) != 0) {
/* NEEDED !!!
      worker.render_span = params.gray_spans;
  NEEDED !!! */
      worker.render_span_data = params.getUser_data();

    } else {
      worker.target = target_map;
/* NEEDED !!!
      worker.render_span = FTGrayRasterClassFuncs.gray_render_span;
      NEEDED !!! */

      worker.render_span_data = worker;
    }
    return gray_convert_glyph(worker);
  }

  /* =====================================================================
   *    gray_raster_done
   *
................................................................................
   *
   * =====================================================================
   */
  private void gray_render_span(int y, int count, FTSpanRec[] spans, grayTWorkerRec worker) {
    int spansIdx = 0;
    int pIdx;
    int qIdx;
    FTBitmapRec map = worker.target;
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_render_span y: %d, count: %d", y, count));

    /* first of all, compute the scanline offset */
    pIdx = 0 - y * map.getPitch();
    if (map.getPitch() >= 0) {
      pIdx += ((map.getRows() - 1) * map.getPitch());
    }
................................................................................
   *    gray_init_cells
   *
   * =====================================================================
   */
  private void gray_init_cells(grayTWorkerRec worker, byte[] buffer, int byte_size) {
    Debug(0, DebugTag.DBG_RENDER, TAG, "+++ gray_init_cells");

    worker.buffer = buffer;
    worker.buffer_size = byte_size;
    worker.ycells = new TCellRec[(int)byte_size / 10];
    worker.cells = null;
    worker.max_cells = 0;
    worker.num_cells = 0;
    worker.area = 0;
    worker.cover = 0;
    worker.invalid = true;
  }

  /* =====================================================================
   *    gray_convert_glyph_inner
   *
   * =====================================================================
   */
................................................................................
  private FTError.ErrorTag gray_convert_glyph_inner(grayTWorkerRec worker) {
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_convert_glyph_inner");
    func_interface = new FTGrayOutlineFuncsClass();
    FTReference<FTOutlineRec> outline_ref = new FTReference<FTOutlineRec>();
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

//      if (ft_setjmp(ras.jump_buffer) == 0) {
    error = worker.outline.FTOutlineDecompose((FTOutlineFuncs)func_interface, worker);
    func_interface.gray_record_cell(worker);
//      } else {
//        error = FT_THROW( Memory_Overflow );
//      }
    return error;
  }

................................................................................
      /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */
      /*                                                           */
    coverage = (area >> (FTGrayOutlineFuncsClass.PIXEL_BITS * 2 + 1 - 8));
                                                      /* use range 0..256 */
    if (coverage < 0) {
      coverage = -coverage;
    }
    if ((worker.outline.getFlags() & Flags.Outline.EVEN_ODD_FILL.getVal()) != 0) {
      coverage &= 511;
      if (coverage > 256) {
        coverage = 512 - coverage;
      } else {
        if (coverage == 256) {
          coverage = 255;
        }
................................................................................
      }
    } else {
        /* normal non-zero winding rule */
      if (coverage >= 256) {
        coverage = 255;
      }
    }
    y += worker.min_ey;
    x += worker.min_ex;
      /* FT_Span.x is a 16-bit short, so limit our coordinates appropriately */
    if (x >= 32767) {
      x = 32767;
    }
      /* FT_Span.y is an integer, so limit our coordinates appropriately */
    if (y >= 0xFFFF) {
      y = 0xFFFF;
................................................................................
    }
    Debug(0, DebugTag.DBG_RENDER, TAG, String.format("x: %d, y: %d, coverage: %x", x, y, coverage));
    if (coverage != 0) {
      int count;
      FTSpanRec span = null;

        /* see whether we can add this span to the current list */
      count = worker.num_gray_spans;
      spanIdx = count - 1;
      if (count > 0) {
        span = worker.gray_spans[count - 1];
      } else {
      }
      if (count > 0 && worker.span_y == y && (int)span.getX() + span.getLen() == (int)x &&
          (span.getCoverage() & 0xFF) == coverage) {
        span.setLen(span.getLen() + acount);
        worker.gray_spans[count - 1] = span;
        return;
      }
      if (worker.span_y != y || count >= FTSpanRec.FT_MAX_GRAY_SPANS) {
        if (count > 0) {
          worker.renderSpan(worker.span_y, count, worker.gray_spans,
              (grayTWorkerRec)worker.render_span_data);
        }
        if (count > 0) {
          int  n;
          StringBuffer str = new StringBuffer();

          str.append(String.format("y = %3d ", worker.span_y));
          for (n = 0; n < count; n++) {
            str.append(String.format("  [%d..%d]:0x%02x ",
                worker.gray_spans[n].getX(), worker.gray_spans[n].getX() + worker.gray_spans[n].getLen() - 1, worker.gray_spans[n].getCoverage()));
          }
          FTTrace.Trace(7, TAG, str.toString());
        }
        worker.num_gray_spans = 0;
        worker.span_y = (int)y;
        count = 0;
        spanIdx = 0;
      } else {
        spanIdx++;
      }
        /* add a gray span to the current list */
      worker.gray_spans[spanIdx].setX(x);
      worker.gray_spans[spanIdx].setLen(acount);
      worker.gray_spans[spanIdx].setCoverage((byte)coverage);
      worker.num_gray_spans++;
    }
    Debug(0, DebugTag.DBG_RENDER, TAG, "gray_hline END 2");
  }

  /* =====================================================================
   *    gray_sweep
   *
   * =====================================================================
   */
  public void gray_sweep(grayTWorkerRec worker, FTBitmapRec target) {
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_sweep");
    int  yindex;

    if (worker.num_cells == 0) {
      return;
    }
    worker.num_gray_spans = 0;
    FTTrace.Trace(7, TAG, "gray_sweep: start "+worker.ycount);
    for (yindex = 0; yindex < worker.ycount; yindex++) {
      TCellRec cell  = worker.ycells[yindex];
      int cover = 0;
      int x = 0;

      for ( ; cell != null; cell = cell.next) {
        int area;

//System.out.println(String.format("cell->next: %d", cell.next == null ? -1 : cell.next.self_idx));
................................................................................
        area = cover * (RasterUtil.ONE_PIXEL() * 2) - cell.area;
        if (area != 0 && cell.x >= 0) {
          gray_hline(worker, cell.x, yindex, area, 1 );
        }
        x = cell.x + 1;
      }
      if (cover != 0) {
        gray_hline(worker, x, yindex, cover * (RasterUtil.ONE_PIXEL() * 2), worker.count_ex - x);
      }
    }
    if (worker.num_gray_spans > 0) {
      worker.renderSpan(worker.span_y, worker.num_gray_spans,
          worker.gray_spans, (grayTWorkerRec)worker.render_span_data);
    }
    if (worker.num_gray_spans > 0) {
      FTSpanRec span;
      int spanIdx = 0;
      int n;
      StringBuffer str = new StringBuffer("");

      str.append(String.format("y = %3d ", worker.span_y));
      for (n = 0; n < worker.num_gray_spans; n++, spanIdx++) {
        span = worker.gray_spans[spanIdx];
        str.append(String.format("  [%d..%d]:0x%02x ",
            span.getX(), span.getX() + span.getLen() - 1, span.getCoverage() & 0xFF));
      }
      FTTrace.Trace(7, TAG, str.toString());
    }
    FTTrace.Trace(7, TAG, "gray_sweep: end");
  }
................................................................................
    for (i = 0; i < 40; i++) {
      bands[i] = new grayTBandRec();
    }

      /* Set up state in the raster object */
    func_interface.gray_compute_cbox(worker);
      /* clip to target bitmap, exit if nothing to do */
    clip = worker.clip_box;
    if (worker.max_ex <= clip.getxMin() || worker.min_ex >= clip.getxMax() ||
        worker.max_ey <= clip.getyMin() || worker.min_ey >= clip.getyMax()) {
      return error;
    }
    if (worker.min_ex < clip.getxMin()) {
      worker.min_ex = clip.getxMin();
    }
    if (worker.min_ey < clip.getyMin()) {
      worker.min_ey = clip.getyMin();
    }
    if (worker.max_ex > clip.getxMax()) {
      worker.max_ex = clip.getxMax();
    }
    if (worker.max_ey > clip.getyMax()) {
      worker.max_ey = clip.getyMax();
    }
    worker.count_ex = worker.max_ex - worker.min_ex;
    worker.count_ey = worker.max_ey - worker.min_ey;
      /* set up vertical bands */
    num_bands = (int)((worker.max_ey - worker.min_ey) / worker.band_size);
    if (num_bands == 0) {
      num_bands = 1;
    }
    if (num_bands >= 39) {
      num_bands = 39;
    }
    worker.band_shoot = 0;
    min = worker.min_ey;
    max_y = worker.max_ey;
    for (n = 0; n < num_bands; n++, min = max) {
      max = min + worker.band_size;
      if (n == num_bands - 1 || max > max_y) {
        max = max_y;
      }
      bands[0].min = (short)min;
      bands[0].max = (short)max;
      bandIdx = 0;
      while (bandIdx >= 0) {
        int bottom;
        int top;
        int middle;
        {
          int cells_max;
          int yindex;
          int cell_start;
          int cell_end;
          int cellsIdx = 0;

//            worker.ycells = (TCell[])worker.buffer;
          worker.ycount = bands[bandIdx].max - bands[bandIdx].min;
          worker.ycells = new TCellRec[(int)worker.ycount];
          cell_start = 0;
          cell_end = 1024;
//            cell_start = TCellSize * worker.ycount;
//            cell_mod = cell_start % TCellSize;
//            if (cell_mod > 0) {
//              cell_start += TCellSize - cell_mod;
//            }
//            cell_end = worker.buffer_size;
//            cell_end -= cell_end % TCellSize;
          cells_max = cell_end;
          cellsIdx = cell_start;
          cellsIdx = 0;
          worker.cells = new TCellRec[(int)cells_max];
          for (int j = 0; j < cells_max; j++) {
            worker.cells[j] = new TCellRec();
          }
          if (cellsIdx >= cells_max) {
            reduceBands = true;
          }
          if (!reduceBands) {
            worker.max_cells = (int)(cells_max - cellsIdx);
            if (worker.max_cells < 2) {
              reduceBands = true;
            }
          }
          if (!reduceBands) {
            for (yindex = 0; yindex < worker.ycount; yindex++) {
              worker.ycells[yindex] = null;
            }
          }
        }
        if (!reduceBands) {
          worker.num_cells = 0;
          worker.invalid = true;
          worker.min_ey = bands[bandIdx].min;
          worker.max_ey = bands[bandIdx].max;
          worker.count_ey = bands[bandIdx].max - bands[bandIdx].min;
          error = gray_convert_glyph_inner(worker);
          if (error == FTError.ErrorTag.ERR_OK) {
            gray_sweep(worker, worker.target);
            bandIdx--;
            continue;
          } else {
            if (error != FTError.ErrorTag.RASTER_MEMORY_OVERFLOW) {
              return error;
            }
          }
        }
        reduceBands = false;
          /* render pool overflow; we will reduce the render band by half */
        bottom = bands[bandIdx].min;
        top = bands[bandIdx].max;
        middle = bottom + ((top - bottom) >> 1);
          /* This is too complex for a single scanline; there must */
          /* be some problems.                                     */
        if (middle == bottom) {
          FTTrace.Trace(7, TAG, "gray_convert_glyph: rotten glyph");
          return FTError.ErrorTag.GLYPH_ROTTEN_GLYPH;
        }
        if (bottom-top >= worker.band_size) {
          worker.band_shoot++;
        }
        bands[bandIdx + 1].min = (short)bottom;
        bands[bandIdx + 1].max = (short)middle;
        bands[bandIdx + 0].min = (short)middle;
        bands[bandIdx + 0].max = (short)top;
        bandIdx++;
      }
    }
    if (worker.band_shoot > 8 && worker.band_size > 16) {
      worker.band_size = worker.band_size / 2;
    }
    return error;
  }

  /* ==================== moduleInit ===================================== */
  @Override
  public FTError.ErrorTag moduleInit(FTModuleRec module) {







|
|



|







 







|







 







|
|
|
|


|

|
|
|
|



|
|
|
|
|

<
|
<
<
>

<
<
<
<
>
|







 







|







 







|
|
|
|
|
|
|
|
|







 







|







 







|







 







|
|







 







|


|


|


|


|

|
|





|


|



|
|






|
|
|
|













|


|
|
|
|







 







|


|
|
|

|





|
|
|







 







|
|
|


|
|

|
|

|
|

|
|

|
|

|






|
|
|

|



|
|













|
|












|

|





|
|




|
|




|
|
|
|
|


|










|
|







|
|

|
|
|
|



|
|







324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
...
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
...
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411

412


413
414




415
416
417
418
419
420
421
422
423
...
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
...
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
...
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
...
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
...
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
...
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
...
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
...
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_raster_reset");
    if (raster != null) {
      if (pool_base != null) {
        grayTWorkerRec worker =  new grayTWorkerRec();
        raster.buffer = pool_base;
        raster.buffer_size = pool_size;
//          raster.band_size = (int)raster.buffer_size / sizeof(TCell) * 8;
        raster.setBand_size(raster.buffer_size / 20);  // FIXME!!!
        raster.setWorker(worker);
      } else {
        raster.buffer = null;
        raster.buffer_size = 0;
        raster.setWorker(null);
      }
    }
    return error;
  }

  /* =====================================================================
   *    gray_raster_render
................................................................................
    }
    if (outline.getContours() == null || outline.getPoints()== null) {
      return FTError.ErrorTag.RENDER_INVALID_OUTLINE;
    }
    if (outline.getN_points() != outline.getContours()[outline.getN_contours() - 1] + 1) {
      return FTError.ErrorTag.RENDER_INVALID_OUTLINE;
    }
    worker = raster.getWorker();
      /* if direct mode is not set, we must have a target bitmap */
    if ((params.getFlags() & FTRasterParamsRec.FT_RASTER_FLAG_DIRECT) == 0) {
      if (target_map == null) {
        return FTError.ErrorTag.RENDER_INVALID_ARGUMENT;
      }
        /* nothing to do */
      if (target_map.getWidth() == 0|| target_map.getRows() == 0) {
................................................................................
      /* this version does not support monochrome rendering */
    if ((params.getFlags() & FTRasterParamsRec.FT_RASTER_FLAG_AA) == 0) {
      return FTError.ErrorTag.RENDER_INVALID_MODE;
    }
      /* compute clipping box */
    if ((params.getFlags() & FTRasterParamsRec.FT_RASTER_FLAG_DIRECT) == 0) {
        /* compute clip box from target pixmap */
      worker.getClip_box().setxMin(0);
      worker.getClip_box().setyMin(0);
      worker.getClip_box().setxMax(target_map.getWidth());
      worker.getClip_box().setyMax(target_map.getRows());
    } else {
      if ((params.getFlags() & FTRasterParamsRec.FT_RASTER_FLAG_CLIP) != 0) {
        worker.setClip_box(params.getClip_box());
      } else {
        worker.getClip_box().setxMin(-32768);
        worker.getClip_box().setyMin(-32768);
        worker.getClip_box().setxMax(32767);
        worker.getClip_box().setyMax(32767);
      }
    }
    gray_init_cells(worker, raster.buffer, raster.buffer_size);
    worker.setOutline(outline);
    worker.setNum_cells(0);
    worker.setInvalid(true);
    worker.setBand_size(raster.getBand_size());
    worker.setNum_gray_spans(0);
    if ((params.getFlags() & FTRasterParamsRec.FT_RASTER_FLAG_DIRECT) != 0) {

//FIXME!!      worker.render_span(params.gray_spans);


      worker.setRender_span_data(params.getUser_data());
    } else {




      worker.setTarget(target_map);
      worker.setRender_span_data(worker);
    }
    return gray_convert_glyph(worker);
  }

  /* =====================================================================
   *    gray_raster_done
   *
................................................................................
   *
   * =====================================================================
   */
  private void gray_render_span(int y, int count, FTSpanRec[] spans, grayTWorkerRec worker) {
    int spansIdx = 0;
    int pIdx;
    int qIdx;
    FTBitmapRec map = worker.getTarget();
Debug(0, DebugTag.DBG_RENDER, TAG, String.format("gray_render_span y: %d, count: %d", y, count));

    /* first of all, compute the scanline offset */
    pIdx = 0 - y * map.getPitch();
    if (map.getPitch() >= 0) {
      pIdx += ((map.getRows() - 1) * map.getPitch());
    }
................................................................................
   *    gray_init_cells
   *
   * =====================================================================
   */
  private void gray_init_cells(grayTWorkerRec worker, byte[] buffer, int byte_size) {
    Debug(0, DebugTag.DBG_RENDER, TAG, "+++ gray_init_cells");

    worker.setBuffer(buffer);
    worker.setBuffer_size(byte_size);
    worker.setYcells(new TCellRec[byte_size / 10]);
    worker.setCells(null);
    worker.setMax_cells(0);
    worker.setNum_cells(0);
    worker.setArea(0);
    worker.setCover(0);
    worker.setInvalid(true);
  }

  /* =====================================================================
   *    gray_convert_glyph_inner
   *
   * =====================================================================
   */
................................................................................
  private FTError.ErrorTag gray_convert_glyph_inner(grayTWorkerRec worker) {
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_convert_glyph_inner");
    func_interface = new FTGrayOutlineFuncsClass();
    FTReference<FTOutlineRec> outline_ref = new FTReference<FTOutlineRec>();
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;

//      if (ft_setjmp(ras.jump_buffer) == 0) {
    error = worker.getOutline().FTOutlineDecompose((FTOutlineFuncs)func_interface, worker);
    func_interface.gray_record_cell(worker);
//      } else {
//        error = FT_THROW( Memory_Overflow );
//      }
    return error;
  }

................................................................................
      /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */
      /*                                                           */
    coverage = (area >> (FTGrayOutlineFuncsClass.PIXEL_BITS * 2 + 1 - 8));
                                                      /* use range 0..256 */
    if (coverage < 0) {
      coverage = -coverage;
    }
    if ((worker.getOutline().getFlags() & Flags.Outline.EVEN_ODD_FILL.getVal()) != 0) {
      coverage &= 511;
      if (coverage > 256) {
        coverage = 512 - coverage;
      } else {
        if (coverage == 256) {
          coverage = 255;
        }
................................................................................
      }
    } else {
        /* normal non-zero winding rule */
      if (coverage >= 256) {
        coverage = 255;
      }
    }
    y += worker.getMin_ey();
    x += worker.getMin_ex();
      /* FT_Span.x is a 16-bit short, so limit our coordinates appropriately */
    if (x >= 32767) {
      x = 32767;
    }
      /* FT_Span.y is an integer, so limit our coordinates appropriately */
    if (y >= 0xFFFF) {
      y = 0xFFFF;
................................................................................
    }
    Debug(0, DebugTag.DBG_RENDER, TAG, String.format("x: %d, y: %d, coverage: %x", x, y, coverage));
    if (coverage != 0) {
      int count;
      FTSpanRec span = null;

        /* see whether we can add this span to the current list */
      count = worker.getNum_gray_spans();
      spanIdx = count - 1;
      if (count > 0) {
        span = worker.getGray_span(count - 1);
      } else {
      }
      if (count > 0 && worker.getSpan_y() == y && span.getX() + span.getLen() == (int)x &&
          (span.getCoverage() & 0xFF) == coverage) {
        span.setLen(span.getLen() + acount);
        worker.setGray_span(count - 1, span);
        return;
      }
      if (worker.getSpan_y() != y || count >= FTSpanRec.FT_MAX_GRAY_SPANS) {
        if (count > 0) {
          worker.renderSpan(worker.getSpan_y(), count, worker.getGray_spans(),
              (grayTWorkerRec)worker.getRender_span_data());
        }
        if (count > 0) {
          int  n;
          StringBuffer str = new StringBuffer();

          str.append(String.format("y = %3d ", worker.getSpan_y()));
          for (n = 0; n < count; n++) {
            str.append(String.format("  [%d..%d]:0x%02x ",
                worker.getGray_span(n).getX(), worker.getGray_span(n).getX() + worker.getGray_span(n).getLen() - 1, worker.getGray_span(n).getCoverage()));
          }
          FTTrace.Trace(7, TAG, str.toString());
        }
        worker.setNum_gray_spans(0);
        worker.setSpan_y(y);
        count = 0;
        spanIdx = 0;
      } else {
        spanIdx++;
      }
        /* add a gray span to the current list */
      worker.getGray_span(spanIdx).setX(x);
      worker.getGray_span(spanIdx).setLen(acount);
      worker.getGray_span(spanIdx).setCoverage((byte)coverage);
      worker.setNum_gray_spans(worker.getNum_gray_spans() + 1);
    }
    Debug(0, DebugTag.DBG_RENDER, TAG, "gray_hline END 2");
  }

  /* =====================================================================
   *    gray_sweep
   *
   * =====================================================================
   */
  public void gray_sweep(grayTWorkerRec worker, FTBitmapRec target) {
Debug(0, DebugTag.DBG_RENDER, TAG, "gray_sweep");
    int  yindex;

    if (worker.getNum_cells() == 0) {
      return;
    }
    worker.setNum_gray_spans(0);
    FTTrace.Trace(7, TAG, "gray_sweep: start "+worker.getYcount());
    for (yindex = 0; yindex < worker.getYcount(); yindex++) {
      TCellRec cell = worker.getYcell(yindex);
      int cover = 0;
      int x = 0;

      for ( ; cell != null; cell = cell.next) {
        int area;

//System.out.println(String.format("cell->next: %d", cell.next == null ? -1 : cell.next.self_idx));
................................................................................
        area = cover * (RasterUtil.ONE_PIXEL() * 2) - cell.area;
        if (area != 0 && cell.x >= 0) {
          gray_hline(worker, cell.x, yindex, area, 1 );
        }
        x = cell.x + 1;
      }
      if (cover != 0) {
        gray_hline(worker, x, yindex, cover * (RasterUtil.ONE_PIXEL() * 2), worker.getCount_ex() - x);
      }
    }
    if (worker.getNum_gray_spans() > 0) {
      worker.renderSpan(worker.getSpan_y(), worker.getNum_gray_spans(),
          worker.getGray_spans(), (grayTWorkerRec)worker.getRender_span_data());
    }
    if (worker.getNum_gray_spans() > 0) {
      FTSpanRec span;
      int spanIdx = 0;
      int n;
      StringBuffer str = new StringBuffer("");

      str.append(String.format("y = %3d ", worker.getSpan_y()));
      for (n = 0; n < worker.getNum_gray_spans(); n++, spanIdx++) {
        span = worker.getGray_span(spanIdx);
        str.append(String.format("  [%d..%d]:0x%02x ",
            span.getX(), span.getX() + span.getLen() - 1, span.getCoverage() & 0xFF));
      }
      FTTrace.Trace(7, TAG, str.toString());
    }
    FTTrace.Trace(7, TAG, "gray_sweep: end");
  }
................................................................................
    for (i = 0; i < 40; i++) {
      bands[i] = new grayTBandRec();
    }

      /* Set up state in the raster object */
    func_interface.gray_compute_cbox(worker);
      /* clip to target bitmap, exit if nothing to do */
    clip = worker.getClip_box();
    if (worker.getMax_ex() <= clip.getxMin() || worker.getMin_ex() >= clip.getxMax() ||
        worker.getMax_ey() <= clip.getyMin() || worker.getMin_ey() >= clip.getyMax()) {
      return error;
    }
    if (worker.getMin_ex() < clip.getxMin()) {
      worker.setMin_ex(clip.getxMin());
    }
    if (worker.getMin_ey() < clip.getyMin()) {
      worker.setMin_ey(clip.getyMin());
    }
    if (worker.getMax_ex() > clip.getxMax()) {
      worker.setMax_ex(clip.getxMax());
    }
    if (worker.getMax_ey() > clip.getyMax()) {
      worker.setMax_ey(clip.getyMax());
    }
    worker.setCount_ex(worker.getMax_ex() - worker.getMin_ex());
    worker.setCount_ey(worker.getMax_ey() - worker.getMin_ey());
      /* set up vertical bands */
    num_bands = (worker.getMax_ey() - worker.getMin_ey() / worker.getBand_size());
    if (num_bands == 0) {
      num_bands = 1;
    }
    if (num_bands >= 39) {
      num_bands = 39;
    }
    worker.setBand_shoot(0);
    min = worker.getMin_ey();
    max_y = worker.getMax_ey();
    for (n = 0; n < num_bands; n++, min = max) {
      max = min + worker.getBand_size();
      if (n == num_bands - 1 || max > max_y) {
        max = max_y;
      }
      bands[0].setMin(min);
      bands[0].setMax(max);
      bandIdx = 0;
      while (bandIdx >= 0) {
        int bottom;
        int top;
        int middle;
        {
          int cells_max;
          int yindex;
          int cell_start;
          int cell_end;
          int cellsIdx = 0;

//            worker.ycells = (TCell[])worker.buffer;
          worker.setYcount(bands[bandIdx].getMax() - bands[bandIdx].getMin());
          worker.setYcells(new TCellRec[worker.getYcount()]);
          cell_start = 0;
          cell_end = 1024;
//            cell_start = TCellSize * worker.ycount;
//            cell_mod = cell_start % TCellSize;
//            if (cell_mod > 0) {
//              cell_start += TCellSize - cell_mod;
//            }
//            cell_end = worker.buffer_size;
//            cell_end -= cell_end % TCellSize;
          cells_max = cell_end;
          cellsIdx = cell_start;
          cellsIdx = 0;
          worker.setCells(new TCellRec[cells_max]);
          for (int j = 0; j < cells_max; j++) {
            worker.setCell(j, new TCellRec());
          }
          if (cellsIdx >= cells_max) {
            reduceBands = true;
          }
          if (!reduceBands) {
            worker.setMax_cells(cells_max - cellsIdx);
            if (worker.getMax_cells() < 2) {
              reduceBands = true;
            }
          }
          if (!reduceBands) {
            for (yindex = 0; yindex < worker.getYcount(); yindex++) {
              worker.setYcell(yindex, null);
            }
          }
        }
        if (!reduceBands) {
          worker.setNum_cells(0);
          worker.setInvalid(true);
          worker.setMin_ey(bands[bandIdx].getMin());
          worker.setMax_ey(bands[bandIdx].getMax());
          worker.setCount_ey(bands[bandIdx].getMax() - bands[bandIdx].getMin());
          error = gray_convert_glyph_inner(worker);
          if (error == FTError.ErrorTag.ERR_OK) {
            gray_sweep(worker, worker.getTarget());
            bandIdx--;
            continue;
          } else {
            if (error != FTError.ErrorTag.RASTER_MEMORY_OVERFLOW) {
              return error;
            }
          }
        }
        reduceBands = false;
          /* render pool overflow; we will reduce the render band by half */
        bottom = bands[bandIdx].getMin();
        top = bands[bandIdx].getMax();
        middle = bottom + ((top - bottom) >> 1);
          /* This is too complex for a single scanline; there must */
          /* be some problems.                                     */
        if (middle == bottom) {
          FTTrace.Trace(7, TAG, "gray_convert_glyph: rotten glyph");
          return FTError.ErrorTag.GLYPH_ROTTEN_GLYPH;
        }
        if (bottom-top >= worker.getBand_size()) {
          worker.setBand_shoot(worker.getBand_shoot() + 1);
        }
        bands[bandIdx + 1].setMin(bottom);
        bands[bandIdx + 1].setMax(middle);
        bands[bandIdx + 0].setMin(middle);
        bands[bandIdx + 0].setMax(top);
        bandIdx++;
      }
    }
    if (worker.getBand_shoot() > 8 && worker.getBand_size() > 16) {
      worker.setBand_size(worker.getBand_size() / 2);
    }
    return error;
  }

  /* ==================== moduleInit ===================================== */
  @Override
  public FTError.ErrorTag moduleInit(FTModuleRec module) {

Changes to aftraster/FTSpanRec.java.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    FTSpan                                                             */
  /*                                                                       */
  /* <Description>                                                         */
  /*    A structure used to model a single span of gray (or black) pixels  */
  /*    when rendering a monochrome or anti-aliased bitmap.                */
  /*                                                                       */
  /* <Fields>                                                              */
  /*    x        :: The span's horizontal start position.                  */
................................................................................

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;

public class FTSpanRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "FTSpan";

  public static int FT_MAX_GRAY_SPANS = 32;

  private int x;
  private int len;
  private byte coverage;

  /* ==================== FTSpan ================================== */
  public FTSpanRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {







|







 







|







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    FTSpanRec                                                          */
  /*                                                                       */
  /* <Description>                                                         */
  /*    A structure used to model a single span of gray (or black) pixels  */
  /*    when rendering a monochrome or anti-aliased bitmap.                */
  /*                                                                       */
  /* <Fields>                                                              */
  /*    x        :: The span's horizontal start position.                  */
................................................................................

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;

public class FTSpanRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "FTSpanRec";

  public static int FT_MAX_GRAY_SPANS = 32;

  private int x;
  private int len;
  private byte coverage;

  /* ==================== FTSpanRec ================================== */
  public FTSpanRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {

Changes to aftraster/TPointRec.java.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45


46
47
48



49

















 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;

public class TPointRec extends FTDebug {
    private static int oid = 0;

    private int id;
    private static String TAG = "ftdemo.TPoint";

    public long x = 0L;
    public long y = 0L;

    /* ==================== ftdemo.TPoint ================================== */
    public TPointRec() {
      oid++;
      id = oid;
    }
    
    /* ==================== mySelf ================================== */
    public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
    /* ==================== toString ===================================== */
    public String toString() {
      return mySelf()+"!";
    }

    /* ==================== toDebugString ===================================== */
    public String toDebugString() {
      StringBuffer str = new StringBuffer(mySelf()+"\n");


      return str.toString();
    }
 



}
























|

|
|

|
|

|
|
|
|
|

|
|



|
|



|
|
|
>
>
|
|
|
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;

public class TPointRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "TPointRec";

  private int x = 0;
  private int y = 0;

  /* ==================== ftdemo.TPoint ================================== */
  public TPointRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
  /* ==================== toString ===================================== */
  public String toString() {
      return mySelf()+"!";
    }

  /* ==================== toDebugString ===================================== */
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    str.append("...x: "+x+'\n');
    str.append("...y: "+y+'\n');
    return str.toString();
  }

  /* ==================== getX ================================== */
  public int getX() {
    return x;
  }

  /* ==================== setX ================================== */
  public void setX(int x) {
    this.x = x;
  }

  /* ==================== getY ================================== */
  public int getY() {
    return y;
  }

  /* ==================== setYf ================================== */
  public void setY(int y) {
    this.y = y;
  }

}

Changes to aftraster/blackTBandRec.java.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    blackTBand                                                          */
  /*                                                                       */
  /* ===================================================================== */

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;

public class blackTBandRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "blackTBand";

  private int y_min = 0;   /* band's minimum */
  private int y_max = 0;   /* band's maximum */

  /* ==================== blackTBand ================================== */
  public blackTBandRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {







|









|




|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    blackTBandRec                                                      */
  /*                                                                       */
  /* ===================================================================== */

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;

public class blackTBandRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "blackTBandRec";

  private int y_min = 0;   /* band's minimum */
  private int y_max = 0;   /* band's maximum */

  /* ==================== blackTBandRec ================================== */
  public blackTBandRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {

Changes to aftraster/blackTRasterRec.java.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    blackTRaster                                                          */
  /*                                                                       */
  /* ===================================================================== */

public class blackTRasterRec extends FTRasterRec {
  private static int oid = 0;

  private int id;
  private static String TAG = "blackTRaster";

  private blackTWorkerRec worker = null;
  private byte[] grays = null;
  private int gray_width = 0;

  /* ==================== blackTRaster ================================== */
  public blackTRasterRec() {
    oid++;
    id = oid;

    grays = new byte[5];
  }
    
  /* ==================== blackTRaster ================================== */
  public blackTRasterRec(FTRasterRec raster_rec) {
    oid++;
    id = oid;

    this.buffer = raster_rec.buffer;
    this.buffer_size = raster_rec.buffer_size;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
  /* ==================== toString ===================================== */







|







|





|






<
<
<
<
<
<
<
<
<







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37









38
39
40
41
42
43
44
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    blackTRasterRec                                                    */
  /*                                                                       */
  /* ===================================================================== */

public class blackTRasterRec extends FTRasterRec {
  private static int oid = 0;

  private int id;
  private static String TAG = "blackTRasterRec";

  private blackTWorkerRec worker = null;
  private byte[] grays = null;
  private int gray_width = 0;

  /* ==================== blackTRasterRec ================================== */
  public blackTRasterRec() {
    oid++;
    id = oid;

    grays = new byte[5];
  }









    
  /* ==================== mySelf ================================== */
  public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
  /* ==================== toString ===================================== */

Changes to aftraster/blackTWorkerRec.java.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
..
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    blackTWorker Rec                                                   */
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTBitmapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTOutlineRec;
................................................................................
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;

public class blackTWorkerRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "blackTWorker";
  private final static int MaxBezier = 32;

  private int precision_bits = 0;     /* precision related variables         */
  private int precision = 0;
  private int precision_half = 0;
  private int precision_shift = 0;
  private int precision_step = 0;
................................................................................
                                     /* Render_Glyph.  Note that there is   */
                                     /* no horizontal pass during gray      */
                                     /* rendering.                          */
  private TPointRec[] arcs = new TPointRec[3 * MaxBezier + 1]; /* The Bezier stack  */
  private blackTBandRec[] band_stack = new blackTBandRec[16]; /* band stack used for sub-banding */
  private int band_top;               /* band stack top                      */

  /* ==================== blackTWorker ================================== */
  public blackTWorkerRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {







|







 







|







 







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
..
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    blackTWorkerRec                                                    */
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTBitmapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTOutlineRec;
................................................................................
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;

public class blackTWorkerRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "blackTWorkerRec";
  private final static int MaxBezier = 32;

  private int precision_bits = 0;     /* precision related variables         */
  private int precision = 0;
  private int precision_half = 0;
  private int precision_shift = 0;
  private int precision_step = 0;
................................................................................
                                     /* Render_Glyph.  Note that there is   */
                                     /* no horizontal pass during gray      */
                                     /* rendering.                          */
  private TPointRec[] arcs = new TPointRec[3 * MaxBezier + 1]; /* The Bezier stack  */
  private blackTBandRec[] band_stack = new blackTBandRec[16]; /* band stack used for sub-banding */
  private int band_top;               /* band stack top                      */

  /* ==================== blackTWorkerRec ================================== */
  public blackTWorkerRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {

Changes to aftraster/grayTBandRec.java.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


51
52
53



54

















 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    grayTBand                                                          */
  /*                                                                       */
  /* ===================================================================== */

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;

public class grayTBandRec extends FTDebug {
    private static int oid = 0;

    private int id;
    private static String TAG = "grayTBand";

    public short min = 0;   /* band's minimum */
    public short max = 0;   /* band's maximum */

    /* ==================== grayTBand ================================== */
    public grayTBandRec() {
      oid++;
      id = oid;
    }
    
    /* ==================== mySelf ================================== */
    public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
    /* ==================== toString ===================================== */
    public String toString() {
      return mySelf()+"!";
    }

    /* ==================== toDebugString ===================================== */
    public String toDebugString() {
      StringBuffer str = new StringBuffer(mySelf()+"\n");


      return str.toString();
    }
 



}
























|






|

|
|

|
|

|
|
|
|
|

|
|



|
|



|
|
|
>
>
|
|
|
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    grayTBandRec                                                       */
  /*                                                                       */
  /* ===================================================================== */

import org.apwtcl.apwfreetypelib.aftutil.FTDebug;

public class grayTBandRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "grayTBandRec";

  private int min = 0;   /* band's minimum */
  private int max = 0;   /* band's maximum */

  /* ==================== grayTBand ================================== */
  public grayTBandRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
  /* ==================== toString ===================================== */
  public String toString() {
      return mySelf()+"!";
    }

  /* ==================== toDebugString ===================================== */
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    str.append("...min: "+min+'\n');
    str.append("...max: "+max+'\n');
    return str.toString();
  }

  /* ==================== getMin ================================== */
  public int getMin() {
    return min;
  }

  /* ==================== setMin ================================== */
  public void setMin(int min) {
    this.min = min;
  }

  /* ==================== getMax ================================== */
  public int getMax() {
    return max;
  }

  /* ==================== setMax ================================== */
  public void setMax(int max) {
    this.max = max;
  }

}

Changes to aftraster/grayTRasterRec.java.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

57
58
59



60

















 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    grayTRaster                                                          */
  /*                                                                       */
  /* ===================================================================== */

public class grayTRasterRec extends FTRasterRec {
    private static int oid = 0;

    private int id;
    private static String TAG = "grayTRaster";

    public int band_size = 0;
    public grayTWorkerRec worker = null;

    /* ==================== grayTRaster ================================== */
    public grayTRasterRec() {
      oid++;
      id = oid;
    }
    
    /* ==================== grayTRaster ================================== */
    public grayTRasterRec(FTRasterRec raster_rec) {
      oid++;
      id = oid;
      this.buffer = raster_rec.buffer;
      this.buffer_size = raster_rec.buffer_size;
    }
    
    /* ==================== mySelf ================================== */
    public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
    /* ==================== toString ===================================== */
    public String toString() {
      return mySelf()+"!";
    }

    /* ==================== toDebugString ===================================== */
    public String toDebugString() {
      StringBuffer str = new StringBuffer(mySelf()+"\n");

      return str.toString();
    }
 



}
























|




|

|
|

|
|

|
|
|
|
|

|
|
|
|
|
|
|

|
|



|
|



|
|
|
>
|
|
|
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    grayTRasterRec                                                     */
  /*                                                                       */
  /* ===================================================================== */

public class grayTRasterRec extends FTRasterRec {
  private static int oid = 0;

  private int id;
  private static String TAG = "grayTRasterRec";

  private int band_size = 0;
  private grayTWorkerRec worker = null;

  /* ==================== grayTRasterRec ================================== */
  public grayTRasterRec() {
    oid++;
    id = oid;
  }
    
  /* ==================== grayTRaster ================================== */
  public grayTRasterRec(FTRasterRec raster_rec) {
    oid++;
    id = oid;
    this.buffer = raster_rec.buffer;
    this.buffer_size = raster_rec.buffer_size;
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
  /* ==================== toString ===================================== */
  public String toString() {
      return mySelf()+"!";
    }

  /* ==================== toDebugString ===================================== */
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    str.append("...band_size: "+band_size+'\n');
    return str.toString();
  }

  /* ==================== getBand_size ================================== */
  public int getBand_size() {
    return band_size;
  }

  /* ==================== setBand_size ================================== */
  public void setBand_size(int band_size) {
    this.band_size = band_size;
  }

  /* ==================== getWorker ================================== */
  public grayTWorkerRec getWorker() {
    return worker;
  }

  /* ==================== setWorker ================================== */
  public void setWorker(grayTWorkerRec worker) {
    this.worker = worker;
  }

}

Changes to aftraster/grayTWorkerRec.java.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
























103
104
105

106
107
108
109
110
111



112















































































































































































































































































































































































 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    grayTWorker                                                        */
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTBBoxRec;
import org.apwtcl.apwfreetypelib.aftbase.FTBitmapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTOutlineRec;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;

public class grayTWorkerRec extends FTDebug {
    private static int oid = 0;

    private int id;
    private static String TAG = "grayTWorker";
    private final static int MaxBezier = 32;

    public int ex;
    public int ey;
    public int min_ex;
    public int max_ex;
    public int min_ey;
    public int max_ey;
    public int count_ex;
    public int count_ey;
    public int area;
    public int cover;
    public boolean invalid;
    public TCellRec[] cells = null;
    public int max_cells;
    public int num_cells;
    public int cx;
    public int cy;
    public int x;
    public int y;
    public int last_ey;
    public FTVectorRec[] bez_stack = new FTVectorRec[MaxBezier * 3 + 1];
    public int[] lev_stack = new int[32];
    public FTOutlineRec outline;
    public FTBitmapRec target;
    public FTBBoxRec clip_box;
    public FTSpanRec[] gray_spans = new FTSpanRec[FTSpanRec.FT_MAX_GRAY_SPANS];
    public int num_gray_spans;
    public Object render_span_data;
    public int span_y;
    public int band_size;
    public int band_shoot;
//    public ft_jmp_buf jump_buffer;
    public Object buffer;
    public int buffer_size;
    public TCellRec[] ycells;
    public int ycount;

    /* ==================== grayTWorker ================================== */
    public grayTWorkerRec() {
      int i;

      oid++;
      id = oid;
      target = new FTBitmapRec();
      outline = new FTOutlineRec();
      clip_box = new FTBBoxRec();
      for (i = 0; i < FTSpanRec.FT_MAX_GRAY_SPANS; i++) {
        gray_spans[i] = new FTSpanRec();
      }
      for (i = 0; i < MaxBezier * 3 + 1; i++) {
        bez_stack[i] = new FTVectorRec();
      }
    }
    
    /* ==================== mySelf ================================== */
    public String mySelf() {
      return TAG+"!"+id+"!";
    }
        
    /* ==================== toString ===================================== */
    public String toString() {
      return mySelf()+"!";
    }

    /* ==================== toDebugString ===================================== */
    public String toDebugString() {
      StringBuffer str = new StringBuffer(mySelf()+"\n");
























      return str.toString();
    }


  public FTError.ErrorTag renderSpan(int y, int count, FTSpanRec[] spans, grayTWorkerRec worker) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    Log.e(TAG, "renderSpan not yet implemented");
    return error;
  }




}






















































































































































































































































































































































































|













|

|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|

|
|
|

|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|

|
|
|
|

|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|

>






>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * =====================================================================
 */

package org.apwtcl.apwfreetypelib.aftraster;

  /* ===================================================================== */
  /*    grayTWorkerRec                                                     */
  /*                                                                       */
  /* ===================================================================== */

import android.util.Log;

import org.apwtcl.apwfreetypelib.aftbase.FTBBoxRec;
import org.apwtcl.apwfreetypelib.aftbase.FTBitmapRec;
import org.apwtcl.apwfreetypelib.aftbase.FTOutlineRec;
import org.apwtcl.apwfreetypelib.aftutil.FTDebug;
import org.apwtcl.apwfreetypelib.aftutil.FTError;
import org.apwtcl.apwfreetypelib.aftutil.FTVectorRec;

public class grayTWorkerRec extends FTDebug {
  private static int oid = 0;

  private int id;
  private static String TAG = "grayTWorkerRec";
  private final static int MaxBezier = 32;

  private int ex;
  private int ey;
  private int min_ex;
  private int max_ex;
  private int min_ey;
  private int max_ey;
  private int count_ex;
  private int count_ey;
  private int area;
  private int cover;
  private boolean invalid;
  private TCellRec[] cells = null;
  private int max_cells;
  private int num_cells;
  private int cx;
  private int cy;
  private int x;
  private int y;
  private int last_ey;
  private FTVectorRec[] bez_stack = new FTVectorRec[MaxBezier * 3 + 1];
  private int[] lev_stack = new int[32];
  private FTOutlineRec outline;
  private FTBitmapRec target;
  private FTBBoxRec clip_box;
  private FTSpanRec[] gray_spans = new FTSpanRec[FTSpanRec.FT_MAX_GRAY_SPANS];
  private int num_gray_spans;
  private Object render_span_data;
  private int span_y;
  private int band_size;
  private int band_shoot;

  private Object buffer;
  private int buffer_size;
  private TCellRec[] ycells;
  private int ycount;

  /* ==================== grayTWorker ================================== */
  public grayTWorkerRec() {
    int i;

    oid++;
    id = oid;
    target = new FTBitmapRec();
    outline = new FTOutlineRec();
    clip_box = new FTBBoxRec();
    for (i = 0; i < FTSpanRec.FT_MAX_GRAY_SPANS; i++) {
      gray_spans[i] = new FTSpanRec();
    }
    for (i = 0; i < MaxBezier * 3 + 1; i++) {
      bez_stack[i] = new FTVectorRec();
    }
  }
    
  /* ==================== mySelf ================================== */
  public String mySelf() {
    return TAG+"!"+id+"!";
  }
        
  /* ==================== toString ===================================== */
  public String toString() {
    return mySelf()+"!";
  }

  /* ==================== toDebugString ===================================== */
  public String toDebugString() {
    StringBuffer str = new StringBuffer(mySelf()+"\n");
    str.append("...ex: "+ex+'\n');
    str.append("...ey: "+ey+'\n');
    str.append("...min_ex: "+min_ex+'\n');
    str.append("...max_ex: "+max_ex+'\n');
    str.append("...min_ey: "+min_ey+'\n');
    str.append("...max_ey: "+max_ey+'\n');
    str.append("...count_ex: "+count_ex+'\n');
    str.append("...count_ey: "+count_ey+'\n');
    str.append("...area: "+area+'\n');
    str.append("...cover: "+cover+'\n');
    str.append("...invalid: "+invalid+'\n');
    str.append("...max_cells: "+max_cells+'\n');
    str.append("...num_cells: "+num_cells+'\n');
    str.append("...cx: "+cx+'\n');
    str.append("...cy: "+cy+'\n');
    str.append("...x: "+x+'\n');
    str.append("...y: "+y+'\n');
    str.append("...last_ey: "+last_ey+'\n');
    str.append("...num_gray_spans: "+num_gray_spans+'\n');
    str.append("...span_y: "+span_y+'\n');
    str.append("...band_size: "+band_size+'\n');
    str.append("...band_shoot: "+band_shoot+'\n');
    str.append("...buffer_size: "+buffer_size+'\n');
    str.append("...ycount: "+ycount+'\n');
    return str.toString();
  }

  /* ==================== renderSpan ================================== */
  public FTError.ErrorTag renderSpan(int y, int count, FTSpanRec[] spans, grayTWorkerRec worker) {
    FTError.ErrorTag error = FTError.ErrorTag.ERR_OK;
    Log.e(TAG, "renderSpan not yet implemented");
    return error;
  }

  /* ==================== getEx ================================== */
  public int getEx() {
    return ex;
  }

  /* ==================== setEx ================================== */
  public void setEx(int ex) {
    this.ex = ex;
  }

  /* ==================== getEy ================================== */
  public int getEy() {
    return ey;
  }

  /* ==================== setEy ================================== */
  public void setEy(int ey) {
    this.ey = ey;
  }

  /* ==================== getMin_ex ================================== */
  public int getMin_ex() {
    return min_ex;
  }

  /* ==================== setMin_ex ================================== */
  public void setMin_ex(int min_ex) {
    this.min_ex = min_ex;
  }

  /* ==================== getMax_ex ================================== */
  public int getMax_ex() {
    return max_ex;
  }

  /* ==================== setMax_ex ================================== */
  public void setMax_ex(int max_ex) {
    this.max_ex = max_ex;
  }

  /* ==================== getMin_ey ================================== */
  public int getMin_ey() {
    return min_ey;
  }

  /* ==================== setMin_ey ================================== */
  public void setMin_ey(int min_ey) {
    this.min_ey = min_ey;
  }

  /* ==================== getMax_ey ================================== */
  public int getMax_ey() {
    return max_ey;
  }

  /* ==================== setMax_ey ================================== */
  public void setMax_ey(int max_ey) {
    this.max_ey = max_ey;
  }

  /* ==================== getCount_ex ================================== */
  public int getCount_ex() {
    return count_ex;
  }

  /* ==================== setCount_ex ================================== */
  public void setCount_ex(int count_ex) {
    this.count_ex = count_ex;
  }

  /* ==================== getCount_ey ================================== */
  public int getCount_ey() {
    return count_ey;
  }

  /* ==================== setCount_ey ================================== */
  public void setCount_ey(int count_ey) {
    this.count_ey = count_ey;
  }

  /* ==================== getArea ================================== */
  public int getArea() {
    return area;
  }

  /* ==================== setArea ================================== */
  public void setArea(int area) {
    this.area = area;
  }

  /* ==================== getCover ================================== */
  public int getCover() {
    return cover;
  }

  /* ==================== setCover ================================== */
  public void setCover(int cover) {
    this.cover = cover;
  }

  /* ==================== isInvalid ================================== */
  public boolean isInvalid() {
    return invalid;
  }

  /* ==================== setInvalid ================================== */
  public void setInvalid(boolean invalid) {
    this.invalid = invalid;
  }

  /* ==================== getCells ================================== */
  public TCellRec[] getCells() {
    return cells;
  }

  /* ==================== getCell ================================== */
  public TCellRec getCell(int idx) {
    return cells[idx];
  }

  /* ==================== setCells ================================== */
  public void setCells(TCellRec[] cells) {
    this.cells = cells;
  }

  /* ==================== setCell ================================== */
  public void setCell(int idx, TCellRec cell) {
    this.cells[idx] = cell;
  }

  /* ==================== getMax_cells ================================== */
  public int getMax_cells() {
    return max_cells;
  }

  /* ==================== setMax_cells ================================== */
  public void setMax_cells(int max_cells) {
    this.max_cells = max_cells;
  }

  /* ==================== getNum_cells ================================== */
  public int getNum_cells() {
    return num_cells;
  }

  /* ==================== setNum_cells ================================== */
  public void setNum_cells(int num_cells) {
    this.num_cells = num_cells;
  }

  /* ==================== getCx ================================== */
  public int getCx() {
    return cx;
  }

  /* ==================== setCx ================================== */
  public void setCx(int cx) {
    this.cx = cx;
  }

  /* ==================== getCy ================================== */
  public int getCy() {
    return cy;
  }

  /* ==================== setCy ================================== */
  public void setCy(int cy) {
    this.cy = cy;
  }

  /* ==================== getX ================================== */
  public int getX() {
    return x;
  }

  /* ==================== setX ================================== */
  public void setX(int x) {
    this.x = x;
  }

  /* ==================== getY ================================== */
  public int getY() {
    return y;
  }

  /* ==================== setY ================================== */
  public void setY(int y) {
    this.y = y;
  }

  /* ==================== getLast_ey ================================== */
  public int getLast_ey() {
    return last_ey;
  }

  /* ==================== setLast_ey ================================== */
  public void setLast_ey(int last_ey) {
    this.last_ey = last_ey;
  }

  /* ==================== getBez_stack ================================== */
  public FTVectorRec[] getBez_stack() {
    return bez_stack;
  }

  /* ==================== setBez_stack ================================== */
  public void setBez_stack(FTVectorRec[] bez_stack) {
    this.bez_stack = bez_stack;
  }

  /* ==================== getLev_stack ================================== */
  public int[] getLev_stack() {
    return lev_stack;
  }

  /* ==================== setLev_stack ================================== */
  public void setLev_stack(int[] lev_stack) {
    this.lev_stack = lev_stack;
  }

  /* ==================== getOutline ================================== */
  public FTOutlineRec getOutline() {
    return outline;
  }

  /* ==================== setOutline ================================== */
  public void setOutline(FTOutlineRec outline) {
    this.outline = outline;
  }

  /* ==================== getTarget ================================== */
  public FTBitmapRec getTarget() {
    return target;
  }

  /* ==================== setTarget ================================== */
  public void setTarget(FTBitmapRec target) {
    this.target = target;
  }

  /* ==================== getClip_box ================================== */
  public FTBBoxRec getClip_box() {
    return clip_box;
  }

  /* ==================== setClip_box ================================== */
  public void setClip_box(FTBBoxRec clip_box) {
    this.clip_box = clip_box;
  }

  /* ==================== getGray_spans ================================== */
  public FTSpanRec[] getGray_spans() {
    return gray_spans;
  }

  /* ==================== getGray_span ================================== */
  public FTSpanRec getGray_span(int idx) {
    return gray_spans[idx];
  }

  /* ==================== setGray_spans ================================== */
  public void setGray_spans(FTSpanRec[] gray_spans) {
    this.gray_spans = gray_spans;
  }

  /* ==================== setGray_span ================================== */
  public void setGray_span(int idx, FTSpanRec gray_span) {
    this.gray_spans[idx] = gray_span;
  }

  /* ==================== getNum_gray_spans ================================== */
  public int getNum_gray_spans() {
    return num_gray_spans;
  }

  /* ==================== setNum_gray_spans ================================== */
  public void setNum_gray_spans(int num_gray_spans) {
    this.num_gray_spans = num_gray_spans;
  }

  /* ==================== getRender_span_data ================================== */
  public Object getRender_span_data() {
    return render_span_data;
  }

  /* ==================== setRender_span_data ================================== */
  public void setRender_span_data(Object render_span_data) {
    this.render_span_data = render_span_data;
  }

  /* ==================== getSpan_y ================================== */
  public int getSpan_y() {
    return span_y;
  }

  /* ==================== setSpan_y ================================== */
  public void setSpan_y(int span_y) {
    this.span_y = span_y;
  }

  /* ==================== getBand_size ================================== */
  public int getBand_size() {
    return band_size;
  }

  /* ==================== setBand_size ================================== */
  public void setBand_size(int band_size) {
    this.band_size = band_size;
  }

  /* ==================== getBand_shoot ================================== */
  public int getBand_shoot() {
    return band_shoot;
  }

  /* ==================== setBand_shoot ================================== */
  public void setBand_shoot(int band_shoot) {
    this.band_shoot = band_shoot;
  }

  /* ==================== getBuffer ================================== */
  public Object getBuffer() {
    return buffer;
  }

  /* ==================== setBuffer ================================== */
  public void setBuffer(Object buffer) {
    this.buffer = buffer;
  }

  /* ==================== getBuffer_size ================================== */
  public int getBuffer_size() {
    return buffer_size;
  }

  /* ==================== setBuffer_size ================================== */
  public void setBuffer_size(int buffer_size) {
    this.buffer_size = buffer_size;
  }

  /* ==================== getYcells ================================== */
  public TCellRec[] getYcells() {
    return ycells;
  }

  /* ==================== getYcell ================================== */
  public TCellRec getYcell(int cell_idx) {
    return ycells[cell_idx];
  }

  /* ==================== setYcells ================================== */
  public void setYcells(TCellRec[] ycells) {
    this.ycells = ycells;
  }

  /* ==================== setYcell ================================== */
  public void setYcell(int idx, TCellRec ycell) {
    this.ycells[idx] = ycell;
  }

  /* ==================== getYcount ================================== */
  public int getYcount() {
    return ycount;
  }

  /* ==================== setYcount ================================== */
  public void setYcount(int ycount) {
    this.ycount = ycount;
  }

}