1/* 2 * Copyright 2023, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Zardshard 7 */ 8 9 10#include "CompoundStyleTransformer.h" 11 12#include <string.h> 13 14 15_USING_ICON_NAMESPACE 16 17 18CompoundStyleTransformer::CompoundStyleTransformer( 19 StyleTransformer** transformers, int32 count) 20 : 21 fTransformers(transformers), 22 fCount(count) 23{ 24} 25 26 27CompoundStyleTransformer::~CompoundStyleTransformer() 28{ 29 for (int i = 0; i < fCount; i++) 30 delete fTransformers[i]; 31 delete[] fTransformers; 32} 33 34 35void 36CompoundStyleTransformer::transform(double* x, double* y) const 37{ 38 for (int i = 0; i < fCount; i++) { 39 if (fTransformers[i] != NULL) 40 fTransformers[i]->transform(x, y); 41 } 42} 43 44 45void 46CompoundStyleTransformer::Invert() 47{ 48 // reverse order of pipeline 49 StyleTransformer* oldOrder[fCount]; 50 memcpy(oldOrder, fTransformers, fCount * sizeof(StyleTransformer*)); 51 for (int i = 0; i < fCount; i++) { 52 fTransformers[fCount-i-1] = oldOrder[i]; 53 } 54 55 // invert individual transformations 56 for (int i = 0; i < fCount; i++) { 57 if (fTransformers[i] != NULL) 58 fTransformers[i]->Invert(); 59 } 60} 61 62 63bool 64CompoundStyleTransformer::IsLinear() 65{ 66 bool linear = true; 67 for (int i = 0; i < fCount; i++) { 68 if (fTransformers[i] != NULL) 69 linear &= fTransformers[i]->IsLinear(); 70 } 71 return linear; 72} 73