Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: core/src/fxge/win32/agg_clip_liang_barsky.h

Issue 402463002: Replace agg with skia (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix clang compile error Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxge/skia/fx_skia_driver.cpp ('k') | core/src/fxge/win32/fx_win32_device.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
2 //---------------------------------------------------------------------------- 1 //----------------------------------------------------------------------------
3 // Anti-Grain Geometry - Version 2.3 2 // Anti-Grain Geometry - Version 2.3
4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) 3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5 // 4 //
6 // Permission to copy, use, modify, sell and distribute this software 5 // Permission to copy, use, modify, sell and distribute this software
7 // is granted provided this copyright notice appears in all copies. 6 // is granted provided this copyright notice appears in all copies.
8 // This software is provided "as is" without express or implied 7 // This software is provided "as is" without express or implied
9 // warranty, and with no claim as to its suitability for any purpose. 8 // warranty, and with no claim as to its suitability for any purpose.
10 // 9 //
11 //---------------------------------------------------------------------------- 10 //----------------------------------------------------------------------------
12 // Contact: mcseem@antigrain.com 11 // Contact: mcseem@antigrain.com
13 // mcseemagg@yahoo.com 12 // mcseemagg@yahoo.com
14 // http://www.antigrain.com 13 // http://www.antigrain.com
15 //---------------------------------------------------------------------------- 14 //----------------------------------------------------------------------------
16 // 15 //
17 // Liang-Barsky clipping 16 // Liang-Barsky clipping
18 // 17 //
19 //---------------------------------------------------------------------------- 18 //----------------------------------------------------------------------------
20 #ifndef AGG_CLIP_LIANG_BARSKY_INCLUDED 19 #ifndef AGG_CLIP_LIANG_BARSKY_INCLUDED
21 #define AGG_CLIP_LIANG_BARSKY_INCLUDED 20 #define AGG_CLIP_LIANG_BARSKY_INCLUDED
22 #include "agg_basics.h" 21 #include "../../../include/fxcrt/fx_coordinates.h"
23 namespace agg 22
24 { 23 inline unsigned clip_liang_barsky(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOA T y2,
25 template<class T> 24 const CFX_FloatRect& clip_box,
26 inline unsigned clipping_flags(T x, T y, const rect_base<T>& clip_box) 25 FX_FLOAT* x, FX_FLOAT* y)
27 {
28 return (x > clip_box.x2) |
29 ((y > clip_box.y2) << 1) |
30 ((x < clip_box.x1) << 2) |
31 ((y < clip_box.y1) << 3);
32 }
33 template<class T>
34 inline unsigned clip_liang_barsky(T x1, T y1, T x2, T y2,
35 const rect_base<T>& clip_box,
36 T* x, T* y)
37 { 26 {
38 const FX_FLOAT nearzero = 1e-30f; 27 const FX_FLOAT nearzero = 1e-30f;
39 FX_FLOAT deltax = (FX_FLOAT)(x2 - x1); 28 FX_FLOAT deltax = (FX_FLOAT)(x2 - x1);
40 FX_FLOAT deltay = (FX_FLOAT)(y2 - y1); 29 FX_FLOAT deltay = (FX_FLOAT)(y2 - y1);
41 unsigned np = 0; 30 unsigned np = 0;
42 if(deltax == 0) { 31 if(deltax == 0) {
43 deltax = (x1 > clip_box.x1) ? -nearzero : nearzero; 32 deltax = (x1 > clip_box.left) ? -nearzero : nearzero;
44 } 33 }
45 FX_FLOAT xin, xout; 34 FX_FLOAT xin, xout;
46 if(deltax > 0) { 35 if(deltax > 0) {
47 xin = (FX_FLOAT)clip_box.x1; 36 xin = (FX_FLOAT)clip_box.left;
48 xout = (FX_FLOAT)clip_box.x2; 37 xout = (FX_FLOAT)clip_box.right;
49 } else { 38 } else {
50 xin = (FX_FLOAT)clip_box.x2; 39 xin = (FX_FLOAT)clip_box.right;
51 xout = (FX_FLOAT)clip_box.x1; 40 xout = (FX_FLOAT)clip_box.left;
52 } 41 }
53 FX_FLOAT tinx = FXSYS_Div(xin - x1, deltax); 42 FX_FLOAT tinx = FXSYS_Div(xin - x1, deltax);
54 if(deltay == 0) { 43 if(deltay == 0) {
55 deltay = (y1 > clip_box.y1) ? -nearzero : nearzero; 44 deltay = (y1 > clip_box.top) ? -nearzero : nearzero;
56 } 45 }
57 FX_FLOAT yin, yout; 46 FX_FLOAT yin, yout;
58 if(deltay > 0) { 47 if(deltay > 0) {
59 yin = (FX_FLOAT)clip_box.y1; 48 yin = (FX_FLOAT)clip_box.top;
60 yout = (FX_FLOAT)clip_box.y2; 49 yout = (FX_FLOAT)clip_box.bottom;
61 } else { 50 } else {
62 yin = (FX_FLOAT)clip_box.y2; 51 yin = (FX_FLOAT)clip_box.bottom;
63 yout = (FX_FLOAT)clip_box.y1; 52 yout = (FX_FLOAT)clip_box.top;
64 } 53 }
65 FX_FLOAT tiny = FXSYS_Div(yin - y1, deltay); 54 FX_FLOAT tiny = FXSYS_Div(yin - y1, deltay);
66 FX_FLOAT tin1, tin2; 55 FX_FLOAT tin1, tin2;
67 if (tinx < tiny) { 56 if (tinx < tiny) {
68 tin1 = tinx; 57 tin1 = tinx;
69 tin2 = tiny; 58 tin2 = tiny;
70 } else { 59 } else {
71 tin1 = tiny; 60 tin1 = tiny;
72 tin2 = tinx; 61 tin2 = tinx;
73 } 62 }
74 if(tin1 <= 1.0f) { 63 if(tin1 <= 1.0f) {
75 if(0 < tin1) { 64 if(0 < tin1) {
76 *x++ = (T)xin; 65 *x++ = xin;
77 *y++ = (T)yin; 66 *y++ = yin;
78 ++np; 67 ++np;
79 } 68 }
80 if(tin2 <= 1.0f) { 69 if(tin2 <= 1.0f) {
81 FX_FLOAT toutx = FXSYS_Div(xout - x1, deltax); 70 FX_FLOAT toutx = FXSYS_Div(xout - x1, deltax);
82 FX_FLOAT touty = FXSYS_Div(yout - y1, deltay); 71 FX_FLOAT touty = FXSYS_Div(yout - y1, deltay);
83 FX_FLOAT tout1 = (toutx < touty) ? toutx : touty; 72 FX_FLOAT tout1 = (toutx < touty) ? toutx : touty;
84 if(tin2 > 0 || tout1 > 0) { 73 if(tin2 > 0 || tout1 > 0) {
85 if(tin2 <= tout1) { 74 if(tin2 <= tout1) {
86 if(tin2 > 0) { 75 if(tin2 > 0) {
87 if(tinx > tiny) { 76 if(tinx > tiny) {
88 *x++ = (T)xin; 77 *x++ = xin;
89 *y++ = (T)(y1 + FXSYS_Mul(deltay, tinx)); 78 *y++ = (y1 + FXSYS_Mul(deltay, tinx));
90 } else { 79 } else {
91 *x++ = (T)(x1 + FXSYS_Mul(deltax, tiny)); 80 *x++ = (x1 + FXSYS_Mul(deltax, tiny));
92 *y++ = (T)yin; 81 *y++ = yin;
93 } 82 }
94 ++np; 83 ++np;
95 } 84 }
96 if(tout1 < 1.0f) { 85 if(tout1 < 1.0f) {
97 if(toutx < touty) { 86 if(toutx < touty) {
98 *x++ = (T)xout; 87 *x++ = xout;
99 *y++ = (T)(y1 + FXSYS_Mul(deltay, toutx)); 88 *y++ = (y1 + FXSYS_Mul(deltay, toutx));
100 } else { 89 } else {
101 *x++ = (T)(x1 + FXSYS_Mul(deltax, touty)); 90 *x++ = (x1 + FXSYS_Mul(deltax, touty));
102 *y++ = (T)yout; 91 *y++ = yout;
103 } 92 }
104 } else { 93 } else {
105 *x++ = x2; 94 *x++ = x2;
106 *y++ = y2; 95 *y++ = y2;
107 } 96 }
108 ++np; 97 ++np;
109 } else { 98 } else {
110 if(tinx > tiny) { 99 if(tinx > tiny) {
111 *x++ = (T)xin; 100 *x++ = xin;
112 *y++ = (T)yout; 101 *y++ = yout;
113 } else { 102 } else {
114 *x++ = (T)xout; 103 *x++ = xout;
115 *y++ = (T)yin; 104 *y++ = yin;
116 } 105 }
117 ++np; 106 ++np;
118 } 107 }
119 } 108 }
120 } 109 }
121 } 110 }
122 return np; 111 return np;
123 } 112 }
124 } 113
125 #endif 114 #endif
OLDNEW
« no previous file with comments | « core/src/fxge/skia/fx_skia_driver.cpp ('k') | core/src/fxge/win32/fx_win32_device.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698