~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/poppler/splash/SplashClip.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//========================================================================
 
2
//
 
3
// SplashClip.h
 
4
//
 
5
//========================================================================
 
6
 
 
7
//========================================================================
 
8
//
 
9
// Modified under the Poppler project - http://poppler.freedesktop.org
 
10
//
 
11
// All changes made under the Poppler project to this file are licensed
 
12
// under GPL version 2 or later
 
13
//
 
14
// Copyright (C) 2010 Albert Astals Cid <aacid@kde.org>
 
15
//
 
16
// To see a description of the changes please see the Changelog file that
 
17
// came with your tarball or type make ChangeLog if you are building from git
 
18
//
 
19
//========================================================================
 
20
 
 
21
#ifndef SPLASHCLIP_H
 
22
#define SPLASHCLIP_H
 
23
 
 
24
#ifdef USE_GCC_PRAGMAS
 
25
#pragma interface
 
26
#endif
 
27
 
 
28
#include "SplashTypes.h"
 
29
#include "SplashMath.h"
 
30
#include "SplashXPathScanner.h"
 
31
 
 
32
class SplashPath;
 
33
class SplashXPath;
 
34
class SplashBitmap;
 
35
 
 
36
//------------------------------------------------------------------------
 
37
 
 
38
enum SplashClipResult {
 
39
  splashClipAllInside,
 
40
  splashClipAllOutside,
 
41
  splashClipPartial
 
42
};
 
43
 
 
44
//------------------------------------------------------------------------
 
45
// SplashClip
 
46
//------------------------------------------------------------------------
 
47
 
 
48
class SplashClip {
 
49
public:
 
50
 
 
51
  // Create a clip, for the given rectangle.
 
52
  SplashClip(SplashCoord x0, SplashCoord y0,
 
53
             SplashCoord x1, SplashCoord y1,
 
54
             GBool antialiasA);
 
55
 
 
56
  // Copy a clip.
 
57
  SplashClip *copy() { return new SplashClip(this); }
 
58
 
 
59
  ~SplashClip();
 
60
 
 
61
  // Reset the clip to a rectangle.
 
62
  void resetToRect(SplashCoord x0, SplashCoord y0,
 
63
                   SplashCoord x1, SplashCoord y1);
 
64
 
 
65
  // Intersect the clip with a rectangle.
 
66
  SplashError clipToRect(SplashCoord x0, SplashCoord y0,
 
67
                         SplashCoord x1, SplashCoord y1);
 
68
 
 
69
  // Interesect the clip with <path>.
 
70
  SplashError clipToPath(SplashPath *path, SplashCoord *matrix,
 
71
                         SplashCoord flatness, GBool eo);
 
72
 
 
73
  // Returns true if (<x>,<y>) is inside the clip.
 
74
  GBool test(int x, int y)
 
75
  {
 
76
    int i;
 
77
 
 
78
    // check the rectangle
 
79
    if (x < xMinI || x > xMaxI || y < yMinI || y > yMaxI) {
 
80
      return gFalse;
 
81
    }
 
82
 
 
83
    // check the paths
 
84
    if (antialias) {
 
85
      for (i = 0; i < length; ++i) {
 
86
        if (!scanners[i]->test(x * splashAASize, y * splashAASize)) {
 
87
          return gFalse;
 
88
        }
 
89
      }
 
90
    } else {
 
91
      for (i = 0; i < length; ++i) {
 
92
        if (!scanners[i]->test(x, y)) {
 
93
          return gFalse;
 
94
        }
 
95
      }
 
96
    }
 
97
 
 
98
    return gTrue;
 
99
  }
 
100
 
 
101
  // Tests a rectangle against the clipping region.  Returns one of:
 
102
  //   - splashClipAllInside if the entire rectangle is inside the
 
103
  //     clipping region, i.e., all pixels in the rectangle are
 
104
  //     visible
 
105
  //   - splashClipAllOutside if the entire rectangle is outside the
 
106
  //     clipping region, i.e., all the pixels in the rectangle are
 
107
  //     clipped
 
108
  //   - splashClipPartial if the rectangle is part inside and part
 
109
  //     outside the clipping region
 
110
  SplashClipResult testRect(int rectXMin, int rectYMin,
 
111
                            int rectXMax, int rectYMax);
 
112
 
 
113
  // Similar to testRect, but tests a horizontal span.
 
114
  SplashClipResult testSpan(int spanXMin, int spanXMax, int spanY);
 
115
 
 
116
  // Clips an anti-aliased line by setting pixels to zero.  On entry,
 
117
  // all non-zero pixels are between <x0> and <x1>.  This function
 
118
  // will update <x0> and <x1>.
 
119
  void clipAALine(SplashBitmap *aaBuf, int *x0, int *x1, int y);
 
120
 
 
121
  // Get the rectangle part of the clip region, in integer coordinates.
 
122
  int getXMinI() { return xMinI; }
 
123
  int getXMaxI() { return xMaxI; }
 
124
  int getYMinI() { return yMinI; }
 
125
  int getYMaxI() { return yMaxI; }
 
126
 
 
127
  // Get the number of arbitrary paths used by the clip region.
 
128
  int getNumPaths() { return length; }
 
129
 
 
130
protected:
 
131
 
 
132
  SplashClip(SplashClip *clip);
 
133
  void grow(int nPaths);
 
134
 
 
135
  GBool antialias;
 
136
  SplashCoord xMin, yMin, xMax, yMax;
 
137
  int xMinI, yMinI, xMaxI, yMaxI;
 
138
  SplashXPath **paths;
 
139
  Guchar *flags;
 
140
  SplashXPathScanner **scanners;
 
141
  int length, size;
 
142
};
 
143
 
 
144
#endif