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 "PathContainer.h" 12 #include "VectorPath.h" 13 14 // constructor 15 PathSource::PathSource(PathContainer* paths) 16 : VertexSource() 17 , fPaths(paths) 18 , fAGGPath() 19 , fAGGCurvedPath(fAGGPath) 20 21 , fGlobalScale(1.0) 22 , fLastTransformerScale(1.0) 23 { 24 } 25 26 // destructor 27 PathSource::~PathSource() 28 { 29 } 30 31 // rewind 32 void 33 PathSource::rewind(unsigned path_id) 34 { 35 fAGGCurvedPath.rewind(path_id); 36 } 37 38 // vertex 39 unsigned 40 PathSource::vertex(double* x, double* y) 41 { 42 return fAGGCurvedPath.vertex(x, y); 43 } 44 45 // WantsOpenPaths 46 bool 47 PathSource::WantsOpenPaths() const 48 { 49 return false; 50 } 51 52 // ApproximationScale 53 double 54 PathSource::ApproximationScale() const 55 { 56 return 1.0; 57 } 58 59 // #pragma mark - 60 61 // Update 62 void 63 PathSource::Update(bool leavePathsOpen, double approximationScale) 64 { 65 fAGGPath.remove_all(); 66 67 int32 count = fPaths->CountPaths(); 68 for (int32 i = 0; i < count; i++) { 69 fPaths->PathAtFast(i)->GetAGGPathStorage(fAGGPath); 70 if (!leavePathsOpen) 71 fAGGPath.close_polygon(); 72 } 73 74 fLastTransformerScale = approximationScale; 75 fAGGCurvedPath.approximation_scale(fLastTransformerScale * fGlobalScale); 76 } 77 78 // SetGlobalScale 79 void 80 PathSource::SetGlobalScale(double scale) 81 { 82 fGlobalScale = scale; 83 fAGGCurvedPath.approximation_scale(fLastTransformerScale * fGlobalScale); 84 } 85 86