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

Side by Side Diff: src/utils/SkPathUtils.cpp

Issue 18552005: Animated the PathUtils Sample to show path contours (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixed (lower)casing of local variables. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « samplecode/SamplePathUtils.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * CAUTION: EXPERIMENTAL CODE 2 * CAUTION: EXPERIMENTAL CODE
3 * 3 *
4 * This code is not to be used and will not be supported 4 * This code is not to be used and will not be supported
5 * if it fails on you. DO NOT USE! 5 * if it fails on you. DO NOT USE!
6 * 6 *
7 */ 7 */
8 8
9 #include "SkPathUtils.h" 9 #include "SkPathUtils.h"
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 SkPath::kCW_Direction); 90 SkPath::kCW_Direction);
91 } else if ( GetBit(line, width - 1) ) { // if last pixel on add 91 } else if ( GetBit(line, width - 1) ) { // if last pixel on add
92 path->addRect(SkRect::MakeXYWH(width - SK_Scalar1, SkIntToScalar(lineIdx ), 92 path->addRect(SkRect::MakeXYWH(width - SK_Scalar1, SkIntToScalar(lineIdx ),
93 SK_Scalar1, SK_Scalar1), 93 SK_Scalar1, SK_Scalar1),
94 SkPath::kCW_Direction); 94 SkPath::kCW_Direction);
95 } 95 }
96 } 96 }
97 97
98 void SkPathUtils::BitsToPath_Path(SkPath* path, 98 void SkPathUtils::BitsToPath_Path(SkPath* path,
99 const char* bitmap, 99 const char* bitmap,
100 int h, int w, int stride) { 100 int w, int h, int stride) {
101 // loop for every line in bitmap 101 // loop for every line in bitmap
102 for (int i = 0; i < h; ++i) { 102 for (int i = 0; i < h; ++i) {
103 // fn ptr handles each line separately 103 // fn ptr handles each line separately
104 //l2p_fn(path, &bitmap[i*stride], i, w); 104 //l2p_fn(path, &bitmap[i*stride], i, w);
105 Line2path_span(path, &bitmap[i*stride], i, w); 105 Line2path_span(path, &bitmap[i*stride], i, w);
106 } 106 }
107 Simplify(*path, path); // simplify resulting bitmap 107 Simplify(*path, path); // simplify resulting path.
108 } 108 }
109 109
110 void SkPathUtils::BitsToPath_Region(SkPath* path, 110 void SkPathUtils::BitsToPath_Region(SkPath* path,
111 const char* bitmap, 111 const char* bitmap,
112 int h, int w, int stride) { 112 int w, int h, int stride) {
113 SkRegion region; 113 SkRegion region;
114 114
115 // loop for each line 115 // loop for each line
116 for (int y = 0; y < h; ++y){ 116 for (int y = 0; y < h; ++y){
117 bool inRun = 0; 117 bool inRun = 0;
118 int start = 1; 118 int start = 1;
119 const char* line = &bitmap[y * stride]; 119 const char* line = &bitmap[y * stride];
120 120
121 // loop for each pixel 121 // loop for each pixel
122 for (int i = 0; i < w; ++i) { 122 for (int i = 0; i < w; ++i) {
(...skipping 20 matching lines...) Expand all
143 143
144 } else if ( GetBit(line,w-1) ) { // if last pixel on add rect 144 } else if ( GetBit(line,w-1) ) { // if last pixel on add rect
145 // add the thing here 145 // add the thing here
146 region.op(SkIRect::MakeXYWH(w-1, y, 1, 1), 146 region.op(SkIRect::MakeXYWH(w-1, y, 1, 1),
147 SkRegion::kUnion_Op ); 147 SkRegion::kUnion_Op );
148 } 148 }
149 } 149 }
150 // convert region to path 150 // convert region to path
151 region.getBoundaryPath(path); 151 region.getBoundaryPath(path);
152 } 152 }
OLDNEW
« no previous file with comments | « samplecode/SamplePathUtils.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698