1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #include "PathSource.h" 10 11 #include "Container.h" 12 #include "VectorPath.h" 13 14 _USING_ICON_NAMESPACE 15 16 17 // constructor 18 PathSource::PathSource(Container<VectorPath>* paths) 19 : VertexSource() 20 , fPaths(paths) 21 , fAGGPath() 22 , fAGGCurvedPath(fAGGPath) 23 24 , fGlobalScale(1.0) 25 , fLastTransformerScale(1.0) 26 { 27 } 28 29 // destructor 30 PathSource::~PathSource() 31 { 32 } 33 34 // rewind 35 void 36 PathSource::rewind(unsigned path_id) 37 { 38 fAGGCurvedPath.rewind(path_id); 39 } 40 41 // vertex 42 unsigned 43 PathSource::vertex(double* x, double* y) 44 { 45 return fAGGCurvedPath.vertex(x, y); 46 } 47 48 // WantsOpenPaths 49 bool 50 PathSource::WantsOpenPaths() const 51 { 52 return false; 53 } 54 55 // ApproximationScale 56 double 57 PathSource::ApproximationScale() const 58 { 59 return 1.0; 60 } 61 62 // #pragma mark - 63 64 // Update 65 void 66 PathSource::Update(bool leavePathsOpen, double approximationScale) 67 { 68 fAGGPath.remove_all(); 69 70 int32 count = fPaths->CountItems(); 71 for (int32 i = 0; i < count; i++) { 72 fPaths->ItemAtFast(i)->GetAGGPathStorage(fAGGPath); 73 if (!leavePathsOpen) 74 fAGGPath.close_polygon(); 75 } 76 77 fLastTransformerScale = approximationScale; 78 fAGGCurvedPath.approximation_scale(fLastTransformerScale * fGlobalScale); 79 } 80 81 // SetGlobalScale 82 void 83 PathSource::SetGlobalScale(double scale) 84 { 85 fGlobalScale = scale; 86 fAGGCurvedPath.approximation_scale(fLastTransformerScale * fGlobalScale); 87 } 88 89