ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

pathiterator.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007 Google (Evan Stade)
00003  * Copyright (C) 2008 Nikolay Sivov <bunglehead at gmail dot com>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00018  */
00019 
00020 #include <stdarg.h>
00021 
00022 #include "windef.h"
00023 #include "winbase.h"
00024 #include "wingdi.h"
00025 
00026 #include "objbase.h"
00027 
00028 #include "gdiplus.h"
00029 #include "gdiplus_private.h"
00030 #include "wine/debug.h"
00031 
00032 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
00033 
00034 GpStatus WINGDIPAPI GdipCreatePathIter(GpPathIterator **iterator, GpPath* path)
00035 {
00036     INT size;
00037 
00038     TRACE("(%p, %p)\n", iterator, path);
00039 
00040     if(!iterator)
00041         return InvalidParameter;
00042 
00043     *iterator = GdipAlloc(sizeof(GpPathIterator));
00044     if(!*iterator)  return OutOfMemory;
00045 
00046     if(path){
00047         size = path->pathdata.Count;
00048 
00049         (*iterator)->pathdata.Types  = GdipAlloc(size);
00050         (*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
00051 
00052         memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
00053         memcpy((*iterator)->pathdata.Points, path->pathdata.Points,size * sizeof(PointF));
00054         (*iterator)->pathdata.Count = size;
00055     }
00056     else{
00057         (*iterator)->pathdata.Types  = NULL;
00058         (*iterator)->pathdata.Points = NULL;
00059         (*iterator)->pathdata.Count  = 0;
00060     }
00061 
00062     (*iterator)->subpath_pos  = 0;
00063     (*iterator)->marker_pos   = 0;
00064     (*iterator)->pathtype_pos = 0;
00065 
00066     return Ok;
00067 }
00068 
00069 GpStatus WINGDIPAPI GdipDeletePathIter(GpPathIterator *iter)
00070 {
00071     TRACE("(%p)\n", iter);
00072 
00073     if(!iter)
00074         return InvalidParameter;
00075 
00076     GdipFree(iter->pathdata.Types);
00077     GdipFree(iter->pathdata.Points);
00078     GdipFree(iter);
00079 
00080     return Ok;
00081 }
00082 
00083 GpStatus WINGDIPAPI GdipPathIterCopyData(GpPathIterator* iterator,
00084     INT* resultCount, GpPointF* points, BYTE* types, INT startIndex, INT endIndex)
00085 {
00086     TRACE("(%p, %p, %p, %p, %d, %d)\n", iterator, resultCount, points, types,
00087            startIndex, endIndex);
00088 
00089     if(!iterator || !types || !points)
00090         return InvalidParameter;
00091 
00092     if(endIndex > iterator->pathdata.Count - 1 || startIndex < 0 ||
00093         endIndex < startIndex){
00094         *resultCount = 0;
00095         return Ok;
00096     }
00097 
00098     *resultCount = endIndex - startIndex + 1;
00099 
00100     memcpy(types, &(iterator->pathdata.Types[startIndex]), *resultCount);
00101     memcpy(points, &(iterator->pathdata.Points[startIndex]),
00102         *resultCount * sizeof(PointF));
00103 
00104     return Ok;
00105 }
00106 
00107 GpStatus WINGDIPAPI GdipPathIterHasCurve(GpPathIterator* iterator, BOOL* hasCurve)
00108 {
00109     INT i;
00110 
00111     TRACE("(%p, %p)\n", iterator, hasCurve);
00112 
00113     if(!iterator)
00114         return InvalidParameter;
00115 
00116     *hasCurve = FALSE;
00117 
00118     for(i = 0; i < iterator->pathdata.Count; i++)
00119         if((iterator->pathdata.Types[i] & PathPointTypePathTypeMask) == PathPointTypeBezier){
00120             *hasCurve = TRUE;
00121             break;
00122         }
00123 
00124     return Ok;
00125 }
00126 
00127 GpStatus WINGDIPAPI GdipPathIterGetSubpathCount(GpPathIterator* iterator, INT* count)
00128 {
00129     INT i;
00130 
00131     TRACE("(%p, %p)\n", iterator, count);
00132 
00133     if(!iterator || !count)
00134         return InvalidParameter;
00135 
00136     *count = 0;
00137     for(i = 0; i < iterator->pathdata.Count; i++){
00138         if(iterator->pathdata.Types[i] == PathPointTypeStart)
00139             (*count)++;
00140     }
00141 
00142     return Ok;
00143 }
00144 
00145 GpStatus WINGDIPAPI GdipPathIterNextMarker(GpPathIterator* iterator, INT *resultCount,
00146     INT* startIndex, INT* endIndex)
00147 {
00148     INT i;
00149 
00150     TRACE("(%p, %p, %p, %p)\n", iterator, resultCount, startIndex, endIndex);
00151 
00152     if(!iterator || !startIndex || !endIndex)
00153         return InvalidParameter;
00154 
00155     *resultCount = 0;
00156 
00157     /* first call could start with second point as all subsequent, cause
00158        path couldn't contain only one */
00159     for(i = iterator->marker_pos + 1; i < iterator->pathdata.Count; i++){
00160         if((iterator->pathdata.Types[i] & PathPointTypePathMarker) ||
00161            (i == iterator->pathdata.Count - 1)){
00162             *startIndex = iterator->marker_pos;
00163             if(iterator->marker_pos > 0) (*startIndex)++;
00164             *endIndex   = iterator->marker_pos = i;
00165             *resultCount= *endIndex - *startIndex + 1;
00166             break;
00167         }
00168     }
00169 
00170     return Ok;
00171 }
00172 
00173 GpStatus WINGDIPAPI GdipPathIterNextMarkerPath(GpPathIterator* iterator, INT* result,
00174     GpPath* path)
00175 {
00176     INT start, end;
00177 
00178     TRACE("(%p, %p, %p)\n", iterator, result, path);
00179 
00180     if(!iterator || !result)
00181         return InvalidParameter;
00182 
00183     GdipPathIterNextMarker(iterator, result, &start, &end);
00184     /* return path */
00185     if(((*result) > 0) && path){
00186         GdipResetPath(path);
00187 
00188         if(!lengthen_path(path, *result))
00189             return OutOfMemory;
00190 
00191         memcpy(path->pathdata.Points, &(iterator->pathdata.Points[start]), sizeof(GpPointF)*(*result));
00192         memcpy(path->pathdata.Types,  &(iterator->pathdata.Types[start]),  sizeof(BYTE)*(*result));
00193         path->pathdata.Count = *result;
00194     }
00195 
00196     return Ok;
00197 }
00198 
00199 GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator* iterator,
00200     INT *resultCount, INT* startIndex, INT* endIndex, BOOL* isClosed)
00201 {
00202     INT i, count;
00203 
00204     TRACE("(%p, %p, %p, %p, %p)\n", iterator, resultCount, startIndex,
00205            endIndex, isClosed);
00206 
00207     if(!iterator || !startIndex || !endIndex || !isClosed || !resultCount)
00208         return InvalidParameter;
00209 
00210     count = iterator->pathdata.Count;
00211 
00212     /* iterator created with NULL path */
00213     if(count == 0){
00214         *resultCount = 0;
00215         return Ok;
00216     }
00217 
00218     if(iterator->subpath_pos == count){
00219         *startIndex = *endIndex = *resultCount = 0;
00220         *isClosed = 1;
00221         return Ok;
00222     }
00223 
00224     *startIndex = iterator->subpath_pos;
00225 
00226     for(i = iterator->subpath_pos + 1; i < count &&
00227         !(iterator->pathdata.Types[i] == PathPointTypeStart); i++);
00228 
00229     *endIndex = i - 1;
00230     iterator->subpath_pos = i;
00231 
00232     *resultCount = *endIndex - *startIndex + 1;
00233 
00234     if(iterator->pathdata.Types[*endIndex] & PathPointTypeCloseSubpath)
00235         *isClosed = TRUE;
00236     else
00237         *isClosed = FALSE;
00238 
00239     return Ok;
00240 }
00241 GpStatus WINGDIPAPI GdipPathIterRewind(GpPathIterator *iterator)
00242 {
00243     TRACE("(%p)\n", iterator);
00244 
00245     if(!iterator)
00246         return InvalidParameter;
00247 
00248     iterator->subpath_pos = 0;
00249     iterator->marker_pos = 0;
00250     iterator->pathtype_pos = 0;
00251 
00252     return Ok;
00253 }
00254 
00255 GpStatus WINGDIPAPI GdipPathIterGetCount(GpPathIterator* iterator, INT* count)
00256 {
00257     TRACE("(%p, %p)\n", iterator, count);
00258 
00259     if(!iterator || !count)
00260         return InvalidParameter;
00261 
00262     *count = iterator->pathdata.Count;
00263 
00264     return Ok;
00265 }
00266 
00267 GpStatus WINGDIPAPI GdipPathIterEnumerate(GpPathIterator* iterator, INT* resultCount,
00268     GpPointF *points, BYTE *types, INT count)
00269 {
00270     TRACE("(%p, %p, %p, %p, %d)\n", iterator, resultCount, points, types, count);
00271 
00272     if((count < 0) || !resultCount)
00273         return InvalidParameter;
00274 
00275     if(count == 0){
00276         *resultCount = 0;
00277         return Ok;
00278     }
00279 
00280     return GdipPathIterCopyData(iterator, resultCount, points, types, 0, count-1);
00281 }
00282 
00283 GpStatus WINGDIPAPI GdipPathIterIsValid(GpPathIterator* iterator, BOOL* valid)
00284 {
00285     TRACE("(%p, %p)\n", iterator, valid);
00286 
00287     if(!iterator || !valid)
00288         return InvalidParameter;
00289 
00290     *valid = TRUE;
00291 
00292     return Ok;
00293 }
00294 
00295 GpStatus WINGDIPAPI GdipPathIterNextPathType(GpPathIterator* iter, INT* result,
00296     BYTE* type, INT* start, INT* end)
00297 {
00298     FIXME("(%p, %p, %p, %p, %p) stub\n", iter, result, type, start, end);
00299 
00300     if(!iter || !result || !type || !start || !end)
00301         return InvalidParameter;
00302 
00303     return NotImplemented;
00304 }
00305 
00306 GpStatus WINGDIPAPI GdipPathIterNextSubpathPath(GpPathIterator* iter, INT* result,
00307     GpPath* path, BOOL* closed)
00308 {
00309     INT start, end;
00310 
00311     TRACE("(%p, %p, %p, %p)\n", iter, result, path, closed);
00312 
00313     if(!iter || !result || !closed)
00314         return InvalidParameter;
00315 
00316     GdipPathIterNextSubpath(iter, result, &start, &end, closed);
00317     /* return path */
00318     if(((*result) > 0) && path){
00319         GdipResetPath(path);
00320 
00321         if(!lengthen_path(path, *result))
00322             return OutOfMemory;
00323 
00324         memcpy(path->pathdata.Points, &(iter->pathdata.Points[start]), sizeof(GpPointF)*(*result));
00325         memcpy(path->pathdata.Types,  &(iter->pathdata.Types[start]),  sizeof(BYTE)*(*result));
00326         path->pathdata.Count = *result;
00327     }
00328 
00329     return Ok;
00330 }

Generated on Sun May 27 2012 04:23:36 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.